- 4K pages are used
- Cores' boot time stack pointer is placed at 4M, 6M, 8M, 10M
0xFC000000 and above ( > 3G960M) devices
0x40000000 - 0xFC000000 (1G ~ 3G960M) free
0x38400000 - 0x40000000 (948M ~ 1G) VC used
0x00000000 - 0x38400000 (0 ~ 948M) free
The kernel is loaded at address 0x00080000 (512K), currently the image is ~40K, avoid using the memory region < 1M should be good now.
get_free_page()
allocates physical frames from 1G upwards to 3G960M
To setup virtual memory, start by mapping the first 2M of memory identically and map all 4G of physical RAM to virtual address starting from 0xffff000000000000
, turn on MMU then branch to high address (must relocate the of the high address).
map property | PA start | PA end | VA start | VA end | flags |
---|---|---|---|---|---|
identity | 0x0 |
0x1000000 (16M) |
0x0 |
0x1000000 (16M) |
normal-nc |
high address first part | 0x0 |
0x3B400000 (948M) |
0xffff000000000000 |
0xffff00003B400000 |
normal-nc |
high address vc | 0x3B400000 |
0x40000000 (1G) |
0xffff00003B400000 |
0xffff000040000000 |
no map |
high address second part | 0x40000000 |
0xFC000000 (3G960M) |
0xffff000040000000 |
0xffff0000FC000000 |
normal-nc |
high address device | 0xFC000000 |
0x100000000 (4G) |
0xffff0000FC000000 |
0xffff000100000000 |
device |
copy_process
allocates a page for the process's task_struct
and kernel stack, then copy_virt_memory
is called which loops with allocate_user_page
which allocates pages used for the page tables and user code/data.
Because of PC-relative addressing, KERNEL_START
macro should still work after moving to high address, but some help is needed when we load the high address.
Because we don't have storage support, the only way for user programs to work is to link it inside the kernel image, but this also causes the ksyms to include symbols in user space. Later on it might be possible to compile kernel and user code separately, stick them together raw, and load it as the "kernel image".
Short for kernel symbols, used by tracing, main purpose is to be able to translate addresses to symbol names in runtime.
_symbols
: section name for the symbol areasrc/symbol_area.S
: assembly file generated after the first pass, containing formatednm
output, to be linked in in the second passksyms
: the symbol which code accesses, it is the start of the symbol area
syms_values.symbol_area_file
has to be under thesrc/
directory- Is
bss_end
section close to the limit of theadr
instruction at the start of the booting process? - There are two copies of output formating code for MiniUART and PL011UART
- In
sysregs.h
, some values use theBIT(x)
macro, some don't
python3
, for symbol generationnm
(both native and cross compiling version should work)