From 40a505f1d80444c5a5ffeb47cd68b91b3f7593d3 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 31 Mar 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-03-31 --- ip/ip.c | 2 +- pc/clock.c | 4 ++-- pc/devata.c | 20 +++++++++++++++----- pc/ether82557.c | 8 ++++---- pc/etherelnk3.c | 10 +++++----- pc/screen.h | 1 - port/devaudio.c | 4 ++-- port/devns16552.c | 20 ++++++++++---------- 8 files changed, 39 insertions(+), 30 deletions(-) diff --git a/ip/ip.c b/ip/ip.c index e46400985d0dbe5925f5ae78f704ed24d4063f4a..abb61fd4381fa2bcf70dee24c8cb30935cadfcd4 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -323,7 +323,7 @@ ipiput(Fs *f, uchar *ia, Block *bp) // h->src, h->dst, BLEN(bp), h->proto); /* - * Ensure we have allt he header info in the first + * Ensure we have all the header info in the first * block. Make life easier for other protocols by * collecting up to the first 64 bytes in the first block. */ diff --git a/pc/clock.c b/pc/clock.c index 6782f49ae5e91543a3d6858c50c2dffa091cbf8f..0e21e510bc328df03af8e492ead8d432ba5d9847 100644 --- a/pc/clock.c +++ b/pc/clock.c @@ -52,10 +52,10 @@ clockintr(Ureg* ureg, void*) checkalarms(); if(m->machno == 0){ - lock(&clock0lock); + ilock(&clock0lock); for(lp = clock0link; lp; lp = lp->link) lp->clock(); - unlock(&clock0lock); + iunlock(&clock0lock); } if(up == 0 || up->state != Running) diff --git a/pc/devata.c b/pc/devata.c index 1ee72b35deda4b7d0b8e890e48973a12181e3580..2b539b44c0767a021ea426d4009b4f0ceb9e310a 100644 --- a/pc/devata.c +++ b/pc/devata.c @@ -346,7 +346,7 @@ static int atactlrprobe(int ctlrno, int irq, int resetok) { Controller *ctlr; - int atapi, mask, port; + int atapi, mask, once, port; uchar error, status, msb, lsb; /* @@ -399,13 +399,16 @@ atactlrprobe(int ctlrno, int irq, int resetok) } } + once = 1; +retry: atapi = 0; mask = 0; DPRINT("ata%d: ATAPI %uX %uX %uX\n", ctlrno, status, inb(port+Pcylmsb), inb(port+Pcyllsb)); - if(status == 0 && inb(port+Pcylmsb) == 0xEB && inb(port+Pcyllsb) == 0x14){ + if(/*status == 0 &&*/ inb(port+Pcylmsb) == 0xEB && inb(port+Pcyllsb) == 0x14){ DPRINT("ata%d: ATAPI ok\n", ctlrno); - intrenable(irq, ataintr, ctlr, ctlr->tbdf); + if(once) + intrenable(irq, ataintr, ctlr, ctlr->tbdf); atapi |= 0x01; mask |= 0x01; goto atapislave; @@ -413,10 +416,16 @@ atactlrprobe(int ctlrno, int irq, int resetok) if(atactlrwait(ctlr, DHmagic, 0, MS2TK(1)) || waserror()){ DPRINT("ata%d: Cedd status %ux/%ux/%ux\n", ctlrno, inb(port+Pstatus), inb(port+Pcylmsb), inb(port+Pcyllsb)); + if(once){ + once = 0; + ctlr->cmd = 0; + goto retry; + } xfree(ctlr); return -1; } - intrenable(irq, ataintr, ctlr, ctlr->tbdf); + if(once) + intrenable(irq, ataintr, ctlr, ctlr->tbdf); ctlr->cmd = Cedd; outb(port+Pcmd, Cedd); atasleep(ctlr, Hardtimeout); @@ -1410,7 +1419,8 @@ atapart(Drive *dp) * the last sector if none is found in the second last. */ i = 0; - ataxfer(dp, &dp->p[0], Cread, (dp->p[0].end-2)*dp->bytes, dp->bytes, buf); + ataxfer(dp, &dp->p[0], Cread, (dp->p[0].end-2)* + (vlong)dp->bytes, dp->bytes, buf); buf[dp->bytes-1] = 0; n = parsefields((char*)buf, line, Npart+1, "\n"); if(n > 0 && strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1) == 0) diff --git a/pc/ether82557.c b/pc/ether82557.c index d763f1d5d621257e5684deccc33db925d6d057e5..0db75935868649c1e3b537d51640175673220960 100644 --- a/pc/ether82557.c +++ b/pc/ether82557.c @@ -554,10 +554,10 @@ interrupt(Ureg*, void* arg) ctlr = ether->ctlr; for(;;){ - lock(&ctlr->rlock); + ilock(&ctlr->rlock); status = csr16r(ctlr, Status); csr8w(ctlr, Ack, (status>>8) & 0xFF); - unlock(&ctlr->rlock); + iunlock(&ctlr->rlock); if(!(status & (StatCX|StatFR|StatCNA|StatRNR|StatMDI|StatSWI))) break; @@ -634,7 +634,7 @@ interrupt(Ureg*, void* arg) } if(status & StatCNA){ - lock(&ctlr->cblock); + ilock(&ctlr->cblock); cb = ctlr->cbtail; while(ctlr->cbq){ @@ -653,7 +653,7 @@ interrupt(Ureg*, void* arg) ctlr->cbtail = cb; txstart(ether); - unlock(&ctlr->cblock); + iunlock(&ctlr->cblock); status &= ~StatCNA; } diff --git a/pc/etherelnk3.c b/pc/etherelnk3.c index c74acb18db28b5c5d28dff73a5e3421f1c4e43b5..14a9d7052a9189af12d553330a4568bf5c1637ff 100644 --- a/pc/etherelnk3.c +++ b/pc/etherelnk3.c @@ -949,7 +949,7 @@ interrupt(Ureg*, void* arg) port = ether->port; ctlr = ether->ctlr; - lock(&ctlr->wlock); + ilock(&ctlr->wlock); w = (STATUS(port)>>13) & 0x07; COMMAND(port, SelectRegisterWindow, Wop); @@ -1102,7 +1102,7 @@ interrupt(Ureg*, void* arg) } COMMAND(port, SelectRegisterWindow, w); - unlock(&ctlr->wlock); + iunlock(&ctlr->wlock); } static long @@ -1509,7 +1509,7 @@ miir(Ether* ether, int phyad, int regad) if(data & 0x10000) return -1; - XCVRDEBUG("phy%d/%d: data=%uX\n", phyad, regad, data); +print("%d/%d: data=%uX\n", phyad, regad, data); return data & 0xFFFF; } @@ -1524,7 +1524,7 @@ scanphy(Ether* ether) continue; x <<= 6; x |= miir(ether, i, 3)>>10; - print("phy%d: oui %uX reg1 %uX\n", i, x, miir(ether, i, 1)); + XCVRDEBUG("phy%d: oui %uX reg1 %uX\n", i, x, miir(ether, i, 1)); } } @@ -1763,7 +1763,7 @@ etherelnk3reset(Ether* ether) an = miir(ether, phyaddr, 0x04); an &= miir(ether, phyaddr, 0x05) & 0x03E0; XCVRDEBUG("mii an: %uX\n", an); - if(an & 0x380) + //if(an & 0x380) ether->mbps = 100; if(an & 0x0140) setfullduplex(port); diff --git a/pc/screen.h b/pc/screen.h index 6f8c750989d8862fc5129da68b6f8043e52fb77e..f8ab293d73c2299301aadceb1f1df7944159fd7d 100644 --- a/pc/screen.h +++ b/pc/screen.h @@ -118,4 +118,3 @@ extern int screenaperture(int, int); /* vga.c */ extern void vgascreenwin(VGAscr*); - diff --git a/port/devaudio.c b/port/devaudio.c index 0a3ca195c68e349e714494f6cfb9a7557b8de853..76ffdc504c97e6cd12b5327da0f8e136deb16563 100644 --- a/port/devaudio.c +++ b/port/devaudio.c @@ -965,10 +965,10 @@ audioread(Chan *c, char *a, long n, vlong off) else{ if(volumes[m].flag & Fin) j += snprint(buf+j, sizeof(buf)-j, - " in %d", liv); + " in %d", liv); if(volumes[m].flag & Fout) j += snprint(buf+j, sizeof(buf)-j, - " out %d", lov); + " out %d", lov); } }else{ if((volumes[m].flag&(Fin|Fout))==(Fin|Fout) && diff --git a/port/devns16552.c b/port/devns16552.c index 3f42c4422c2e64829e4a71a9423cfd67dd1eb71b..cc683d27b8f4d4ec05bd8e6f2adcc95c98bc1ab1 100644 --- a/port/devns16552.c +++ b/port/devns16552.c @@ -559,7 +559,7 @@ ns16552intr(int dev) case 4: /* received data available */ case 12: ch = uartrdreg(p, Data) & 0xff; - lock(&p->tlock); + ilock(&p->tlock); if(p->xonoff){ if(ch == CTLS){ p->blocked = 1; @@ -568,15 +568,15 @@ ns16552intr(int dev) /* clock gets output going again */ } } - unlock(&p->tlock); + iunlock(&p->tlock); if(p->putc) p->putc(p->iq, ch); else { - lock(&p->rlock); + ilock(&p->rlock); if(p->ip < p->ie) *p->ip++ = ch; p->haveinput = 1; - unlock(&p->rlock); + iunlock(&p->rlock); } break; @@ -587,12 +587,12 @@ ns16552intr(int dev) case 0: /* modem status */ ch = uartrdreg(p, Mstat); if(ch & Ctsc){ - lock(&p->tlock); + ilock(&p->tlock); l = p->cts; p->cts = ch & Cts; if(l == 0 && p->cts) p->ctsbackoff = 2; /* clock gets output going again */ - unlock(&p->tlock); + iunlock(&p->tlock); } break; @@ -626,7 +626,7 @@ uartclock(void) /* this amortizes cost of qproduce to many chars */ if(p->haveinput){ - lock(&p->rlock); + ilock(&p->rlock); if(p->haveinput){ n = p->ip - p->istage; if(n > 0 && p->iq){ @@ -639,17 +639,17 @@ uartclock(void) } p->haveinput = 0; } - unlock(&p->rlock); + iunlock(&p->rlock); } /* this adds hysteresis to hardware flow control */ if(p->ctsbackoff){ - lock(&p->tlock); + ilock(&p->tlock); if(p->ctsbackoff){ if(--(p->ctsbackoff) == 0) ns16552kick0(p); } - unlock(&p->tlock); + iunlock(&p->tlock); } } }