/* init_main.c 4.7 %G% */
* Called from cold start routine as
* soon as a stack and segmentation
* clear and free user core
* call all initialization routines
* fork - process 0 to schedule
* - process 2 to page out
* - process 1 execute bootstrap
* loop at loc 13 (0xd) in user mode -- /etc/init
* set up system process 0 (swapper)
p
->p_p0br
= (struct pte
*)mfpr(P0BR
);
setredzone(p
->p_addr
, (caddr_t
)&u
);
for (i
= 1; i
< sizeof(u
.u_limit
)/sizeof(u
.u_limit
[0]); i
++)
u
.u_limit
[i
] = ctob(MAXDSIZ
);
rootdir
= iget(rootdev
, (ino_t
)ROOTINO
);
rootdir
->i_flag
&= ~ILOCK
;
u
.u_cdir
= iget(rootdev
, (ino_t
)ROOTINO
);
u
.u_cdir
->i_flag
&= ~ILOCK
;
* make page-out daemon (process 2)
* the daemon has ctopt(NSWBUF*CLSIZE*KLMAX) pages of page
* table so that it can map dirty pages into
* its address space during asychronous pushes.
proc
[0].p_szpt
= clrnd(ctopt(NSWBUF
*CLSIZE
*KLMAX
+ UPAGES
));
proc
[1].p_stat
= SZOMB
; /* force it to be in proc slot 2 */
proc
[2].p_flag
|= SLOAD
|SSYS
;
proc
[2].p_dsize
= u
.u_dsize
= NSWBUF
*CLSIZE
*KLMAX
;
expand(clrnd((int)btoc(szicode
)), P0BR
);
(void) swpexpand(u
.u_dsize
, 0, &u
.u_dmap
, &u
.u_smap
);
(void) copyout((caddr_t
)icode
, (caddr_t
)0, (unsigned)szicode
);
* Return goes to loc. 0 of user init
* iinit is called once (from main)
* very early in initialization.
* It reads the root's super block
* and initializes the current date
* from the last modified date.
* panic: iinit -- cannot read the super
* block. Usually because of an IO error.
register struct filsys
*fp
;
(*bdevsw
[major(rootdev
)].d_open
)(rootdev
, 1);
bp
= bread(rootdev
, SUPERB
);
bp
->b_flags
|= B_LOCKED
; /* block can never be re-used */
mount
[0].m_dev
= rootdev
;
* This is the set of buffers proper, whose heads
* were declared in buf.h. There can exist buffer
* headers not pointing here that are used purely
* as arguments to the I/O routines to describe
* I/O to be done-- e.g. swap headers swbuf[] for
* These are actually allocated kernel map slots and space is
* allocated in locore.s for them.
char buffers
[NBUF
][BSIZE
];
* Initialize the buffer I/O system by freeing
* all buffers and setting all device buffer lists to empty.
for (dp
= bfreelist
; dp
< &bfreelist
[BQUEUES
]; dp
++) {
dp
->b_forw
= dp
->b_back
= dp
->av_forw
= dp
->av_back
= dp
;
dp
--; /* dp = &bfreelist[BQUEUES-1]; */
bp
->b_un
.b_addr
= buffers
[i
];
bp
->b_flags
= B_BUSY
|B_INVAL
;
for (bdp
= bdevsw
; bdp
->d_open
; bdp
++)
* Count swap devices, and adjust total swap space available.
* Some of this space will not be available until a vswapon()
* system is issued, usually when the system goes multi-user.
for (swp
= swdevt
; swp
->sw_dev
; swp
++)
* Initialize linked list of free swap
* headers. These do not actually point
* to buffers, but rather to pages that
* are being swapped in and out.
bswlist
.av_forw
= &swbuf
[0];
for (i
=0; i
<NSWBUF
-1; i
++)
swbuf
[i
].av_forw
= &swbuf
[i
+1];
swbuf
[NSWBUF
-1].av_forw
= NULL
;