diff options
author | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2009-06-28 22:07:26 +0000 |
commit | 3562e78743202e43aec8727005182a2558117eca (patch) | |
tree | 8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/hw/xfree86/os-support/sysv/sysv_video.c | |
download | vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2 vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip |
Checked in the following released items:
xkeyboard-config-1.4.tar.gz
ttf-bitstream-vera-1.10.tar.gz
font-alias-1.0.1.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sun-misc-1.0.0.tar.gz
font-sony-misc-1.0.0.tar.gz
font-schumacher-misc-1.0.0.tar.gz
font-mutt-misc-1.0.0.tar.gz
font-misc-misc-1.0.0.tar.gz
font-misc-meltho-1.0.0.tar.gz
font-micro-misc-1.0.0.tar.gz
font-jis-misc-1.0.0.tar.gz
font-isas-misc-1.0.0.tar.gz
font-dec-misc-1.0.0.tar.gz
font-daewoo-misc-1.0.0.tar.gz
font-cursor-misc-1.0.0.tar.gz
font-arabic-misc-1.0.0.tar.gz
font-winitzki-cyrillic-1.0.0.tar.gz
font-misc-cyrillic-1.0.0.tar.gz
font-cronyx-cyrillic-1.0.0.tar.gz
font-screen-cyrillic-1.0.1.tar.gz
font-xfree86-type1-1.0.1.tar.gz
font-adobe-utopia-type1-1.0.1.tar.gz
font-ibm-type1-1.0.0.tar.gz
font-bitstream-type1-1.0.0.tar.gz
font-bitstream-speedo-1.0.0.tar.gz
font-bh-ttf-1.0.0.tar.gz
font-bh-type1-1.0.0.tar.gz
font-bitstream-100dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz
font-bh-100dpi-1.0.0.tar.gz
font-adobe-utopia-100dpi-1.0.1.tar.gz
font-adobe-100dpi-1.0.0.tar.gz
font-util-1.0.1.tar.gz
font-bitstream-75dpi-1.0.0.tar.gz
font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz
font-adobe-utopia-75dpi-1.0.1.tar.gz
font-bh-75dpi-1.0.0.tar.gz
bdftopcf-1.0.1.tar.gz
font-adobe-75dpi-1.0.0.tar.gz
mkfontscale-1.0.6.tar.gz
openssl-0.9.8k.tar.gz
bigreqsproto-1.0.2.tar.gz
xtrans-1.2.2.tar.gz
resourceproto-1.0.2.tar.gz
inputproto-1.4.4.tar.gz
compositeproto-0.4.tar.gz
damageproto-1.1.0.tar.gz
zlib-1.2.3.tar.gz
xkbcomp-1.0.5.tar.gz
freetype-2.3.9.tar.gz
pthreads-w32-2-8-0-release.tar.gz
pixman-0.12.0.tar.gz
kbproto-1.0.3.tar.gz
evieext-1.0.2.tar.gz
fixesproto-4.0.tar.gz
recordproto-1.13.2.tar.gz
randrproto-1.2.2.tar.gz
scrnsaverproto-1.1.0.tar.gz
renderproto-0.9.3.tar.gz
xcmiscproto-1.1.2.tar.gz
fontsproto-2.0.2.tar.gz
xextproto-7.0.3.tar.gz
xproto-7.0.14.tar.gz
libXdmcp-1.0.2.tar.gz
libxkbfile-1.0.5.tar.gz
libfontenc-1.0.4.tar.gz
libXfont-1.3.4.tar.gz
libX11-1.1.5.tar.gz
libXau-1.0.4.tar.gz
libxcb-1.1.tar.gz
xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/sysv/sysv_video.c')
-rw-r--r-- | xorg-server/hw/xfree86/os-support/sysv/sysv_video.c | 367 |
1 files changed, 367 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c new file mode 100644 index 000000000..9972bcaa4 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c @@ -0,0 +1,367 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * 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 names of Thomas Roell and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR 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> + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +#ifndef SI86IOPL +#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL) +#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0) +#else +#define SET_IOPL() sysi86(SI86IOPL,3) +#define RESET_IOPL() sysi86(SI86IOPL,0) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +/* + * XXX Support for SVR3 will need to be reworked if needed. In particular + * the Region parameter is no longer passed, and will need to be dealt + * with internally if required. + * OK, i'll rework that thing ... (clean it up a lot) + * SVR3 Support only with SVR3_MMAPDRV (mr) + * + */ + +#ifdef HAS_SVR3_MMAPDRV +#ifndef MMAP_DEBUG +#define MMAP_DEBUG 3 +#endif + +struct kd_memloc MapDSC; +int mmapFd = -2; + +static int +mmapStat(pointer Base, unsigned long Size) { + + int nmmreg,i=0,region=-1; + mmapinfo_t *ibuf; + + nmmreg = ioctl(mmapFd, GETNMMREG); + + if(nmmreg <= 0) + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "\nNo physical memory mapped currently.\n\n"); + else { + if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL) + xf86Msg(X_WARNING, + "Couldn't allocate memory 4 mmapinfo_t\n"); + else { + if(ioctl(mmapFd, GETMMREG, ibuf) != -1) + { + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# mmapStat: [Size=%x,Base=%x]\n", Size, Base); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# Physical Address Size Reference Count\n"); + for(i = 0; i < nmmreg; i++) { + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "%-4d 0x%08X %5dk %5d ", + i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt); + if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) { + xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!"); + if (region==-1) region=i; + } + xf86ErrorFVerb(MMAP_DEBUG, "\n"); + } + xf86ErrorFVerb(MMAP_DEBUG, "\n"); + } + free(ibuf); + } + } + if (region == -1 && nmmreg > 0) region=region * i; + return(region); +} +#endif + + +static Bool +linearVidMem() +{ +#ifdef SVR4 + return TRUE; +#elif defined(HAS_SVR3_MMAPDRV) + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# xf86LinearVidMem: MMAP 2.2.2 called\n"); + + if(mmapFd >= 0) return TRUE; + + if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) + { + if(ioctl(mmapFd, GETVERSION) < 0x0222) { + xf86Msg(X_WARNING, + "xf86LinearVidMem: MMAP 2.2.2 or above required\n"); + xf86ErrorF("\tlinear memory access disabled\n"); + return FALSE; + } + return TRUE; + } + xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n", + strerror(errno)); + xf86ErrorF("\tlinear memory access disabled\n"); + return FALSE; +#endif +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + int fd; + +#if defined(SVR4) + fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 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_SHARED, fd, (off_t)Base); + close(fd); + if (base == MAP_FAILED) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + } +#else /* SVR4 */ +#ifdef HAS_SVR3_MMAPDRV + + xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n"); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); + if (ioctl(mmapFd, GETVERSION) == -1) + { + xf86LinearVidMem(); + } + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: Screen: %d\n", ScreenNum); + mmapStat(Base,Size); + /* To force the MMAP driver to provide the address */ + base = (pointer)0; + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base); + MapDSC.vaddr = (char *)base; + MapDSC.physaddr = (char *)Base; + MapDSC.length = Size; + MapDSC.ioflg = 1; + if(mmapFd >= 0) + { + if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + /* NOTREACHED */ + } + + /* Next time we want the same address! */ + MapDSC.vaddr = (char *)base; + } + + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "MapDSC.length : %d\n", MapDSC.length); + mmapStat(Base,Size); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n"); +#endif /* HAS_SVR3_MMAPDRV */ +#endif /* SVR4 */ + return(base); +} + +/* ARGSUSED */ +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ +#if defined (SVR4) + munmap(Base, Size); +#else /* SVR4 */ +#ifdef HAS_SVR3_MMAPDRV + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# xf86UnMapVidMem: UNMapping FrameBuffer\n"); + mmapStat(Base,Size); + ioctl(mmapFd, UNMAPRM , Base); + mmapStat(Base,Size); + xf86MsgVerb(X_INFO, MMAP_DEBUG, + "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base); +#endif /* HAS_SVR3_MMAPDRV */ +#endif /* SVR4 */ + return; +} + +#if defined(SVR4) && defined(__i386__) && !defined(sun) +/* + * For some SVR4 versions, a 32-bit read is done for the first location + * in each page when the page is first mapped. If this is done while + * memory access is enabled for regions that have read side-effects, + * this can cause unexpected results, including lockups on some hardware. + * This function is called to make sure each page is mapped while it is + * safe to do so. + */ + +/* + * XXX Should get this the correct way (see os/xalloc.c), but since this is + * for one platform I'll be lazy. + */ +#define X_PAGE_SIZE 4096 + +static void +readSideEffects(int ScreenNum, pointer Base, unsigned long Size) +{ + unsigned long base, end, addr; + CARD32 val; + + base = (unsigned long)Base; + end = base + Size; + + for (addr = base; addr < end; addr += X_PAGE_SIZE) + val = *(volatile CARD32 *)addr; +} +#endif + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = linearVidMem(); + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; +#if defined(SVR4) && defined(__i386__) && !defined(sun) + pVidMem->readSideEffects = readSideEffects; +#endif + pVidMem->initialised = TRUE; +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +_X_EXPORT Bool +xf86EnableIO() +{ + int i; + + if (ExtendedEnabled) + return TRUE; + + if (SET_IOPL() < 0) + { + xf86Msg(X_WARNING, + "xf86EnableIO: Failed to set IOPL for extended I/O\n"); + return FALSE; + } + ExtendedEnabled = TRUE; + + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + RESET_IOPL(); + ExtendedEnabled = FALSE; + + return; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + if (!ExtendedEnabled) + { + if (SET_IOPL() < 0) + { + return(FALSE); + } + } + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + { + RESET_IOPL(); + } + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + if (!ExtendedEnabled) + { + if (SET_IOPL() < 0) + { + return; + } + } + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + { + RESET_IOPL(); + } + return; +} |