OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 6:17 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: GRUB modules?
PostPosted: Mon May 08, 2006 11:19 am 
Offline
Member
Member

Joined: Sat Jun 24, 2006 4:40 pm
Posts: 140
Location: Falkirk, Scotland
Could anyone tell me what GRUB does with files you specify as 'modules' for it to load?

It sounds like it could possibly be handy for keymaps (in the beginning, anyway), possibly drivers - and maybe loading some simply tasks to test multitasking before writing floppy drivers.

_________________
Regards,
Angus [Óengus] 'Midas' Lepper


Top
 Profile  
 
 Post subject: Re:GRUB modules?
PostPosted: Mon May 08, 2006 11:28 am 
Midas wrote:
Could anyone tell me what GRUB does with files you specify as 'modules' for it to load?


This thread probably gives you some insight.

Midas wrote:
It sounds like it could possibly be handy for keymaps (in the beginning, anyway), possibly drivers - and maybe loading some simply tasks to test multitasking before writing floppy drivers.


Exactly, that's the point of multiboot modules. ;) I plan to use them excessively, for exactly those purposes.

cheers Joe


Top
  
 
 Post subject: Re:GRUB modules?
PostPosted: Mon May 08, 2006 12:24 pm 
They all also cool for loading initial process for a microkernel system which doesn't have kernel mode drivers. I wonder what they were designed for...


Top
  
 
 Post subject: Re:GRUB modules?
PostPosted: Mon May 08, 2006 2:16 pm 
Offline
Member
Member

Joined: Sat Jun 24, 2006 4:40 pm
Posts: 140
Location: Falkirk, Scotland
Okay, I get the general idea now...

I've made a keymap, a simple .bin file. I load this as a module (module /boot/keymap.bin). I get the address that the module's loaded at from the multiboot data structure, and then try to load my keymap from there (using the following code - although I strongly suspect the code is right, and that the bug lies in loading the module somehow).

Code:
void loadKeymap(void *mbdata)
{
   unsigned long *modadd = mbdata;
   modadd = &modadd[6];

   unsigned char *modkeymap;
   modkeymap = (unsigned char*) *modadd; /* Get a pointer to our keymap
                   module - lowercase is at the
                   start and is 88 chars long */
   
   unsigned char *modkeymapshift = &modkeymap[88]; /* Get a pointer to the uppercase
                  section of our keymap module -
                  lowercase is 88 chars long, starting
                  at 0 so our uppercase starts at
                  index 88 */
   
   puts(" from 0x");
   char buf[10];
   puts(itoa((long) modkeymap, buf, 16));
   
   for(int i = 0; i < 88; i++)
   {
      keymap[i] = modkeymap[i];
      keymapshift[i] = modkeymapshift[i+88];
   }

   puts("...");   
}


However, this is bizarre, it has to be said. I get all sorts of alternative characters - I'm guessing I'm reading uninitialized memory. Using a debug build of bochs, and doing

xp /8b 0x20B40

I can see that the keymap isn't there, at all (this is the address that is printed as being loaded - and is in the data structure (I've got code that dumps that to the bochs i/o console ports)). So basically - what do I have to do with this address to get where my module has actually been loaded?

_________________
Regards,
Angus [Óengus] 'Midas' Lepper


Top
 Profile  
 
 Post subject: Re:GRUB modules?
PostPosted: Mon May 08, 2006 2:28 pm 
I suggest you have a read of the multiboot spec, and use a structure with proper names (theres an incomplete sample one in the multiboot docs) rather than array indices to access members of the multiboot info.

The mods_addr member points to an array of module data structures, and the number of entries in this list is given by mods_count.


Top
  
 
 Post subject: Re:GRUB modules?
PostPosted: Mon May 08, 2006 2:36 pm 
Offline
Member
Member

Joined: Sat Jun 24, 2006 4:40 pm
Posts: 140
Location: Falkirk, Scotland
paulbarker wrote:
I suggest you have a read of the multiboot spec, and use a structure with proper names (theres an incomplete sample one in the multiboot docs) rather than array indices to access members of the multiboot info.

The mods_addr member points to an array of module data structures, and the number of entries in this list is given by mods_count.


I suspected that was the case, but did have a reasonable look at the multiboot spec earlier, but couldn't find anything detailing how exactly it worked. Could you point me in the direction of which particular section I should be looking at?

EDIT: This is what I read: http://www.gnu.org/software/grub/manual ... iboot.html

Now, I'm a little tired - but I certainly didn't see anything the couple times I looked through that. Sorry! :-[

EDIT2: Ah, wait, it is on there! D'oh. Sorry, got it. Think I'll leave it to read tonight and work on tomorrow. Thanks. ;D

_________________
Regards,
Angus [Óengus] 'Midas' Lepper


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 158 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group