Upper Memory GRUB

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.
Post Reply
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Upper Memory GRUB

Post 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
Free energy is indeed evil for it absorbs the light.
blound
Member
Member
Posts: 70
Joined: Sat Dec 01, 2007 1:36 pm

Re: Upper Memory GRUB

Post by blound »

you should at least tell us how much ram the emulator or machine you are booting on has...
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Upper Memory GRUB

Post by Omega »

MS Virtual PC reports 128 MB RAM.
Free energy is indeed evil for it absorbs the light.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Upper Memory GRUB

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Upper Memory GRUB

Post by Combuster »

Its looks like (part of) an ascii string...
1296130921 = 69 63 41 4D = "icAM"

do you have your struct offsets right?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Upper Memory GRUB

Post 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.
Free energy is indeed evil for it absorbs the light.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Upper Memory GRUB

Post 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?
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Upper Memory GRUB

Post by Omega »

There is no sense in polishing a turd. ;)
Free energy is indeed evil for it absorbs the light.
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Upper Memory GRUB

Post 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.
Free energy is indeed evil for it absorbs the light.
User avatar
finarfin
Member
Member
Posts: 106
Joined: Fri Feb 23, 2007 1:41 am
Location: Italy & Ireland
Contact:

Re: Upper Memory GRUB

Post 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 ^_^
Elen síla lúmenn' omentielvo
- DreamOS64 - My latest attempt with osdev: https://github.com/dreamos82/Dreamos64
- Osdev Notes - My notes about osdeving! https://github.com/dreamos82/Osdev-Notes
- My old Os Project: https://github.com/dreamos82/DreamOs
User avatar
Omega
Member
Member
Posts: 250
Joined: Sun May 25, 2008 2:04 am
Location: United States
Contact:

Re: Upper Memory GRUB

Post 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
Free energy is indeed evil for it absorbs the light.
Post Reply