void main(void) { memset(edata, 0, (ulong)end-(ulong)edata); conf.nmach = 1; machinit(); confinit(); xinit(); trapinit(); mmuinit(); plan9iniinit(); hwintrinit(); clockinit(); timerinit(); console(); quotefmtinstall(); printinit(); cpuidprint(); print("\nPlan 9 from Bell Labs\n"); procinit0(); initseg(); timersinit(); links(); chandevreset(); pageinit(); swapinit(); sharedseginit(); fpsave(&initfp); initfp.fpscr = 0; userinit(); schedinit(); }
// Bootstrap processor starts running C code here. int main(int memsize) { mpinit(); // collect info about this machine lapicinit(mpbcpu()); ksegment(); picinit(); // interrupt controller ioapicinit(); // another interrupt controller consoleinit(); // I/O devices & their interrupts uartinit(); // serial port cprintf("cpus %p cpu %p\n", cpus, cpu); cprintf("\ncpu%d: starting xv6\n\n", cpu->id); cprintf("mem: %d kb\n", memsize); kinit(memsize); // physical memory allocator pinit(); // process table tvinit(); // trap vectors binit(); // buffer cache fileinit(); // file table iinit(); // inode cache ideinit(); // disk if(!ismp) timerinit(); // uniprocessor timer pageinit(); // enable paging userinit(); // first user process bootothers(); // start other processors // Finish setting up this processor in mpmain. mpmain(); }
void main(void) { cgapost(0); mach0init(); options(); ioinit(); i8250console(); quotefmtinstall(); screeninit(); print("\nPlan 9\n"); trapinit0(); mmuinit0(); kbdinit(); i8253init(); cpuidentify(); meminit(); confinit(); archinit(); if(!isa20on()) panic("bootstrap didn't leave a20 address line enabled"); xinit(); if(i8237alloc != nil) i8237alloc(); trapinit(); printinit(); cpuidprint(); mmuinit(); fpsavealloc(); if(arch->intrinit) /* launches other processors on an mp */ arch->intrinit(); timersinit(); mathinit(); kbdenable(); if(arch->clockenable) arch->clockenable(); procinit0(); initseg(); if(delaylink){ bootlinks(); pcimatch(0, 0, 0); }else links(); conf.monitor = 1; chandevreset(); cgapost(0xcd); pageinit(); i8253link(); swapinit(); userinit(); active.thunderbirdsarego = 1; cgapost(0x99); schedinit(); }
void main(void) { extern char edata[], end[]; uint rev; okay(1); m = (Mach*)MACHADDR; memset(edata, 0, end - edata); /* clear bss */ machinit(); mmuinit1(); optionsinit("/boot/boot boot"); quotefmtinstall(); ataginit((Atag*)BOOTARGS); confinit(); /* figures out amount of memory */ xinit(); uartconsinit(); screeninit(); print("\nPlan 9 from Bell Labs\n"); rev = getfirmware(); print("firmware: rev %d\n", rev); if(rev < Minfirmrev){ print("Sorry, firmware (start.elf) must be at least rev %d (%s)\n", Minfirmrev, Minfirmdate); for(;;) ; } trapinit(); clockinit(); printinit(); timersinit(); cpuidprint(); archreset(); procinit0(); initseg(); links(); chandevreset(); /* most devices are discovered here */ pageinit(); swapinit(); userinit(); gpiomeminit(); schedinit(); assert(0); /* shouldn't have returned */ }
void main(void) { hwrpb = (Hwrpb*)0x10000000; hwrpb = (Hwrpb*)(KZERO|hwrpb->phys); arginit(); machinit(); options(); ioinit(); clockinit(); confinit(); archinit(); xinit(); memholes(); if(i8237alloc != nil) i8237alloc(); mmuinit(); if(arch->coreinit) arch->coreinit(); trapinit(); screeninit(); printinit(); /* it's now safe to print */ /* dumpopts(); /* DEBUG */ i8250console(); quotefmtinstall(); print("\nPlan 9\n"); cpuidprint(); if(arch->corehello) arch->corehello(); procinit0(); initseg(); timersinit(); links(); chandevreset(); pageinit(); swapinit(); savefpregs(&initfp); initfp.fpstatus = 0x68028000; userinit(); schedinit(); }
void main(void) { mmuinvalidate(); /* zero out bss */ memset(edata, 0, end-edata); /* point to Mach structure */ m = (Mach*)MACHADDR; memset(m, 0, sizeof(Mach)); m->ticks = 1; active.machs = 1; rs232power(1); quotefmtinstall(); iprint("\nPlan 9 bitsy kernel\n"); confinit(); xinit(); mmuinit(); machinit(); trapinit(); sa1110_uartsetup(1); dmainit(); screeninit(); printinit(); /* from here on, print works, before this we need iprint */ clockinit(); procinit0(); initseg(); links(); chandevreset(); pageinit(); swapinit(); userinit(); powerinit(); schedinit(); }
void main(u32int ax, u32int bx) { vlong hz; memset(edata, 0, end - edata); /* * ilock via i8250enable via i8250console * needs m->machno, sys->machptr[] set, and * also 'up' set to nil. */ cgapost(sizeof(uintptr)*8); memset(m, 0, sizeof(Mach)); m->machno = 0; m->online = 1; m->nixtype = NIXTC; sys->machptr[m->machno] = &sys->mach; m->stack = PTR2UINT(sys->machstk); m->vsvm = sys->vsvmpage; up = nil; active.nonline = 1; active.exiting = 0; active.nbooting = 0; asminit(); multiboot(ax, bx, 0); options(oargc, oargv); crapoptions(); /* * Need something for initial delays * until a timebase is worked out. */ m->cpuhz = 2000000000ll; m->cpumhz = 2000; cgainit(); i8250console("0"); consputs = cgaconsputs; vsvminit(MACHSTKSZ, NIXTC); conf.nmach = 1; fmtinit(); print("\nNIX\n"); if(vflag){ print("&ax = %#p, ax = %#ux, bx = %#ux\n", &ax, ax, bx); multiboot(ax, bx, vflag); } m->perf.period = 1; if((hz = archhz()) != 0ll){ m->cpuhz = hz; m->cyclefreq = hz; m->cpumhz = hz/1000000ll; } /* * Mmuinit before meminit because it * flushes the TLB via m->pml4->pa. */ mmuinit(); ioinit(); kbdinit(); meminit(); confinit(); archinit(); mallocinit(); /* * Acpiinit will cause the first malloc * call to happen. * If the system dies here it's probably due * to malloc not being initialised * correctly, or the data segment is misaligned * (it's amazing how far you can get with * things like that completely broken). */ acpiinit(); umeminit(); trapinit(); printinit(); /* * This is necessary with GRUB and QEMU. * Without it an interrupt can occur at a weird vector, * because the vector base is likely different, causing * havoc. Do it before any APIC initialisation. */ i8259init(32); procinit0(); mpsinit(maxcores); apiconline(); sipi(); timersinit(); kbdenable(); fpuinit(); psinit(conf.nproc); initimage(); links(); devtabreset(); pageinit(); swapinit(); userinit(); nixsquids(); testiccs(); print("schedinit...\n"); schedinit(); }
void dopage P1H(void) { register shalfword cmd ; register integer p ; register chardesctype *cd ; register integer h ; register fontmaptype *cfnt ; register frametype *frp = frames ; integer fnt ; #ifdef Omega integer mychar; #endif int charmove ; struct dvistack *sp = stack ; integer v, w, x, y, z ; integer roundpos ; integer thinspace ; integer vertsmallspace ; #ifdef XENIX integer iconv ; integer viconv ; iconv = (integer)(1.0 / conv + 0.5) ; viconv = (integer)(1.0 / vconv + 0.5) ; #else #ifdef __THINK__ integer iconv ; integer viconv ; iconv = (integer)(1.0 / conv + 0.5) ; viconv = (integer)(1.0 / vconv + 0.5) ; #endif #endif #ifdef EMTEX emclear() ; #endif pageinit() ; bopcolor(1) ; thinspace = (integer)(0.025*DPI/conv) ; /* 0.025 inches */ vertsmallspace = (integer)(0.025*VDPI/vconv) ; /* 0.025 inches */ #ifdef HPS if (HPS_FLAG) pagecounter++ ; H_BREAK = (30 * DPI / 400 ) ; /* 30 seems to have worked well at 400 dpi */ #endif w = x = y = z = 0 ; h = (integer) (DPI / conv * hoff / 4736286.72) ; v = (integer) (DPI / conv * voff / 4736286.72) ; hh = PixRound(h) ; vv = PixRound(v) ; curfnt = NULL ; curpos = NULL ; charmove = 0 ; beginloop: switch (cmd=dvibyte()) { case 138: goto beginloop ; /* nop command does nuttin */ /* * For put1 commands, we subtract the width of the character before * dropping through to the normal character setting routines. This */ #ifdef Omega case 134: /* put2 */ mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ; charmove = 0 ; goto dochar ; case 133: /* put1 */ mychar = dvibyte() ; charmove = 0 ; goto dochar ; case 129: /* set2 */ mychar = dvibyte() ; mychar = (mychar << 8) + dvibyte() ; charmove = 1 ; goto dochar ; case 128: /* set1 */ mychar = dvibyte() ; charmove = 1 ; goto dochar ; default: /* these are commands 0 (setchar0) thru 127 (setchar127) */ mychar = cmd ; charmove = 1 ; dochar: #else case 133: /* put1 */ cmd = dvibyte() ; charmove = 0 ; goto dochar ; case 128: cmd = dvibyte() ; /* set1 command drops through to setchar */ default: /* these are commands 0 (setchar0) thru 127 (setchar127) */ charmove = 1 ; dochar: #endif #ifdef HPS if (HPS_FLAG && PAGEUS_INTERUPPTUS) { HREF_COUNT-- ; start_new_box() ; PAGEUS_INTERUPPTUS = 0 ; } if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); NEED_NEW_BOX = 0; } #endif #ifdef Omega cd = &(curfnt->chardesc[mychar]) ; #else cd = &(curfnt->chardesc[cmd]) ; #endif if (cd->flags & EXISTS) { if (curfnt->loaded == 2) { /* virtual character being typeset */ if (charmove) { sp->hh = hh + cd->pixelwidth ; sp->h = h + cd->TFMwidth ; } else { sp->hh = hh ; sp->h = h ; } sp->vv = vv ; sp-> v = v ; sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; w = x = y = z = 0 ; /* will be in relative units at new stack level */ frp->curp = curpos ; frp->curl = curlim ; frp->ff = ffont ; frp->curf = curfnt ; if (++frp == &frames[MAXFRAME] ) error("! virtual recursion stack overflow") ; curpos = cd->packptr + 2 ; curlim = curpos + (256*(long)(*cd->packptr)+(*(cd->packptr+1))) ; ffont = curfnt->localfonts ; if (ffont) { curfnt = ffont->desc ; thinspace = curfnt->thinspace ; } else { curfnt = NULL ; thinspace = vertsmallspace ; } goto beginloop ; } #ifdef Omega drawchar(cd, mychar) ; #else drawchar(cd, cmd) ; #endif } if (charmove) { h += cd->TFMwidth ; hh += cd->pixelwidth ; } goto setmotion ; #ifdef Omega case 130: case 131: case 135: case 136: case 139: #else case 129: case 130: case 131: case 134: case 135: case 136: case 139: #endif case 247: case 248: case 249: case 250: case 251: case 252: case 253: case 254: case 255: /* unimplemented or illegal commands */ error("! synch") ; case 132: case 137: /* rules */ { integer ry, rx , rxx, ryy ; ry = signedquad() ; rx = signedquad() ; if (rx>0 && ry>0) { if (curpos) { rx = scalewidth(rx, (frp-1)->curf->scaledsize) ; ry = scalewidth(ry, (frp-1)->curf->scaledsize) ; } rxx = (int)(conv * rx + 0.9999999) ; ryy = (int)(vconv * ry + 0.9999999) ; drawrule(rxx, ryy) ; } else rxx = 0 ; if (cmd == 137) goto beginloop ; h += rx ; hh += rxx ; goto setmotion ; } case 141: /* push */ #ifdef HPS if (HPS_FLAG) pushcount++ ; /* if (HPS_FLAG && PAGEUS_INTERUPPTUS) { HREF_COUNT-- ; start_new_box() ; PAGEUS_INTERUPPTUS = 0 ; } */ if (HPS_FLAG && NEED_NEW_BOX) { vertical_in_hps(); NEED_NEW_BOX = 0; } /* printf("push %i, %i\n", pushcount, inHTMLregion) ; */ #endif sp->hh = hh ; sp->vv = vv ; sp->h = h ; sp->v = v ; sp->w = w ; sp->x = x ; sp->y = y ; sp->z = z ; if (++sp >= &stack[STACKSIZE]) error("! Out of stack space") ; goto beginloop ; case 140: /* eop or end of virtual character */ if (curpos == NULL) { /* eop */ #ifdef HPS if (HPS_FLAG && inHTMLregion) PAGEUS_INTERUPPTUS = 1 ; /* printf("Page interrupted"); */ #endif break; } --frp ; curfnt = frp->curf ; thinspace = (curfnt) ? curfnt->thinspace : vertsmallspace ; ffont = frp->ff ; curlim = frp->curl ; curpos = frp->curp ; if (hh < (sp-1)->hh+2 && hh > (sp-1)->hh-2) (sp-1)->hh = hh; /* retain `intelligence' of pixel width, if close */ /* falls through */ case 142: /* pop */ #ifdef HPS pushcount-- ; /* printf("pop %i\n", pushcount) ; */ #endif if (--sp < stack) error("! More pops than pushes") ; #ifdef HPS if (HPS_FLAG) { hhmem = hh ; vvmem = vv ; } #endif hh = sp->hh ; vv = sp->vv ; h = sp->h ; v = sp->v ; w = sp->w ; x = sp->x ; y = sp->y ; z = sp->z ; #ifdef HPS if (HPS_FLAG && inHTMLregion && (hhmem - hh > H_BREAK) && (pushcount > 0) && (pushcount < current_pushcount)) end_current_box() ; #endif goto beginloop ; case 143: /* right1 */ p = signedbyte() ; goto horizontalmotion ; case 144: /* right2 */ p = signedpair() ; goto horizontalmotion ; case 145: /* right3 */ p = signedtrio() ; goto horizontalmotion ; case 146: /* right4 */ p = signedquad() ; goto horizontalmotion ; case 147: /* w0 */ p = w ; goto horizontalmotion ; case 148: /* w1 */ p = w = signedbyte() ; goto horizontalmotion ; case 149: /* w2 */ p = w = signedpair() ; goto horizontalmotion ; case 150: /* w3 */ p = w = signedtrio() ; goto horizontalmotion ; case 151: /* w4 */ p = w = signedquad() ; goto horizontalmotion ; case 152: /* x0 */ p = x ; goto horizontalmotion ; case 153: /* x1 */ p = x = signedbyte() ; goto horizontalmotion ; case 154: /* x2 */ p = x = signedpair() ; goto horizontalmotion ; case 155: /* x3 */ p = x = signedtrio() ; goto horizontalmotion ; case 156: /* x4 */ p = x = signedquad() ; goto horizontalmotion ; case 157: /* down1 */ p = signedbyte() ; goto verticalmotion ; case 158: /* down2 */ p = signedpair() ; goto verticalmotion ; case 159: /* down3 */ p = signedtrio() ; goto verticalmotion ; case 160: /* down4 */ p = signedquad() ; goto verticalmotion ; case 161: /* y0 */ p = y ; goto verticalmotion ; case 162: /* y1 */ p = y = signedbyte() ; goto verticalmotion ; case 163: /* y2 */ p = y = signedpair() ; goto verticalmotion ; case 164: /* y3 */ p = y = signedtrio() ; goto verticalmotion ; case 165: /* y4 */ p = y = signedquad() ; goto verticalmotion ; case 166: /* z0 */ p = z ; goto verticalmotion ; case 167: /* z1 */ p = z = signedbyte() ; goto verticalmotion ; case 168: /* z2 */ p = z = signedpair() ; goto verticalmotion ; case 169: /* z3 */ p = z = signedtrio() ; goto verticalmotion ; case 170: /* z4 */ p = z = signedquad() ; goto verticalmotion ; case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: case 200: case 201: case 202: case 203: case 204: case 205: case 206: case 207: case 208: case 209: case 210: case 211: case 212: case 213: case 214: case 215: case 216: case 217: case 218: case 219: case 220: case 221: case 222: case 223: case 224: case 225: case 226: case 227: case 228: case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: /* font selection commands */ if (cmd < 235) fnt = cmd - 171 ; /* fntnum0 thru fntnum63 */ else { fnt = dvibyte() ; while (cmd-- > 235) fnt = (fnt << 8) + dvibyte() ; } if (curpos || fnt > 255) { for (cfnt=ffont; cfnt; cfnt = cfnt->next) if (cfnt->fontnum == fnt) break ; curfnt = cfnt->desc ; } else curfnt = baseFonts[fnt] ; thinspace = curfnt->thinspace ; goto beginloop ; case 243: case 244: case 245: case 246: /*fntdef1 */ skipover(cmd - 230) ; skipover(dvibyte() + dvibyte()) ; goto beginloop ; case 239: /* xxx1 */ p = dvibyte() ; dospecial(p) ; goto beginloop ; case 240: /* xxx2 */ p = twobytes() ; dospecial(p) ; goto beginloop ; case 241: /* xxx3 */ p = threebytes() ; dospecial(p) ; goto beginloop ; case 242: /* xxx4 */ p = signedquad() ; dospecial(p) ; goto beginloop ; /* * The calculations here are crucial to the appearance of the document. * If the motion is small, we round the amount of relative motion; otherwise, * we update the position and round the new position. Then we check to * insure that the rounded position didn't accumulate an error that was * greater than maxdrift. */ verticalmotion: /* vertical motion cases */ if (curpos) p = scalewidth(p, (frp-1)->curf->scaledsize) ; v += p ; if (p >= vertsmallspace) vv = VPixRound(v) ; else if (p <= -vertsmallspace) vv = VPixRound(v) ; else { vv += VPixRound(p) ; roundpos = VPixRound(v) ; if (roundpos - vv > vmaxdrift) vv = roundpos - vmaxdrift ; else if (vv - roundpos > vmaxdrift) vv = roundpos + vmaxdrift ; } #ifdef HPS /* printf("Doing vertical motion: p = %i, v = %i, vv = %i\n",p,v,vv); */ /* printf("inHTMLregion %i\n", inHTMLregion) ; */ if (HPS_FLAG && inHTMLregion) NEED_NEW_BOX = 1 /* vertical_in_hps() */; #endif goto beginloop ; /* * Horizontal motion is analogous. We know the exact width of each * character in pixels. Kerning is distinguished from space between * words if it's less than a thinspace and not more negative than would * occur when an accent is being positioned by backspacing. */ horizontalmotion: /* horizontal motion cases */ if (curpos) p = scalewidth(p, (frp-1)->curf->scaledsize) ; h += p ; if (p >= thinspace || p <= -6 * thinspace) { hh = PixRound(h) ; goto beginloop ; } else hh += PixRound(p) ; #ifdef HPS /* printf("Doing horizontal motion: p = %i, h = %i, hh = %i\n",p,h,hh); */ #endif setmotion: roundpos = PixRound(h) ; if (roundpos - hh > maxdrift) { hh = roundpos - maxdrift ; } else if (hh - roundpos > maxdrift) { hh = roundpos + maxdrift ; } goto beginloop ; } /* end of the big switch */ pageend() ; }
/* * 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"); }
/* * at entry, l.s has set m for cpu0 and printed "Plan 9 from Be" * but has not zeroed bss. */ void main(void) { int cpu; static ulong vfy = 0xcafebabe; up = nil; if (vfy != 0xcafebabe) { serialputc('?'); serialputc('d'); panic("data segment misaligned"); } memset(edata, 0, end - edata); /* * we can't lock until smpon has run, but we're supposed to wait * until l1 & l2 are on. too bad. l1 is on, l2 will soon be. */ smpon(); iprint("ll Labs "); cacheinit(); /* * data segment is aligned, bss is zeroed, caches' characteristics * are known. begin initialisation. */ mach0init(); l2pageinit(); mmuinit(); optionsinit("/boot/boot boot"); quotefmtinstall(); /* want plan9.ini to be able to affect memory sizing in confinit */ plan9iniinit(); /* before we step on plan9.ini in low memory */ /* l2 looks for *l2off= in plan9.ini */ l2cache->on(); /* l2->on requires locks to work, thus smpon */ l2cache->info(&cachel[2]); allcache->on(); cortexa9cachecfg(); trapinit(); /* so confinit can probe memory to size it */ confinit(); /* figures out amount of memory */ /* xinit prints (if it can), so finish up the banner here. */ delay(100); navailcpus = getncpus(); iprint("(mp arm; %d cpus)\n\n", navailcpus); delay(100); for (cpu = 1; cpu < navailcpus; cpu++) stopcpu(cpu); xinit(); irqtooearly = 0; /* now that xinit and trapinit have run */ mainmem->flags |= POOL_ANTAGONISM /* | POOL_PARANOIA */ ; /* * Printinit will cause the first malloc call. * (printinit->qopen->malloc) unless any of the * above (like clockinit) 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. */ archreset(); /* cfg clock signals, print cache cfg */ clockinit(); /* start clocks */ timersinit(); delay(50); /* let uart catch up */ printinit(); kbdenable(); cpuidprint(); chkmissing(); procinit0(); initseg(); // dmainit(); links(); conf.monitor = 1; // screeninit(); iprint("pcireset..."); pcireset(); /* this tends to hang after a reboot */ iprint("ok\n"); chandevreset(); /* most devices are discovered here */ // i8250console(); /* too early; see init0 */ pageinit(); /* prints "1020M memory: ⋯ */ swapinit(); userinit(); /* * starting a cpu will eventually result in it calling schedinit, * so everything necessary to run user processes should be set up * before starting secondary cpus. */ launchinit(); /* SMP & FW are already on when we get here; u-boot set them? */ for (cpu = 1; cpu < navailcpus; cpu++) if (startcpu(cpu) < 0) panic("cpu%d didn't start", cpu); l1diag(); schedinit(); panic("cpu%d: schedinit returned", m->machno); }
void main(uint32_t mbmagic, uint32_t mbaddress) { Mach *m = entrym; /* when we get here, entrym is set to core0 mach. */ sys->machptr[m->machno] = m; // Very special case for BSP only. Too many things // assume this is set. wrmsr(GSbase, PTR2UINT(&sys->machptr[m->machno])); if (machp() != m) panic("m and machp() are different!!\n"); assert(sizeof(Mach) <= PGSZ); /* * Check that our data is on the right boundaries. * This works because the immediate value is in code. */ if (x != 0x123456) panic("Data is not set up correctly\n"); memset(edata, 0, end - edata); m = (void *) (KZERO + 1048576 + 11*4096); sys = (void *) (KZERO + 1048576); /* * ilock via i8250enable via i8250console * needs m->machno, sys->machptr[] set, and * also 'up' set to nil. */ cgapost(sizeof(uintptr_t)*8); memset(m, 0, sizeof(Mach)); m->machno = 0; m->online = 1; m->nixtype = NIXTC; sys->machptr[m->machno] = &sys->mach; m->stack = PTR2UINT(sys->machstk); *(uintptr_t*)m->stack = STACKGUARD; m->vsvm = sys->vsvmpage; m->externup = (void *)0; active.nonline = 1; active.exiting = 0; active.nbooting = 0; asminit(); multiboot(mbmagic, mbaddress, 0); options(oargc, oargv); /* * Need something for initial delays * until a timebase is worked out. */ m->cpuhz = 2000000000ll; m->cpumhz = 2000; cgainit(); i8250console("0"); consputs = cgaconsputs; /* It all ends here. */ vsvminit(MACHSTKSZ, NIXTC, m); if (machp() != m) panic("After vsvminit, m and machp() are different"); sys->nmach = 1; fmtinit(); print("\nHarvey\n"); if(vflag){ multiboot(mbmagic, mbaddress, vflag); } m->perf.period = 1; if((hz = archhz()) != 0ll){ m->cpuhz = hz; m->cyclefreq = hz; m->cpumhz = hz/1000000ll; } //iprint("archhz returns 0x%lld\n", hz); //iprint("NOTE: if cpuidhz runs too fast, we get die early with a NULL pointer\n"); //iprint("So, until that's fixed, we bring up AP cores slowly. Sorry!\n"); /* * Mmuinit before meminit because it * flushes the TLB via m->pml4->pa. */ mmuinit(); ioinit(); meminit(); confinit(); archinit(); mallocinit(); /* test malloc. It's easier to find out it's broken here, * not deep in some call chain. * See next note. * void *v = malloc(1234); hi("v "); put64((uint64_t)v); hi("\n"); free(v); hi("free ok\n"); */ /* * Acpiinit will cause the first malloc * call to happen. * If the system dies here it's probably due * to malloc not being initialised * correctly, or the data segment is misaligned * (it's amazing how far you can get with * things like that completely broken). */ if (0){ acpiinit(); hi(" acpiinit();\n");} umeminit(); trapinit(); /* * This is necessary with GRUB and QEMU. * Without it an interrupt can occur at a weird vector, * because the vector base is likely different, causing * havoc. Do it before any APIC initialisation. */ i8259init(32); procinit0(); mpsinit(maxcores); apiconline(); /* Forcing to single core if desired */ if(!nosmp) { sipi(); } teardownidmap(m); timersinit(); fpuinit(); psinit(conf.nproc); initimage(); links(); keybinit(); keybenable(); mouseenable(); devtabreset(); pageinit(); swapinit(); userinit(); /* Forcing to single core if desired */ if(!nosmp) { nixsquids(); testiccs(); } print("CPU Freq. %dMHz\n", m->cpumhz); print("schedinit...\n"); schedinit(); }
void main(void) { int machno; /* entry to main pushed stuff onto the stack. */ // memset(edata, 0, (ulong)end-(ulong)edata); machno = getpir(); if (machno > 0) startcpu(machno); // dcrcompile(); if (dverify != 0x01020304) { uartlputs("data segment not initialised\n"); panic("data segment not initialised"); } if (bverify != 0) { uartlputs("bss segment not zeroed\n"); panic("bss segment not zeroed"); } mach0init(); archreset(); quotefmtinstall(); optionsinit("/boot/boot boot"); // archconsole(); meminit(); confinit(); mmuinit(); xinit(); /* xinit would print if it could */ trapinit(); qtminit(); ioinit(); uncinit(); printinit(); uartliteconsole(); mainmem->flags |= POOL_ANTAGONISM; mainmem->panic = mypanic; ethermedium.maxtu = 1512; /* must be multiple of 4 for temac's dma */ // print("\n\nPlan 9k H\n"); /* already printed by l.s */ plan9iniinit(); timersinit(); clockinit(); dma0init(); /* does not start kprocs; see init0 */ fpuinit(); procinit0(); initseg(); links(); chandevreset(); okprint = 1; /* only now can we print */ barriers(); dcflush((uintptr)&okprint, sizeof okprint); cpuidprint(); print("%d Hz clock", HZ); print("; memory size %,ud (%#ux)\n", (uint)memsz, (uint)memsz); pageinit(); swapinit(); userinit(); active.thunderbirdsarego = 1; dcflush((uintptr)&active.thunderbirdsarego, sizeof active.thunderbirdsarego); schedinit(); /* no return */ panic("schedinit returned"); }
void main(void) { Proc *savup; static ulong vfy = Datamagic; static char novga[] = "\nno vga; serial console only\n"; savup = up; up = nil; /* m has been set by l32v.s */ /* * disable address wraps at 1MB boundaries. * if we're 9boot, ldecomp.s already did this. */ a20init(); mach0init(); // options(); /* we don't get options passed to us */ ioinit(); /* we later call i8250console after plan9.ini has been read */ i8250config("0"); /* configure serial port 0 with defaults */ quotefmtinstall(); fmtinstall('i', eipfmt); fmtinstall('I', eipfmt); fmtinstall('E', eipfmt); fmtinstall('V', eipfmt); fmtinstall('M', eipfmt); screeninit(); /* cga setup */ cgapost(0xc); trapinit0(); mmuinit0(); kbdinit(); i8253init(); cpuidentify(); readlsconf(); meminit(); confinit(); archinit(); xinit(); if(i8237alloc != nil) i8237alloc(); /* dma (for floppy) init */ trapinit(); printinit(); sanity(); cgapost(1); /* * soekris servers have no built-in video but each has a serial port. * they must see serial output, if any, before cga output because * otherwise the soekris bios will translate cga output to serial * output, which will garble serial console output. */ pcimatch(nil, 0, 0); /* force scan of pci table */ if (!pcivga) { screenputs = nil; uartputs(novga, sizeof novga - 1); } print(" %s\n\n", hellomsg); if (vfy != Datamagic) panic("data segment incorrectly aligned or loaded"); if (savup) print("up was non-nil (%#p) upon entry to main; bss wasn't zeroed!\n", savup); // xsummary(); cpuidprint(); mmuinit(); if(arch->intrinit) /* launches other processors on an mp */ arch->intrinit(); timersinit(); mathinit(); kbdenable(); /* * 9loadusb runs much faster if we don't use the clock. * perhaps we're competing with the bios for the use of it? */ if(!noclock && arch->clockenable) arch->clockenable(); procinit0(); initseg(); if(delaylink){ bootlinks(); pcimatch(0, 0, 0); }else links(); conf.monitor = 1; cgapost(0xcd); chandevreset(); cgapost(2); pageinit(); /* must follow xinit, and conf.mem must be populated */ i8253link(); userinit(); active.thunderbirdsarego = 1; cgapost(0xb0); schedinit(); }
void main(void) { // int i; extern char bdata[], edata[], end[], etext[]; static ulong vfy = 0xcafebabe; /* l.s has already printed "Plan 9 from Be" */ // m = mach; /* now done in l.s */ /* realign data seg; apparently -H0 -R4096 does not pad the text seg */ if (vfy != 0xcafebabe) { // wave('<'); wave('-'); memmove(bdata, etext, edata - bdata); } /* * once data segment is in place, always zero bss since we may * have been loaded by another Plan 9 kernel. */ memset(edata, 0, end - edata); /* zero BSS */ cacheuwbinv(); l2cacheuwbinv(); if (vfy != 0xcafebabe) panic("data segment misaligned"); vfy = 0; wave('l'); machinit(); mmuinit(); optionsinit("/boot/boot boot"); quotefmtinstall(); /* want plan9.ini to be able to affect memory sizing in confinit */ plan9iniinit(); /* before we step on plan9.ini in low memory */ trapinit(); /* so confinit can probe memory to size it */ confinit(); /* figures out amount of memory */ /* xinit prints (if it can), so finish up the banner here. */ delay(500); iprint("l Labs\n\n"); delay(500); xinit(); mainmem->flags |= POOL_ANTAGONISM /* | POOL_PARANOIA */ ; /* * Printinit will cause the first malloc call. * (printinit->qopen->malloc) unless any of the * above (like clockinit) 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. */ archreset(); /* configure clock signals */ clockinit(); /* start clocks */ timersinit(); watchdoginit(); delay(250); /* let uart catch up */ printinit(); // kbdenable(); cpuidprint(); // chkmissing(); procinit0(); initseg(); dmainit(); links(); conf.monitor = 1; screeninit(); chandevreset(); /* most devices are discovered here */ // i8250console(); /* too early; see init0 */ pageinit(); swapinit(); userinit(); schedinit(); }