Thursday 15 March 2012

c++ - How to query BIOS using GRUB? -



c++ - How to query BIOS using GRUB? -

i trying create little kernel 80386 processor learning purpose , want total memory map of available ram.

i have read possible , improve help of grub straight querying bios.

can tell me how do ?

particularly, using bios functionality in real mode utilize bios interrupts , desired values in registers , actual equivalent way when want utilize grub provided functions ?

here process utilize in kernel (note 32bit). in bootstrap assembly file, tell grub provide me memory map:

.set meminfo, 1 << 1 # memory map grub

then, grub loads address of multiboot info construction ebx (this construction contains address of memory map). phone call c code handle actual iteration , processing of memory map. iterate on map:

/* macro next entry in memory map */ #define mmap_next(m) \ (multiboot_memory_map_t*)((uint32_t)m + m->size + sizeof(uint32_t)) void read_mmap(multiboot_info_t* mbt){ multiboot_memory_map_t* mmap = (multiboot_memory_map_t*) mbt->mmap_addr; /* iterate on memory map */ while((uint32_t)mmap < mbt->mmap_addr + mbt->mmap_length) { // process current memory map entry mmap = mmap_next(mmap); } }

where multiboot_info_t , multiboot_memory_map_t defined in gnu multiboot.h file. andrew medico posted in comments, here great link getting started this.

c++ c kernel bios grub

No comments:

Post a Comment