Browse Source

ACPI: testing move to ACPI-based interrupts

This boots to working, using only ACPI to set up interrupts.

Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 7 years ago
parent
commit
3979a85be4

+ 1 - 1
sys/src/9/386/i8042.c

@@ -327,7 +327,7 @@ keybenable(void)
 	ioalloc(Data, 1, 0, "keyb");
 	ioalloc(Cmd, 1, 0, "keyb");
 
-	intrenable(IrqKBD, i8042intr, 0, BUSUNKNOWN, "keyb");
+	intrenable(IrqKBD, i8042intr, 0, MKBUS(BusISA, 0xff, 0xff, 0xff), "keyb");
 
 	addarchfile("ps2keyb", 0666, keybread, nil);
 

+ 1 - 1
sys/src/9/amd64/apic.c

@@ -348,7 +348,7 @@ apiconline(void)
 
 	if(apic->Lapic.machno == 0){
 		apicrput(Tic, apic->Lapic.max);
-		intrenable(IdtTIMER, apictimer, 0, -1, "APIC timer");
+		intrenable(IdtTIMER, apictimer, 0, MKBUS(BusLAPIC, 0, 0, 0), "APIC timer");
 		apicrput(Tlvt, Periodic|IrqTIMER);
 	}
 

+ 3 - 1
sys/src/9/amd64/io.h

@@ -115,6 +115,8 @@ enum {
 	BusVL,				/* VESA Local bus */
 	BusVME,				/* VMEbus */
 	BusXPRESS,			/* Express System Bus */
+	BusLAPIC,	/* Local APIC, fake type */
+	BusIPI,	/* IPIs, fake type like the LAPIC */
 };
 
 #define MKBUS(t,b,d,f)	(((t)<<24)|(((b)&0xFF)<<16)|(((d)&0x1F)<<11)|(((f)&0x07)<<8))
@@ -123,7 +125,7 @@ enum {
 #define BUSBNO(tbdf)	(((tbdf)>>16)&0xFF)
 #define BUSTYPE(tbdf)	((tbdf)>>24)
 #define BUSBDF(tbdf)	((tbdf)&0x00FFFF00)
-#define BUSUNKNOWN	(-1)
+#define BUSUNKNOWN	MKBUS(BusISA, 0xff, 0xff, 0xff)
 
 enum {
 	MaxEISA		= 16,

+ 29 - 26
sys/src/9/amd64/ioapic.c

@@ -219,6 +219,8 @@ static int acpi_make_rdt(int tbdf, int irq, int busno, int devno)
 	Apicst *st, *lst;
 	uint32_t lo;
 	int pol, edge_level, ioapic_nr, gsi_irq;
+print("acpi_make_rdt(0x%x %d %d 0x%x)\n", tbdf, irq, busno, devno);
+//die("acpi.make.rdt)\n");
 
 	at = apics;
 	st = nil;
@@ -273,13 +275,15 @@ ioapicinit(int id, int ibase, uintptr_t pa)
 	 * Mark the IOAPIC useable if it has a good ID
 	 * and the registers can be mapped.
 	 */
-	if(id >= Napic)
-
+	if(id >= Napic) {
+		print("NOT setting ioapic %d useable; id must be < %d\n", id, Napic);
 		return;
+	}
 
 	apic = &xioapic[id];
 	if(apic->useable || (apic->Ioapic.addr = vmap(pa, 1024)) == nil)
 		return;
+	print("===================> set %d useable\n", id);
 	apic->useable = 1;
 	apic->Ioapic.paddr = pa;
 
@@ -694,38 +698,37 @@ int bus_irq_setup(Vctl *v)
 		}
 	}
 	switch (BUSTYPE(v->Vkey.tbdf)) {
-#if 0
 	case BusLAPIC:
 		/* nxm used to set the initial 'isr' method (i think equiv to our
 		 * check_spurious) to apiceoi for non-spurious lapic vectors.  in
 		 * effect, i think they were sending the EOI early, and their eoi
 		 * method was 0.  we're not doing that (unless we have to). */
-		irq_h->check_spurious = lapic_check_spurious;
-		irq_h->eoi = lapic_send_eoi;
-		irq_h->mask = lapic_mask_irq;
-		irq_h->unmask = lapic_unmask_irq;
-		irq_h->route_irq = 0;
-		irq_h->type = "lapic";
+		//v->check_spurious = lapic_check_spurious;
+		v->eoi = nil; //apiceoi;
+		v->isr = apiceoi;
+		//v->mask = lapic_mask_irq;
+		//v->unmask = lapic_unmask_irq;
+		//v->route_irq = 0;
+		v->type = "lapic";
 		/* For the LAPIC, irq == vector */
-		return irq_h->dev_irq;
+		return v->Vkey.irq;
 	case BusIPI:
 		/* similar to LAPIC, but we don't actually have LVT entries */
-		irq_h->check_spurious = lapic_check_spurious;
-		irq_h->eoi = lapic_send_eoi;
-		irq_h->mask = 0;
-		irq_h->unmask = 0;
-		irq_h->route_irq = 0;
-		irq_h->type = "IPI";
-		return irq_h->dev_irq;
-		case BusISA:
-			if (mpisabusno == -1)
-				panic("No ISA bus allocated");
-			busno = mpisabusno;
-			/* need to track the irq in devno in PCI interrupt assignment entry
-			 * format (see mp.c or MP spec D.3). */
-			devno = v->Vkey.irq << 2;
-			break;
-#endif
+		//v->check_spurious = lapic_check_spurious;
+		v->eoi = apiceoi;
+		//v->mask = 0;
+		//v->unmask = 0;
+		//v->route_irq = 0;
+		v->type = "IPI";
+		return v->Vkey.irq;
+	case BusISA:
+		if (mpisabusno == -1)
+			panic("No ISA bus allocated");
+		busno = mpisabusno;
+		/* need to track the irq in devno in PCI interrupt assignment entry
+		 * format (see mp.c or MP spec D.3). */
+		devno = v->Vkey.irq << 2;
+		break;
 	case BusPCI:
 		p = pcimatchtbdf(v->Vkey.tbdf);
 		if (!p) {

+ 5 - 3
sys/src/9/amd64/main.c

@@ -55,7 +55,7 @@ char dbgflg[256];
 static int vflag = 1;
 
 int nosmp = 1;
-int acpionly = 0;
+int acpionly = 1;
 
 /*
  *	this may need improvement, but right now it's just for
@@ -148,8 +148,8 @@ options(int argc, char* argv[])
 	}
 	vflag = dbgflg['v'];
 	// hack.
-	nosmp = dbgflg['n'];
-	acpionly = dbgflg['z'];
+	//nosmp = dbgflg['n'];
+	//acpionly = dbgflg['z'];
 }
 
 void
@@ -600,8 +600,10 @@ if (1){	acpiinit(); hi("	acpiinit();\n");}
 
 
 	procinit0();
+	print("before mpsinit: acpionly %d, maxcores %d\n", acpionly, maxcores);
 	if (! acpionly)
 		maxcores = mpsinit(maxcores);
+	print("before mpacpi, maxcores %d\n", maxcores);
 	mpacpi(maxcores);
 	apiconline();
 	/* Forcing to single core if desired */

+ 4 - 17
sys/src/9/amd64/trap.c

@@ -54,6 +54,7 @@ intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
 	int vno;
 	Vctl *v;
 	extern int ioapicintrenable(Vctl*);
+	extern int bus_irq_setup(Vctl*);
 	if(f == nil){
 		print("intrenable: nil handler for %d, tbdf %#x for %s\n",
 			irq, tbdf, name);
@@ -70,7 +71,7 @@ intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name)
 	v->name[KNAMELEN-1] = 0;
 
 	ilock(&vctllock);
-	vno = ioapicintrenable(v);
+	vno = bus_irq_setup(v);
 	if(vno == -1){
 		iunlock(&vctllock);
 		print("intrenable: couldn't enable irq %d, tbdf %#x for %s\n",
@@ -218,7 +219,7 @@ trapinit(void)
 	trapenable(VectorBPT, debugbpt, 0, "#BP");
 	trapenable(VectorPF, faultamd64, 0, "#PF");
 	trapenable(Vector2F, doublefault, 0, "#DF");
-	intrenable(IdtIPI, expected, 0, BUSUNKNOWN, "#IPI");
+	//intrenable(IdtIPI, expected, 0, BUSUNKNOWN, "#IPI");
 	trapenable(Vector15, unexpected, 0, "#15");
 	nmienable();
 
@@ -355,6 +356,7 @@ _trap(Ureg *ureg)
 	trap(ureg);
 }
 
+static int lastvno;
 /*
  *  All traps come here.  It is slower to have all traps call trap()
  *  rather than directly vectoring the handler.  However, this avoids a
@@ -368,19 +370,9 @@ trap(Ureg* ureg)
 	int clockintr, vno, user;
 	// cache the previous vno to see what might be causing
 	// trouble
-	static int lastvno;
 	vno = ureg->type;
 	uint64_t gsbase = rdmsr(GSbase);
 	//if (sce > scx) iprint("====================");
-	if (vno == 8) {
-		iprint("Lstar is %p\n", (void *)rdmsr(Lstar));
-		iprint("GSbase is %p\n", (void *)gsbase);
-		iprint("ire %d irx %d sce %d scx %d lastvno %d\n",
-			ire, irx, sce, scx, lastvno);
-		iprint("irxe %d \n",
-			irxe);
-		die("8");
-	}
 	lastvno = vno;
 	if (gsbase < 1ULL<<63)
 		die("bogus gsbase");
@@ -388,11 +380,6 @@ trap(Ureg* ureg)
 	char buf[ERRMAX];
 	Vctl *ctl, *v;
 
-	if (0 && machp() && up && up->pid == 6) {
-		//iprint("type %x\n", ureg->type);
-		if (ureg->type != 0x49)
-			die("6\n");
-	}
 	machp()->perf.intrts = perfticks();
 	user = userureg(ureg);
 	if(user && (machp()->NIX.nixtype == NIXTC)){

+ 2 - 0
sys/src/9/port/devtab.c

@@ -35,7 +35,9 @@ devtabinit(void)
 	int i;
 
 	for(i = 0; devtab[i] != nil; i++) {
+		print("INIT %d %s\n", i, devtab[i]->name);
 		devtab[i]->init();
+		print("DONE\n");
 	}
 }