diff options
author | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2011-10-10 17:43:39 +0200 |
commit | f4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch) | |
tree | 2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/programs/Xserver/hw/xfree86/os-support/nto | |
parent | a840692edc9c6d19cd7c057f68e39c7d95eb767d (diff) | |
download | nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2 nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip |
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz
Keywords:
Imported nx-X11-3.1.0-1.tar.gz
into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/xfree86/os-support/nto')
8 files changed, 769 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile new file mode 100644 index 000000000..fb7132182 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/Imakefile @@ -0,0 +1,37 @@ +XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v 1.7 2002/10/11 01:46:59 dawes Exp $ +XCOMM + +#include <Server.tmpl> + + +SRCS = nto_io.c nto_init.c nto_kbdEv.c nto_ioperm.c nto_video.c \ + VTsw_noop.c posix_tty.c kmod_noop.c agp_noop.c stdResource.c \ + stdPci.c libc_wrapper.c sigiostubs.c pm_noop.c nto_mouse.c + +OBJS = nto_io.o nto_init.o nto_kbdEv.o nto_ioperm.o nto_video.o \ + VTsw_noop.o posix_tty.o kmod_noop.o agp_noop.o stdResource.o \ + stdPci.o libc_wrapper.o sigiostubs.o pm_noop.o nto_mouse.o + +INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \ + -I$(XINCLUDESRC) + +RESDEFINES = -DUSESTDRES + +DEFINES = $(RESDEFINES) + +SubdirLibraryRule($(OBJS)) +NormalLibraryObjectRule() + + +LinkSourceFile(libc_wrapper.c,../shared) +LinkSourceFile(sigiostubs.c,../shared) +LinkSourceFile(pm_noop.c,../shared) +LinkSourceFile(stdResource.c,../shared) +LinkSourceFile(stdPci.c,../shared) + +LinkSourceFile(VTsw_noop.c,../shared) +LinkSourceFile(posix_tty.c,../shared) +LinkSourceFile(kmod_noop.c,../shared) +LinkSourceFile(agp_noop.c,../shared) + +DependTarget() diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README new file mode 100644 index 000000000..8d262fe08 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/README @@ -0,0 +1,29 @@ +XFree86 on NTO + +Status: +Everything builds, and appears to work. Libraries are built as shared. + +Building: +Buiding is done as cross-development from QNX4. What you'll need: + +QNX4 4.24+ +Neutrino 2.0 x86 runtime and development packages for QNX4 host. +Various QNX4 utilities, such as pdksh, cpp etc. + +To build: + +type (from the xc/ directory) +BOOTSTRAPCFLAGS="-D__QNXNTO__ -Di386 -D__GNUC__" make World 2>&1 | tee make.log + +you can also make PPC or MIPS clients (-DPPC or -DMIPS): +BOOTSTRAPCFLAGS="-D__QNXNTO__ -DPPC -D__GNUC__" make World 2>&1 | tee make.log + +Let the build run, and then examine make.log for any errors. + + +Note that we'll very soon be able to build X natively on NTO... + +Sebastien Marineau +sebastien@qnx.com + +$XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/README,v 1.1.2.1 1999/07/29 09:40:14 hohndel Exp $ diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c new file mode 100644 index 000000000..726a8a5ac --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c @@ -0,0 +1,104 @@ +/* + * (c) Copyright 1998 by Sebastien Marineau + * <sebastien@qnx.com> + * + * 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 + * SEBASTIEN MARINEAU 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 Sebastien Marineau shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Sebastien Marineau. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_init.c,v 1.2 1999/12/27 00:45:45 robin Exp $ + */ + +/* This module contains the NTO-specific functions used at server init. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/neutrino.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/mman.h> +#include <sys/dcmd_chr.h> + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +extern int NTO_con_fd; + +void +xf86UseMsg() +{ + ErrorF("No NTO-specific usage options available at this time\n"); + return; +} + +int +xf86ProcessArgument(argc, argv, i) +int argc; +char **argv; +int i; +{ + + return 0; + +} + + +/* Right now, OpenConsole() does not do much; later, we may want to handle + * console switching and so on.... + */ + +void +xf86OpenConsole() +{ + unsigned flags; + + + ThreadCtl(_NTO_TCTL_IO, 0); + + if((NTO_con_fd = open("/dev/con1", O_RDWR)) == -1) { + ErrorF("Unable to open console\n"); + return; + } + + /* Make the console invisible to prevent devc-con from touching hardware */ + flags = _CONCTL_INVISIBLE | _CONCTL_INVISIBLE_CHG; + devctl(NTO_con_fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0); + + return; +} + +void +xf86CloseConsole() +{ + unsigned flags; + + /* Make console visible again */ + flags = _CONCTL_INVISIBLE_CHG; + devctl(NTO_con_fd, DCMD_CHR_SERCTL, &flags, sizeof flags, 0); + close(NTO_con_fd); + + return; +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c new file mode 100644 index 000000000..9c32afd35 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c @@ -0,0 +1,118 @@ +/* + * (c) Copyright 1998 by Sebastien Marineau + * <sebastien@qnx.com> + * + * 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 + * SEBASTIEN MARINEAU 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 Sebastien Marineau shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Sebastien Marineau. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_io.c,v 1.4 2002/10/11 01:40:35 dawes Exp $ + */ + +/* This module contains the NTO-specific functions to access the keyboard + * and the console. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/mman.h> + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +int NTO_kbd_fd = -1; +int NTO_con_fd = -1; + +void +xf86SoundKbdBell(loudness, pitch, duration) +int loudness, pitch, duration; +{ + +/* Come back and fix! */ +ErrorF("xf86SoundKbdBell: to implement\n"); +} + +void +xf86SetKbdLeds(leds) +int leds; +{ + +ErrorF("xf86SetKbdLeds: to implement\n"); +} + +int +xf86GetKbdLeds() +{ + int leds; + + leds = 0; + ErrorF("xf86GetKbdLeds: to implement\n"); + return(leds); +} + +/* This is a no-op for now */ +void +xf86SetKbdRepeat(rad) +char rad; +{ + return; +} + + +/* Need to open keyboard here ? */ +void +xf86KbdInit() +{ + + ErrorF("xf86KbdInit: to implement\n"); + return; +} + + +int xf86KbdOn() +{ + /* Here, we need to open /dev/kbd */ + NTO_kbd_fd = open("/dev/kbd", O_RDWR | O_NONBLOCK); + ErrorF("Opened keyboard device, handle %d\n",NTO_kbd_fd); + return(NTO_kbd_fd); +} + +int xf86KbdOff() +{ + close(NTO_kbd_fd); + NTO_kbd_fd = -1; + return (-1); +} + +#include "xf86OSKbd.h" + +Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + return FALSE; +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c new file mode 100644 index 000000000..67a771ff6 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c @@ -0,0 +1,48 @@ +/* + * Copyright 1998 by Sebastien Marineau <sebastien@qnx.com> + * + * 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. Sebastien Marineau makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * SEBASTIEN MARINEAU 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. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_ioperm.c,v 1.2 1999/12/27 00:45:45 robin Exp $ + */ + +/* I/O functions to enable access to I/O ports under Neutrino */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/neutrino.h> +#include <errno.h> + + +Bool xf86EnableIO() +{ + ErrorF("xf86EnableIO: enabling I/O access\n"); + if(ThreadCtl(_NTO_TCTL_IO, 0)) { + ErrorF("xf86EnableIO: could not set I/O privilege, errno %d\n",errno); + return FALSE; + } + return TRUE; +} + +void xf86DisableIO() +{ + return; +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c new file mode 100644 index 000000000..a028de6b6 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c @@ -0,0 +1,53 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_kbdEv.c,v 1.2 1999/12/27 00:45:46 robin Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * 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 Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Dawes 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 DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES 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. + * + */ +/* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */ + +#define NEED_EVENTS +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "inputstr.h" +#include "scrnintstr.h" + +#include "xf86_OSlib.h" + +extern int NTO_kbd_fd; + +void xf86KbdEvents() +{ + unsigned char rBuf[64]; + int nBytes, i; + + if ((nBytes = read( NTO_kbd_fd, (char *)rBuf, sizeof(rBuf))) > 0) { + for (i = 0; i < nBytes; i++) { + xf86PostKbdEvent(rBuf[i]); + } + } +} + diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c new file mode 100644 index 000000000..2dda8aa32 --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c @@ -0,0 +1,210 @@ +/* + * Written by Frank Liu Oct 10, 2001 + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_mouse.c,v 1.1 2001/11/16 16:47:56 dawes Exp $ */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" + +/* copied from mipointer.h */ +extern int miPointerGetMotionEvents( + DeviceIntPtr /*pPtr*/, + xTimecoord * /*coords*/, + unsigned long /*start*/, + unsigned long /*stop*/, + ScreenPtr /*pScreen*/ +); + +#include <sys/dcmd_input.h> +#define NUMEVENTS 64 /* don't want to stuck in the mouse read loop */ + +/* + * OsMouseReadInput -- + * Get some events from our queue. Process outstanding events now. + */ +static void +OsMouseReadInput(InputInfoPtr pInfo) +{ + int n = 0; + int buttons, col, row; + struct _mouse_packet mp; + MouseDevPtr pMse; + + pMse = pInfo->private; + + while ( (read(pInfo->fd, &mp, sizeof(struct _mouse_packet)) > 0 ) + && (n < NUMEVENTS ) ) + { + col = mp.dx; + row = -mp.dy; + buttons = mp.hdr.buttons; + pMse->PostEvent(pInfo, buttons, col, row, 0, 0); + n++; + } +} + +/* + * OsMouseProc -- + * Handle the initialization, etc. of a mouse + */ +static int +OsMouseProc(pPointer, what) +DeviceIntPtr pPointer; +int what; +{ + int nbuttons; + unsigned char map[MSE_MAXBUTTONS + 1]; + MouseDevPtr pMse; + InputInfoPtr pInfo; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons) + map[nbuttons + 1] = nbuttons + 1; + + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + min(pMse->buttons, MSE_MAXBUTTONS), + miPointerGetMotionEvents, + pMse->Ctrl, + miPointerGetMotionBufferSize()); + + /* X valuator */ + xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 0); + /* Y valuator */ + xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 1); + xf86MotionHistoryAllocate(pInfo); + break; + + case DEVICE_ON: + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + AddEnabledDevice(pInfo->fd); + } + pMse->lastButtons = 0; + pMse->lastMappedButtons = 0; + pMse->emulateState = 0; + pPointer->public.on = TRUE; + break; + + case DEVICE_CLOSE: + case DEVICE_OFF: + if (pInfo->fd != -1) { + RemoveEnabledDevice(pInfo->fd); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } + pPointer->public.on = FALSE; + break; + } + return (Success); +} + +static int +SupportedInterfaces(void) +{ + /* FIXME: Is this correct? Should we just return MSE_MISC? */ + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_MISC | MSE_AUTO; +} + +static const char *internalNames[] = { + "OSMouse", + NULL +}; + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + return FALSE; +} + +/* XXX Is this appropriate? If not, this function should be removed. */ +static const char * +DefaultProtocol(void) +{ + return "OSMouse"; +} + +static Bool +OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse; + + /* This is called when the protocol is "OSMouse". */ + + pMse = pInfo->private; + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pMse); + return FALSE; + } + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->device_control = OsMouseProc; + pInfo->read_input = OsMouseReadInput; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} + +OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; + p->BuiltinNames = BuiltinNames; + p->DefaultProtocol = DefaultProtocol; + p->CheckProtocol = CheckProtocol; + p->PreInit = OsMousePreInit; + return p; +} diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c new file mode 100644 index 000000000..f78f6864a --- /dev/null +++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c @@ -0,0 +1,170 @@ +/* (c) Copyright 1998 by Sebastien Marineau + * <sebastien@qnx.com> + * + * 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 + * SEBASTIEN MARINEAU 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 Sebastien Marineau shall not be + * used in advertising or otherwise to promote the sale, use or other dealings + * in this Software without prior written authorization from Sebastien Marineau. + * + * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/nto_video.c,v 1.3tsi Exp $ + */ + +/* This module contains the NTO-specific functions to deal with video + * framebuffer access and interrupts. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/mman.h> +#include <sys/neutrino.h> + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + + +/* These are the interrupt enabling/disabling functions. + */ + +void xf86EnableInterrupts() +{ + InterruptEnable(); +} + +Bool xf86DisableInterrupts() +{ + InterruptDisable(); + return 0; +} + +/* These are the routines to map/unmap video memory... */ + +Bool xf86LinearVidMem() +{ + /* Yes we can... */ + return(TRUE); +} + +/* This is our shmem "Physical" handle */ +int NTO_PhMem_fd = -1; + + +/* Map a chunk of physical video memory, using mmap */ +pointer +xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) +{ + int fd; + pointer base; + + if(NTO_PhMem_fd < 0) { + if ((fd = open("/dev/mem", O_RDWR, 0777)) < 0) { + FatalError("xf86MapVidMem: Failed to open /dev/mem\n"); + } + NTO_PhMem_fd = fd; + } + + base = mmap((caddr_t)0, Size, + (Flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, NTO_PhMem_fd, (off_t)Base); + + ErrorF("MapVidMem: addr %08x size %08x addr %08x\n", Base, Size, base); + if ((long)base == -1) { + FatalError("xf86MapVidMem: Failed to mmap video memory\n"); + } + + return base; +} + +/* ARGSUSED */ +void +xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + + ErrorF("xf86UnmapVidMem: base %x size %x\n", Base, Size); + munmap((caddr_t) Base, Size); + +} + +/* Finally, this function allows us to read the video BIOS content */ + +int +xf86ReadBIOS(Base, Offset, Buf, Len) +unsigned long Base, Offset; +unsigned char *Buf; +int Len; +{ + unsigned char * VirtBase; + + ErrorF("xf86ReadBIOS: base %x offset %x len %x\n", Base, Offset, Len); + + if (NTO_PhMem_fd == -1) { + if ((NTO_PhMem_fd = open("/dev/mem", O_RDWR, 0777)) < 0) { + FatalError("xf86ReadBIOS: cannot open Physical memory\n"); + } + } + + /* Use mmap to map BIOS region. Note the restrictions on + * mmap alignement of offset variable (which must be on a page + * boundary). + */ + VirtBase = (unsigned char *) mmap(0, (size_t)((Offset & 0x7fff) + Len), PROT_READ, + MAP_SHARED, NTO_PhMem_fd, (off_t) (Base + (Offset & 0xffff8000))); + if((long)VirtBase == -1) { + FatalError( "xf86ReadBIOS: Could not mmap BIOS memory space, errno=%i\n", errno); + } + + /* So now we have our mapping to the BIOS region */ + + /* Do a sanity check on what we have just mapped */ + if (((off_t)((off_t)Offset & 0x7FFF) != (off_t)0) && + (VirtBase[0] != 0x55) && + (VirtBase[1] != 0xaa)) { + ErrorF( "xf86ReadBIOS: BIOS sanity check failed, addr=%x\n", + (int)Base + Offset); + munmap(VirtBase, (Offset & 0x7fff) + Len); + return -1; + } + + /* Things look good: copy BIOS data */ + memcpy(Buf, VirtBase + (Offset & 0x7fff), Len); + munmap(VirtBase, (Offset & 0x7fff) + Len); + + return Len; +} + +void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base, + unsigned long Size) +{ + return; +} + +Bool +xf86CheckMTRR(int s) +{ + return FALSE; +} + |