put in checks that will allow acpi and other discovery mechanisms to declare that certain hardware that is traditionally just assumed to be declared unavailable. also, move the remaining bits of the Conf structure into the sys structure, and remove the Conf structure. this means conf.nmach -> sys->nmach. old habits may die hard. Reference: /n/atom/patch/applied2013/acpichkprobe Date: Sat Oct 5 17:30:20 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/nix/k10/dat.h Sat Oct 5 17:26:32 2013 +++ /sys/src/nix/k10/dat.h Sat Oct 5 17:26:33 2013 @@ -1,4 +1,3 @@ -typedef struct Conf Conf; typedef struct Fxsave Fxsave; typedef struct Label Label; typedef struct Lock Lock; @@ -88,13 +87,6 @@ int emptiness; }; -struct Conf -{ - uint nmach; /* processors */ - uint nproc; /* processes */ - uint nimage; /* number of page cache image headers */ -}; - enum { NPGSZ = 4 /* # of supported pages sizes in Mach */ @@ -229,13 +221,17 @@ uint copymode; /* 0 is copy on write, 1 is copy on reference */ - uchar legacyprobe; /* acpi tells us */ - uchar i8042kbd; + uchar nolegacyprobe; /* acpi tells us */ + uchar noi8042kbd; uchar novga; uchar nomsi; uchar nocmos; uchar monitor; + + uint nmach; /* processors */ + uint nproc; /* processes */ + uint nimage; /* number of page cache image headers */ uvlong npages; /* total physical pages of memory */ uvlong upages; /* user page pool */ --- /sys/src/nix/k10/kbd.c Sat Oct 5 17:26:34 2013 +++ /sys/src/nix/k10/kbd.c Sat Oct 5 17:26:35 2013 @@ -175,7 +175,6 @@ int mouseshifted; void (*kbdmouse)(int); -static int nokbd = 1; static Lock i8042lock; static uchar ccc; @@ -222,7 +221,7 @@ ushort *s; int i, x; - if(nokbd) + if(sys->noi8042kbd) return; s = KADDR(0x472); @@ -330,7 +329,7 @@ { int leds; - if(nokbd) + if(sys->noi8042kbd) return; leds = 0; if(kbscan->scroll) @@ -595,6 +594,9 @@ { int c, try; + if(sys->noi8042kbd) + return; + /* wait for a quiescent controller */ try = 1000; while(try-- > 0 && (c = inb(Status)) & (Outbusy | Inready)) { @@ -604,6 +606,7 @@ } if (try <= 0) { print(initfailed); + sys->noi8042kbd = 1; return; } @@ -620,10 +623,9 @@ ccc |= Csf | Ckbdint | Cscs1; if(outready() < 0) { print(initfailed); + sys->noi8042kbd = 1; return; } - - nokbd = 0; /* disable mouse */ if (outbyte(Cmd, 0x60) < 0 || outbyte(Data, ccc) < 0) --- /sys/src/nix/k10/cga.c Sat Oct 5 17:26:36 2013 +++ /sys/src/nix/k10/cga.c Sat Oct 5 17:26:36 2013 @@ -27,15 +27,17 @@ Width = 80*2, Height = 25, - Postcodelen = 2, - Postlen = Postcodelen, + Postlen = 2, }; #define CGA (BIOSSEG(0xb800)) -static Lock cgalock; -static int cgapos; -static int cgainitdone; +struct { + Lock; + int pos; + int initdone; + uchar *cga; +} cga; static Rune ibm437[256] = { 0x2007, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, @@ -89,37 +91,31 @@ static void cgacursor(void) { - uchar *cga; - - cgaregw(0x0e, (cgapos/2>>8) & 0xff); - cgaregw(0x0f, cgapos/2 & 0xff); - - cga = CGA; - cga[cgapos+1] = Attr; + cgaregw(0x0e, (cga.pos/2>>8) & 0xff); + cgaregw(0x0f, cga.pos/2 & 0xff); + cga.cga[cga.pos+1] = Attr; } static void cgaputr(Rune c) { int i; - uchar *cga, *p; - - cga = CGA; + uchar *p; if(c == '\n'){ - cgapos = cgapos/Width; - cgapos = (cgapos+1)*Width; + cga.pos = cga.pos/Width; + cga.pos = (cga.pos+1)*Width; } else if(c == '\t'){ - i = 8 - ((cgapos/2)&7); + i = 8 - ((cga.pos/2)&7); while(i-- > 0) cgaputr(' '); } else if(c == '\b'){ - if(cgapos >= 2) - cgapos -= 2; + if(cga.pos >= 2) + cga.pos -= 2; cgaputr(' '); - cgapos -= 2; + cga.pos -= 2; } else{ if(c < ' ' || c >= 127) @@ -133,17 +129,17 @@ break; } } - cga[cgapos++] = c; - cga[cgapos++] = Attr; + cga.cga[cga.pos++] = c; + cga.cga[cga.pos++] = Attr; } - if(cgapos >= (Width*Height)-Postlen*2){ - memmove(cga, &cga[Width], Width*(Height-1)); - p = &cga[Width*(Height-1)-Postlen*2]; + if(cga.pos >= (Width*Height)-Postlen*2){ + memmove(cga.cga, &cga.cga[Width], Width*(Height-1)); + p = &cga.cga[Width*(Height-1)-Postlen*2]; for(i = 0; i < Width/2; i++){ *p++ = ' '; *p++ = Attr; } - cgapos -= Width; + cga.pos -= Width; } cgacursor(); } @@ -154,37 +150,45 @@ int i; Rune r; - ilock(&cgalock); + if(sys->novga || cga.initdone == 0) + return; + ilock(&cga); while(n > 0 && fullrune(s, n)){ i = chartorune(&r, s); n -= i; s += i; cgaputr(r); } - iunlock(&cgalock); + iunlock(&cga); } void cgapost(int code) { - uchar *cga; - + uchar *p; static char hex[] = "0123456789ABCDEF"; - cga = CGA; - cga[Width*Height-Postcodelen*2] = hex[(code>>4) & 0x0f]; - cga[Width*Height-Postcodelen*2+1] = Attr; - cga[Width*Height-Postcodelen*2+2] = hex[code & 0x0f]; - cga[Width*Height-Postcodelen*2+3] = Attr; + if(sys->novga) + return; + ilock(&cga); + p = (uchar*)CGA + Width*Height-Postlen*2; + p[0] = hex[(code>>4) & 0x0f]; + p[1] = Attr; + p[2] = hex[code & 0x0f]; + p[3] = Attr; + iunlock(&cga); } void cgainit(void) { - ilock(&cgalock); - cgapos = cgaregr(0x0e)<<8; - cgapos |= cgaregr(0x0f); - cgapos *= 2; - cgainitdone = 1; - iunlock(&cgalock); + if(sys->novga) + return; + ilock(&cga); + cga.pos = cgaregr(0x0e)<<8; + cga.pos |= cgaregr(0x0f); + cga.pos *= 2; + cga.cga = CGA; + cga.initdone = 1; + iunlock(&cga); } --- /sys/src/nix/k10/sdide.c Sat Oct 5 17:26:38 2013 +++ /sys/src/nix/k10/sdide.c Sat Oct 5 17:26:39 2013 @@ -1136,6 +1136,8 @@ print("ide: %T: pci style %#ux %#ux\n", p->tbdf, c->cmd, c->ctl); if(c->cmd == c->ctl) continue; + else if(sys->nolegacyprobe) + continue; }else if(lchan[seq].probed == 0){ lchan[seq].probed = 1; c->tbdf = BUSUNKNOWN; --- /sys/src/nix/k10/main.c Sat Oct 5 17:26:39 2013 +++ /sys/src/nix/k10/main.c Sat Oct 5 17:26:40 2013 @@ -8,7 +8,6 @@ #include "io.h" #include "apic.h" -Conf conf; uintptr kseg0 = KZERO; Sys* sys; char dbgflg[256]; @@ -83,7 +82,7 @@ for(i = 1; i < MACHMAX; i++) if((mp = sys->machptr[i]) != nil && mp->online != 0){ - conf.nmach++; + sys->nmach++; ainc(&active.nbooting); } sys->epoch = rdtsc(); @@ -101,6 +100,13 @@ } void +sysconfinit(void) +{ + sys->nproc = 2000; + sys->nimage = 200; +} + +void main(void) { vlong hz; @@ -126,7 +132,7 @@ active.nbooting = 0; log2init(); adrinit(); - confinit(); + sysconfinit(); options(); /* @@ -143,7 +149,7 @@ vsvminit(MACHSTKSZ); - conf.nmach = 1; + sys->nmach = 1; fmtinit(); print("\nnix\n"); @@ -193,7 +199,7 @@ timersinit(); kbdenable(); fpuinit(); - psinit(conf.nproc); + psinit(sys->nproc); initimage(); links(); devtabreset(); @@ -346,13 +352,6 @@ kunmap(k); ready(p); -} - -void -confinit(void) -{ - conf.nproc = 2000; - conf.nimage = 200; } static void --- /sys/src/nix/k10/devarch.c Sat Oct 5 17:26:41 2013 +++ /sys/src/nix/k10/devarch.c Sat Oct 5 17:26:42 2013 @@ -309,7 +309,7 @@ u32int *lp; Rdwrfn *fn; - switch((ulong)c->qid.path){ + switch((uint)c->qid.path){ case Qiob: p = a; --- /sys/src/nix/k10/audiohda.c Sat Oct 5 17:26:43 2013 +++ /sys/src/nix/k10/audiohda.c Sat Oct 5 17:26:45 2013 @@ -1702,7 +1702,7 @@ ctlr->q = qopen(256, 0, 0, 0); ctlr->mem = vmap(p->mem[0].bar & ~(uintmem)0xf, ctlr->size); if(ctlr->mem == nil){ - print("#A%d: hda: can't map %.8ux\n", ctlr->no, p->mem[0].bar); + print("#A%d: hda: can't map %#P\n", ctlr->no, p->mem[0].bar); return -1; } print("#A%d: hda: mem %p irq %d\n", ctlr->no, ctlr->mem, irq); --- /sys/src/nix/k10/acpi.c Sat Oct 5 17:26:46 2013 +++ /sys/src/nix/k10/acpi.c Sat Oct 5 17:26:47 2013 @@ -608,8 +608,6 @@ Tbl *t; print("acpiinit\n"); -uvlong tk; -tk = rdtsc(); maptables(); amlinit(); loadtbls("DSDT", 0); @@ -632,9 +630,9 @@ break; switch(*p){ case 0x00: /* Processor Local APIC */ - if(p[4] & Lapicen && conf.nmach < maxmach){ + if(p[4] & Lapicen && nmach < maxmach){ lapicinit(p[3], lapicbase, nmach==0); - /* conf.nmach = */++nmach; + ++nmach; } break; case 0x01: /* I/O APIC */ @@ -674,7 +672,5 @@ amlexit(); print("acpiinit: %d maches\n", nmach); -tk += rdtsc(); -print("acpi: time %lld ms\n", tk*1000/m->cpuhz); addarchfile("acpitbls", 0444, readtbls, nil); } --- /sys/src/nix/port/portdat.h Sat Oct 5 17:26:48 2013 +++ /sys/src/nix/port/portdat.h Sat Oct 5 17:26:49 2013 @@ -1032,7 +1032,6 @@ DEVDOTDOT = -1, }; -extern Conf conf; extern char* conffile; extern Uart* consuart; extern int cpuserver; --- /sys/src/nix/port/portfns.h Sat Oct 5 17:26:50 2013 +++ /sys/src/nix/port/portfns.h Sat Oct 5 17:26:51 2013 @@ -42,7 +42,6 @@ void cmderror(Cmdbuf*, char*); int cmount(Chan**, Chan*, int, char*); Block* concatblock(Block*); -void confinit(void); int consactive(void); void (*consdebug)(void); void (*consputs)(char*, int); @@ -190,7 +189,6 @@ ulong ms2tk(ulong); void mul64fract(uvlong*, uvlong, uvlong); void muxclose(Mnt*); -void (*mwait)(void *); Chan* namec(char*, int, int, int); void nameerror(char*, char*); Chan* newchan(void); @@ -235,7 +233,6 @@ void* phystag(uintmem); void pio(Segment*, uintptr, usize, Page**, int); #define poperror() up->nerrlab-- -void portmwait(void*); int postnote(Proc*, int, char*, int); int pprint(char*, ...); int preempted(void); --- /sys/src/nix/port/proc.c Sat Oct 5 17:26:53 2013 +++ /sys/src/nix/port/proc.c Sat Oct 5 17:26:54 2013 @@ -382,7 +382,7 @@ /* * On average, p has used p->cpu of a cpu recently. - * Its fair share is conf.nmach/m->load of a cpu. If it has been getting + * Its fair share is sys->nmach/m->load of a cpu. If it has been getting * too much, penalize it. If it has been getting not enough, reward it. * I don't think you can get much more than your fair share that * often, so most of the queues are for using less. Having a priority @@ -399,11 +399,11 @@ return p->basepri; /* - * fairshare = 1.000 * conf.nproc * 1.000/load, + * fairshare = 1.000 * sys->nmach * 1.000/load, * except the decimal point is moved three places * on both load and fairshare. */ - fairshare = (conf.nmach*1000*1000)/load; + fairshare = (sys->nmach*1000*1000)/load; n = p->cpu; if(n == 0) n = 1; @@ -831,12 +831,12 @@ psdecref(pp); } bm = 0; - for(i=0; inmach; i++) if(nwired[i] < nwired[bm]) bm = i; } else { /* use the virtual machine requested */ - bm = bm % conf.nmach; + bm = bm % sys->nmach; } p->wired = sys->machptr[bm]; @@ -1437,7 +1437,7 @@ for(ns = 0; ns < NSEG; ns++){ if(p->seg[ns] == s){ p->newtlb = 1; - for(nm = 0; nm < conf.nmach; nm++){ + for(nm = 0; nm < sys->nmach; nm++){ if(sys->machptr[nm]->proc == p){ sys->machptr[nm]->mmuflush = 1; nwait++; @@ -1456,7 +1456,7 @@ * wait for all processors to take a clock interrupt * and flush their mmu's. */ - for(nm = 0; nm < conf.nmach; nm++) + for(nm = 0; nm < sys->nmach; nm++) if(sys->machptr[nm] != m) while(sys->machptr[nm]->mmuflush) sched(); --- /sys/src/nix/port/ps.c Sat Oct 5 17:26:55 2013 +++ /sys/src/nix/port/ps.c Sat Oct 5 17:26:55 2013 @@ -63,7 +63,7 @@ /* * Placeholder. */ - if(i >= conf.nproc) + if(i >= sys->nproc) return nil; return &procalloc.arena[i]; } --- /sys/src/nix/port/taslock.c Sat Oct 5 17:26:56 2013 +++ /sys/src/nix/port/taslock.c Sat Oct 5 17:26:57 2013 @@ -63,7 +63,7 @@ lockstats.inglare++; i = 0; while(l->key){ - if(conf.nmach < 2 && up && up->edf && (up->edf->flags & Admitted)){ + if(sys->nmach < 2 && up && up->edf && (up->edf->flags & Admitted)){ /* * Priority inversion, yield on a uniprocessor; on a * multiprocessor, the other processor will unlock --- /sys/src/nix/port/image.c Sat Oct 5 17:26:57 2013 +++ /sys/src/nix/port/image.c Sat Oct 5 17:26:58 2013 @@ -94,7 +94,7 @@ } /* - * On clu, set conf.nimages = 10 to exercise reclaiming. + * On clu, set sys->nimages = 10 to exercise reclaiming. * It won't be able to get through all of cpurc, but will reclaim. */ void @@ -102,11 +102,11 @@ { Image *i, *ie; - DBG("initimage: %ud images\n", conf.nimage); - imagealloc.mru = malloc(conf.nimage*sizeof(Image)); + DBG("initimage: %ud images\n", sys->nimage); + imagealloc.mru = malloc(sys->nimage*sizeof(Image)); if(imagealloc.mru == nil) panic("imagealloc: no memory"); - ie = &imagealloc.mru[conf.nimage]; + ie = &imagealloc.mru[sys->nimage]; for(i = imagealloc.mru; i < ie; i++){ i->c = nil; i->ref = 0; @@ -114,8 +114,8 @@ i->next = i+1; } imagealloc.mru[0].prev = nil; - imagealloc.mru[conf.nimage-1].next = nil; - imagealloc.lru = &imagealloc.mru[conf.nimage-1]; + imagealloc.mru[sys->nimage-1].next = nil; + imagealloc.lru = &imagealloc.mru[sys->nimage-1]; imagealloc.freechan = malloc(NFREECHAN * sizeof(Chan*)); imagealloc.szfreechan = NFREECHAN; --- /sys/src/nix/port/devproc.c Sat Oct 5 17:27:00 2013 +++ /sys/src/nix/port/devproc.c Sat Oct 5 17:27:01 2013 @@ -233,7 +233,7 @@ if(s < 0) return -1; } - else if(s >= conf.nproc) + else if(s >= sys->nproc) return -1; if((p = psincref(s)) == nil || (pid = p->pid) == 0) @@ -343,7 +343,7 @@ static void procinit(void) { - if(conf.nproc >= (SLOTMASK>>QSHIFT) - 1) + if(sys->nproc >= (SLOTMASK>>QSHIFT) - 1) print("warning: too many procs for devproc\n"); addclock0link((void (*)(void))profclock, 113); /* Relative prime to HZ */ }