在setup_arch()中: 1. parse_cmdline(): 根據uboot傳遞的mem資訊,調用early_mem()通過arm_add_memory()把實體記憶體資訊添加到meminfo結構體中。 2. paging_init(): 這個就是關鍵的初始化頁表的函數,在裡面會調用bootmem_init()->bootmem_init_node()->map_memory_bank(),在這裡會根據meminfo的資訊調用create_mapping()來為實體記憶體建立核心空間的映射,一般是從0xc0000000開始。下面是arm linux的虛擬位址映射表: Start End Use
--------------------------------------------------------------------------
ffff8000 ffffffff copy_user_page / clear_user_page use.
ffff1000 ffff7fff Reserved.
ffff0000 ffff0fff CPU vector page.
The CPU vectors are mapped here if the CPU supports vector relocation (control
register V bit.) ffc00000 fffeffff DMA memory mapping region. Memory returned by the dma_alloc_xxx functions will be dynamically mapped here. ff000000 ffbfffff Reserved for future expansion of DMA mapping region. VMALLOC_END feffffff Free for platform use, recommended.
VMALLOC_END must be aligned to a 2MB
boundary. VMALLOC_START VMALLOC_END-1 vmalloc() / ioremap() space.
Memory returned by vmalloc/ioremap will
be dynamically placed in this region.
VMALLOC_START may be based upon the value
of the high_memory variable. PAGE_OFFSET high_memory-1 Kernel direct-mapped RAM region.
This maps the platforms RAM, and typically
maps all platform RAM in a 1:1 relationship. TASK_SIZE PAGE_OFFSET-1 Kernel module space
Kernel modules inserted via insmod are
placed here using dynamic mappings. 00001000 TASK_SIZE-1 User space mappings
Per-thread mappings are placed here via
the mmap() system call. 00000000 00000fff CPU vector page / null pointer trap
CPUs which do not support vector remapping
place their vector page here. NULL pointer
dereferences by both the kernel and user
space are also caught via this mapping.雖然後面這個表我不知道什麼意思,但是上面的對我還是蠻有用的,至少我知道了,實體記憶體是如何映射到核心空間的。