| 191 | } |
| 192 | |
| 193 | static void |
| 194 | linker_file_sysinit(linker_file_t lf) |
| 195 | { |
| 196 | struct sysinit **start, **stop, **sipp, **xipp, *save; |
| 197 | |
| 198 | KLD_DPF(FILE, ("linker_file_sysinit: calling SYSINITs for %s\n", |
| 199 | lf->filename)); |
| 200 | |
| 201 | sx_assert(&kld_sx, SA_XLOCKED); |
| 202 | |
| 203 | if (linker_file_lookup_set(lf, "sysinit_set", &start, &stop, NULL) != 0) |
| 204 | return; |
| 205 | /* |
| 206 | * Perform a bubble sort of the system initialization objects by |
| 207 | * their subsystem (primary key) and order (secondary key). |
| 208 | * |
| 209 | * Since some things care about execution order, this is the operation |
| 210 | * which ensures continued function. |
| 211 | */ |
| 212 | for (sipp = start; sipp < stop; sipp++) { |
| 213 | for (xipp = sipp + 1; xipp < stop; xipp++) { |
| 214 | if ((*sipp)->subsystem < (*xipp)->subsystem || |
| 215 | ((*sipp)->subsystem == (*xipp)->subsystem && |
| 216 | (*sipp)->order <= (*xipp)->order)) |
| 217 | continue; /* skip */ |
| 218 | save = *sipp; |
| 219 | *sipp = *xipp; |
| 220 | *xipp = save; |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * Traverse the (now) ordered list of system initialization tasks. |
| 226 | * Perform each task, and continue on to the next task. |
| 227 | */ |
| 228 | sx_xunlock(&kld_sx); |
| 229 | mtx_lock(&Giant); |
| 230 | for (sipp = start; sipp < stop; sipp++) { |
| 231 | if ((*sipp)->subsystem == SI_SUB_DUMMY) |
| 232 | continue; /* skip dummy task(s) */ |
| 233 | |
| 234 | /* Call function */ |
| 235 | (*((*sipp)->func)) ((*sipp)->udata); |
| 236 | } |
| 237 | mtx_unlock(&Giant); |
| 238 | sx_xlock(&kld_sx); |
| 239 | } |
| 240 | |
| 241 | static void |
| 242 | linker_file_sysuninit(linker_file_t lf) |
no test coverage detected