Author: marcel Date: Wed Feb 9 19:08:21 2011 New Revision: 218494 URL: http://svn.freebsd.org/changeset/base/218494
Log: 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 Modified: head/sys/kern/subr_module.c head/sys/sys/linker.h Modified: head/sys/kern/subr_module.c ============================================================================== --- head/sys/kern/subr_module.c Wed Feb 9 18:45:33 2011 (r218493) +++ head/sys/kern/subr_module.c Wed Feb 9 19:08:21 2011 (r218494) @@ -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) Modified: head/sys/sys/linker.h ============================================================================== --- head/sys/sys/linker.h Wed Feb 9 18:45:33 2011 (r218493) +++ head/sys/sys/linker.h Wed Feb 9 19:08:21 2011 (r218494) @@ -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); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"