From 26f591114e6cb67a9c24d78301e6a108b98f2552 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 16 Feb 1994 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1994-02-16 --- carrera/screen.c | 15 ++++++- pc/ether509.c | 105 ++++++++++++++++++++++++++++++++++------------- pc/kbd.c | 3 +- port/devmouse.c | 6 ++- port/portdat.h | 1 + 5 files changed, 97 insertions(+), 33 deletions(-) diff --git a/carrera/screen.c b/carrera/screen.c index b883f5454e8a2ad237556f18667fac5ca6755793..614bd11f190e124cc852484777475661755c592f 100644 --- a/carrera/screen.c +++ b/carrera/screen.c @@ -118,19 +118,30 @@ void screenwin(void) { Dac *d; + Point p; + int i, y; ulong zbuf[16]; - memset(Screenvirt, 0, 3*1024*1024); + memset((void*)Screenvirt, 0xff, 3*1024*1024); gtexture(&gscreen, gscreen.r, &bgrnd, S); w = defont0.info[' '].width; h = defont0.height; window.min = Pt(100, 100); - window.max = add(window.min, Pt(10+w*120, 10+h*60)); + window.max = add(window.min, Pt(10+w*80, 10+h*40)); + gbitblt(&gscreen, add(window.min, Pt(5, 5)), &gscreen, window, F); gbitblt(&gscreen, window.min, &gscreen, window, Zero); + gborder(&gscreen, window, 4, F); window = inset(window, 5); + for(i = 0; i < h+6; i += 2) { + y = window.min.y+i; + gsegment(&gscreen, Pt(window.min.x, y), Pt(window.max.x, y), ~0, F); + } + p = add(window.min, Pt(10, 2)); + gsubfstring(&gscreen, p, &defont0, "Brazil Console ", S); + window.min.y += h+6; cursor = window.min; window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h; diff --git a/pc/ether509.c b/pc/ether509.c index c02dbb2c70fe0b224b9287b0a039aded7222b1cb..ccc1b6708fca156a34d2ab1744c220773f9e9f4c 100644 --- a/pc/ether509.c +++ b/pc/ether509.c @@ -384,7 +384,7 @@ idseq(void) } static ulong -activate(void) +activate(int tag) { int i; ushort x, acr; @@ -419,9 +419,6 @@ activate(void) /* * 3. Read the Address Configuration from the EEPROM. * The Address Configuration field is at offset 0x08 in the EEPROM). - * 6. Tag the adapter so it won't respond in future. - * 6. Activate the adapter by writing the Activate command - * (0xFF). */ outb(IDport, 0x88); for(acr = 0, i = 0; i < 16; i++){ @@ -429,17 +426,25 @@ activate(void) acr <<= 1; acr |= inb(IDport) & 0x01; } - outb(IDport, 0xD1); - outb(IDport, 0xFF); - - /* - * 8. Now we can talk to the adapter's I/O base addresses. - * We get the I/O base address from the acr just read. - * - * Enable the adapter. - */ port = (acr & 0x1F)*0x10 + 0x200; - outs(port+ConfigControl, Ena); + + if(tag){ + /* + * 6. Tag the adapter so it won't respond in future. + * 6. Activate the adapter by writing the Activate command + * (0xFF). + */ + outb(IDport, 0xD1); + outb(IDport, 0xFF); + + /* + * 8. Now we can talk to the adapter's I/O base addresses. + * We get the I/O base address from the acr just read. + * + * Enable the adapter. + */ + outs(port+ConfigControl, Ena); + } return port; } @@ -447,29 +452,38 @@ activate(void) static ulong tcm509(Ether *ether) { - static int reset; + static int untag; ulong port; Adapter *ap; /* * One time only: * write ID sequence to get the attention of all adapters; - * global-reset all adapters; * untag all adapters. + * If we do a global reset here on all adapters we'll confuse any + * ISA cards configured for EISA mode. */ - if(reset == 0){ + if(untag == 0){ idseq(); - outb(IDport, 0xC0); - delay(2); outb(IDport, 0xD0); - reset = 1; + untag = 1; } /* * Attempt to activate adapters until one matches our - * address criteria. + * address criteria. If adapter is set for EISA mode, + * tag it and ignore. Otherwise, reset the adapter and + * activate it fully. */ - while(port = activate()){ + while(port = activate(0)){ + if(port == 0x3F0){ + outb(IDport, 0xD1); + continue; + } + outb(IDport, 0xC0); + if(activate(1) != port) + print("activate %d\n"); + if(ether->port == 0 || ether->port == port) return port; @@ -486,19 +500,40 @@ static ulong tcm579(Ether *ether) { static int slot = 1; + ushort x; ulong port; Adapter *ap; + /* + * First time through, check if this is an EISA machine. + * If not, nothing to do. + */ if(slot == 1 && strncmp((char*)(KZERO|0xFFFD9), "EISA", 4)) return 0; + + /* + * Continue through the EISA slots looking for a match on both + * 3COM as the manufacturer and 3C579 or 3C579-TP as the product. + * If we find an adapter, select window 0, enable it and clear + * out any lingering status and interrupts. + * Trying to do a GlobalReset here to re-init the card (as in the + * 509 code) doesn't seem to work. + */ while(slot < 16){ port = slot++*0x1000; if(ins(port+0xC80+ManufacturerID) != 0x6D50) continue; - COMMAND(port+0xC80, GlobalReset, 0); - delay(1000); - outs(port+0xC80+ConfigControl, Ena); - COMMAND(port+0xC80, SelectWindow, 0); + x = ins(port+0xC80+ProductID); + if((x & 0xF0FF) != 0x9050/* || (x != 0x9350 && x != 0x9250)*/) + continue; + + COMMAND(port, SelectWindow, 0); + outs(port+ConfigControl, Ena); + + COMMAND(port, TxReset, 0); + COMMAND(port, RxReset, 0); + COMMAND(port, AckIntr, 0xFF); + if(ether->port == 0 || ether->port == port) return port; @@ -511,6 +546,13 @@ tcm579(Ether *ether) return 0; } +static ulong +tcm589(Ether *ether) +{ + USED(ether); + return 0; +} + /* * Get configuration parameters. */ @@ -528,8 +570,8 @@ reset(Ether *ether) * otherwise the ports must match. * See if we've already found an adapter that fits * the bill. - * If no match then try for an EISA card and finally - * for an ISA card. + * If no match then try for an EISA card, an ISA card + * and finally for a PCMCIA card. */ port = 0; for(app = &adapter, ap = *app; ap; app = &ap->next, ap = ap->next){ @@ -544,13 +586,15 @@ reset(Ether *ether) port = tcm579(ether); if(port == 0) port = tcm509(ether); + if(port == 0) + port = tcm589(ether); if(port == 0) return -1; /* * Read the IRQ from the Resource Configuration Register, * the ethernet address from the EEPROM, and the address configuration. - * The EEPROM command is 8bits, the lower 6 bits being + * The EEPROM command is 8 bits, the lower 6 bits being * the address offset. */ ether->irq = (ins(port+ResourceConfig)>>12) & 0x0F; @@ -583,8 +627,11 @@ reset(Ether *ether) /* * Finished with window 2. * Set window 1 for normal operation. + * Clear out any lingering Tx status. */ COMMAND(port, SelectWindow, 1); + while(inb(port+TxStatus)) + outb(port+TxStatus, 0); /* * If we have a 10BASE2 transceiver, start the DC-DC diff --git a/pc/kbd.c b/pc/kbd.c index 7f742ccec799e134f25842073896f81b28d9a0c5..0133cd1e34ee54d02507673146978f2b00e652d5 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -594,7 +594,8 @@ mousectl(char *arg) splx(x); break; } - } + } else if(strcmp(field[0], "swap") == 0) + mouseswap ^= 1; } void diff --git a/port/devmouse.c b/port/devmouse.c index e56c70e7856bdb290581a590c2772d13506e6a85..45716b2342846a6ca3c2c69f585d8dca28b95cb7 100644 --- a/port/devmouse.c +++ b/port/devmouse.c @@ -63,6 +63,7 @@ Mouseinfo mouse; Cursorinfo cursor; int mouseshifted; int mousetype; +int mouseswap; int hwcurs; Cursor curs; @@ -260,11 +261,13 @@ mouseclose(Chan *c) } } + long mouseread(Chan *c, void *va, long n, ulong offset) { char buf[4*12+1]; uchar *p; + static int map[8] = {0, 4, 2, 6, 1, 5, 3, 7 }; p = va; switch(c->qid.path){ @@ -290,7 +293,8 @@ mouseread(Chan *c, void *va, long n, ulong offset) sleep(&mouse.r, mousechanged, 0); lock(&cursor); sprint(buf, "%11d %11d %11d %11d", - mouse.xy.x, mouse.xy.y, mouse.buttons, + mouse.xy.x, mouse.xy.y, + mouseswap ? map[mouse.buttons&7] : mouse.buttons, TK2MS(MACHP(0)->ticks)); mouse.lastcounter = mouse.counter; unlock(&cursor); diff --git a/port/portdat.h b/port/portdat.h index 7e5051153c99cdee23be9d8d0f4bc9905c2b44f3..44f31c911bcc40a4fd13f8eacb0de97c99d19cd8 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -650,3 +650,4 @@ enum }; extern int mouseshifted; extern int mousetype; +extern int mouseswap;