summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2006-03-12 06:11:18 +0000
committerLuc Verhaegen <libv@skynet.be>2006-03-12 06:11:18 +0000
commit2dd64279f07c09583c747db58f226dbfa5949486 (patch)
tree3a7ab655885390e0e20968c2697f4de8fa42851b
parent794dad47f82f3571a35397dcd0875c986d24bdad (diff)
Remove some clearly unwanted sections from the Probe routine. We will be
replacing it all with a simple pci id lookup anyway.
-rw-r--r--ChangeLog11
-rw-r--r--src/atibus.c32
-rw-r--r--src/atibus.h2
-rw-r--r--src/atichip.c46
-rw-r--r--src/atichip.h6
-rw-r--r--src/atiprobe.c929
6 files changed, 159 insertions, 867 deletions
diff --git a/ChangeLog b/ChangeLog
index 29b729d..ee52ed5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2006-03-12 Luc Verhaegen <libv@skynet.be>
+
+ * src/atibus.c: (ATIClaimResources):
+ * src/atibus.h:
+ * src/atichip.c:
+ * src/atichip.h:
+ * src/atiprobe.c: (ATIProbe):
+
+ Remove some clearly unwanted sections from the Probe routine.
+ We will be replacing it all with a simple pci id lookup anyway.
+
2006-03-11 Luc Verhaegen <libv@skynet.be>
* README:
diff --git a/src/atibus.c b/src/atibus.c
index c6eade1..e2a436d 100644
--- a/src/atibus.c
+++ b/src/atibus.c
@@ -59,7 +59,7 @@ const char *ATIBusNames[] =
* attempts to register unshareable resources for inactive PCI adapters,
* whether or not they are relocatable.
*/
-static void
+void
ATIClaimResources
(
ATIPtr pATI,
@@ -155,33 +155,3 @@ ATIClaimResources
xf86PrintResList(1, pResources);
xf86FreeResList(pResources);
}
-
-/*
- * ATIClaimBusSlot --
- *
- * Claim an adapter and register its resources.
- */
-int
-ATIClaimBusSlot
-(
- DriverPtr pDriver,
- int Chipset,
- GDevPtr pGDev,
- Bool Active,
- ATIPtr pATI
-)
-{
- pciVideoPtr pVideo = pATI->PCIInfo;
-
- if (pVideo)
- pATI->iEntity =
- xf86ClaimPciSlot(pVideo->bus, pVideo->device, pVideo->func,
- pDriver, Chipset, pGDev, Active);
- else
- pATI->iEntity = xf86ClaimIsaSlot(pDriver, Chipset, pGDev, Active);
-
- if (pATI->iEntity >= 0)
- ATIClaimResources(pATI, Active);
-
- return pATI->iEntity;
-}
diff --git a/src/atibus.h b/src/atibus.h
index d13a6fd..63b74af 100644
--- a/src/atibus.h
+++ b/src/atibus.h
@@ -52,6 +52,6 @@ typedef enum
extern const char *ATIBusNames[];
-extern int ATIClaimBusSlot(DriverPtr, int, GDevPtr, Bool, ATIPtr);
+void ATIClaimResources(ATIPtr pATI, Bool Active);
#endif /* ___ATIBUS_H___ */
diff --git a/src/atichip.c b/src/atichip.c
index 4d676de..34d9bea 100644
--- a/src/atichip.c
+++ b/src/atichip.c
@@ -123,52 +123,6 @@ const char *ATIChipNames[] =
const char *ATIFoundryNames[] =
{ "SGS", "NEC", "KCS", "UMC", "TSMC", "5", "6", "UMC" };
-#ifndef AVOID_CPIO
-
-/*
- * ATIMach32ChipID --
- *
- * Set variables whose value is dependent upon an 68800's CHIP_ID register.
- */
-void
-ATIMach32ChipID
-(
- ATIPtr pATI
-)
-{
- CARD16 IOValue = inw(CHIP_ID);
- pATI->ChipType = GetBits(IOValue, CHIP_CODE_0 | CHIP_CODE_1);
- pATI->ChipClass = GetBits(IOValue, CHIP_CLASS);
- pATI->ChipRevision = GetBits(IOValue, CHIP_REV);
- pATI->ChipRev = pATI->ChipRevision;
- if (IOValue == 0xFFFFU)
- IOValue = 0;
- switch (GetBits(IOValue, CHIP_CODE_0 | CHIP_CODE_1))
- {
- case OldChipID('A', 'A'):
- pATI->Chip = ATI_CHIP_68800_3;
- break;
-
- case OldChipID('X', 'X'):
- pATI->Chip = ATI_CHIP_68800_6;
- break;
-
- case OldChipID('L', 'X'):
- pATI->Chip = ATI_CHIP_68800LX;
- break;
-
- case OldChipID('A', 'X'):
- pATI->Chip = ATI_CHIP_68800AX;
- break;
-
- default:
- pATI->Chip = ATI_CHIP_68800;
- break;
- }
-}
-
-#endif /* AVOID_CPIO */
-
/*
* ATIMach64ChipID --
*
diff --git a/src/atichip.h b/src/atichip.h
index f0d6827..e594ab2 100644
--- a/src/atichip.h
+++ b/src/atichip.h
@@ -137,12 +137,6 @@ typedef enum
extern const char *ATIFoundryNames[];
-#ifndef AVOID_CPIO
-
-extern void ATIMach32ChipID(ATIPtr);
-
-#endif /* AVOID_CPIO */
-
extern void ATIMach64ChipID(ATIPtr, const CARD16);
extern ATIChipType ATIChipID(const CARD16, const CARD8);
diff --git a/src/atiprobe.c b/src/atiprobe.c
index 8f25db0..b417c5b 100644
--- a/src/atiprobe.c
+++ b/src/atiprobe.c
@@ -88,60 +88,6 @@ typedef struct
} PortRec, *PortPtr;
/*
- * ATIScanPCIBases --
- *
- * This function loops though a device's PCI registered bases and accumulates
- * a list of block I/O bases in use in the system.
- */
-static void
-ATIScanPCIBases
-(
- PortPtr *PCIPorts,
- int *nPCIPort,
- const CARD32 *pBase,
- const int *pSize,
- const CARD8 ProbeFlag
-)
-{
- IOADDRESS Base;
- int i, j;
-
- for (i = 6; --i >= 0; pBase++, pSize++)
- {
- if (*pBase & PCI_MAP_IO)
- {
- Base = *pBase & ~IO_BYTE_SELECT;
- for (j = 0; ; j++)
- {
- if (j >= *nPCIPort)
- {
- (*nPCIPort)++;
- *PCIPorts = (PortPtr)xnfrealloc(*PCIPorts,
- *nPCIPort * SizeOf(PortRec));
- (*PCIPorts)[j].Base = Base;
- (*PCIPorts)[j].Size = (CARD8)*pSize;
- (*PCIPorts)[j].Flag = ProbeFlag;
- break;
- }
-
- if (Base == (*PCIPorts)[j].Base)
- break;
- }
-
- continue;
- }
-
- /* Allow for 64-bit addresses */
- if (!PCI_MAP_IS64BITMEM(*pBase))
- continue;
-
- i--;
- pBase++;
- pSize++;
- }
-}
-
-/*
* ATICheckSparseIOBases --
*
* This function checks whether a sparse I/O base can safely be probed.
@@ -331,149 +277,6 @@ ATIVGAWonderProbe
}
}
-/*
- * ATI8514Probe --
- *
- * This function looks for an 8514/A compatible and returns an ATIRec if one is
- * found. The function also determines whether or not the detected 8514/A
- * compatible device is actually a Mach8 or Mach32, and sets pATI->Adapter
- * accordingly.
- */
-static ATIPtr
-ATI8514Probe
-(
- pciVideoPtr pVideo
-)
-{
- ATIPtr pATI = NULL;
- CARD16 IOValue1, IOValue2;
-
- /*
- * Save register value to be modified, just in case there is no 8514/A
- * compatible accelerator. Note that, in more ways than one,
- * SUBSYS_STAT == SUBSYS_CNTL.
- */
- IOValue1 = inw(SUBSYS_STAT);
- IOValue2 = IOValue1 & _8PLANE;
-
- /* Reset any 8514/A compatible adapter that might be present */
- outw(SUBSYS_CNTL, IOValue2 | (GPCTRL_RESET | CHPTEST_NORMAL));
- outw(SUBSYS_CNTL, IOValue2 | (GPCTRL_ENAB | CHPTEST_NORMAL |
- RVBLNKFLG | RPICKFLAG | RINVALIDIO | RGPIDLE));
-
- /* Probe for an 8514/A compatible */
- IOValue2 = inw(ERR_TERM);
- outw(ERR_TERM, 0x5A5AU);
- ProbeWaitIdleEmpty();
- if (inw(ERR_TERM) == 0x5A5AU)
- {
- outw(ERR_TERM, 0x2525U);
- if (inw(ERR_TERM) == 0x2525U)
- {
- pATI = (ATIPtr)xnfcalloc(1, SizeOf(ATIRec));
- pATI->Adapter = ATI_ADAPTER_8514A;
- pATI->ChipHasSUBSYS_CNTL = TRUE;
- pATI->PCIInfo = pVideo;
- }
- }
- outw(ERR_TERM, IOValue2);
-
- /* Restore register value clobbered by 8514/A reset attempt */
- if (!pATI)
- {
- outw(SUBSYS_CNTL, IOValue1);
- return NULL;
- }
-
- /* Ensure any Mach8 or Mach32 is not in 8514/A emulation mode */
- IOValue1 = inw(CLOCK_SEL);
- outw(CLOCK_SEL, IOValue1);
- ProbeWaitIdleEmpty();
-
- IOValue1 = IOValue2 = inw(ROM_ADDR_1);
- outw(ROM_ADDR_1, 0x5555U);
- ProbeWaitIdleEmpty();
- if (inw(ROM_ADDR_1) == 0x5555U)
- {
- outw(ROM_ADDR_1, 0x2A2AU);
- ProbeWaitIdleEmpty();
- if (inw(ROM_ADDR_1) == 0x2A2AU)
- pATI->Adapter = ATI_ADAPTER_MACH8;
- }
- outw(ROM_ADDR_1, IOValue1);
-
- if (pATI->Adapter == ATI_ADAPTER_MACH8)
- {
- /* A Mach8 or Mach32 has been detected */
- IOValue1 = inw(READ_SRC_X);
- outw(DESTX_DIASTP, 0xAAAAU);
- ProbeWaitIdleEmpty();
- if (inw(READ_SRC_X) == 0x02AAU)
- pATI->Adapter = ATI_ADAPTER_MACH32;
-
- outw(DESTX_DIASTP, 0x5555U);
- ProbeWaitIdleEmpty();
- if (inw(READ_SRC_X) == 0x0555U)
- {
- if (pATI->Adapter != ATI_ADAPTER_MACH32)
- pATI->Adapter = ATI_ADAPTER_8514A;
- }
- else
- {
- if (pATI->Adapter != ATI_ADAPTER_MACH8)
- pATI->Adapter = ATI_ADAPTER_8514A;
- }
- outw(DESTX_DIASTP, IOValue1);
- }
-
- switch (pATI->Adapter)
- {
- case ATI_ADAPTER_8514A:
- pATI->Coprocessor = ATI_CHIP_8514A;
- IOValue1 = inb(EXT_CONFIG_3);
- outb(EXT_CONFIG_3, IOValue1 & 0x0FU);
- if (!(inb(EXT_CONFIG_3) & 0xF0U))
- {
- outb(EXT_CONFIG_3, IOValue1 | 0xF0U);
- if ((inb(EXT_CONFIG_3) & 0xF0U) == 0xF0U)
- pATI->Coprocessor = ATI_CHIP_CT480;
- }
- outb(EXT_CONFIG_3, IOValue1);
- break;
-
- case ATI_ADAPTER_MACH8:
- pATI->Coprocessor = ATI_CHIP_38800_1;
- if (inw(CONFIG_STATUS_1) & MC_BUS)
- pATI->BusType = ATI_BUS_MCA16;
- break;
-
- case ATI_ADAPTER_MACH32:
- IOValue1 = inw(CONFIG_STATUS_1);
- pATI->BusType = GetBits(IOValue1, BUS_TYPE);
- pATI->BIOSBase = 0x000C0000U +
- (GetBits(IOValue2, BIOS_BASE_SEGMENT) << 11);
- if (!(IOValue1 & (_8514_ONLY | CHIP_DIS)))
- {
- pATI->VGAAdapter = ATI_ADAPTER_MACH32;
- if ((xf86ReadBIOS(pATI->BIOSBase, 0x10U,
- (pointer)(&pATI->CPIO_VGAWonder),
- SizeOf(pATI->CPIO_VGAWonder)) <
- SizeOf(pATI->CPIO_VGAWonder)) ||
- !(pATI->CPIO_VGAWonder &= SPARSE_IO_PORT))
- pATI->CPIO_VGAWonder = 0x01CEU;
- pATI->VGAOffset = 0x80U;
- }
-
- ATIMach32ChipID(pATI);
- break;
-
- default:
- break;
- }
-
- return pATI;
-}
-
#endif /* AVOID_CPIO */
/*
@@ -927,7 +730,7 @@ ATIProbe
)
{
ATIPtr pATI, *ATIPtrs = NULL;
- GDevPtr *GDevs, pGDev;
+ GDevPtr pGDev;
pciVideoPtr pVideo, *xf86PciVideoInfo = xf86GetPciVideoInfo();
pciConfigPtr pPCI;
ATIGDev *ATIGDevs = NULL, *pATIGDev;
@@ -935,30 +738,22 @@ ATIProbe
CARD32 PciReg;
Bool ProbeSuccess = FALSE;
int i, j, k;
- int nGDev, nATIGDev = -1, nATIPtr = 0;
+ int nATIGDev = -1, nATIPtr = 0;
int Chipset;
ATIChipType Chip;
#ifndef AVOID_CPIO
- ATIPtr pVGA = NULL, p8514 = NULL;
- pciConfigPtr *xf86PciInfo = xf86GetPciConfigInfo();
- PortPtr PCIPorts = NULL;
- int nPCIPort = 0;
- CARD8 fChipsets[ATI_CHIPSET_MAX];
+ ATIPtr pVGA = NULL;
static const IOADDRESS Mach64SparseIOBases[] = {0x02ECU, 0x01CCU, 0x01C8U};
CARD8 ProbeFlags[LongPort(SPARSE_IO_BASE) + 1];
- unsigned long BIOSBase;
- static const CARD8 ATISignature[] = " 761295520";
-# define SignatureSize 10
-# define PrefixSize 0x50U
-# define BIOSSignature 0x30U
- CARD8 BIOS[PrefixSize];
-# define BIOSWord(_n) (BIOS[_n] | (BIOS[(_n) + 1] << 8))
-
#endif /* AVOID_CPIO */
+ /* We only do PCI from now on. */
+ if (!xf86PciVideoInfo)
+ return FALSE;
+
# define AddAdapter(_p) \
do \
{ \
@@ -968,14 +763,10 @@ ATIProbe
(_p)->iEntity = -2; \
} while (0)
-#ifndef AVOID_CPIO
-
- (void)memset(fChipsets, FALSE, SizeOf(fChipsets));
-
-#endif /* AVOID_CPIO */
+ if (!(flags & PROBE_DETECT)) {
+ GDevPtr *GDevs;
+ int nGDev;
- if (!(flags & PROBE_DETECT))
- {
/*
* Get a list of XF86Config device sections whose "Driver" is either
* not specified, or specified as this driver. From this list,
@@ -1018,13 +809,6 @@ ATIProbe
xf86MsgVerb(X_INFO, 3,
ATI_NAME ": Candidate \"Device\" section \"%s\".\n",
pGDev->identifier);
-
-#ifndef AVOID_CPIO
-
- fChipsets[Chipset] = TRUE;
-
-#endif /* AVOID_CPIO */
-
}
xfree(GDevs);
@@ -1037,595 +821,196 @@ ATIProbe
}
}
-#ifndef AVOID_CPIO
-
- /*
- * Collect hardware information. This must be done with care to avoid
- * lockups due to overlapping I/O port assignments.
- *
- * First, scan PCI configuration space for registered I/O ports (which will
- * be block I/O bases). Each such port is used to generate a list of
- * sparse I/O bases it precludes. This list is then used to decide whether
- * or not certain sparse I/O probes are done. Unfortunately, this assumes
- * that any registered I/O base actually reserves upto the full 256 ports
- * allowed by the PCI specification. This assumption holds true for PCI
- * Mach64, but probably doesn't for other device types. For some things,
- * such as video devices, the number of ports a base represents is
- * determined by the server's PCI probe, but, for other devices, this
- * cannot be done by a user-level process without jeopardizing system
- * integrity. This information should ideally be retrieved from the OS's
- * own PCI probe (if any), but there's currently no portable way of doing
- * so. The following allows sparse I/O probes to be forced in certain
- * circumstances when an appropriate chipset specification is used in any
- * XF86Config Device section.
- *
- * Note that this is not bullet-proof. Lockups can still occur, but they
- * will usually be due to devices that are misconfigured to respond to the
- * same I/O ports as 8514/A's or ATI sparse I/O devices without registering
- * them in PCI configuration space.
- */
- if (nATIGDev)
- {
- if (xf86PciVideoInfo)
- {
- for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
- {
- if ((pVideo->vendor == PCI_VENDOR_ATI) ||
- !(pPCI = pVideo->thisCard))
- continue;
-
- ATIScanPCIBases(&PCIPorts, &nPCIPort,
- &pPCI->pci_base0, pVideo->size,
- (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) &
- PCI_CMD_IO_ENABLE) ? 0 : Allowed);
- }
- }
-
- /* Check non-video PCI devices for I/O bases */
- if (xf86PciInfo)
- {
- for (i = 0; (pPCI = xf86PciInfo[i++]); )
- {
- if ((pPCI->pci_vendor == PCI_VENDOR_ATI) ||
- (pPCI->pci_base_class == PCI_CLASS_BRIDGE) ||
- (pPCI->pci_header_type &
- ~GetByte(PCI_HEADER_MULTIFUNCTION, 2)))
- continue;
-
- ATIScanPCIBases(&PCIPorts, &nPCIPort,
- &pPCI->pci_base0, pPCI->basesize,
- (pciReadLong(pPCI->tag, PCI_CMD_STAT_REG) &
- PCI_CMD_IO_ENABLE) ? 0 : Allowed);
- }
- }
-
- /* Generate ProbeFlags array from list of registered PCI I/O bases */
- (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags));
- for (i = 0; i < nPCIPort; i++)
- {
- CARD32 Base = PCIPorts[i].Base;
- CARD16 Count = (1 << PCIPorts[i].Size) - 1;
- CARD8 ProbeFlag = PCIPorts[i].Flag;
-
- /*
- * The following reduction of Count is based on the assumption that
- * PCI-registered I/O port ranges do not overlap.
- */
- for (j = 0; j < nPCIPort; j++)
- {
- CARD32 Base2 = PCIPorts[j].Base;
-
- if (Base < Base2)
- while ((Base + Count) >= Base2)
- Count >>= 1;
- }
-
- Base = LongPort(Base);
- Count = LongPort((Count | IO_BYTE_SELECT) + 1);
- while (Count--)
- ProbeFlags[Base++] &= ProbeFlag;
- }
-
- xfree(PCIPorts);
- }
-
-#endif /* AVOID_CPIO */
-
- if (xf86PciVideoInfo)
- {
- if (nATIGDev)
- {
+ if (nATIGDev) {
#ifndef AVOID_CPIO
- /*
- * This is the second pass through PCI configuration space. Much
- * of this is verbiage to deal with potential situations that are
- * very unlikely to occur in practice.
- *
- * First, look for non-ATI shareable VGA's. For now, these must
- * the primary device.
- */
- if (ATICheckSparseIOBases(NULL, ProbeFlags, ATTRX, 16, TRUE) ==
- DoProbe)
- {
- for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
- {
- if ((pVideo->vendor == PCI_VENDOR_ATI) ||
- !xf86IsPrimaryPci(pVideo))
- continue;
-
- if (!xf86CheckPciSlot(pVideo->bus,
- pVideo->device,
- pVideo->func))
- continue;
-
- xf86SetPciVideo(pVideo, MEM_IO);
-
- pATI = ATIVGAProbe(NULL);
- if (pATI->Adapter == ATI_ADAPTER_NONE)
- {
- xfree(pATI);
- xf86Msg(X_WARNING,
- ATI_NAME ": PCI/AGP VGA compatible in slot"
- " %d:%d:%d could not be detected!\n",
- pVideo->bus, pVideo->device, pVideo->func);
- }
- else
- {
- sprintf(Identifier,
- "Shared non-ATI VGA in PCI/AGP slot %d:%d:%d",
- pVideo->bus, pVideo->device, pVideo->func);
- xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n",
- Identifier);
- AddAdapter(pATI);
- pATI->SharedVGA = TRUE;
- pATI->BusType = ATI_BUS_PCI;
- pATI->PCIInfo = pVideo;
- }
-
- xf86SetPciVideo(NULL, NONE);
- }
- }
-
- /* Next, look for PCI Mach32's */
- for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
- {
- if ((pVideo->vendor != PCI_VENDOR_ATI) ||
- (pVideo->chipType != PCI_CHIP_MACH32))
- continue;
-
- switch (ATICheckSparseIOBases(pVideo, ProbeFlags,
- 0x02E8U, 8, TRUE))
- {
- case 0:
- xf86Msg(X_WARNING,
- ATI_NAME ": PCI Mach32 in slot %d:%d:%d will not"
- " be enabled\n because it conflicts with a"
- " non-video PCI/AGP device.\n",
- pVideo->bus, pVideo->device, pVideo->func);
- break;
- default: /* Must be DoProbe */
- if (!xf86CheckPciSlot(pVideo->bus,
- pVideo->device,
- pVideo->func))
- continue;
-
- xf86SetPciVideo(pVideo, MEM_IO);
-
- if (!(pATI = ATI8514Probe(pVideo)))
- {
- xf86Msg(X_WARNING,
- ATI_NAME ": PCI Mach32 in slot %d:%d:%d could"
- " not be detected!\n",
- pVideo->bus, pVideo->device, pVideo->func);
- }
- else
- {
- sprintf(Identifier,
- "Shared 8514/A in PCI slot %d:%d:%d",
- pVideo->bus, pVideo->device, pVideo->func);
- xf86MsgVerb(X_INFO, 3,
- ATI_NAME ": %s detected.\n", Identifier);
- if (pATI->Adapter != ATI_ADAPTER_MACH32)
- xf86Msg(X_WARNING,
- ATI_NAME ": PCI Mach32 in slot %d:%d:%d"
- " could only be detected as an %s!\n",
- pVideo->bus, pVideo->device, pVideo->func,
- ATIAdapterNames[pATI->Adapter]);
-
- AddAdapter(pATI);
- pATI->SharedAccelerator = TRUE;
-
- if ((pATI->VGAAdapter != ATI_ADAPTER_NONE) ||
- (pATI->Coprocessor != ATI_CHIP_NONE))
- ATIFindVGA(pVideo, &pVGA, &pATI, p8514,
- ProbeFlags);
- }
- xf86SetPciVideo(NULL, NONE);
- break;
- }
- }
-
- /* Next, look for sparse I/O Mach64's */
- for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
- {
- if ((pVideo->vendor != PCI_VENDOR_ATI) ||
- (pVideo->chipType == PCI_CHIP_MACH32) ||
- pVideo->size[1])
- continue;
+ /* Next, look for sparse I/O Mach64's */
+ for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) {
+ if ((pVideo->vendor != PCI_VENDOR_ATI) ||
+ (pVideo->chipType == PCI_CHIP_MACH32) ||
+ pVideo->size[1])
+ continue;
- pPCI = pVideo->thisCard;
- if (pPCI == NULL)
- continue;
+ pPCI = pVideo->thisCard;
+ if (pPCI == NULL)
+ continue;
- PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG);
- j = PciReg & 0x03U;
- if (j == 0x03U)
- {
- xf86Msg(X_WARNING,
+ PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG);
+ j = PciReg & 0x03U;
+ if (j == 0x03U) {
+ xf86Msg(X_WARNING,
ATI_NAME ": PCI Mach64 in slot %d:%d:%d cannot be"
" enabled\n because it has neither a block, nor a"
" sparse, I/O base.\n",
pVideo->bus, pVideo->device, pVideo->func);
- }
- else switch(ATICheckSparseIOBases(pVideo, ProbeFlags,
- Mach64SparseIOBases[j], 4, TRUE))
- {
- case 0:
- xf86Msg(X_WARNING,
+ } else
+ switch(ATICheckSparseIOBases(pVideo, ProbeFlags,
+ Mach64SparseIOBases[j], 4, TRUE)) {
+ case 0:
+ xf86Msg(X_WARNING,
ATI_NAME ": PCI Mach64 in slot %d:%d:%d will not"
" be enabled\n because it conflicts with another"
" non-video PCI device.\n",
pVideo->bus, pVideo->device, pVideo->func);
- break;
- default: /* Must be DoProbe */
- if (!xf86CheckPciSlot(pVideo->bus,
- pVideo->device,
- pVideo->func))
- continue;
+ break;
+ default: /* Must be DoProbe */
+ if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func))
+ continue;
- /* Possibly fix block I/O indicator */
- if (PciReg & 0x00000004U)
- pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG,
- PciReg & ~0x00000004U);
+ /* Possibly fix block I/O indicator */
+ if (PciReg & 0x00000004U)
+ pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG,
+ PciReg & ~0x00000004U);
- xf86SetPciVideo(pVideo, MEM_IO);
+ xf86SetPciVideo(pVideo, MEM_IO);
- Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
- pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j],
- SPARSE_IO, Chip);
- if (!pATI)
- {
- xf86Msg(X_WARNING,
+ Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
+ pATI = ATIMach64Probe(pVideo, Mach64SparseIOBases[j],
+ SPARSE_IO, Chip);
+ if (!pATI) {
+ xf86Msg(X_WARNING,
ATI_NAME ": PCI Mach64 in slot %d:%d:%d could"
" not be detected!\n",
pVideo->bus, pVideo->device, pVideo->func);
- }
- else
- {
- sprintf(Identifier,
+ } else {
+ sprintf(Identifier,
"Shared PCI Mach64 in slot %d:%d:%d",
pVideo->bus, pVideo->device, pVideo->func);
- xf86MsgVerb(X_INFO, 3,
- ATI_NAME ": %s with sparse PIO base 0x%04lX"
- " detected.\n", Identifier,
- Mach64SparseIOBases[j]);
- AddAdapter(pATI);
- pATI->SharedAccelerator = TRUE;
- pATI->PCIInfo = pVideo;
-
- if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
- ATIFindVGA(pVideo, &pVGA, &pATI, p8514,
- ProbeFlags);
- }
-
- xf86SetPciVideo(NULL, NONE);
- break;
- }
- }
-
-#else /* AVOID_CPIO */
-
- for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
- {
- if ((pVideo->vendor != PCI_VENDOR_ATI) ||
- (pVideo->chipType == PCI_CHIP_MACH32) ||
- pVideo->size[1])
- continue;
-
- /* Check if this one has already been detected */
- for (j = 0; j < nATIPtr; j++)
- {
- pATI = ATIPtrs[j];
- if (pATI->PCIInfo == pVideo)
- goto SkipThisSlot;
- }
-
- if (!xf86CheckPciSlot(pVideo->bus,
- pVideo->device,
- pVideo->func))
- continue;
-
- xf86SetPciVideo(pVideo, MEM_IO);
+ xf86MsgVerb(X_INFO, 3,
+ ATI_NAME ": %s with sparse PIO base 0x%04lX"
+ " detected.\n", Identifier,
+ Mach64SparseIOBases[j]);
+ AddAdapter(pATI);
+ pATI->SharedAccelerator = TRUE;
+ pATI->PCIInfo = pVideo;
- Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
+ if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
+ ATIFindVGA(pVideo, &pVGA, &pATI, NULL, ProbeFlags);
+ }
- /* The adapter's CPIO base is of little concern here */
- pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip);
- if (pATI)
- {
- sprintf(Identifier, "Shared PCI Mach64 in slot %d:%d:%d",
- pVideo->bus, pVideo->device, pVideo->func);
- xf86MsgVerb(X_INFO, 3,
- ATI_NAME ": %s with Block 0 base 0x%08lX detected.\n",
- Identifier, pATI->Block0Base);
- AddAdapter(pATI);
- pATI->SharedAccelerator = TRUE;
- pATI->PCIInfo = pVideo;
- }
- else
- {
- xf86Msg(X_WARNING,
- ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be"
- " detected!\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ xf86SetPciVideo(NULL, NONE);
+ break;
}
-
- xf86SetPciVideo(NULL, NONE);
-
- SkipThisSlot:;
- }
-
-#endif /* AVOID_CPIO */
-
}
- /* Lastly, look for block I/O devices */
- for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
- {
+#else /* AVOID_CPIO */
+
+ for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) {
if ((pVideo->vendor != PCI_VENDOR_ATI) ||
(pVideo->chipType == PCI_CHIP_MACH32) ||
- !pVideo->size[1])
- continue;
-
- /* Check for Rage128's, Radeon's and later adapters */
- Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
- if (Chip > ATI_CHIP_Mach64)
- continue;
-
- if (!nATIGDev)
+ pVideo->size[1])
continue;
/* Check if this one has already been detected */
- for (j = 0; j < nATIPtr; j++)
- {
+ for (j = 0; j < nATIPtr; j++) {
pATI = ATIPtrs[j];
- if (pATI->CPIOBase == pVideo->ioBase[1])
- goto SetPCIInfo;
+ if (pATI->PCIInfo == pVideo)
+ goto SkipThisSlot;
}
if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func))
continue;
- /* Probe for it */
xf86SetPciVideo(pVideo, MEM_IO);
- pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip);
- if (pATI)
- {
- sprintf(Identifier, "Shared PCI/AGP Mach64 in slot %d:%d:%d",
- pVideo->bus, pVideo->device, pVideo->func);
- xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n",
- Identifier);
+ Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
+
+ /* The adapter's CPIO base is of little concern here */
+ pATI = ATIMach64Probe(pVideo, 0, SPARSE_IO, Chip);
+ if (pATI) {
+ sprintf(Identifier, "Shared PCI Mach64 in slot %d:%d:%d",
+ pVideo->bus, pVideo->device, pVideo->func);
+ xf86MsgVerb(X_INFO, 3,
+ ATI_NAME ": %s with Block 0 base 0x%08lX detected.\n",
+ Identifier, pATI->Block0Base);
AddAdapter(pATI);
pATI->SharedAccelerator = TRUE;
-
-#ifndef AVOID_CPIO
-
- if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
- ATIFindVGA(pVideo, &pVGA, &pATI, p8514, ProbeFlags);
-
-#endif /* AVOID_CPIO */
-
+ pATI->PCIInfo = pVideo;
+ } else {
+ xf86Msg(X_WARNING,
+ ATI_NAME ": PCI Mach64 in slot %d:%d:%d could not be"
+ " detected!\n",
+ pVideo->bus, pVideo->device, pVideo->func);
}
xf86SetPciVideo(NULL, NONE);
- if (!pATI)
- {
- xf86Msg(X_WARNING,
- ATI_NAME ": PCI/AGP Mach64 in slot %d:%d:%d could not be"
- " detected!\n", pVideo->bus, pVideo->device, pVideo->func);
- continue;
- }
-
- SetPCIInfo:
- pATI->PCIInfo = pVideo;
+ SkipThisSlot:;
}
- }
-
-#ifndef AVOID_CPIO
- /*
- * At this point, if there's a non-shareable VGA with its own framebuffer,
- * find out if it's an ATI VGA Wonder.
- */
- do
- {
- if (!nATIGDev || !pVGA || (pVGA->VGAAdapter > ATI_ADAPTER_VGA))
- break;
+#endif /* AVOID_CPIO */
- /* If it has not been assigned to a coprocessor, keep track of it */
- if (pVGA->Coprocessor == ATI_CHIP_NONE)
- AddAdapter(pVGA);
+ }
- /*
- * A VGA should have installed its int 10 vector. Use that to find the
- * VGA BIOS. If this fails, scan all legacy BIOS segments, in 512-byte
- * increments.
- */
- if (xf86ReadBIOS(0U, 0x42U, BIOS, 2) != 2)
- goto NoVGAWonder;
+ /* Lastly, look for block I/O devices */
+ for (i = 0; (pVideo = xf86PciVideoInfo[i++]); ) {
+ if ((pVideo->vendor != PCI_VENDOR_ATI) ||
+ (pVideo->chipType == PCI_CHIP_MACH32) ||
+ !pVideo->size[1])
+ continue;
- pATI = NULL;
- BIOSBase = 0;
- if (!(BIOS[0] & 0x1FU)) /* Otherwise there's no 512-byte alignment */
- BIOSBase = ((BIOS[1] << 8) | BIOS[0]) << 4;
+ /* Check for Rage128's, Radeon's and later adapters */
+ Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
+ if (Chip > ATI_CHIP_Mach64)
+ continue;
- /* Look for its BIOS */
- for(; ; BIOSBase += 0x00000200U)
- {
- if (!BIOSBase)
- goto SkipBiosSegment;
-
- if (BIOSBase >= 0x000F8000U)
- goto NoVGAWonder;
-
- /* Skip over those that are already known */
- for (i = 0; i < nATIPtr; i++)
- if (ATIPtrs[i]->BIOSBase == BIOSBase)
- goto SkipBiosSegment;
-
- /* Get first 80 bytes of video BIOS */
- if (xf86ReadBIOS(BIOSBase, 0, BIOS, SizeOf(BIOS)) !=
- SizeOf(BIOS))
- goto NoVGAWonder;
-
- if ((BIOS[0x00U] != 0x55U) || (BIOS[0x01U] != 0xAAU))
- goto SkipBiosSegment;
-
- if ((BIOS[0x1EU] == 'I') &&
- (BIOS[0x1FU] == 'B') &&
- (BIOS[0x20U] == 'M'))
- break;
-
- /* XXX Should PCI BIOS signature be checked for here ? */
- if ((BIOS[0x20U] == 'P') &&
- (BIOS[0x21U] == 'C') &&
- (BIOS[0x22U] == 'I'))
- break;
-
- SkipBiosSegment:
- if (pATI)
- continue;
+ if (!nATIGDev)
+ continue;
- pATI = pVGA;
- BIOSBase = 0x000C0000U - 0x00000200U;
+ /* Check if this one has already been detected */
+ for (j = 0; j < nATIPtr; j++) {
+ pATI = ATIPtrs[j];
+ if (pATI->CPIOBase == pVideo->ioBase[1])
+ goto SetPCIInfo;
}
- pVGA->BIOSBase = BIOSBase;
-
- /* Look for the ATI signature string */
- if (memcmp(BIOS + BIOSSignature, ATISignature, SignatureSize))
- break;
-
- if (BIOS[0x40U] != '3')
- break;
-
- switch (BIOS[0x41U])
- {
- case '1':
- /* This is a Mach8 or VGA Wonder adapter of some kind */
- if ((BIOS[0x43U] >= '1') && (BIOS[0x43U] <= '6'))
- pVGA->Chip = BIOS[0x43U] - ('1' - ATI_CHIP_18800);
+ if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func))
+ continue;
- switch (BIOS[0x43U])
- {
- case '1': /* ATI_CHIP_18800 */
- pVGA->VGAOffset = 0xB0U;
- pVGA->VGAAdapter = ATI_ADAPTER_V3;
- break;
+ /* Probe for it */
+ xf86SetPciVideo(pVideo, MEM_IO);
- case '2': /* ATI_CHIP_18800_1 */
- pVGA->VGAOffset = 0xB0U;
- if (BIOS[0x42U] & 0x10U)
- pVGA->VGAAdapter = ATI_ADAPTER_V5;
- else
- pVGA->VGAAdapter = ATI_ADAPTER_V4;
- break;
+ pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip);
+ if (pATI) {
+ sprintf(Identifier, "Shared PCI/AGP Mach64 in slot %d:%d:%d",
+ pVideo->bus, pVideo->device, pVideo->func);
+ xf86MsgVerb(X_INFO, 3, ATI_NAME ": %s detected.\n",
+ Identifier);
+ AddAdapter(pATI);
+ pATI->SharedAccelerator = TRUE;
- case '3': /* ATI_CHIP_28800_2 */
- case '4': /* ATI_CHIP_28800_4 */
- case '5': /* ATI_CHIP_28800_5 */
- case '6': /* ATI_CHIP_28800_6 */
- pVGA->VGAOffset = 0xA0U;
- if (BIOS[0x44U] & 0x80U)
- pVGA->VGAAdapter = ATI_ADAPTER_XL;
- else
- pVGA->VGAAdapter = ATI_ADAPTER_PLUS;
- break;
+#ifndef AVOID_CPIO
- case 'a': /* A crippled Mach32 */
- case 'b':
- case 'c':
- pVGA->VGAOffset = 0x80U;
- pVGA->VGAAdapter = ATI_ADAPTER_NONISA;
- ATIMach32ChipID(pVGA);
- ProbeWaitIdleEmpty();
- if (inw(SUBSYS_STAT) != (CARD16)(-1))
- pVGA->ChipHasSUBSYS_CNTL = TRUE;
- break;
-#if 0
- case ' ': /* A crippled Mach64 */
- pVGA->VGAOffset = 0x80U;
- pVGA->VGAAdapter = ATI_ADAPTER_NONISA;
- ATIMach64ChipID(pVGA, 0);
- break;
-#endif
- default:
- break;
- }
+ if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
+ ATIFindVGA(pVideo, &pVGA, &pATI, NULL, ProbeFlags);
- if (pVGA->VGAAdapter == ATI_ADAPTER_NONE)
- break;
+#endif /* AVOID_CPIO */
- /* Set VGA Wonder I/O port */
- pVGA->CPIO_VGAWonder = BIOSWord(0x10U) & SPARSE_IO_PORT;
- if (!pVGA->CPIO_VGAWonder)
- pVGA->CPIO_VGAWonder = 0x01CEU;
-
- ATIVGAWonderProbe(NULL, pVGA, p8514, ProbeFlags);
- break;
-#if 0
- case '2':
- pVGA->VGAOffset = 0xB0U; /* Presumably */
- pVGA->VGAAdapter = ATI_ADAPTER_EGA_PLUS;
- break;
-
- case '3':
- pVGA->VGAOffset = 0xB0U; /* Presumably */
- pVGA->VGAAdapter = ATI_ADAPTER_BASIC;
- break;
-
- case '?': /* A crippled Mach64 */
- pVGA->VGAAdapter = ATI_ADAPTER_NONISA;
- ATIMach64ChipID(pVGA, 0);
- break;
-#endif
- default:
- break;
}
- if (pVGA->Adapter <= ATI_ADAPTER_VGA)
- pVGA->Adapter = pVGA->VGAAdapter;
+ xf86SetPciVideo(NULL, NONE);
-NoVGAWonder:;
- } while (0);
+ if (!pATI) {
+ xf86Msg(X_WARNING,
+ ATI_NAME ": PCI/AGP Mach64 in slot %d:%d:%d could not be"
+ " detected!\n", pVideo->bus, pVideo->device, pVideo->func);
+ continue;
+ }
-#endif /* AVOID_CPIO */
+ SetPCIInfo:
+ pATI->PCIInfo = pVideo;
+ }
/*
* Re-order list of detected devices so that the primary device is before
* any other PCI device.
*/
- for (i = 0; i < nATIPtr; i++)
- {
+ for (i = 0; i < nATIPtr; i++) {
if (!ATIPtrs[i]->PCIInfo)
continue;
- for (j = i; j < nATIPtr; j++)
- {
+ for (j = i; j < nATIPtr; j++) {
pATI = ATIPtrs[j];
if (!xf86IsPrimaryPci(pATI->PCIInfo))
continue;
@@ -1635,7 +1020,7 @@ NoVGAWonder:;
ATIPtrs[j] = pATI;
break;
}
-
+
break;
}
@@ -1825,22 +1210,11 @@ NoVGAWonder:;
* Compare BusID's. This specification is only allowed for PCI
* Mach32's or Mach64's and is optional.
*/
- if (pGDev->busID && pGDev->busID[0])
- {
- pVideo = pATI->PCIInfo;
-
-#ifndef AVOID_CPIO
-
- if (!pVideo)
+ if (pVideo && pGDev->busID && pGDev->busID[0])
+ if (!xf86ComparePciBusString(pGDev->busID, pVideo->bus,
+ pVideo->device, pVideo->func))
continue;
-#endif /* AVOID_CPIO */
-
- if (!xf86ComparePciBusString(pGDev->busID,
- pVideo->bus, pVideo->device, pVideo->func))
- continue;
- }
-
/*
* Ensure no two adapters are assigned to the same XF86Config
* Device section.
@@ -1909,14 +1283,21 @@ NoVGAWonder:;
* Attach adapter to XF86Config Device section and register its
* resources.
*/
- if (ATIClaimBusSlot(pDriver, pATIGDev->Chipset,
- pGDev, pGDev->active, pATI) < 0)
- {
+ pVideo = pATI->PCIInfo;
+
+ if (pVideo)
+ pATI->iEntity = xf86ClaimPciSlot(pVideo->bus, pVideo->device,
+ pVideo->func, pDriver,
+ pATIGDev->Chipset, pGDev,
+ pGDev->active);
+
+ if (!pVideo || (pATI->iEntity < 0)) {
xf86Msg(X_ERROR,
- ATI_NAME ": Could not claim bus slot for %s.\n",
- Identifier);
+ ATI_NAME ": Could not claim bus slot for %s.\n",
+ Identifier);
continue;
- }
+ } else
+ ATIClaimResources(pATI, pGDev->active);
if (!pGDev->active)
continue;
@@ -1950,25 +1331,7 @@ NoVGAWonder:;
ProbeSuccess = TRUE;
}
- /* Deal with unassigned adapters */
- for (i = 0; i < nATIPtr; i++)
- {
- if (!(pATI = ATIPtrs[i]))
- continue;
-
-#ifndef AVOID_CPIO
-
- if (pATI->Adapter > ATI_ADAPTER_VGA)
-
-#endif /* AVOID_CPIO */
-
- {
- if (pATI->iEntity < 0)
- (void)ATIClaimBusSlot(pDriver, 0, NULL, FALSE, pATI);
- }
-
- xfree(pATI);
- }
+ /* ignore unassigned adapters */
xfree(ATIGDevs);
}