From f4b25f1bf1b9c485451279a9bb96d026a78e2dbc Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 31 Mar 1995 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1995-03-31 --- pc/devi82365.c | 18 ++++-------- pc/ether509.c | 21 +++++-------- pc/ether589.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ pc/trap.c | 2 +- 4 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 pc/ether589.c diff --git a/pc/devi82365.c b/pc/devi82365.c index fca55e92b515f0276211a5efb05a7f0c9dd8fb82..dae0883d58e12b90925551c2db6a84b53ac7272a 100644 --- a/pc/devi82365.c +++ b/pc/devi82365.c @@ -246,14 +246,8 @@ slotena(Slot *pp) /* power up and unreset, wait's are empirical (???) */ wrreg(pp, Rpc, Fautopower|Foutena|Fcardena); delay(300); - wrreg(pp, Rigc, Fnotreset); - delay(500); - - wrreg(pp, Rpc, 0); - delay(500); - - wrreg(pp, Rpc, Fautopower|Foutena|Fcardena); - delay(300); + wrreg(pp, Rigc, 0); + delay(100); wrreg(pp, Rigc, Fnotreset); delay(500); @@ -263,7 +257,7 @@ slotena(Slot *pp) cisread(pp); pp->enabled = 1; } else - wrreg(pp, Rpc, 0); + wrreg(pp, Rpc, Fautopower); } /* @@ -272,8 +266,8 @@ slotena(Slot *pp) static void slotdis(Slot *pp) { - wrreg(pp, Rwe, 0); /* no windows */ - wrreg(pp, Rpc, 0); /* turn off card power */ + wrreg(pp, Rpc, 0); /* turn off card power */ + wrreg(pp, Rwe, 0); /* no windows */ pp->enabled = 0; } @@ -1306,7 +1300,7 @@ tentry(Slot *pp, int ttype) case 3: if(readc(pp, &c) != 1) return; - for(i = 0; i <= c&0x7; i++) + for(i = 0; i <= (c&0x7); i++) memspace(pp, (c>>5)&0x3, (c>>3)&0x3, c&0x80); break; } diff --git a/pc/ether509.c b/pc/ether509.c index ff3c66547df74f9a35038e54d30c1deb8b80087a..9f5db085c60527ac9fed16fe90478c885fcfab9a 100644 --- a/pc/ether509.c +++ b/pc/ether509.c @@ -279,7 +279,6 @@ interrupt(Ureg *ur, void *arg) Ether *ether; USED(ur); - ether = arg; port = ether->port; @@ -552,18 +551,11 @@ tcm579(Ether *ether) return 0; } -static ulong -tcm589(Ether *ether) -{ - USED(ether); - return 0; -} - /* * Get configuration parameters. */ -static int -reset(Ether *ether) +int +ether509reset(Ether *ether) { int i, eax; uchar ea[Eaddrlen]; @@ -588,12 +580,12 @@ reset(Ether *ether) break; } } + if(strcmp(ether->type, "3C589") == 0) + port = ether->port; if(port == 0) port = tcm579(ether); if(port == 0) port = tcm509(ether); - if(port == 0) - port = tcm589(ether); if(port == 0) return -1; @@ -603,7 +595,8 @@ reset(Ether *ether) * The EEPROM command is 8 bits, the lower 6 bits being * the address offset. */ - ether->irq = (ins(port+ResourceConfig)>>12) & 0x0F; + if(strcmp(ether->type, "3C589") != 0) + ether->irq = (ins(port+ResourceConfig)>>12) & 0x0F; for(eax = 0, i = 0; i < 3; i++, eax += 2){ while(ins(port+EEPROMcmd) & 0x8000) ; @@ -680,5 +673,5 @@ reset(Ether *ether) void ether509link(void) { - addethercard("3C509", reset); + addethercard("3C509", ether509reset); } diff --git a/pc/ether589.c b/pc/ether589.c new file mode 100644 index 0000000000000000000000000000000000000000..5ae9430327c50bf3807db1b0e3b5f3c5d3fccc8f --- /dev/null +++ b/pc/ether589.c @@ -0,0 +1,80 @@ +#include "u.h" +#include "../port/lib.h" +#include "mem.h" +#include "dat.h" +#include "fns.h" +#include "io.h" +#include "../port/error.h" +#include "../port/netif.h" + +#include "etherif.h" + +enum { + SelectWindow = 0x01, /* SelectWindow command */ + + Command = 0x0E, /* all windows */ + Status = 0x0E, + + ManufacturerID = 0x00, /* window 0 */ + ProductID = 0x02, + ConfigControl = 0x04, + AddressConfig = 0x06, + ResourceConfig = 0x08, + EEPROMcmd = 0x0A, + EEPROMdata = 0x0C, +}; + +#define COMMAND(port, cmd, a) outs(port+Command, ((cmd)<<11)|(a)) + +extern int ether509reset(Ether*); + +static int +reset(Ether *ether) +{ + int slot; + int port; + ushort x; + + if(ether->irq == 0) + ether->irq = 10; + if(ether->port == 0) + ether->port = 0x3F0; + port = ether->port; + + slot = pcmspecial("3C589", ether); + if(slot < 0) + return -1; + + /* set Window 0 configuration registers */ + COMMAND(port, SelectWindow, 0); + + /* ROM size & base - must be set before we can access ROM */ + /* transceiver type (for now always 10baseT) */ + x = ins(port + AddressConfig); + outs(port + AddressConfig, x & 0x20); + + /* IRQ must be 3 on 3C589 */ + x = ins(port + ResourceConfig); + outs(port + ResourceConfig, 0x3000 | (x&0xfff)); + + /* move product ID to register */ + while(ins(port+EEPROMcmd) & 0x8000) + ; + outs(port+EEPROMcmd, (2<<6)|3); + while(ins(port+EEPROMcmd) & 0x8000) + ; + x = ins(port+EEPROMdata); + outs(port + ProductID, x); + + if(ether509reset(ether) < 0){ + pcmspecialclose(slot); + return -1; + } + return 0; +} + +void +ether589link(void) +{ + addethercard("3C589", reset); +} diff --git a/pc/trap.c b/pc/trap.c index 9e01d3abbc26efe6654ff90fbc4c26de8827cf0a..9f9c7bbcf9fbbc512caf435a58b2d6e06c105f3f 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -199,7 +199,7 @@ trapinit(void) /* * Set up the second 8259 interrupt processor. * Make 8259 interrupts start at CPU vector Int1vec. - * Set the 8259 as master with edge triggered + * Set the 8259 as master with level triggered * input with fully nested interrupts. */ outb(Int1ctl, (1<<4)|(1<<3)|(1<<0)); /* ICW1 - master, level triggered,