summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2006-04-20 02:48:14 +0200
committerLuc Verhaegen <libv@skynet.be>2006-04-20 02:48:14 +0200
commitd03e528f9836d2614141ce1e4262494d1e1f2277 (patch)
treee3332036933ef28b51698560ca0ee4cbf60b1e39
parented8bce4fee83938c416507fd09014c0d90b1efa9 (diff)
Fix MMIO mapping.
We can get to MMIO on the GX as well, even when it's not primary. So assume that we can always map the IO area.
-rw-r--r--src/atipreinit.c436
-rw-r--r--src/atividmem.c101
-rw-r--r--src/atividmem.h1
3 files changed, 236 insertions, 302 deletions
diff --git a/src/atipreinit.c b/src/atipreinit.c
index c3d547e..6ac936d 100644
--- a/src/atipreinit.c
+++ b/src/atipreinit.c
@@ -57,10 +57,10 @@
#include "xf86RAC.h"
/*
- *
+ * FreeScreen handles the clean-up.
*/
static Bool
-ATIGetRec(ScrnInfoPtr pScrn)
+Mach64GetRec(ScrnInfoPtr pScrn)
{
if (!pScrn->driverPrivate) {
pScrn->driverPrivate = xnfcalloc(sizeof(ATIRec), 1);
@@ -73,11 +73,147 @@ ATIGetRec(ScrnInfoPtr pScrn)
return TRUE;
}
+#ifdef DEBUG
+static void
+Mach64MMIOTestDump(ATIPtr pATI, pointer IOAddress)
+{
+ int Index;
+
+ xf86ErrorF("MMIO register values (%p):\n", IOAddress);
+
+ for (Index = 0; Index < 256; Index+= 4) {
+ if (!(Index & 15))
+ xf86ErrorF("\n 0x%02X: ", Index);
+ xf86ErrorF(" %08lX", MMIO_IN32(IOAddress, Index));
+ }
+ xf86ErrorF("\n");
+}
+#endif
+
+/*
+ * Test MMIO range.
+ */
+static Bool
+Mach64MMIOTest(ATIPtr pATI, pointer IOAddress)
+{
+ CARD16 ChipID = MMIO_IN32(IOAddress, 0xE0) & 0xFFFF;
+
+ /* of course GX/CX has to be different */
+ if (pATI->Chip < ATI_CHIP_264CT) {
+ if (pATI->Chip == ATI_CHIP_88800CX) {
+ if (ChipID == 0x57)
+ return TRUE;
+ } else if (ChipID == 0xD7)
+ return TRUE;
+ } else {
+ if (ChipID == pATI->PCIInfo->chipType)
+ return TRUE;
+
+ /* Some early GT's are detected as VT's */
+ if ((ChipID == ATI_CHIP_264VT) &&
+ (pATI->PCIInfo->chipType == ATI_CHIP_264GT))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/*
+ * Temporarily map IO address and test it.
+ */
+static Bool
+Mach64MMIOProbeMap(ATIPtr pATI, unsigned long Address)
+{
+ char *IOAddress;
+ unsigned long PageSize = getpagesize();
+ unsigned long MMIOBase = Address & ~(PageSize - 1);
+ Bool Result = FALSE;
+
+ IOAddress = xf86MapPciMem(pATI->scrnIndex, VIDMEM_MMIO,
+ ((pciConfigPtr) pATI->PCIInfo->thisCard)->tag,
+ MMIOBase, PageSize);
+ if (!IOAddress)
+ return FALSE;
+
+ Result = Mach64MMIOTest(pATI, IOAddress + (Address - MMIOBase));
+
+ xf86UnMapVidMem(pATI->scrnIndex, IOAddress, PageSize);
+ return Result;
+}
+
+/*
+ * This function attempts to locate the MMIO area.
+ *
+ * TODO: ClaimFixedResource sparse IO address 0x6AEC
+ */
+static unsigned long
+Mach64MMIOProbe(ATIPtr pATI)
+{
+ pciVideoPtr pVideo = pATI->PCIInfo;
+ unsigned long Address;
+
+ /*
+ * Probe through auxiliary MMIO aperture if one exists. Because such
+ * apertures can be enabled/disabled only through PCI, this probes no
+ * further.
+ */
+ if ((pVideo->size[2] >= 12) && pVideo->memBase[2]) {
+ if (pVideo->memBase[2] < (CARD32)(-1 << pVideo->size[2])) {
+ Address = pVideo->memBase[2] + 0x400;
+
+ if (Mach64MMIOProbeMap(pATI, Address)) {
+ xf86DrvMsg(pATI->scrnIndex, X_PROBED,
+ "MMIO area detected in the third BAR.\n");
+ return Address;
+ }
+ }
+ }
+
+ /*
+ * Probe through the primary MMIO aperture that exists at the tail end
+ * of the linear aperture. Test for both 8MB and 4MB linear apertures.
+ */
+ if (pVideo->memBase[0]) {
+ /* Check if our linear memory aperture is enabled */
+ if (!(inw(0x6AEC) & 0x3)) {
+ CARD32 tmp = inw(0x6AEC);
+ xf86DrvMsg(pATI->scrnIndex, X_WARNING, "Linear memory aperture "
+ "not set up. Correcting.\n");
+
+ outw(0x6AEC, tmp | 0x2); /* Go for 8MB anyway */
+ }
+
+ if (pVideo->size[0] >= 23) {
+ Address = pVideo->memBase[0] + 0x007FFC00;
+
+ if (Mach64MMIOProbeMap(pATI, Address)) {
+ xf86DrvMsg(pATI->scrnIndex, X_PROBED,
+ "MMIO area detected in the first BAR.\n");
+ return Address;
+ }
+ }
+
+ if (pVideo->size[0] >= 22) {
+ Address = pVideo->memBase[0] + 0x003FFC00;
+
+ if (Mach64MMIOProbeMap(pATI, Address)) {
+ xf86DrvMsg(pATI->scrnIndex, X_PROBED,
+ "MMIO area detected in the first BAR.\n");
+ return Address;
+ }
+ }
+ }
+
+ xf86DrvMsg(pATI->scrnIndex, X_ERROR, "Unable to find MMIO Area.\n");
+ return 0;
+}
+
+
/*
* Collect IO range information.
*/
static void
-Mach64IOSetup(ATIPtr pATI)
+Mach64CPIOSetup(ATIPtr pATI)
{
/* block IO? */
if (pATI->PCIInfo->size[1]) {
@@ -125,138 +261,36 @@ Mach64IOSetup(ATIPtr pATI)
}
/*
- * ATIMach64Detect --
- *
- * This function determines if a Mach64 is detectable at a particular base
- * address.
+ * Make sure any Mach64 is not in some weird state
*/
-static Bool
-ATIMach64Detect(ATIPtr pATI)
+static void
+Mach64BusInit(ATIPtr pATI)
{
- CARD32 IOValue, bus_cntl, gen_test_cntl;
- Bool Found = FALSE;
-
- (void)ATIMapApertures(-1, pATI); /* Ignore errors */
-
-#ifdef AVOID_CPIO
-
- if (!pATI->pBlock[0])
- {
- ATIUnmapApertures(-1, pATI);
- return FALSE;
- }
-
-#endif /* AVOID_CPIO */
+ CARD32 IOValue;
- /* Make sure any Mach64 is not in some weird state */
- bus_cntl = inr(BUS_CNTL);
+ IOValue = inr(BUS_CNTL);
if (pATI->Chip < ATI_CHIP_264VTB)
outr(BUS_CNTL,
- (bus_cntl & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) |
+ (IOValue & ~(BUS_HOST_ERR_INT_EN | BUS_FIFO_ERR_INT_EN)) |
(BUS_HOST_ERR_INT | BUS_FIFO_ERR_INT));
else if (pATI->Chip < ATI_CHIP_264VT4)
- outr(BUS_CNTL, (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT);
+ outr(BUS_CNTL, (IOValue & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT);
- gen_test_cntl = inr(GEN_TEST_CNTL);
- IOValue = gen_test_cntl &
+ IOValue = inr(GEN_TEST_CNTL) &
(GEN_OVR_OUTPUT_EN | GEN_OVR_POLARITY | GEN_CUR_EN | GEN_BLOCK_WR_EN);
outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN);
outr(GEN_TEST_CNTL, IOValue);
- outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN);
-
- /* See if a Mach64 answers */
- IOValue = inr(SCRATCH_REG0);
-
- /* Test odd bits */
- outr(SCRATCH_REG0, 0x55555555U);
- if (inr(SCRATCH_REG0) == 0x55555555U) {
- /* Test even bits */
- outr(SCRATCH_REG0, 0xAAAAAAAAU);
- if (inr(SCRATCH_REG0) == 0xAAAAAAAAU)
- Found = TRUE;
- }
-
- /* Restore clobbered register value */
- outr(SCRATCH_REG0, IOValue);
-
- /* If no Mach64 was detected, return now */
- if (!Found) {
- outr(GEN_TEST_CNTL, gen_test_cntl);
- outr(BUS_CNTL, bus_cntl);
- }
-
- ATIUnmapApertures(-1, pATI);
- return Found;
+ outr(GEN_TEST_CNTL, IOValue | GEN_GUI_EN);
}
-#ifdef AVOID_CPIO
-
-/*
- * This function looks for a Mach64 at a particular MMIO address.
- */
-static Bool
-ATIMach64Probe(ATIPtr pATI)
-{
- pciVideoPtr pVideo = pATI->PCIInfo;
-
- /*
- * Probe through auxiliary MMIO aperture if one exists. Because such
- * apertures can be enabled/disabled only through PCI, this probes no
- * further.
- */
- if ((pVideo->size[2] >= 12) &&
- (pATI->Block0Base = pVideo->memBase[2]) &&
- (pATI->Block0Base < (CARD32)(-1 << pVideo->size[2]))) {
- pATI->Block0Base += 0x00000400U;
- return ATIMach64Detect(pATI);
- }
-
- /*
- * Probe through the primary MMIO aperture that exists at the tail end
- * of the linear aperture. Test for both 8MB and 4MB linear apertures.
- */
- if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0])) {
- pATI->Block0Base += 0x007FFC00U;
- if ((pVideo->size[0] >= 23) && ATIMach64Detect(pATI))
- return TRUE;
-
- pATI->Block0Base -= 0x00400000U;
- if (ATIMach64Detect(pATI))
- return TRUE;
- }
-
- /*
- * A last, perhaps desparate, probe attempt. Note that if this succeeds,
- * there's a VGA in the system and it's likely the PIO version of the
- * driver should be used instead (barring OS issues).
- */
- pATI->Block0Base = 0x000BFC00U;
- return ATIMach64Detect(pATI);
-}
-
-#else /* AVOID_CPIO */
-
+#ifndef AVOID_CPIO
/*
- * This function looks for a Mach64 at a particular PIO address.
+ * Determine VGA capability. VGA can always be enabled on integrated
+ * controllers. For the GX/CX, it's a board strap.
*/
-static Bool
-ATIMach64Probe(ATIPtr pATI)
+static void
+Mach64VGAInit(ATIPtr pATI)
{
- if (!pATI->CPIOBase)
- return FALSE;
-
- if ((pATI->CPIODecoding == BLOCK_IO) &&
- ((pATI->PCIInfo->size[1] < 8) ||
- (pATI->CPIOBase >= (CARD32)(-1 << pATI->PCIInfo->size[1]))))
- return FALSE;
-
- if (!ATIMach64Detect(pATI))
- return FALSE;
-
- /*
- * Determine VGA capability. VGA can always be enabled on integrated
- * controllers. For the GX/CX, it's a board strap.
- */
if (pATI->Chip < ATI_CHIP_264CT) {
CARD32 IOValue;
@@ -279,8 +313,6 @@ ATIMach64Probe(ATIPtr pATI)
outb(GENVS, 0x01U);
outb(GENENA, 0x0EU);
}
-
- return TRUE;
}
/*
@@ -1461,32 +1493,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]) {
- /* test wether we can read the pci-id */
- CARD16 ChipID = inr(CONFIG_CHIP_ID) & 0xFFFF;
-
- if (ChipID == pATI->PCIInfo->chipType)
- return;
-
- /* Some early GT's are detected as VT's */
- if ((ChipID == ATI_CHIP_264VT) &&
- (pATI->PCIInfo->chipType == ATI_CHIP_264GT))
- return;
- }
-
- ATIUnmapApertures(iScreen, pATI);
-}
-
-/*
* ATIPrintNoiseIfRequested --
*
* This function formats debugging information on the server's stderr when
@@ -1522,9 +1528,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
GDevPtr pGDev;
EntityInfoPtr pEntity;
resPtr pResources;
- pciVideoPtr pVideo;
DisplayModePtr pMode;
- unsigned long Block0Base;
CARD32 IOValue;
int i, j, AcceleratorVideoRAM = 0, ServerVideoRAM;
int Numerator, Denominator;
@@ -1555,7 +1559,7 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
return FALSE;
}
- if (!ATIGetRec(pScreenInfo))
+ if (!Mach64GetRec(pScreenInfo))
return FALSE;
pATI = ATIPTR(pScreenInfo);
@@ -1567,25 +1571,40 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
pResources = pEntity->resources;
pATI->PCIInfo = xf86GetPciInfoForEntity(pEntity->index);
pATI->iEntity = pEntity->index;
+ pATI->Chip = pEntity->chipset;
xfree(pEntity);
- pATI->Chip = pEntity->chipset;
-
- Mach64IOSetup(pATI);
-
- if (!ATIMach64Probe(pATI)) {
- xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
- "Mach64 at %02x:%02x:%01x can not be accessed!\n",
- pATI->PCIInfo->bus, pATI->PCIInfo->device,
- pATI->PCIInfo->func);
- xfree(pATI);
+ /*
+ * Set up MMIO.
+ * If we don't manage to access it now, then when will we?
+ */
+ pATI->Block0Base = Mach64MMIOProbe(pATI);
+ if (!pATI->Block0Base) {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, "Unable to locate MMIO "
+ "area for %02x:%02x:%01x. Exiting.\n", pATI->PCIInfo->bus,
+ pATI->PCIInfo->device, pATI->PCIInfo->func);
return FALSE;
}
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "Using Block 0 MMIO aperture"
+ " at 0x%08lX.\n", pATI->Block0Base);
+
+ /* Set Block1 MMIO address if supported */
+ if (pATI->Chip >= ATI_CHIP_264VT) {
+ pATI->Block1Base = pATI->Block0Base - 0x00000400U;
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED, "Using Block 1 MMIO aperture"
+ " at 0x%08lX.\n", pATI->Block1Base);
+ }
+ Mach64MMIOMap(pATI);
+
+ Mach64CPIOSetup(pATI); /* work me out */
+
+ Mach64BusInit(pATI);
Mach64BusType(pATI);
#ifndef AVOID_CPIO
+ Mach64VGAInit(pATI);
if (pATI->IsVGA)
ATIClaimVGAResources(pATI);
#endif
@@ -1772,20 +1791,6 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
#endif /* AVOID_CPIO */
- pATI->Block0Base = 0; /* Might no longer be valid */
- pVideo = pATI->PCIInfo;
-
- 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;
- }
-
#ifdef AVOID_CPIO
pScreenInfo->racMemFlags =
@@ -1816,43 +1821,6 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
pATI->nFIFOEntries = 16; /* For now */
pATI->Audio = ATI_AUDIO_NONE;
- do {
- /*
- * Find and mmap() MMIO area. Allow only auxiliary aperture if
- * it exists.
- */
- if (!(Block0Base = 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;
-
-#ifdef AVOID_CPIO
-
- if (!pATI->pBlock[0]) {
- xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
- "Unable to mmap() adapter registers.\n");
- return FALSE;
- }
-
-#endif /* AVOID_CPIO */
-
pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL);
if (!(pATIHW->crtc_gen_cntl & CRTC_EN) &&
(pATI->Chip >= ATI_CHIP_264CT)) {
@@ -2195,16 +2163,6 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
}
if (pATI->LinearBase && pATI->LinearSize) {
- /*
- * Unless specified in PCI configuration space, set MMIO
- * address to tail end of linear aperture.
- */
- if (!pATI->Block0Base) {
- pATI->Block0Base =
- pATI->LinearBase + pATI->LinearSize - 0x00000400U;
- pATI->MMIOInLinear = TRUE;
- }
-
AcceleratorVideoRAM = pATI->LinearSize >> 10;
/*
@@ -2313,17 +2271,6 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
pATI->BankInfo.SetDestinationBank = ATIMach64SetWritePacked;
pATI->BankInfo.SetSourceAndDestinationBanks =
ATIMach64SetReadWritePacked;
-
- /*
- * Unless specified in PCI configuration space, or at the top of
- * of a little-endian linear aperture, set MMIO address to the one
- * just above the VGA aperture. This does not work on the CT
- * (maybe others).
- */
- if (!pATI->Block0Base &&
- ((pATI->Chip < ATI_CHIP_264CT) || (pATI->Chip >= ATI_CHIP_264VT) ||
- pATI->OptionDevel))
- pATI->Block0Base = 0x000BFC00U;
}
if (!pATI->OptionLinear)
@@ -2357,20 +2304,6 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
}
- if (pATI->Block0Base) {
- xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
- "Using Block 0 MMIO aperture at 0x%08lX.\n",
- pATI->Block0Base);
-
- /* Set Block1 MMIO address if supported */
- if (pATI->Chip >= ATI_CHIP_264VT) {
- pATI->Block1Base = pATI->Block0Base - 0x00000400U;
- xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
- "Using Block 1 MMIO aperture at 0x%08lX.\n",
- pATI->Block1Base);
- }
- }
-
#ifndef AVOID_CPIO
if (pATI->OptionLinear)
@@ -2418,18 +2351,15 @@ ATIPreInit(ScrnInfoPtr pScreenInfo, int flags)
ATIUnlock(pATI);
- if (pATI->OptionAccel)
- {
+ if (pATI->OptionAccel) {
#ifndef AVOID_CPIO
- if (!pATI->Block0Base || (pATI->NewHW.crtc == ATI_CRTC_VGA))
- {
+ if (pATI->NewHW.crtc == ATI_CRTC_VGA) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
- "Acceleration not supported in this configuration.\n");
+ "Acceleration not supported in this configuration.\n");
pATI->OptionAccel = FALSE;
- }
- else
+ } else
#endif /* AVOID_CPIO */
diff --git a/src/atividmem.c b/src/atividmem.c
index f55fee2..bbbca0f 100644
--- a/src/atividmem.c
+++ b/src/atividmem.c
@@ -134,41 +134,57 @@ ATIUnmapLinear
}
/*
- * ATIUnmapMMIO --
+ * ATIUnmapCursor --
*
- * Unmap MMIO registers.
+ * Unmap hardware cursor image area.
*/
static void
-ATIUnmapMMIO
+ATIUnmapCursor
(
int iScreen,
ATIPtr pATI
)
{
- if (pATI->pMMIO)
- xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize());
+ if (pATI->pCursorPage)
+ xf86UnMapVidMem(iScreen, pATI->pCursorPage, getpagesize());
- pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL;
+ pATI->pCursorPage = pATI->pCursorImage = NULL;
}
/*
- * ATIUnmapCursor --
*
- * Unmap hardware cursor image area.
+ *
*/
+Bool
+Mach64MMIOMap(ATIPtr pATI)
+{
+ unsigned long PageSize = getpagesize();
+ unsigned long MMIOBase = pATI->Block0Base & ~(PageSize - 1);
+
+ pATI->pMMIO = xf86MapPciMem(pATI->scrnIndex, VIDMEM_MMIO,
+ ((pciConfigPtr) pATI->PCIInfo->thisCard)->tag,
+ MMIOBase, PageSize);
+ if (!pATI->pMMIO)
+ return FALSE;
+
+ pATI->pBlock[0] = (char *)pATI->pMMIO + (pATI->Block0Base - MMIOBase);
+
+ if (pATI->Block1Base)
+ pATI->pBlock[1] = (char *)pATI->pBlock[0] - 0x00000400U;
+
+ return TRUE;
+}
+
static void
-ATIUnmapCursor
-(
- int iScreen,
- ATIPtr pATI
-)
+Mach64MMIOUnmap(ATIPtr pATI)
{
- if (pATI->pCursorPage)
- xf86UnMapVidMem(iScreen, pATI->pCursorPage, getpagesize());
+ if (pATI->pMMIO)
+ xf86UnMapVidMem(pATI->scrnIndex, pATI->pMMIO, getpagesize());
- pATI->pCursorPage = pATI->pCursorImage = NULL;
+ pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL;
}
+
/*
* ATIMapApertures --
*
@@ -257,42 +273,29 @@ ATIMapApertures(int iScreen, ATIPtr pATI)
}
/* Map MMIO aperture */
- if (pATI->Block0Base) {
- unsigned long MMIOBase = pATI->Block0Base & ~(PageSize - 1);
-
- pATI->pMMIO = xf86MapPciMem(iScreen, VIDMEM_MMIO,
- Tag, MMIOBase, PageSize);
- if (!pATI->pMMIO) {
-
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- ATIUnmapCursor(iScreen, pATI);
-#endif /* X_BYTE_ORDER */
-
- ATIUnmapLinear(iScreen, pATI);
+ if (!pATI->pMMIO && !Mach64MMIOMap(pATI)) {
+ ATIUnmapCursor(iScreen, pATI);
+ ATIUnmapLinear(iScreen, pATI);
#ifndef AVOID_CPIO
- ATIUnmapVGA(iScreen, pATI);
+ ATIUnmapVGA(iScreen, pATI);
#endif /* AVOID_CPIO */
- pATI->Mapped = FALSE;
- return FALSE;
- }
-
- pATI->Mapped = TRUE;
-
- pATI->pBlock[0] = (char *)pATI->pMMIO +
- (pATI->Block0Base - MMIOBase);
-
- if (pATI->Block1Base)
- pATI->pBlock[1] = (char *)pATI->pBlock[0] - 0x00000400U;
+ pATI->Mapped = FALSE;
+ return FALSE;
+ }
+ pATI->Mapped = TRUE;
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- if (!pATI->pCursorImage)
-#endif /* X_BYTE_ORDER */
- if ((pATI->CursorBase >= MMIOBase) &&
- ((pATI->CursorBase + 0x00000400UL) <= (MMIOBase + PageSize)))
- pATI->pCursorImage = (char *)pATI->pMMIO +
- (pATI->CursorBase - MMIOBase);
+ /*
+ * Try to stick the cursor in the vicinity of the MMIO address.
+ * !!! CHECK ME -- does CursorBase fall in the page mapped?
+ */
+ if (!pATI->pCursorImage) {
+ unsigned long MMIOBase = pATI->Block0Base & ~(PageSize - 1);
+ if ((pATI->CursorBase >= MMIOBase) &&
+ ((pATI->CursorBase + 0x00000400UL) <= (MMIOBase + PageSize)))
+ pATI->pCursorImage = (char *)pATI->pMMIO +
+ (pATI->CursorBase - MMIOBase);
}
/* Map hardware cursor image area */
@@ -303,7 +306,7 @@ ATIMapApertures(int iScreen, ATIPtr pATI)
Tag, CursorBase, PageSize);
if (!pATI->pCursorPage) {
ATIUnmapCursor(iScreen, pATI);
- ATIUnmapMMIO(iScreen, pATI);
+ Mach64MMIOUnmap(pATI);
ATIUnmapLinear(iScreen, pATI);
#ifndef AVOID_CPIO
@@ -341,7 +344,7 @@ ATIUnmapApertures
ATIUnmapCursor(iScreen, pATI);
/* Unmap MMIO area */
- ATIUnmapMMIO(iScreen, pATI);
+ Mach64MMIOUnmap(pATI);
/* Unmap linear aperture */
ATIUnmapLinear(iScreen, pATI);
diff --git a/src/atividmem.h b/src/atividmem.h
index fbb6a0b..10dc126 100644
--- a/src/atividmem.h
+++ b/src/atividmem.h
@@ -70,5 +70,6 @@ extern const char *ATIMemoryTypeNames_264xT[];
extern Bool ATIMapApertures(int, ATIPtr);
extern void ATIUnmapApertures(int, ATIPtr);
+extern Bool Mach64MMIOMap(ATIPtr pATI);
#endif /* ___ATIVIDMEM_H___ */