MCPcopy Create free account
hub / github.com/F-Stack/f-stack / module_register_init

Function module_register_init

freebsd/kern/kern_module.c:109–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void
110module_register_init(const void *arg)
111{
112 const moduledata_t *data = (const moduledata_t *)arg;
113 int error;
114 module_t mod;
115
116 mtx_lock(&Giant);
117 MOD_SLOCK;
118 mod = module_lookupbyname(data->name);
119 if (mod == NULL)
120 panic("module_register_init: module named %s not found\n",
121 data->name);
122 MOD_SUNLOCK;
123 error = MOD_EVENT(mod, MOD_LOAD);
124 if (error) {
125 MOD_EVENT(mod, MOD_UNLOAD);
126 MOD_XLOCK;
127 module_release(mod);
128 MOD_XUNLOCK;
129 printf("module_register_init: MOD_LOAD (%s, %p, %p) error"
130 " %d\n", data->name, (void *)data->evhand, data->priv,
131 error);
132 } else {
133 MOD_XLOCK;
134 if (mod->file) {
135 /*
136 * Once a module is successfully loaded, move
137 * it to the head of the module list for this
138 * linker file. This resorts the list so that
139 * when the kernel linker iterates over the
140 * modules to unload them, it will unload them
141 * in the reverse order they were loaded.
142 */
143 TAILQ_REMOVE(&mod->file->modules, mod, flink);
144 TAILQ_INSERT_HEAD(&mod->file->modules, mod, flink);
145 }
146 MOD_XUNLOCK;
147 }
148 mtx_unlock(&Giant);
149}
150
151int
152module_register(const moduledata_t *data, linker_file_t container)

Callers

nothing calls this directly

Calls 6

module_lookupbynameFunction · 0.85
module_releaseFunction · 0.85
mtx_lockFunction · 0.70
panicFunction · 0.70
printfFunction · 0.70
mtx_unlockFunction · 0.70

Tested by

no test coverage detected