From 24dd01c6957d014b68883bae027f2f5cae33228d Mon Sep 17 00:00:00 2001 From: Scott Long Date: Sat, 30 Nov 2002 19:11:44 +0000 Subject: [PATCH] Always compile in the AHC_ALLOW_MEMIO code, but only try MEMIO if AHC_ALLOW_MEMIO is set, or the hint hint.ahc.N.allow_memio=1 is set in the bootloader. Make use of ah?_pci_test_register_access(). Approved by: re (blanket) --- sys/dev/aic7xxx/ahc_pci.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/sys/dev/aic7xxx/ahc_pci.c b/sys/dev/aic7xxx/ahc_pci.c index 192e22ea5d20..3a9a24e323db 100644 --- a/sys/dev/aic7xxx/ahc_pci.c +++ b/sys/dev/aic7xxx/ahc_pci.c @@ -28,7 +28,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#9 $ + * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/ahc_pci.c#11 $ * * $FreeBSD$ */ @@ -145,13 +145,31 @@ ahc_pci_map_registers(struct ahc_softc *ahc) u_int command; int regs_type; int regs_id; + int allow_memio; command = ahc_pci_read_config(ahc->dev_softc, PCIR_COMMAND, /*bytes*/1); regs = NULL; regs_type = 0; regs_id = 0; + + /* Retrieve the per-device 'allow_memio' hint */ + if (resource_int_value(device_get_name(ahc->dev_softc), + device_get_unit(ahc->dev_softc), + "allow_memio", &allow_memio) != 0) { + if (bootverbose) + device_printf(ahc->dev_softc, "Defaulting to MEMIO "); #ifdef AHC_ALLOW_MEMIO - if ((command & PCIM_CMD_MEMEN) != 0) { + if (bootverbose) + printf("on\n"); + allow_memio = 1; +#else + if (bootverbose) + printf("off\n"); + allow_memio = 0; +#endif + } + + if ((allow_memio != 0) && (command & PCIM_CMD_MEMEN) != 0) { regs_type = SYS_RES_MEMORY; regs_id = AHC_PCI_MEMADDR; @@ -165,7 +183,7 @@ ahc_pci_map_registers(struct ahc_softc *ahc) * Do a quick test to see if memory mapped * I/O is functioning correctly. */ - if (ahc_inb(ahc, HCNTRL) == 0xFF) { + if (ahc_pci_test_register_access(ahc) != 0) { device_printf(ahc->dev_softc, "PCI Device %d:%d:%d failed memory " "mapped test. Using PIO.\n", @@ -183,7 +201,7 @@ ahc_pci_map_registers(struct ahc_softc *ahc) } } } -#endif + if (regs == NULL && (command & PCIM_CMD_PORTEN) != 0) { regs_type = SYS_RES_IOPORT; regs_id = AHC_PCI_IOADDR;