Page 1 of 1

Upper Memory GRUB

Posted: Wed Jun 25, 2008 5:34 pm
by Omega
Hi. I may be wrong about this but I think I am returning a really high number for upper_mem: 1296130921

I was under the assumption that the return was going to be KB, but if that is KB, then that would be way too high even if it were bytes it would be too high? Am I right? Would be 1236.0867700576782 MB.

My code:

Code: Select all

typedef struct multiboot_info {
    unsigned long flags;
    unsigned long mem_lower;
    unsigned long mem_upper;
    unsigned long boot_device;
    unsigned long cmdline;
    unsigned long mods_count;
    unsigned long mods_addr;
    unsigned long mmap_length;
    unsigned long mmap_addr;
} multiboot_info_t;

multiboot_info_t *boot_info;

char str[32]={0};
itoa_s (boot_info->mem_upper,10,str);
printf(0x07, str, 1, 1);
Output: 1296130921

thanks

Re: Upper Memory GRUB

Posted: Wed Jun 25, 2008 6:50 pm
by blound
you should at least tell us how much ram the emulator or machine you are booting on has...

Re: Upper Memory GRUB

Posted: Wed Jun 25, 2008 8:07 pm
by Omega
MS Virtual PC reports 128 MB RAM.

Re: Upper Memory GRUB

Posted: Thu Jun 26, 2008 1:35 am
by JamesM
Have you sanity checked any of the other fields to make sure that (a) your itoa_s function is not broken and (b) you get the data you expect?

Try dumping the "flags" field and see if it's what you expect.

Re: Upper Memory GRUB

Posted: Thu Jun 26, 2008 2:18 am
by Combuster
Its looks like (part of) an ascii string...
1296130921 = 69 63 41 4D = "icAM"

do you have your struct offsets right?

Re: Upper Memory GRUB

Posted: Thu Jun 26, 2008 1:37 pm
by Omega
@Combuster: My man, you are a genius! It must be part of ASCII, because it looks a lot like what my CPUID would return: AuthenticAMD

It prints just icAM according to you so it must be part of that. I don't know about the offsets, they seem OK to me. I think I might just do the code for that stuff myself instead of relying on grub too much. I haven't got it to return anything correct since I started supporting that structure, so to the recycle bin it goes. Thanks anyway.

Re: Upper Memory GRUB

Posted: Thu Jun 26, 2008 1:45 pm
by JamesM
vst_0201 wrote:@Combuster: My man, you are a genius! It must be part of ASCII, because it looks a lot like what my CPUID would return: AuthenticAMD

It prints just icAM according to you so it must be part of that. I don't know about the offsets, they seem OK to me. I think I might just do the code for that stuff myself instead of relying on grub too much. I haven't got it to return anything correct since I started supporting that structure, so to the recycle bin it goes. Thanks anyway.
I would have thought the best solution would be to fix your problem, not abandon it. Who knows, you may learn something?

Re: Upper Memory GRUB

Posted: Thu Jun 26, 2008 1:50 pm
by Omega
There is no sense in polishing a turd. ;)

Re: Upper Memory GRUB

Posted: Sat Jun 28, 2008 1:14 am
by Omega
@JamesM: Your words haunted my conscience until I did this. When I said, "There is no sense in polishing a turd." I meant that there was no sense in fixing a broken implementation of my GRUB memory map display functionality. I simply did not have the energy nor the time to seek this any further when I was asked; however, just to show you I am not a stubborn mule, my results:
flags = 0x7c7
mem_lower = 639KB, mem_upper = 129984KB
boot_device = 0xffffff
cmdline = /kernel
mmap_addr = 0x2be84, mmap_length = 0xa8
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
size = 0x14, base_addr = 0x0fffc0000, length = 0x040000, type = 0x2
My initial attempt was minimal both in my loader and in my kernel. The result was a incomplete header, loader, and false returns. My new attempt resulted in a better developed printf, iota, putchar, and the results I intended initially. It goes to show that lack of persistence is surely a sin. Thanks.

Re: Upper Memory GRUB

Posted: Tue Jul 01, 2008 7:14 am
by finarfin
@vst_0201:
I had a similar problem in my OS, and i noticed the error was in my ld script (kernel.lds).

In my case, things didn't 'work because the
ENTRY(...)
line has a wrong content.

For make things work ENTRY(...) must point to "start:" routine label in grub, so:
ENTRY(start)

I hope it could be useful.

P.S. Again, sorry for my bad english ^_^

Re: Upper Memory GRUB

Posted: Tue Jul 01, 2008 7:25 pm
by Omega
That's what it was, it was with my global variable. I just went like this:

global start, _start
start:
_start:

and that seemed to do it. thanks