Convert int10 and vgaHW to use 'struct pci_device' instead of PCITAG.

Convert all uses of PCITAG in int10 and vgaHW to 'struct pci_device'.
This allows the conversion of xf86ReadLegacyVideoBIOS and
xf86MapDomainMemory to 'struct pci_device' from PCITAG.
This commit is contained in:
Ian Romanick 2007-01-11 21:09:20 -08:00
parent da09964a93
commit ca9c41e09d
9 changed files with 21 additions and 46 deletions

View File

@ -69,7 +69,6 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
void* base = 0; void* base = 0;
void* vbiosMem = 0; void* vbiosMem = 0;
void* options = NULL; void* options = NULL;
struct pci_device * pvp;
int screen; int screen;
legacyVGARec vga; legacyVGARec vga;
xf86int10BiosLocation bios; xf86int10BiosLocation bios;
@ -98,14 +97,10 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
pInt->scrnIndex = screen; pInt->scrnIndex = screen;
base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS); base = INTPriv(pInt)->base = xnfalloc(SYS_BIOS);
/* FIXME: Shouldn't this be a failure case? Leaving Tag as 0 seems like /* FIXME: Shouldn't this be a failure case? Leaving dev as NULL seems like
* FIXME: an error * FIXME: an error
*/ */
pvp = xf86GetPciInfoForEntity(entityIndex); pInt->dev = xf86GetPciInfoForEntity(entityIndex);
if (pvp != NULL) {
pInt->Tag = PCI_MAKE_TAG(PCI_MAKE_BUS(pvp->domain, pvp->bus),
pvp->dev, pvp->func);
}
/* /*
* we need to map video RAM MMIO as some chipsets map mmio * we need to map video RAM MMIO as some chipsets map mmio
@ -221,7 +216,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
*/ */
vbiosMem = (char *)base + V_BIOS; vbiosMem = (char *)base + V_BIOS;
(void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE); (void)memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
if (xf86ReadLegacyVideoBIOS(pInt->Tag, vbiosMem) < V_BIOS_SIZE) { if (xf86ReadLegacyVideoBIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
xf86DrvMsg(screen, X_WARNING, xf86DrvMsg(screen, X_WARNING,
"Unable to retrieve all of segment 0x0C0000.\n"); "Unable to retrieve all of segment 0x0C0000.\n");
} }
@ -299,7 +294,7 @@ MapVRam(xf86Int10InfoPtr pInt)
int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize; int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO, INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO,
pInt->Tag, V_RAM, size); pInt->dev, V_RAM, size);
pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase; pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase;
} }

View File

@ -471,12 +471,6 @@ Mem_wl(CARD32 addr, CARD32 val)
static CARD32 PciCfg1Addr = 0; static CARD32 PciCfg1Addr = 0;
#define OFFSET(Cfg1Addr) (Cfg1Addr & 0xff) #define OFFSET(Cfg1Addr) (Cfg1Addr & 0xff)
#define _DOM(x) PCI_DOM_FROM_TAG(x)
#define _BUS(x) PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(x))
#define _DEV(x) PCI_DEV_FROM_TAG(x)
#define _FUNC(x) PCI_FUNC_FROM_TAG(x)
#define GET_DEVICE(_tag) \
pci_device_find_by_slot(_DOM(_tag), _BUS(_tag), _DEV(_tag), _FUNC(_tag))
static int static int
pciCfg1in(CARD16 addr, CARD32 *val) pciCfg1in(CARD16 addr, CARD32 *val)
@ -486,9 +480,7 @@ pciCfg1in(CARD16 addr, CARD32 *val)
return 1; return 1;
} }
if (addr == 0xCFC) { if (addr == 0xCFC) {
struct pci_device *dev = GET_DEVICE(Int10Current->Tag); pci_device_cfg_read_u32(Int10Current->dev, val, OFFSET(PciCfg1Addr));
pci_device_cfg_read_u32(dev, val, OFFSET(PciCfg1Addr));
return 1; return 1;
} }
return 0; return 0;
@ -502,9 +494,7 @@ pciCfg1out(CARD16 addr, CARD32 val)
return 1; return 1;
} }
if (addr == 0xCFC) { if (addr == 0xCFC) {
struct pci_device *dev = GET_DEVICE(Int10Current->Tag); pci_device_cfg_write_u32(Int10Current->dev, & val, OFFSET(PciCfg1Addr));
pci_device_cfg_write_u32(dev, & val, OFFSET(PciCfg1Addr));
return 1; return 1;
} }
return 0; return 0;
@ -522,9 +512,8 @@ pciCfg1inw(CARD16 addr, CARD16 *val)
} }
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
const unsigned offset = addr - 0xCFC; const unsigned offset = addr - 0xCFC;
struct pci_device *dev = GET_DEVICE(Int10Current->Tag);
pci_device_cfg_read_u16(dev, val, OFFSET(PciCfg1Addr) + offset); pci_device_cfg_read_u16(Int10Current->dev, val, OFFSET(PciCfg1Addr) + offset);
return 1; return 1;
} }
return 0; return 0;
@ -543,9 +532,8 @@ pciCfg1outw(CARD16 addr, CARD16 val)
} }
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
const unsigned offset = addr - 0xCFC; const unsigned offset = addr - 0xCFC;
struct pci_device *dev = GET_DEVICE(Int10Current->Tag);
pci_device_cfg_write_u16(dev, & val, OFFSET(PciCfg1Addr) + offset); pci_device_cfg_write_u16(Int10Current->dev, & val, OFFSET(PciCfg1Addr) + offset);
return 1; return 1;
} }
return 0; return 0;
@ -563,9 +551,8 @@ pciCfg1inb(CARD16 addr, CARD8 *val)
} }
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
const unsigned offset = addr - 0xCFC; const unsigned offset = addr - 0xCFC;
struct pci_device *dev = GET_DEVICE(Int10Current->Tag);
pci_device_cfg_read_u8(dev, val, OFFSET(PciCfg1Addr) + offset); pci_device_cfg_read_u8(Int10Current->dev, val, OFFSET(PciCfg1Addr) + offset);
return 1; return 1;
} }
return 0; return 0;
@ -584,9 +571,8 @@ pciCfg1outb(CARD16 addr, CARD8 val)
} }
if ((addr >= 0xCFC) && (addr <= 0xCFF)) { if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
const unsigned offset = addr - 0xCFC; const unsigned offset = addr - 0xCFC;
struct pci_device *dev = GET_DEVICE(Int10Current->Tag);
pci_device_cfg_write_u8(dev, & val, OFFSET(PciCfg1Addr) + offset); pci_device_cfg_write_u8(Int10Current->dev, & val, OFFSET(PciCfg1Addr) + offset);
return 1; return 1;
} }
return 0; return 0;

View File

@ -819,12 +819,11 @@ int1A_handler(xf86Int10InfoPtr pInt)
static struct pci_device * static struct pci_device *
findPci(xf86Int10InfoPtr pInt, unsigned short bx) findPci(xf86Int10InfoPtr pInt, unsigned short bx)
{ {
const unsigned domain = PCI_DOM_FROM_TAG( pInt->Tag );
const unsigned bus = (bx >> 8) & 0x00FF; const unsigned bus = (bx >> 8) & 0x00FF;
const unsigned dev = (bx >> 3) & 0x001F; const unsigned dev = (bx >> 3) & 0x001F;
const unsigned func = (bx ) & 0x0007; const unsigned func = (bx ) & 0x0007;
return pci_device_find_by_slot(domain, bus, dev, func); return pci_device_find_by_slot(pInt->dev->domain, bus, dev, func);
} }
static CARD32 static CARD32

View File

@ -40,7 +40,7 @@ typedef struct {
int bp; int bp;
int flags; int flags;
int stackseg; int stackseg;
PCITAG Tag; struct pci_device *dev;
IOADDRESS ioBase; IOADDRESS ioBase;
} xf86Int10InfoRec, *xf86Int10InfoPtr; } xf86Int10InfoRec, *xf86Int10InfoPtr;

View File

@ -319,7 +319,7 @@ xf86GetPciDomain(PCITAG Tag)
} }
_X_EXPORT pointer _X_EXPORT pointer
xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size) ADDRESS Base, unsigned long Size)
{ {
return xf86MapVidMem(ScreenNum, Flags, Base, Size); return xf86MapVidMem(ScreenNum, Flags, Base, Size);
@ -333,7 +333,7 @@ xf86MapLegacyIO(struct pci_device *dev)
} }
_X_EXPORT int _X_EXPORT int
xf86ReadLegacyVideoBIOS(PCITAG Tag, unsigned char *Buf) xf86ReadLegacyVideoBIOS(struct pci_device *dev, unsigned char *Buf)
{ {
const unsigned Len = (2 * 0x10000); const unsigned Len = (2 * 0x10000);
ADDRESS Base = 0xC0000; ADDRESS Base = 0xC0000;

View File

@ -513,11 +513,9 @@ linuxOpenLegacy(struct pci_device *dev, char *name)
* the legacy ISA memory space (memory in a domain between 0 and 1MB). * the legacy ISA memory space (memory in a domain between 0 and 1MB).
*/ */
_X_EXPORT pointer _X_EXPORT pointer
xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size) ADDRESS Base, unsigned long Size)
{ {
int domain = xf86GetPciDomain(Tag);
const struct pci_device *dev = xf86GetPciHostConfigFromTag(Tag);
int fd = -1; int fd = -1;
pointer addr; pointer addr;

View File

@ -260,9 +260,9 @@ extern int pciNumBuses;
/* Domain access functions. Some of these probably shouldn't be public */ /* Domain access functions. Some of these probably shouldn't be public */
int xf86GetPciDomain(PCITAG tag); int xf86GetPciDomain(PCITAG tag);
pointer xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size); ADDRESS Base, unsigned long Size);
IOADDRESS xf86MapLegacyIO(struct pci_device *dev); IOADDRESS xf86MapLegacyIO(struct pci_device *dev);
int xf86ReadLegacyVideoBIOS(PCITAG Tag, unsigned char *Buf); int xf86ReadLegacyVideoBIOS(struct pci_device *dev, unsigned char *Buf);
#endif /* _XF86PCI_H */ #endif /* _XF86PCI_H */

View File

@ -1638,7 +1638,6 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
{ {
vgaRegPtr regp; vgaRegPtr regp;
vgaHWPtr hwp; vgaHWPtr hwp;
struct pci_device * pvp;
int i; int i;
/* /*
@ -1724,9 +1723,7 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
vgaHWSetStdFuncs(hwp); vgaHWSetStdFuncs(hwp);
hwp->PIOOffset = scrp->domainIOBase; hwp->PIOOffset = scrp->domainIOBase;
if ((pvp = xf86GetPciInfoForEntity(scrp->entityList[0]))) hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]);
hwp->Tag = pciTag( PCI_MAKE_BUS( pvp->domain, pvp->bus ),
pvp->dev, pvp->func );
return TRUE; return TRUE;
} }
@ -1778,7 +1775,7 @@ vgaHWMapMem(ScrnInfoPtr scrp)
#ifdef DEBUG #ifdef DEBUG
ErrorF("Mapping VGAMem\n"); ErrorF("Mapping VGAMem\n");
#endif #endif
hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->Tag, hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev,
hwp->MapPhys, hwp->MapSize); hwp->MapPhys, hwp->MapSize);
return hwp->Base != NULL; return hwp->Base != NULL;
} }

View File

@ -156,7 +156,7 @@ typedef struct _vgaHWRec {
= pioreg */ = pioreg */
vgaHWReadProcPtr readEnable; vgaHWReadProcPtr readEnable;
vgaHWWriteProcPtr writeEnable; vgaHWWriteProcPtr writeEnable;
PCITAG Tag; struct pci_device *dev;
} vgaHWRec; } vgaHWRec;
/* Some macros that VGA drivers can use in their ChipProbe() function */ /* Some macros that VGA drivers can use in their ChipProbe() function */