17 changed files with 40 additions and 289 deletions
@ -0,0 +1,22 @@ |
|||||
|
#include "mcall.h" |
||||
|
|
||||
|
.section ".text.init" |
||||
|
.globl _start |
||||
|
_start: |
||||
|
la s0, str |
||||
|
1: |
||||
|
lbu a0, (s0) |
||||
|
beqz a0, 1f |
||||
|
li a7, MCALL_CONSOLE_PUTCHAR |
||||
|
ecall |
||||
|
add s0, s0, 1 |
||||
|
j 1b |
||||
|
|
||||
|
1: |
||||
|
li a7, MCALL_SHUTDOWN |
||||
|
ecall |
||||
|
|
||||
|
.data |
||||
|
str: |
||||
|
.asciz "This is bbl's dummy_payload. To boot a real kernel, reconfigure\n\ |
||||
|
bbl with the flag --with-payload=PATH, then rebuild bbl.\n" |
||||
@ -1,21 +0,0 @@ |
|||||
#include <stdint.h> |
|
||||
#include "sbi.h" |
|
||||
|
|
||||
asm (".globl _start\n\
|
|
||||
_start: la sp, stack\n\ |
|
||||
j entry\n\ |
|
||||
.pushsection .rodata\n\ |
|
||||
.align 4\n\ |
|
||||
.skip 4096\n\ |
|
||||
stack:\n\ |
|
||||
.popsection"); |
|
||||
|
|
||||
void entry() |
|
||||
{ |
|
||||
const char* message = |
|
||||
"This is bbl's dummy_payload. To boot a real kernel, reconfigure\n\
|
|
||||
bbl with the flag --with-payload=PATH, then rebuild bbl.\n"; |
|
||||
while (*message) |
|
||||
sbi_console_putchar(*message++); |
|
||||
sbi_shutdown(); |
|
||||
} |
|
||||
@ -1,3 +1,7 @@ |
|||||
|
ENTRY(_start) |
||||
|
|
||||
SECTIONS { |
SECTIONS { |
||||
. = -0x80000000; |
. = -0x80000000; |
||||
|
|
||||
|
.text.init : { *(.text.init) } |
||||
} |
} |
||||
|
|||||
@ -1 +0,0 @@ |
|||||
../machine/sbi.S |
|
||||
@ -1,15 +0,0 @@ |
|||||
.globl sbi_hart_id; sbi_hart_id = -2048 |
|
||||
.globl sbi_num_harts; sbi_num_harts = -2032 |
|
||||
.globl sbi_query_memory; sbi_query_memory = -2016 |
|
||||
.globl sbi_console_putchar; sbi_console_putchar = -2000 |
|
||||
.globl sbi_console_getchar; sbi_console_getchar = -1984 |
|
||||
.globl sbi_send_ipi; sbi_send_ipi = -1952 |
|
||||
.globl sbi_clear_ipi; sbi_clear_ipi = -1936 |
|
||||
.globl sbi_timebase; sbi_timebase = -1920 |
|
||||
.globl sbi_shutdown; sbi_shutdown = -1904 |
|
||||
.globl sbi_set_timer; sbi_set_timer = -1888 |
|
||||
.globl sbi_mask_interrupt; sbi_mask_interrupt = -1872 |
|
||||
.globl sbi_unmask_interrupt; sbi_unmask_interrupt = -1856 |
|
||||
.globl sbi_remote_sfence_vm; sbi_remote_sfence_vm = -1840 |
|
||||
.globl sbi_remote_sfence_vm_range; sbi_remote_sfence_vm_range = -1824 |
|
||||
.globl sbi_remote_fence_i; sbi_remote_fence_i = -1808 |
|
||||
@ -1,30 +0,0 @@ |
|||||
#ifndef _ASM_RISCV_SBI_H |
|
||||
#define _ASM_RISCV_SBI_H |
|
||||
|
|
||||
typedef struct { |
|
||||
unsigned long base; |
|
||||
unsigned long size; |
|
||||
unsigned long node_id; |
|
||||
} memory_block_info; |
|
||||
|
|
||||
unsigned long sbi_query_memory(unsigned long id, memory_block_info *p); |
|
||||
|
|
||||
unsigned long sbi_hart_id(void); |
|
||||
unsigned long sbi_num_harts(void); |
|
||||
unsigned long sbi_timebase(void); |
|
||||
void sbi_set_timer(unsigned long long stime_value); |
|
||||
void sbi_send_ipi(unsigned long hart_id); |
|
||||
unsigned long sbi_clear_ipi(void); |
|
||||
void sbi_shutdown(void); |
|
||||
|
|
||||
void sbi_console_putchar(unsigned char ch); |
|
||||
int sbi_console_getchar(void); |
|
||||
|
|
||||
void sbi_remote_sfence_vm(unsigned long hart_mask_ptr, unsigned long asid); |
|
||||
void sbi_remote_sfence_vm_range(unsigned long hart_mask_ptr, unsigned long asid, unsigned long start, unsigned long size); |
|
||||
void sbi_remote_fence_i(unsigned long hart_mask_ptr); |
|
||||
|
|
||||
unsigned long sbi_mask_interrupt(unsigned long which); |
|
||||
unsigned long sbi_unmask_interrupt(unsigned long which); |
|
||||
|
|
||||
#endif |
|
||||
@ -1,111 +0,0 @@ |
|||||
#include "encoding.h" |
|
||||
#include "mcall.h" |
|
||||
|
|
||||
.section .sbi,"ax",@progbits |
|
||||
.option norvc |
|
||||
.align RISCV_PGSHIFT |
|
||||
.globl sbi_base |
|
||||
sbi_base: |
|
||||
|
|
||||
# TODO: figure out something better to do with this space. It's not |
|
||||
# protected from the OS, so beware. |
|
||||
.skip RISCV_PGSIZE - 2048 |
|
||||
|
|
||||
# hart_id |
|
||||
.align 4 |
|
||||
li a7, MCALL_HART_ID |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# num_harts |
|
||||
.align 4 |
|
||||
lw a0, num_harts |
|
||||
ret |
|
||||
|
|
||||
# query_memory |
|
||||
.align 4 |
|
||||
tail __sbi_query_memory |
|
||||
|
|
||||
# console_putchar |
|
||||
.align 4 |
|
||||
li a7, MCALL_CONSOLE_PUTCHAR |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# console_getchar |
|
||||
.align 4 |
|
||||
li a7, MCALL_CONSOLE_GETCHAR |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# empty |
|
||||
.align 4 |
|
||||
unimp |
|
||||
|
|
||||
# send ipi |
|
||||
.align 4 |
|
||||
li a7, MCALL_SEND_IPI |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# clear ipi |
|
||||
.align 4 |
|
||||
li a7, MCALL_CLEAR_IPI |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# timebase |
|
||||
.align 4 |
|
||||
li a0, 10000000 # or, you know, we could provide the correct answer |
|
||||
ret |
|
||||
|
|
||||
# shutdown |
|
||||
.align 4 |
|
||||
li a7, MCALL_SHUTDOWN |
|
||||
ecall |
|
||||
|
|
||||
# set_timer |
|
||||
.align 4 |
|
||||
li a7, MCALL_SET_TIMER |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# mask_interrupt |
|
||||
.align 4 |
|
||||
tail __sbi_mask_interrupt |
|
||||
|
|
||||
# unmask_interrupt |
|
||||
.align 4 |
|
||||
tail __sbi_unmask_interrupt |
|
||||
|
|
||||
# remote_sfence_vm |
|
||||
.align 4 |
|
||||
li a7, MCALL_REMOTE_SFENCE_VM |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# remote_sfence_vm_range |
|
||||
.align 4 |
|
||||
li a7, MCALL_REMOTE_SFENCE_VM |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# remote_fence_i |
|
||||
.align 4 |
|
||||
li a7, MCALL_REMOTE_FENCE_I |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
# end of SBI trampolines |
|
||||
|
|
||||
.globl do_mcall |
|
||||
do_mcall: |
|
||||
mv a7, a0 |
|
||||
mv a0, a1 |
|
||||
mv a1, a2 |
|
||||
ecall |
|
||||
ret |
|
||||
|
|
||||
.align RISCV_PGSHIFT |
|
||||
.globl _sbi_end |
|
||||
_sbi_end: |
|
||||
@ -1,33 +0,0 @@ |
|||||
#include "mtrap.h" |
|
||||
#include "sbi.h" |
|
||||
|
|
||||
uintptr_t __sbi_query_memory(uintptr_t id, memory_block_info *p) |
|
||||
{ |
|
||||
if (id == 0) { |
|
||||
p->base = first_free_paddr; |
|
||||
p->size = mem_size + DRAM_BASE - p->base; |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
return -1; |
|
||||
} |
|
||||
|
|
||||
#define LOW_IRQ_OK(n) ((n) == IRQ_S_SOFT || (n) == IRQ_S_TIMER) |
|
||||
|
|
||||
uintptr_t __sbi_mask_interrupt(uintptr_t which) |
|
||||
{ |
|
||||
if (!LOW_IRQ_OK(which)) |
|
||||
return -1; |
|
||||
|
|
||||
clear_csr(sie, 1UL << which); |
|
||||
return 0; |
|
||||
} |
|
||||
|
|
||||
uintptr_t __sbi_unmask_interrupt(uintptr_t which) |
|
||||
{ |
|
||||
if (!LOW_IRQ_OK(which)) |
|
||||
return -1; |
|
||||
|
|
||||
set_csr(sie, 1UL << which); |
|
||||
return 0; |
|
||||
} |
|
||||
Loading…
Reference in new issue