diff options
author | Adam Jackson <ajax@redhat.com> | 2014-05-02 12:14:10 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2014-09-16 11:58:52 -0400 |
commit | 9db2af6f757ef9680c70eb731698b7c9f9aca203 (patch) | |
tree | f3eec66e6defd6d5b380784ea4d96a9fda648681 | |
parent | d3427717f2c6a473dc3d20631dff653e4e37228e (diff) |
xfree86: Remove xf86{Map,Unmap}VidMem
This API sucks. Fortunately it's mostly unused at this point. geode,
sis, and xgi need minor patches to use the corresponding pciaccess code,
neomagic will (more explicitly) lose its non-PCI support, and newport
will need to be ported to /dev/mem or the platform bus or something.
This should also make it pretty clear that alpha's sparse memory support
was basically not a thing anymore, very few tears shed.
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | hw/xfree86/os-support/bsd/alpha_video.c | 327 | ||||
-rw-r--r-- | hw/xfree86/os-support/bsd/arm_video.c | 235 | ||||
-rw-r--r-- | hw/xfree86/os-support/bsd/i386_video.c | 50 | ||||
-rw-r--r-- | hw/xfree86/os-support/bsd/ppc_video.c | 31 | ||||
-rw-r--r-- | hw/xfree86/os-support/bsd/sparc64_video.c | 31 | ||||
-rw-r--r-- | hw/xfree86/os-support/hurd/hurd_video.c | 64 | ||||
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_video.c | 369 | ||||
-rw-r--r-- | hw/xfree86/os-support/shared/vidmem.c | 118 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_vid.c | 53 | ||||
-rw-r--r-- | hw/xfree86/os-support/xf86OSpriv.h | 4 | ||||
-rw-r--r-- | hw/xfree86/os-support/xf86_OSproc.h | 22 |
11 files changed, 2 insertions, 1302 deletions
diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c index f656f5595..3aeae583b 100644 --- a/hw/xfree86/os-support/bsd/alpha_video.c +++ b/hw/xfree86/os-support/bsd/alpha_video.c @@ -35,9 +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" @@ -59,32 +56,6 @@ 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) { @@ -147,30 +118,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 */ @@ -189,11 +139,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); -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. @@ -278,13 +223,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) 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(); @@ -295,52 +236,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) 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 */ @@ -422,11 +317,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 +327,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/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c index e295c9244..95f4017f5 100644 --- a/hw/xfree86/os-support/bsd/arm_video.c +++ b/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 @@ -111,9 +82,6 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, 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. @@ -164,57 +132,10 @@ 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 */ @@ -258,162 +179,6 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, 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/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c index 745319054..cc84f44b8 100644 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ b/hw/xfree86/os-support/bsd/i386_video.c @@ -85,9 +85,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 *); @@ -189,8 +186,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) { checkDevMem(TRUE); pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; if (useDevMem) pci_system_init_dev_mem(devMemFd); @@ -210,51 +205,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) 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)", - 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 */ diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c index 3fd28c3b5..a624d4dd1 100644 --- a/hw/xfree86/os-support/bsd/ppc_video.c +++ b/hw/xfree86/os-support/bsd/ppc_video.c @@ -44,9 +44,6 @@ #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); @@ -54,40 +51,12 @@ 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) diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c index 02951d602..3fd031533 100644 --- a/hw/xfree86/os-support/bsd/sparc64_video.c +++ b/hw/xfree86/os-support/bsd/sparc64_video.c @@ -38,44 +38,13 @@ /* 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) diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c index dc1a8e670..6485917a0 100644 --- a/hw/xfree86/os-support/hurd/hurd_video.c +++ b/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 @@ -147,7 +85,5 @@ void xf86OSInitVidMem(VidMemInfoPtr pVidMem) { pVidMem->linearSupported = TRUE; - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; pVidMem->initialised = TRUE; } diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c index ffffc81c5..7389d48a7 100644 --- a/hw/xfree86/os-support/linux/lnx_video.c +++ b/hw/xfree86/os-support/linux/lnx_video.c @@ -82,17 +82,12 @@ extern int iopl(int __level); /* 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; @@ -374,17 +369,10 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) } 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 @@ -394,83 +382,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem) 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 +476,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 +486,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/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c index f473293c7..1c695fe2c 100644 --- a/hw/xfree86/os-support/shared/vidmem.c +++ b/hw/xfree86/os-support/shared/vidmem.c @@ -50,14 +50,6 @@ */ typedef struct { - unsigned long size; - void *virtBase; - void *mtrrInfo; -} MappingRec, *MappingPtr; - -typedef struct { - int numMappings; - MappingPtr *mappings; Bool mtrrEnabled; MessageType mtrrFrom; Bool mtrrOptChecked; @@ -69,7 +61,7 @@ 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 VidMapRec vidMapRec = { TRUE, X_DEFAULT, FALSE, NULL }; static VidMapPtr getVidMapRec(int scrnIndex) @@ -94,45 +86,6 @@ getVidMapRec(int scrnIndex) 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[] = { @@ -165,75 +118,6 @@ xf86InitVidMem(void) } } -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) { diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c index fc464871d..1526ae72b 100644 --- a/hw/xfree86/os-support/solaris/sun_vid.c +++ b/hw/xfree86/os-support/solaris/sun_vid.c @@ -107,62 +107,11 @@ solOpenAperture(void) 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 { + if (!pVidMem->linearSupported) { xf86MsgVerb(X_WARNING, 0, "xf86OSInitVidMem: linear memory access disabled\n"); } diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h index b56f45a3e..c586c7a8b 100644 --- a/hw/xfree86/os-support/xf86OSpriv.h +++ b/hw/xfree86/os-support/xf86OSpriv.h @@ -32,16 +32,12 @@ #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; diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h index 8d27e8b7b..747803cc7 100644 --- a/hw/xfree86/os-support/xf86_OSproc.h +++ b/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(). */ @@ -132,10 +114,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); |