Page 1 of 1

failure when loading modules with grub

Posted: Sun Nov 02, 2008 9:56 am
by xDDunce
ok, so this is the first time i've been stuck for a while now, and with very good reason to be.

I have recently tried loading a module with grub (soon to become loading a basic file system and all that) but whenever i load a module (just one) the multiboot structure does not like it. it appears that the boot->mods_count and boot->mods_address are just filled with 0xFFFFFFFF and so i have no idea what to do next. i have an exact copy of the multiboot structure from James M's tutorial and am following his way of finding the module in memory.

my code, which involves the module, is only reading from the multiboot structure and is printing the addresses to the screen. it looks like this:

Code: Select all

ASSERT(boot->mods_count > 0);
    puts("modules address = ");
    puthex((*(unsigned int*)boot->mods_addr));
    puts("\nmodules count = ");
    puthex(*(unsigned int*)(boot->mods_count));
    puts("\n\n");
    read_vfs(boot);
th assert returns fine but the hex values passed to puthex() seem to be corrupted. read_vfs(boot); only gives placement address the end address of the kernel and enables paging for the moment.

so what could the error be? i can post more code if you need it, but most of it is just the multiboot structure which can be found on JamesM's site.

thanks in advance!

James.

Re: failure when loading modules with grub

Posted: Sun Nov 02, 2008 10:20 am
by eddyb
you sould remove the *(unsigned int*) part. it makes some pointers.
let me explain: let's say the mods_count value is 2 (there are 2 modules).if you add that pointer stuff, it will understand to use the value at address 2, which may be 0xFFFFFFFF.

Re: failure when loading modules with grub

Posted: Sun Nov 02, 2008 10:26 am
by xDDunce
thanks for the quick reply, but it's still not working.

although im not given 0xFFFFFFFF anymore, they are both still the same, and are 0xF000FF53

i guess im getting closer, seeing as they are shrinking :lol:

any more ideas?

thanks in advance.

James.

Re: failure when loading modules with grub

Posted: Sun Nov 02, 2008 11:02 am
by ru2aqare
johnsy2008 wrote:thanks for the quick reply, but it's still not working.

although im not given 0xFFFFFFFF anymore, they are both still the same, and are 0xF000FF53

i guess im getting closer, seeing as they are shrinking :lol:

any more ideas?

thanks in advance.

James.
This is looks like you are dereferencing a null pointer. Change your assert to test first that the pointer is valid.
The reason this looks like a null pointer is that the divide-by-zero handler is located at F000:FF53 in the Bochs BIOS.

Re: failure when loading modules with grub

Posted: Sun Nov 02, 2008 11:53 am
by xDDunce
ah, so that is my problem. i just did ASSERT(boot); and it fails (meaning it is equal to 0)

so... how can i fix it? is this not an error on GRUB's side? as it passes the pointer to my kernel?

thanks for the help! this has realy clarified things for me :D

Re: failure when loading modules with grub

Posted: Sun Nov 02, 2008 1:02 pm
by ru2aqare
johnsy2008 wrote:so... how can i fix it? is this not an error on GRUB's side? as it passes the pointer to my kernel?
I don't know - I never used GRUB before. Are you sure your stack is correct at the entry point? Maybe placing a breakpoing on the entry point in the Bochs debugger helps clearing up what goes wrong.

Re: failure when loading modules with grub

Posted: Mon Nov 03, 2008 8:28 am
by xDDunce
ok, ive fixed it now, i think it was just a few mistakes in typing here and there. i have noticed a new problem though, but i will post a new topic as it is unrelated to this error.

thanks for all the help!

James.