| 107 | } |
| 108 | |
| 109 | void |
| 110 | module_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 | |
| 151 | int |
| 152 | module_register(const moduledata_t *data, linker_file_t container) |
nothing calls this directly
no test coverage detected