failure when loading modules with 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
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

failure when loading modules with grub

Post 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.
eddyb
Member
Member
Posts: 248
Joined: Fri Aug 01, 2008 7:52 am

Re: failure when loading modules with grub

Post 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.
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: failure when loading modules with grub

Post 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.
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: failure when loading modules with grub

Post 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.
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: failure when loading modules with grub

Post 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
ru2aqare
Member
Member
Posts: 342
Joined: Fri Jul 11, 2008 5:15 am
Location: Hungary

Re: failure when loading modules with grub

Post 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.
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: failure when loading modules with grub

Post 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.
Post Reply