diff options
Diffstat (limited to 'src/atipreinit.c')
-rw-r--r-- | src/atipreinit.c | 126 |
1 files changed, 54 insertions, 72 deletions
diff --git a/src/atipreinit.c b/src/atipreinit.c index d960e88f..8114f512 100644 --- a/src/atipreinit.c +++ b/src/atipreinit.c @@ -101,24 +101,6 @@ static const rgb defaultWeight = {0, 0, 0}; static const Gamma defaultGamma = {0.0, 0.0, 0.0}; /* - * ATIMach64Map -- - * - * This function attempts to mmap() a Mach64's MMIO aperture. - */ -static void -ATIMach64Map -( - int iScreen, - ATIPtr pATI -) -{ - (void)ATIMapApertures(iScreen, pATI); - if (!pATI->pBlock[0] || - (pATI->config_chip_id != inr(CONFIG_CHIP_ID))) - ATIUnmapApertures(iScreen, pATI); -} - -/* * ATIPrintNoiseIfRequested -- * * This function formats debugging information on the server's stderr when @@ -175,7 +157,6 @@ ATIPreInit resPtr pResources; pciVideoPtr pVideo; DisplayModePtr pMode; - unsigned long Block0Base; CARD32 IOValue; int i, j; int Numerator, Denominator; @@ -402,6 +383,24 @@ ATIPreInit return TRUE; } +#ifndef AVOID_CPIO + + /* I/O bases might no longer be valid after BIOS initialisation */ + { + if (pATI->CPIODecoding == BLOCK_IO) + pATI->CPIOBase = PCI_REGION_BASE(pVideo, 1, REGION_IO); + + pATI->MMIOInLinear = FALSE; + + /* Set MMIO address from PCI configuration space, if available */ + if ((pATI->Block0Base = PCI_REGION_BASE(pVideo, 2, REGION_MEM))) + { + pATI->Block0Base += 0x0400U; + } + } + +#endif /* AVOID_CPIO */ + #ifdef AVOID_CPIO pScreenInfo->racMemFlags = @@ -424,51 +423,17 @@ ATIPreInit /* Finish probing the adapter */ { - - if (pATI->CPIODecoding == BLOCK_IO) - pATI->CPIOBase = pVideo->ioBase[1]; - - /* Set MMIO address from PCI configuration space, if available */ - if ((pATI->Block0Base = pVideo->memBase[2])) - { - if (pATI->Block0Base >= (CARD32)(-1 << pVideo->size[2])) - pATI->Block0Base = 0; - else - pATI->Block0Base += 0x0400U; - } - - Block0Base = pATI->Block0Base; /* save */ - - do - { - /* - * Find and mmap() MMIO area. Allow only auxiliary aperture if - * it exists. - */ - if (!pATI->Block0Base) - { - /* Check tail end of linear (8MB or 4MB) aperture */ - if ((pATI->Block0Base = pVideo->memBase[0])) - { - pATI->Block0Base += 0x007FFC00U; - ATIMach64Map(pScreenInfo->scrnIndex, pATI); - if (pATI->pBlock[0]) - break; - - pATI->Block0Base -= 0x00400000U; - ATIMach64Map(pScreenInfo->scrnIndex, pATI); - if (pATI->pBlock[0]) - break; - } - - /* Check VGA MMIO aperture */ - pATI->Block0Base = 0x000BFC00U; - } - - ATIMach64Map(pScreenInfo->scrnIndex, pATI); - } while (0); - - pATI->Block0Base = Block0Base; /* restore */ + /* + * For MMIO register access, the MMIO address is computed when probing + * and there are no BIOS calls. This mapping should always succeed. + * + * For CPIO register access, the MMIO address is computed above in the + * presence of an auxiliary aperture. Otherwise, it is set to zero and + * gets computed when we read the linear aperture configuration. This + * mapping is either irrelevant or a no-op. + */ + if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI)) + return FALSE; #ifdef AVOID_CPIO @@ -481,15 +446,25 @@ ATIPreInit #endif /* AVOID_CPIO */ + /* + * Verify register access by comparing against the CONFIG_CHIP_ID + * value saved by adapter detection. + */ + if (pATI->config_chip_id != inr(CONFIG_CHIP_ID)) + { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Adapter registers not mapped correctly.\n"); + ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); + return FALSE; + } + pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL); if (!(pATIHW->crtc_gen_cntl & CRTC_EN) && (pATI->Chip >= ATI_CHIP_264CT)) { xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Adapter has not been initialised.\n"); - ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); - return FALSE; + goto bail_locked; } #ifdef AVOID_CPIO @@ -499,9 +474,7 @@ ATIPreInit xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Adapters found to be in VGA mode on server entry are not" " supported by the MMIO-only version of this driver.\n"); - ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); - ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); - return FALSE; + goto bail_locked; } #endif /* AVOID_CPIO */ @@ -1809,8 +1782,9 @@ ATIPreInit if (pATI->LinearBase && pATI->LinearSize) { - int AcceleratorVideoRAM = pATI->LinearSize >> 10; - int ServerVideoRAM = pATI->VideoRAM; + int AcceleratorVideoRAM = 0, ServerVideoRAM; + +#ifndef AVOID_CPIO /* * Unless specified in PCI configuration space, set MMIO @@ -1823,6 +1797,10 @@ ATIPreInit pATI->MMIOInLinear = TRUE; } +#endif /* AVOID_CPIO */ + + AcceleratorVideoRAM = pATI->LinearSize >> 10; + /* * Account for MMIO area at the tail end of the linear * aperture, if it is needed or if it cannot be disabled. @@ -1830,6 +1808,8 @@ ATIPreInit if (pATI->MMIOInLinear || (pATI->Chip < ATI_CHIP_264VTB)) AcceleratorVideoRAM -= 2; + ServerVideoRAM = pATI->VideoRAM; + if (pATI->Cursor > ATI_CURSOR_SOFTWARE) { /* @@ -2475,6 +2455,8 @@ ATIPreInit bail: ATILock(pATI); + +bail_locked: ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize); ATIUnmapApertures(pScreenInfo->scrnIndex, pATI); |