Grub not loading modules properly?

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
carbonBased

Grub not loading modules properly?

Post by carbonBased »

Hey,

I'm trying to grab a list of all the modules GRUBs loaded for my kernel, but GRUB only returns the first module.  All others (despite GRUB saying it has loaded them) come back as start 0, length 0!!!

My code is almost an exact rip of the multiboot example found on the multiboot specs page:

  printf("mods_count = %d, mods_addr = 0x%x\n",
        (int)multibootInfo->mods_count,
(int)multibootInfo->mods_addr);

  mod = (module_t *) multibootInfo->mods_addr;
  for(i = 0; i < multibootInfo->mods_count; i++) {
    printf(" mod_start = 0x%x, mod_end = 0x%x, string = %s\n",
          (unsigned)mod->mod_start,
          (unsigned)mod->mod_end,
          (char *)mod->string);
    mod += sizeof (module_t);
  }

It seems to me that the problem is on the last line... it doesn't seem to increment to the next module info block properly!  Is this a bug in GRUB?  Has the multiboot standard changed?  All module info blocks (afaik!!) should be located, one after the other, and are each 16 bytes long...

Any ideas?

Jeff
carbonBased

RE:Grub not loading modules properly? (fixed)

Post by carbonBased »

Sorry folks, waste of time there... I figured it out.

Although, it really doesn't make much sense.  Instead keeping "mod" as a pointer to the current module and adding sizeof(module_t) on each loop increment, I've maintained "mod" as a pointer to the _first_ module, and used it as an array index "mod[i].whatever"

As far as I'm concerned, these two methods are (effectively) equivalent, and yet only the later works!  Kinda sucks, 'cuz that's the slower of the two methods...

Anyway, I'm just glad it works... a microkernel that doesn't load objects correctly is pretty useless ;)

Jeff
Post Reply