Subject: Re: Booting a Compaq ProLiant ML370
To: Mark Davies <mark@MCS.VUW.AC.NZ>
From: Andrew Doran <ad@netbsd.org>
List: current-users
Date: 01/08/2001 13:03:44
Hi Mark.

Mark Davies <mark@MCS.VUW.AC.NZ> wrote:

> Problem 2)
>        This machine has a Smart Array 431 controller which is found (cac0) but no
> lsu's and the following appears in the msgbuf
> 
> 	pci_mem_find: expected type mem, found i/o
> 	pci_io_find: expected type i/o, found mem

Sigh. Try the following kludge:

Index: cac_pci.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/cac_pci.c,v
retrieving revision 1.9
diff -u -r1.9 dev/pci/cac_pci.c
--- dev/pci/cac_pci.c	2000/12/28 22:59:11	1.9
+++ dev/pci/cac_pci.c	2001/01/08 12:59:58
@@ -55,9 +55,6 @@
 #include <dev/ic/cacreg.h>
 #include <dev/ic/cacvar.h>
 
-#define	PCI_CBIO	0x10	/* Configuration base I/O address */
-#define	PCI_CBMA	0x14	/* Configuration base memory address */
-
 static void	cac_pci_attach(struct device *, struct device *, void *);
 static struct	cac_pci_type *cac_pci_findtype(struct pci_attach_args *);
 static int	cac_pci_match(struct device *, struct cfdata *, void *);
@@ -160,27 +157,54 @@
 	pci_chipset_tag_t pc;
 	pci_intr_handle_t ih;
 	const char *intrstr;
-	pcireg_t csr;
+	pcireg_t reg;
+	int memr, ior, i;
 
 	sc = (struct cac_softc *)self;
 	pa = (struct pci_attach_args *)aux;
 	pc = pa->pa_pc;
 	ct = cac_pci_findtype(pa);
 
-	if (pci_mapreg_map(pa, PCI_CBMA, PCI_MAPREG_TYPE_MEM, 0,
-	    &sc->sc_iot, &sc->sc_ioh, NULL, NULL))
-		if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
-		    &sc->sc_iot, &sc->sc_ioh, NULL, NULL)) {
-			printf("can't map memory or i/o space\n");
-			return;
+	/*
+	 * Map the PCI register window.
+	 */
+	memr = -1;
+	ior = -1;
+
+	for (i = 0x10; i <= 0x14; i += 4) {
+		reg = pci_conf_read(pa->pa_pc, pa->pa_tag, i);
+
+		if (PCI_MAPREG_TYPE(reg) == PCI_MAPREG_TYPE_IO) {
+			if (ior == -1 && PCI_MAPREG_IO_SIZE(reg) != 0)
+				ior = i;
+		} else {
+			if (memr == -1 && PCI_MAPREG_MEM_SIZE(reg) != 0)
+				memr = i;
 		}
+	}
+
+	if (memr != -1) {
+		if (pci_mapreg_map(pa, memr, PCI_MAPREG_TYPE_MEM, 0,
+		    &sc->sc_iot, &sc->sc_ioh, NULL, NULL))
+			memr = -1;
+		else
+			ior = -1;
+	}
+	if (ior != -1)
+		if (pci_mapreg_map(pa, ior, PCI_MAPREG_TYPE_IO, 0,
+		    &sc->sc_iot, &sc->sc_ioh, NULL, NULL))
+		    	ior = -1;
+	if (memr == -1 && ior == -1) {
+		printf("%s: can't map i/o or memory space\n", self->dv_xname);
+		return;
+	}
 
 	sc->sc_dmat = pa->pa_dmat;
 
 	/* Enable the device. */
-	csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+	reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
 	pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
-		       csr | PCI_COMMAND_MASTER_ENABLE);
+		       reg | PCI_COMMAND_MASTER_ENABLE);
 
 	/* Map and establish the interrupt. */
 	if (pci_intr_map(pa, &ih)) {