Linux内核高-低端内存设置代码跟踪(ARM构架)
- void __init bootmem_init(void)
- {
unsigned long min, max_low, max_high; max_low = max_high = 0; find_limits(&min, &max_low, &max_high); arm_bootmem_init(min, max_low); /* * Sparsemem tries to allocate bootmem in memory_present(), * so must be done after the fixed reservations */ arm_memory_present(); /* * sparse_init() needs the bootmem allocator up and running. */ sparse_init(); /* * Now free the memory - free_area_init_node needs * the sparse mem_map arrays initialized by sparse_init() * for memmap_init_zone(), otherwise all PFNs are invalid. */ arm_bootmem_free(min, max_low, max_high); high_memory = __va(((phys_addr_t)max_low < PAGE_SHIFT) - 1) + 1; /* * This doesnt seem to be used by the Linux memory manager any * more, but is used by ll_rw_block. If we can get rid of it, we * also get rid of some of the stuff above as well. * * Note: max_low_pfn and max_pfn reflect the number of _pages_ in * the system, not the maximum PFN. */ max_low_pfn = max_low - PHYS_PFN_OFFSET; max_pfn = max_high - PHYS_PFN_OFFSET; - }
- static void __init find_limits(unsigned long
*min, unsigned long *max_low, unsigned long *max_high) - {
struct meminfo *mi = &meminfo; int i; *min = -1UL; *max_low = *max_high = 0; for_each_bank (i, mi) { struct membank *bank = &mi->bank[i]; unsigned long start, end; start = bank_pfn_start(bank); end = bank_pfn_end(bank); if (*min > start) *min = start; if (*max_high end) *max_high = end; if (bank->highmem) continue; if (*max_low < end) *max_low = end; } - }
- min :内存物理地址起始
- max_low :低端内存区物理地址末端
- max_high :高端内存区物理地址末端
- “如果这个内存bank是高端内存(bank->highmem != 0),跳过max_low = end;语句,max_low和max_high将不同(结果实际上是max_high >
max_low); - 否则假设没有一个内存bank是高端内存(所有bank->highmem == 0)max_low和max_high必然一致(高端内存大小为0)”
- struct meminfo meminfo;
- /*
* Memory map description */ - #define NR_BANKS 8
- struct membank {
phys_addr_t start; unsigned long size; unsigned int highmem; - };
- struct meminfo {
int nr_banks; struct membank bank[NR_BANKS]; - };
- extern struct meminfo meminfo;
- #define for_each_bank(iter,mi)
\ for (iter = 0; iter < (mi)->nr_banks; iter++)
Linux内核内存设置代码跟踪ARM构 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)