Provide convenience function for obtaining MODINFO_ADDR and MODINFO_SIZE

attributes for preloaded modules/images. In particular, MODINFO_ADDR has
the added complexity of not always being relocated properly. Rather than
kluging this in the various components that are affected, we handle it
in a centralized place (preload_fetch_addr()). To that end, expose a new
variable, preload_addr_relocate, that MD initialization code can set and
that turns the address attribute into a valid kernel VA.

Architectures that need the relocation: arm & powerpc (at least).
Components that can utilize this: acpi(4), md(4), fb(4), pci(4), ZFS, geli.

Sponsored by: Juniper Networks
This commit is contained in:
Marcel Moolenaar 2011-02-09 19:08:21 +00:00
parent 02e5228ca0
commit 278e79707e
2 changed files with 28 additions and 1 deletions

View File

@ -35,7 +35,8 @@ __FBSDID("$FreeBSD$");
* Preloaded module support
*/
caddr_t preload_metadata;
vm_offset_t preload_addr_relocate = 0;
caddr_t preload_metadata;
/*
* Search for the preloaded module (name)
@ -230,6 +231,28 @@ preload_delete_name(const char *name)
}
}
void *
preload_fetch_addr(caddr_t mod)
{
caddr_t *mdp;
mdp = (caddr_t *)preload_search_info(mod, MODINFO_ADDR);
if (mdp == NULL)
return (NULL);
return (*mdp + preload_addr_relocate);
}
size_t
preload_fetch_size(caddr_t mod)
{
size_t *mdp;
mdp = (size_t *)preload_search_info(mod, MODINFO_SIZE);
if (mdp == NULL)
return (0);
return (*mdp);
}
/* Called from locore on i386. Convert physical pointers to kvm. Sigh. */
void
preload_bootstrap_relocate(vm_offset_t offset)

View File

@ -234,7 +234,11 @@ void *linker_hwpmc_list_objects(void);
/*
* Module lookup
*/
extern vm_offset_t preload_addr_relocate;
extern caddr_t preload_metadata;
extern void * preload_fetch_addr(caddr_t _mod);
extern size_t preload_fetch_size(caddr_t _mod);
extern caddr_t preload_search_by_name(const char *_name);
extern caddr_t preload_search_by_type(const char *_type);
extern caddr_t preload_search_next_name(caddr_t _base);