Changeset View
Changeset View
Standalone View
Standalone View
stand/common/module.c
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
static int file_load_dependencies(struct preloaded_file *base_mod); | static int file_load_dependencies(struct preloaded_file *base_mod); | ||||
static char * file_search(const char *name, char **extlist); | static char * file_search(const char *name, char **extlist); | ||||
static struct kernel_module * file_findmodule(struct preloaded_file *fp, char *modname, struct mod_depend *verinfo); | static struct kernel_module * file_findmodule(struct preloaded_file *fp, char *modname, struct mod_depend *verinfo); | ||||
static int file_havepath(const char *name); | static int file_havepath(const char *name); | ||||
static char *mod_searchmodule(char *name, struct mod_depend *verinfo); | static char *mod_searchmodule(char *name, struct mod_depend *verinfo); | ||||
static char * mod_searchmodule_pnpinfo(const char *bus, const char *pnpinfo); | static char * mod_searchmodule_pnpinfo(const char *bus, const char *pnpinfo); | ||||
static void file_insert_tail(struct preloaded_file *mp); | static void file_insert_tail(struct preloaded_file *mp); | ||||
static void file_remove(struct preloaded_file *fp); | static void file_remove(struct preloaded_file *fp); | ||||
static void file_remove_tail(struct preloaded_file *fp); | |||||
struct file_metadata* metadata_next(struct file_metadata *base_mp, int type); | struct file_metadata* metadata_next(struct file_metadata *base_mp, int type); | ||||
static void moduledir_readhints(struct moduledir *mdp); | static void moduledir_readhints(struct moduledir *mdp); | ||||
static void moduledir_rebuild(void); | static void moduledir_rebuild(void); | ||||
/* load address should be tweaked by first module loaded (kernel) */ | /* load address should be tweaked by first module loaded (kernel) */ | ||||
static vm_offset_t loadaddr = 0; | static vm_offset_t loadaddr = 0; | ||||
#if defined(LOADER_FDT_SUPPORT) | #if defined(LOADER_FDT_SUPPORT) | ||||
▲ Show 20 Lines • Show All 796 Lines • ▼ Show 20 Lines | do { | ||||
if (err) | if (err) | ||||
break; | break; | ||||
fp->f_args = unargv(argc, argv); | fp->f_args = unargv(argc, argv); | ||||
loadaddr_saved = loadaddr; | loadaddr_saved = loadaddr; | ||||
loadaddr = fp->f_addr + fp->f_size; | loadaddr = fp->f_addr + fp->f_size; | ||||
file_insert_tail(fp); /* Add to the list of loaded files */ | file_insert_tail(fp); /* Add to the list of loaded files */ | ||||
if (file_load_dependencies(fp) != 0) { | if (file_load_dependencies(fp) != 0) { | ||||
err = ENOENT; | err = ENOENT; | ||||
file_remove(fp); | file_remove_tail(fp); | ||||
loadaddr = loadaddr_saved; | loadaddr = loadaddr_saved; | ||||
fp = NULL; | fp = NULL; | ||||
break; | break; | ||||
} | } | ||||
} while(0); | } while(0); | ||||
if (err == EFTYPE) { | if (err == EFTYPE) { | ||||
snprintf(command_errbuf, sizeof(command_errbuf), | snprintf(command_errbuf, sizeof(command_errbuf), | ||||
"don't know how to load module '%s'", filename); | "don't know how to load module '%s'", filename); | ||||
▲ Show 20 Lines • Show All 744 Lines • ▼ Show 20 Lines | if (preloaded_files == NULL) { | ||||
cm->f_next = fp; | cm->f_next = fp; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Remove module from the chain | * Remove module from the chain | ||||
*/ | */ | ||||
static void | static void | ||||
file_remove(struct preloaded_file *fp) | file_remove_impl(struct preloaded_file *fp, bool keep_tail) | ||||
{ | { | ||||
struct preloaded_file *cm; | struct preloaded_file *cm, *next; | ||||
if (preloaded_files == NULL) | if (preloaded_files == NULL) | ||||
return; | return; | ||||
if (keep_tail) | |||||
next = fp->f_next; | |||||
else | |||||
next = NULL; | |||||
if (preloaded_files == fp) { | if (preloaded_files == fp) { | ||||
preloaded_files = fp->f_next; | preloaded_files = next; | ||||
return; | return; | ||||
} | } | ||||
for (cm = preloaded_files; cm->f_next != NULL; cm = cm->f_next) { | for (cm = preloaded_files; cm->f_next != NULL; cm = cm->f_next) { | ||||
if (cm->f_next == fp) { | if (cm->f_next == fp) { | ||||
cm->f_next = fp->f_next; | cm->f_next = next; | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | |||||
static void | |||||
file_remove(struct preloaded_file *fp) | |||||
{ | |||||
file_remove_impl(fp, true); | |||||
} | |||||
static void | |||||
file_remove_tail(struct preloaded_file *fp) | |||||
{ | |||||
file_remove_impl(fp, false); | |||||
} | } | ||||
static char * | static char * | ||||
moduledir_fullpath(struct moduledir *mdp, const char *fname) | moduledir_fullpath(struct moduledir *mdp, const char *fname) | ||||
{ | { | ||||
char *cp; | char *cp; | ||||
cp = malloc(strlen(mdp->d_path) + strlen(fname) + 2); | cp = malloc(strlen(mdp->d_path) + strlen(fname) + 2); | ||||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |