Basic initialization
RPI 上的 GPU 會將 kernel8.img 載入到 RAM (預設位於 0x80000
),之後 4 個 CPU 會同時跑 kernel code,在這邊為了簡單一點,所以只希望只有一個 core 在跑。
需求:
- Let only one core proceed, and let others enter a busy loop.
- Initialize the BSS segment.
- Set the stack pointer to an appropriate position.
start.s
我將 Lab 0 的 main.s
改名為 start.s
,用於跑開機後的初始化流程,最後會跳到 main.c
定義的 main function。
|
|
mrs: Move to ARM register from system coprocessor register
linker.ld
Linker Script 也做了些微的修改,將 .text.boot
固定放在 0x80000
後,確保開機跑的是對的 code。
|
|
KEEP: Mark sections that should not be eliminated when link-time garbage collection is in use (Ref: Input Section and Garbage Collection)
NOLOAD: Mark a section to not be loaded at run time. (Ref: Optional Section Attributes)
ALIGN: 對齊到數字的倍數