More cleanup.
authorRonald G. Minnich <rminnich@google.com>
Mon, 3 Mar 2014 23:25:16 +0000 (15:25 -0800)
committerRonald G. Minnich <rminnich@google.com>
Mon, 3 Mar 2014 23:25:16 +0000 (15:25 -0800)
Also, we needed tbdf in the ether struct as a "hook" for the ioapic.
ioapics really want that devno in the interrupt tables.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/arch/x86/ioapic.c
kern/drivers/dev/ether.c
kern/drivers/dev/pci.c
kern/drivers/net/ether8139.c
kern/include/ip.h

index 2fb4b56..2f6a8c8 100644 (file)
@@ -426,7 +426,7 @@ ioapicintrenable(Vctl* v)
  * the work in progress...
  */
        if(v->tbdf == BUSUNKNOWN){
-
+printk("%s; BUSUNKNOWN\n", __func__);
                if(v->irq >= IrqLINT0 && v->irq <= MaxIrqLAPIC){
                        if(v->irq != IrqSPURIOUS)
                                v->isr = apiceoi;
@@ -434,6 +434,8 @@ ioapicintrenable(Vctl* v)
                        return v->irq;
                }
                else{
+printk("%s; legacy isa\n", __func__);
+
                        /*
                         * Legacy ISA.
                         * Make a busno and devno using the
@@ -451,6 +453,7 @@ ioapicintrenable(Vctl* v)
                }
        }
        else if(BUSTYPE(v->tbdf) == BusPCI){
+printk("%s; BusPCI \n", __func__);
                /*
                 * PCI.
                 * Make a devno from BUSDNO(tbdf) and pcidev->intp.
@@ -471,10 +474,12 @@ ioapicintrenable(Vctl* v)
                
                explode_tbdf(v->tbdf);
                devno = pcidev_read8(&pcidev, PciINTP);
+printk("INTP is %d\n", devno);
 
                if(devno == 0)
                        panic("no INTP for tbdf %#8.8ux", v->tbdf);
                devno = BUSDNO(v->tbdf)<<2|(devno-1);
+printk("devno is %08lx\n", devno);
                printk("ioapicintrenable: tbdf %#8.8p busno %d devno %d\n",
                       v->tbdf, busno, devno);
        }
@@ -485,13 +490,16 @@ ioapicintrenable(Vctl* v)
        }
        
        rdt = NULL;
-       for(rbus = rdtbus[busno]; rbus != NULL; rbus = rbus->next)
+       for(rbus = rdtbus[busno]; rbus != NULL; rbus = rbus->next){
+               printk("Check rbus->devno %p devno %p\n", rbus->devno, devno);
                if(rbus->devno == devno){
                        rdt = rbus->rdt;
                        break;
                }
+       }
        if(rdt == NULL){
                extern int mpisabusno;
+printk("rdt is NULLLLLLLLLLLLLLLLLLLLLL\n");
                
                /*
                 * First crack in the smooth exterior of the new code:
@@ -505,15 +513,19 @@ ioapicintrenable(Vctl* v)
                devno = v->irq<<2;
                for(rbus = rdtbus[busno]; rbus != NULL; rbus = rbus->next)
                        if(rbus->devno == devno){
+printk("rbus->devno = %p, devno %p\n", rbus->devno, devno);
                                rdt = rbus->rdt;
                                break;
                        }
                printk("isa: tbdf %#8.8ux busno %d devno %d %#p\n",
                       v->tbdf, busno, devno, rdt);
        }
-       if(rdt == NULL)
+       if(rdt == NULL){
+               printk("RDT Is STILL NULL!\n");
                return -1;
+       }
        
+printk("Second crack\n");
        /*
         * Second crack:
         * what to do about devices that intrenable/intrdisable frequently?
@@ -527,13 +539,13 @@ ioapicintrenable(Vctl* v)
         * rather than putting a Lock in each entry.
         */
        spin_lock(&rdt->apic->lock);
-       printk("%T: %ld/%d/%d (%d)\n", v->tbdf, rdt->apic - xioapic, rbus->devno, rdt->intin, devno);
+       printk("%p: %ld/%d/%d (%d)\n", v->tbdf, rdt->apic - xioapic, rbus->devno, rdt->intin, devno);
        if((rdt->lo & 0xff) == 0){
                vecno = nextvec();
                rdt->lo |= vecno;
                rdtvecno[vecno] = rdt;
        }else
-               printk("%T: mutiple irq bus %d dev %d\n", v->tbdf, busno, devno);
+               printk("%p: mutiple irq bus %d dev %d\n", v->tbdf, busno, devno);
 
        rdt->enabled++;
        lo = (rdt->lo & ~Im);
@@ -542,7 +554,7 @@ ioapicintrenable(Vctl* v)
        vecno = lo & 0xff;
        spin_unlock(&rdt->apic->lock);
 
-       printk("busno %d devno %d hi %#8.8ux lo %#8.8ux vecno %d\n",
+       printk("busno %d devno %d hi %#8.8p lo %#8.8p vecno %d\n",
               busno, devno, hi, lo, vecno);
        v->isr = apicisr;
        v->eoi = apiceoi;
@@ -607,9 +619,10 @@ intrenable(int irq, void (*f)(void*, void*), void* a, int tbdf)
 
        //spilock(&vctllock);
        vno = ioapicintrenable(v);
+       printk("INTRENABLE, vno is %d\n", vno);
        if(vno == -1){
                //iunlock(&vctllock);
-               printk("intrenable: couldn't enable irq %d, tbdf %#ux for %s\n",
+               printk("intrenable: couldn't enable irq %d, tbdf %p for %s\n",
                        irq, tbdf, v->name);
                kfree(v);
                return NULL;
@@ -636,5 +649,6 @@ intrenable(int irq, void (*f)(void*, void*), void* a, int tbdf)
         * the handler; the IRQ is useless in the wonderful world
         * of the IOAPIC.
         */
+       printk("INTRNABLE returns %d\n", v);
        return v;
 }
index ff00f7e..cc482c2 100644 (file)
@@ -682,7 +682,7 @@ static void etherreset(void)
                        snprintf(name, sizeof(name), "ether%d", ctlrno);
 
                        if (ether->interrupt != NULL)
-                               register_dev_irq(ether->irq, ether->interrupt, ether, BUSUNKNOWN);
+                               register_dev_irq(ether->irq, ether->interrupt, ether, ether->tbdf);
 
                        i = snprintf(buf, sizeof(buf),
                                                 "#l%d: %s: %dMbps port 0x%x irq %u", ctlrno,
index 614583b..33cd8a5 100644 (file)
@@ -20,6 +20,7 @@
 #include <pmap.h>
 #include <smp.h>
 #include <ip.h>
+#include <arch/io.h>
 
 enum {
        Qtopdir = 0,
index 5cc149a..f995e6f 100644 (file)
@@ -17,6 +17,7 @@
 #include <pmap.h>
 #include <smp.h>
 #include <ip.h>
+#include <arch/io.h>
 
 enum {                                                 /* registers */
        Idr0 = 0x0000,                          /* MAC address */
@@ -749,6 +750,10 @@ static int rtl8139pnp(struct ether *edev)
                edev->ea[4] = i;
                edev->ea[5] = i >> 8;
        }
+       edev->tbdf = MKBUS(BusPCI, ctlr->pcidev->bus, 
+                          ctlr->pcidev->dev, ctlr->pcidev->func);
+       printk("TBDF is %p\n", edev->tbdf);
+monitor(NULL);
        edev->attach = rtl8139attach;
        edev->transmit = rtl8139transmit;
        edev->interrupt = rtl8139interrupt;
index 8c802e1..b9574b4 100644 (file)
@@ -999,6 +999,9 @@ struct ether {
 
        /* another case where we wish we had anon struct members. */
        struct netif netif;
+
+       /* xxxx -- this is a defect in this implementation. */
+       unsigned int tbdf;
 };
 
 extern struct block *etheriq(struct ether *, struct block *, int);