Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
so im working on the beginnings of a memory manager and I said to myself: "I need to get a picutre of how memory is right now before I can start managing it." So I decided I wanted to get my memory info from GRUB. Its fast, its easy. However I dont think im getting this correctly. Is there some sort of "expected" value that an inital memory map from grub is going to give me on an x86? im using the following code with mbd being the full multiboot info struct that grub passes. I actually dont have an intelligent printf() solution coded as of yet, so pardon my lots of puts, also my puts doesnt handle numbers well so far, so I have a long2char() function that does guess what?
typedef struct memory_map {
unsigned long size;
unsigned long base_addr_low;
unsigned long base_addr_high;
unsigned long length_low;
unsigned long length_high;
unsigned long type;
} memory_map_t;
I'd say you should read a bit more about pointers and the like. casting your memory_map into a void* to safely advance by "entry->size" is okay. casting it into an int (or unsigned, or long, or whatever) is weird, and extracting the int's address rather than casting the void* back into a memory_map_t* is just wrong.
well, i'd say use the bochs with debugger, set a breakpoint on your function (hint: use objdump -drS to find its address in your elf file), check the address you receive and inspect memory content over there to make sure it looks like what GRUB reported.
Then check you actually read the correct values with your code and that what's printed correspond to what's to be printed (e.g. have you debugged hex_to_str yet?)