diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 15:54:54 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 15:54:54 +0000 |
commit | ded6147bfb5d75ff1e67c858040a628b61bc17d1 (patch) | |
tree | 82355105e93cdac89ef7d987424351c77545faf0 /hw/xfree86/os-support/lynxos | |
parent | cb6ef07bf01e72d1a6e6e83ceb7f76d6534da941 (diff) |
R6.6 is the Xorg base-lineXORG-MAIN
Diffstat (limited to 'hw/xfree86/os-support/lynxos')
-rw-r--r-- | hw/xfree86/os-support/lynxos/lynx_init.c | 198 | ||||
-rw-r--r-- | hw/xfree86/os-support/lynxos/lynx_io.c | 172 | ||||
-rw-r--r-- | hw/xfree86/os-support/lynxos/lynx_mmap.c | 66 | ||||
-rw-r--r-- | hw/xfree86/os-support/lynxos/lynx_video.c | 167 |
4 files changed, 603 insertions, 0 deletions
diff --git a/hw/xfree86/os-support/lynxos/lynx_init.c b/hw/xfree86/os-support/lynxos/lynx_init.c new file mode 100644 index 000000000..6c0e00aa3 --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_init.c @@ -0,0 +1,198 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER 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/lynxos/lynx_init.c,v 3.1.6.1 1998/02/06 22:36:51 hohndel Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +static int VTnum = -1; + +void xf86OpenConsole() +{ + struct vt_mode VT; + char vtname1[11]; + int i, fd, pgrp; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be running with root " + "permissions\n" + "You should be using Xwrapper to start the server or xdm.\n" + "We strongly advise against making the server SUID root!\n"); + } + + /* + * setup the virtual terminal manager + * NOTE: + * We use the out-of-the-box atc terminal driver, + * not the GE contributed vdt driver. + * Also, we do setup signals for VT switching which + * is not really necessary because we don't feed the + * VT switch keystrokes to the kernel in xf86Events.c + * (it bombs occasionally...) + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + } + else + { + /* We could use /dev/con which is usually a symlink + * to /dev/atc0 but one could configure the system + * to use a serial line as console device, so to + * be sure we take /dev/atc0. + */ + if ((fd = open("/dev/atc0",O_WRONLY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open /dev/atc0 (%s)\n", + strerror(errno)); + } + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + { + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + } + close(fd); + } + ErrorF("(using VT number %d)\n\n", xf86Info.vtno); + + sprintf(vtname1,"/dev/atc%d",xf86Info.vtno); + + pgrp = getpgrp(); /* POSIX version ! */ + ioctl(xf86Info.consoleFd, TIOCSPGRP, &pgrp); + + if ((xf86Info.consoleFd = open(vtname1,O_RDWR|O_NDELAY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open %s (%s)\n", + vtname1, strerror(errno)); + } + /* change ownership of the vt */ + chown(vtname1, getuid(), getgid()); + + /* Reading Config after opening the VT get's rid of */ + /* problems with LynxOS VT handling (i.e. VT_OPENQUERY */ + /* without open() leaves the vtxx busy until next */ + /* open/close) */ + + xf86Config(FALSE); /* Read XF86Config */ + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + } + + /* for future use... */ + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86VTSema) + sleep(5); + } + return; +} + +void xf86CloseConsole() +{ + struct vt_mode VT; + +#if 0 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); +#endif + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int xf86ProcessArgument (argc, argv, i) +int argc; +char *argv[]; +int i; +{ + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + return; +} + diff --git a/hw/xfree86/os-support/lynxos/lynx_io.c b/hw/xfree86/os-support/lynxos/lynx_io.c new file mode 100644 index 000000000..e0134609e --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_io.c @@ -0,0 +1,172 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER 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/lynxos/lynx_io.c,v 3.3 1996/08/10 13:07:36 dawes Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +#if defined(KDMKTONE) || defined(KIOCSOUND) +/* Lynx 2.2.1 has sophisticated atc stuff.... */ +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + if (loudness && pitch) + { +#ifdef KDMKTONE + /* + * If we have KDMKTONE use it to avoid putting the server + * to sleep + */ + ioctl(xf86Info.consoleFd, KDMKTONE, + (pitch & 0xffff) | + (((unsigned long)duration * + loudness / 50) << 16)); +#else + ioctl(xf86Info.consoleFd, KIOCSOUND, pitch); + usleep(xf86Info.bell_duration * loudness * 20); + ioctl(xf86Info.consoleFd, KIOCSOUND, 0); +#endif + } +} + +#else + +/* this is pulled from /sys/drivers/vt100/atbeep.c */ + +#define SPEAKER_CONTROL 0x61 +#define TIMER_CONTROL 0x43 +#define TIMER_DATA 0x42 +#define TIMER_LOAD_CMD 0xb6 + +#define TIMER_CONSTANT 1193280 +#define FREQ_LO(f) ((TIMER_CONSTANT / (f)) % 256) +#define FREQ_HI(f) ((TIMER_CONSTANT / (f)) / 256) + +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + int flo = FREQ_LO(pitch); + int fhi = FREQ_HI(pitch); + + outb(TIMER_CONTROL, TIMER_LOAD_CMD); + outb(TIMER_DATA, flo); + outb(TIMER_DATA, fhi); + + /* speaker on */ + outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) | 3); + usleep(xf86Info.bell_duration * loudness * 20); + /* speaker off */ + outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) & ~3); +} +#endif + +void xf86SetKbdLeds(leds) +int leds; +{ +} + +int xf86GetKbdLeds() +{ + return 0; +} + +void xf86SetKbdRepeat(char rad) +{ +} + +static struct termio kbdtty; + +void xf86KbdInit() +{ + ioctl(xf86Info.consoleFd, TCGETA, &kbdtty); +} + +int xf86KbdOn() +{ + struct termio nTty; + + /* set CAPS_LOCK to behave as CAPS_LOCK not as CTRL */ + write(xf86Info.consoleFd, "\033<", 2); + + /* enable scan mode */ + ioctl(xf86Info.consoleFd, TIO_ENSCANMODE, NULL); + + nTty = kbdtty; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME]=0; + nTty.c_cc[VMIN]=1; + ioctl(xf86Info.consoleFd, TCSETA, &nTty); + + return(xf86Info.consoleFd); +} + +int xf86KbdOff() +{ + /* disable scan mode */ + ioctl(xf86Info.consoleFd, TIO_DISSCANMODE, NULL); + ioctl(xf86Info.consoleFd, TCSETA, &kbdtty); + return(xf86Info.consoleFd); +} + +void xf86MouseInit(mouse) +MouseDevPtr mouse; +{ + return; +} + +int xf86MouseOn(mouse) +MouseDevPtr mouse; +{ + if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open mouse (%s) - Continuing...\n", + strerror(errno)); + return(-2); + } + FatalError("Cannot open mouse (%s)\n", strerror(errno)); + } + + /* assert DTR */ + ioctl(mouse->mseFd, TIOCSDTR, NULL); + + xf86SetupMouse(mouse); + + return(mouse->mseFd); +} diff --git a/hw/xfree86/os-support/lynxos/lynx_mmap.c b/hw/xfree86/os-support/lynxos/lynx_mmap.c new file mode 100644 index 000000000..621f42c5d --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_mmap.c @@ -0,0 +1,66 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER 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/lynxos/lynx_mmap.c,v 3.2 1996/09/29 13:38:29 dawes Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Read BIOS using smem_create facility + */ + +int xf86ReadBIOS(Base, Offset, Buf, Len) +unsigned long Base; +unsigned long Offset; +unsigned char *Buf; +int Len; +{ + char *p; + int mlen; + + mlen = (Offset + Len + 4095) & ~4096; + p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); + if (p == NULL) + { + /* check if there is a stale segment around */ + if (smem_remove("BIOS-probe") == 0) { + ErrorF("xf86ReadBios: removed stale smem_ segment\n"); + p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); + } + if (p == NULL) { + ErrorF("xf86ReadBios: Failed to smem_create Base %x len %x %s \n", + Base, mlen, strerror(errno)); + return(-1); + } + } + memcpy(Buf, p + Offset, Len); + smem_create(NULL, p, 0, SM_DETACH); + smem_remove("BIOS-probe"); + return(Len); +} diff --git a/hw/xfree86/os-support/lynxos/lynx_video.c b/hw/xfree86/os-support/lynxos/lynx_video.c new file mode 100644 index 000000000..94b2f0ecd --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_video.c @@ -0,0 +1,167 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * 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 Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER 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/lynxos/lynx_video.c,v 3.2.4.1 1997/05/09 07:15:24 hohndel Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +typedef struct +{ + char name[16]; + pointer Base; + long Size; + char *ptr; + int RefCnt; +} +_SMEMS; + +#define MAX_SMEMS 8 + +static _SMEMS smems[MAX_SMEMS]; + +static void +smemCleanup() +{ + int i; + + for (i = 0; i < MAX_SMEMS; i++) { + if (*smems[i].name && smems[i].ptr) { + (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); + (void)smem_remove(smems[i].name); + *smems[i].name = '\0'; + smems[i].ptr = NULL; + smems[i].Base = NULL; + smems[i].Size = 0; + smems[i].RefCnt = 0; + } + } +} + +pointer xf86MapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + static int once; + int free_slot = -1; + int i; + + if (!once) + { + atexit(smemCleanup); + once = 1; + } + for (i = 0; i < MAX_SMEMS; i++) + { + if (!*smems[i].name && free_slot == -1) + free_slot = i; + if (smems[i].Base == Base && smems[i].Size == Size && *smems[i].name) { + smems[i].RefCnt++; + return smems[i].ptr; + } + } + if (i == MAX_SMEMS && free_slot == -1) + { + FatalError("xf86MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n", + Base, Size); + } + + i = free_slot; + sprintf(smems[i].name, "Video-%d", i); + smems[i].Base = Base; + smems[i].Size = Size; + smems[i].ptr = smem_create(smems[i].name, Base, Size, SM_READ|SM_WRITE); + smems[i].RefCnt = 1; + if (smems[i].ptr == NULL) + { + /* check if there is a stale segment around */ + if (smem_remove(smems[i].name) == 0) { + ErrorF("xf86MapVidMem: removed stale smem_ segment %s\n", + smems[i].name); + smems[i].ptr = smem_create(smems[i].name, + Base, Size, SM_READ|SM_WRITE); + } + if (smems[i].ptr == NULL) { + *smems[i].name = '\0'; + FatalError("xf86MapVidMem: failed to smem_create Base %x Size %x (%s)\n", + Base, Size, strerror(errno)); + } + } + return smems[i].ptr; +} + +void xf86UnMapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + int i; + + for (i = 0; i < MAX_SMEMS; i++) + { + if (*smems[i].name && smems[i].ptr == Base && smems[i].Size == Size) + { + if (--smems[i].RefCnt > 0) + return; + (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); + (void)smem_remove(smems[i].name); + *smems[i].name = '\0'; + smems[i].RefCnt = 0; + return; + } + } + ErrorF("xf86UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n", Base, Size); +} + +Bool xf86LinearVidMem() +{ + return(TRUE); +} + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts() +{ + return(TRUE); +} + +void xf86EnableInterrupts() +{ + return; +} + |