Hello every one.
I want to setup a memory manager but it seems that I should get some information from grub with a pointer in ebx. But I don't know how. I have read the wiki tutorial but I don't understand it. There is another multiboot structure in http://www.gnu.org/software/grub/manual ... n%20format and as you see it's different from that multiboot.h file in the wiki (Or may not). I just want to know how do I get the size of my kernel and it's position and reserved memory areas for BIOS and others and get the total size of memory
I will appreciate if anyone could help
Multiboot information
Re: Multiboot information
The main issue is that some versions of the header have slightly different (additional) fields.
Examples: APM info, ELF info, AOUT info, VBE info etc etc.
The important thing in the early stage is usually just the memory map and modules:
If you lack the ability (not trying to be condescending) to convert an address passed in %ebx to a struct pointer, you need to relook at your skills in C, especially pointer magic.
EDIT:
Firstly, you want to get the E820 memory map: get a pointer to a MemoryMap_type struct from Info->mmap_addr.
You should read some tutorials on parsing the GRUB memory map, it's fairly trivial.
Then you'd have the complete memory map: 0x00 to 0x9FC00 is usually free (as GRUB says, but the real-mode IVT, BDA and EBDA is there). 0xA0000 to 0x100000 is usually reserved for the video memory.
Anything beyond that should be free memory, minus some memory-mapped device address space at the top of the address space.
As for your kernel's size, I'm not sure how to get that -- you might want to look into the ELF or AOUT fields of the multiboot header.
A quick workaround would be to place a symbol at the end of your linker script and that in C.
As for me, I'd just read my kernel executable off the disk. :p
Examples: APM info, ELF info, AOUT info, VBE info etc etc.
The important thing in the early stage is usually just the memory map and modules:
Code: Select all
struct Info_type
{
uint32_t flags, mem_lower, mem_upper, boot_device, cmdline, mods_count, mods_addr;
uint32_t num, size, addr, shndx;
uint32_t mmap_length, mmap_addr;
};
struct Module_type { uint32_t mod_start, mod_end, string, reserved; };
struct MemoryMap_type
{
uint32_t Size;
uint32_t BaseAddr_Low;
uint32_t BaseAddr_High;
uint32_t Length_Low;
uint32_t Length_High;
uint32_t Type;
};
EDIT:
Firstly, you want to get the E820 memory map: get a pointer to a MemoryMap_type struct from Info->mmap_addr.
You should read some tutorials on parsing the GRUB memory map, it's fairly trivial.
Then you'd have the complete memory map: 0x00 to 0x9FC00 is usually free (as GRUB says, but the real-mode IVT, BDA and EBDA is there). 0xA0000 to 0x100000 is usually reserved for the video memory.
Anything beyond that should be free memory, minus some memory-mapped device address space at the top of the address space.
As for your kernel's size, I'm not sure how to get that -- you might want to look into the ELF or AOUT fields of the multiboot header.
A quick workaround would be to place a symbol at the end of your linker script and
Code: Select all
extern
As for me, I'd just read my kernel executable off the disk. :p
[nx] kernel: http://github.com/zhiayang/nx
Re: Multiboot information
Okay thanks I got it working. It wasn't too hard
But I guess that I can get the kernel information from the ELF and AOUT structures
But I guess that I can get the kernel information from the ELF and AOUT structures