void archreset(void) { static int beenhere; if (beenhere) return; beenhere = 1; /* conservative temporary values until archconfinit runs */ m->cpuhz = 1000 * Mhz; /* trimslice speed */ m->delayloop = m->cpuhz/2000; /* initial estimate */ prcachecfg(); clockson(); /* all partitions were powered up by u-boot, so needn't do anything */ archconfinit(); // resetusb(); fpon(); if (irqtooearly) panic("archreset: too early for irqenable"); irqenable(Cpu0irq, sgintr, nil, "cpu0"); irqenable(Cpu1irq, sgintr, nil, "cpu1"); /* ... */ }
void confinit(void) { char *p; int pcnt; if(p = getconf("*kernelpercent")) pcnt = 100 - strtol(p, 0, 0); else pcnt = 0; conf.nscc = 4; conf.smcuarts = 1<<0; /* SMC1 (usual console) */ conf.sccuarts = 1<<1; /* SCC2 available by default */ archconfinit(); conf.npage = conf.npage0 + conf.npage1; if(pcnt < 10) pcnt = 70; conf.ialloc = (((conf.npage*(100-pcnt))/100)/2)*BY2PG; conf.nproc = 100 + ((conf.npage*BY2PG)/MB)*5; conf.nmach = MAXMACH; }
/* * entered from l.s with mmu enabled. * * we may have to realign the data segment; apparently 5l -H0 -R4096 * does not pad the text segment. on the other hand, we may have been * loaded by another kernel. * * be careful not to touch the data segment until we know it's aligned. */ void main(Mach* mach) { extern char bdata[], edata[], end[], etext[]; static ulong vfy = 0xcafebabe; m = mach; if (vfy != 0xcafebabe) memmove(bdata, etext, edata - bdata); if (vfy != 0xcafebabe) { wave('?'); panic("misaligned data segment"); } memset(edata, 0, end - edata); /* zero bss */ vfy = 0; wave('9'); machinit(); archreset(); mmuinit(); optionsinit("/boot/boot boot"); quotefmtinstall(); archconsole(); wave(' '); /* want plan9.ini to be able to affect memory sizing in confinit */ plan9iniinit(); /* before we step on plan9.ini in low memory */ /* set memsize before xinit */ confinit(); /* xinit would print if it could */ xinit(); /* * Printinit will cause the first malloc call. * (printinit->qopen->malloc) unless any of the * above (like clockintr) do an irqenable, which * will call malloc. * If the system dies here it's probably due * to malloc(->xalloc) not being initialised * correctly, or the data segment is misaligned * (it's amazing how far you can get with * things like that completely broken). * * (Should be) boilerplate from here on. */ trapinit(); clockinit(); printinit(); uartkirkwoodconsole(); /* only now can we print */ print("from Bell Labs\n\n"); #ifdef CRYPTOSANDBOX print("sandbox: 64K at physical %#lux, mapped to 0xf10b0000\n", PADDR((uintptr)sandbox & ~(BY2PG-1))); #endif archconfinit(); cpuidprint(); timersinit(); procinit0(); initseg(); links(); chandevreset(); /* most devices are discovered here */ spiprobe(); pageinit(); swapinit(); userinit(); schedinit(); panic("schedinit returned"); }