OSDev.org
https://forum.osdev.org/

GRUB modules?
https://forum.osdev.org/viewtopic.php?f=1&t=11601
Page 1 of 1

Author:  Midas [ Mon May 08, 2006 11:19 am ]
Post subject:  GRUB modules?

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.

Author:  JoeKayzA [ Mon May 08, 2006 11:28 am ]
Post subject:  Re:GRUB modules?

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

Author:  mystran [ Mon May 08, 2006 12:24 pm ]
Post subject:  Re:GRUB modules?

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

Author:  Midas [ Mon May 08, 2006 2:16 pm ]
Post subject:  Re:GRUB modules?

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?

Author:  paulbarker [ Mon May 08, 2006 2:28 pm ]
Post subject:  Re:GRUB modules?

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.

Author:  Midas [ Mon May 08, 2006 2:36 pm ]
Post subject:  Re:GRUB modules?

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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/