Added PCI2Host bus translations for linux PPC and fixed fixed bugs in

macros that apply these functions (Bill Randle Bugzilla #325 and #327).
This commit is contained in:
Egbert Eich 2005-02-09 11:12:54 +00:00
parent aab9a8dd99
commit e7369daba5
2 changed files with 56 additions and 3 deletions

View File

@ -105,11 +105,11 @@ static PciBusPtr xf86PciBus = NULL;
#define PCI_MEM32_LENGTH_MAX 0xFFFFFFFF
#define B2M(tag,base) pciBusAddrToHostAddr(tag,PCI_MEM,base)
#define B2I(tag,base) (base)
#define B2I(tag,base) pciBusAddrToHostAddr(tag,PCI_IO,base)
#define B2H(tag,base,type) (((type & ResPhysMask) == ResMem) ? \
B2M(tag, base) : B2I(tag, base))
#define M2B(tag,base) pciHostAddrToBusAddr(tag,PCI_IO,base)
#define I2B(tag,base) (base)
#define M2B(tag,base) pciHostAddrToBusAddr(tag,PCI_MEM,base)
#define I2B(tag,base) pciHostAddrToBusAddr(tag,PCI_IO,base)
#define H2B(tag,base,type) (((type & ResPhysMask) == ResMem) ? \
M2B(tag, base) : I2B(tag, base))
#define TAG(pvp) (pciTag(pvp->bus,pvp->device,pvp->func))

View File

@ -59,13 +59,22 @@
static CARD32 linuxPciCfgRead(PCITAG tag, int off);
static void linuxPciCfgWrite(PCITAG, int off, CARD32 val);
static void linuxPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
#if defined(__powerpc__)
static ADDRESS linuxPpcBusAddrToHostAddr(PCITAG, PciAddrType, ADDRESS);
static ADDRESS linuxPpcHostAddrToBusAddr(PCITAG, PciAddrType, ADDRESS);
#endif
static pciBusFuncs_t linuxFuncs0 = {
/* pciReadLong */ linuxPciCfgRead,
/* pciWriteLong */ linuxPciCfgWrite,
/* pciSetBitsLong */ linuxPciCfgSetBits,
#if defined(__powerpc__)
/* pciAddrHostToBus */ linuxPpcHostAddrToBusAddr,
/* pciAddrBusToHost */ linuxPpcBusAddrToHostAddr
#else
/* pciAddrHostToBus */ pciAddrNOOP,
/* pciAddrBusToHost */ pciAddrNOOP
#endif
};
static pciBusInfo_t linuxPci0 = {
@ -192,6 +201,50 @@ linuxPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
}
}
#if defined(__powerpc__)
#ifndef __NR_pciconfig_iobase
#define __NR_pciconfig_iobase 200
#endif
static ADDRESS
linuxPpcBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
{
if (type == PCI_MEM)
{
ADDRESS membase = syscall(__NR_pciconfig_iobase, 1,
PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
return (addr + membase);
}
else if (type == PCI_IO)
{
ADDRESS iobase = syscall(__NR_pciconfig_iobase, 2,
PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
return (addr + iobase);
}
else return addr;
}
static ADDRESS
linuxPpcHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr)
{
if (type == PCI_MEM)
{
ADDRESS membase = syscall(__NR_pciconfig_iobase, 1,
PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
return (addr - membase);
}
else if (type == PCI_IO)
{
ADDRESS iobase = syscall(__NR_pciconfig_iobase, 2,
PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag));
return (addr - iobase);
}
else return addr;
}
#endif /* __powerpc__ */
#ifndef INCLUDE_XF86_NO_DOMAIN
/*