I wondered where linux get information about memory capacity in the machine. In i386 machine, we can get information from BIOS or e820 which is shorthand for BIOS function name. You can find some information from whikipedia : http://en.wikipedia.org/wiki/E820
Anyway, after checking basic memory map information, kernel call following function to get max_pfn value.
868/* 869 * Find the highest page frame number we have available 870 */ 871void __init find_max_pfn(void) 872{ 873 int i; 874 875 max_pfn = 0; 876 if (efi_enabled) { 877 efi_memmap_walk(efi_find_max_pfn, &max_pfn); 878 return; 879 } 880 881 for (i = 0; i < e820.nr_map; i++) { 882 unsigned long start, end; 883 /* RAM? */ 884 if (e820.map[i].type != E820_RAM) 885 continue; 886 start = PFN_UP(e820.map[i].addr); 887 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size); 888 if (start >= end) 889 continue; 890 if (end > max_pfn) 891 max_pfn = end; 892 } 893}
Leave a Reply