# #include "param.h" #include "user.h" #include "systm.h" #include "proc.h" #include "inode.h" #define CLOCK1 0177546 #define CLOCK2 0172540 #define SWREG 0177570 extern char *end; /* End of kernel */ /* * Icode is the octal bootstrap * program executed in user mode * to bring up the system. */ int icode[] { 0104413, /* sys exec; init; initp */ TOPSYS+014, TOPSYS+010, 0000777, /* br . */ TOPSYS+014, /* initp: init; 0 */ 0000000, 0062457, /* init: */ 0061564, 0064457, 0064556, 0000164, }; /* * Initialization code. * Called from mch.s as * soon as a stack * has been established. * Functions: * find which clock is configured * hand craft 0th process * call all initialization routines * fork - process 0 to schedule * - process 1 execute bootstrap * * panic: no clock -- neither clock responds * loop at loc 6 in user mode -- /etc/init * cannot be executed. */ main() { extern schar; register i, *p; updlock = 0; /* determine switch register and clock * (switch reg must be done first since printf() uses it) */ if (fuiword(SWREG) != -1) SW = SWREG; /* * determine clock */ lks = CLOCK1; if (fuiword(lks) == -1) { lks = CLOCK2; if(fuiword(lks) == -1) { lks = 0; prs("No clock?\n"); prs("On an 11/03, turn on clock now\n"); } } /* check system didn't overflow its space */ if (&end > &u) { prs("sys too big\n"); halt(); } /* * set up system process */ proc[0].p_stat = SRUN; proc[0].p_flag =| SLOAD; u.u_procp = &proc[0]; /* * set up 'known' i-nodes */ if (lks != 0) *lks = 0115; cinit(); binit(); iinit(); rootdir = iget(rootdev, ROOTINO); rootdir->i_flag =& ~ILOCK; u.u_cdir = iget(rootdev, ROOTINO); u.u_cdir->i_flag =& ~ILOCK; /* * make init process */ copyout(icode, TOPSYS, sizeof icode); /* * Return goes to loc. 0 of user init * code just copied out. */ }