Clean up the prints, add some debug info
authorRonald G. Minnich <rminnich@google.com>
Tue, 4 Mar 2014 02:00:50 +0000 (18:00 -0800)
committerRonald G. Minnich <rminnich@google.com>
Tue, 4 Mar 2014 02:00:50 +0000 (18:00 -0800)
Still does not work of course but at least
we can learn more about why not.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/arch/x86/apic9.c
kern/arch/x86/ioapic.c

index c444b93..af82c18 100644 (file)
@@ -47,6 +47,42 @@ enum {                                               /* Local APIC registers */
        Tslvt           = Lvt5,                 /* Thermal Sensor */
 };
 
+
+static char *apicregnames[] = {
+       [Id]    "Identification",
+       [Ver]   "Version",
+       [Tp]    "Task Priority",
+       [Ap]    "Arbitration Priority",
+       [Pp]    "Processor Priority",
+       [Eoi]   "EOI",
+       [Ld]    "Logical Destination",
+       [Df]    "Destination Format",
+       [Siv]   "Spurious Interrupt Vector",
+       [Is]    "Interrupt Status (8)",
+       [Tm]    "Trigger Mode (8)",
+       [Ir]    "Interrupt Request (8)",
+       [Es]    "Error Status",
+       [Iclo]  "Interrupt Command",
+       [Ichi]  "Interrupt Command [63:32]",
+       [Lvt0]  "Local Vector Table 0",
+       [Lvt5]  "Local Vector Table 5",
+       [Lvt4]  "Local Vector Table 4",
+       [Lvt1]  "Local Vector Table 1",
+       [Lvt2]  "Local Vector Table 2",
+       [Lvt3]  "Local Vector Table 3",
+       [Tic]   "Timer Initial Count",
+       [Tcc]   "Timer Current Count",
+       [Tdc]   "Timer Divide Configuration",
+
+       [Tlvt]  "Timer",
+       [Lint0] "Local Interrupt 0",
+       [Lint1] "Local Interrupt 1",
+       [Elvt]  "Error",
+       [Pclvt] "Performance Counter",
+       [Tslvt] "Thermal Sensor",
+};
+
+
 enum {                                         /* Siv */
        Swen            = 0x00000100,           /* Software Enable */
        Fdis            = 0x00000200,           /* Focus Disable */
@@ -84,9 +120,13 @@ struct apic xlapic[Napic];
 static uint32_t
 apicrget(int r)
 {
+       uint32_t val;
        if (! apicbase)
                panic("apicrget: no apic");
+       val = *((uint32_t*)(apicbase+r));
+       printk("apicrget: %s returns %p\n", apicregnames[r], val);
        return *((uint32_t*)(apicbase+r));
+       return val;
 }
 
 static void
@@ -94,6 +134,7 @@ apicrput(int r, uint32_t data)
 {
        if (! apicbase)
                panic("apicrput: no apic");
+       printk("apicrput: %s = %p\n", apicregnames[r], data);
        *((uint32_t*)(apicbase+r)) = data;
 }
 
@@ -137,13 +178,8 @@ apicinit(int apicno, uintptr_t pa, int isbp)
                printd("apicinit%d: already initialised\n", apicno);
                return;
        }
-       if(apicbase == NULL){
-               if((apicbase = vmap_pmem(pa, 1024)) == NULL){
-                       printd("apicinit%d: can't map apicbase\n", apicno);
-                       return;
-               }
-               printk("apicinit%d: apicbase %#p -> %#p\n", apicno, pa, apicbase);
-       }
+       apicbase = LAPIC_BASE;
+       printk("apicinit%d: apicbase %#p -> %#p\n", apicno, pa, apicbase);
        apic->useable = 1;
        printk("apicinit%d: it's useable\n", apicno);
 
@@ -226,7 +262,7 @@ apiconline(void)
        ver = apicrget(Ver);
        nlvt = ((ver>>16) & 0xff) + 1;
        if(nlvt > ARRAY_SIZE(apic->lvt)){
-               printk("apicinit%d: nlvt %d > max (%d)\n",
+               printk("apiconline%d: nlvt %d > max (%d)\n",
                        apicno, nlvt, ARRAY_SIZE(apic->lvt));
                nlvt = ARRAY_SIZE(apic->lvt);
        }
index 44a65b3..d4681b8 100644 (file)
@@ -140,7 +140,7 @@ printk("NO RDT, install it for apic %d intin %d lo %p\n", apic, intin, lo);
                               busno, apicno, intin, devno, lo, rdt->lo);
                        return;
                }
-               printk("dup rdt %d %d %d %d %.8ux\n", busno, apicno, intin, devno, lo);
+               printk("dup rdt %d %d %d %d %.8p\n", busno, apicno, intin, devno, lo);
        }
        rdt->ref++;
        rbus = kzmalloc(sizeof *rbus, 0);
@@ -210,7 +210,8 @@ ioapicinit(int id, int ibase, uintptr_t pa)
                return;
 
        apic = &xioapic[id];
-       if(apic->useable || (apic->addr = vmap_pmem(pa, 1024)) == NULL)
+       apic->addr = IOAPIC_BASE;
+       if(apic->useable)
                return;
        apic->useable = 1;
        apic->paddr = pa;
@@ -255,7 +256,7 @@ ioapicdump(char *start, char *end)
                        spin_lock(&apic->lock);
                        rtblget(apic, n, &hi, &lo);
                        spin_unlock(&apic->lock);
-                       start = seprintf(start, end, " rdt %2.2d %#8.8p %#8.8p\n", n, hi, lo);
+                       start = seprintf(start, end, " rdt %2.2d %p %p\n", n, hi, lo);
                }
        }
        for(i = 0; i < Nbus; i++){
@@ -407,7 +408,7 @@ intrenablemsi(struct vctl* v, Pcidev *p)
        v->type = "msi";
        v->mask = msimask;
 
-       printk("msiirq: %T: enabling %.16llux %s irq %d vno %d\n", p->tbdf, msivec, v->name, v->irq, vno);
+       printk("msiirq: %T: enabling %.16llp %s irq %d vno %d\n", p->tbdf, msivec, v->name, v->irq, vno);
        return vno;
 }
 #endif
@@ -472,7 +473,7 @@ printk("%s; BusPCI \n", __func__);
                
                busno = BUSBNO(v->tbdf);
                if((pcidev = pcimatchtbdf(v->tbdf)) == NULL)
-                       panic("no PCI dev for tbdf %#8.8ux", v->tbdf);
+                       panic("no PCI dev for tbdf %p", v->tbdf);
                if((vecno = intrenablemsi(v, pcidev)) != -1)
                        return vecno;
                disablemsi(v, pcidev);
@@ -485,16 +486,16 @@ printk("%s; BusPCI \n", __func__);
 printk("INTP is %d\n", devno);
 
                if(devno == 0)
-                       panic("no INTP for tbdf %#8.8ux", v->tbdf);
+                       panic("no INTP for tbdf %p", 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",
+               printk("ioapicintrenable: tbdf %p busno %d devno %d\n",
                       v->tbdf, busno, devno);
        }
        else{
                //SET(busno, devno);
                busno = devno = 0;
-               panic("unknown tbdf %#8.8px", v->tbdf);
+               panic("unknown tbdf %px", v->tbdf);
        }
        
        rdt = NULL;
@@ -529,7 +530,7 @@ 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",
+               printk("isa: tbdf %p busno %d devno %d %#p\n",
                       v->tbdf, busno, devno, rdt);
        }
        if(rdt == NULL){
@@ -566,7 +567,7 @@ printk("Second crack\n");
        vecno = lo & 0xff;
        spin_unlock(&rdt->apic->lock);
 
-       printk("busno %d devno %d hi %#8.8p lo %#8.8p vecno %d\n",
+       printk("busno %d devno %d hi %p lo %p vecno %d\n",
               busno, devno, hi, lo, vecno);
        v->isr = apicisr;
        v->eoi = apiceoi;