From 3562e78743202e43aec8727005182a2558117eca Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 28 Jun 2009 22:07:26 +0000 Subject: 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 --- .../hw/xfree86/os-support/shared/VTsw_noop.c | 54 ++ .../hw/xfree86/os-support/shared/VTsw_usl.c | 90 +++ .../hw/xfree86/os-support/shared/agp_noop.c | 103 ++++ .../hw/xfree86/os-support/shared/bios_devmem.c | 75 +++ .../hw/xfree86/os-support/shared/bios_mmap.c | 162 +++++ xorg-server/hw/xfree86/os-support/shared/ia64Pci.c | 188 ++++++ xorg-server/hw/xfree86/os-support/shared/inout.S | 111 ++++ .../hw/xfree86/os-support/shared/ioperm_noop.c | 49 ++ .../hw/xfree86/os-support/shared/kmod_noop.c | 38 ++ xorg-server/hw/xfree86/os-support/shared/pm_noop.c | 47 ++ .../hw/xfree86/os-support/shared/posix_tty.c | 686 +++++++++++++++++++++ xorg-server/hw/xfree86/os-support/shared/sigio.c | 282 +++++++++ .../hw/xfree86/os-support/shared/sigiostubs.c | 71 +++ .../hw/xfree86/os-support/shared/stdResource.c | 116 ++++ xorg-server/hw/xfree86/os-support/shared/vidmem.c | 296 +++++++++ xorg-server/hw/xfree86/os-support/shared/xf86Axp.c | 49 ++ xorg-server/hw/xfree86/os-support/shared/xf86Axp.h | 34 + 17 files changed, 2451 insertions(+) create mode 100644 xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/agp_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/bios_devmem.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/bios_mmap.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/ia64Pci.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/inout.S create mode 100644 xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/kmod_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/pm_noop.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/posix_tty.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/sigio.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/sigiostubs.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/stdResource.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/vidmem.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/xf86Axp.c create mode 100644 xorg-server/hw/xfree86/os-support/shared/xf86Axp.h (limited to 'xorg-server/hw/xfree86/os-support/shared') diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c new file mode 100644 index 000000000..a3cfe40b9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c @@ -0,0 +1,54 @@ +/* + * Copyright 1993 by David Wexelblat + * + * 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 +#endif + +#include + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * No-op functions for OSs without VTs + */ + +Bool +xf86VTSwitchPending() +{ + return(FALSE); +} + +Bool +xf86VTSwitchAway() +{ + return(FALSE); +} + +Bool +xf86VTSwitchTo() +{ + return(TRUE); +} diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c new file mode 100644 index 000000000..4d473147f --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c @@ -0,0 +1,90 @@ +/* + * Copyright 1993 by David Wexelblat + * + * 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 +#endif + +#include + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef OSHEADER +# include OSHEADER +#endif + +/* + * Handle the VT-switching interface for OSs that use USL-style ioctl()s + * (the sysv, sco, and linux subdirs). + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void +xf86VTRequest(int sig) +{ + signal(sig, (void(*)(int))xf86VTRequest); + xf86Info.vtRequestsPending = TRUE; + return; +} + +Bool +xf86VTSwitchPending() +{ + return(xf86Info.vtRequestsPending ? TRUE : FALSE); +} + +Bool +xf86VTSwitchAway() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + { + return(FALSE); + } + else + { +#ifdef OSSWITCHAWAY + OSSWITCHAWAY; +#endif + return(TRUE); + } +} + +Bool +xf86VTSwitchTo() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + { + return(FALSE); + } + else + { + return(TRUE); + } +} diff --git a/xorg-server/hw/xfree86/os-support/shared/agp_noop.c b/xorg-server/hw/xfree86/os-support/shared/agp_noop.c new file mode 100644 index 000000000..5774bc231 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/agp_noop.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2000-2003 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). + */ + +/* + * Abstraction of the AGP GART interface. Stubs for platforms without + * AGP GART support. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +_X_EXPORT Bool +xf86GARTCloseScreen(int screenNum) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86AgpGARTSupported() +{ + return FALSE; +} + +_X_EXPORT AgpInfoPtr +xf86GetAGPInfo(int screenNum) +{ + return NULL; +} + +_X_EXPORT Bool +xf86AcquireGART(int screenNum) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86ReleaseGART(int screenNum) +{ + return FALSE; +} + +_X_EXPORT int +xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, + unsigned long *physical) +{ + return -1; +} + +_X_EXPORT Bool +xf86DeallocateGARTMemory(int screenNum, int key) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86BindGARTMemory(int screenNum, int key, unsigned long offset) +{ + return FALSE; +} + + +_X_EXPORT Bool +xf86UnbindGARTMemory(int screenNum, int key) +{ + return FALSE; +} + +_X_EXPORT Bool +xf86EnableAGP(int screenNum, CARD32 mode) +{ + return FALSE; +} diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c new file mode 100644 index 000000000..7288239be --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c @@ -0,0 +1,75 @@ +/* + * Copyright 1993 by David Wexelblat + * + * 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 +#endif + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include + +/* + * Read BIOS via /dev/mem. + */ + +#ifndef DEV_MEM +# define DEV_MEM "/dev/mem" +#endif + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int fd; + +#ifdef __ia64__ + if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) +#else + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) +#endif + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + return(-1); + } + + if (lseek(fd, (Base+Offset), SEEK_SET) < 0) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n", + DEV_MEM, strerror(errno)); + close(fd); + return(-1); + } + if (read(fd, Buf, Len) != Len) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n", + DEV_MEM, strerror(errno)); + close(fd); + return(-1); + } + close(fd); + return(Len); +} diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c new file mode 100644 index 000000000..8bac87ebe --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c @@ -0,0 +1,162 @@ +/* + * Copyright 1993 by David Wexelblat + * + * 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 +#endif + +#include + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +#ifndef __alpha__ +_X_EXPORT 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); + } +#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); + (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... + */ + +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef linux + +#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ +#define SPARSE (5) +#define isJensen (1) +#else +#define isJensen (!_bus_base()) +#define SPARSE (7) +#endif + +extern unsigned long _bus_base(void); +extern unsigned long _bus_base_sparse(void); +#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base()) +#define JENSEN_SHIFT(x) (isJensen ? ((long)x< +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "compiler.h" +#include "Pci.h" + +/* + * We use special in/out routines here since Altix platforms require the + * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O + * space of a given PCI domain; reads and writes are used to do port I/O. + * The file descriptor for the file is stored in the upper bits of the + * value passed in by the caller, and is created and populated by + * xf86MapLegacyIO. + * + * If the legacy_io interface doesn't exist, we fall back to the glibc in/out + * routines, which are prefixed by an underscore (e.g. _outb). + */ +static int ia64_port_to_fd(unsigned long port) +{ + return (port >> 24) & 0xffffffff; +} + +_X_EXPORT void outb(unsigned long port, unsigned char val) +{ + int fd = ia64_port_to_fd(port); + + if (!fd) { + _outb(val, port & 0xffff); + goto out; + } + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + goto out; + } + if (write(fd, &val, 1) != 1) { + ErrorF("I/O write failed\n"); + goto out; + } + out: + return; +} + +_X_EXPORT void outw(unsigned long port, unsigned short val) +{ + int fd = ia64_port_to_fd(port); + + if (!fd) { + _outw(val, port & 0xffff); + goto out; + } + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + goto out; + } + if (write(fd, &val, 2) != 2) { + ErrorF("I/O write failed\n"); + goto out; + } + out: + return; +} + +_X_EXPORT void outl(unsigned long port, unsigned int val) +{ + int fd = ia64_port_to_fd(port); + + if (!fd) { + _outl(val, port & 0xffff); + goto out; + } + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + goto out; + } + if (write(fd, &val, 4) != 4) { + ErrorF("I/O write failed\n"); + goto out; + } + out: + return; +} + +_X_EXPORT unsigned int inb(unsigned long port) +{ + int fd = ia64_port_to_fd(port); + unsigned char val; + + if (!fd) + return _inb(port & 0xffff); + + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + val = -1; + goto out; + } + if (read(fd, &val, 1) != 1) { + ErrorF("I/O read failed\n"); + val = -1; + goto out; + } + out: + return val; +} + +_X_EXPORT unsigned int inw(unsigned long port) +{ + int fd = ia64_port_to_fd(port); + unsigned short val; + + if (!fd) + return _inw(port & 0xffff); + + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + val = -1; + goto out; + } + if (read(fd, &val, 2) != 2) { + ErrorF("I/O read failed\n"); + val = -1; + goto out; + } + out: + return val; +} + +_X_EXPORT unsigned int inl(unsigned long port) +{ + int fd = ia64_port_to_fd(port); + unsigned int val; + + if (!fd) + return _inl(port & 0xffff); + + if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { + ErrorF("I/O lseek failed\n"); + val = -1; + goto out; + } + if (read(fd, &val, 4) != 4) { + ErrorF("I/O read failed\n"); + val = -1; + goto out; + } + out: + return val; +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/inout.S b/xorg-server/hw/xfree86/os-support/shared/inout.S new file mode 100644 index 000000000..80c47c419 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/inout.S @@ -0,0 +1,111 @@ +/* $XConsortium: inout.s /main/6 1996/02/21 17:53:35 kaleb $ */ + + + + + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/inout.S,v 1.1 1999/07/10 07:24:52 dawes Exp $ */ + +#include "assyntax.h" + +/* + * Make i80386 io primitives available at C-level. + */ + + FILE("inout.s") + AS_BEGIN + SEG_TEXT + +/* + *----------------------------------------------------------------------- + * inb --- + * Input one byte. + * + * Results: + * Byte in al. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(inb) +GLNAME(inb): + MOV_L (REGOFF(4,ESP),EDX) + SUB_L (EAX,EAX) + IN_B + RET + +/* + *----------------------------------------------------------------------- + * outb --- + * Output one byte. + * + * Results: + * None. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(outb) +GLNAME(outb): + MOV_L (REGOFF(4,sp),EDX) + MOV_L (REGOFF(8,sp),EAX) + OUT_B + RET +/* + *----------------------------------------------------------------------- + * inw --- + * Input one 16-bit word. + * + * Results: + * Word in ax. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(inw) +GLNAME(inw): + MOV_L (REGOFF(4,ESP),EDX) + IN_W + RET + +/* + *----------------------------------------------------------------------- + * outw --- + * Output one 16-bit word. + * + * Results: + * None. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(outw) +GLNAME(outw): + MOV_L (REGOFF(4,ESP),EDX) + MOV_L (REGOFF(8,ESP),EAX) + OUT_W + RET + +/* + *----------------------------------------------------------------------- + * inl --- + * Input one 32-bit longword. + * + * Results: + * Word in eax. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(inl) +GLNAME(inl): + MOV_L (REGOFF(4,ESP),EDX) + IN_L + RET + +/* + *----------------------------------------------------------------------- + * outl --- + * Output one 32-bit longword. + * + * Results: + * None. + *----------------------------------------------------------------------- + */ + GLOBL GLNAME(outl) +GLNAME(outl): + MOV_L (REGOFF(4,ESP),EDX) + MOV_L (REGOFF(8,ESP),EAX) + OUT_L + RET + diff --git a/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c b/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c new file mode 100644 index 000000000..1d7851a5b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/ioperm_noop.c @@ -0,0 +1,49 @@ +/* + * Copyright 1993 by David Wexelblat + * + * 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. + * + */ + +/* + * Some platforms don't bother with I/O permissions, + * or the permissions are implicit with opening/enabling the console. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +_X_EXPORT Bool +xf86EnableIO() +{ + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + return; +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c b/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c new file mode 100644 index 000000000..6525e8414 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/kmod_noop.c @@ -0,0 +1,38 @@ +/* + * 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 +#endif + +#include "xf86_OSproc.h" + +_X_EXPORT int xf86LoadKernelModule(const char *pathname) +{ + (void) pathname; + return 0; /* failure */ +} diff --git a/xorg-server/hw/xfree86/os-support/shared/pm_noop.c b/xorg-server/hw/xfree86/os-support/shared/pm_noop.c new file mode 100644 index 000000000..bfac4b1c8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/pm_noop.c @@ -0,0 +1,47 @@ +/* + * 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). + */ + +/* Stubs for the OS-support layer power-management functions. */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" + +PMClose +xf86OSPMOpen(void) +{ + return NULL; +} + + diff --git a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c new file mode 100644 index 000000000..002e3a275 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c @@ -0,0 +1,686 @@ +/* + * Copyright 1993-2003 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 XFREE86 PROJECT 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 XFree86 Project 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 + * XFree86 Project. + */ +/* + * + * Copyright (c) 1997 Metro Link Incorporated + * + * 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 X CONSORTIUM 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 Metro Link shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Metro Link. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static int +GetBaud (int baudrate) +{ +#ifdef B300 + if (baudrate == 300) + return B300; +#endif +#ifdef B1200 + if (baudrate == 1200) + return B1200; +#endif +#ifdef B2400 + if (baudrate == 2400) + return B2400; +#endif +#ifdef B4800 + if (baudrate == 4800) + return B4800; +#endif +#ifdef B9600 + if (baudrate == 9600) + return B9600; +#endif +#ifdef B19200 + if (baudrate == 19200) + return B19200; +#endif +#ifdef B38400 + if (baudrate == 38400) + return B38400; +#endif +#ifdef B57600 + if (baudrate == 57600) + return B57600; +#endif +#ifdef B115200 + if (baudrate == 115200) + return B115200; +#endif +#ifdef B230400 + if (baudrate == 230400) + return B230400; +#endif +#ifdef B460800 + if (baudrate == 460800) + return B460800; +#endif + return (0); +} + +_X_EXPORT int +xf86OpenSerial (pointer options) +{ +#ifdef Lynx + struct sgttyb ms_sgtty; +#endif + struct termios t; + int fd, i; + char *dev; + + dev = xf86SetStrOption (options, "Device", NULL); + if (!dev) + { + xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n"); + return (-1); + } + + SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK)); + if (fd == -1) + { + xf86Msg (X_ERROR, + "xf86OpenSerial: Cannot open device %s\n\t%s.\n", + dev, strerror (errno)); + xfree(dev); + return (-1); + } + + if (!isatty (fd)) + { +#if 1 + /* Allow non-tty devices to be opened. */ + xfree(dev); + return (fd); +#else + xf86Msg (X_WARNING, + "xf86OpenSerial: Specified device %s is not a tty\n", + dev); + SYSCALL (close (fd)); + errno = EINVAL; + xfree(dev); + return (-1); +#endif + } + +#ifdef Lynx + /* LynxOS does not assert DTR without this */ + ioctl (fd, TIOCGETP, (char *) &ms_sgtty); + ioctl (fd, TIOCSDTR, (char *) &ms_sgtty); +#endif + + /* set up default port parameters */ + SYSCALL (tcgetattr (fd, &t)); + t.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\ + |IGNCR|ICRNL|IXON); + t.c_oflag &= ~OPOST; + t.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t.c_cflag &= ~(CSIZE|PARENB); + t.c_cflag |= CS8|CLOCAL; + + cfsetispeed (&t, B9600); + cfsetospeed (&t, B9600); + t.c_cc[VMIN] = 1; + t.c_cc[VTIME] = 0; + + SYSCALL (tcsetattr (fd, TCSANOW, &t)); + + if (xf86SetSerial (fd, options) == -1) + { + SYSCALL (close (fd)); + xfree(dev); + return (-1); + } + + SYSCALL (i = fcntl (fd, F_GETFL, 0)); + if (i == -1) + { + SYSCALL (close (fd)); + xfree(dev); + return (-1); + } + i &= ~O_NONBLOCK; + SYSCALL (i = fcntl (fd, F_SETFL, i)); + if (i == -1) + { + SYSCALL (close (fd)); + xfree(dev); + return (-1); + } + xfree(dev); + return (fd); +} + +_X_EXPORT int +xf86SetSerial (int fd, pointer options) +{ + struct termios t; + int val; + const char *s; + int baud, r; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + + SYSCALL (tcgetattr (fd, &t)); + + if ((val = xf86SetIntOption (options, "BaudRate", 0))) + { + if ((baud = GetBaud (val))) + { + cfsetispeed (&t, baud); + cfsetospeed (&t, baud); + } + else + { + xf86Msg (X_ERROR, + "Invalid Option BaudRate value: %d\n", val); + return (-1); + } + } + + if ((val = xf86SetIntOption (options, "StopBits", 0))) + { + switch (val) + { + case 1: + t.c_cflag &= ~(CSTOPB); + break; + case 2: + t.c_cflag |= CSTOPB; + break; + default: + xf86Msg (X_ERROR, + "Invalid Option StopBits value: %d\n", val); + return (-1); + break; + } + } + + if ((val = xf86SetIntOption (options, "DataBits", 0))) + { + switch (val) + { + case 5: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS5; + break; + case 6: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS6; + break; + case 7: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS7; + break; + case 8: + t.c_cflag &= ~(CSIZE); + t.c_cflag |= CS8; + break; + default: + xf86Msg (X_ERROR, + "Invalid Option DataBits value: %d\n", val); + return (-1); + break; + } + } + + if ((s = xf86SetStrOption (options, "Parity", NULL))) + { + if (xf86NameCmp (s, "Odd") == 0) + { + t.c_cflag |= PARENB | PARODD; + } + else if (xf86NameCmp (s, "Even") == 0) + { + t.c_cflag |= PARENB; + t.c_cflag &= ~(PARODD); + } + else if (xf86NameCmp (s, "None") == 0) + { + t.c_cflag &= ~(PARENB); + } + else + { + xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n", + s); + return (-1); + } + } + + if ((val = xf86SetIntOption (options, "Vmin", -1)) != -1) + { + t.c_cc[VMIN] = val; + } + if ((val = xf86SetIntOption (options, "Vtime", -1)) != -1) + { + t.c_cc[VTIME] = val; + } + + if ((s = xf86SetStrOption (options, "FlowControl", NULL))) + { + xf86MarkOptionUsedByName (options, "FlowControl"); + if (xf86NameCmp (s, "Xoff") == 0) + { + t.c_iflag |= IXOFF; + } + else if (xf86NameCmp (s, "Xon") == 0) + { + t.c_iflag |= IXON; + } + else if (xf86NameCmp (s, "XonXoff") == 0) + { + t.c_iflag |= IXON|IXOFF; + } + else if (xf86NameCmp (s, "None") == 0) + { + t.c_iflag &= ~(IXON | IXOFF); + } + else + { + xf86Msg (X_ERROR, + "Invalid Option FlowControl value: %s\n", s); + return (-1); + } + } + + if ((xf86SetBoolOption (options, "ClearDTR", FALSE))) + { +#ifdef CLEARDTR_SUPPORT +# if !defined(Lynx) || defined(TIOCMBIC) + val = TIOCM_DTR; + SYSCALL (ioctl(fd, TIOCMBIC, &val)); +# else + SYSCALL (ioctl(fd, TIOCCDTR, NULL)); +# endif +#else + xf86Msg (X_WARNING, + "Option ClearDTR not supported on this OS\n"); + return (-1); +#endif + xf86MarkOptionUsedByName (options, "ClearDTR"); + } + + if ((xf86SetBoolOption (options, "ClearRTS", FALSE))) + { +#ifdef CLEARRTS_SUPPORT + val = TIOCM_RTS; + SYSCALL (ioctl(fd, TIOCMBIC, &val)); +#else + xf86Msg (X_WARNING, + "Option ClearRTS not supported on this OS\n"); + return (-1); +#endif + xf86MarkOptionUsedByName (options, "ClearRTS"); + } + + SYSCALL (r = tcsetattr (fd, TCSANOW, &t)); + return (r); +} + +_X_EXPORT int +xf86SetSerialSpeed (int fd, int speed) +{ + struct termios t; + int baud, r; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + + SYSCALL (tcgetattr (fd, &t)); + + if ((baud = GetBaud (speed))) + { + cfsetispeed (&t, baud); + cfsetospeed (&t, baud); + } + else + { + xf86Msg (X_ERROR, + "Invalid Option BaudRate value: %d\n", speed); + return (-1); + } + + SYSCALL (r = tcsetattr (fd, TCSANOW, &t)); + return (r); +} + +_X_EXPORT int +xf86ReadSerial (int fd, void *buf, int count) +{ + int r; +#ifdef DEBUG + int i; +#endif + SYSCALL (r = read (fd, buf, count)); +#ifdef DEBUG + ErrorF("ReadingSerial: 0x%x", + (unsigned char)*(((unsigned char *)buf))); + for (i = 1; i < r; i++) + ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i)); + ErrorF("\n"); +#endif + return (r); +} + +_X_EXPORT int +xf86WriteSerial (int fd, const void *buf, int count) +{ + int r; +#ifdef DEBUG + int i; + + ErrorF("WritingSerial: 0x%x",(unsigned char)*(((unsigned char *)buf))); + for (i = 1; i < count; i++) + ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i)); + ErrorF("\n"); +#endif + SYSCALL (r = write (fd, buf, count)); + return (r); +} + +_X_EXPORT int +xf86CloseSerial (int fd) +{ + int r; + + SYSCALL (r = close (fd)); + return (r); +} + +_X_EXPORT int +xf86WaitForInput (int fd, int timeout) +{ + fd_set readfds; + struct timeval to; + int r; + + FD_ZERO(&readfds); + + if (fd >= 0) { + FD_SET(fd, &readfds); + } + + to.tv_sec = timeout / 1000000; + to.tv_usec = timeout % 1000000; + + if (fd >= 0) { + SYSCALL (r = select (FD_SETSIZE, &readfds, NULL, NULL, &to)); + } + else { + SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to)); + } + xf86ErrorFVerb (9,"select returned %d\n", r); + return (r); +} + +_X_EXPORT int +xf86SerialSendBreak (int fd, int duration) +{ + int r; + + SYSCALL (r = tcsendbreak (fd, duration)); + return (r); + +} + +_X_EXPORT int +xf86FlushInput(int fd) +{ + fd_set fds; + struct timeval timeout; + char c[4]; + +#ifdef DEBUG + ErrorF("FlushingSerial\n"); +#endif + if (tcflush(fd, TCIFLUSH) == 0) + return 0; + + timeout.tv_sec = 0; + timeout.tv_usec = 0; + FD_ZERO(&fds); + FD_SET(fd, &fds); + while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) { + if (read(fd, &c, sizeof(c)) < 1) + return 0; + FD_ZERO(&fds); + FD_SET(fd, &fds); + } + return 0; +} + +static struct states { + int xf; + int os; +} modemStates[] = { +#ifdef TIOCM_LE + { XF86_M_LE, TIOCM_LE }, +#endif +#ifdef TIOCM_DTR + { XF86_M_DTR, TIOCM_DTR }, +#endif +#ifdef TIOCM_RTS + { XF86_M_RTS, TIOCM_RTS }, +#endif +#ifdef TIOCM_ST + { XF86_M_ST, TIOCM_ST }, +#endif +#ifdef TIOCM_SR + { XF86_M_SR, TIOCM_SR }, +#endif +#ifdef TIOCM_CTS + { XF86_M_CTS, TIOCM_CTS }, +#endif +#ifdef TIOCM_CAR + { XF86_M_CAR, TIOCM_CAR }, +#elif defined(TIOCM_CD) + { XF86_M_CAR, TIOCM_CD }, +#endif +#ifdef TIOCM_RNG + { XF86_M_RNG, TIOCM_RNG }, +#elif defined(TIOCM_RI) + { XF86_M_CAR, TIOCM_RI }, +#endif +#ifdef TIOCM_DSR + { XF86_M_DSR, TIOCM_DSR }, +#endif +}; + +static int numStates = sizeof(modemStates) / sizeof(modemStates[0]); + +static int +xf2osState(int state) +{ + int i; + int ret = 0; + + for (i = 0; i < numStates; i++) + if (state & modemStates[i].xf) + ret |= modemStates[i].os; + return ret; +} + +static int +os2xfState(int state) +{ + int i; + int ret = 0; + + for (i = 0; i < numStates; i++) + if (state & modemStates[i].os) + ret |= modemStates[i].xf; + return ret; +} + +static int +getOsStateMask(void) +{ + int i; + int ret = 0; + for (i = 0; i < numStates; i++) + ret |= modemStates[i].os; + return ret; +} + +static int osStateMask = 0; + +_X_EXPORT int +xf86SetSerialModemState(int fd, int state) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + if (!osStateMask) + osStateMask = getOsStateMask(); + + state = xf2osState(state); + SYSCALL((ret = ioctl(fd, TIOCMGET, &s))); + if (ret < 0) + return -1; + s &= ~osStateMask; + s |= state; + SYSCALL((ret = ioctl(fd, TIOCMSET, &s))); + if (ret < 0) + return -1; + else + return 0; +#endif +} + +_X_EXPORT int +xf86GetSerialModemState(int fd) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + SYSCALL((ret = ioctl(fd, TIOCMGET, &s))); + if (ret < 0) + return -1; + return os2xfState(s); +#endif +} + +_X_EXPORT int +xf86SerialModemSetBits(int fd, int bits) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + s = xf2osState(bits); + SYSCALL((ret = ioctl(fd, TIOCMBIS, &s))); + return ret; +#endif +} + +_X_EXPORT int +xf86SerialModemClearBits(int fd, int bits) +{ + int ret; + int s; + + if (fd < 0) + return -1; + + /* Don't try to set parameters for non-tty devices. */ + if (!isatty(fd)) + return 0; + +#ifndef TIOCMGET + return -1; +#else + s = xf2osState(bits); + SYSCALL((ret = ioctl(fd, TIOCMBIC, &s))); + return ret; +#endif +} diff --git a/xorg-server/hw/xfree86/os-support/shared/sigio.c b/xorg-server/hw/xfree86/os-support/shared/sigio.c new file mode 100644 index 000000000..f51131c6b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/sigio.c @@ -0,0 +1,282 @@ + +/* sigio.c -- Support for SIGIO handler installation and removal + * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * 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 (including the next + * paragraph) 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 + * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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. + * + * Authors: Rickard E. (Rik) Faith + */ +/* + * Copyright (c) 2002 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 +#endif + +# include +# include "xf86.h" +# include "xf86Priv.h" +# include "xf86_OSlib.h" +# include "inputstr.h" + +/* + * Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is + * functional or not. + */ +#if defined(FASYNC) && !defined(O_ASYNC) +# define O_ASYNC FASYNC +#endif + +#ifdef MAX_DEVICES +/* MAX_DEVICES represents the maximimum number of input devices usable + * at the same time plus one entry for DRM support. + */ +# define MAX_FUNCS (MAX_DEVICES + 1) +#else +# define MAX_FUNCS 16 +#endif + +typedef struct _xf86SigIOFunc { + void (*f) (int, void *); + int fd; + void *closure; +} Xf86SigIOFunc; + +static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS]; +static int xf86SigIOMax; +static int xf86SigIOMaxFd; +static fd_set xf86SigIOMask; + +/* + * SIGIO gives no way of discovering which fd signalled, select + * to discover + */ +static void +xf86SIGIO (int sig) +{ + int i; + fd_set ready; + struct timeval to; + int save_errno = errno; /* do not clobber the global errno */ + int r; + + ready = xf86SigIOMask; + to.tv_sec = 0; + to.tv_usec = 0; + SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to)); + for (i = 0; r > 0 && i < xf86SigIOMax; i++) + if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready)) + { + (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd, + xf86SigIOFuncs[i].closure); + r--; + } + if (r > 0) { + xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); + } + /* restore global errno */ + errno = save_errno; +} + +static int +xf86IsPipe (int fd) +{ + struct stat buf; + + if (fstat (fd, &buf) < 0) + return 0; + return S_ISFIFO(buf.st_mode); +} + +_X_EXPORT int +xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure) +{ + struct sigaction sa; + struct sigaction osa; + int i; + int blocked; + + for (i = 0; i < MAX_FUNCS; i++) + { + if (!xf86SigIOFuncs[i].f) + { + if (xf86IsPipe (fd)) + return 0; + blocked = xf86BlockSIGIO(); + if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) { + xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n", + fd, strerror(errno)); + xf86UnblockSIGIO(blocked); + return 0; + } + if (fcntl(fd, F_SETOWN, getpid()) == -1) { + xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n", + fd, strerror(errno)); + xf86UnblockSIGIO(blocked); + return 0; + } + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGIO); + sa.sa_flags = 0; + sa.sa_handler = xf86SIGIO; + sigaction(SIGIO, &sa, &osa); + xf86SigIOFuncs[i].fd = fd; + xf86SigIOFuncs[i].closure = closure; + xf86SigIOFuncs[i].f = f; + if (i >= xf86SigIOMax) + xf86SigIOMax = i+1; + if (fd >= xf86SigIOMaxFd) + xf86SigIOMaxFd = fd + 1; + FD_SET (fd, &xf86SigIOMask); + xf86UnblockSIGIO(blocked); + return 1; + } + /* Allow overwriting of the closure and callback */ + else if (xf86SigIOFuncs[i].fd == fd) + { + xf86SigIOFuncs[i].closure = closure; + xf86SigIOFuncs[i].f = f; + return 1; + } + } + return 0; +} + +_X_EXPORT int +xf86RemoveSIGIOHandler(int fd) +{ + struct sigaction sa; + struct sigaction osa; + int i; + int max; + int maxfd; + int ret; + + max = 0; + maxfd = -1; + ret = 0; + for (i = 0; i < MAX_FUNCS; i++) + { + if (xf86SigIOFuncs[i].f) + { + if (xf86SigIOFuncs[i].fd == fd) + { + xf86SigIOFuncs[i].f = 0; + xf86SigIOFuncs[i].fd = 0; + xf86SigIOFuncs[i].closure = 0; + FD_CLR (fd, &xf86SigIOMask); + ret = 1; + } + else + { + max = i + 1; + if (xf86SigIOFuncs[i].fd >= maxfd) + maxfd = xf86SigIOFuncs[i].fd + 1; + } + } + } + if (ret) + { + fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC); + xf86SigIOMax = max; + xf86SigIOMaxFd = maxfd; + if (!max) + { + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGIO); + sa.sa_flags = 0; + sa.sa_handler = SIG_DFL; + sigaction(SIGIO, &sa, &osa); + } + } + return ret; +} + +_X_EXPORT int +xf86BlockSIGIO (void) +{ + sigset_t set, old; + int ret; + + sigemptyset (&set); + sigaddset (&set, SIGIO); + sigprocmask (SIG_BLOCK, &set, &old); + ret = sigismember (&old, SIGIO); + return ret; +} + +_X_EXPORT void +xf86UnblockSIGIO (int wasset) +{ + sigset_t set; + + if (!wasset) + { + sigemptyset (&set); + sigaddset (&set, SIGIO); + sigprocmask (SIG_UNBLOCK, &set, NULL); + } +} + +void +xf86AssertBlockedSIGIO (char *where) +{ + sigset_t set, old; + + sigemptyset (&set); + sigprocmask (SIG_BLOCK, &set, &old); + if (!sigismember (&old, SIGIO)) + xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where); +} + +/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */ + +int +xf86SIGIOSupported (void) +{ + return 1; +} diff --git a/xorg-server/hw/xfree86/os-support/shared/sigiostubs.c b/xorg-server/hw/xfree86/os-support/shared/sigiostubs.c new file mode 100644 index 000000000..7113968c6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/sigiostubs.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1999-2003 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 +#endif + +# include +# include "xf86.h" +# include "xf86Priv.h" +# include "xf86_OSlib.h" + +_X_EXPORT int +xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure) +{ + return 0; +} + +_X_EXPORT int +xf86RemoveSIGIOHandler(int fd) +{ + return 0; +} + +_X_EXPORT int +xf86BlockSIGIO (void) +{ + return 0; +} + +_X_EXPORT void +xf86UnblockSIGIO (int wasset) +{ +} + +void +xf86AssertBlockedSIGIO (char *where) +{ +} + +/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */ +Bool +xf86SIGIOSupported () +{ + return FALSE; +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/stdResource.c b/xorg-server/hw/xfree86/os-support/shared/stdResource.c new file mode 100644 index 000000000..c144211f0 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/stdResource.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 1999-2003 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). + */ + +/* Standard resource information code */ + +#ifdef HAVE_XORG_CONFIG_H +#include +#endif + +#include +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" +#include "xf86Pci.h" +#define NEED_OS_RAC_PROTOS +#include "xf86_OSlib.h" +#include "xf86Resources.h" + +/* Avoid Imakefile changes */ +#include "bus/Pci.h" + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) || defined(__sun) +#define xf86StdAccResFromOS xf86AccResFromOS +#endif + +resPtr +xf86StdAccResFromOS(resPtr ret) +{ + resRange range; + + /* + * Fallback is to claim the following areas: + * + * 0x00000000 - 0x0009ffff low 640k host memory + * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS + * 0x000f0000 - 0x000fffff system BIOS + * 0x00100000 - 0x3fffffff low 1G - 1MB host memory + * 0xfec00000 - 0xfecfffff default I/O APIC config space + * 0xfee00000 - 0xfeefffff default Local APIC config space + * 0xffe00000 - 0xffffffff high BIOS area (should this be included?) + * + * reference: Intel 440BX AGP specs + * + * The two APIC spaces appear to be BX-specific and should be dealt with + * elsewhere. + */ + + /* Fallback is to claim 0x0 - 0x9ffff and 0x100000 - 0x7fffffff */ + RANGE(range, 0x00000000, 0x0009ffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x000f0000, 0x000fffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00100000, 0x3fffffff, + ResExcMemBlock | ResBios | ResEstimated); + ret = xf86AddResToList(ret, &range, -1); +#if 0 + RANGE(range, 0xfec00000, 0xfecfffff, ResExcMemBlock | ResBios); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xfee00000, 0xfeefffff, ResExcMemBlock | ResBios); + ret = xf86AddResToList(ret, &range, -1); + /* airlied - remove BIOS range it shouldn't be here + this should use E820 - or THE OS */ + RANGE(range, 0xffe00000, 0xffffffff, ResExcMemBlock | ResBios); + ret = xf86AddResToList(ret, &range, -1); +#endif + /* + * Fallback would be to claim well known ports in the 0x0 - 0x3ff range + * along with their sparse I/O aliases, but that's too imprecise. Instead + * claim a bare minimum here. + */ + RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ + ret = xf86AddResToList(ret, &range, -1); + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ +/* RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); */ + RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* XXX add others */ + return ret; +} diff --git a/xorg-server/hw/xfree86/os-support/shared/vidmem.c b/xorg-server/hw/xfree86/os-support/shared/vidmem.c new file mode 100644 index 000000000..0b4411604 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/vidmem.c @@ -0,0 +1,296 @@ +/* + * Copyright (c) 1993-2003 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 +#endif + +#include +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +/* + * 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 physBase; + unsigned long size; + pointer virtBase; + pointer mtrrInfo; + int flags; +} 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, pointer 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; + xfree(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; + xfree(options); + vp->mtrrOptChecked = TRUE; + } +} + +void +xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase) +{ + VidMapPtr vp; + MappingPtr mp; + + vp = getVidMapRec(ScreenNum); + mp = newMapping(vp); + mp->physBase = Base; + mp->size = Size; + mp->virtBase = Vbase; + mp->flags = Flags; +} + +void +xf86InitVidMem(void) +{ + if (!vidMemInfo.initialised) { + memset(&vidMemInfo, 0, sizeof(VidMemInfo)); + xf86OSInitVidMem(&vidMemInfo); + } +} + +_X_EXPORT pointer +xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) +{ + pointer 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 == (pointer)-1) + return NULL; + + vp = getVidMapRec(ScreenNum); + mp = newMapping(vp); + mp->physBase = Base; + mp->size = Size; + mp->virtBase = vbase; + mp->flags = Flags; + + /* + * 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; +} + +_X_EXPORT void +xf86UnMapVidMem(int ScreenNum, pointer 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); +} + +_X_EXPORT 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; +} + +_X_EXPORT Bool +xf86LinearVidMem() +{ + xf86InitVidMem(); + return vidMemInfo.linearSupported; +} + +_X_EXPORT void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base, + unsigned long Size) +{ + if (!(Flags & VIDMEM_READSIDEEFFECT)) + return; + + if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects) + return; + + vidMemInfo.readSideEffects(ScreenNum, base, Size); +} + diff --git a/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c new file mode 100644 index 000000000..e6511dd43 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.c @@ -0,0 +1,49 @@ +/* + * 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 +#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 new file mode 100644 index 000000000..5e9d6284c --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/shared/xf86Axp.h @@ -0,0 +1,34 @@ +#ifdef HAVE_XORG_CONFIG_H +#include +#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 + -- cgit v1.2.3