diff options
Diffstat (limited to 'xorg-server/hw/xfree86/os-support')
24 files changed, 27 insertions, 3022 deletions
diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.am b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am index 7133c0f21..b01ea5bca 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am @@ -27,9 +27,7 @@ if ALPHA_VIDEO # Cheat here and piggyback other alpha bits on ALPHA_VIDEO. ARCH_SOURCES = \ alpha_video.c \ - bsd_ev56.c \ - bsd_axp.c \ - $(srcdir)/../shared/xf86Axp.c + bsd_ev56.c endif if ARM_VIDEO diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c index f656f5595..236def6ff 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c @@ -35,11 +35,6 @@ #ifndef __NetBSD__ #include <sys/sysctl.h> #endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) -#include <machine/sysarch.h> -#endif - -#include "xf86Axp.h" #include "xf86_OSlib.h" #include "xf86OSpriv.h" @@ -50,69 +45,9 @@ #define MAP_FLAGS (MAP_FILE | MAP_SHARED) #endif -axpDevice bsdGetAXP(void); - #ifndef __NetBSD__ extern unsigned long dense_base(void); - -static int axpSystem = -1; -static unsigned long hae_thresh; -static unsigned long hae_mask; - -static unsigned long -memory_base(void) -{ - static unsigned long base = 0; - - if (base == 0) { - size_t len = sizeof(base); - int error; - -#ifdef __OpenBSD__ - int mib[3]; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_MEM; - - if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0) -#else - if ((error = sysctlbyname("hw.chipset.memory", &base, &len, 0, 0)) < 0) -#endif - FatalError("xf86MapVidMem: can't find memory\n"); - } - - return base; -} - -static int -has_bwx(void) -{ - static int bwx = 0; - size_t len = sizeof(bwx); - int error; - -#ifdef __OpenBSD__ - int mib[3]; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_BWX; - - if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0) - return FALSE; - else - return bwx; -#else - if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0) - return FALSE; - else - return bwx; -#endif -} #else /* __NetBSD__ */ -static unsigned long hae_thresh = (1UL << 24); -static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */ static struct alpha_bus_window *abw; static int abw_count = -1; @@ -126,16 +61,6 @@ init_abw(void) } } -static int -has_bwx(void) -{ - if (abw_count < 0) - init_abw(); - - xf86Msg(X_INFO, "has_bwx = %d\n", abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */ - return abw[0].abw_abst.abst_flags & ABST_BWX; -} - static unsigned long dense_base(void) { @@ -147,30 +72,9 @@ dense_base(void) return abw[0].abw_abst.abst_sys_start; } -static unsigned long -memory_base(void) -{ - if (abw_count < 0) - init_abw(); - - if (abw_count > 1) { - xf86Msg(X_INFO, "memory base = %#lx\n", abw[1].abw_abst.abst_sys_start); /* XXXX */ - return abw[1].abw_abst.abst_sys_start; - } - else if (abw_count == 1) { - /* assume memory_base == dense_base */ - xf86Msg(X_INFO, "memory base = %#lx\n", abw[0].abw_abst.abst_sys_start); /* XXXX */ - return abw[0].abw_abst.abst_sys_start; - } - else { - xf86Msg(X_INFO, "no memory base\n"); /* XXXX */ - return 0; - } -} #endif /* __NetBSD__ */ #define BUS_BASE dense_base() -#define BUS_BASE_BWX memory_base() /***************************************************************************/ /* Video Memory Mapping section */ @@ -182,18 +86,12 @@ memory_base(void) "\trefer to xf86(4) for details" #endif -static Bool useDevMem = FALSE; static int devMemFd = -1; #ifdef HAS_APERTURE_DRV #define DEV_APERTURE "/dev/xf86" #endif -static void *mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, void *, unsigned long); -static void *mapVidMemSparse(int, unsigned long, unsigned long, int); -static void unmapVidMemSparse(int, void *, unsigned long); - /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. @@ -219,7 +117,6 @@ checkDevMem(Bool warn) if (base != MAP_FAILED) { munmap((caddr_t) base, 4096); devMemFd = fd; - useDevMem = TRUE; xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", DEV_APERTURE); return; @@ -240,7 +137,6 @@ checkDevMem(Bool warn) if (base != MAP_FAILED) { munmap((caddr_t) base, 4096); devMemFd = fd; - useDevMem = TRUE; return; } else { @@ -266,7 +162,6 @@ checkDevMem(Bool warn) #endif xf86ErrorF("\tlinear framebuffer access unavailable\n"); } - useDevMem = FALSE; return; } @@ -274,117 +169,10 @@ void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - if (has_bwx()) { - xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n"); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - } - else { - xf86Msg(X_PROBED, "Machine needs sparse mapping\n"); - pVidMem->mapMem = mapVidMemSparse; - pVidMem->unmapMem = unmapVidMemSparse; -#ifndef __NetBSD__ - if (axpSystem == -1) - axpSystem = bsdGetAXP(); - hae_thresh = xf86AXPParams[axpSystem].hae_thresh; - hae_mask = xf86AXPParams[axpSystem].hae_mask; -#endif /* __NetBSD__ */ - } pVidMem->initialised = TRUE; } -static void * -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - void *base; - - checkDevMem(FALSE); - Base = Base & ((1L << 32) - 1); - - if (useDevMem) { - if (devMemFd < 0) { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t) 0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX); - if (base == MAP_FAILED) { - FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno)); - } - return base; - } - - /* else, mmap /dev/vga */ - if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) { - FatalError("%s: Address 0x%lx outside allowable range\n", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base + BUS_BASE); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return base; -} - -static void -unmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - munmap((caddr_t) Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return -1; - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE); - if ((long) ptr == -1) { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return -1; - } -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, - "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base, - ptr[0] | (ptr[1] << 8)); -#endif - (void) memcpy(Buf, (void *) (ptr + Offset), Len); - (void) munmap((caddr_t) ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return Len; -} - #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) extern int ioperm(unsigned long from, unsigned long num, int on); @@ -422,11 +210,6 @@ xf86DisableIO() #endif /* USE_ALPHA_PIO */ -#define vuip volatile unsigned int * - -static void *memSBase = 0; -static void *memBase = 0; - extern int readDense8(void *Base, register unsigned long Offset); extern int readDense16(void *Base, register unsigned long Offset); extern int readDense32(void *Base, register unsigned long Offset); @@ -437,223 +220,6 @@ extern void extern void writeDense32(int Value, void *Base, register unsigned long Offset); -static int readSparse8(void *Base, register unsigned long Offset); -static int readSparse16(void *Base, register unsigned long Offset); -static int readSparse32(void *Base, register unsigned long Offset); -static void - writeSparseNB8(int Value, void *Base, register unsigned long Offset); -static void - writeSparseNB16(int Value, void *Base, register unsigned long Offset); -static void - writeSparseNB32(int Value, void *Base, register unsigned long Offset); -static void - writeSparse8(int Value, void *Base, register unsigned long Offset); -static void - writeSparse16(int Value, void *Base, register unsigned long Offset); -static void - writeSparse32(int Value, void *Base, register unsigned long Offset); - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -extern int sysarch(int, void *); - -struct parms { - u_int64_t hae; -}; - -static void -sethae(u_int64_t hae) -{ -#ifndef ALPHA_SETHAE -#define ALPHA_SETHAE 0 -#endif - static struct parms p; - - if (p.hae != hae) { - p.hae = hae; - sysarch(ALPHA_SETHAE, (char *) &p); - } -} -#endif - -static void * -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, - int flags) -{ - static Bool was_here = FALSE; - - if (!was_here) { - was_here = TRUE; - - checkDevMem(FALSE); - - xf86WriteMmio8 = writeSparse8; - xf86WriteMmio16 = writeSparse16; - xf86WriteMmio32 = writeSparse32; - xf86WriteMmioNB8 = writeSparseNB8; - xf86WriteMmioNB16 = writeSparseNB16; - xf86WriteMmioNB32 = writeSparseNB32; - xf86ReadMmio8 = readSparse8; - xf86ReadMmio16 = readSparse16; - xf86ReadMmio32 = readSparse32; - - memBase = mmap((caddr_t) 0, 0x100000000, - PROT_READ | PROT_WRITE, - MAP_SHARED, devMemFd, (off_t) BUS_BASE); - memSBase = mmap((caddr_t) 0, 0x100000000, - PROT_READ | PROT_WRITE, - MAP_SHARED, devMemFd, (off_t) BUS_BASE_BWX); - - if (memSBase == MAP_FAILED || memBase == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", - strerror(errno)); - } - } - return (void *) ((unsigned long) memBase + Base); -} - -static void -unmapVidMemSparse(int ScreenNum, void *Base, unsigned long Size) -{ -} - -static int -readSparse8(void *Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long) Base - (unsigned long) memBase; - shift = (Offset & 0x3) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - sethae(msb); -#endif - } - result = *(vuip) ((unsigned long) memSBase + (Offset << 5)); - result >>= shift; - return 0xffUL & result; -} - -static int -readSparse16(void *Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long) Base - (unsigned long) memBase; - shift = (Offset & 0x2) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - sethae(msb); -#endif - } - result = - *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))); - result >>= shift; - return 0xffffUL & result; -} - -static int -readSparse32(void *Base, register unsigned long Offset) -{ - mem_barrier(); - return *(vuip) ((unsigned long) Base + (Offset)); -} - -static void -writeSparse8(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - write_mem_barrier(); - Offset += (unsigned long) Base - (unsigned long) memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - sethae(msb); -#endif - } - *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparse16(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - write_mem_barrier(); - Offset += (unsigned long) Base - (unsigned long) memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - sethae(msb); -#endif - } - *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) = - w * 0x00010001; - -} - -static void -writeSparse32(int Value, void *Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(vuip) ((unsigned long) Base + (Offset)) = Value; - return; -} - -static void -writeSparseNB8(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - Offset += (unsigned long) Base - (unsigned long) memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - sethae(msb); -#endif - } - *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparseNB16(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - Offset += (unsigned long) Base - (unsigned long) memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - sethae(msb); -#endif - } - *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) = - w * 0x00010001; -} - -static void -writeSparseNB32(int Value, void *Base, register unsigned long Offset) -{ - *(vuip) ((unsigned long) Base + (Offset)) = Value; - return; -} - void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset) = writeDense8; void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset) diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c index e295c9244..3a639b8c6 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c @@ -66,35 +66,6 @@ #include "xf86_OSlib.h" #include "xf86OSpriv.h" -#ifdef __arm32__ -#include "machine/devmap.h" -struct memAccess { - int ioctl; - struct map_info memInfo; - void *regionVirtBase; - Bool Checked; - Bool OK; -}; - -static void *xf86MapInfoMap(); -static void xf86MapInfoUnmap(); -static struct memAccess *checkMapInfo(); -extern int vgaPhysLinearBase; - -/* A memAccess structure is needed for each possible region */ -struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, - FALSE, FALSE -}; - -struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, - FALSE, FALSE -}; - -struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, - FALSE, FALSE -}; -#endif /* __arm32__ */ - #if defined(__NetBSD__) && !defined(MAP_FILE) #define MAP_FLAGS MAP_SHARED #else @@ -108,12 +79,8 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, /* Video Memory Mapping section */ /***************************************************************************/ -static Bool useDevMem = FALSE; static int devMemFd = -1; -static void *mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, void *, unsigned long); - /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. @@ -137,7 +104,6 @@ checkDevMem(Bool warn) if (base != MAP_FAILED) { munmap((caddr_t) base, 4096); devMemFd = fd; - useDevMem = TRUE; return; } else { @@ -146,7 +112,6 @@ checkDevMem(Bool warn) xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", DEV_MEM, strerror(errno)); } - useDevMem = FALSE; return; } } @@ -154,266 +119,17 @@ checkDevMem(Bool warn) xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", DEV_MEM, strerror(errno)); } - useDevMem = FALSE; return; } void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = armMapVidMem; - pVidMem->unmapVidMem = armUnmapVidMem; pVidMem->initialised = TRUE; } -static void * -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - void *base; - - checkDevMem(FALSE); - - if (useDevMem) { - if (devMemFd < 0) { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t) 0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX); - if (base == MAP_FAILED) { - FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno)); - } - return base; - } - - /* else, mmap /dev/vga */ - if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) { - FatalError("%s: Address 0x%x outside allowable range\n", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return base; -} - -static void -unmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - munmap((caddr_t) Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return -1; - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE); - if ((long) ptr == -1) { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return -1; - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void) memcpy(Buf, (void *) (ptr + Offset), Len); - (void) munmap((caddr_t) ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return Len; -} - -/* XXX This needs to be updated for the ND */ - -/* -** Find out whether the console driver provides memory mapping information -** for the specified region and return the map_info pointer. Print a warning if required. -*/ -static struct memAccess * -checkMapInfo(Bool warn, int Region) -{ - struct memAccess *memAccP; - - switch (Region) { - case VGA_REGION: - memAccP = &vgaMemInfo; - break; - - case LINEAR_REGION: - memAccP = &linearMemInfo; - break; - - case MMIO_REGION: - memAccP = &ioMemInfo; - break; - - default: - return NULL; - break; - } - - if (!memAccP->Checked) { - if (ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) == - -1) { - if (warn) { - xf86Msg(X_WARNING, - "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", - Region, strerror(errno)); - } - } - else { - if (memAccP->memInfo.u.map_info_mmap.map_offset != MAP_INFO_UNKNOWN) - memAccP->OK = TRUE; - } - memAccP->Checked = TRUE; - } - if (memAccP->OK) { - return memAccP; - } - else { - return NULL; - } -} - -static void * -xf86MapInfoMap(struct memAccess *memInfoP, void *Base, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) { - Size = (unsigned long) Base + Size; - } - else { - Size = mapInfoP->u.map_info_mmap.map_size; - } - - switch (mapInfoP->method) { - case MAP_MMAP: - /* Need to remap if size is unknown because we may not have - mapped the whole region initially */ - if (memInfoP->regionVirtBase == NULL || - mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) { - if ((memInfoP->regionVirtBase = - mmap((caddr_t) 0, - Size, - PROT_READ | PROT_WRITE, - MAP_SHARED, - xf86Info.consoleFd, - (unsigned long) mapInfoP->u.map_info_mmap.map_offset)) - == (void *) -1) { - FatalError - ("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", - mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); - } - if (mapInfoP->u.map_info_mmap.internal_offset > 0) - memInfoP->regionVirtBase += - mapInfoP->u.map_info_mmap.internal_offset; - } - break; - - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } - - return (void *) ((int) memInfoP->regionVirtBase + (int) Base); -} - -static void -xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - switch (mapInfoP->method) { - case MAP_MMAP: - if (memInfoP->regionVirtBase != NULL) { - if (mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) - Size = mapInfoP->u.map_info_mmap.map_size; - munmap((caddr_t) memInfoP->regionVirtBase, Size); - memInfoP->regionVirtBase = NULL; - } - break; - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } -} - -static void * -armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct memAccess *memInfoP; - - if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) { - /* - ** xf86 passes in a physical address offset from the start - ** of physical memory, but xf86MapInfoMap expects an - ** offset from the start of the specified region - it gets - ** the physical address of the region from the display driver. - */ - switch (Region) { - case LINEAR_REGION: - if (vgaPhysLinearBase) { - Base -= vgaPhysLinearBase; - } - break; - case VGA_REGION: - Base -= 0xA0000; - break; - } - - base = xf86MapInfoMap(memInfoP, Base, Size); - return base; - } - return mapVidMem(ScreenNum, Base, Size, flags); -} - -static void -armUnmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - struct memAccess *memInfoP; - - if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) { - xf86MapInfoUnmap(memInfoP, Base, Size); - } - unmapVidMem(ScreenNum, Base, Size); -} - #ifdef USE_DEV_IO static int IoFd = -1; diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c deleted file mode 100644 index e7a36f8bf..000000000 --- a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c +++ /dev/null @@ -1,71 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "shared/xf86Axp.h" -#include <sys/param.h> -#include "xf86_OSlib.h" -#include <stdio.h> -#include <sys/sysctl.h> - -axpDevice bsdGetAXP(void); - -/* - * BSD does a very nice job providing system information to - * user space programs. Unfortunately it doesn't provide all - * the information required. Therefore we just obtain the - * system type and look up the rest from a list we maintain - * ourselves. - */ - -typedef struct { - char *name; - int type; -} _AXP; - -static _AXP axpList[] = { - {"apecs", APECS}, - {"pyxis", PYXIS}, - {"cia", CIA}, - {"irongate", IRONGATE}, - {"lca", LCA}, - {"t2", T2}, - {"tsunami", TSUNAMI}, - {NULL, SYS_NONE} -}; - -axpDevice -bsdGetAXP(void) -{ - int i; - char sysname[64]; - size_t len = sizeof(sysname); - -#ifdef __OpenBSD__ - int mib[3]; - int error; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_TYPE; - - if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0) -#else - if ((sysctlbyname("hw.chipset.type", &sysname, &len, 0, 0)) < 0) -#endif - FatalError("bsdGetAXP: can't find machine type\n"); -#ifdef DEBUG - xf86Msg(X_INFO, "AXP is a: %s\n", sysname); -#endif - for (i = 0;; i++) { - if (axpList[i].name == NULL) - return SYS_NONE; - if (!strcmp(sysname, axpList[i].name)) - return axpList[i].type; - } -} diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c index 745319054..6c3bbcb48 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c @@ -34,27 +34,6 @@ #include <errno.h> #include <sys/mman.h> -#ifdef HAS_MTRR_SUPPORT -#ifndef __NetBSD__ -#include <sys/types.h> -#include <sys/memrange.h> -#else -#include "memrange.h" -#endif -#define X_MTRR_ID "XFree86" -#endif - -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) -#include <machine/mtrr.h> -#include <machine/sysarch.h> -#include <sys/queue.h> -#ifdef __x86_64__ -#define i386_set_mtrr x86_64_set_mtrr -#define i386_get_mtrr x86_64_get_mtrr -#define i386_iopl x86_64_iopl -#endif -#endif - #include "xf86_OSlib.h" #include "xf86OSpriv.h" @@ -85,20 +64,6 @@ static int devMemFd = -1; #define DEV_APERTURE "/dev/xf86" #endif -static void *mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, void *, unsigned long); - -#ifdef HAS_MTRR_SUPPORT -static void *setWC(int, unsigned long, unsigned long, Bool, MessageType); -static void undoWC(int, void *); -static Bool cleanMTRR(void); -#endif -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) -static void *NetBSDsetWC(int, unsigned long, unsigned long, Bool, - MessageType); -static void NetBSDundoWC(int, void *); -#endif - /* * Check if /dev/mem can be mmap'd. If it can't print a warning when * "warn" is TRUE. @@ -188,119 +153,10 @@ void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - - if (useDevMem) - pci_system_init_dev_mem(devMemFd); - -#ifdef HAS_MTRR_SUPPORT - if (useDevMem) { - if (cleanMTRR()) { - pVidMem->setWC = setWC; - pVidMem->undoWC = undoWC; - } - } -#endif -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) - pVidMem->setWC = NetBSDsetWC; - pVidMem->undoWC = NetBSDundoWC; -#endif - pVidMem->initialised = TRUE; -} -static void * -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - void *base; + pci_system_init_dev_mem(devMemFd); - checkDevMem(FALSE); - - if (useDevMem) { - if (devMemFd < 0) { - FatalError("xf86MapVidMem: failed to open %s (%s)", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t) 0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t) Base); - if (base == MAP_FAILED) { - FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)", - "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno)); - } - return base; - } - - /* else, mmap /dev/vga */ - if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) { - FatalError("%s: Address 0x%lx outside allowable range", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)", - strerror(errno)); - } - return base; -} - -static void -unmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - munmap((caddr_t) Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return -1; - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t) Base); - if ((long) ptr == -1) { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); -#ifdef __OpenBSD__ - if (Base < 0xa0000) { - xf86Msg(X_WARNING, SYSCTL_MSG2); - } -#endif - return -1; - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void) memcpy(Buf, (void *) (ptr + Offset), Len); - (void) munmap((caddr_t) ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return Len; + pVidMem->initialised = TRUE; } #ifdef USE_I386_IOPL @@ -470,417 +326,3 @@ xf86SetRGBOut() return; } #endif - -#ifdef HAS_MTRR_SUPPORT -/* memory range (MTRR) support for FreeBSD */ - -/* - * This code is experimental. Some parts may be overkill, and other parts - * may be incomplete. - */ - -/* - * getAllRanges returns the full list of memory ranges with attributes set. - */ - -static struct mem_range_desc * -getAllRanges(int *nmr) -{ - struct mem_range_desc *mrd; - struct mem_range_op mro; - - /* - * Find how many ranges there are. If this fails, then the kernel - * probably doesn't have MTRR support. - */ - mro.mo_arg[0] = 0; - if (ioctl(devMemFd, MEMRANGE_GET, &mro)) - return NULL; - *nmr = mro.mo_arg[0]; - mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); - mro.mo_arg[0] = *nmr; - mro.mo_desc = mrd; - if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { - free(mrd); - return NULL; - } - return mrd; -} - -/* - * cleanMTRR removes any memory attribute that may be left by a previous - * X server. Normally there won't be any, but this takes care of the - * case where a server crashed without being able finish cleaning up. - */ - -static Bool -cleanMTRR() -{ - struct mem_range_desc *mrd; - struct mem_range_op mro; - int nmr, i; - - /* This shouldn't happen */ - if (devMemFd < 0) - return FALSE; - - if (!(mrd = getAllRanges(&nmr))) - return FALSE; - - for (i = 0; i < nmr; i++) { - if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 && - (mrd[i].mr_flags & MDF_ACTIVE)) { -#ifdef DEBUG - ErrorF("Clean for (0x%lx,0x%lx)\n", - (unsigned long) mrd[i].mr_base, - (unsigned long) mrd[i].mr_len); -#endif - if (mrd[i].mr_flags & MDF_FIXACTIVE) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - mrd[i].mr_flags = MDF_UNCACHEABLE; - } - else { - mro.mo_arg[0] = MEMRANGE_SET_REMOVE; - } - mro.mo_desc = mrd + i; - ioctl(devMemFd, MEMRANGE_SET, &mro); - } - } -#ifdef DEBUG - sleep(10); -#endif - free(mrd); - return TRUE; -} - -typedef struct x_RangeRec { - struct mem_range_desc mrd; - Bool wasWC; - struct x_RangeRec *next; -} RangeRec, *RangePtr; - -static void -freeRangeList(RangePtr range) -{ - RangePtr rp; - - while (range) { - rp = range; - range = rp->next; - free(rp); - } -} - -static RangePtr -dupRangeList(RangePtr list) -{ - RangePtr new = NULL, rp, p; - - rp = list; - while (rp) { - p = xnfalloc(sizeof(RangeRec)); - *p = *rp; - p->next = new; - new = p; - rp = rp->next; - } - return new; -} - -static RangePtr -sortRangeList(RangePtr list) -{ - RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev; - unsigned long minBase; - - /* Sort by base address */ - rp1 = copy = dupRangeList(list); - while (rp1) { - minBase = rp1->mrd.mr_base; - minp = rp1; - minprev = NULL; - prev = rp1; - rp2 = rp1->next; - while (rp2) { - if (rp2->mrd.mr_base < minBase) { - minBase = rp2->mrd.mr_base; - minp = rp2; - minprev = prev; - } - prev = rp2; - rp2 = rp2->next; - } - if (minprev) { - minprev->next = minp->next; - rp1 = copy; - } - else { - rp1 = minp->next; - } - minp->next = sorted; - sorted = minp; - } - return sorted; -} - -/* - * findRanges returns a list of ranges that overlap the specified range. - */ - -static void -findRanges(unsigned long base, unsigned long size, RangePtr * ucp, - RangePtr * wcp) -{ - struct mem_range_desc *mrd; - int nmr, i; - RangePtr rp, *p; - - if (!(mrd = getAllRanges(&nmr))) - return; - - for (i = 0; i < nmr; i++) { - if ((mrd[i].mr_flags & MDF_ACTIVE) && - mrd[i].mr_base < base + size && - mrd[i].mr_base + mrd[i].mr_len > base) { - if (mrd[i].mr_flags & MDF_WRITECOMBINE) - p = wcp; - else if (mrd[i].mr_flags & MDF_UNCACHEABLE) - p = ucp; - else - continue; - rp = xnfalloc(sizeof(RangeRec)); - rp->mrd = mrd[i]; - rp->next = *p; - *p = rp; - } - } - free(mrd); -} - -/* - * This checks if the existing overlapping ranges fully cover the requested - * range. Is this overkill? - */ - -static Bool -fullCoverage(unsigned long base, unsigned long size, RangePtr overlap) -{ - RangePtr rp1, sorted = NULL; - unsigned long end; - - sorted = sortRangeList(overlap); - /* Look for gaps */ - rp1 = sorted; - end = base + size; - while (rp1) { - if (rp1->mrd.mr_base > base) { - freeRangeList(sorted); - return FALSE; - } - else { - base = rp1->mrd.mr_base + rp1->mrd.mr_len; - } - if (base >= end) { - freeRangeList(sorted); - return TRUE; - } - rp1 = rp1->next; - } - freeRangeList(sorted); - return FALSE; -} - -static void * -addWC(int screenNum, unsigned long base, unsigned long size, MessageType from) -{ - RangePtr uc = NULL, wc = NULL, retlist = NULL; - struct mem_range_desc mrd; - struct mem_range_op mro; - - findRanges(base, size, &uc, &wc); - - /* See of the full range is already WC */ - if (!uc && fullCoverage(base, size, wc)) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx) was already set\n", - base, size); - return NULL; - } - - /* Otherwise, try to add the new range */ - mrd.mr_base = base; - mrd.mr_len = size; - strcpy(mrd.mr_owner, X_MTRR_ID); - mrd.mr_flags = MDF_WRITECOMBINE; - mro.mo_desc = &mrd; - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to set write-combining range " - "(0x%lx,0x%lx)\n", base, size); - return NULL; - } - else { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx)\n", base, size); - retlist = xnfalloc(sizeof(RangeRec)); - retlist->mrd = mrd; - retlist->wasWC = FALSE; - retlist->next = NULL; - return retlist; - } -} - -static void * -delWC(int screenNum, unsigned long base, unsigned long size, MessageType from) -{ - RangePtr uc = NULL, wc = NULL, retlist = NULL; - struct mem_range_desc mrd; - struct mem_range_op mro; - - findRanges(base, size, &uc, &wc); - - /* - * See of the full range is already not WC, or if there is full - * coverage from UC ranges. - */ - if (!wc || fullCoverage(base, size, uc)) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx) was already clear\n", - base, size); - return NULL; - } - - /* Otherwise, try to add the new range */ - mrd.mr_base = base; - mrd.mr_len = size; - strcpy(mrd.mr_owner, X_MTRR_ID); - mrd.mr_flags = MDF_UNCACHEABLE; - mro.mo_desc = &mrd; - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to remove write-combining range " - "(0x%lx,0x%lx)\n", base, size); - /* XXX Should then remove all of the overlapping WC ranges */ - return NULL; - } - else { - xf86DrvMsg(screenNum, from, - "Removed Write-combining range (0x%lx,0x%lx)\n", base, size); - retlist = xnfalloc(sizeof(RangeRec)); - retlist->mrd = mrd; - retlist->wasWC = TRUE; - retlist->next = NULL; - return retlist; - } -} - -static void * -setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - if (enable) - return addWC(screenNum, base, size, from); - else - return delWC(screenNum, base, size, from); -} - -static void -undoWC(int screenNum, void *list) -{ - RangePtr rp; - struct mem_range_op mro; - Bool failed; - - rp = list; - while (rp) { -#ifdef DEBUG - ErrorF("Undo for (0x%lx,0x%lx), %d\n", - (unsigned long) rp->mrd.mr_base, - (unsigned long) rp->mrd.mr_len, rp->wasWC); -#endif - failed = FALSE; - if (rp->wasWC) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - rp->mrd.mr_flags = MDF_WRITECOMBINE; - strcpy(rp->mrd.mr_owner, "unknown"); - } - else { - mro.mo_arg[0] = MEMRANGE_SET_REMOVE; - } - mro.mo_desc = &rp->mrd; - - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - if (!rp->wasWC) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - rp->mrd.mr_flags = MDF_UNCACHEABLE; - strcpy(rp->mrd.mr_owner, "unknown"); - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) - failed = TRUE; - } - else - failed = TRUE; - } - if (failed) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to restore MTRR range (0x%lx,0x%lx)\n", - (unsigned long) rp->mrd.mr_base, - (unsigned long) rp->mrd.mr_len); - } - rp = rp->next; - } -} - -#endif /* HAS_MTRR_SUPPORT */ - -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) -static void * -NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - struct mtrr *mtrrp; - int n; - - xf86DrvMsg(screenNum, X_WARNING, - "%s MTRR %lx - %lx\n", enable ? "set" : "remove", - base, (base + size)); - - mtrrp = xnfalloc(sizeof(struct mtrr)); - mtrrp->base = base; - mtrrp->len = size; - mtrrp->type = MTRR_TYPE_WC; - - /* - * MTRR_PRIVATE will make this MTRR get reset automatically - * if this process exits, so we have no need for an explicit - * cleanup operation when starting a new server. - */ - - if (enable) - mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; - else - mtrrp->flags = 0; - n = 1; - - if (i386_set_mtrr(mtrrp, &n) < 0) { - free(mtrrp); - return NULL; - } - return mtrrp; -} - -static void -NetBSDundoWC(int screenNum, void *list) -{ - struct mtrr *mtrrp = (struct mtrr *) list; - int n; - - if (mtrrp == NULL) - return; - n = 1; - mtrrp->flags &= ~MTRR_VALID; - i386_set_mtrr(mtrrp, &n); - free(mtrrp); -} -#endif diff --git a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c index 3fd28c3b5..b1cf7eb1b 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c @@ -44,74 +44,18 @@ #define DEV_MEM "/dev/xf86" #endif -static void *ppcMapVidMem(int, unsigned long, unsigned long, int flags); -static void ppcUnmapVidMem(int, void *, unsigned long); - Bool xf86EnableIO(void); void xf86DisableIO(void); void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = ppcMapVidMem; - pVidMem->unmapMem = ppcUnmapVidMem; pVidMem->initialised = TRUE; xf86EnableIO(); } volatile unsigned char *ioBase = MAP_FAILED; -static void * -ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - int fd = xf86Info.consoleFd; - void *base; - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd); -#endif - - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base); - if (base == MAP_FAILED) - FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)", - "xf86MapVidMem", Size, Base, strerror(errno)); - - return base; -} - -static void -ppcUnmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - munmap(Base, Size); -} - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int rv; - static int kmem = -1; - - if (kmem == -1) { - kmem = open(DEV_MEM, 2); - if (kmem == -1) { - FatalError("xf86ReadBIOS: open %s", DEV_MEM); - } - } - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len); -#endif - - lseek(kmem, Base + Offset, 0); - rv = read(kmem, Buf, Len); - - return rv; -} - Bool xf86EnableIO() { diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c index 02951d602..5bed01790 100644 --- a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c +++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c @@ -38,48 +38,8 @@ /* Video Memory Mapping section */ /***************************************************************************/ -static void *sparc64MapVidMem(int, unsigned long, unsigned long, int); -static void sparc64UnmapVidMem(int, void *, unsigned long); - void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = sparc64MapVidMem; - pVidMem->unmapMem = sparc64UnmapVidMem; pVidMem->initialised = TRUE; } - -static void * -sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, - int flags) -{ - int fd = xf86Info.consoleFd; - void *base; - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd); -#endif - - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base); - if (base == MAP_FAILED) - FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", - "xf86MapVidMem", Size, Base, strerror(errno)); - return base; -} - -static void -sparc64UnmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - munmap(Base, Size); -} - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - - return 0; -} diff --git a/xorg-server/hw/xfree86/os-support/hurd/Makefile.am b/xorg-server/hw/xfree86/os-support/hurd/Makefile.am index f228c1ce4..38660544a 100644 --- a/xorg-server/hw/xfree86/os-support/hurd/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/hurd/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libhurd.la -libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \ +libhurd_la_SOURCES = hurd_bell.c hurd_init.c \ hurd_video.c \ $(srcdir)/../shared/VTsw_noop.c \ $(srcdir)/../shared/posix_tty.c \ diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c deleted file mode 100644 index 8e089cadb..000000000 --- a/xorg-server/hw/xfree86/os-support/hurd/hurd_mmap.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 1997 by UCHIYAMA Yasushi - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of UCHIYAMA Yasushi not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. UCHIYAMA Yasushi makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include<mach.h> -#include<device/device.h> -#include<mach/machine/mach_i386.h> -#include <hurd.h> - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#define BIOS_SIZE 0x20000 - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - mach_port_t device, mem_dev; - memory_object_t mem_obj; - vm_address_t addr = (vm_address_t) 0; /* serach starting address */ - kern_return_t err; - - err = get_privileged_ports(NULL, &device); - if (err) { - errno = err; - FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n", - strerror(errno)); - } - err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev); - mach_port_deallocate(mach_task_self(), device); - if (err) { - errno = err; - FatalError("xf86ReadBIOS() can't device_open. (%s)\n", strerror(errno)); - } - err = - device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, BIOS_SIZE, - &mem_obj, 0); - if (err) { - errno = err; - FatalError("xf86ReadBIOS() can't device_map. (%s)\n", strerror(errno)); - } - err = vm_map(mach_task_self(), - &addr, - BIOS_SIZE, - 0, - TRUE, - mem_obj, - Base, - FALSE, - VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE); - mach_port_deallocate(mach_task_self(), mem_obj); - if (err) { - errno = err; - FatalError("xf86ReadBIOS() can't vm_map. (%s)\n", strerror(errno)); - } - - memcpy(Buf, (void *) ((int) addr + Offset), Len); - - err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE); - if (err) { - errno = err; - FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n", - strerror(errno)); - } - - return Len; -} diff --git a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c index dc1a8e670..2a96393b0 100644 --- a/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c +++ b/xorg-server/hw/xfree86/os-support/hurd/hurd_video.c @@ -42,68 +42,6 @@ /************************************************************************** * Video Memory Mapping section ***************************************************************************/ -static void * -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags) -{ - mach_port_t device, mem_dev; - memory_object_t mem_obj; - kern_return_t err; - vm_address_t addr = (vm_address_t) 0; - - err = get_privileged_ports(NULL, &device); - if (err) { - errno = err; - FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n", - strerror(errno)); - } - err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev); - mach_port_deallocate(mach_task_self(), device); - if (err) { - errno = err; - FatalError("xf86MapVidMem() can't device_open. (%s)\n", - strerror(errno)); - } - - err = - device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, Size, &mem_obj, - 0); - if (err) { - errno = err; - FatalError("xf86MapVidMem() can't device_map. (%s)\n", strerror(errno)); - } - err = vm_map(mach_task_self(), &addr, Size, 0, /* mask */ - TRUE, /* anywhere */ - mem_obj, (vm_offset_t) Base, FALSE, /* copy on write */ - VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE); - mach_port_deallocate(mach_task_self(), mem_obj); - if (err) { - errno = err; - FatalError("xf86MapVidMem() can't vm_map.(mem_obj) (%s)\n", - strerror(errno)); - } - mach_port_deallocate(mach_task_self(), mem_dev); - if (err) { - errno = err; - FatalError - ("xf86MapVidMem() can't mach_port_deallocate.(mem_dev) (%s)\n", - strerror(errno)); - } - return (void *) addr; -} - -static void -unmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - kern_return_t err = vm_deallocate(mach_task_self(), (int) Base, Size); - - if (err) { - errno = err; - ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n", - strerror(errno)); - } - return; -} /************************************************************************** * I/O Permissions section @@ -146,8 +84,5 @@ xf86DisableIO() void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; pVidMem->initialised = TRUE; } diff --git a/xorg-server/hw/xfree86/os-support/linux/Makefile.am b/xorg-server/hw/xfree86/os-support/linux/Makefile.am index 1686dc2c1..50fcd1f28 100644 --- a/xorg-server/hw/xfree86/os-support/linux/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/linux/Makefile.am @@ -2,9 +2,6 @@ noinst_LTLIBRARIES = liblinux.la if LINUX_ALPHA noinst_LTLIBRARIES += liblinuxev56.la -PLATFORM_PCI_SUPPORT = \ - $(srcdir)/lnx_axp.c \ - $(srcdir)/../shared/xf86Axp.c liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56 @@ -28,23 +25,18 @@ endif liblinux_la_SOURCES = lnx_init.c lnx_video.c \ lnx_agp.c lnx_kmod.c lnx_bell.c lnx_platform.c \ - $(srcdir)/../shared/bios_mmap.c \ $(srcdir)/../shared/VTsw_usl.c \ $(srcdir)/../shared/posix_tty.c \ $(srcdir)/../shared/vidmem.c \ $(srcdir)/../shared/sigio.c \ $(ACPI_SRCS) \ $(APM_SRCS) \ - $(LOGIND_SRCS) \ - $(PLATFORM_PCI_SUPPORT) + $(LOGIND_SRCS) AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES) AM_CPPFLAGS = $(XORG_INCS) $(PLATFORM_INCLUDES) $(LIBDRM_CFLAGS) -EXTRA_DIST = \ - $(srcdir)/../shared/xf86Axp.h - if LINUX_ALPHA liblinux_la_LIBADD = liblinuxev56.la endif diff --git a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c index 6181eb9c5..79b9a8858 100644 --- a/xorg-server/hw/xfree86/os-support/linux/int10/linux.c +++ b/xorg-server/hw/xfree86/os-support/linux/int10/linux.c @@ -70,6 +70,20 @@ static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn); #endif /* DoSubModules */ +static Bool +readLegacy(struct pci_device *dev, unsigned char *buf, int base, int len) +{ + void *map; + + if (!pci_device_map_legacy(dev, base, len, 0, &map)) + return FALSE; + + memcpy(buf, map, len); + pci_device_unmap_legacy(dev, man, len); + + return TRUE; +} + xf86Int10InfoPtr xf86ExtendedInitInt10(int entityIndex, int Flags) { @@ -222,7 +236,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) Int10Current = pInt; DebugF("Mapping int area\n"); - if (xf86ReadBIOS(0, 0, (unsigned char *) 0, LOW_PAGE_SIZE) < 0) { + /* note: yes, we really are writing the 0 page here */ + if (!readLegacy(pInt->dev, (unsigned char *) 0, 0, LOW_PAGE_SIZE)) { xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n"); goto error3; } @@ -236,7 +251,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags) memset((void *) V_BIOS, 0, SYS_BIOS - V_BIOS); DebugF("Reading BIOS\n"); for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) - if (xf86ReadBIOS(cs, 0, (void *) cs, V_BIOS_SIZE) < V_BIOS_SIZE) + if (!readLegacy(pInt->dev, (void *)cs, cs, V_BIOS_SIZE)) xf86DrvMsg(screen, X_WARNING, "Unable to retrieve all of segment 0x%06lX.\n", (long) cs); diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c deleted file mode 100644 index d65a3a487..000000000 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_axp.c +++ /dev/null @@ -1,103 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "xf86.h" -#include "shared/xf86Axp.h" - -axpDevice lnxGetAXP(void); - -typedef struct { - char *sysName; - char *sysVari; - char *cpu; - axpDevice sys; -} AXP; - -static AXP axpList[] = { - {"Tsunami", NULL, NULL, TSUNAMI}, - {"Eiger", NULL, NULL, TSUNAMI}, - {"Noname", NULL, NULL, LCA}, - {"AlphaBook1", NULL, NULL, LCA}, - {"EB66", NULL, NULL, LCA}, - {"EB64+", NULL, NULL, APECS}, - {"Noritake", NULL, "EV5", CIA}, - {"Noritake", NULL, "EV56", CIA}, - {"Noritake", NULL, NULL, APECS}, - {"XL", NULL, NULL, APECS}, - {"Avanti", NULL, NULL, APECS}, - {"Mikasa", NULL, "EV5", CIA}, - {"Mikasa", NULL, "EV56", CIA}, - {"Mikasa", NULL, NULL, APECS}, - {"EB164", "EB164", NULL, CIA}, - {"EB164", "PC164", NULL, CIA}, - {"EB164", "LX164", NULL, PYXIS}, - {"EB164", "SX164", NULL, PYXIS}, - {"EB164", "RX164", NULL, POLARIS}, - {"Alcor", NULL, NULL, CIA}, - {"Takara", NULL, NULL, CIA}, - {"Sable", NULL, "EV5", T2_GAMMA}, - {"Sable", NULL, "EV56", T2_GAMMA}, - {"Sable", NULL, NULL, T2}, - {"Rawhide", NULL, NULL, MCPCIA}, - {"Jensen", NULL, NULL, JENSEN}, - {"Miata", NULL, NULL, PYXIS_CIA}, - {"Ruffian", NULL, NULL, PYXIS_CIA}, - {"Nautilus", NULL, NULL, IRONGATE}, - {NULL, NULL, NULL, SYS_NONE} -}; - -axpDevice -lnxGetAXP(void) -{ - FILE *file; - int count = 0; - char res[256]; - char cpu[255]; - char systype[255]; - char sysvari[255]; - - if (!(file = fopen("/proc/cpuinfo", "r"))) - return SYS_NONE; - do { - if (!fgets(res, 0xff, file)) - return SYS_NONE; - switch (count) { - case 1: - sscanf(res, "cpu model : %s", cpu); - DebugF("CPU %s\n", cpu); - break; - case 5: - sscanf(res, "system type : %s", systype); - DebugF("system type : %s\n", systype); - break; - case 6: - sscanf(res, "system variation : %s", sysvari); - DebugF("system variation: %s\n", sysvari); - break; - } - count++; - } while (count < 8); - - fclose(file); - - count = 0; - - do { - if (!axpList[count].sysName || !strcmp(axpList[count].sysName, systype)) { - if (axpList[count].sysVari && - strcmp(axpList[count].sysVari, sysvari)) { - count++; - continue; - }; - if (axpList[count].cpu && strcmp(axpList[count].cpu, cpu)) { - count++; - continue; - } - return axpList[count].sys; - } - count++; - } while (1); -} diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c index 85709c629..94853070d 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c @@ -76,6 +76,9 @@ switch_to(int vt, const char *from) FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + void xf86OpenConsole(void) { @@ -166,7 +169,6 @@ xf86OpenConsole(void) i = 0; while (vcs[i] != NULL) { -#pragma GCC diagnostic ignored "-Wformat-nonliteral" snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */ if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) >= 0) break; @@ -272,6 +274,8 @@ xf86OpenConsole(void) } } +#pragma GCC diagnostic pop + void xf86CloseConsole(void) { diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c index ffffc81c5..c09d71947 100644 --- a/xorg-server/hw/xfree86/os-support/linux/lnx_video.c +++ b/xorg-server/hw/xfree86/os-support/linux/lnx_video.c @@ -38,13 +38,6 @@ #include "xf86Priv.h" #include "xf86_OSlib.h" #include "xf86OSpriv.h" -#ifdef __alpha__ -#include "shared/xf86Axp.h" -#endif - -#ifdef HAS_MTRR_SUPPORT -#include <asm/mtrr.h> -#endif static Bool ExtendedEnabled = FALSE; @@ -72,405 +65,16 @@ extern int iopl(int __level); #endif -#ifdef __alpha__ -#define BUS_BASE bus_base -#else -#define BUS_BASE (0) -#endif /* __alpha__ */ - /***************************************************************************/ /* Video Memory Mapping section */ /***************************************************************************/ -static void *mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, void *, unsigned long); - -#if defined (__alpha__) -extern void sethae(unsigned long hae); -extern unsigned long _bus_base __P((void)) __attribute__ ((const)); -extern unsigned long _bus_base_sparse __P((void)) __attribute__ ((const)); - -static void *mapVidMemSparse(int, unsigned long, unsigned long, int); -extern axpDevice lnxGetAXP(void); -static void unmapVidMemSparse(int, void *, unsigned long); -static axpDevice axpSystem = -1; -static Bool needSparse; -static unsigned long hae_thresh; -static unsigned long hae_mask; -static unsigned long bus_base; -#endif - -#ifdef HAS_MTRR_SUPPORT - -#define SPLIT_WC_REGIONS 1 - -static void *setWC(int, unsigned long, unsigned long, Bool, MessageType); -static void undoWC(int, void *); - -/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr - driver will clean up when we exit. */ -#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */ -#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had - a problem. */ -static int mtrr_fd = MTRR_FD_UNOPENED; - -/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, - and will fail on Linux 2.2 with MTRR support configured out, - so verbosity should be chosen appropriately. */ -static Bool -mtrr_open(int verbosity) -{ - /* Only report absence of /proc/mtrr once. */ - static Bool warned = FALSE; - - if (mtrr_fd == MTRR_FD_UNOPENED) { - mtrr_fd = open("/proc/mtrr", O_WRONLY); - - if (mtrr_fd < 0) - mtrr_fd = MTRR_FD_PROBLEM; - } - - if (mtrr_fd == MTRR_FD_PROBLEM) { - /* To make sure we only ever warn once, need to check - verbosity outside xf86MsgVerb */ - if (!warned && verbosity <= xf86GetVerbosity()) { - xf86MsgVerb(X_WARNING, verbosity, - "System lacks support for changing MTRRs\n"); - warned = TRUE; - } - - return FALSE; - } - else - return TRUE; -} - -/* - * We maintain a list of WC regions for each physical mapping so they can - * be undone when unmapping. - */ - -struct mtrr_wc_region { - struct mtrr_sentry sentry; - Bool added; /* added WC or removed it */ - struct mtrr_wc_region *next; -}; - -static struct mtrr_wc_region * -mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size, - MessageType from) -{ - /* Some BIOS writers thought that setting wc over the mmio - region of a graphics devices was a good idea. Try to fix - it. */ - - struct mtrr_gentry gent; - struct mtrr_wc_region *wcreturn = NULL, *wcr; - int count, ret = 0; - - /* Linux 2.0 users should not get a warning without -verbose */ - if (!mtrr_open(2)) - return NULL; - - for (gent.regnum = 0; - ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) { - if (gent.type != MTRR_TYPE_WRCOMB - || gent.base + gent.size <= base || base + size <= gent.base) - continue; - - /* Found an overlapping region. Delete it. */ - - wcr = malloc(sizeof(*wcr)); - if (!wcr) - return NULL; - wcr->sentry.base = gent.base; - wcr->sentry.size = gent.size; - wcr->sentry.type = MTRR_TYPE_WRCOMB; - wcr->added = FALSE; - - count = 3; - while (count-- && - (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0); - - if (ret >= 0) { - xf86DrvMsg(screenNum, from, - "Removed MMIO write-combining range " - "(0x%lx,0x%lx)\n", - (unsigned long) gent.base, (unsigned long) gent.size); - wcr->next = wcreturn; - wcreturn = wcr; - gent.regnum--; - } - else { - free(wcr); - xf86DrvMsgVerb(screenNum, X_WARNING, 0, - "Failed to remove MMIO " - "write-combining range (0x%lx,0x%lx)\n", - (unsigned long)gent.base, (unsigned long) gent.size); - } - } - return wcreturn; -} - -static struct mtrr_wc_region * -mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size, - MessageType from) -{ - struct mtrr_gentry gent; - struct mtrr_wc_region *wcreturn = NULL, **wcr; - - if (!mtrr_open(2)) - return NULL; - - wcr = &wcreturn; - for (gent.regnum = 0; - ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) { - if (gent.type == MTRR_TYPE_WRCOMB - && ((gent.base >= base && gent.base + gent.size < base + size) || - (gent.base > base && gent.base + gent.size <= base + size))) { - *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from); - if (*wcr) - gent.regnum--; - while (*wcr) { - wcr = &((*wcr)->next); - } - } - } - return wcreturn; -} - -static struct mtrr_wc_region * -mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size, - MessageType from) -{ - struct mtrr_wc_region **wcr, *wcreturn, *curwcr; - - /* - * There can be only one.... - */ - - wcreturn = mtrr_remove_offending(screenNum, base, size, from); - wcr = &wcreturn; - while (*wcr) { - wcr = &((*wcr)->next); - } - - /* Linux 2.0 should not warn, unless the user explicitly asks for - WC. */ - - if (!mtrr_open(from == X_CONFIG ? 0 : 2)) - return wcreturn; - - *wcr = curwcr = malloc(sizeof(**wcr)); - if (!curwcr) - return wcreturn; - - curwcr->sentry.base = base; - curwcr->sentry.size = size; - curwcr->sentry.type = MTRR_TYPE_WRCOMB; - curwcr->added = TRUE; - curwcr->next = NULL; - -#if SPLIT_WC_REGIONS - /* - * Splits up the write-combining region if it is not aligned on a - * size boundary. - */ - - { - unsigned long lbase, d_size = 1; - unsigned long n_size = size; - unsigned long n_base = base; - - for (lbase = n_base, d_size = 1; !(lbase & 1); - lbase = lbase >> 1, d_size <<= 1); - while (d_size > n_size) - d_size = d_size >> 1; - DebugF("WC_BASE: 0x%lx WC_END: 0x%lx\n", base, base + d_size - 1); - n_base += d_size; - n_size -= d_size; - if (n_size) { - xf86DrvMsgVerb(screenNum, X_INFO, 3, "Splitting WC range: " - "base: 0x%lx, size: 0x%lx\n", base, size); - curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size, from); - } - curwcr->sentry.size = d_size; - } - - /*****************************************************************/ -#endif /* SPLIT_WC_REGIONS */ - - if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) { - /* Avoid printing on every VT switch */ - if (xf86ServerIsInitialising()) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx)\n", base, size); - } - return wcreturn; - } - else { - *wcr = curwcr->next; - free(curwcr); - - /* Don't complain about the VGA region: MTRR fixed - regions aren't currently supported, but might be in - the future. */ - if ((unsigned long) base >= 0x100000) { - xf86DrvMsgVerb(screenNum, X_WARNING, 0, - "Failed to set up write-combining range " - "(0x%lx,0x%lx)\n", base, size); - } - return wcreturn; - } -} - -static void -mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr) -{ - struct mtrr_wc_region *p, *prev; - - if (mtrr_fd >= 0) { - p = wcr; - while (p) { - if (p->added) - ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry); - prev = p; - p = p->next; - free(prev); - } - } -} - -static void * -setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - if (enable) - return mtrr_add_wc_region(screenNum, base, size, from); - else - return mtrr_cull_wc_region(screenNum, base, size, from); -} - -static void -undoWC(int screenNum, void *regioninfo) -{ - mtrr_undo_wc_region(screenNum, regioninfo); -} - -#endif /* HAS_MTRR_SUPPORT */ - void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - pVidMem->linearSupported = TRUE; -#ifdef __alpha__ - if (axpSystem == -1) { - axpSystem = lnxGetAXP(); - if ((needSparse = (_bus_base_sparse() > 0))) { - hae_thresh = xf86AXPParams[axpSystem].hae_thresh; - hae_mask = xf86AXPParams[axpSystem].hae_mask; - } - bus_base = _bus_base(); - } - if (needSparse) { - xf86Msg(X_INFO, "Machine needs sparse mapping\n"); - pVidMem->mapMem = mapVidMemSparse; - pVidMem->unmapMem = unmapVidMemSparse; - } - else { - xf86Msg(X_INFO, "Machine type has 8/16 bit access\n"); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - } -#else - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; -#endif /* __alpha__ */ - -#ifdef HAS_MTRR_SUPPORT - pVidMem->setWC = setWC; - pVidMem->undoWC = undoWC; -#endif pVidMem->initialised = TRUE; } -#ifdef __sparc__ -/* Basically, you simply cannot do this on Sparc. You have to do something portable - * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM - */ -static void * -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - return NULL; -} -#else -static void * -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - void *base; - int fd; - int mapflags = MAP_SHARED; - int prot; - memType realBase, alignOff; - - realBase = Base & ~(getpagesize() - 1); - alignOff = Base - realBase; - DebugF("base: %lx, realBase: %lx, alignOff: %lx \n", - Base, realBase, alignOff); - -#if defined(__ia64__) || defined(__arm__) || defined(__s390__) -#ifndef MAP_WRITECOMBINED -#define MAP_WRITECOMBINED 0x00010000 -#endif -#ifndef MAP_NONCACHED -#define MAP_NONCACHED 0x00020000 -#endif - if (flags & VIDMEM_FRAMEBUFFER) - mapflags |= MAP_WRITECOMBINED; - else - mapflags |= MAP_NONCACHED; -#endif - -#if 0 - /* this will disappear when people upgrade their kernels */ - fd = open(DEV_MEM, - ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC); -#else - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); -#endif - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", - strerror(errno)); - } - - if (flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - /* This requires linux-0.99.pl10 or above */ - base = mmap((caddr_t) 0, Size + alignOff, prot, mapflags, fd, - (off_t) realBase + BUS_BASE); - close(fd); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer" - " (0x%08lx,0x%lx) (%s)\n", Base, Size, strerror(errno)); - } - DebugF("base: %lx aligned base: %lx\n", base, (char *) base + alignOff); - return (char *) base + alignOff; -} -#endif /* !(__sparc__) */ - -static void -unmapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - uintptr_t alignOff = (uintptr_t) Base - - ((uintptr_t) Base & ~(getpagesize() - 1)); - - DebugF("alignment offset: %lx\n", (unsigned long) alignOff); - munmap((void *) ((uintptr_t) Base - alignOff), (Size + alignOff)); -} - /***************************************************************************/ /* I/O Permissions section */ /***************************************************************************/ @@ -565,8 +169,6 @@ xf86DisableIO(void) #if defined (__alpha__) -#define vuip volatile unsigned int * - extern int readDense8(void *Base, register unsigned long Offset); extern int readDense16(void *Base, register unsigned long Offset); extern int readDense32(void *Base, register unsigned long Offset); @@ -577,284 +179,6 @@ extern void extern void writeDense32(int Value, void *Base, register unsigned long Offset); -static int readSparse8(void *Base, register unsigned long Offset); -static int readSparse16(void *Base, register unsigned long Offset); -static int readSparse32(void *Base, register unsigned long Offset); -static void - writeSparseNB8(int Value, void *Base, register unsigned long Offset); -static void - writeSparseNB16(int Value, void *Base, register unsigned long Offset); -static void - writeSparseNB32(int Value, void *Base, register unsigned long Offset); -static void - writeSparse8(int Value, void *Base, register unsigned long Offset); -static void - writeSparse16(int Value, void *Base, register unsigned long Offset); -static void - writeSparse32(int Value, void *Base, register unsigned long Offset); - -#define DENSE_BASE 0x2ff00000000UL -#define SPARSE_BASE 0x30000000000UL - -static unsigned long msb_set = 0; - -static void * -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, - int flags) -{ - int fd, prot; - unsigned long ret, rets = 0; - - static Bool was_here = FALSE; - - if (!was_here) { - was_here = TRUE; - - xf86WriteMmio8 = writeSparse8; - xf86WriteMmio16 = writeSparse16; - xf86WriteMmio32 = writeSparse32; - xf86WriteMmioNB8 = writeSparseNB8; - xf86WriteMmioNB16 = writeSparseNB16; - xf86WriteMmioNB32 = writeSparseNB32; - xf86ReadMmio8 = readSparse8; - xf86ReadMmio16 = readSparse16; - xf86ReadMmio32 = readSparse32; - } - - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", - strerror(errno)); - } - -#if 0 - xf86Msg(X_INFO, "mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n", - Base, Size, flags); -#endif - - if (flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - /* This requirers linux-0.99.pl10 or above */ - - /* - * Always do DENSE mmap, since read32/write32 currently require it. - */ - ret = (unsigned long) mmap((caddr_t) (DENSE_BASE + Base), Size, - prot, MAP_SHARED, fd, (off_t) (bus_base + Base)); - - /* - * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER - * and SPARSE (which should require the use of read/write macros). - * - * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K - * bytes worth of pagetable (32 pages). - */ - if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) || - ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) { - rets = (unsigned long) mmap((caddr_t) (SPARSE_BASE + (Base << 5)), - Size << 5, prot, MAP_SHARED, fd, - (off_t) _bus_base_sparse() + (Base << 5)); - } - - close(fd); - - if (ret == (unsigned long) MAP_FAILED) { - FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n", - strerror(errno)); - } - - if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) || - ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) { - if (rets == (unsigned long) MAP_FAILED || - rets != (SPARSE_BASE + (Base << 5))) { - FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n", - strerror(errno)); - } - } - -#if 1 - if (rets) - xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx" - " to DENSE at 0x%lx and SPARSE at 0x%lx\n", - Base, Size, ret, rets); - else - xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx" - " to DENSE only at 0x%lx\n", Base, Size, ret); - -#endif - return (void *) ret; -} - -static void -unmapVidMemSparse(int ScreenNum, void *Base, unsigned long Size) -{ - unsigned long Offset = (unsigned long) Base - DENSE_BASE; - -#if 1 - xf86Msg(X_INFO, "unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n", - Base, Size); -#endif - /* Unmap DENSE always. */ - munmap((caddr_t) Base, Size); - - /* Unmap SPARSE always, and ignore error in case we did not map it. */ - munmap((caddr_t) (SPARSE_BASE + (Offset << 5)), Size << 5); -} - -static int -readSparse8(void *Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long) Base - DENSE_BASE; - shift = (Offset & 0x3) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - mem_barrier(); - result = *(vuip) (SPARSE_BASE + (Offset << 5)); - result >>= shift; - return 0xffUL & result; -} - -static int -readSparse16(void *Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long) Base - DENSE_BASE; - shift = (Offset & 0x2) << 3; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - mem_barrier(); - result = *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))); - result >>= shift; - return 0xffffUL & result; -} - -static int -readSparse32(void *Base, register unsigned long Offset) -{ - /* NOTE: this is really using DENSE. */ - mem_barrier(); - return *(vuip) ((unsigned long) Base + (Offset)); -} - -static void -writeSparse8(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - write_mem_barrier(); - Offset += (unsigned long) Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - write_mem_barrier(); - *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparse16(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - write_mem_barrier(); - Offset += (unsigned long) Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - write_mem_barrier(); - *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001; -} - -static void -writeSparse32(int Value, void *Base, register unsigned long Offset) -{ - /* NOTE: this is really using DENSE. */ - write_mem_barrier(); - *(vuip) ((unsigned long) Base + (Offset)) = Value; - return; -} - -static void -writeSparseNB8(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - Offset += (unsigned long) Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparseNB16(int Value, void *Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - Offset += (unsigned long) Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001; -} - -static void -writeSparseNB32(int Value, void *Base, register unsigned long Offset) -{ - /* NOTE: this is really using DENSE. */ - *(vuip) ((unsigned long) Base + (Offset)) = Value; - return; -} - void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset) = writeDense8; void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset) diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c deleted file mode 100644 index e000dc9c8..000000000 --- a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of David Wexelblat not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. David Wexelblat makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -#ifndef __alpha__ -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - unsigned char *ptr; - int psize; - int mlen; - - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return -1; - } - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ, - MAP_SHARED, fd, (off_t) Base); - if (ptr == MAP_FAILED) { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return -1; - } - DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); - (void) memcpy(Buf, (void *) (ptr + Offset), Len); - (void) munmap((caddr_t) ptr, mlen); - (void) close(fd); - return Len; -} - -#else /* __alpha__ */ - - /* - * We trick "mmap" into mapping BUS memory for us via BUS_BASE, - * which is the KSEG address of the start of the DENSE memory - * area. - */ - - /* - * NOTE: there prolly ought to be more validity checks and all - * re: boundaries and sizes and such... - */ - -#ifdef linux - -extern unsigned long _bus_base(void); - -#define BUS_BASE _bus_base() - -#else - -extern u_int64_t dense_base(void); - -#define BUS_BASE dense_base() - -#endif - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - caddr_t base; - int fd; - int psize; - int mlen; - - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return -1; - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - base = mmap((caddr_t) 0, mlen, PROT_READ, - MAP_SHARED, fd, (off_t) (Base + BUS_BASE)); - - if (base == MAP_FAILED) { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - return -1; - } - - xf86SlowBCopyFromBus((unsigned char *) (base + Offset), Buf, Len); - - munmap((caddr_t) base, mlen); - close(fd); - return Len; -} - -#endif /* __alpha__ */ diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c index f473293c7..a6bf677f5 100644 --- a/xorg-server/hw/xfree86/os-support/shared/vidmem.c +++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c @@ -42,119 +42,7 @@ * This file contains the common part of the video memory mapping functions */ -/* - * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold - * the MTRR option information, but it is likely to be expanded if we do - * auto unmapping of memory at VT switch. - * - */ - -typedef struct { - unsigned long size; - void *virtBase; - void *mtrrInfo; -} MappingRec, *MappingPtr; - -typedef struct { - int numMappings; - MappingPtr *mappings; - Bool mtrrEnabled; - MessageType mtrrFrom; - Bool mtrrOptChecked; - ScrnInfoPtr pScrn; -} VidMapRec, *VidMapPtr; - -static int vidMapIndex = -1; - -#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr)) - static VidMemInfo vidMemInfo = { FALSE, }; -static VidMapRec vidMapRec = { 0, NULL, TRUE, X_DEFAULT, FALSE, NULL }; - -static VidMapPtr -getVidMapRec(int scrnIndex) -{ - VidMapPtr vp; - ScrnInfoPtr pScrn; - - if ((scrnIndex < 0) || !(pScrn = xf86Screens[scrnIndex])) - return &vidMapRec; - - if (vidMapIndex < 0) - vidMapIndex = xf86AllocateScrnInfoPrivateIndex(); - - if (VIDMAPPTR(pScrn) != NULL) - return VIDMAPPTR(pScrn); - - vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1); - vp->mtrrEnabled = TRUE; /* default to enabled */ - vp->mtrrFrom = X_DEFAULT; - vp->mtrrOptChecked = FALSE; - vp->pScrn = pScrn; - return vp; -} - -static MappingPtr -newMapping(VidMapPtr vp) -{ - vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) * - (vp->numMappings + 1)); - vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1); - return vp->mappings[vp->numMappings++]; -} - -static MappingPtr -findMapping(VidMapPtr vp, void *vbase, unsigned long size) -{ - int i; - - for (i = 0; i < vp->numMappings; i++) { - if (vp->mappings[i]->virtBase == vbase && vp->mappings[i]->size == size) - return vp->mappings[i]; - } - return NULL; -} - -static void -removeMapping(VidMapPtr vp, MappingPtr mp) -{ - int i, found = 0; - - for (i = 0; i < vp->numMappings; i++) { - if (vp->mappings[i] == mp) { - found = 1; - free(vp->mappings[i]); - } - else if (found) { - vp->mappings[i - 1] = vp->mappings[i]; - } - } - vp->numMappings--; - vp->mappings[vp->numMappings] = NULL; -} - -enum { OPTION_MTRR }; - -static const OptionInfoRec opts[] = { - {OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE}, - {-1, NULL, OPTV_NONE, {0}, FALSE} -}; - -static void -checkMtrrOption(VidMapPtr vp) -{ - if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) { - OptionInfoPtr options; - - options = xnfalloc(sizeof(opts)); - (void) memcpy(options, opts, sizeof(opts)); - xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, options); - if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled)) - vp->mtrrFrom = X_CONFIG; - free(options); - vp->mtrrOptChecked = TRUE; - } -} void xf86InitVidMem(void) @@ -164,96 +52,3 @@ xf86InitVidMem(void) xf86OSInitVidMem(&vidMemInfo); } } - -void * -xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) -{ - void *vbase = NULL; - VidMapPtr vp; - MappingPtr mp; - - if (((Flags & VIDMEM_FRAMEBUFFER) && - (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)))) - FatalError("Mapping memory with more than one type\n"); - - xf86InitVidMem(); - if (!vidMemInfo.initialised || !vidMemInfo.mapMem) - return NULL; - - vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags); - - if (!vbase || vbase == (void *) -1) - return NULL; - - vp = getVidMapRec(ScreenNum); - mp = newMapping(vp); - mp->size = Size; - mp->virtBase = vbase; - - /* - * Check the "mtrr" option even when MTRR isn't supported to avoid - * warnings about unrecognised options. - */ - checkMtrrOption(vp); - - if (vp->mtrrEnabled && vidMemInfo.setWC) { - if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)) - mp->mtrrInfo = - vidMemInfo.setWC(ScreenNum, Base, Size, FALSE, vp->mtrrFrom); - else if (Flags & VIDMEM_FRAMEBUFFER) - mp->mtrrInfo = - vidMemInfo.setWC(ScreenNum, Base, Size, TRUE, vp->mtrrFrom); - } - return vbase; -} - -void -xf86UnMapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - VidMapPtr vp; - MappingPtr mp; - - if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) { - xf86DrvMsg(ScreenNum, X_WARNING, - "xf86UnMapVidMem() called before xf86MapVidMem()\n"); - return; - } - - vp = getVidMapRec(ScreenNum); - mp = findMapping(vp, Base, Size); - if (!mp) { - xf86DrvMsg(ScreenNum, X_WARNING, - "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n", - Base, Size); - return; - } - if (vp->mtrrEnabled && vidMemInfo.undoWC && mp) - vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo); - - vidMemInfo.unmapMem(ScreenNum, Base, Size); - removeMapping(vp, mp); -} - -Bool -xf86CheckMTRR(int ScreenNum) -{ - VidMapPtr vp = getVidMapRec(ScreenNum); - - /* - * Check the "mtrr" option even when MTRR isn't supported to avoid - * warnings about unrecognised options. - */ - checkMtrrOption(vp); - - if (vp->mtrrEnabled && vidMemInfo.setWC) - return TRUE; - - return FALSE; -} - -Bool -xf86LinearVidMem(void) -{ - xf86InitVidMem(); - return vidMemInfo.linearSupported; -} diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c deleted file mode 100644 index 5f2f3985e..000000000 --- a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2000 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Axp.h" - -axpParams xf86AXPParams[] = { - {SYS_NONE, 0, 0, 0} - , - {TSUNAMI, 0, 0, 0} - , - {LCA, 1 << 24, 0xf8000000, 1UL << 32} - , - {APECS, 1 << 24, 0xf8000000, 1UL << 32} - , - {T2, 0, 0xFC000000, 1UL << 31} - , - {T2_GAMMA, 0, 0xFC000000, 1UL << 31} - , - {CIA, 0, 0xE0000000, 1UL << 34} - , - {MCPCIA, 0, 0xf8000000, 1UL << 31} - , - {JENSEN, 0, 0xE000000, 1UL << 32} - , - {POLARIS, 0, 0, 0} - , - {PYXIS, 0, 0, 0} - , - {PYXIS_CIA, 0, 0xE0000000, 1UL << 34} - , - {IRONGATE, 0, 0, 0} -}; diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h deleted file mode 100644 index fded9d8c9..000000000 --- a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _XF86_AXP_H_ -#define _XF86_AXP_H_ - -typedef enum { - SYS_NONE, - TSUNAMI, - LCA, - APECS, - T2, - T2_GAMMA, - CIA, - MCPCIA, - JENSEN, - POLARIS, - PYXIS, - PYXIS_CIA, - IRONGATE -} axpDevice; - -typedef struct { - axpDevice id; - unsigned long hae_thresh; - unsigned long hae_mask; - unsigned long size; -} axpParams; - -extern axpParams xf86AXPParams[]; - -#endif diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c index fc464871d..25f76181c 100644 --- a/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c +++ b/xorg-server/hw/xfree86/os-support/solaris/sun_vid.c @@ -63,152 +63,12 @@ /* Video Memory Mapping section */ /***************************************************************************/ -static char *apertureDevName = NULL; -static int apertureDevFD_ro = -1; -static int apertureDevFD_rw = -1; - -static Bool -solOpenAperture(void) -{ - if (apertureDevName == NULL) { - apertureDevName = "/dev/xsvc"; - if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0) { - xf86MsgVerb(X_WARNING, 0, - "solOpenAperture: failed to open %s (%s)\n", - apertureDevName, strerror(errno)); - apertureDevName = "/dev/fbs/aperture"; - apertureDevFD_rw = open(apertureDevName, O_RDWR); - } - apertureDevFD_ro = open(apertureDevName, O_RDONLY); - - if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0)) { - xf86MsgVerb(X_WARNING, 0, - "solOpenAperture: failed to open %s (%s)\n", - apertureDevName, strerror(errno)); - xf86MsgVerb(X_WARNING, 0, - "solOpenAperture: either /dev/fbs/aperture" - " or /dev/xsvc required\n"); - - apertureDevName = NULL; - - if (apertureDevFD_rw >= 0) { - close(apertureDevFD_rw); - } - apertureDevFD_rw = -1; - - if (apertureDevFD_ro >= 0) { - close(apertureDevFD_ro); - } - apertureDevFD_ro = -1; - - return FALSE; - } - } - return TRUE; -} - -static void * -solMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags) -{ - void *base; - int fd; - int prot; - - if (Flags & VIDMEM_READONLY) { - fd = apertureDevFD_ro; - prot = PROT_READ; - } - else { - fd = apertureDevFD_rw; - prot = PROT_READ | PROT_WRITE; - } - - if (fd < 0) { - xf86DrvMsg(ScreenNum, X_ERROR, - "solMapVidMem: failed to open %s (%s)\n", - apertureDevName, strerror(errno)); - return NULL; - } - - base = mmap(NULL, Size, prot, MAP_SHARED, fd, (off_t) Base); - - if (base == MAP_FAILED) { - xf86DrvMsg(ScreenNum, X_ERROR, - "solMapVidMem: failed to mmap %s (0x%08lx,0x%lx) (%s)\n", - apertureDevName, Base, Size, strerror(errno)); - return NULL; - } - - return base; -} - -/* ARGSUSED */ -static void -solUnMapVidMem(int ScreenNum, void *Base, unsigned long Size) -{ - if (munmap(Base, Size) != 0) { - xf86DrvMsgVerb(ScreenNum, X_WARNING, 0, - "solUnMapVidMem: failed to unmap %s" - " (0x%p,0x%lx) (%s)\n", - apertureDevName, Base, Size, strerror(errno)); - } -} - _X_HIDDEN void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { - pVidMem->linearSupported = solOpenAperture(); - if (pVidMem->linearSupported) { - pVidMem->mapMem = solMapVidMem; - pVidMem->unmapMem = solUnMapVidMem; - } - else { - xf86MsgVerb(X_WARNING, 0, - "xf86OSInitVidMem: linear memory access disabled\n"); - } pVidMem->initialised = TRUE; } -/* - * Read BIOS via mmap()ing physical memory. - */ -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - - if (solOpenAperture() == FALSE) { - xf86Msg(X_WARNING, - "xf86ReadBIOS: Failed to open aperture to read BIOS\n"); - return -1; - } - - ptr = (unsigned char *) mmap(NULL, mlen, PROT_READ, - MAP_SHARED, apertureDevFD_ro, (off_t) Base); - if (ptr == MAP_FAILED) { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n", - apertureDevName, Base, mlen); - return -1; - } - - (void) memcpy(Buf, (void *) (ptr + Offset), Len); - if (munmap((caddr_t) ptr, mlen) != 0) { - xf86MsgVerb(X_WARNING, 0, - "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n", - apertureDevName, ptr, mlen, strerror(errno)); - } - - return Len; -} - /***************************************************************************/ /* I/O Permissions section */ /***************************************************************************/ diff --git a/xorg-server/hw/xfree86/os-support/stub/Makefile.am b/xorg-server/hw/xfree86/os-support/stub/Makefile.am index a39e17d55..19468c6de 100644 --- a/xorg-server/hw/xfree86/os-support/stub/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/stub/Makefile.am @@ -14,6 +14,5 @@ libstub_la_SOURCES = \ $(srcdir)/../shared/posix_tty.c \ $(srcdir)/../shared/sigio.c \ stub_bell.c \ - stub_bios.c \ stub_init.c \ stub_video.c diff --git a/xorg-server/hw/xfree86/os-support/stub/stub_bios.c b/xorg-server/hw/xfree86/os-support/stub/stub_bios.c deleted file mode 100644 index dbc92fcdb..000000000 --- a/xorg-server/hw/xfree86/os-support/stub/stub_bios.c +++ /dev/null @@ -1,12 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86_OSlib.h" - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - return -1; -} diff --git a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h index b56f45a3e..ce1ec33a1 100644 --- a/xorg-server/hw/xfree86/os-support/xf86OSpriv.h +++ b/xorg-server/hw/xfree86/os-support/xf86OSpriv.h @@ -32,19 +32,8 @@ #ifndef _XF86OSPRIV_H #define _XF86OSPRIV_H -typedef void *(*MapMemProcPtr) (int, unsigned long, unsigned long, int); -typedef void (*UnmapMemProcPtr) (int, void *, unsigned long); -typedef void *(*SetWCProcPtr) (int, unsigned long, unsigned long, Bool, - MessageType); -typedef void (*UndoWCProcPtr) (int, void *); - typedef struct { Bool initialised; - MapMemProcPtr mapMem; - UnmapMemProcPtr unmapMem; - SetWCProcPtr setWC; - UndoWCProcPtr undoWC; - Bool linearSupported; } VidMemInfo, *VidMemInfoPtr; void xf86OSInitVidMem(VidMemInfoPtr); diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h index 8d27e8b7b..822bab2ca 100644 --- a/xorg-server/hw/xfree86/os-support/xf86_OSproc.h +++ b/xorg-server/hw/xfree86/os-support/xf86_OSproc.h @@ -74,24 +74,6 @@ */ /* - * Flags for xf86MapVidMem(). Multiple flags can be or'd together. The - * flags may be used as hints. For example it would be permissible to - * enable write combining for memory marked only for framebuffer use. - */ - -#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */ -#define VIDMEM_MMIO 0x02 /* memory for I/O use */ -#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */ -#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */ -#define VIDMEM_SPARSE 0x10 /* sparse mapping required - * assumed when VIDMEM_MMIO is - * set. May be used with - * VIDMEM_FRAMEBUFFER) */ -#define VIDMEM_READONLY 0x20 /* read-only mapping - * used when reading BIOS images - * through xf86MapVidMem() */ - -/* * OS-independent modem state flags for xf86SetSerialModemState() and * xf86GetSerialModemState(). */ @@ -130,14 +112,6 @@ _XFUNCPROTOBEGIN /* public functions */ -extern _X_EXPORT Bool xf86LinearVidMem(void); -extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int); -extern _X_EXPORT _X_DEPRECATED void *xf86MapVidMem(int, int, unsigned long, - unsigned long); -extern _X_EXPORT _X_DEPRECATED void xf86UnMapVidMem(int, void *, - unsigned long); -extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, - int); extern _X_EXPORT Bool xf86EnableIO(void); extern _X_EXPORT void xf86DisableIO(void); |