2.6 Code: starting xv6, the first process and system call
# boot
1. boot loader
2. boot loader 把 xv6 kernal 搬到 memory
3. 在 machine mode,CPU 開始執行 `kernel/entry.S: _entryo`
* 直接使用 physical address
loader 把 xv6 kernel 放到 0x80000000
kernel 放到 0x80000000 是因為較低的 memory 位置 0x0 ~ 0x80000000 包含了 I/O devices
有點看不懂這裡是在做什麼:
```asm=
# qemu -kernel loads the kernel at 0x80000000
# and causes each hart (i.e. CPU) to jump there.
# kernel.ld causes the following code to
# be placed at 0x80000000.
.section .text
.global _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
spin:
j spin
```
## reference
[2.6 Code: starting xv6, the first process and system call](https://pdos.csail.mit.edu/6.S081/2022/xv6/book-riscv-rev3.pdf)