]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/9/pc/ether83815.c
kernel: cleanup the software mouse cursor mess
[plan9front.git] / sys / src / 9 / pc / ether83815.c
index 19131b0f6437650c65abd237d991d89c46842cdd..a65fe719ed167ac3c7fc6505ac7acc653d366768 100644 (file)
@@ -24,8 +24,7 @@
 #include "io.h"
 #include "../port/error.h"
 #include "../port/netif.h"
-
-#include "etherif.h"
+#include "../port/etherif.h"
 
 #define DEBUG          0
 #define debug          if(DEBUG)print
@@ -92,6 +91,7 @@ enum {                                /* PCI vendor & device IDs */
        SiSrev630s =    0x81,
        SiSrev630e =    0x82,
        SiSrev630ea1 =  0x83,
+       SiSrev635 =     0x90,
 
        SiSeenodeaddr = 8,              /* short addr of SiS eeprom mac addr */
        SiS630eenodeaddr =      9,      /* likewise for the 630 */
@@ -166,6 +166,7 @@ static Ctlr* ctlrtail;
 enum {
        /* registers (could memory map) */
        Rcr=    0x00,           /* command register */
+         Rld=          1<<10,  /* reload */
          Rst=          1<<8,
          Rxr=          1<<5,   /* receiver reset */
          Txr=          1<<4,   /* transmitter reset */
@@ -544,7 +545,7 @@ interrupt(Ureg*, void* arg)
                                                freeb(des->bp);
                                        }else{
                                                des->bp->wp = des->bp->rp+len;
-                                               etheriq(ether, des->bp, 1);
+                                               etheriq(ether, des->bp);
                                        }
                                        des->bp = bp;
                                        des->addr = PADDR(bp->rp);
@@ -644,7 +645,7 @@ ctlrinit(Ether* ether)
        for(des = ctlr->rdr; des < &ctlr->rdr[ctlr->nrdr]; des++){
                des->bp = iallocb(Rbsz);
                if(des->bp == nil)
-                       error(Enomem);
+                       panic("ether83815: can't allocate receive buffer");
                des->cmdsts = Rbsz;
                des->addr = PADDR(des->bp->rp);
                if(last != nil)
@@ -772,6 +773,8 @@ softreset(Ctlr* ctlr, int resetphys)
         * Soft-reset the controller
         */
        resetctlr(ctlr);
+       if(ctlr->id != Nat83815)
+               return 0;
        csr32w(ctlr, Rccsr, Pmests);
        csr32w(ctlr, Rccsr, 0);
        csr32w(ctlr, Rcfg, csr32r(ctlr, Rcfg) | Pint_acen);
@@ -923,7 +926,21 @@ sissrom(Ctlr *ctlr)
        int i, off = SiSeenodeaddr, cnt = sizeof ee.eaddr / sizeof(short);
        ushort *shp = (ushort *)ee.eaddr;
 
-       if(!is630(ctlr->id, ctlr->pcidev) || !sisrdcmos(ctlr)) {
+       if(ctlr->id == SiS900 && ctlr->pcidev->rid == SiSrev635) {
+               csr32w(ctlr, Rcr, csr32r(ctlr, Rcr) | Rld);
+               csr32w(ctlr, Rcr, csr32r(ctlr, Rcr) & ~Rld);
+               csr32w(ctlr, Rrfcr, csr32r(ctlr, Rrfcr) & ~Rfen);
+
+               csr32w(ctlr, Rrfcr, 0);
+               *shp++ = csr32r(ctlr, Rrfdr);
+               csr32w(ctlr, Rrfcr, 1<<16);
+               *shp++ = csr32r(ctlr, Rrfdr);
+               csr32w(ctlr, Rrfcr, 1<<17);
+               *shp = csr32r(ctlr, Rrfdr);
+
+               csr32w(ctlr, Rrfcr, csr32r(ctlr, Rrfcr) | Rfen);
+               memmove(ctlr->sromea, ee.eaddr, sizeof ctlr->sromea);
+       } else if(!is630(ctlr->id, ctlr->pcidev) || !sisrdcmos(ctlr)) {
                for (i = 0; i < cnt; i++)
                        *shp++ = eegetw(ctlr, off++);
                memmove(ctlr->sromea, ee.eaddr, sizeof ctlr->sromea);
@@ -1068,6 +1085,10 @@ scanpci83815(void)
                 * bar[1] is the memory-mapped register address.
                 */
                ctlr = malloc(sizeof(Ctlr));
+               if(ctlr == nil){
+                       print("ns83815: can't allocate memory\n");
+                       continue;
+               }
                ctlr->port = p->mem[0].bar & ~0x01;
                ctlr->pcidev = p;
                ctlr->id = id;
@@ -1077,13 +1098,6 @@ scanpci83815(void)
                        free(ctlr);
                        continue;
                }
-
-               if(softreset(ctlr, 0) == -1){
-                       free(ctlr);
-                       continue;
-               }
-               srom(ctlr);
-
                if(ctlrhead != nil)
                        ctlrtail->next = ctlr;
                else
@@ -1127,6 +1141,10 @@ reset(Ether* ether)
        if(ctlr == nil)
                return -1;
 
+       pcienable(ctlr->pcidev);
+       softreset(ctlr, 0);
+       srom(ctlr);
+
        ether->ctlr = ctlr;
        ether->port = ctlr->port;
        ether->irq = ctlr->pcidev->intl;
@@ -1197,13 +1215,15 @@ reset(Ether* ether)
         */
        ether->attach = attach;
        ether->transmit = transmit;
-       ether->interrupt = interrupt;
        ether->ifstat = ifstat;
 
        ether->arg = ether;
        ether->promiscuous = promiscuous;
        ether->multicast = multicast;
        ether->shutdown = shutdown;
+
+       intrenable(ether->irq, interrupt, ether, ether->tbdf, ether->name);
+
        return 0;
 }