init_main.c (12501) | init_main.c (12569) |
---|---|
1/* 2 * Copyright (c) 1995 Terrence R. Lambert 3 * All rights reserved. 4 * 5 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * (c) UNIX System Laboratories, Inc. 8 * All or some portions of this file are derived from material licensed --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * @(#)init_main.c 8.9 (Berkeley) 1/21/94 | 1/* 2 * Copyright (c) 1995 Terrence R. Lambert 3 * All rights reserved. 4 * 5 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993 6 * The Regents of the University of California. All rights reserved. 7 * (c) UNIX System Laboratories, Inc. 8 * All or some portions of this file are derived from material licensed --- 25 unchanged lines hidden (view full) --- 34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 * SUCH DAMAGE. 40 * 41 * @(#)init_main.c 8.9 (Berkeley) 1/21/94 |
42 * $Id: init_main.c,v 1.31 1995/10/08 00:05:59 swallace Exp $ | 42 * $Id: init_main.c,v 1.32 1995/11/28 07:29:59 bde Exp $ |
43 */ 44 45#include <sys/param.h> 46#include <sys/filedesc.h> 47#include <sys/errno.h> 48#include <sys/exec.h> 49#include <sys/kernel.h> 50#ifdef GPROF --- 167 unchanged lines hidden (view full) --- 218 * Start a kernel process. This is called after a fork() call in 219 * main() in the file kern/init_main.c. 220 * 221 * This function is used to start "internal" daemons. 222 */ 223/* ARGSUSED*/ 224void 225kproc_start(udata) | 43 */ 44 45#include <sys/param.h> 46#include <sys/filedesc.h> 47#include <sys/errno.h> 48#include <sys/exec.h> 49#include <sys/kernel.h> 50#ifdef GPROF --- 167 unchanged lines hidden (view full) --- 218 * Start a kernel process. This is called after a fork() call in 219 * main() in the file kern/init_main.c. 220 * 221 * This function is used to start "internal" daemons. 222 */ 223/* ARGSUSED*/ 224void 225kproc_start(udata) |
226 void *udata; /* pointer to a 'kproc_desc' ? */ | 226 void *udata; |
227{ | 227{ |
228 struct kproc_desc *kp = (struct kproc_desc *)udata; | 228 struct kproc_desc *kp = udata; |
229 struct proc *p = curproc; 230 231 /* save a global descriptor, if desired*/ 232 if( kp->global_procpp != NULL) 233 *kp->global_procpp = p; 234 235 /* this is a non-swapped system process*/ 236 p->p_flag |= P_INMEM | P_SYSTEM; 237 238 /* set up arg0 for 'ps', et al*/ 239 strcpy( p->p_comm, kp->arg0); 240 241 /* call the processes' main()...*/ 242 (*kp->func)(); 243 244 /* NOTREACHED */ | 229 struct proc *p = curproc; 230 231 /* save a global descriptor, if desired*/ 232 if( kp->global_procpp != NULL) 233 *kp->global_procpp = p; 234 235 /* this is a non-swapped system process*/ 236 p->p_flag |= P_INMEM | P_SYSTEM; 237 238 /* set up arg0 for 'ps', et al*/ 239 strcpy( p->p_comm, kp->arg0); 240 241 /* call the processes' main()...*/ 242 (*kp->func)(); 243 244 /* NOTREACHED */ |
245 panic( "kproc_start: %s", kp->arg0); | 245 panic("kproc_start: %s", kp->arg0); |
246} 247 248 249/* 250 *************************************************************************** 251 **** 252 **** The following SYSINIT's belong elsewhere, but have not yet 253 **** been moved. --- 20 unchanged lines hidden (view full) --- 274#endif 275static void print_caddr_t __P((void *data)); 276static void 277print_caddr_t(data) 278 void *data; 279{ 280 printf("%s", (char *)data); 281} | 246} 247 248 249/* 250 *************************************************************************** 251 **** 252 **** The following SYSINIT's belong elsewhere, but have not yet 253 **** been moved. --- 20 unchanged lines hidden (view full) --- 274#endif 275static void print_caddr_t __P((void *data)); 276static void 277print_caddr_t(data) 278 void *data; 279{ 280 printf("%s", (char *)data); 281} |
282SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t, 283 copyright) | 282SYSINIT(announce, SI_SUB_COPYRIGHT, SI_ORDER_FIRST, print_caddr_t, copyright) |
284 285 286/* 287 *************************************************************************** 288 **** 289 **** The two following SYSINT's are proc0 specific glue code. I am not 290 **** convinced that they can not be safely combined, but their order of 291 **** operation has been maintained as the same as the original init_main.c 292 **** for right now. 293 **** 294 **** These probably belong in init_proc.c or kern_proc.c, since they 295 **** deal with proc0 (the fork template process). 296 **** 297 *************************************************************************** 298 */ 299/* ARGSUSED*/ | 283 284 285/* 286 *************************************************************************** 287 **** 288 **** The two following SYSINT's are proc0 specific glue code. I am not 289 **** convinced that they can not be safely combined, but their order of 290 **** operation has been maintained as the same as the original init_main.c 291 **** for right now. 292 **** 293 **** These probably belong in init_proc.c or kern_proc.c, since they 294 **** deal with proc0 (the fork template process). 295 **** 296 *************************************************************************** 297 */ 298/* ARGSUSED*/ |
300void proc0_init __P((void *udata)); | 299void proc0_init __P((void *dummy)); |
301void | 300void |
302proc0_init(udata) 303 void *udata; /* not used*/ | 301proc0_init(dummy) 302 void *dummy; |
304{ 305 register struct proc *p; 306 register struct filedesc0 *fdp; 307 register int i; 308 309 /* 310 * Initialize the current process pointer (curproc) before 311 * any possible traps/probes to simplify trap processing. --- 83 unchanged lines hidden (view full) --- 395 * root for one process. 396 */ 397 usrinfoinit(); 398 (void)chgproccnt(0, 1); 399} 400SYSINIT(p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL) 401 402/* ARGSUSED*/ | 303{ 304 register struct proc *p; 305 register struct filedesc0 *fdp; 306 register int i; 307 308 /* 309 * Initialize the current process pointer (curproc) before 310 * any possible traps/probes to simplify trap processing. --- 83 unchanged lines hidden (view full) --- 394 * root for one process. 395 */ 396 usrinfoinit(); 397 (void)chgproccnt(0, 1); 398} 399SYSINIT(p0init, SI_SUB_INTRINSIC, SI_ORDER_FIRST, proc0_init, NULL) 400 401/* ARGSUSED*/ |
403void proc0_post __P((void *udata)); | 402void proc0_post __P((void *dummy)); |
404void | 403void |
405proc0_post(udata) 406 void *udata; /* not used*/ | 404proc0_post(dummy) 405 void *dummy; |
407{ 408 /* 409 * Now can look at time, having had a chance to verify the time 410 * from the file system. Reset p->p_rtime as it may have been 411 * munched in mi_switch() after the time got set. 412 */ 413 proc0.p_stats->p_start = runtime = mono_time = boottime = time; 414 proc0.p_rtime.tv_sec = proc0.p_rtime.tv_usec = 0; --- 10 unchanged lines hidden (view full) --- 425 *************************************************************************** 426 **** 427 **** The following SYSINIT's and glue code should be moved to the 428 **** respective files on a per subsystem basis. 429 **** 430 *************************************************************************** 431 */ 432/* ARGSUSED*/ | 406{ 407 /* 408 * Now can look at time, having had a chance to verify the time 409 * from the file system. Reset p->p_rtime as it may have been 410 * munched in mi_switch() after the time got set. 411 */ 412 proc0.p_stats->p_start = runtime = mono_time = boottime = time; 413 proc0.p_rtime.tv_sec = proc0.p_rtime.tv_usec = 0; --- 10 unchanged lines hidden (view full) --- 424 *************************************************************************** 425 **** 426 **** The following SYSINIT's and glue code should be moved to the 427 **** respective files on a per subsystem basis. 428 **** 429 *************************************************************************** 430 */ 431/* ARGSUSED*/ |
433void sched_setup __P((void *udata)); | 432void sched_setup __P((void *dummy)); |
434void | 433void |
435sched_setup(udata) 436 void *udata; /* not used*/ | 434sched_setup(dummy) 435 void *dummy; |
437{ 438 /* Kick off timeout driven events by calling first time. */ 439 roundrobin(NULL); 440 schedcpu(NULL); 441} 442SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL) 443 444/* ARGSUSED*/ | 436{ 437 /* Kick off timeout driven events by calling first time. */ 438 roundrobin(NULL); 439 schedcpu(NULL); 440} 441SYSINIT(sched_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, sched_setup, NULL) 442 443/* ARGSUSED*/ |
445void xxx_vfs_mountroot __P((void *udata)); | 444void xxx_vfs_mountroot __P((void *dummy)); |
446void | 445void |
447xxx_vfs_mountroot(udata) 448 void *udata; /* not used*/ | 446xxx_vfs_mountroot(dummy) 447 void *dummy; |
449{ 450 /* Mount the root file system. */ 451 if ((*mountroot)(mountrootvfsops)) 452 panic("cannot mount root"); 453} 454SYSINIT(mountroot, SI_SUB_ROOT, SI_ORDER_FIRST, xxx_vfs_mountroot, NULL) 455 456/* ARGSUSED*/ | 448{ 449 /* Mount the root file system. */ 450 if ((*mountroot)(mountrootvfsops)) 451 panic("cannot mount root"); 452} 453SYSINIT(mountroot, SI_SUB_ROOT, SI_ORDER_FIRST, xxx_vfs_mountroot, NULL) 454 455/* ARGSUSED*/ |
457void xxx_vfs_root_fdtab __P((void *udata)); | 456void xxx_vfs_root_fdtab __P((void *dummy)); |
458void | 457void |
459xxx_vfs_root_fdtab(udata) 460 void *udata; /* not used*/ | 458xxx_vfs_root_fdtab(dummy) 459 void *dummy; |
461{ 462 register struct filedesc0 *fdp = &filedesc0; 463 464 /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */ 465 if (VFS_ROOT(mountlist.cqh_first, &rootvnode)) 466 panic("cannot find root vnode"); 467 fdp->fd_fd.fd_cdir = rootvnode; 468 VREF(fdp->fd_fd.fd_cdir); --- 11 unchanged lines hidden (view full) --- 480 **** 481 **** 1) This code returns to startup the system; this is 482 **** abnormal for a kernel thread. 483 **** 2) This code promiscuously uses init_frame 484 **** 485 *************************************************************************** 486 */ 487 | 460{ 461 register struct filedesc0 *fdp = &filedesc0; 462 463 /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */ 464 if (VFS_ROOT(mountlist.cqh_first, &rootvnode)) 465 panic("cannot find root vnode"); 466 fdp->fd_fd.fd_cdir = rootvnode; 467 VREF(fdp->fd_fd.fd_cdir); --- 11 unchanged lines hidden (view full) --- 479 **** 480 **** 1) This code returns to startup the system; this is 481 **** abnormal for a kernel thread. 482 **** 2) This code promiscuously uses init_frame 483 **** 484 *************************************************************************** 485 */ 486 |
488static void kthread_init __P((void *udata)); | 487static void kthread_init __P((void *dummy)); |
489SYSINIT_KT(init,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kthread_init, NULL) 490 491 492static void start_init __P((struct proc *p, void *framep)); 493 494/* ARGSUSED*/ 495static void | 488SYSINIT_KT(init,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kthread_init, NULL) 489 490 491static void start_init __P((struct proc *p, void *framep)); 492 493/* ARGSUSED*/ 494static void |
496kthread_init(udata) 497 void *udata; /* not used*/ | 495kthread_init(dummy) 496 void *dummy; |
498{ 499 500 /* Create process 1 (init(8)). */ 501 start_init(curproc, init_framep); 502 503 /* 504 * This is the only kernel thread allowed to return yo the 505 * caller!!! --- 114 unchanged lines hidden --- | 497{ 498 499 /* Create process 1 (init(8)). */ 500 start_init(curproc, init_framep); 501 502 /* 503 * This is the only kernel thread allowed to return yo the 504 * caller!!! --- 114 unchanged lines hidden --- |