Hi, I am modifying GRUB for a Linux LiveOS, which boots into separate images depends on how much RAM presents on the system. GRUB has a memory map initialized, so I think it is relatively easy to do so.
However, I discovered this method only works on EFI systems, if I load it on i386-pc (not a real i386 PC, just using BIOS to boot), the memory usage returns 0. Here's my code[1]: grub-core/commands/phymem.c grub_uint64_t total_mem_bytes = 0ULL; static int traverse_mmap_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, void *data __attribute__ ((unused))) { total_mem_bytes += size; } grub_err_t grub_cmd_phymem (...) { grub_mmap_iterate (traverse_mmap_hook, NULL); } Then I convert the integer into a string and export to the environment variables, and print it out. On EFI systems, I can get the correct amount of system memory: grub> insmod phymem grub> phymem The total system memory is 16384 MiB. However on BIOS systems, the result is zero: grub> insmod phymem grub> phymem The total system memory is 0 MiB. So, how can I detect the amount if RAM on non-EFI systems? If I recalled it right, GRUB can boot kernels which complies with Multiboot specification, so the memory info should be always present. If I missed something, please point it out. Thanks, Cinhi Young _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel