···2021static int detect_memory_e820(void)22{023 u32 next = 0;24 u32 size, id;25 u8 err;···34 "=m" (*desc)35 : "D" (desc), "a" (0xe820));3637- if (err || id != SMAP)000000000038 break;3940- boot_params.e820_entries++;41 desc++;42- } while (next && boot_params.e820_entries < E820MAX);4344- return boot_params.e820_entries;45}4647static int detect_memory_e801(void)···100101int detect_memory(void)102{00103 if (detect_memory_e820() > 0)104- return 0;105106 if (!detect_memory_e801())107- return 0;108109- return detect_memory_88();000110}
···2021static int detect_memory_e820(void)22{23+ int count = 0;24 u32 next = 0;25 u32 size, id;26 u8 err;···33 "=m" (*desc)34 : "D" (desc), "a" (0xe820));3536+ /* Some BIOSes stop returning SMAP in the middle of37+ the search loop. We don't know exactly how the BIOS38+ screwed up the map at that point, we might have a39+ partial map, the full map, or complete garbage, so40+ just return failure. */41+ if (id != SMAP) {42+ count = 0;43+ break;44+ }45+46+ if (err)47 break;4849+ count++;50 desc++;51+ } while (next && count < E820MAX);5253+ return boot_params.e820_entries = count;54}5556static int detect_memory_e801(void)···8990int detect_memory(void)91{92+ int err = -1;93+94 if (detect_memory_e820() > 0)95+ err = 0;9697 if (!detect_memory_e801())98+ err = 0;99100+ if (!detect_memory_88())101+ err = 0;102+103+ return err;104}