Subject: Re: INSTALL kernel support
To: Manuel BOUYER <bouyer@antioche.lip6.fr>
From: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
List: current-users
Date: 12/05/1997 22:08:17
Excerpts from netbsd: 5-Dec-97 Re: INSTALL kernel support Jason
Thorpe@nas.nasa.go (868)

>  > It does. But the Compaq Deskpro has a strange PCI system, and NetBSD
>  > incorreclty detects the PCI Mode (detected as mode 2, where it should be
>  > mode 1).
> [...]
> I thought Matthias Drochner made this probe more robust?

Not exactly. I sent out a patch which works for me
but didn't get much response. So it stayed in the drawer.

Here is the patch again. My machines all have Intel
chipsets, it would be nice if people could try it on
different ones. There is a part #ifdef'd with
"PCI_PROBE_DONTKNOW". If the PCI detection
fails, you could try to enable it. (It is an additional
check similar to something done in FreeBSD. According
to my documentation it is useless. I just asked the
Author but got no response so far.)

best regards
Matthias


Index: pci_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/pci/pci_machdep.c,v
retrieving revision 1.28
diff -r1.28 pci_machdep.c
338a339,340
> 	u_int32_t sav, val;
> 
343,348c345
< 	 * We try to divine which configuration mode the host bridge wants.  We
< 	 * try mode 2 first, because our probe for mode 1 is likely to succeed
< 	 * for mode 2 also.
< 	 *
< 	 * XXX
< 	 * This should really be done using the PCI BIOS.
---
> 	 * We try to divine which configuration mode the host bridge wants.
350a348,395
> 	sav = inl(PCI_MODE1_ADDRESS_REG);
> 	/*
> 	 * Check:
> 	 * 1. bit 31 ("enable") can be set
> 	 * 2. byte/word access does not affect register
> 	 */
> 	outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE);
> 	outb(PCI_MODE1_ADDRESS_REG + 3, 0);
> 	outw(PCI_MODE1_ADDRESS_REG + 2, 0);
> 	val = inl(PCI_MODE1_ADDRESS_REG);
> 	if ((val & 0x80fffffc) != PCI_MODE1_ENABLE) {
> #ifdef DEBUG
> 		printf("pci_mode_detect: mode 1 enable failed\n");
> #endif
> #ifdef PCI_PROBE_DONTKNOW
> 		/*
> 		 * FreeBSD gives a second chance - test if bit 0
> 		 * cannot be written. In Intel documentation, this
> 		 * is marked as "reserved" - but these chipsets
> 		 * should have passed the first test.
> 		 */
> 		outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE | 1);
> 		val = inl(PCI_MODE1_ADDRESS_REG);
> 		if ((val & 0x80fffffd) != PCI_MODE1_ENABLE) {
> #ifdef DEBUG
> 			printf("pci_mode_detect: bit 1 writable\n");
> #endif
> 			goto not1;
> 		}
> #else
> 		goto not1;
> #endif /* PCI_PROBE_DONTKNOW */
> 	}
> 	outl(PCI_MODE1_ADDRESS_REG, 0);
> 	val = inl(PCI_MODE1_ADDRESS_REG);
> 	if ((val & 0x80fffffc) != 0)
> 		goto not1;
> 	return (pci_mode = 1);
> not1:
> 	outl(PCI_MODE1_ADDRESS_REG, sav);
> 
> 	/*
> 	 * This mode 2 check is quite weak (and known to give false
> 	 * positives on some Compaq machines).
> 	 * However, this doesn't matter, because this is the
> 	 * last test, and simply no PCI devices will be found if
> 	 * this happens.
> 	 */
357d401
< 
359,365d402
< 	outl(PCI_MODE1_ADDRESS_REG, PCI_MODE1_ENABLE);
< 	if (inl(PCI_MODE1_ADDRESS_REG) != PCI_MODE1_ENABLE)
< 		goto not1;
< 	outl(PCI_MODE1_ADDRESS_REG, 0);
< 	if (inl(PCI_MODE1_ADDRESS_REG) != 0)
< 		goto not1;
< 	return (pci_mode = 1);
367d403
< not1: