I'm trying to get into memory management in my OS, but I obviously need to detect the RAM first. I followed http://wiki.osdev.org/Detecting_Memory_%28x86%29, but I get this:
I would suspect that some variable somewhere went uninitialized, but I can't seem to find it.
Here is my main function and uitoa (unsigned int to ascii) function:
Code: Select all
int main(multiboot_info_t* mbt, unsigned int magic)
{
multiboot_memory_map_t* mmap = mbt->mmap_addr;
while ((unsigned int)mmap < mbt->mmap_addr + mbt->mmap_length) {
mmap = (multiboot_memory_map_t*) ((unsigned int)mmap + mmap->size + sizeof(unsigned int));
}
/* irrelevant code removed */
unsigned char atest[20] = { 0 };
uitoa(mmap->length_low, atest);
puts(atest);
puts(" + ");
uitoa(mmap->length_high, atest);
puts(atest);
puts(" RAM available");
...
}
void uitoa(unsigned int value, unsigned char number[])
{
unsigned char t[12];
int i, j;
i = 0;
do {
number[i++] = value % 10 + '0';
} while ((value /= 10) > 0);
number[i] = '\0';
strcpy(t, number);
for (i = 0, j = strlen(number) - 1; j >= 0; i++, j--)
{
number[i] = *(t + j);
}
}