Subject: Re: clue?
To: None <tech-smp@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-smp
Date: 01/14/2002 14:36:44
In article <Pine.NEB.4.33.0201140103100.7221-100000@rivendell.starwolf.com>,
Greywolf <greywolf@starwolf.com> wrote:
>Hello, all
>
>I did this:
>
>cd /sys
>cvs update -d -P -D "12/29/2001 14:45:06 EST" .
>cd arch/i386
>cvs update -d -P -rsommerfeld_i386mp_1 .
>cd conf
><make myself an MP config file>
>config RIVENDELL.MP
>cd ../compile/RIVENDELL.MP
>make
>

Get up to current, cvs update -d -P -rsommerfeld_i386mp_1 in arch/i386,
then apply the enclosed patch; that builds a working kernel for me.

christos

Index: i386/autoconf.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/autoconf.c,v
retrieving revision 1.45.2.10
diff -u -u -r1.45.2.10 autoconf.c
--- i386/autoconf.c	2001/12/29 21:09:05	1.45.2.10
+++ i386/autoconf.c	2002/01/14 14:35:25
@@ -513,7 +513,9 @@
 			struct isa_attach_args *iaa = aux;
 
 			/* compare IO base address */
-			if (bin->addr.iobase == iaa->ia_iobase)
+			/* XXXJRT what about multiple I/O addrs? */
+			if (iaa->ia_nio > 0 &&
+			    bin->addr.iobase == iaa->ia_io[0].ir_addr)
 				goto found;
 		}
 #if NPCI > 0
Index: include/atomic.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/include/Attic/atomic.h,v
retrieving revision 1.1.2.5
diff -u -u -r1.1.2.5 atomic.h
--- include/atomic.h	2001/12/11 23:52:07	1.1.2.5
+++ include/atomic.h	2002/01/14 14:35:25
@@ -43,7 +43,7 @@
 
 #ifndef _LOCORE
 
-static __inline u_int32_t
+static __inline unsigned long
 i386_atomic_testset_ul (volatile u_int32_t *ptr, unsigned long val) {
     __asm__ volatile ("xchgl %0,(%2)" :"=r" (val):"0" (val),"r" (ptr));
     return val;
@@ -67,4 +67,3 @@
 
 #endif
 #endif
-
Index: isa/ahc_isa.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/ahc_isa.c,v
retrieving revision 1.15
diff -u -u -r1.15 ahc_isa.c
--- isa/ahc_isa.c	2001/11/15 07:03:32	1.15
+++ isa/ahc_isa.c	2002/01/14 14:35:25
@@ -288,18 +288,24 @@
 	if (irq < 0)
 		return (0);
 
-	if (ia->ia_irq != IRQUNK &&
-	    ia->ia_irq != irq) {
+	if (ia->ia_irq[0].ir_irq != ISACF_IRQ_DEFAULT &&
+	    ia->ia_irq[0].ir_irq != irq) {
 		printf("ahc_isa_match: irq mismatch (kernel %d, card %d)\n",
-		    ia->ia_irq, irq);
+		    ia->ia_irq[0].ir_irq, irq);
 		return (0);
 	}
 
 	/* We have a match */
-	ia->ia_iobase = iobase;
-	ia->ia_irq = irq;
-	ia->ia_iosize = AHC_ISA_IOSIZE;
-	ia->ia_msize = 0;
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_addr = iobase;
+	ia->ia_io[0].ir_size = AHC_ISA_IOSIZE;
+
+	ia->ia_nirq = 1;
+	ia->ia_irq[0].ir_irq = irq;
+
+	ia->ia_ndrq = 0;
+	ia->ia_niomem = 0;
+
 	return (1);
 }
 
@@ -321,9 +327,17 @@
 		LIST_INIT(&ahc_isa_all_slots);
 		ahc_isa_slot_initialized = 1;
 	}
+
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
 
-	if (ia->ia_iobase != IOBASEUNK)
-		return (ahc_isa_match(ia, ia->ia_iobase));
+	if (ia->ia_io[0].ir_addr != ISACF_PORT_DEFAULT)
+		return (ahc_isa_match(ia, ia->ia_io[0].ir_addr));
 
 	/*
 	 * Find this bus's state.  If we don't yet have a slot
@@ -373,7 +387,8 @@
 	const char *intrtypestr;
 	char idstring[EISA_IDSTRINGLEN];
 
-	if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) {
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, ia->ia_io[0].ir_size,
+	    0, &ioh)) {
 		printf(": can't map i/o space\n");
 		return;
 	}
@@ -454,7 +469,7 @@
 free_ahc:
 	ahc_free(ahc);
 free_io:
-	bus_space_unmap(iot, ioh, ia->ia_iosize);
+	bus_space_unmap(iot, ioh, ia->ia_io[0].ir_size);
 }
 
 /*
Index: isa/joy_isa.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/joy_isa.c,v
retrieving revision 1.5
diff -u -u -r1.5 joy_isa.c
--- isa/joy_isa.c	2001/11/15 07:03:32	1.5
+++ isa/joy_isa.c	2002/01/14 14:35:25
@@ -66,12 +66,15 @@
 	bus_space_handle_t ioh;
 	int rval = 0;
 
-	if (ia->ia_iobase == IOBASEUNK)
+	if (ia->ia_nio < 1)
 		return (0);
 
-	if (bus_space_map(iot, ia->ia_iobase, JOY_NPORTS, 0, &ioh))
+	if (ia->ia_io[0].ir_addr == ISACF_PORT_DEFAULT)
 		return (0);
 
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, JOY_NPORTS, 0, &ioh))
+		return (0);
+
 #ifdef WANT_JOYSTICK_CONNECTED
 	bus_space_write_1(iot, ioh, 0, 0xff);
 	DELAY(10000);		/* 10 ms delay */
@@ -83,8 +86,14 @@
 
 	bus_space_unmap(iot, ioh, JOY_NPORTS);
 
-	ia->ia_iosize = JOY_NPORTS;
-	ia->ia_msize = 0;
+	if (rval) {
+		ia->ia_nio = 1;
+		ia->ia_io[0].ir_size = JOY_NPORTS;
+
+		ia->ia_niomem = 0;
+		ia->ia_nirq = 0;
+		ia->ia_ndrq = 0;
+	}
 	return (rval);
 }
 
@@ -100,7 +109,7 @@
 
 	sc->sc_iot = ia->ia_iot;
 
-	if (bus_space_map(sc->sc_iot, ia->ia_iobase, JOY_NPORTS, 0,
+	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, JOY_NPORTS, 0,
 	    &sc->sc_ioh)) {
 		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
 		return;
Index: isa/lms.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/lms.c,v
retrieving revision 1.39
diff -u -u -r1.39 lms.c
--- isa/lms.c	2001/11/15 07:03:32	1.39
+++ isa/lms.c	2002/01/14 14:35:25
@@ -87,13 +87,23 @@
 	bus_space_tag_t iot = ia->ia_iot;
 	bus_space_handle_t ioh;
 	int rv;
-	
+
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
+
 	/* Disallow wildcarded i/o base. */
-	if (ia->ia_iobase == ISACF_PORT_DEFAULT)
+	if (ia->ia_io[0].ir_addr == ISACF_PORT_DEFAULT)
 		return 0;
+	if (ia->ia_irq[0].ir_irq == ISACF_IRQ_DEFAULT)
+		return 0;
 
 	/* Map the i/o space. */
-	if (bus_space_map(iot, ia->ia_iobase, LMS_NPORTS, 0, &ioh))
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, LMS_NPORTS, 0, &ioh))
 		return 0;
 
 	rv = 0;
@@ -114,8 +124,13 @@
 	bus_space_write_1(iot, ioh, LMS_CNTRL, 0x10);
 
 	rv = 1;
-	ia->ia_iosize = LMS_NPORTS;
-	ia->ia_msize = 0;
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_size = LMS_NPORTS;
+
+	ia->ia_nirq = 1;
+
+	ia->ia_niomem = 0;
+	ia->ia_ndrq = 0;
 
 out:
 	bus_space_unmap(iot, ioh, LMS_NPORTS);
@@ -135,7 +150,7 @@
 
 	printf("\n");
 
-	if (bus_space_map(iot, ia->ia_iobase, LMS_NPORTS, 0, &ioh)) {
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, LMS_NPORTS, 0, &ioh)) {
 		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
 		return;
 	}
@@ -145,8 +160,8 @@
 	sc->sc_ioh = ioh;
 	sc->sc_enabled = 0;
 
-	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
-	    IPL_TTY, lmsintr, sc);
+	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
+	    IST_PULSE, IPL_TTY, lmsintr, sc);
 
 	a.accessops = &lms_accessops;
 	a.accesscookie = sc;
Index: isa/mms.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/mms.c,v
retrieving revision 1.36
diff -u -u -r1.36 mms.c
--- isa/mms.c	2001/11/15 07:03:32	1.36
+++ isa/mms.c	2002/01/14 14:35:25
@@ -85,12 +85,23 @@
 	bus_space_handle_t ioh;
 	int rv;
 
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
+
 	/* Disallow wildcarded i/o address. */
-	if (ia->ia_iobase == ISACF_PORT_DEFAULT)
+	if (ia->ia_io[0].ir_addr == ISACF_PORT_DEFAULT)
+		return 0;
+
+	if (ia->ia_irq[0].ir_irq == ISACF_IRQ_DEFAULT)
 		return 0;
 
 	/* Map the i/o space. */
-	if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh))
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, MMS_NPORTS, 0, &ioh))
 		return 0;
 
 	rv = 0;
@@ -103,8 +114,14 @@
 	bus_space_write_1(iot, ioh, MMS_ADDR, 0x87);
 
 	rv = 1;
-	ia->ia_iosize = MMS_NPORTS;
-	ia->ia_msize = 0;
+
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_size = MMS_NPORTS;
+
+	ia->ia_nirq = 1;
+
+	ia->ia_niomem = 0;
+	ia->ia_ndrq = 0;
 
 out:
 	bus_space_unmap(iot, ioh, MMS_NPORTS);
@@ -124,7 +141,7 @@
 
 	printf("\n");
 
-	if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh)) {
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, MMS_NPORTS, 0, &ioh)) {
 		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
 		return;
 	}
@@ -134,8 +151,8 @@
 	sc->sc_ioh = ioh;
 	sc->sc_enabled = 0;
 
-	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
-	    IPL_TTY, mmsintr, sc);
+	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
+	    IST_PULSE, IPL_TTY, mmsintr, sc);
 
 	a.accessops = &mms_accessops;
 	a.accesscookie = sc;
Index: isa/npx.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/npx.c,v
retrieving revision 1.70.8.15
diff -u -u -r1.70.8.15 npx.c
--- isa/npx.c	2001/12/29 21:09:10	1.70.8.15
+++ isa/npx.c	2002/01/14 14:35:25
@@ -133,8 +133,6 @@
                 fxsave(&addr->sv_xmm);
 
 		/* FXSAVE doesn't FNINIT like FNSAVE does -- so do it here. */
-		fwait();
-		/* XXX needed? */
 		fninit();
 	} else
 #endif /* I686_CPU */
Index: isa/npx_isa.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/npx_isa.c,v
retrieving revision 1.1.6.2
diff -u -u -r1.1.6.2 npx_isa.c
--- isa/npx_isa.c	2001/12/29 21:09:10	1.1.6.2
+++ isa/npx_isa.c	2002/01/14 14:35:25
@@ -68,25 +68,43 @@
 	bus_space_handle_t ioh;
 	enum npx_type result;
 
-	ia->ia_iosize = 16;
-	ia->ia_msize = 0;
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
 
-	if (bus_space_map(ia->ia_iot, 0xf0, ia->ia_iosize, 0, &ioh) != 0)
+	if (bus_space_map(ia->ia_iot, 0xf0, 16, 0, &ioh) != 0)
 		return (0);
 
-	result = npxprobe1(ia->ia_iot, ioh, ia->ia_irq);
-	if (result != NPX_INTERRUPT)
-		ia->ia_irq = IRQUNK;	/* zap the interrupt */
-
-	bus_space_unmap(ia->ia_iot, ioh, ia->ia_iosize);
-
-	/*
-	 * Remember our result -- we don't want to have to npxprobe1()
-	 * again (especially if we've zapped the IRQ).
-	 */
-	ia->ia_aux = (void *)(u_long)result;
+	result = npxprobe1(ia->ia_iot, ioh, ia->ia_irq[0].ir_irq);
+
+	bus_space_unmap(ia->ia_iot, ioh, 16);
+
+	if (result != NPX_NONE) {
+		/*
+		 * Remember our result -- we don't want to have to npxprobe1()
+		 * again (especially if we've zapped the IRQ).
+		 */
+		ia->ia_aux = (void *)(u_long)result;
+
+		ia->ia_nio = 1;
+		ia->ia_io[0].ir_addr = 0xf0;
+		ia->ia_io[0].ir_size = 16;
+
+		if (result != NPX_INTERRUPT)
+			ia->ia_nirq = 0;	/* zap the interrupt */
+		else
+			ia->ia_nirq = 1;
+
+		ia->ia_niomem = 0;
+		ia->ia_ndrq = 0;
+		return (1);
+	}
 
-	return (result != NPX_NONE);
+	return (0);
 }
 
 void
@@ -97,7 +115,7 @@
 
 	sc->sc_iot = ia->ia_iot;
 
-	if (bus_space_map(sc->sc_iot, 0xf0, ia->ia_iosize, 0, &sc->sc_ioh)) {
+	if (bus_space_map(sc->sc_iot, 0xf0, 16, 0, &sc->sc_ioh)) {
 		printf("\n");
 		panic("npxattach: unable to map I/O space");
 	}
@@ -108,7 +126,7 @@
 	case NPX_INTERRUPT:
 		printf("\n");
 		lcr0(rcr0() & ~CR0_NE);
-		sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq,
+		sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
 		    IST_EDGE, IPL_NONE, npxintr, 0);
 		break;
 	case NPX_EXCEPTION:
Index: isa/olms.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/olms.c,v
retrieving revision 1.3
diff -u -u -r1.3 olms.c
--- isa/olms.c	2001/11/15 07:03:33	1.3
+++ isa/olms.c	2002/01/14 14:35:25
@@ -96,13 +96,23 @@
 	bus_space_tag_t iot = ia->ia_iot;
 	bus_space_handle_t ioh;
 	int rv;
-	
+
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
+
 	/* Disallow wildcarded i/o base. */
-	if (ia->ia_iobase == ISACF_PORT_DEFAULT)
+	if (ia->ia_io[0].ir_addr == ISACF_PORT_DEFAULT)
 		return 0;
+	if (ia->ia_irq[0].ir_irq == ISACF_IRQ_DEFAULT)
+		return 0;
 
 	/* Map the i/o space. */
-	if (bus_space_map(iot, ia->ia_iobase, LMS_NPORTS, 0, &ioh))
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, LMS_NPORTS, 0, &ioh))
 		return 0;
 
 	rv = 0;
@@ -123,8 +133,13 @@
 	bus_space_write_1(iot, ioh, LMS_CNTRL, 0x10);
 
 	rv = 1;
-	ia->ia_iosize = LMS_NPORTS;
-	ia->ia_msize = 0;
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_size = LMS_NPORTS;
+
+	ia->ia_nirq = 1;
+
+	ia->ia_niomem = 0;
+	ia->ia_ndrq = 0;
 
 out:
 	bus_space_unmap(iot, ioh, LMS_NPORTS);
@@ -143,7 +158,7 @@
 
 	printf("\n");
 
-	if (bus_space_map(iot, ia->ia_iobase, LMS_NPORTS, 0, &ioh)) {
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, LMS_NPORTS, 0, &ioh)) {
 		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
 		return;
 	}
@@ -153,8 +168,8 @@
 	sc->sc_ioh = ioh;
 	sc->sc_state = 0;
 
-	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
-	    IPL_TTY, olmsintr, sc);
+	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
+	    IST_PULSE, IPL_TTY, olmsintr, sc);
 }
 
 int
Index: isa/omms.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/omms.c,v
retrieving revision 1.3
diff -u -u -r1.3 omms.c
--- isa/omms.c	2001/11/15 07:03:33	1.3
+++ isa/omms.c	2002/01/14 14:35:25
@@ -95,12 +95,22 @@
 	bus_space_handle_t ioh;
 	int rv;
 
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
+
 	/* Disallow wildcarded i/o address. */
-	if (ia->ia_iobase == ISACF_PORT_DEFAULT)
+	if (ia->ia_io[0].ir_addr == ISACF_PORT_DEFAULT)
+		return 0;
+	if (ia->ia_irq[0].ir_irq == ISACF_IRQ_DEFAULT)
 		return 0;
 
 	/* Map the i/o space. */
-	if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh))
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, MMS_NPORTS, 0, &ioh))
 		return 0;
 
 	rv = 0;
@@ -113,8 +123,13 @@
 	bus_space_write_1(iot, ioh, MMS_ADDR, 0x87);
 
 	rv = 1;
-	ia->ia_iosize = MMS_NPORTS;
-	ia->ia_msize = 0;
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_size = MMS_NPORTS;
+
+	ia->ia_nirq = 1;
+
+	ia->ia_niomem = 0;
+	ia->ia_ndrq = 0;
 
 out:
 	bus_space_unmap(iot, ioh, MMS_NPORTS);
@@ -133,7 +148,7 @@
 
 	printf("\n");
 
-	if (bus_space_map(iot, ia->ia_iobase, MMS_NPORTS, 0, &ioh)) {
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, MMS_NPORTS, 0, &ioh)) {
 		printf("%s: can't map i/o space\n", sc->sc_dev.dv_xname);
 		return;
 	}
@@ -143,8 +158,8 @@
 	sc->sc_ioh = ioh;
 	sc->sc_state = 0;
 
-	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_PULSE,
-	    IPL_TTY, ommsintr, sc);
+	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
+	    IST_PULSE, IPL_TTY, ommsintr, sc);
 }
 
 int
Index: isa/pccons.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/isa/pccons.c,v
retrieving revision 1.150
diff -u -u -r1.150 pccons.c
--- isa/pccons.c	2001/11/15 07:03:33	1.150
+++ isa/pccons.c	2002/01/14 14:35:26
@@ -574,6 +574,18 @@
 	int res;
 #endif
 
+	if (ia->ia_nio < 1)
+		return (0);
+	if (ia->ia_nirq < 1)
+		return (0);
+
+	/*
+	 * XXXJRT This is probably wrong, but then again, pccons is a
+	 * XXXJRT total hack to begin with.
+	 */
+	if (ISA_DIRECT_CONFIG(ia))
+		return (0);
+
 #if (NPCCONSKBD == 0)
 	/* Enable interrupts and keyboard, etc. */
 	if (!kbc_put8042cmd(CMDBYTE)) {
@@ -709,11 +721,17 @@
 #endif /* 1 */
 
 #if (NPCCONSKBD > 0)
-	ia->ia_iosize = 0;
+	ia->ia_nio = 0;
+	ia->ia_nirq = 0;
 #else
-	ia->ia_iosize = 16;
+	ia->ia_nio = 1;
+	ia->ia_io[0].ir_size = 16;
+	ia->ia_nirq = 1;
 #endif
-	ia->ia_msize = 0;
+
+	ia->ia_niomem = 0;
+	ia->ia_ndrq = 0;
+
 	return (1);
 }
 
@@ -736,8 +754,8 @@
 #if (NPCCONSKBD > 0)
 	pckbc_set_inputhandler(kbctag, kbcslot, pcinput, sc, sc->sc_dev.dv_xname);
 #else
-	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
-	    IPL_TTY, pcintr, sc);
+	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
+	    IST_EDGE, IPL_TTY, pcintr, sc);
 
 	/*
 	 * Look for children of the keyboard controller.