diff options
Diffstat (limited to 'kernel/entry.S')
-rw-r--r-- | kernel/entry.S | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/kernel/entry.S b/kernel/entry.S new file mode 100644 index 0000000..ef5a56a --- /dev/null +++ b/kernel/entry.S @@ -0,0 +1,26 @@ + # qemu -kernel starts at 0x1000. the instructions + # there seem to be provided by qemu, as if it + # were a ROM. the code at 0x1000 jumps to + # 0x8000000, the _start function here, + # in machine mode. each CPU starts here. +.section .data +.globl stack0 +.section .text +.globl start +.section .text +.globl _entry +_entry: + # set up a stack for C. + # stack0 is declared in start.c, + # with a 4096-byte stack per CPU. + # sp = stack0 + (hartid * 4096) + la sp, stack0 + li a0, 1024*4 + csrr a1, mhartid + addi a1, a1, 1 + mul a0, a0, a1 + add sp, sp, a0 + # jump to start() in start.c + call start +junk: + j junk |