aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/bsd/arm_video.c')
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/arm_video.c284
1 files changed, 0 insertions, 284 deletions
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;