diff options
author | marius <marius@FreeBSD.org> | 2007-09-30 19:01:41 +0800 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2007-09-30 19:01:41 +0800 |
commit | 02f975dc2069deca029bd48fba8910d6f36c5549 (patch) | |
tree | 4bb9605a5c8f68fabc210f87618ff01c5b55361d /x11-servers | |
parent | 877ea43c01e1c760a60b9f4690a63f91375773ad (diff) | |
download | freebsd-ports-gnome-02f975dc2069deca029bd48fba8910d6f36c5549.tar.gz freebsd-ports-gnome-02f975dc2069deca029bd48fba8910d6f36c5549.tar.zst freebsd-ports-gnome-02f975dc2069deca029bd48fba8910d6f36c5549.zip |
Teach xorg-server that FreeBSD >= 700053 supports PCI domains and
how to deal with it. This affects !386 only and is based on the
respective Linux support code.
Approved by: flz
Diffstat (limited to 'x11-servers')
-rw-r--r-- | x11-servers/xorg-server/Makefile | 1 | ||||
-rw-r--r-- | x11-servers/xorg-server/files/patch-Pci.h | 88 | ||||
-rw-r--r-- | x11-servers/xorg-server/files/patch-freebsdPci.c | 306 |
3 files changed, 395 insertions, 0 deletions
diff --git a/x11-servers/xorg-server/Makefile b/x11-servers/xorg-server/Makefile index e29687b9dbd3..aada4cf66bbc 100644 --- a/x11-servers/xorg-server/Makefile +++ b/x11-servers/xorg-server/Makefile @@ -7,6 +7,7 @@ PORTNAME= xorg-server PORTVERSION= 1.4 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= x11-servers MASTER_SITES= http://xorg.freedesktop.org/releases/individual/xserver/:fdo \ diff --git a/x11-servers/xorg-server/files/patch-Pci.h b/x11-servers/xorg-server/files/patch-Pci.h new file mode 100644 index 000000000000..0d6991b41700 --- /dev/null +++ b/x11-servers/xorg-server/files/patch-Pci.h @@ -0,0 +1,88 @@ +--- hw/xfree86/os-support/bus/Pci.h.orig 2007-09-06 02:48:26.000000000 +0200 ++++ hw/xfree86/os-support/bus/Pci.h 2007-09-28 21:43:06.000000000 +0200 +@@ -112,6 +112,10 @@ + #include "xf86Pci.h" + #include "xf86PciInfo.h" + ++#if defined(__FreeBSD__) ++#include <osreldate.h> ++#endif ++ + /* + * Global Definitions + */ +@@ -123,6 +127,10 @@ + # define MAX_PCI_DOMAINS 512 + # define PCI_DOM_MASK 0x01fful + # define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */ ++#elif defined(FreeBSD) && __FreeBSD_version >= 700053 && !defined(__i386__) ++# define MAX_PCI_DOMAINS 256 /* limited by 32-bit xf86 PCITAG */ ++# define PCI_DOM_MASK (MAX_PCI_DOMAINS - 1) ++# define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */ + #else + # define MAX_PCI_BUSES 256 /* Max number of PCI buses */ + #endif +@@ -238,7 +246,9 @@ + # elif defined(__FreeBSD__) || defined(__OpenBSD__) + # define ARCH_PCI_INIT freebsdPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +-# define INCLUDE_XF86_NO_DOMAIN ++# if __FreeBSD_version < 700053 || defined(__OpenBSD__) ++# define INCLUDE_XF86_NO_DOMAIN ++# endif + # elif defined(__NetBSD__) + # define ARCH_PCI_INIT netbsdPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +@@ -260,10 +270,12 @@ + # if defined(linux) + # define ARCH_PCI_INIT ia64linuxPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +-# elif defined(FreeBSD) ++# elif defined(FreeBSD) || defined(__OpenBSD__) + # define ARCH_PCI_INIT freebsdPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +-# define INCLUDE_XF86_NO_DOMAIN ++# if __FreeBSD_version < 700053 || defined(__OpenBSD__) ++# define INCLUDE_XF86_NO_DOMAIN ++# endif + # endif + # define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper + #elif defined(__i386__) || defined(i386) +@@ -293,7 +305,9 @@ + # elif defined(__FreeBSD__) || defined(__OpenBSD__) + # define ARCH_PCI_INIT freebsdPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +-# define INCLUDE_XF86_NO_DOMAIN ++# if __FreeBSD_version < 700053 || defined(__OpenBSD__) ++# define INCLUDE_XF86_NO_DOMAIN ++# endif + # elif defined(__NetBSD__) + # define ARCH_PCI_INIT netbsdPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +@@ -325,7 +339,9 @@ + # elif (defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc64__) + # define ARCH_PCI_INIT freebsdPciInit + # define INCLUDE_XF86_MAP_PCI_MEM +-# define INCLUDE_XF86_NO_DOMAIN ++# if __FreeBSD_version < 700053 || defined(__OpenBSD__) ++# define INCLUDE_XF86_NO_DOMAIN ++# endif + # endif + # if !defined(__FreeBSD__) && !defined(linux) + # define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge +@@ -333,11 +349,14 @@ + #elif defined(__amd64__) || defined(__amd64) + # if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + # define ARCH_PCI_INIT freebsdPciInit ++# if __FreeBSD_version < 700053 || defined(__FreeBSD_kernel__) ++# define INCLUDE_XF86_NO_DOMAIN ++# endif + # else + # define ARCH_PCI_INIT ix86PciInit ++# define INCLUDE_XF86_NO_DOMAIN + # endif + # define INCLUDE_XF86_MAP_PCI_MEM +-# define INCLUDE_XF86_NO_DOMAIN + # if defined(linux) + # define ARCH_PCI_OS_INIT linuxPciInit + # endif diff --git a/x11-servers/xorg-server/files/patch-freebsdPci.c b/x11-servers/xorg-server/files/patch-freebsdPci.c new file mode 100644 index 000000000000..83b034fc9a3e --- /dev/null +++ b/x11-servers/xorg-server/files/patch-freebsdPci.c @@ -0,0 +1,306 @@ +--- hw/xfree86/os-support/bus/freebsdPci.c.orig Thu Sep 6 02:48:26 2007 ++++ hw/xfree86/os-support/bus/freebsdPci.c Sat Sep 29 12:22:56 2007 +@@ -109,10 +109,6 @@ + #define PCI_CPU(val) (val) + #endif + +- +-#define BUS(tag) (((tag)>>16)&0xff) +-#define DFN(tag) (((tag)>>8)&0xff) +- + static int pciFd = -1; + + void +@@ -133,9 +129,12 @@ + { + struct pci_io io; + int error; +- io.pi_sel.pc_bus = BUS(tag); +- io.pi_sel.pc_dev = DFN(tag) >> 3; +- io.pi_sel.pc_func = DFN(tag) & 7; ++#ifndef INCLUDE_XF86_NO_DOMAIN ++ io.pi_sel.pc_domain = PCI_DOM_FROM_TAG(tag); ++#endif ++ io.pi_sel.pc_bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)); ++ io.pi_sel.pc_dev = PCI_DEV_FROM_TAG(tag); ++ io.pi_sel.pc_func = PCI_FUNC_FROM_TAG(tag); + io.pi_reg = off; + io.pi_width = 4; + error = ioctl(pciFd, PCIOCREAD, &io); +@@ -148,9 +147,12 @@ + freebsdPciCfgWrite(PCITAG tag, int off, CARD32 val) + { + struct pci_io io; +- io.pi_sel.pc_bus = BUS(tag); +- io.pi_sel.pc_dev = DFN(tag) >> 3; +- io.pi_sel.pc_func = DFN(tag) & 7; ++#ifndef INCLUDE_XF86_NO_DOMAIN ++ io.pi_sel.pc_domain = PCI_DOM_FROM_TAG(tag); ++#endif ++ io.pi_sel.pc_bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)); ++ io.pi_sel.pc_dev = PCI_DEV_FROM_TAG(tag); ++ io.pi_sel.pc_func = PCI_FUNC_FROM_TAG(tag); + io.pi_reg = off; + io.pi_width = 4; + io.pi_data = PCI_CPU(val); +@@ -164,3 +166,260 @@ + val = (val & ~mask) | (bits & mask); + freebsdPciCfgWrite(tag, off, val); + } ++ ++#ifndef INCLUDE_XF86_NO_DOMAIN ++ ++/* This probably shouldn't be FreeBSD-specific. */ ++static pciConfigPtr ++xf86GetPciHostConfigFromTag(PCITAG Tag) ++{ ++ int bus = PCI_BUS_FROM_TAG(Tag); ++ pciBusInfo_t *pBusInfo; ++ ++ while ((bus < pciNumBuses) && (pBusInfo = pciBusInfo[bus])) { ++ if (bus == pBusInfo->primary_bus) ++ return pBusInfo->bridge; ++ bus = pBusInfo->primary_bus; ++ } ++ ++ return NULL; /* Bad data */ ++} ++ ++/* ++ * This is ugly, but until I can extract this information from the kernel, ++ * it'll have to do. The default I/O space size is 64K, and 4G for memory. ++ * Anything else needs to go in this table. (PowerPC folk take note.) ++ * ++ * Please keep this table in ascending vendor/device order. ++ */ ++static const struct pciSizes { ++ unsigned short vendor, device; ++ unsigned long io_size, mem_size; ++} pciControllerSizes[] = { ++ { ++ PCI_VENDOR_SUN, PCI_CHIP_PSYCHO, ++ 1U << 16, 1U << 31 ++ }, ++ { ++ PCI_VENDOR_SUN, PCI_CHIP_SCHIZO, ++ 1U << 24, 1U << 31 /* ??? */ ++ }, ++ { ++ PCI_VENDOR_SUN, PCI_CHIP_SABRE, ++ 1U << 24, (unsigned long)(1ULL << 32) ++ }, ++ { ++ PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD, ++ 1U << 24, (unsigned long)(1ULL << 32) ++ } ++}; ++#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0])) ++ ++static const struct pciSizes * ++freebsdGetSizesStruct(PCITAG Tag) ++{ ++ static const struct pciSizes default_size = { ++ 0, 0, 1U << 16, (unsigned long)(1ULL << 32) ++ }; ++ pciConfigPtr pPCI; ++ int i; ++ ++ /* Find host bridge */ ++ if ((pPCI = xf86GetPciHostConfigFromTag(Tag))) { ++ /* Look up vendor/device */ ++ for (i = 0; i < NUM_SIZES; i++) { ++ if ((pPCI->pci_vendor == ++ pciControllerSizes[i].vendor) && ++ (pPCI->pci_device == ++ pciControllerSizes[i].device)) { ++ return & pciControllerSizes[i]; ++ } ++ } ++ } ++ ++ /* Default to 64KB I/O and 4GB memory. */ ++ return & default_size; ++} ++ ++static __inline__ unsigned long ++freebsdGetIOSize(PCITAG Tag) ++{ ++ const struct pciSizes * const sizes = freebsdGetSizesStruct(Tag); ++ return sizes->io_size; ++} ++ ++static __inline__ void ++freebsdGetSizes(PCITAG Tag, unsigned long *io_size, unsigned long *mem_size) ++{ ++ const struct pciSizes * const sizes = freebsdGetSizesStruct(Tag); ++ ++ *io_size = sizes->io_size; ++ *mem_size = sizes->mem_size; ++} ++ ++_X_EXPORT int ++xf86GetPciDomain(PCITAG Tag) ++{ ++ return PCI_DOM_FROM_TAG(Tag); ++} ++ ++_X_EXPORT pointer ++xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, ADDRESS Base, ++ unsigned long Size) ++{ ++ return xf86MapVidMem(ScreenNum, Flags, Base, Size); ++} ++ ++_X_EXPORT IOADDRESS ++xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag, IOADDRESS Base, ++ unsigned long Size) ++{ ++ return Base; ++} ++ ++_X_EXPORT int ++xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len, unsigned char *Buf) ++{ ++ int ret, length, rlength; ++ ++ /* Read in 64kB chunks. */ ++ ret = 0; ++ while ((length = Len) > 0) { ++ if (length > 0x010000) length = 0x010000; ++ rlength = xf86ReadBIOS(Base, 0, Buf, length); ++ if (rlength < 0) { ++ ret = rlength; ++ break; ++ } ++ ret += rlength; ++ if (rlength < length) break; ++ Base += rlength; ++ Buf += rlength; ++ Len -= rlength; ++ } ++ ++ return ret; ++} ++ ++resPtr ++xf86BusAccWindowsFromOS(void) ++{ ++ pciConfigPtr *ppPCI, pPCI; ++ resPtr pRes = NULL; ++ resRange range; ++ unsigned long io_size, mem_size; ++ int domain; ++ ++ if ((ppPCI = xf86scanpci(0))) { ++ for (; (pPCI = *ppPCI); ppPCI++) { ++ if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) || ++ (pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST)) ++ continue; ++ ++ domain = xf86GetPciDomain(pPCI->tag); ++ freebsdGetSizes(pPCI->tag, &io_size, &mem_size); ++ ++ RANGE(range, 0, (ADDRESS)(mem_size - 1), ++ RANGE_TYPE(ResExcMemBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ RANGE(range, 0, (IOADDRESS)(io_size - 1), ++ RANGE_TYPE(ResExcIoBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ if (domain <= 0) ++ break; ++ } ++ } ++ ++ return pRes; ++} ++ ++resPtr ++xf86PciBusAccWindowsFromOS(void) ++{ ++ pciConfigPtr *ppPCI, pPCI; ++ resPtr pRes = NULL; ++ resRange range; ++ unsigned long io_size, mem_size; ++ int domain; ++ ++ if ((ppPCI = xf86scanpci(0))) { ++ for (; (pPCI = *ppPCI); ppPCI++) { ++ if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) || ++ (pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST)) ++ continue; ++ ++ domain = xf86GetPciDomain(pPCI->tag); ++ freebsdGetSizes(pPCI->tag, &io_size, &mem_size); ++ ++ RANGE(range, 0, (ADDRESS)(mem_size - 1), ++ RANGE_TYPE(ResExcMemBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ RANGE(range, 0, (IOADDRESS)(io_size - 1), ++ RANGE_TYPE(ResExcIoBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ if (domain <= 0) ++ break; ++ } ++ } ++ ++ return pRes; ++} ++ ++resPtr ++xf86AccResFromOS(resPtr pRes) ++{ ++ pciConfigPtr *ppPCI, pPCI; ++ resRange range; ++ unsigned long io_size, mem_size; ++ int domain; ++ ++ if ((ppPCI = xf86scanpci(0))) { ++ for (; (pPCI = *ppPCI); ppPCI++) { ++ if ((pPCI->pci_base_class != PCI_CLASS_BRIDGE) || ++ (pPCI->pci_sub_class != PCI_SUBCLASS_BRIDGE_HOST)) ++ continue; ++ ++ domain = xf86GetPciDomain(pPCI->tag); ++ freebsdGetSizes(pPCI->tag, &io_size, &mem_size); ++ ++ /* ++ * At minimum, the top and bottom resources must be ++ * claimed, so that resources that are (or appear to ++ * be) unallocated can be relocated. ++ */ ++ RANGE(range, 0x00000000u, 0x0009ffffu, ++ RANGE_TYPE(ResExcMemBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ RANGE(range, 0x000c0000u, 0x000effffu, ++ RANGE_TYPE(ResExcMemBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ RANGE(range, 0x000f0000u, 0x000fffffu, ++ RANGE_TYPE(ResExcMemBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ RANGE(range, (ADDRESS)(mem_size - 1), ++ (ADDRESS)(mem_size - 1), ++ RANGE_TYPE(ResExcMemBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ RANGE(range, 0x00000000u, 0x00000000u, ++ RANGE_TYPE(ResExcIoBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ RANGE(range, (IOADDRESS)(io_size - 1), ++ (IOADDRESS)(io_size - 1), ++ RANGE_TYPE(ResExcIoBlock, domain)); ++ pRes = xf86AddResToList(pRes, &range, -1); ++ ++ if (domain <= 0) ++ break; ++ } ++ } ++ ++ return pRes; ++} ++ ++#endif /* !INCLUDE_XF86_NO_DOMAIN */ |