init_main.c (1542) | init_main.c (1549) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 67 unchanged lines hidden (view full) --- 76struct session session0; 77struct pgrp pgrp0; 78struct proc proc0; 79struct pcred cred0; 80struct filedesc0 filedesc0; 81struct plimit limit0; 82struct vmspace vmspace0; 83struct proc *curproc = &proc0; | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 67 unchanged lines hidden (view full) --- 76struct session session0; 77struct pgrp pgrp0; 78struct proc proc0; 79struct pcred cred0; 80struct filedesc0 filedesc0; 81struct plimit limit0; 82struct vmspace vmspace0; 83struct proc *curproc = &proc0; |
84struct proc *initproc, *pageproc; | 84struct proc *initproc, *pageproc, *pagescanproc, *updateproc; |
85 86int cmask = CMASK; 87extern struct user *proc0paddr; 88 89struct vnode *rootvp, *swapdev_vp; 90int boothowto; 91struct timeval boottime; 92struct timeval runtime; 93 94static void start_init __P((struct proc *p, void *framep)); 95 | 85 86int cmask = CMASK; 87extern struct user *proc0paddr; 88 89struct vnode *rootvp, *swapdev_vp; 90int boothowto; 91struct timeval boottime; 92struct timeval runtime; 93 94static void start_init __P((struct proc *p, void *framep)); 95 |
96#if __GNUC__ >= 2 97void __main() {} 98#endif 99 |
|
96/* | 100/* |
101 * This table is filled in by the linker with functions that need to be 102 * called to initialize various pseudo-devices and whatnot. 103 */ 104typedef void (*pseudo_func_t)(void); 105extern const struct linker_set pseudo_set; 106static const pseudo_func_t *pseudos = 107 (const pseudo_func_t *)&pseudo_set.ls_items[0]; 108 109/* |
|
97 * System startup; initialize the world, create process 0, mount root 98 * filesystem, and fork to create init and pagedaemon. Most of the 99 * hard work is done in the lower-level initialization routines including 100 * startup(), which does memory initialization and autoconfiguration. 101 */ | 110 * System startup; initialize the world, create process 0, mount root 111 * filesystem, and fork to create init and pagedaemon. Most of the 112 * hard work is done in the lower-level initialization routines including 113 * startup(), which does memory initialization and autoconfiguration. 114 */ |
115void |
|
102main(framep) 103 void *framep; 104{ 105 register struct proc *p; 106 register struct filedesc0 *fdp; 107 register struct pdevinit *pdev; 108 register int i; 109 int s, rval[2]; --- 63 unchanged lines hidden (view full) --- 173 limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = i; 174 limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3; 175 limit0.p_refcnt = 1; 176 177 /* Allocate a prototype map so we have something to fork. */ 178 p->p_vmspace = &vmspace0; 179 vmspace0.vm_refcnt = 1; 180 pmap_pinit(&vmspace0.vm_pmap); | 116main(framep) 117 void *framep; 118{ 119 register struct proc *p; 120 register struct filedesc0 *fdp; 121 register struct pdevinit *pdev; 122 register int i; 123 int s, rval[2]; --- 63 unchanged lines hidden (view full) --- 187 limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = i; 188 limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3; 189 limit0.p_refcnt = 1; 190 191 /* Allocate a prototype map so we have something to fork. */ 192 p->p_vmspace = &vmspace0; 193 vmspace0.vm_refcnt = 1; 194 pmap_pinit(&vmspace0.vm_pmap); |
181 vm_map_init(&p->p_vmspace->vm_map, round_page(VM_MIN_ADDRESS), | 195 vm_map_init(&vmspace0.vm_map, round_page(VM_MIN_ADDRESS), |
182 trunc_page(VM_MAX_ADDRESS), TRUE); 183 vmspace0.vm_map.pmap = &vmspace0.vm_pmap; 184 p->p_addr = proc0paddr; /* XXX */ 185 186 /* 187 * We continue to place resource usage info and signal 188 * actions in the user struct so they're pageable. 189 */ --- 19 unchanged lines hidden (view full) --- 209 initclocks(); 210 211 /* Initialize mbuf's. */ 212 mbinit(); 213 214 /* Initialize clists. */ 215 clist_init(); 216 | 196 trunc_page(VM_MAX_ADDRESS), TRUE); 197 vmspace0.vm_map.pmap = &vmspace0.vm_pmap; 198 p->p_addr = proc0paddr; /* XXX */ 199 200 /* 201 * We continue to place resource usage info and signal 202 * actions in the user struct so they're pageable. 203 */ --- 19 unchanged lines hidden (view full) --- 223 initclocks(); 224 225 /* Initialize mbuf's. */ 226 mbinit(); 227 228 /* Initialize clists. */ 229 clist_init(); 230 |
217#ifdef SYSVSHM 218 /* Initialize System V style shared memory. */ 219 shminit(); 220#endif | 231 /* 232 * Attach pseudo-devices. 233 */ 234 while(*pseudos) { 235 (**pseudos++)(); 236 } |
221 | 237 |
222 /* Attach pseudo-devices. */ 223 for (pdev = pdevinit; pdev->pdev_attach != NULL; pdev++) 224 (*pdev->pdev_attach)(pdev->pdev_count); 225 | |
226 /* 227 * Initialize protocols. Block reception of incoming packets 228 * until everything is ready. 229 */ 230 s = splimp(); 231 ifinit(); 232 domaininit(); 233 splx(s); --- 48 unchanged lines hidden (view full) --- 282 */ 283 p = curproc; 284 pageproc = p; 285 p->p_flag |= P_INMEM | P_SYSTEM; /* XXX */ 286 bcopy("pagedaemon", curproc->p_comm, sizeof ("pagedaemon")); 287 vm_pageout(); 288 /* NOTREACHED */ 289 } | 238 /* 239 * Initialize protocols. Block reception of incoming packets 240 * until everything is ready. 241 */ 242 s = splimp(); 243 ifinit(); 244 domaininit(); 245 splx(s); --- 48 unchanged lines hidden (view full) --- 294 */ 295 p = curproc; 296 pageproc = p; 297 p->p_flag |= P_INMEM | P_SYSTEM; /* XXX */ 298 bcopy("pagedaemon", curproc->p_comm, sizeof ("pagedaemon")); 299 vm_pageout(); 300 /* NOTREACHED */ 301 } |
302#if 1 303 /* 304 * Start page scanner daemon (process 3). 305 */ 306 if (fork(p, (void *) NULL, rval)) 307 panic("failed fork page scanner daemon"); 308 if (rval[1]) { 309 p = curproc; 310 pagescanproc = p; 311 p->p_flag |= P_INMEM | P_SYSTEM; 312 bcopy("pagescan", p->p_comm, sizeof("pagescan")); 313 vm_pagescan(); 314 /*NOTREACHED*/ 315 } 316#endif |
|
290 | 317 |
318 /* 319 * Start update daemon (process 4). 320 */ 321#ifndef LAPTOP 322 if (fork(p, (void *) NULL, rval)) 323 panic("failed fork update daemon"); 324 if (rval[1]) { 325 p = curproc; 326 updateproc = p; 327 p->p_flag |= P_INMEM | P_SYSTEM; 328 bcopy("update", p->p_comm, sizeof("update")); 329 vfs_update(); 330 /*NOTREACHED*/ 331 } 332#endif 333 |
|
291 /* The scheduler is an infinite loop. */ 292 scheduler(); 293 /* NOTREACHED */ 294} 295 296/* 297 * List of paths to try when searching for "init". 298 */ --- 27 unchanged lines hidden (view full) --- 326 * startup code in "locore.s" has allocated space for the frame and 327 * passed a pointer to that space as main's argument. 328 */ 329 cpu_set_init_frame(p, framep); 330 331 /* 332 * Need just enough stack to hold the faked-up "execve()" arguments. 333 */ | 334 /* The scheduler is an infinite loop. */ 335 scheduler(); 336 /* NOTREACHED */ 337} 338 339/* 340 * List of paths to try when searching for "init". 341 */ --- 27 unchanged lines hidden (view full) --- 369 * startup code in "locore.s" has allocated space for the frame and 370 * passed a pointer to that space as main's argument. 371 */ 372 cpu_set_init_frame(p, framep); 373 374 /* 375 * Need just enough stack to hold the faked-up "execve()" arguments. 376 */ |
334 addr = trunc_page(VM_MAX_ADDRESS - PAGE_SIZE); | 377 addr = trunc_page(VM_MAXUSER_ADDRESS - PAGE_SIZE); |
335 if (vm_allocate(&p->p_vmspace->vm_map, &addr, PAGE_SIZE, FALSE) != 0) 336 panic("init: couldn't allocate argument space"); 337 p->p_vmspace->vm_maxsaddr = (caddr_t)addr; | 378 if (vm_allocate(&p->p_vmspace->vm_map, &addr, PAGE_SIZE, FALSE) != 0) 379 panic("init: couldn't allocate argument space"); 380 p->p_vmspace->vm_maxsaddr = (caddr_t)addr; |
381 p->p_vmspace->vm_ssize = 1; |
|
338 339 for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) { 340 /* 341 * Move out the boot flag argument. 342 */ 343 options = 0; 344 ucp = (char *)USRSTACK; 345 (void)subyte(--ucp, 0); /* trailing zero */ --- 26 unchanged lines hidden (view full) --- 372 (void)suword((caddr_t)--uap, 0); /* terminator */ 373 (void)suword((caddr_t)--uap, (int)arg1); 374 (void)suword((caddr_t)--uap, (int)arg0); 375 376 /* 377 * Point at the arguments. 378 */ 379 args.fname = arg0; | 382 383 for (pathp = &initpaths[0]; (path = *pathp) != NULL; pathp++) { 384 /* 385 * Move out the boot flag argument. 386 */ 387 options = 0; 388 ucp = (char *)USRSTACK; 389 (void)subyte(--ucp, 0); /* trailing zero */ --- 26 unchanged lines hidden (view full) --- 416 (void)suword((caddr_t)--uap, 0); /* terminator */ 417 (void)suword((caddr_t)--uap, (int)arg1); 418 (void)suword((caddr_t)--uap, (int)arg0); 419 420 /* 421 * Point at the arguments. 422 */ 423 args.fname = arg0; |
380 args.argp = uap; 381 args.envp = NULL; | 424 args.argv = uap; 425 args.envv = NULL; |
382 383 /* 384 * Now try to exec the program. If can't for any reason 385 * other than it doesn't exist, complain. 386 */ 387 if ((error = execve(p, &args, &retval)) == 0) 388 return; 389 if (error != ENOENT) 390 printf("exec %s: error %d\n", path, error); 391 } 392 printf("init: not found\n"); 393 panic("no init"); 394} | 426 427 /* 428 * Now try to exec the program. If can't for any reason 429 * other than it doesn't exist, complain. 430 */ 431 if ((error = execve(p, &args, &retval)) == 0) 432 return; 433 if (error != ENOENT) 434 printf("exec %s: error %d\n", path, error); 435 } 436 printf("init: not found\n"); 437 panic("no init"); 438} |