Hi,
I believe bootinfo does not contain the address of the module but a pointer to an array of modules (pointer, size and name) triplets. But I'm not very fond of Grub, so maybe someone can correct me on this. From the spec:
Code:
/* Are mods_* valid? */
if (CHECK_FLAG (mbi->flags, 3))
{
multiboot_module_t *mod;
int i;
printf ("mods_count = %d, mods_addr = 0x%x\n",
(int) mbi->mods_count, (int) mbi->mods_addr);
for (i = 0, mod = (multiboot_module_t *) mbi->mods_addr;
i < mbi->mods_count;
i++, mod++)
printf (" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
(unsigned) mod->mod_start,
(unsigned) mod->mod_end,
(char *) mod->cmdline);
}
Second, why do you copy the module? Why don't you simply map the memory where it's already located? If it's aligned on frame boundary, I see no reason why to copy it.
Code:
map_address(get_directory(), 0x08048000 + i, (char*)p_hdr + i, PTE_PRESENT | PTE_WRITEABLE | PTE_USER);
Cheers,
bzt