Deleted Added
full compact
kern_linker.c (40961) kern_linker.c (41055)
1/*-
2 * Copyright (c) 1997 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1997 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: kern_linker.c,v 1.14 1998/11/04 15:20:56 peter Exp $
26 * $Id: kern_linker.c,v 1.15 1998/11/06 15:10:17 peter Exp $
27 */
28
29#include "opt_ddb.h"
30
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>

--- 83 unchanged lines hidden (view full) ---

118
119 /*
120 * Perform a bubble sort of the system initialization objects by
121 * their subsystem (primary key) and order (secondary key).
122 *
123 * Since some things care about execution order, this is the
124 * operation which ensures continued function.
125 */
27 */
28
29#include "opt_ddb.h"
30
31#include <sys/param.h>
32#include <sys/kernel.h>
33#include <sys/systm.h>
34#include <sys/malloc.h>

--- 83 unchanged lines hidden (view full) ---

118
119 /*
120 * Perform a bubble sort of the system initialization objects by
121 * their subsystem (primary key) and order (secondary key).
122 *
123 * Since some things care about execution order, this is the
124 * operation which ensures continued function.
125 */
126 for( sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) {
127 for( xipp = sipp + 1; *xipp; xipp++) {
128 if( (*sipp)->subsystem < (*xipp)->subsystem ||
129 ( (*sipp)->subsystem == (*xipp)->subsystem &&
130 (*sipp)->order < (*xipp)->order))
126 for (sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) {
127 for (xipp = sipp + 1; *xipp; xipp++) {
128 if ((*sipp)->subsystem <= (*xipp)->subsystem ||
129 ((*sipp)->subsystem == (*xipp)->subsystem &&
130 (*sipp)->order <= (*xipp)->order))
131 continue; /* skip*/
132 save = *sipp;
133 *sipp = *xipp;
134 *xipp = save;
135 }
136 }
137
138
139 /*
140 * Traverse the (now) ordered list of system initialization tasks.
141 * Perform each task, and continue on to the next task.
131 continue; /* skip*/
132 save = *sipp;
133 *sipp = *xipp;
134 *xipp = save;
135 }
136 }
137
138
139 /*
140 * Traverse the (now) ordered list of system initialization tasks.
141 * Perform each task, and continue on to the next task.
142 *
143 * The last item on the list is expected to be the scheduler,
144 * which will not return.
145 */
142 */
146 for( sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) {
147 if( (*sipp)->subsystem == SI_SUB_DUMMY)
143 for (sipp = (struct sysinit **)sysinits->ls_items; *sipp; sipp++) {
144 if ((*sipp)->subsystem == SI_SUB_DUMMY)
148 continue; /* skip dummy task(s)*/
149
145 continue; /* skip dummy task(s)*/
146
150 switch( (*sipp)->type) {
147 switch ((*sipp)->type) {
151 case SI_TYPE_DEFAULT:
152 /* no special processing*/
148 case SI_TYPE_DEFAULT:
149 /* no special processing*/
153 (*((*sipp)->func))( (*sipp)->udata);
150 (*((*sipp)->func))((*sipp)->udata);
154 break;
155
156 case SI_TYPE_KTHREAD:
157#if !defined(SMP)
158 /* kernel thread*/
159 if (fork1(&proc0, RFFDG|RFPROC|RFMEM))
160 panic("fork kernel thread");
161 cpu_set_fork_handler(pfind(proc0.p_retval[0]),

--- 5 unchanged lines hidden (view full) ---

167 /* kernel thread*/
168 if (fork1(&proc0, RFFDG|RFPROC))
169 panic("fork kernel process");
170 cpu_set_fork_handler(pfind(proc0.p_retval[0]),
171 (*sipp)->func, (*sipp)->udata);
172 break;
173
174 default:
151 break;
152
153 case SI_TYPE_KTHREAD:
154#if !defined(SMP)
155 /* kernel thread*/
156 if (fork1(&proc0, RFFDG|RFPROC|RFMEM))
157 panic("fork kernel thread");
158 cpu_set_fork_handler(pfind(proc0.p_retval[0]),

--- 5 unchanged lines hidden (view full) ---

164 /* kernel thread*/
165 if (fork1(&proc0, RFFDG|RFPROC))
166 panic("fork kernel process");
167 cpu_set_fork_handler(pfind(proc0.p_retval[0]),
168 (*sipp)->func, (*sipp)->udata);
169 break;
170
171 default:
175 panic( "linker_file_sysinit: unrecognized init type");
172 panic ("linker_file_sysinit: unrecognized init type");
176 }
177 }
178}
179
173 }
174 }
175}
176
177static void
178linker_file_sysuninit(linker_file_t lf)
179{
180 struct linker_set* sysuninits;
181 struct sysinit** sipp;
182 struct sysinit** xipp;
183 struct sysinit* save;
184
185 KLD_DPF(FILE, ("linker_file_sysuninit: calling SYSUNINITs for %s\n",
186 lf->filename));
187
188 sysuninits = (struct linker_set*)
189 linker_file_lookup_symbol(lf, "sysuninit_set", 0);
190
191 KLD_DPF(FILE, ("linker_file_sysuninit: SYSUNINITs %p\n", sysuninits));
192 if (!sysuninits)
193 return;
194
195 /*
196 * Perform a reverse bubble sort of the system initialization objects
197 * by their subsystem (primary key) and order (secondary key).
198 *
199 * Since some things care about execution order, this is the
200 * operation which ensures continued function.
201 */
202 for (sipp = (struct sysinit **)sysuninits->ls_items; *sipp; sipp++) {
203 for (xipp = sipp + 1; *xipp; xipp++) {
204 if ((*sipp)->subsystem >= (*xipp)->subsystem ||
205 ((*sipp)->subsystem == (*xipp)->subsystem &&
206 (*sipp)->order >= (*xipp)->order))
207 continue; /* skip*/
208 save = *sipp;
209 *sipp = *xipp;
210 *xipp = save;
211 }
212 }
213
214
215 /*
216 * Traverse the (now) ordered list of system initialization tasks.
217 * Perform each task, and continue on to the next task.
218 */
219 for (sipp = (struct sysinit **)sysuninits->ls_items; *sipp; sipp++) {
220 if ((*sipp)->subsystem == SI_SUB_DUMMY)
221 continue; /* skip dummy task(s)*/
222
223 switch ((*sipp)->type) {
224 case SI_TYPE_DEFAULT:
225 /* no special processing*/
226 (*((*sipp)->func))((*sipp)->udata);
227 break;
228
229 default:
230 panic("linker_file_sysuninit: unrecognized uninit type");
231 }
232 }
233}
234
180int
181linker_load_file(const char* filename, linker_file_t* result)
182{
183 linker_class_t lc;
184 linker_file_t lf;
185 int error = 0;
186 char *koname = NULL;
187

--- 151 unchanged lines hidden (view full) ---

339 }
340
341 file->refs--;
342 if (file->refs > 0) {
343 lockmgr(&lock, LK_RELEASE, 0, curproc);
344 goto out;
345 }
346
235int
236linker_load_file(const char* filename, linker_file_t* result)
237{
238 linker_class_t lc;
239 linker_file_t lf;
240 int error = 0;
241 char *koname = NULL;
242

--- 151 unchanged lines hidden (view full) ---

394 }
395
396 file->refs--;
397 if (file->refs > 0) {
398 lockmgr(&lock, LK_RELEASE, 0, curproc);
399 goto out;
400 }
401
402 linker_file_sysuninit(file);
403
347 TAILQ_REMOVE(&files, file, link);
348 lockmgr(&lock, LK_RELEASE, 0, curproc);
349
350 for (i = 0; i < file->ndeps; i++)
351 linker_file_unload(file->deps[i]);
352 free(file->deps, M_LINKER);
353
354 for (cp = STAILQ_FIRST(&file->common); cp;

--- 506 unchanged lines hidden ---
404 TAILQ_REMOVE(&files, file, link);
405 lockmgr(&lock, LK_RELEASE, 0, curproc);
406
407 for (i = 0; i < file->ndeps; i++)
408 linker_file_unload(file->deps[i]);
409 free(file->deps, M_LINKER);
410
411 for (cp = STAILQ_FIRST(&file->common); cp;

--- 506 unchanged lines hidden ---