PERFORCE change 41507 for review

Peter Wemm peter at FreeBSD.org
Wed Nov 5 17:21:13 PST 2003


http://perforce.freebsd.org/chv.cgi?CH=41507

Change 41507 by peter at peter_daintree on 2003/11/05 17:21:04

	integrate -I -b smp_hammer

Affected files ...

.. //depot/projects/hammer/sys/amd64/acpica/madt.c#12 integrate
.. //depot/projects/hammer/sys/amd64/amd64/intr_machdep.c#5 integrate
.. //depot/projects/hammer/sys/amd64/amd64/io_apic.c#13 integrate
.. //depot/projects/hammer/sys/amd64/amd64/mptable.c#8 integrate
.. //depot/projects/hammer/sys/amd64/isa/atpic.c#12 integrate
.. //depot/projects/hammer/sys/amd64/isa/nmi.c#5 integrate
.. //depot/projects/hammer/sys/jhb_notes#10 integrate

Differences ...

==== //depot/projects/hammer/sys/amd64/acpica/madt.c#12 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/acpica/madt.c,v 1.1 2003/11/03 22:17:44 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/acpica/madt.c,v 1.3 2003/11/05 23:15:51 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -251,7 +251,8 @@
 		return (ENXIO);
 	}
 	if (bootverbose)
-		printf("MADT: Found table at %p\n", (void *)madt_physaddr);
+		printf("MADT: Found table at 0x%jx\n",
+		    (uintmax_t)madt_physaddr);
 
 	return (0);
 }
@@ -267,13 +268,13 @@
 	table = madt_map(address, 0, sizeof(ACPI_TABLE_HEADER));
 	if (table == NULL) {
 		if (bootverbose)
-			printf("MADT: Failed to map table at %p\n",
-			    (void *)address);
+			printf("MADT: Failed to map table at 0x%jx\n",
+			    (uintmax_t)address);
 		return (0);
 	}
 	if (bootverbose)
-		printf("Table '%.4s' at %p\n", table->Signature,
-		    (void *)address);
+		printf("Table '%.4s' at 0x%jx\n", table->Signature,
+		    (uintmax_t)address);
 
 	/* XXX: Verify checksum? */
 	if (strncmp(table->Signature, APIC_SIG, 4) != 0) {
@@ -524,25 +525,33 @@
 static void
 madt_parse_interrupt_override(INTERRUPT_SOURCE_OVERRIDE *intr)
 {
-	void *ioapic;
-	u_int pin;
+	void *new_ioapic, *old_ioapic;
+	u_int new_pin, old_pin;
 
 	if (bootverbose)
 		printf("MADT: intr override: source %u, irq %u\n",
 		    intr->Source, intr->GlobalSystemInterrupt);
 	KASSERT(intr->Bus == 0, ("bus for interrupt overrides must be zero"));
-	if (madt_find_interrupt(intr->GlobalSystemInterrupt,
-	    &ioapic, &pin) != 0) {
+	if (madt_find_interrupt(intr->GlobalSystemInterrupt, &new_ioapic,
+	    &new_pin) != 0) {
 		printf("MADT: Could not find APIC for vector %d (IRQ %d)\n",
 		    intr->GlobalSystemInterrupt, intr->Source);
 		return;
 	}
 
-	if (intr->Source != intr->GlobalSystemInterrupt)
-		ioapic_remap_vector(ioapic, pin, intr->Source);
-	ioapic_set_triggermode(ioapic, pin,
+	if (intr->Source != intr->GlobalSystemInterrupt) {
+		ioapic_remap_vector(new_ioapic, new_pin, intr->Source);
+		if (madt_find_interrupt(intr->Source, &old_ioapic,
+		    &old_pin) != 0)
+			printf("MADT: Could not find APIC for source IRQ %d\n",
+			    intr->Source);
+		else
+			ioapic_disable_pin(old_ioapic, old_pin);
+	}
+	ioapic_set_triggermode(new_ioapic, new_pin,
 	    interrupt_trigger(intr->TriggerMode));
-	ioapic_set_polarity(ioapic, pin, interrupt_polarity(intr->Polarity));
+	ioapic_set_polarity(new_ioapic, new_pin,
+	    interrupt_polarity(intr->Polarity));
 }
 
 /*

==== //depot/projects/hammer/sys/amd64/amd64/intr_machdep.c#5 (text+ko) ====

@@ -105,6 +105,7 @@
 	}
 	intrcnt_register(isrc);
 	interrupt_sources[vector] = isrc;
+	isrc->is_pic->pic_enable_intr(isrc);
 	mtx_unlock_spin(&intr_table_lock);
 	return (0);
 }
@@ -130,7 +131,6 @@
 	    ithread_priority(flags), flags, cookiep);
 	if (error == 0) {
 		intrcnt_updatename(isrc);
-		isrc->is_pic->pic_enable_intr(isrc);
 		isrc->is_pic->pic_enable_source(isrc);
 	}
 	return (error);

==== //depot/projects/hammer/sys/amd64/amd64/io_apic.c#13 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/io_apic.c,v 1.1 2003/11/03 21:53:36 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/io_apic.c,v 1.4 2003/11/05 23:07:39 jhb Exp $");
 
 #include "opt_isa.h"
 #include "opt_no_mixed_mode.h"
@@ -59,10 +59,10 @@
 #define	IOAPIC_REDTBL_LO(i)	(IOAPIC_REDTBL + (i) * 2)
 #define	IOAPIC_REDTBL_HI(i)	(IOAPIC_REDTBL_LO(i) + 1)
 
-#define	VECTOR_EXTINT		-1
-#define	VECTOR_NMI		-2
-#define	VECTOR_SMI		-3
-#define	VECTOR_DISABLED		-4
+#define	VECTOR_EXTINT		252
+#define	VECTOR_NMI		253
+#define	VECTOR_SMI		254
+#define	VECTOR_DISABLED		255
 
 #define	DEST_NONE		-1
 #define	DEST_EXTINT		-2
@@ -97,11 +97,11 @@
 
 struct ioapic_intsrc {
 	struct intsrc io_intsrc;
-	int io_intpin:8;
-	int io_vector:8;
-	int io_activehi:1;
-	int io_edgetrigger:1;
-	int io_masked:1;
+	u_int io_intpin:8;
+	u_int io_vector:8;
+	u_int io_activehi:1;
+	u_int io_edgetrigger:1;
+	u_int io_masked:1;
 	int io_dest:5;
 };
 
@@ -200,6 +200,7 @@
 static void
 ioapic_eoi_source(struct intsrc *isrc)
 {
+
 	TODO;
 	/* lapic_eoi(); */
 }
@@ -242,6 +243,7 @@
 static void
 ioapic_assign_cluster(struct ioapic_intsrc *intpin)
 {
+
 	/*
 	 * Assign this intpin to a logical APIC cluster in a
 	 * round-robin fashion.  We don't actually use the logical
@@ -358,7 +360,7 @@
 		printf("ioapic%u: WARNING: intbase %d != expected base %d\n",
 		    io->io_id, intbase, next_ioapic_base);
 	io->io_intbase = intbase;
-	next_ioapic_base += numintr;
+	next_ioapic_base = intbase + numintr;
 	io->io_numintr = numintr;
 	io->io_addr = apic;
 
@@ -406,7 +408,7 @@
 			if (intpin->io_vector == VECTOR_EXTINT)
 				printf("ExtINT\n");
 			else
-				printf("irq %d\n", intpin->io_vector);
+				printf("irq %u\n", intpin->io_vector);
 		}
 		value = ioapic_read(apic, IOAPIC_REDTBL_LO(i));
 		ioapic_write(apic, IOAPIC_REDTBL_LO(i), value | IOART_INTMSET);
@@ -451,7 +453,7 @@
 	io = (struct ioapic *)cookie;
 	if (pin >= io->io_numintr || vector < 0)
 		return (EINVAL);
-	if (io->io_pins[pin].io_vector < 0)
+	if (io->io_pins[pin].io_vector >= NUM_IO_INTS)
 		return (EINVAL);
 	io->io_pins[pin].io_vector = vector;
 	if (bootverbose)
@@ -468,7 +470,7 @@
 	io = (struct ioapic *)cookie;
 	if (pin >= io->io_numintr)
 		return (EINVAL);
-	if (io->io_pins[pin].io_vector < 0)
+	if (io->io_pins[pin].io_vector >= NUM_IO_INTS)
 		return (EINVAL);
 	io->io_pins[pin].io_vector = VECTOR_NMI;
 	io->io_pins[pin].io_masked = 0;
@@ -488,7 +490,7 @@
 	io = (struct ioapic *)cookie;
 	if (pin >= io->io_numintr)
 		return (EINVAL);
-	if (io->io_pins[pin].io_vector < 0)
+	if (io->io_pins[pin].io_vector >= NUM_IO_INTS)
 		return (EINVAL);
 	io->io_pins[pin].io_vector = VECTOR_SMI;
 	io->io_pins[pin].io_masked = 0;
@@ -508,7 +510,7 @@
 	io = (struct ioapic *)cookie;
 	if (pin >= io->io_numintr)
 		return (EINVAL);
-	if (io->io_pins[pin].io_vector < 0)
+	if (io->io_pins[pin].io_vector >= NUM_IO_INTS)
 		return (EINVAL);
 	io->io_pins[pin].io_vector = VECTOR_EXTINT;
 	io->io_pins[pin].io_masked = 0;
@@ -528,7 +530,7 @@
 	io = (struct ioapic *)cookie;
 	if (pin >= io->io_numintr)
 		return (EINVAL);
-	if (io->io_pins[pin].io_vector < 0)
+	if (io->io_pins[pin].io_vector >= NUM_IO_INTS)
 		return (EINVAL);
 	io->io_pins[pin].io_activehi = activehi;
 	if (bootverbose)
@@ -545,7 +547,7 @@
 	io = (struct ioapic *)cookie;
 	if (pin >= io->io_numintr)
 		return (EINVAL);
-	if (io->io_pins[pin].io_vector < 0)
+	if (io->io_pins[pin].io_vector >= NUM_IO_INTS)
 		return (EINVAL);
 	io->io_pins[pin].io_edgetrigger = edgetrigger;
 	if (bootverbose)
@@ -572,8 +574,9 @@
 	flags = ioapic_read(apic, IOAPIC_VER) & IOART_VER_VERSION;
 	STAILQ_INSERT_TAIL(&ioapic_list, io, io_next);
 	mtx_unlock_spin(&icu_lock);
-	printf("ioapic%u <Version %u> irqs %u-%u on motherboard\n", io->io_id,
-	    flags, io->io_intbase, io->io_intbase + io->io_numintr - 1);
+	printf("ioapic%u <Version %u.%u> irqs %u-%u on motherboard\n",
+	    io->io_id, flags >> 4, flags & 0xf, io->io_intbase,
+	    io->io_intbase + io->io_numintr - 1);
 	for (i = 0, pin = io->io_pins; i < io->io_numintr; i++, pin++) {
 		/*
 		 * Finish initializing the pins by programming the vectors
@@ -625,7 +628,7 @@
 		flags |= PCPU_GET(apic_id) << APIC_ID_SHIFT;
 		ioapic_write(apic, IOAPIC_REDTBL_HI(i), flags);
 		mtx_unlock_spin(&icu_lock);
-		if (pin->io_vector >= 0) {
+		if (pin->io_vector < NUM_IO_INTS) {
 #ifdef MIXED_MODE
 			/* Route IRQ0 via the 8259A using mixed mode. */
 			if (pin->io_vector == 0)

==== //depot/projects/hammer/sys/amd64/amd64/mptable.c#8 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/i386/mptable.c,v 1.220 2003/11/03 22:12:37 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/i386/mptable.c,v 1.222 2003/11/05 23:15:52 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -650,8 +650,12 @@
 		if (busses[intr->src_bus_id].bus_type == NOBUS)
 			panic("interrupt from missing bus");
 		if (busses[intr->src_bus_id].bus_type == ISA &&
-		    intr->src_bus_irq != pin)
+		    intr->src_bus_irq != pin) {
 			ioapic_remap_vector(ioapic, pin, intr->src_bus_irq);
+			if (ioapic_get_vector(ioapic, intr->src_bus_irq) ==
+			    intr->src_bus_irq)
+				ioapic_disable_pin(ioapic, intr->src_bus_irq);
+		}
 		break;
 	case INTENTRY_TYPE_NMI:
 		ioapic_set_nmi(ioapic, pin);
@@ -890,6 +894,7 @@
 {
 	struct pci_route_interrupt_args *args;
 	int_entry_ptr intr;
+	int vector;
 
 	if (*entry != MPCT_ENTRY_INT)
 		return;
@@ -897,12 +902,24 @@
 	args = (struct pci_route_interrupt_args *)arg;
 	if (intr->src_bus_id != args->bus || intr->src_bus_irq != args->irq)
 		return;
-	KASSERT(args->vector == -1,
-	    ("Multiple entries for PCI IRQ %d", args->vector));
+
+	/* Make sure the APIC maps to a known APIC. */
 	KASSERT(ioapics[intr->dst_apic_id] != NULL,
 	    ("No I/O APIC %d to route interrupt to", intr->dst_apic_id));
-	args->vector = ioapic_get_vector(ioapics[intr->dst_apic_id],
+
+	/*
+	 * Look up the vector for this APIC / pin combination.  If we
+	 * have previously matched an entry for this PCI IRQ but it
+	 * has the same vector as this entry, just return.  Otherwise,
+	 * we use the vector for this APIC / pin combination.
+	 */
+	vector = ioapic_get_vector(ioapics[intr->dst_apic_id],
 	    intr->dst_apic_int);
+	if (args->vector == vector)
+		return;
+	KASSERT(args->vector == -1,
+	    ("Multiple entries for PCI IRQ %d", args->vector));
+	args->vector = vector;
 }
 
 int

==== //depot/projects/hammer/sys/amd64/isa/atpic.c#12 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/isa/atpic.c,v 1.1 2003/11/03 21:34:45 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/isa/atpic.c,v 1.2 2003/11/04 13:13:04 nyan Exp $");
 
 #include "opt_auto_eoi.h"
 #include "opt_isa.h"
@@ -52,8 +52,8 @@
 #include <machine/resource.h>
 #include <machine/segments.h>
 
+#include <amd64/isa/icu.h>
 #include <amd64/isa/isa.h>
-#include <amd64/isa/icu.h>
 
 #ifdef DEV_ISA
 #include <isa/isavar.h>
@@ -366,7 +366,9 @@
 static devclass_t atpic_devclass;
 
 DRIVER_MODULE(atpic, isa, atpic_driver, atpic_devclass, 0, 0);
+#ifndef PC98
 DRIVER_MODULE(atpic, acpi, atpic_driver, atpic_devclass, 0, 0);
+#endif
 
 /*
  * Return a bitmap of the current interrupt requests.  This is 8259-specific

==== //depot/projects/hammer/sys/amd64/isa/nmi.c#5 (text+ko) ====

@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/isa/nmi.c,v 1.77 2003/11/03 21:10:17 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/isa/nmi.c,v 1.78 2003/11/04 13:01:41 nyan Exp $");
 
 #include "opt_mca.h"
 
@@ -51,16 +51,11 @@
 #include <i386/bios/mca_machdep.h>
 #endif
 
-#ifdef PC98
-#define NMI_PARITY 0x04
-#define NMI_EPARITY 0x02
-#else
 #define NMI_PARITY (1 << 7)
 #define NMI_IOCHAN (1 << 6)
 #define ENMI_WATCHDOG (1 << 7)
 #define ENMI_BUSTIMER (1 << 6)
 #define ENMI_IOSTATUS (1 << 5)
-#endif
 
 /*
  * Handle a NMI, possibly a machine check.
@@ -70,22 +65,6 @@
 isa_nmi(int cd)
 {
 	int retval = 0;
-#ifdef PC98
- 	int port = inb(0x33);
-
-	log(LOG_CRIT, "NMI PC98 port = %x\n", port);
-	if (epson_machine_id == 0x20)
-		epson_outb(0xc16, epson_inb(0xc16) | 0x1);
-	if (port & NMI_PARITY) {
-		log(LOG_CRIT, "BASE RAM parity error, likely hardware failure.");
-		retval = 1;
-	} else if (port & NMI_EPARITY) {
-		log(LOG_CRIT, "EXTENDED RAM parity error, likely hardware failure.");
-		retval = 1;
-	} else {
-		log(LOG_CRIT, "\nNMI Resume ??\n");
-	}
-#else /* IBM-PC */
 	int isa_port = inb(0x61);
 	int eisa_port = inb(0x461);
 
@@ -127,6 +106,6 @@
 		log(LOG_CRIT, "EISA I/O port status error.");
 		retval = 1;
 	}
-#endif
+
 	return(retval);
 }

==== //depot/projects/hammer/sys/jhb_notes#10 (text+ko) ====

@@ -1,4 +1,8 @@
 Todo:
+- Add a MI interrupt source abstraction and move handlers out of ithd and
+  into that
+  - Defer creation of ithreads until a non-fast handler is added to an
+    interrupt source
 - DDB
   - Add 'show ithread'
   + Add 'show irqs'
@@ -29,7 +33,7 @@
   + Add NO_MIXED_MODE option
   - Add runtime decision for IRQ0 mixed mode?
   - Don't use mixed mode with MADT?
-- Perhaps change the IRQ resource manager such that it starts out empty
++ Perhaps change the IRQ resource manager such that it starts out empty
   and a resource entry for each IRQ is added as each IRQ is registered
 - Add handling of local APIC ERROR lvt.
 - Use the local apic timer to drive hard/stat/profclock (maybe too hard)


More information about the p4-projects mailing list