假如内存的物理起始地址为:0x30000000, 大小为:0x1000000
void __init reserve_node_zero(pg_data_t *pgdat)
{
unsigned long res_size = 0;
/*
* Register the kernel text and data with bootmem.
* Note that this can only be in node 0.
*/
#ifdef CONFIG_XIP_KERNEL
...
#else
//start=0x30008 end=0x30431
reserve_bootmem_node(pgdat, __pa(_stext), _end - _stext,
BOOTMEM_DEFAULT);
#endif
/*
* Reserve the page tables. These are already in use,
* and can only be in node 0.
*/
//start=0x30004 end=0x30008
reserve_bootmem_node(pgdat, __pa(swapper_pg_dir),
PTRS_PER_PGD * sizeof(pgd_t), BOOTMEM_DEFAULT);
...
...
...
}
该函数其实只是两次调用了reserve_bootmem_node函数。
reserve_bootmem_node函数前面已经分析过了。
所以reserve_node_zero函数的主要工作为:
1,为Kernel保存内存空间,将相应位图标志置1
2,为pgd保存内存空间,将相应位图标志置1