R6.6 is the Xorg base-line

This commit is contained in:
Kaleb Keithley 2003-11-14 15:54:54 +00:00
commit ded6147bfb
609 changed files with 262690 additions and 0 deletions

View file

@ -0,0 +1,437 @@
README for XFree86 OS-support Layer
-----------------------------------
Contents
--------
1) Overview
2) Directory Layout
3) Adding a new OS
4) OS Support API
1 - Overview
------------
This directory contains the OS support layer functions for the XFree86
servers. In addition, some miscellaneous server support functions (not
OS-dependent) are included here, to take advantage of the fact that this
library comes last in the linking order.
Most of the functionality required to support a new OS is encapsulated in
this library. It is hoped that all OS-specific details can be encapsulated,
but that is not likely ever to be completely possible. Hence some minor
changes will wind up being made in other parts of the server. The major
design principles for this library are maintainability, readability, and
portability. Sometimes these goals conflict; some somewhat arbitrary choices
have been made in implementation.
2 - Directory Layout
--------------------
os-support/ Contains headers and documentation; no code
misc/ Non-OS-specific miscellaneous functions that
fit best into the link architecture this way.
shared/ Contains files with functions used by more than one
OS. These are symlinked into the OS subdirectories
at build time via Imakefile rules. This is alway
preferable to reproducing functions in more than one
OS library.
amoeba/ OS support for the Amoeba operating system.
bsd/ OS support for the 386BSD/NetBSD/FreeBSD operating
systems.
bsdi/ OS support for the BSD/386 operating system.
linux/ OS support for the Linux operating system.
mach/ OS support for the Mach and OSF/1 operating systems.
minix/ OS support for the Minix operating system.
os2/ OS support for OS/2 2.11 and OS/2 Warp
sco/ OS support for the SCO SVR3.x operating system.
solx86/ OS support for the Solaris x86 operating system.
sysv/ OS support for all SVR4.0 and SVR4.2, and for
ISC and AT&T SVR3.2 operating systems.
3 - Adding A New OS
-------------------
Adding a support for a new operating system entails implementing all of
the functions described in the API below. Many of these functions are no-ops
for many operating systems, and appropriate files with dummy declarations are
available in the 'shared' subdirectory.
If your OS is sufficiently similar to an existing OS, you can make use of
the existing subdirectory. One of the reasons for implementing this OS
library was the unmaintainability of the spagetti-#ifdef code that existed
before. You should try to avoid cluttering the code with #ifdef's. If
you find that the subdirectory is getting cluttered, split off into a
seperate subdirectory (e.g. as was done for SCO, rather than cluttering
the 'sysv' subdirectory). You can split functions out of an existing
subdirectory into the 'shared' subdirectory, if that is appropriate. Just
remember to update the Imakefile for the old subdirectory.
You will still likely have to make some small changes to other parts of
the server. You should not put OS-specific #define's or #include's anywhere
else in the server. These should all go in the "xf86_OSlib.h" header file
in this directory.
4 - OS Support API
-----------------
void xf86OpenConsole(void)
{
/*
* Open console device, activate VTs, etc, etc. Fill in requisite
* pieces of x386Info. Most of this code comes from x386Init.c
*/
}
void xf86CloseConsole(void)
{
/*
* Close console at server exit.
*/
}
Bool xf86VTSwitchPending(void)
{
/*
* Returns TRUE iff there is a VT switch operation pending for
* the server. In the USL VT model, this is indicated via a
* signal handler. Should return FALSE always for OSs without
* VTs.
*/
}
Bool xf86VTSwitchAway(void)
{
/*
* Handles the OS-specific action for switching away from the active
* VT. Returns FALSE if the switch away fails. Should return
* FALSE always for OSs without VTs (then again, this function
* should never be called in that case).
*/
}
Bool xf86VTSwitchTo(void)
{
/*
* Handles the OS-specific action for switching to the active VT.
* Returns FALSE if the switch to fails. Should return TRUE
* always for OSs without VTs (then again, this function should
* never be called in that case).
*/
}
Bool xf86LinearVidMem(void)
{
/*
* Returns TRUE if the OS supports mapping linear frame buffers
* (ie memory at addresses above physical memory).
*/
}
pointer xf86MapVidMem(int ScreenNum, int Region, pointer Base,
unsigned long Size)
{
/*
* Handle mapping the video memory. Returns (pointer *)0 for
* failure; causes server exit. It is allowable to call FatalError()
* from inside this function and exit directly.
*/
}
void xf86UnMapVidMem(int ScreenNum, int Region, pointer Base,
unsigned long Size)
{
/*
* Handle unmapping the video memory. This should undo what
* xf86MapVidMem() does. Base is a pointer obtained from
* a previous call to xf86MapVidMem().
*/
}
void xf86MapDisplay(int ScreenNum, int Region)
{
/*
* For OSs that require the screen be mapped when entering a VT.
* A dummy function will be defined for OSs that don't require
* this (or don't have VTs at all).
*/
}
void xf86UnMapDisplay(int ScreenNum, int Region)
{
/*
* For Os that require that the screen be unmapped when leaving a
* VT. A dummy function will be defined for OSs that don't require
* this (or don't have VTs at all).
*/
}
int xf86ReadBIOS(unsigned long Base, unsigned long Offset,
unsigned char *Buf, int Len)
{
/*
* Read Len bytes from the BIOS at address Base, offset Offset,
* into buffer Buf. Returns -1 for failure or if the OS does
* not support reading the BIOS. This causes a driver probe
* to fail, but does not cause the server to abort.
*/
}
void xf86ClearIOPortList(int ScreenNum)
{
/*
* Clears any list of I/O ports that the OS-layer may be maintaining.
* Note: the value used for ScreenNum must be the scrnIndex field
* of the screenInfoRec, because this is the only index that is
* guaranteed to be valid and never change during the life of the
* server. It is not the same as the index of pScreen in ScreenInfo.
*/
}
void xf86AddIOPorts(int ScreenNum, int NumPorts, unsigned *Ports)
{
/*
* Adds NumPorts I/O ports listed in array Ports to a list that
* the OS-layer may be maintaining. Successive calls to this
* function are cumulative.
*/
}
void xf86EnableIOPorts(int ScreenNum)
{
/*
* Enables I/O permissions. The OS layer can either use a
* previously created list of I/O ports to be used, or can
* enable all I/O port access.
*/
}
void xf86DisableIOPorts(int ScreenNum)
{
/*
* Disables I/O permissions. Does not clear the list of I/O
* ports, if any exists.
*/
}
void xf86DisableIOPrivs(void)
{
/*
* Do whatever is necessary to disable I/O permissions after forking
* a child process.
*/
}
Bool xf86DisableInterrupts(void)
{
/*
* Disable interrupts if allowed for this OS. Returns FALSE if
* this is not allowed or if the attempt fails for some reason.
*/
}
void xf86EnableInterrupts(void)
{
/*
* Reenable interrupts
*/
}
int xf86ProcessArgument(int argc, char *argv[], int i)
{
/*
* Process OS-specific command-line arguments. See
* ddxProcessArgument() for more info.
*/
}
void xf86UseMsg(void)
{
/*
* Print list of OS-specific command-line arguments. See
* ddxUseMsg() for more info.
*/
}
void xf86SoundKbdBell(int loudness, int pitch, int duration)
{
/*
* Sound the keyboard bell. pitch is in Hz, duration in ms,
* loudness is in the range 0-100 (0 -> off). For systems
* where the loudness can't be controlled, scale the duration
* by loudness/50.
*/
}
void xf86SetKbdLeds(int leds)
{
/*
* Set the keyboard LEDs to the state indicated in leds
*/
}
int xf86GetKbdLeds(void)
{
/*
* Return the state of the keyboard LEDs. If the OS doesn't
* support this, return 0.
*/
}
void xf86SetKbdRepeat(char rad)
{
/*
* Set the keyboard repeat rate and delay according the
* the rad value. The lower 5 bits determine the repeat
* rate (lower value -> higher rate). The next 2 bits
* determine the delay.
* This should possibly be changed to take separate rate and
* delay parameters.
*/
}
void xf86KbdInit(void)
{
/*
* Save initial keyboard state. This is called at the start of
* each server generation.
*/
}
int xf86KbdOn(void)
{
/*
* Set the keyboard up for use with X. This is called whenever
* the server becomes active (ie at the start of each generation and
* whenever its VT becomes active). Return the file descriptor
* for keyboard input. Return -1 if there is no file descriptor
* to add as an input device. If there are errors encountered,
* call FatalError(). A return value of -1 is not considered an
* error condition.
*/
}
int xf86KbdOff(void)
{
/*
* Return the keyboard to the state saved by xf86KbdInit(). This is
* called at the end of a server generation, and also when the
* server's VT ceases being active. Returns the keyboard file
* descriptor. Returns -1 if there is no file descriptor to be
* removed as an input device. Errors should be handled the same
* way as in xf86KbdOn().
*/
}
void xf86KbdEvents(void)
{
/*
* Read characters from the keyboard device, and post the events
* by calling x386PostKbdEvent(). Read as much as is available
* without waiting.
*/
}
void xf86SetMouseSpeed(int old, int new, unsigned cflag)
{
/*
* Set the speed of the mouse port. old is the previous speed,
* new is the new speed, and cflag is the value of the termio[s]
* c_cflag field. For mice that have programmable speed operation,
* this should send the appropriate commands to the mouse.
*/
}
void xf86MouseInit(void)
{
/*
* This is called at the start of each server generation. In most
* cases this is a noop. If the mouse must not be opened/closed
* when VT switching, the open should be done here.
*/
}
int xf86MousedOn(void)
{
/*
* Set the mouse up for use with X. This is called whenever
* the server becomes active (ie at the start of each generation and
* whenever its VT becomes active). This function normally opens
* the mouse device, and may call xf86SetupMouse() to initialise
* the mouse parameters. Return the file descriptor for mouse input.
* Return -1 if there is no file descriptor to add as an input
* device. If there are errors encountered, call FatalError().
* A return value of -1 is not considered an error condition.
*/
}
int xf86MouseOff(Bool doclose)
{
/*
* Release the mouse from use with X. This is called at the end
* of a server generation (with doclose==TRUE), and also when the
* server's VT ceases being active (with doclose==FALSE). If the
* mouse should not be opened/closed when VT switching, the close
* should be done here when doclose==TRUE. For other systems, the
* mouse device should be closed regardless of the doclose value.
* Returns the mouse file descriptor. Returns -1 if there is no
* file descriptor to be removed as an input device. Errors
* should be handled the same way as in xf86MouseOn().
*/
}
void xf86MouseEvents(void)
{
/*
* Read characters from the mouse device, and post the events
* by calling x386PostMseEvent(). Read as much as is available
* without waiting. If the OS doesn't handle the mouse protocol
* translation, xf86MouseProtocol() may be called to do the
* translation and event posting. If the OS does handle the protocol
* translation, MOUSE_PROTOCOL_IN_KERNEL should be #define'd in
* xf86_OSlib.h.
*/
}
int xf86OsMouseProc(DevicePtr pPointer, int what)
{
/*
* Implements the device-proc for the pointer device when an
* OS-based mouse driver is being used (as opposed to the
* server's internal mouse driver). Implemented as any other
* device-proc in the server.
*
* This function only needs to be implemented if USE_OSMOUSE is
* defined for the OS.
*/
}
int xf86OsMouseEvents(void)
{
/*
* When supporting an OS-based mouse driver (as opposed to the
* server's internal mouse driver), read some events from the device
* and post them to the DIX layer through x386PostMseEvent().
*
* This function only needs to be implemented if USE_OSMOUSE is
* defined for the OS.
*/
}
void xf86OsMouseOption(int token, pointer lex_ptr)
{
/*
* Used in parsing an OsMouse keyword from the Xconfig file.
* Passed the token type and a pointer to the token value.
* The function should do whatever is appropriate for the OS's
* mouse driver.
*
* This function only needs to be implemented if USE_OSMOUSE is
* defined for the OS.
*/
}
$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.2 1996/12/23 06:48:59 dawes Exp $
$Xorg: README.OS-lib,v 1.3 2000/08/17 19:51:19 cpqbld Exp $

View file

@ -0,0 +1,725 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/assyntax.h,v 3.7.2.2 1997/05/11 02:56:22 dawes Exp $ */
#ifndef __ASSYNTAX_H__
#define __ASSYNTAX_H__
/*
* Copyright 1992 Vrije Universiteit, The Netherlands
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, 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 the Vrije Universiteit not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. The Vrije Universiteit makes no
* representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
* The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL The Vrije Universiteit 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.
*/
/* $Xorg: assyntax.h,v 1.3 2000/08/17 19:51:19 cpqbld Exp $ */
/*
* assyntax.h
*
* Select the syntax appropriate to the 386 assembler being used
* To add support for more assemblers add more columns to the CHOICE
* macro. Note that register names must also have uppercase names
* to avoid macro recursion. e.g., #define ah %ah recurses!
*
* NB 1. Some of the macros for certain assemblers imply that the code is to
* run in protected mode!! Caveat emptor.
*
* NB 2. 486 specific instructions are not included. This is to discourage
* their accidental use in code that is intended to run on 386 and 486
* systems.
*
* Supported assemblers:
*
* (a) AT&T SysVr4 as(1): default
* (b) GNU Assembler gas: define USE_GAS or GNU_ASSEMBLER
* (c) Amsterdam Compiler kit: define ACK_ASSEMBLER
*
* The following naming conventions have been used to identify the various
* data types:
* _SR = segment register version
* Integer:
* _Q = quadword = 64 bits
* _L = long = 32 bits
* _W = short = 16 bits
* _B = byte = 8 bits
* Floating-point:
* _X = m80real = 80 bits
* _D = double = 64 bits
* _S = single = 32 bits
*
* Author: Gregory J. Sharp, Sept 1992
* Vrije Universiteit, Amsterdam, The Netherlands
*/
#if defined(USE_GAS) && !defined(GNU_ASSEMBLER)
#define GNU_ASSEMBLER
#endif
#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__))
#define CONCAT(x, y) x ## y
#else
#define CONCAT(x, y) x/**/y
#endif
#ifdef ACK_ASSEMBLER
/* Assume we write code for 32-bit protected mode! */
/* Redefine register names for GAS & AT&T assemblers */
#define AL al
#define AH ah
#define AX ax
#define EAX ax
#define BL bl
#define BH bh
#define BX bx
#define EBX bx
#define CL cl
#define CH ch
#define CX cx
#define ECX cx
#define DL dl
#define DH dh
#define DX dx
#define EDX dx
#define BP bp
#define EBP bp
#define SI si
#define ESI si
#define DI di
#define EDI di
#define SP sp
#define ESP sp
#define CS cs
#define SS ss
#define DS ds
#define ES es
#define FS fs
#define GS gs
/* Control Registers */
#define CR0 cr0
#define CR1 cr1
#define CR2 cr2
#define CR3 cr3
/* Debug Registers */
#define DR0 dr0
#define DR1 dr1
#define DR2 dr2
#define DR3 dr3
#define DR4 dr4
#define DR5 dr5
#define DR6 dr6
#define DR7 dr7
/* Floating-point Stack */
#define ST st
#define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
#define _WTOG o16 /* word toggle for _W instructions */
#define _LTOG /* long toggle for _L instructions */
#define ADDR_TOGGLE a16
#define OPSZ_TOGGLE o16
#define USE16 .use16
#define USE32 .use32
#define CHOICE(a,b,c) c
#else /* AT&T or GAS */
/* Redefine register names for GAS & AT&T assemblers */
#define AL %al
#define AH %ah
#define AX %ax
#define EAX %eax
#define BL %bl
#define BH %bh
#define BX %bx
#define EBX %ebx
#define CL %cl
#define CH %ch
#define CX %cx
#define ECX %ecx
#define DL %dl
#define DH %dh
#define DX %dx
#define EDX %edx
#define BP %bp
#define EBP %ebp
#define SI %si
#define ESI %esi
#define DI %di
#define EDI %edi
#define SP %sp
#define ESP %esp
#define CS %cs
#define SS %ss
#define DS %ds
#define ES %es
#define FS %fs
#define GS %gs
/* Control Registers */
#define CR0 %cr0
#define CR1 %cr1
#define CR2 %cr2
#define CR3 %cr3
/* Debug Registers */
#define DR0 %db0
#define DR1 %db1
#define DR2 %db2
#define DR3 %db3
#define DR4 %db4
#define DR5 %db5
#define DR6 %db6
#define DR7 %db7
/* Floating-point Stack */
#define ST %st
#define AS_BEGIN
#define USE16
#define USE32
#ifdef GNU_ASSEMBLER
#define ADDR_TOGGLE aword
#define OPSZ_TOGGLE word
#define CHOICE(a,b,c) b
#else
/*
* AT&T ASSEMBLER SYNTAX
* *********************
*/
#define CHOICE(a,b,c) a
#define ADDR_TOGGLE addr16
#define OPSZ_TOGGLE data16
#endif /* GNU_ASSEMBLER */
#endif /* ACK_ASSEMBLER */
#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || (defined(linux) || defined(__OS2ELF__)) && defined(__ELF__)
#define GLNAME(a) a
#else
#define GLNAME(a) CONCAT(_,a)
#endif
/****************************************/
/* */
/* Select the various choices */
/* */
/****************************************/
/* Redefine assembler directives */
/*********************************/
#define GLOBL CHOICE(.globl, .globl, .extern)
#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4)
#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2)
/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
* guaranteed to be filled with NOPs. Otherwise it does nothing.
*/
#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/)
#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4)
#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2)
#define FILE(s) CHOICE(.file s, .file s, .file s)
#define STRING(s) CHOICE(.string s, .asciz s, .asciz s)
#define D_LONG CHOICE(.long, .long, .data4)
#define D_WORD CHOICE(.value, .short, .data2)
#define D_BYTE CHOICE(.byte, .byte, .data1)
#define SPACE CHOICE(.comm, .space, .space)
#define COMM CHOICE(.comm, .comm, .comm)
#define SEG_DATA CHOICE(.data, .data, .sect .data)
#define SEG_TEXT CHOICE(.text, .text, .sect .text)
#define SEG_BSS CHOICE(.bss, .bss, .sect .bss)
#ifdef GNU_ASSEMBLER
#define D_SPACE(n) . = . + n
#else
#define D_SPACE(n) .space n
#endif
/* Addressing Modes */
/* Immediate Mode */
#define ADDR(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
#define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a)
/* Indirect Mode */
#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */
#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */
/* Register b indirect plus displacement a */
#define REGOFF(a, b) CHOICE(a(b), a(b), a(b))
/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode
* which has no scaling
*/
#define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i))
/* Reg indirect Base + (Index * Scale) + Displacement */
#define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s))
/* Displaced Scaled Index: */
#define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s))
/* Indexed Base: */
#define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i))
/* Displaced Base: */
#define REGDB(d,b) CHOICE(d(b), d(b), d(b))
/* Variable indirect: */
#define VARINDIRECT(var) CHOICE(*var, *var, (var))
/* Use register contents as jump/call target: */
#define CODEPTR(reg) CHOICE(*reg, *reg, reg)
/* For expressions requiring bracketing
* eg. (CRT0_PM | CRT_EM)
*/
#define EXPR(a) CHOICE([a], (a), [a])
#define ENOT(a) CHOICE(0!a, ~a, ~a)
#define EMUL(a,b) CHOICE(a\*b, a*b, a*b)
#define EDIV(a,b) CHOICE(a\/b, a/b, a/b)
/*
* We have to beat the problem of commas within arguments to choice.
* eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI
* and other known cpp definitions evaluate arguments before substitution
* so the following works.
*/
#define ARG2(a, b) a,b
#define ARG3(a,b,c) a,b,c
/* Redefine assembler commands */
#define AAA CHOICE(aaa, aaa, aaa)
#define AAD CHOICE(aad, aad, aad)
#define AAM CHOICE(aam, aam, aam)
#define AAS CHOICE(aas, aas, aas)
#define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a))
#define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a))
#define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a))
#define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a))
#define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a))
#define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a))
#define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a))
#define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a))
#define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a))
#define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a))
#define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a))
#define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a))
#define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a))
#define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a))
#define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a))
#define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a))
#define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a))
#define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a))
#define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a))
#define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a))
#define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a))
#define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a))
#define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a))
#define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a))
#define CALL(a) CHOICE(call a, call a, call a)
#define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a)
#define CBW CHOICE(cbtw, cbw, cbw)
#define CWDE CHOICE(cwtd, cwde, cwde)
#define CLC CHOICE(clc, clc, clc)
#define CLD CHOICE(cld, cld, cld)
#define CLI CHOICE(cli, cli, cli)
#define CLTS CHOICE(clts, clts, clts)
#define CMC CHOICE(cmc, cmc, cmc)
#define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a))
#define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a))
#define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a))
#define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps)
#define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps)
#define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb)
#define CWD CHOICE(cwtl, cwd, cwd)
#define CDQ CHOICE(cltd, cdq, cdq)
#define DAA CHOICE(daa, daa, daa)
#define DAS CHOICE(das, das, das)
#define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a)
#define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a)
#define DEC_B(a) CHOICE(decb a, decb a, decb a)
#define DIV_L(a) CHOICE(divl a, divl a, div a)
#define DIV_W(a) CHOICE(divw a, divw a, div a)
#define DIV_B(a) CHOICE(divb a, divb a, divb a)
#define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a))
#define HLT CHOICE(hlt, hlt, hlt)
#define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a)
#define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a)
#define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a)
/* More forms than this for imul!! */
#define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a))
#define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a))
#define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a)
#define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX)
#define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX)
#define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX)
/* Please AS code writer: use the following ONLY, if you refer to ports<256
* directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer
*/
#if defined (sun)
#define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a)
#define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a)
#define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a)
#else
#define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a)
#define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a)
#define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a)
#endif
#define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a)
#define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a)
#define INC_B(a) CHOICE(incb a, incb a, incb a)
#define INS_L CHOICE(insl, insl, _LTOG ins)
#define INS_W CHOICE(insw, insw, _WTOG ins)
#define INS_B CHOICE(insb, insb, insb)
#define INT(a) CHOICE(int a, int a, int a)
#define INT3 CHOICE(int CONST(3), int3, int CONST(3))
#define INTO CHOICE(into, into, into)
#define IRET CHOICE(iret, iret, iret)
#define IRETD CHOICE(iret, iret, iretd)
#define JA(a) CHOICE(ja a, ja a, ja a)
#define JAE(a) CHOICE(jae a, jae a, jae a)
#define JB(a) CHOICE(jb a, jb a, jb a)
#define JBE(a) CHOICE(jbe a, jbe a, jbe a)
#define JC(a) CHOICE(jc a, jc a, jc a)
#define JE(a) CHOICE(je a, je a, je a)
#define JG(a) CHOICE(jg a, jg a, jg a)
#define JGE(a) CHOICE(jge a, jge a, jge a)
#define JL(a) CHOICE(jl a, jl a, jl a)
#define JLE(a) CHOICE(jle a, jle a, jle a)
#define JNA(a) CHOICE(jna a, jna a, jna a)
#define JNAE(a) CHOICE(jnae a, jnae a, jnae a)
#define JNB(a) CHOICE(jnb a, jnb a, jnb a)
#define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a)
#define JNC(a) CHOICE(jnc a, jnc a, jnc a)
#define JNE(a) CHOICE(jne a, jne a, jne a)
#define JNG(a) CHOICE(jng a, jng a, jng a)
#define JNGE(a) CHOICE(jnge a, jnge a, jnge a)
#define JNL(a) CHOICE(jnl a, jnl a, jnl a)
#define JNLE(a) CHOICE(jnle a, jnle a, jnle a)
#define JNO(a) CHOICE(jno a, jno a, jno a)
#define JNP(a) CHOICE(jnp a, jnp a, jnp a)
#define JNS(a) CHOICE(jns a, jns a, jns a)
#define JNZ(a) CHOICE(jnz a, jnz a, jnz a)
#define JO(a) CHOICE(jo a, jo a, jo a)
#define JP(a) CHOICE(jp a, jp a, jp a)
#define JPE(a) CHOICE(jpe a, jpe a, jpe a)
#define JPO(a) CHOICE(jpo a, jpo a, jpo a)
#define JS(a) CHOICE(js a, js a, js a)
#define JZ(a) CHOICE(jz a, jz a, jz a)
#define JMP(a) CHOICE(jmp a, jmp a, jmp a)
#define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a)
#define LAHF CHOICE(lahf, lahf, lahf)
#if !defined(_REAL_MODE) && !defined(_V86_MODE)
#define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a))
#endif
#define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a))
#define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a))
#define LEAVE CHOICE(leave, leave, leave)
#define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a)
#define LIDT(a) CHOICE(lidt a, lidt a, lidt a)
#define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a))
#define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a))
#define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a))
#define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a))
#define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a))
#define LLDT(a) CHOICE(lldt a, lldt a, lldt a)
#define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a)
#define LOCK CHOICE(lock, lock, lock)
#define LODS_L CHOICE(lodsl, lodsl, _LTOG lods)
#define LODS_W CHOICE(lodsw, lodsw, _WTOG lods)
#define LODS_B CHOICE(lodsb, lodsb, lodsb)
#define LOOP(a) CHOICE(loop a, loop a, loop a)
#define LOOPE(a) CHOICE(loope a, loope a, loope a)
#define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a)
#define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a)
#define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a)
#if !defined(_REAL_MODE) && !defined(_V86_MODE)
#define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a))
#endif
#define LTR(a) CHOICE(ltr a, ltr a, ltr a)
#define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a))
#define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a))
#define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a))
#define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a))
#define MOVS_L CHOICE(movsl, movsl, _LTOG movs)
#define MOVS_W CHOICE(movsw, movsw, _WTOG movs)
#define MOVS_B CHOICE(movsb, movsb, movsb)
#define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a))
#define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a))
#define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a))
#define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a))
#define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a))
#define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a))
#define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a)
#define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a)
#define MUL_B(a) CHOICE(mulb a, mulb a, mulb a)
#define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a)
#define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a)
#define NEG_B(a) CHOICE(negb a, negb a, negb a)
#define NOP CHOICE(nop, nop, nop)
#define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a)
#define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a)
#define NOT_B(a) CHOICE(notb a, notb a, notb a)
#define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a))
#define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a))
#define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a))
#define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX)
#define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX)
#define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX)
/* Please AS code writer: use the following ONLY, if you refer to ports<256
* directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer
*/
#define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a)
#define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a)
#define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a)
#define OUTS_L CHOICE(outsl, outsl, _LTOG outs)
#define OUTS_W CHOICE(outsw, outsw, _WTOG outs)
#define OUTS_B CHOICE(outsb, outsb, outsb)
#define POP_SR(a) CHOICE(pop a, pop a, pop a)
#define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a)
#define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a)
#define POPA_L CHOICE(popal, popal, _LTOG popa)
#define POPA_W CHOICE(popaw, popaw, _WTOG popa)
#define POPF_L CHOICE(popfl, popfl, _LTOG popf)
#define POPF_W CHOICE(popfw, popfw, _WTOG popf)
#define PUSH_SR(a) CHOICE(push a, push a, push a)
#define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a)
#define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a)
#define PUSH_B(a) CHOICE(push a, pushb a, push a)
#define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha)
#define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha)
#define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf)
#define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf)
#define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a))
#define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a))
#define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a))
#define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a))
#define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a))
#define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a))
#define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a))
#define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a))
#define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a))
#define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a))
#define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a))
#define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a))
#define REP CHOICE(rep ;, rep ;, repe)
#define REPE CHOICE(repz ;, repe ;, repe)
#define REPNE CHOICE(repnz ;, repne ;, repne)
#define REPNZ REPNE
#define REPZ REPE
#define RET CHOICE(ret, ret, ret)
#define SAHF CHOICE(sahf, sahf, sahf)
#define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a))
#define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a))
#define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a))
#define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a))
#define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a))
#define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a))
#define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a))
#define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a))
#define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a))
#define SCAS_L CHOICE(scasl, scasl, _LTOG scas)
#define SCAS_W CHOICE(scasw, scasw, _WTOG scas)
#define SCAS_B CHOICE(scasb, scasb, scasb)
#define SETA(a) CHOICE(seta a, seta a, seta a)
#define SETAE(a) CHOICE(setae a, setae a, setae a)
#define SETB(a) CHOICE(setb a, setb a, setb a)
#define SETBE(a) CHOICE(setbe a, setbe a, setbe a)
#define SETC(a) CHOICE(setc a, setb a, setb a)
#define SETE(a) CHOICE(sete a, sete a, sete a)
#define SETG(a) CHOICE(setg a, setg a, setg a)
#define SETGE(a) CHOICE(setge a, setge a, setge a)
#define SETL(a) CHOICE(setl a, setl a, setl a)
#define SETLE(a) CHOICE(setle a, setle a, setle a)
#define SETNA(a) CHOICE(setna a, setna a, setna a)
#define SETNAE(a) CHOICE(setnae a, setnae a, setnae a)
#define SETNB(a) CHOICE(setnb a, setnb a, setnb a)
#define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a)
#define SETNC(a) CHOICE(setnc a, setnb a, setnb a)
#define SETNE(a) CHOICE(setne a, setne a, setne a)
#define SETNG(a) CHOICE(setng a, setng a, setng a)
#define SETNGE(a) CHOICE(setnge a, setnge a, setnge a)
#define SETNL(a) CHOICE(setnl a, setnl a, setnl a)
#define SETNLE(a) CHOICE(setnle a, setnle a, setnle a)
#define SETNO(a) CHOICE(setno a, setno a, setno a)
#define SETNP(a) CHOICE(setnp a, setnp a, setnp a)
#define SETNS(a) CHOICE(setns a, setns a, setna a)
#define SETNZ(a) CHOICE(setnz a, setnz a, setnz a)
#define SETO(a) CHOICE(seto a, seto a, seto a)
#define SETP(a) CHOICE(setp a, setp a, setp a)
#define SETPE(a) CHOICE(setpe a, setpe a, setpe a)
#define SETPO(a) CHOICE(setpo a, setpo a, setpo a)
#define SETS(a) CHOICE(sets a, sets a, seta a)
#define SETZ(a) CHOICE(setz a, setz a, setz a)
#define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a)
#define SIDT(a) CHOICE(sidt a, sidt a, sidt a)
#define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a))
#define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a))
#define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a))
#define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a))
#define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL))
#define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a))
#define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL))
#define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a))
#define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a))
#define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a))
#define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a))
#define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL))
#define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a))
#define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL))
#define SLDT(a) CHOICE(sldt a, sldt a, sldt a)
#define SMSW(a) CHOICE(smsw a, smsw a, smsw a)
#define STC CHOICE(stc, stc, stc)
#define STD CHOICE(std, std, std)
#define STI CHOICE(sti, sti, sti)
#define STOS_L CHOICE(stosl, stosl, _LTOG stos)
#define STOS_W CHOICE(stosw, stosw, _WTOG stos)
#define STOS_B CHOICE(stosb, stosb, stosb)
#define STR(a) CHOICE(str a, str a, str a)
#define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a))
#define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a))
#define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a))
#define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a))
#define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a))
#define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a))
#define VERR(a) CHOICE(verr a, verr a, verr a)
#define VERW(a) CHOICE(verw a, verw a, verw a)
#define WAIT CHOICE(wait, wait, wait)
#define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a))
#define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a))
#define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a))
#define XLAT CHOICE(xlat, xlat, xlat)
#define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a))
#define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a))
#define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a))
/* Floating Point Instructions */
#define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1)
#define FABS CHOICE(fabs, fabs, fabs)
#define FADD_D(a) CHOICE(faddl a, faddl a, faddd a)
#define FADD_S(a) CHOICE(fadds a, fadds a, fadds a)
#define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a))
#define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a))
#define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a)
#define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a)
#define FBLD(a) CHOICE(fbld a, fbld a, fbld a)
#define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a)
#define FCHS CHOICE(fchs, fchs, fchs)
#define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex)
#define FNCLEX CHOICE(fnclex, fnclex, fclex)
#define FCOM(a) CHOICE(fcom a, fcom a, fcom a)
#define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a)
#define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a)
#define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a)
#define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a)
#define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a)
#define FCOMPP CHOICE(fcompp, fcompp, fcompp)
#define FCOS CHOICE(fcos, fcos, fcos)
#define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp)
#define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a)
#define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a)
#define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a))
#define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a))
#define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a)
#define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a)
#define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a)
#define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a)
#define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a))
#define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a))
#define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a)
#define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a)
#define FFREE(a) CHOICE(ffree a, ffree a, ffree a)
#define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a)
#define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a)
#define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a)
#define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a)
#define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a)
#define FILD_L(a) CHOICE(fildl a, fildl a, fildl a)
#define FILD_W(a) CHOICE(fild a, filds a, filds a)
#define FINCSTP CHOICE(fincstp, fincstp, fincstp)
#define FINIT CHOICE(finit, wait; fninit, wait; finit)
#define FNINIT CHOICE(fninit, fninit, finit)
#define FIST_L(a) CHOICE(fistl a, fistl a, fistl a)
#define FIST_W(a) CHOICE(fist a, fists a, fists a)
#define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a)
#define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a)
#define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a)
#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */
#define FLD_D(a) CHOICE(fldl a, fldl a, fldd a)
#define FLD_S(a) CHOICE(flds a, flds a, flds a)
#define FLD1 CHOICE(fld1, fld1, fld1)
#define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t)
#define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e)
#define FLDPI CHOICE(fldpi, fldpi, fldpi)
#define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2)
#define FLDLN2 CHOICE(fldln2, fldln2, fldln2)
#define FLDZ CHOICE(fldz, fldz, fldz)
#define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a)
#define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a)
#define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a)
#define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a)
#define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a))
#define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a))
#define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a)
#define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a)
#define FNOP CHOICE(fnop, fnop, fnop)
#define FPATAN CHOICE(fpatan, fpatan, fpatan)
#define FPREM CHOICE(fprem, fprem, fprem)
#define FPREM1 CHOICE(fprem1, fprem1, fprem1)
#define FPTAN CHOICE(fptan, fptan, fptan)
#define FRNDINT CHOICE(frndint, frndint, frndint)
#define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a)
#define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a)
#define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a)
#define FSCALE CHOICE(fscale, fscale, fscale)
#define FSIN CHOICE(fsin, fsin, fsin)
#define FSINCOS CHOICE(fsincos, fsincos, fsincos)
#define FSQRT CHOICE(fsqrt, fsqrt, fsqrt)
#define FST_D(a) CHOICE(fstl a, fstl a, fstd a)
#define FST_S(a) CHOICE(fsts a, fsts a, fsts a)
#define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a)
#define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a)
#define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a)
#define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a)
#define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a)
#define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a)
#define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a)
#define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a)
#define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a)
#define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a)
#define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a)
#define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a))
#define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a))
#define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a)
#define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a)
#define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a)
#define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a)
#define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a))
#define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a))
#define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a)
#define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a)
#define FTST CHOICE(ftst, ftst, ftst)
#define FUCOM(a) CHOICE(fucom a, fucom a, fucom a)
#define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a)
#define FUCOMPP CHOICE(fucompp, fucompp, fucompp)
#define FWAIT CHOICE(wait, wait, wait)
#define FXAM CHOICE(fxam, fxam, fxam)
#define FXCH(a) CHOICE(fxch a, fxch a, fxch a)
#define FXTRACT CHOICE(fxtract, fxtract, fxtract)
#define FYL2X CHOICE(fyl2x, fyl2x, fyl2x)
#define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1)
#endif /* __ASSYNTAX_H__ */

View file

@ -0,0 +1,92 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c,v 3.5 1996/12/23 06:49:35 dawes Exp $ */
/*
* Derived from VTsw_usl.c which is
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
* by S_ren Schmidt (sos@login.dkuug.dk)
*
* 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.
*
*/
/* $Xorg: bsd_VTsw.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
/*
* Handle the VT-switching interface for OSs that use USL-style ioctl()s
* (the bsd, 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(sig)
int sig;
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = TRUE;
}
#endif
return;
}
Bool xf86VTSwitchPending()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
return(xf86Info.vtRequestsPending ? TRUE : FALSE);
}
#endif
return FALSE;
}
Bool xf86VTSwitchAway()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
return(FALSE);
else
return(TRUE);
}
#endif
return FALSE;
}
Bool xf86VTSwitchTo()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
return(FALSE);
else
return(TRUE);
}
#endif
return(TRUE);
}

View file

@ -0,0 +1,780 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.8.2.1 1998/02/06 22:36:49 hohndel Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Rich Murphey and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Rich Murphey and
* David Wexelblat make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: bsd_init.c,v 1.3 2000/08/17 19:51:21 cpqbld 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"
extern void xf86VTRequest(
#if NeedFunctionPrototypes
int
#endif
);
static Bool KeepTty = FALSE;
static int devConsoleFd = -1;
static int VTnum = -1;
static int initialVT = -1;
#ifdef PCCONS_SUPPORT
/* Stock 0.1 386bsd pccons console driver interface */
#ifndef __OpenBSD__
# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
#else
# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0"
#endif
#define PCCONS_CONSOLE_DEV2 "/dev/vga"
#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
#endif
#ifdef CODRV_SUPPORT
/* Holger Veit's codrv console driver */
#define CODRV_CONSOLE_DEV "/dev/kbd"
#define CODRV_CONSOLE_MODE O_RDONLY|O_NDELAY
#endif
#ifdef SYSCONS_SUPPORT
/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
#endif
#ifdef PCVT_SUPPORT
/* Hellmuth Michaelis' pcvt driver */
#ifndef __OpenBSD__
# define PCVT_CONSOLE_DEV "/dev/ttyv0"
#else
# define PCVT_CONSOLE_DEV "/dev/ttyC0"
#endif
#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
#endif
#define CHECK_DRIVER_MSG \
"Check your kernel's console driver configuration and /dev entries"
static char *supported_drivers[] = {
#ifdef PCCONS_SUPPORT
"pccons (with X support)",
#endif
#ifdef CODRV_SUPPORT
"codrv",
#endif
#ifdef SYSCONS_SUPPORT
"syscons",
#endif
#ifdef PCVT_SUPPORT
"pcvt",
#endif
};
/*
* Functions to probe for the existance of a supported console driver.
* Any function returns either a valid file descriptor (driver probed
* succesfully), -1 (driver not found), or uses FatalError() if the
* driver was found but proved to not support the required mode to run
* an X server.
*/
typedef int (*xf86ConsOpen_t)(
#if NeedFunctionPrototypes
void
#endif
);
#ifdef PCCONS_SUPPORT
static int xf86OpenPccons(
#if NeedFunctionPrototypes
void
#endif
);
#endif /* PCCONS_SUPPORT */
#ifdef CODRV_SUPPORT
static int xf86OpenCodrv(
#if NeedFunctionPrototypes
void
#endif
);
#endif /* CODRV_SUPPORT */
#ifdef SYSCONS_SUPPORT
static int xf86OpenSyscons(
#if NeedFunctionPrototypes
void
#endif
);
#endif /* SYSCONS_SUPPORT */
#ifdef PCVT_SUPPORT
static int xf86OpenPcvt(
#if NeedFunctionPrototypes
void
#endif
);
#endif /* PCVT_SUPPORT */
/*
* The sequence of the driver probes is important; start with the
* driver that is best distinguishable, and end with the most generic
* driver. (Otherwise, pcvt would also probe as syscons, and either
* pcvt or syscons might succesfully probe as pccons. Only codrv is
* at its own.)
*/
static xf86ConsOpen_t xf86ConsTab[] = {
#ifdef PCVT_SUPPORT
xf86OpenPcvt,
#endif
#ifdef CODRV_SUPPORT
xf86OpenCodrv,
#endif
#ifdef SYSCONS_SUPPORT
xf86OpenSyscons,
#endif
#ifdef PCCONS_SUPPORT
xf86OpenPccons,
#endif
(xf86ConsOpen_t)NULL
};
void
xf86OpenConsole()
{
int i, fd;
#ifdef CODRV_SUPPORT
int onoff;
#endif
xf86ConsOpen_t *driver;
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
vtmode_t vtmode;
#endif
if (serverGeneration == 1)
{
/* check if we are 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");
}
if (!KeepTty)
{
/*
* detaching the controlling tty solves problems of kbd character
* loss. This is not interesting for CO driver, because it is
* exclusive.
*/
setpgrp(0, getpid());
if ((i = open("/dev/tty",O_RDWR)) >= 0)
{
ioctl(i,TIOCNOTTY,(char *)0);
close(i);
}
}
/* detect which driver we are running on */
for (driver = xf86ConsTab; *driver; driver++)
{
if((fd = (*driver)()) >= 0)
break;
}
/* Check that a supported console driver was found */
if (fd < 0)
{
char cons_drivers[80] = {0, };
for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
{
if (i)
{
strcat(cons_drivers, ", ");
}
strcat(cons_drivers, supported_drivers[i]);
}
FatalError(
"%s: No console driver found\n\tSupported drivers: %s\n\t%s\n",
"xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
}
fclose(stdin);
xf86Info.consoleFd = fd;
xf86Info.screenFd = fd;
xf86Config(FALSE); /* Read XF86Config */
switch (xf86Info.consType)
{
#ifdef CODRV_SUPPORT
case CODRV011:
case CODRV01X:
onoff = X_MODE_ON;
if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE, &onoff) < 0)
{
FatalError("%s: CONSOLE_X_MODE ON failed (%s)\n%s\n",
"xf86OpenConsole", strerror(errno),
CHECK_DRIVER_MSG);
}
if (xf86Info.consType == CODRV01X)
ioctl(xf86Info.consoleFd, VGATAKECTRL, 0);
break;
#endif
#ifdef PCCONS_SUPPORT
case PCCONS:
if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
{
FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s\n",
"xf86OpenConsole", strerror(errno),
CHECK_DRIVER_MSG);
}
/*
* Hack to prevent keyboard hanging when syslogd closes
* /dev/console
*/
if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
{
ErrorF("Warning: couldn't open /dev/console (%s)\n",
strerror(errno));
}
break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
/*
* First activate the #1 VT. This is a hack to allow a server
* to be started while another one is active. There should be
* a better way.
*/
if (initialVT != 1) {
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
sleep(1);
}
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
}
signal(SIGUSR1, xf86VTRequest);
vtmode.mode = VT_PROCESS;
vtmode.relsig = SIGUSR1;
vtmode.acqsig = SIGUSR1;
vtmode.frsig = SIGUSR1;
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
{
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
}
if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
{
FatalError("xf86OpenConsole: KDENABIO failed (%s)\n",
strerror(errno));
}
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
}
break;
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
}
}
else
{
/* serverGeneration != 1 */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
}
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
}
return;
}
#ifdef PCCONS_SUPPORT
static int
xf86OpenPccons()
{
int fd = -1;
if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
>= 0 ||
(fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
>= 0)
{
if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
{
FatalError(
"%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s\n",
"xf86OpenPccons",
strerror(errno),
"Was expecting pccons driver with X support",
CHECK_DRIVER_MSG);
}
xf86Info.consType = PCCONS;
if (xf86Verbose)
{
ErrorF("Using pccons driver with X support\n");
}
}
return fd;
}
#endif /* PCCONS_SUPPORT */
#ifdef SYSCONS_SUPPORT
static int
xf86OpenSyscons()
{
int fd = -1;
vtmode_t vtmode;
char vtname[12];
struct stat status;
long syscons_version;
/* Check for syscons */
if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
|| (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
{
if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
{
/* Get syscons version */
if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
{
syscons_version = 0;
}
xf86Info.vtno = VTnum;
#ifdef VT_GETACTIVE
if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
initialVT = -1;
#endif
if (xf86Info.vtno == -1)
{
/*
* For old syscons versions (<0x100), VT_OPENQRY returns
* the current VT rather than the next free VT. In this
* case, the server gets started on the current VT instead
* of the next free VT.
*/
#if 0
/* check for the fixed VT_OPENQRY */
if (syscons_version >= 0x100)
{
#endif
if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
{
/* No free VTs */
xf86Info.vtno = -1;
}
#if 0
}
#endif
if (xf86Info.vtno == -1)
{
/*
* All VTs are in use. If initialVT was found, use it.
* Otherwise, if stdin is a VT, use that one.
*/
if (initialVT != -1)
{
xf86Info.vtno = initialVT;
}
else if ((fstat(0, &status) >= 0)
&& S_ISCHR(status.st_mode)
&& (ioctl(0, VT_GETMODE, &vtmode) >= 0))
{
/* stdin is a VT */
xf86Info.vtno = minor(status.st_rdev) + 1;
}
else
{
if (syscons_version >= 0x100)
{
FatalError("%s: Cannot find a free VT\n",
"xf86OpenSyscons");
}
/* Should no longer reach here */
FatalError("%s: %s %s\n\t%s %s\n",
"xf86OpenSyscons",
"syscons versions prior to 1.0 require",
"either the",
"server's stdin be a VT",
"or the use of the vtxx server option");
}
}
}
close(fd);
#ifndef __OpenBSD__
sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
#else
sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
#endif
if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
{
FatalError("xf86OpenSyscons: Cannot open %s (%s)\n",
vtname, strerror(errno));
}
if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
{
FatalError("xf86OpenSyscons: VT_GETMODE failed\n");
}
xf86Info.consType = SYSCONS;
if (xf86Verbose)
{
ErrorF("Using syscons driver with X support");
if (syscons_version >= 0x100)
{
ErrorF(" (version %d.%d)\n", syscons_version >> 8,
syscons_version & 0xFF);
}
else
{
ErrorF(" (version 0.x)\n");
}
ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
}
}
else
{
/* VT_GETMODE failed, probably not syscons */
close(fd);
fd = -1;
}
}
return fd;
}
#endif /* SYSCONS_SUPPORT */
#ifdef CODRV_SUPPORT
static int
xf86OpenCodrv()
{
int fd = -1, onoff = X_MODE_OFF;
struct oldconsinfo ci;
if ((fd = open(CODRV_CONSOLE_DEV, CODRV_CONSOLE_MODE, 0)) >= 0)
{
if (ioctl(fd, CONSOLE_X_MODE, &onoff) < 0)
{
FatalError("%s: CONSOLE_X_MODE on %s failed (%s)\n%s\n%s\n",
"xf86OpenCodrv",
CODRV_CONSOLE_DEV, strerror(errno),
"Was expecting codrv driver",
CHECK_DRIVER_MSG);
}
xf86Info.consType = CODRV011;
}
else
{
if (errno == EBUSY)
{
FatalError("xf86OpenCodrv: %s is already in use (codrv)\n",
CODRV_CONSOLE_DEV);
}
}
else
{
fd = -1;
}
if(fd >= 0)
{
/*
* analyse whether this kernel has sufficient capabilities for
* this xserver, if not don't proceed: it won't work. Also
* find out which codrv version.
*/
#define NECESSARY (CONS_HASKBD|CONS_HASKEYNUM|CONS_HASPX386)
if ((ioctl(fd, OLDCONSGINFO, &ci) < 0 ||
(ci.info1 & NECESSARY) != NECESSARY))
{
FatalError("xf86OpenCodrv: %s\n%s\n%s\n",
"This Xserver has detected the codrv driver, but your",
"kernel doesn't appear to have the required facilities",
CHECK_DRIVER_MSG);
}
/* Check for codrv 0.1.2 or later */
if (ci.info1 & CONS_CODRV2)
{
xf86Info.consType = CODRV01X;
if (xf86Verbose)
{
ErrorF("Using codrv 0.1.2 (or later)\n");
}
}
else
{
if (xf86Verbose)
{
ErrorF("Using codrv 0.1.1\n");
}
}
#undef NECESSARY
}
return fd;
}
#endif /* CODRV_SUPPORT */
#ifdef PCVT_SUPPORT
static int
xf86OpenPcvt()
{
/* This looks much like syscons, since pcvt is API compatible */
int fd = -1;
vtmode_t vtmode;
char vtname[12];
struct stat status;
struct pcvtid pcvt_version;
if ((fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0)) >= 0)
{
if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
{
if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
{
FatalError("%s: VT_GETMODE failed\n%s%s\n%s\n",
"xf86OpenPcvt",
"Found pcvt driver but X11 seems to be",
" not supported.", CHECK_DRIVER_MSG);
}
xf86Info.vtno = VTnum;
if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
initialVT = -1;
if (xf86Info.vtno == -1)
{
if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
{
/* No free VTs */
xf86Info.vtno = -1;
}
if (xf86Info.vtno == -1)
{
/*
* All VTs are in use. If initialVT was found, use it.
* Otherwise, if stdin is a VT, use that one.
*/
if (initialVT != -1)
{
xf86Info.vtno = initialVT;
}
else if ((fstat(0, &status) >= 0)
&& S_ISCHR(status.st_mode)
&& (ioctl(0, VT_GETMODE, &vtmode) >= 0))
{
/* stdin is a VT */
xf86Info.vtno = minor(status.st_rdev) + 1;
}
else
{
FatalError("%s: Cannot find a free VT\n",
"xf86OpenPcvt");
}
}
}
close(fd);
#ifndef __OpenBSD__
sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
#else
sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
#endif
if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
{
FatalError("xf86OpenPcvt: Cannot open %s (%s)\n",
vtname, strerror(errno));
}
if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
{
FatalError("xf86OpenPcvt: VT_GETMODE failed\n");
}
xf86Info.consType = PCVT;
if (xf86Verbose)
{
ErrorF("Using pcvt driver (version %d.%d)\n",
pcvt_version.rmajor, pcvt_version.rminor);
}
}
else
{
/* Not pcvt */
close(fd);
fd = -1;
}
}
return fd;
}
#endif /* PCVT_SUPPORT */
void
xf86CloseConsole()
{
#if defined(CODRV_SUPPORT)
int onoff;
#endif
#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
struct vt_mode VT;
#endif
switch (xf86Info.consType)
{
#ifdef CODRV_SUPPORT
case CODRV011:
case CODRV01X:
onoff = X_MODE_OFF;
if (xf86Info.consType == CODRV01X)
{
ioctl (xf86Info.consoleFd, VGAGIVECTRL, 0);
}
ioctl (xf86Info.consoleFd, CONSOLE_X_MODE, &onoff);
break;
#endif /* CODRV_SUPPORT */
#ifdef PCCONS_SUPPORT
case PCCONS:
ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
break;
#endif /* PCCONS_SUPPORT */
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
{
VT.mode = VT_AUTO;
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
}
if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
{
xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)\n",
strerror(errno));
}
if (initialVT != -1)
ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
break;
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
}
if (xf86Info.screenFd != xf86Info.consoleFd)
{
close(xf86Info.screenFd);
close(xf86Info.consoleFd);
if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
{
xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)\n",
strerror(errno));
}
}
close(xf86Info.consoleFd);
if (devConsoleFd >= 0)
close(devConsoleFd);
return;
}
int
xf86ProcessArgument (argc, argv, i)
int argc;
char *argv[];
int i;
{
/*
* Keep server from detaching from controlling tty. This is useful
* when debugging (so the server can receive keyboard signals.
*/
if (!strcmp(argv[i], "-keeptty"))
{
KeepTty = TRUE;
return(1);
}
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{
if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
VTnum < 1 || VTnum > 12)
{
UseMsg();
VTnum = -1;
return(0);
}
return(1);
}
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
return(0);
}
void
xf86UseMsg()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
ErrorF("vtXX use the specified VT number (1-12)\n");
#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");
return;
}

View file

@ -0,0 +1,257 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.12 1996/12/23 06:49:37 dawes Exp $ */
/*
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* 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 Rich Murphey and David Dawes
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Rich Murphey and
* David Dawes make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL RICH MURPHEY 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.
*
*/
/* $Xorg: bsd_io.c,v 1.3 2000/08/17 19:51:21 cpqbld 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"
void xf86SoundKbdBell(loudness, pitch, duration)
int loudness;
int pitch;
int duration;
{
if (loudness && pitch)
{
#ifdef CODRV_SUPPORT
struct kbd_sound s;
#endif
#ifdef PCCONS_SUPPORT
int data[2];
#endif
switch (xf86Info.consType) {
#ifdef PCCONS_SUPPORT
case PCCONS:
data[0] = pitch;
data[1] = (duration * loudness) / 50;
ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
break;
#endif
#ifdef CODRV_SUPPORT
case CODRV011:
case CODRV01X:
s.pitch = pitch;
s.duration = (duration * loudness) / 50;
ioctl(xf86Info.consoleFd, KBDSETBELL, &s);
break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDMKTONE,
((1193190 / pitch) & 0xffff) |
(((unsigned long)duration*loudness/50)<<16));
break;
#endif
}
}
}
void xf86SetKbdLeds(leds)
int leds;
{
switch (xf86Info.consType) {
case PCCONS:
break;
#ifdef CODRV_SUPPORT
case CODRV011:
case CODRV01X:
leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
ioctl(xf86Info.consoleFd, KBDSLEDS, &leds);
break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDSETLED, leds);
break;
#endif
}
}
int xf86GetKbdLeds()
{
int leds = 0;
switch (xf86Info.consType) {
case PCCONS:
break;
#ifdef CODRV_SUPPORT
case CODRV011:
case CODRV01X:
ioctl(xf86Info.consoleFd, KBDGLEDS, &leds);
leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDGETLED, &leds);
break;
#endif
}
return(leds);
}
#if NeedFunctionPrototypes
void xf86SetKbdRepeat(char rad)
#else
void xf86SetKbdRepeat(rad)
char rad;
#endif
{
switch (xf86Info.consType) {
case PCCONS:
break;
#ifdef CODRV_SUPPORT
case CODRV011:
case CODRV01X:
ioctl(xf86Info.consoleFd, KBDSTPMAT, &rad);
break;
#endif
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDSETRAD, rad);
break;
#endif
}
}
static struct termio kbdtty;
void xf86KbdInit()
{
switch (xf86Info.consType) {
case CODRV011:
case CODRV01X:
break;
#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case PCCONS:
case SYSCONS:
case PCVT:
tcgetattr(xf86Info.consoleFd, &kbdtty);
break;
#endif
}
}
int xf86KbdOn()
{
struct termios nTty;
switch (xf86Info.consType) {
case CODRV011:
case CODRV01X:
break;
#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
case SYSCONS:
case PCCONS:
case PCVT:
nTty = kbdtty;
nTty.c_iflag = IGNPAR | IGNBRK;
nTty.c_oflag = 0;
nTty.c_cflag = CREAD | CS8;
nTty.c_lflag = 0;
nTty.c_cc[VTIME] = 0;
nTty.c_cc[VMIN] = 1;
cfsetispeed(&nTty, 9600);
cfsetospeed(&nTty, 9600);
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
#endif
break;
#endif
}
return(xf86Info.consoleFd);
}
int xf86KbdOff()
{
switch (xf86Info.consType) {
case CODRV011:
case CODRV01X:
break;
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
case SYSCONS:
case PCVT:
ioctl(xf86Info.consoleFd, KDSKBMODE, K_XLATE);
/* FALL THROUGH */
#endif
#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
case PCCONS:
tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
break;
#endif
}
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));
}
xf86SetupMouse(mouse);
/* Flush any pending input */
tcflush(mouse->mseFd, TCIFLUSH);
return(mouse->mseFd);
}

View file

@ -0,0 +1,180 @@
/*
* Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
*
* 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 Frederic Lepied not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED 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.
*
*/
/* Modified for FreeBSD by David Dawes <dawes@XFree86.org> */
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c,v 3.2 1996/01/12 14:34:41 dawes Exp $ */
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <machine/joystick.h>
#include <fcntl.h>
#define JS_RETURN sizeof(struct joystick)
extern int errno;
extern int xf86Verbose;
/***********************************************************************
*
* xf86JoystickOn --
*
* open the device and init timeout according to the device value.
*
***********************************************************************
*/
int
xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY)
{
int status;
int changed = 0;
int timeinmicros;
struct joystick js;
#ifdef DEBUG
ErrorF("xf86JoystickOn: %s\n", name);
#endif
if ((status = open(name, O_RDWR | O_NDELAY)) < 0)
{
ErrorF("xf86JoystickOn: Cannot open joystick '%s' (%s)\n", name,
strerror(errno));
return -1;
}
if (*timeout <= 0) {
/* Use the current setting */
ioctl(status, JOY_GETTIMEOUT, &timeinmicros);
*timeout = timeinmicros / 1000;
if (*timeout == 0)
*timeout = 1;
changed = 1;
}
/* Maximum allowed timeout in the FreeBSD driver is 10ms */
if (*timeout > 10) {
*timeout = 10;
changed = 1;
}
if (changed && xf86Verbose)
ErrorF("(--) Joystick: timeout value = %d\n", *timeout);
timeinmicros = *timeout * 1000;
/* Assume the joystick is centred when this is called */
read(status, &js, JS_RETURN);
if (*centerX < 0) {
*centerX = js.x;
if (xf86Verbose) {
ErrorF("(--) Joystick: CenterX set to %d\n", *centerX);
}
}
if (*centerY < 0) {
*centerY = js.y;
if (xf86Verbose) {
ErrorF("(--) Joystick: CenterY set to %d\n", *centerY);
}
}
return status;
}
/***********************************************************************
*
* xf86JoystickInit --
*
* called when X device is initialized.
*
***********************************************************************
*/
void
xf86JoystickInit()
{
return;
}
/***********************************************************************
*
* xf86JoystickOff --
*
* close the handle.
*
***********************************************************************
*/
int
xf86JoystickOff(fd, doclose)
int *fd;
int doclose;
{
int oldfd;
if (((oldfd = *fd) >= 0) && doclose) {
close(*fd);
*fd = -1;
}
return oldfd;
}
/***********************************************************************
*
* xf86JoystickGetState --
*
* return the state of buttons and the position of the joystick.
*
***********************************************************************
*/
int
xf86JoystickGetState(fd, x, y, buttons)
int fd;
int *x;
int *y;
int *buttons;
{
struct joystick js;
int status;
status = read(fd, &js, JS_RETURN);
if (status != JS_RETURN)
{
Error("Joystick read");
return 0;
}
*x = js.x;
*y = js.y;
*buttons = js.b1 | (js.b2 << 1);
#ifdef DEBUG
ErrorF("xf86JoystickGetState: x = %d, y = %d, buttons = %d\n", *x, *y,
*buttons);
#endif
return 1;
}
/* end of bsd_jstk.c */

View file

@ -0,0 +1,274 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.7.2.3 1998/02/06 22:36:51 hohndel Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Orest Zborowski and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Orest Zborowski
* and David Wexelblat make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: lnx_init.c,v 1.3 2000/08/17 19:51:23 cpqbld 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"
#ifdef USE_DEV_FB
extern char *getenv(const char *);
#include <linux/fb.h>
char *fb_dev_name;
#endif
static Bool KeepTty = FALSE;
static int VTnum = -1;
static int activeVT = -1;
extern void xf86VTRequest(
#if NeedFunctionPrototypes
int
#endif
);
void xf86OpenConsole()
{
int i, fd;
struct vt_mode VT;
char vtname[11];
struct vt_stat vts;
#ifdef USE_DEV_FB
struct fb_var_screeninfo var;
int fbfd;
#endif
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
*/
if (VTnum != -1)
{
xf86Info.vtno = VTnum;
}
else
{
if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0)
{
FatalError(
"xf86OpenConsole: Cannot open /dev/tty0 (%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);
}
#ifdef USE_DEV_FB
fb_dev_name=getenv("FRAMEBUFFER");
if (!fb_dev_name)
fb_dev_name="/dev/fb0current";
if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0)
FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
fb_dev_name, strerror(errno));
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
FatalError("xf86OpenConsole: Unable to get screen info\n");
#endif
ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
sprintf(vtname,"/dev/tty%d",xf86Info.vtno); /* /dev/tty1-64 */
xf86Config(FALSE); /* Read XF86Config */
if (!KeepTty)
{
setpgrp();
}
if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
{
FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
vtname, strerror(errno));
}
/* change ownership of the vt */
chown(vtname, getuid(), getgid());
/*
* the current VT device we're running on is not "console", we want
* to grab all consoles too
*
* Why is this needed?
*/
chown("/dev/tty0", getuid(), getgid());
/*
* Linux doesn't switch to an active vt after the last close of a vt,
* so we do this ourselves by remembering which is active now.
*/
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) == 0)
{
activeVT = vts.v_active;
}
if (!KeepTty)
{
/*
* Detach from the controlling tty to avoid char loss
*/
if ((i = open("/dev/tty",O_RDWR)) >= 0)
{
ioctl(i, TIOCNOTTY, 0);
close(i);
}
}
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
{
FatalError ("xf86OpenConsole: VT_GETMODE failed\n");
}
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");
}
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
}
#ifdef USE_DEV_FB
/* copy info to new console */
var.yoffset=0;
var.xoffset=0;
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
FatalError("Unable to set screen info\n");
close(fbfd);
#endif
}
else
{
/* serverGeneration != 1 */
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
}
}
return;
}
void xf86CloseConsole()
{
struct vt_mode VT;
#if 0
ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
#endif
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
{
VT.mode = VT_AUTO;
ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
}
/*
* Perform a switch back to the active VT when we were started
*/
if (activeVT >= 0)
{
ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
activeVT = -1;
}
close(xf86Info.consoleFd); /* make the vt-manager happy */
return;
}
int xf86ProcessArgument (argc, argv, i)
int argc;
char *argv[];
int i;
{
/*
* Keep server from detaching from controlling tty. This is useful
* when debugging (so the server can receive keyboard signals.
*/
if (!strcmp(argv[i], "-keeptty"))
{
KeepTty = TRUE;
return(1);
}
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");
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");
return;
}

View file

@ -0,0 +1,136 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.3 1996/12/23 06:50:01 dawes Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* 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 Orest Zborowski and David Dawes
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Orest Zborowski
* and David Dawes make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI 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.
*
*/
/* $Xorg: lnx_io.c,v 1.3 2000/08/17 19:51:23 cpqbld 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"
void xf86SoundKbdBell(loudness, pitch, duration)
int loudness;
int pitch;
int duration;
{
if (loudness && pitch)
{
ioctl(xf86Info.consoleFd, KDMKTONE,
((1193190 / pitch) & 0xffff) |
(((unsigned long)duration *
loudness / 50) << 16));
}
}
void xf86SetKbdLeds(leds)
int leds;
{
ioctl(xf86Info.consoleFd, KDSETLED, leds);
}
int xf86GetKbdLeds()
{
int leds;
ioctl(xf86Info.consoleFd, KDGETLED, &leds);
return(leds);
}
#if NeedFunctionPrototypes
void xf86SetKbdRepeat(char rad)
#else
void xf86SetKbdRepeat(rad)
char rad;
#endif
{
return;
}
static int kbdtrans;
static struct termios kbdtty;
void xf86KbdInit()
{
ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
tcgetattr (xf86Info.consoleFd, &kbdtty);
}
int xf86KbdOn()
{
struct termios nTty;
ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
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;
cfsetispeed(&nTty, 9600);
cfsetospeed(&nTty, 9600);
tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
return(xf86Info.consoleFd);
}
int xf86KbdOff()
{
ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
tcsetattr(xf86Info.consoleFd, TCSANOW, &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));
}
xf86SetupMouse(mouse);
/* Flush any pending input */
tcflush(mouse->mseFd, TCIFLUSH);
return(mouse->mseFd);
}

View file

@ -0,0 +1,173 @@
/* $Xorg: lnx_jstk.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */
/* Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp */
/*
* Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net>
*
* 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 Frederic Lepied not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Frederic Lepied makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL FREDERIC LEPIED 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/linux/lnx_jstk.c,v 3.6 1996/12/23 06:50:02 dawes Exp $ */
static const char rcs_id[] = "$Xorg: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp";
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#define inline __inline__
#include <linux/joystick.h>
#include <fcntl.h>
#include <sys/ioctl.h>
extern int errno;
/***********************************************************************
*
* xf86JoystickOn --
*
* open the device and init timeout according to the device value.
*
***********************************************************************
*/
int
xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY)
{
int fd;
struct JS_DATA_TYPE js;
extern int xf86Verbose;
#ifdef DEBUG
ErrorF("xf86JoystickOn %s\n", name);
#endif
if ((fd = open(name, O_RDWR | O_NDELAY)) < 0)
{
ErrorF("Cannot open joystick '%s' (%s)\n", name,
strerror(errno));
return -1;
}
if (*timeout == 0) {
if (ioctl (fd, JS_GET_TIMELIMIT, timeout) == -1) {
Error("joystick JS_GET_TIMELIMIT ioctl");
}
else {
if (xf86Verbose) {
ErrorF("(--) Joystick: timeout value = %d\n", *timeout);
}
}
}
else {
if (ioctl(fd, JS_SET_TIMELIMIT, timeout) == -1) {
Error("joystick JS_SET_TIMELIMIT ioctl");
}
}
/* Assume the joystick is centred when this is called */
read(fd, &js, JS_RETURN);
if (*centerX < 0) {
*centerX = js.x;
if (xf86Verbose) {
ErrorF("(--) Joystick: CenterX set to %d\n", *centerX);
}
}
if (*centerY < 0) {
*centerY = js.y;
if (xf86Verbose) {
ErrorF("(--) Joystick: CenterY set to %d\n", *centerY);
}
}
return fd;
}
/***********************************************************************
*
* xf86JoystickInit --
*
* called when X device is initialized.
*
***********************************************************************
*/
void
xf86JoystickInit()
{
return;
}
/***********************************************************************
*
* xf86JoystickOff --
*
* close the handle.
*
***********************************************************************
*/
int
xf86JoystickOff(fd, doclose)
int *fd;
int doclose;
{
int oldfd;
if (((oldfd = *fd) >= 0) && doclose) {
close(*fd);
*fd = -1;
}
return oldfd;
}
/***********************************************************************
*
* xf86JoystickGetState --
*
* return the state of buttons and the position of the joystick.
*
***********************************************************************
*/
int
xf86JoystickGetState(fd, x, y, buttons)
int fd;
int *x;
int *y;
int *buttons;
{
struct JS_DATA_TYPE js;
int status;
status = read(fd, &js, JS_RETURN);
if (status != JS_RETURN)
{
Error("Joystick read");
return 0;
}
*x = js.x;
*y = js.y;
*buttons = js.buttons;
return 1;
}
/* end of lnx_jstk.c */

View file

@ -0,0 +1,634 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.13.2.1 1997/05/11 05:04:25 dawes Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Orest Zborowski and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Orest Zborowski
* and David Wexelblat make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: lnx_video.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#ifdef __alpha__
/*
* 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 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
#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base())
#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x)
#else
#define BUS_BASE 0
#define JENSEN_SHIFT(x) (x)
#endif
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
/*
* Unfortunatly mmap without MAP_FIXED only works the first time :-(
* This is now fixed in pl13 ALPHA, but still seems to have problems.
*/
#undef ONLY_MMAP_FIXED_WORKS
#ifdef ONLY_MMAP_FIXED_WORKS
static pointer AllocAddress[MAXSCREENS][NUM_REGIONS];
#endif
#if 0
static struct xf86memMap {
int offset;
int memSize;
} xf86memMaps[MAXSCREENS];
#endif
pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
pointer base;
int fd;
#ifdef ONLY_MMAP_FIXED_WORKS
#ifdef __alpha__
FatalError("xf86MapVidMem: Unexpected code for Alpha (pagesize=8k!)\n");
#endif
AllocAddress[ScreenNum][Region] = (pointer)xalloc(Size + 0x1000);
if (AllocAddress[ScreenNum][Region] == NULL)
{
FatalError("xf86MapVidMem: can't alloc framebuffer space\n");
}
base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region]
& ~0xFFF) + 0x1000);
if ((fd = open("/dev/mem", O_RDWR)) < 0)
{
FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
strerror(errno));
}
base = (pointer)mmap((caddr_t)base, Size, PROT_READ|PROT_WRITE,
MAP_FIXED|MAP_SHARED, fd, (off_t)Base);
#else
if ((fd = open("/dev/mem", O_RDWR)) < 0)
{
FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
strerror(errno));
}
/* This requirers linux-0.99.pl10 or above */
base = (pointer)mmap((caddr_t)0, JENSEN_SHIFT(Size),
PROT_READ|PROT_WRITE,
MAP_SHARED, fd,
(off_t)(JENSEN_SHIFT((off_t)Base) + BUS_BASE));
#endif
close(fd);
if ((long)base == -1)
{
FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
strerror(errno));
}
#if 0
xf86memMaps[ScreenNum].offset = (int) Base;
xf86memMaps[ScreenNum].memSize = Size;
#endif
return base;
}
#if 0
void xf86GetVidMemData(ScreenNum, Base, Size)
int ScreenNum;
int *Base;
int *Size;
{
*Base = xf86memMaps[ScreenNum].offset;
*Size = xf86memMaps[ScreenNum].memSize;
}
#endif
void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
munmap((caddr_t)JENSEN_SHIFT(Base), JENSEN_SHIFT(Size));
#ifdef ONLY_MMAP_FIXED_WORKS
xfree(AllocAddress[ScreenNum][Region]);
#endif
}
Bool xf86LinearVidMem()
{
return(TRUE);
}
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
/*
* Linux handles regular (<= 0x3ff) ports with the TSS I/O bitmap, and
* extended ports with the iopl() system call.
*
* For testing, it's useful to enable only the ports we need, but for
* production purposes, it's faster to enable all ports.
*/
#define ALWAYS_USE_EXTENDED
#ifdef ALWAYS_USE_EXTENDED
static Bool ScreenEnabled[MAXSCREENS];
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
void xf86ClearIOPortList(ScreenNum)
int ScreenNum;
{
if (!InitDone)
{
int i;
for (i = 0; i < MAXSCREENS; i++)
ScreenEnabled[i] = FALSE;
InitDone = TRUE;
}
return;
}
void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
int ScreenNum;
int NumPorts;
unsigned *Ports;
{
return;
}
void xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
ScreenEnabled[ScreenNum] = TRUE;
if (ExtendedEnabled)
return;
#ifndef __mc68000__
if (iopl(3))
FatalError("%s: Failed to set IOPL for I/O\n",
"xf86EnableIOPorts");
#endif
ExtendedEnabled = TRUE;
return;
}
void xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
ScreenEnabled[ScreenNum] = FALSE;
if (!ExtendedEnabled)
return;
for (i = 0; i < MAXSCREENS; i++)
if (ScreenEnabled[i])
return;
#ifndef __mc68000__
iopl(0);
#endif
ExtendedEnabled = FALSE;
return;
}
#else /* !ALWAYS_USE_EXTENDED */
static unsigned *EnabledPorts[MAXSCREENS];
static int NumEnabledPorts[MAXSCREENS];
static Bool ScreenEnabled[MAXSCREENS];
static Bool ExtendedPorts[MAXSCREENS];
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
void xf86ClearIOPortList(ScreenNum)
int ScreenNum;
{
if (!InitDone)
{
xf86InitPortLists(EnabledPorts, NumEnabledPorts,
ScreenEnabled, ExtendedPorts, MAXSCREENS);
InitDone = TRUE;
return;
}
ExtendedPorts[ScreenNum] = FALSE;
if (EnabledPorts[ScreenNum] != (unsigned *)NULL)
xfree(EnabledPorts[ScreenNum]);
EnabledPorts[ScreenNum] = (unsigned *)NULL;
NumEnabledPorts[ScreenNum] = 0;
}
void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
int ScreenNum;
int NumPorts;
unsigned *Ports;
{
int i;
if (!InitDone)
{
FatalError("xf86AddIOPorts: I/O control lists not initialised\n");
}
EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum],
(NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned));
for (i = 0; i < NumPorts; i++)
{
EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] =
Ports[i];
if (Ports[i] > 0x3FF)
ExtendedPorts[ScreenNum] = TRUE;
}
NumEnabledPorts[ScreenNum] += NumPorts;
}
void xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
if (ScreenEnabled[ScreenNum])
return;
for (i = 0; i < MAXSCREENS; i++)
{
if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum))
{
#ifndef __mc68000__
if (iopl(3))
{
FatalError("%s: Failed to set IOPL for extended I/O\n",
"xf86EnableIOPorts");
}
#endif
ExtendedEnabled = TRUE;
break;
}
}
/* Extended I/O was used, but not any more */
if (ExtendedEnabled && i == MAXSCREENS)
{
#ifndef __mc68000__
iopl(0);
#endif
ExtendedEnabled = FALSE;
}
/*
* Turn on non-extended ports even when using extended I/O
* so they are there if extended I/O gets turned off when it's no
* longer needed.
*/
for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
{
unsigned port = EnabledPorts[ScreenNum][i];
if (port > 0x3FF)
continue;
if (xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
ScreenEnabled, MAXSCREENS))
{
if (ioperm(port, 1, TRUE) < 0)
{
FatalError("%s: Failed to enable I/O port 0x%x (%s)\n",
"xf86EnableIOPorts", port, strerror(errno));
}
}
}
ScreenEnabled[ScreenNum] = TRUE;
return;
}
void xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
if (!ScreenEnabled[ScreenNum])
return;
ScreenEnabled[ScreenNum] = FALSE;
for (i = 0; i < MAXSCREENS; i++)
{
if (ScreenEnabled[i] && ExtendedPorts[i])
break;
}
if (ExtendedEnabled && i == MAXSCREENS)
{
#ifndef __mc68000__
iopl(0);
#endif
ExtendedEnabled = FALSE;
}
for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
{
unsigned port = EnabledPorts[ScreenNum][i];
if (port > 0x3FF)
continue;
if (xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
ScreenEnabled, MAXSCREENS))
{
ioperm(port, 1, FALSE);
}
}
return;
}
#endif /* ALWAYS_USE_EXTENDED */
void xf86DisableIOPrivs()
{
#ifndef __mc68000__
if (ExtendedEnabled)
iopl(0);
#endif
return;
}
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
Bool xf86DisableInterrupts()
{
if (!ExtendedEnabled)
#ifndef __mc68000__
if (iopl(3))
return (FALSE);
#endif
#if defined(__alpha__) || defined(__mc68000__)
#else
#ifdef __GNUC__
__asm__ __volatile__("cli");
#else
asm("cli");
#endif
#endif
#ifndef __mc68000__
if (!ExtendedEnabled)
iopl(0);
#endif
return (TRUE);
}
void xf86EnableInterrupts()
{
if (!ExtendedEnabled)
#ifndef __mc68000__
if (iopl(3))
return;
#endif
#if defined(__alpha__) || defined(__mc68000__)
#else
#ifdef __GNUC__
__asm__ __volatile__("sti");
#else
asm("sti");
#endif
#endif
#ifndef __mc68000__
if (!ExtendedEnabled)
iopl(0);
#endif
return;
}
#if defined(__alpha__)
static int xf86SparseShift = 5; /* default to all but JENSEN */
pointer xf86MapVidMemSparse(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
pointer base;
int fd;
if (!_bus_base()) xf86SparseShift = 7; /* Uh, oh, JENSEN... */
Size <<= xf86SparseShift;
Base = (pointer)((unsigned long)Base << xf86SparseShift);
if ((fd = open("/dev/mem", O_RDWR)) < 0)
{
FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
strerror(errno));
}
/* This requirers linux-0.99.pl10 or above */
base = (pointer)mmap((caddr_t)0, Size,
PROT_READ | PROT_WRITE,
MAP_SHARED, fd,
(off_t)Base + _bus_base_sparse());
close(fd);
if ((long)base == -1)
{
FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
strerror(errno));
}
return base;
}
void xf86UnMapVidMemSparse(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
Size <<= xf86SparseShift;
munmap((caddr_t)Base, Size);
}
#define vuip volatile unsigned int *
extern void sethae(unsigned long hae);
int xf86ReadSparse8(Base, Offset)
pointer Base;
unsigned long Offset;
{
unsigned long result, shift;
unsigned long msb = 0;
shift = (Offset & 0x3) * 8;
if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */
if (Offset >= (1UL << 24)) {
msb = Offset & 0xf8000000UL;
Offset -= msb;
if (msb) {
sethae(msb);
}
}
}
result = *(vuip) ((unsigned long)Base + (Offset << xf86SparseShift));
if (msb)
sethae(0);
result >>= shift;
return 0xffUL & result;
}
int xf86ReadSparse16(Base, Offset)
pointer Base;
unsigned long Offset;
{
unsigned long result, shift;
unsigned long msb = 0;
shift = (Offset & 0x2) * 8;
if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */
if (Offset >= (1UL << 24)) {
msb = Offset & 0xf8000000UL;
Offset -= msb;
if (msb) {
sethae(msb);
}
}
}
result = *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(1<<(xf86SparseShift-2)));
if (msb)
sethae(0);
result >>= shift;
return 0xffffUL & result;
}
int xf86ReadSparse32(Base, Offset)
pointer Base;
unsigned long Offset;
{
unsigned long result;
unsigned long msb = 0;
if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */
if (Offset >= (1UL << 24)) {
msb = Offset & 0xf8000000UL;
Offset -= msb;
if (msb) {
sethae(msb);
}
}
}
result = *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(3<<(xf86SparseShift-2)));
if (msb)
sethae(0);
return result;
}
void xf86WriteSparse8(Value, Base, Offset)
int Value;
pointer Base;
unsigned long Offset;
{
unsigned long msb = 0;
unsigned int b = Value & 0xffU;
if (xf86SparseShift != 7) { /* not JENSEN */
if (Offset >= (1UL << 24)) {
msb = Offset & 0xf8000000;
Offset -= msb;
if (msb) {
sethae(msb);
}
}
}
*(vuip) ((unsigned long)Base + (Offset << xf86SparseShift)) = b * 0x01010101;
if (msb)
sethae(0);
}
void xf86WriteSparse16(Value, Base, Offset)
int Value;
pointer Base;
unsigned long Offset;
{
unsigned long msb = 0;
unsigned int w = Value & 0xffffU;
if (xf86SparseShift != 7) { /* not JENSEN */
if (Offset >= (1UL << 24)) {
msb = Offset & 0xf8000000;
Offset -= msb;
if (msb) {
sethae(msb);
}
}
}
*(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(1<<(xf86SparseShift-2))) =
w * 0x00010001;
if (msb)
sethae(0);
}
void xf86WriteSparse32(Value, Base, Offset)
int Value;
pointer Base;
unsigned long Offset;
{
unsigned long msb = 0;
if (xf86SparseShift != 7) { /* not JENSEN */
if (Offset >= (1UL << 24)) {
msb = Offset & 0xf8000000;
Offset -= msb;
if (msb) {
sethae(msb);
}
}
}
*(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(3<<(xf86SparseShift-2))) = Value;
if (msb)
sethae(0);
}
#endif /* __alpha__ */

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;
}

View file

@ -0,0 +1,14 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c,v 3.4 1996/12/23 06:50:24 dawes Exp $ */
/*
* This file is an incredible crock to get the normally-inline functions
* built into the server so that things can be debugged properly.
*
* Note: this doesn't work when using a compiler other than GCC.
*/
/* $Xorg: xf86_IlHack.c,v 1.3 2000/08/17 19:51:25 cpqbld Exp $ */
#define static /**/
#define __inline__ /**/
#undef NO_INLINE
#include "compiler.h"

View file

@ -0,0 +1,126 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c,v 3.4 1996/12/23 06:50:25 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the 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.
*
*/
/* $Xorg: xf86_Util.c,v 1.3 2000/08/17 19:51:26 cpqbld Exp $ */
/*
* This file is for utility functions that will be shared by other pieces
* of the system. Putting things here ensure that all the linking order
* dependencies are dealt with, as this library will be linked in last.
*/
#include <ctype.h>
/*
* A portable hack at implementing strcasecmp()
* The characters '_', ' ', and '\t' are ignored in the comparison
*/
int StrCaseCmp(s1, s2)
const char *s1, *s2;
{
char c1, c2;
if (*s1 == 0)
if (*s2 == 0)
return(0);
else
return(1);
while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
s1++;
while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
s2++;
c1 = (isupper(*s1) ? tolower(*s1) : *s1);
c2 = (isupper(*s2) ? tolower(*s2) : *s2);
while (c1 == c2)
{
if (c1 == '\0')
return(0);
s1++; s2++;
while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
s1++;
while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
s2++;
c1 = (isupper(*s1) ? tolower(*s1) : *s1);
c2 = (isupper(*s2) ? tolower(*s2) : *s2);
}
return(c1 - c2);
}
/* For use only with gcc */
#ifdef __GNUC__
#include "os.h"
char *debug_alloca(file, line, size)
char *file;
int line;
int size;
{
char *ptr;
ptr = (char *)Xalloc(size);
ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line,
ptr, size);
return ptr;
}
void debug_dealloca(file, line, ptr)
char *file;
int line;
char *ptr;
{
ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr);
Xfree(ptr);
}
#endif
#if defined(ISC) || defined(Lynx)
#include <math.h>
/* Needed for apm_driver.c */
/* These functions are modeled after the functions inside gnu's libc */
static double copysign(double x, double y)
{
x = fabs(x);
return y < 0 ? - x : x;
}
double RInt(double x)
{
double s,t;
const double one = 1.0;
const static double L = 4503599627370496.0E0;
if (x!=x)
return(x);
if (copysign(x,one) >= L)
return(x);
s = copysign(L,x);
t = x + s;
return (t - s);
}
#endif

View file

@ -0,0 +1,94 @@
/* XFree86: $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
* Copyright 1993 by David McCullough <davidm@stallion.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 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.
*
*/
/* $Xorg: VTsw_sco.c,v 1.3 2000/08/17 19:51:28 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
/*
* Handle the VT-switching interface for SCO
*/
/*
* This function is the signal handler for the VT-switching signal. It
* is only referenced inside the OS-support layer.
*/
void xf86VTRequest(sig)
int sig;
{
signal(sig, (void(*)())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
{
return(TRUE);
}
}
Bool xf86VTSwitchTo()
{
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
{
return(FALSE);
}
else
{
/*
* make sure the console driver thinks the console is in
* graphics mode. Under mono we have to do the two as the
* console driver only allows valid modes for the current
* video card and Herc or vga are the only devices currently
* supported.
*/
if (ioctl(xf86Info.consoleFd, SW_VGA12, 0) < 0)
if (ioctl(xf86Info.consoleFd, SW_HGC_P0, 0) < 0)
{
ErrorF("Failed to set graphics mode : %s\n",
strerror(errno));
}
return(TRUE);
}
}

View file

@ -0,0 +1,261 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c,v 3.10.2.1 1998/02/06 22:36:53 hohndel Exp $ */
/*
* Copyright 1993 by David McCullough <davidm@stallion.oz.au>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of David McCullough and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. David McCullough and
* David Wexelblat makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID MCCULLOUGH AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH OR DAVID WEXELBLAT BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: sco_init.c,v 1.3 2000/08/17 19:51:28 cpqbld 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 Bool KeepTty = FALSE;
static int VTnum = -1;
static int sco_console_mode = -1;
extern void xf86VTRequest(
#if NeedFunctionPrototypes
int
#endif
);
void xf86OpenConsole()
{
int fd,wc;
struct vt_mode VT;
struct stat status;
char vtname[11];
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
*
* SCO vts start at tty01 which is vt00, if you could call them VT's.
* We use the numbers 1..X as it fits nicer with the device naming
* scheme.
*
* In os/osinit.c we took the precuation of not closing stdin so that
* we can use the current vt if no vt was specified on the command line
*
* Under SCO VT_OPENQRY does nothing at all
* if nothing was specified we try to determine the VT from stdin
*/
if ((VTnum != -1) && (VTnum != 0))
{
wc = VTnum - 1;
}
else
{
if ((fstat(0, &status) >= 0) && (status.st_mode & S_IFCHR))
{
wc = minor(status.st_rdev);
}
else
{
ErrorF("%s: Failed to stat stdin, using tty02 (%s)\n",
"xf86OpenConsole", strerror(errno));
wc = 1; /* tty02 */
}
}
ErrorF("(using VT number %d)\n\n", wc + 1);
sprintf(vtname,"/dev/tty%02d", wc+1); /* /dev/tty[01-12] */
if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) < 0)
{
FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
vtname, strerror(errno));
}
/* now we can dispose of stdin */
if (freopen(vtname, "r+", stdin) == (FILE *) NULL)
{
FatalError("xf86OpenConsole: Cannot reopen stdin as %s (%s)\n",
vtname, strerror(errno));
}
/* now we can fixup stdout */
if (freopen(vtname, "r+", stdout) == (FILE *) NULL)
{
FatalError("xf86OpenConsole: Cannot reopen stdout as %s (%s)\n",
vtname, strerror(errno));
}
/* We activate the console just in case its not the one we are on */
xf86Info.vtno = wc;
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, wc) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
xf86Config(FALSE); /* Read XF86Config */
if (!KeepTty)
{
setpgrp();
}
/*
* now get the VT
*/
if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0)
{
FatalError("xf86OpenConsole: VT_GETMODE failed on console (%s)\n",
strerror(errno));
}
if (ioctl(xf86Info.consoleFd, VGA_IOPRIVL, 1) < 0)
{
FatalError("xf86OpenConsole: VGA_IOPRIVL failed for VGA acc (%s)\n",
strerror(errno));
}
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
{
FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n",
strerror(errno));
}
signal(SIGUSR1, xf86VTRequest);
VT.mode = VT_PROCESS;
VT.relsig = SIGUSR1;
VT.acqsig = SIGUSR1;
VT.frsig = SIGUSR1;
VT.waitv = 0;
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
{
FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
}
/*
* make sure the console driver thinks the console is in graphics
* mode. Under mono we have to do the two as the console driver only
* allows valid modes for the current video card and Herc or vga are
* the only devices currently supported.
*/
if (ioctl(xf86Info.consoleFd, SW_VGA12, 0) < 0)
if (ioctl(xf86Info.consoleFd, SW_HGC_P0, 0) < 0)
{
ErrorF("Failed to set graphics mode (%s)\n",
strerror(errno));
}
}
else
{
/* serverGeneration != 1 */
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
}
return;
}
void xf86CloseConsole()
{
struct vt_mode VT;
ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
if (sco_console_mode != -1)
{
ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
}
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;
{
/*
* Keep server from detaching from controlling tty. This is useful
* when debugging (so the server can receive keyboard signals.
*/
if (!strcmp(argv[i], "-keeptty"))
{
KeepTty = TRUE;
return(1);
}
if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
{
if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
{
UseMsg();
VTnum = -1;
return(0);
}
return(1);
}
if (!strcmp(argv[i], "-crt"))
{
if ((++i > argc) ||
(sscanf(argv[i], "/dev/tty%2d", &VTnum) == 0))
{
UseMsg();
VTnum = -1;
return(0);
}
else
{
return(2);
}
}
return(0);
}
void xf86UseMsg()
{
ErrorF("vtXX use the specified VT number\n");
ErrorF("-crt /dev/ttyXX use the specified VT number\n");
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");
return;
}

View file

@ -0,0 +1,117 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c,v 3.3 1996/12/23 06:50:49 dawes Exp $ */
/*
* Copyright 1993 by David McCullough <davidm@stallion.oz.au>
* 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 David McCullough and David Dawes
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. David McCullough
* 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.
*
* DAVID MCCULLOUGH AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH 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.
*
*/
/* $Xorg: sco_io.c,v 1.3 2000/08/17 19:51:29 cpqbld 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"
#include "xf86_Config.h"
void xf86SoundKbdBell(loudness, pitch, duration)
int loudness;
int pitch;
int duration;
{
if (loudness && pitch)
{
ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
usleep(duration * loudness * 20);
ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
}
}
void xf86SetKbdLeds(leds)
int leds;
{
/*
* sleep the first time through under SCO. There appears to be a
* timing problem in the driver which causes the keyboard to be lost.
* This sleep stops it from occurring. The sleep could proably be
* a lot shorter as even trace can fix the problem. You may
* prefer a usleep(100).
*/
static int once = 1;
if (once)
{
sleep(1);
once = 0;
}
ioctl(xf86Info.consoleFd, KDSETLED, leds );
}
void xf86MouseInit(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;
}
FatalError("Cannot open mouse (%s)\n", strerror(errno));
}
}
int xf86MouseOn(mouse)
MouseDevPtr mouse;
{
xf86SetupMouse(mouse);
/* Flush any pending input */
ioctl(mouse->mseFd, TCFLSH, 0);
return(mouse->mseFd);
}
int xf86MouseOff(mouse, doclose)
MouseDevPtr mouse;
Bool doclose;
{
if (mouse->mseFd >= 0)
{
if (mouse->mseType == P_LOGI)
{
write(mouse->mseFd, "U", 1);
xf86SetMouseSpeed(mouse, mouse->baudRate,
mouse->oldBaudRate,
xf86MouseCflags[P_LOGI]);
}
if (doclose)
{
close(mouse->mseFd);
}
}
return(mouse->mseFd);
}

View file

@ -0,0 +1,175 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c,v 3.8 1996/12/23 06:50:50 dawes Exp $ */
/* $Xorg: sco_mouse.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
/******************************************************************************/
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "compiler.h"
#include "xf86.h"
#include "xf86Procs.h"
#include "xf86_OSlib.h"
/******************************************************************************/
#ifdef USE_OSMOUSE
/******************************************************************************/
#include <sys/event.h>
#include <mouse.h>
#include "xf86_Config.h"
static dmask_t real_mask = (dmask_t) (D_REL | D_BUTTON);
static int config_buttons = 0;
extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
unsigned long start, unsigned long stop,
ScreenPtr pScreen);
/******************************************************************************/
/*
* Handle any XF86Config options for "OsMouse", How you treat errors
* is up to you, they may or may not be Fatal
*/
void
xf86OsMouseOption(lt, lp)
int lt; /* type returned by gettoken */
pointer lp; /* The lexical return symbol */
{
if (lt != NUMBER) {
ErrorF("%s: Invalid Argument to OsMouse, %s\n",
"xf86OsMouseOption", "Number of buttons expected");
return;
}
config_buttons = ((LexPtr)lp)->num;
}
/******************************************************************************/
/*
* xf86OsMouseProc --
* Handle the initialization, etc. of a mouse
*/
int
xf86OsMouseProc(pPointer, what)
DeviceIntPtr pPointer;
int what;
{
unchar *map;
int i, err, buttons;
struct devinfo *dip;
dmask_t dmask;
switch (what) {
case DEVICE_INIT:
pPointer->public.on = FALSE;
if (ev_init() < 0)
ErrorF("ev_init: Failed to initialize event driver\n");
dmask = real_mask;
xf86Info.mouseDev->mseFd = ev_open(&dmask);
switch (xf86Info.mouseDev->mseFd) {
case -1: FatalError("ev_open: Error in Configuration files\n");
case -2: FatalError("ev_open: No mouse devices to attach\n");
case -3: FatalError("ev_open: Unable to open a found device\n");
case -4: FatalError("ev_open: unable to open an event queue\n");
default:
if (xf86Info.mouseDev->mseFd < 0)
FatalError("ev_open: Failed to open device, reason unkown\n");
break;
}
if (dmask != real_mask)
FatalError("Could not attach the mouse device (0x%x)\n", dmask);
dip = (struct devinfo *) NULL;
if ((dip = ev_getdev(D_REL, dip)) == (struct devinfo *) NULL)
FatalError("Could not find info on mouse device\n");
buttons = config_buttons > 0 ? config_buttons : ((int) dip->buttons);
buttons = buttons > 0 ? buttons : 3; /* just in case */
ErrorF("%s OsMouse has %d buttons\n",
buttons == config_buttons ? XCONFIG_GIVEN : XCONFIG_PROBED,
buttons);
map = (unchar *) xalloc(buttons + 1);
if (map == (unchar *) NULL)
FatalError("Failed to allocate OsMouse map structure\n");
for (i = 1; i <= buttons; i++)
map[i] = i;
InitPointerDeviceStruct((DevicePtr)pPointer,
map,
buttons,
miPointerGetMotionEvents,
(PtrCtrlProcPtr)xf86MseCtrl,
0);
xfree(map);
ev_suspend(); /* suspend device until its turned on */
break;
case DEVICE_ON:
ev_resume();
AddEnabledDevice(xf86Info.mouseDev->mseFd);
xf86Info.mouseDev->lastButtons = 0;
xf86Info.mouseDev->emulateState = 0;
pPointer->public.on = TRUE;
break;
case DEVICE_CLOSE:
case DEVICE_OFF:
pPointer->public.on = FALSE;
RemoveEnabledDevice(xf86Info.mouseDev->mseFd);
if (what == DEVICE_CLOSE) {
ev_close();
xf86Info.mouseDev->mseFd = -1;
} else
ev_suspend();
break;
}
return Success;
}
/******************************************************************************/
/*
* xf86OsMouseEvents --
* Get some events from our queue. Process all outstanding events now.
*/
void
xf86OsMouseEvents()
{
EVENT *evp;
static long time = -1;
while ((evp = ev_read()) != (EVENT *) NULL ) {
#if DEBUG
if (time == -1)
time = EV_TIME(*evp);
ErrorF("sco_event time(%ld) tag(%d) butts(%d) x(%ld) y(%ld)\n",
EV_TIME(*evp) - time, EV_TAG(*evp), EV_BUTTONS(*evp),
EV_DX(*evp), EV_DY(*evp));
#endif
xf86PostMseEvent(xf86Info.pMouse,EV_BUTTONS(*evp), EV_DX(*evp), -(EV_DY(*evp)));
ev_pop();
}
xf86Info.inputPending = TRUE;
}
/******************************************************************************/
#endif /* USE_OSMOUSE */
/******************************************************************************/

View file

@ -0,0 +1,284 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c,v 3.2.2.1 1997/07/19 04:59:31 dawes Exp $ */
/*
* Copyright 1993 by David McCullough <davidm@stallion.oz.au>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of David McCullough and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. David McCullough and
* David Wexelblat makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID MCCULLOUGH AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH OR DAVID WEXELBLAT BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: sco_video.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#define _NEED_SYSI86
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
static struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS];
static int ver_once = 1;
/***************************************************************************/
/*
* To map the video-memory, we use the MAP_CLASS ioctl.
* Different drivers may have to do another one of these
* for their own special registers (ie., ATI). To find
* out which strings are valid look in /etc/conf/pack.d/cn/class.h
*
* if we fail to find one of these we try for the dmmap driver
*/
struct {
unsigned long base, size;
char *class;
} SCO_Mapping[] = {
{0xA0000, 0x10000, "VGA"},
{0xA0000, 0x20000, "SVGA"},
{0xB0000, 0x08000, "HGA"},
{0x0, 0x0, ""},
};
/* ARGSUSED */
pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
int i;
char *class = (char *)NULL;
pointer base;
for (i=0; SCO_Mapping[i].base != 0; i++)
{
if (((pointer)SCO_Mapping[i].base == Base) &&
(SCO_Mapping[i].size == Size))
{
class = SCO_Mapping[i].class;
break;
}
}
if (class == (char *)NULL)
{
int fd;
#if defined(SVR4) || defined(SCO325)
if ((fd = open(DEV_MEM, O_RDWR)) < 0)
{
FatalError("xf86MapVidMem: failed to open %s (%s)\n",
DEV_MEM, strerror(errno));
}
base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, (off_t)Base);
close(fd);
if ((long)base == -1)
{
FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
"xf86MapVidMem", Size, Base, strerror(errno));
}
return(base);
#else
MapDSC[ScreenNum][Region].vaddr = (char *) NULL;
MapDSC[ScreenNum][Region].physaddr = (char *) Base;
MapDSC[ScreenNum][Region].length = Size;
MapDSC[ScreenNum][Region].ioflg = 1;
if ((fd = open("/dev/dmmap", O_RDWR)) >= 0) {
if (ioctl(fd, KDMAPDISP, &MapDSC[ScreenNum][Region]) == -1)
ErrorF("xf86MapVidMem: dmmap KDMAPDISP failed (%s)\n",
strerror(errno));
else {
if (ver_once)
ErrorF("Using dmmap version 0x%04x.\n",
ioctl(fd, -1));
ver_once = 0;
close(fd);
return(MapDSC[ScreenNum][Region].vaddr);
}
close(fd);
}
FatalError("xf86MapVidMem:No class map defined for (%x,%x)\n",
Base, Size);
/* NOTREACHED */
#endif
}
base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class);
if ((int)base == -1)
{
FatalError("xf86MapVidMem:Failed to map video mem class %s\n",
class);
/* NOTREACHED */
}
return(base);
}
/*
* Nothing to do here if it wasn't mapped using the dmmap driver
*/
/* ARGSUSED */
void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
int fd;
#if defined (SVR4) || defined(SCO325)
munmap(Base, Size);
#else /* SVR4 */
if (MapDSC[ScreenNum][Region].vaddr) {
if ((fd = open("/dev/dmmap", O_RDWR)) < 0) {
if (ioctl(fd, KDUNMAPDISP, &MapDSC[ScreenNum][Region]) == -1)
ErrorF("xf86UnMapVidMem: dmmap KDUNMAPDISP failed (%s)\n",
strerror(errno));
close(fd);
}
MapDSC[ScreenNum][Region].vaddr = (char *) NULL;
MapDSC[ScreenNum][Region].physaddr = (char *) NULL;
MapDSC[ScreenNum][Region].length = 0;
MapDSC[ScreenNum][Region].ioflg = 0;
}
#endif
return;
}
/* ARGSUSED */
Bool xf86LinearVidMem()
{
int fd, ver;
#if defined(SVR4) || defined(SCO325)
return TRUE;
#else
if ((fd = open("/dev/dmmap", O_RDWR)) >= 0) {
ver = ioctl(fd, -1);
close(fd);
if (ver >= 0) {
if (ver_once)
ErrorF("Using dmmap version 0x%04x.\n", ver);
ver_once = 0;
return(TRUE);
}
}
return(FALSE);
#endif
}
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
static Bool ScreenEnabled[MAXSCREENS];
static Bool IOEnabled = FALSE;
static Bool InitDone = FALSE;
void xf86ClearIOPortList(ScreenNum)
int ScreenNum;
{
int i;
if (!InitDone)
{
for (i = 0; i < MAXSCREENS; i++)
ScreenEnabled[i] = FALSE;
InitDone = TRUE;
}
}
/* ARGSUSED */
void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
int ScreenNum;
int NumPorts;
unsigned *Ports;
{
}
void xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
ScreenEnabled[ScreenNum] = TRUE;
if (IOEnabled)
return;
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
FatalError("Failed to set IOPL for extended I/O\n");
IOEnabled = TRUE;
return;
}
void xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
ScreenEnabled[ScreenNum] = FALSE;
if (!IOEnabled)
return;
for (i = 0; i < MAXSCREENS; i++)
if (ScreenEnabled[i])
return;
sysi86(SI86V86, V86SC_IOPL, 0);
IOEnabled = FALSE;
return;
}
void xf86DisableIOPrivs()
{
if (IOEnabled)
sysi86(SI86V86, V86SC_IOPL, 0);
return;
}
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
Bool xf86DisableInterrupts()
{
#ifdef __GNUC__
__asm__ __volatile__("cli");
#else
asm("cli");
#endif /* __GNUC__ */
return(TRUE);
}
void xf86EnableInterrupts()
{
#ifdef __GNUC__
__asm__ __volatile__("sti");
#else
asm("sti");
#endif /* __GNUC__ */
return;
}

View file

@ -0,0 +1,51 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c,v 3.1 1996/12/23 06:50:56 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the 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.
*
*/
/* $Xorg: VTsw_noop.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#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);
}

View file

@ -0,0 +1,80 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c,v 3.1 1996/12/23 06:50:57 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the 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.
*
*/
/* $Xorg: VTsw_usl.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
/*
* 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(sig)
int sig;
{
signal(sig, (void(*)())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
{
return(TRUE);
}
}
Bool xf86VTSwitchTo()
{
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
{
return(FALSE);
}
else
{
return(TRUE);
}
}

View file

@ -0,0 +1,139 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.3 1996/12/23 06:50:58 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the 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.
*
*/
/* $Xorg: bios_devmem.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include <string.h>
/*
* Read BIOS via /dev/mem.
*/
#ifndef DEV_MEM
# define DEV_MEM "/dev/mem"
#endif
int xf86ReadBIOS(Base, Offset, Buf, Len)
unsigned long Base;
unsigned long Offset;
unsigned char *Buf;
int Len;
{
#ifdef __alpha__
/*
* The Alpha version uses "mmap" instead of "lseek/read",
* because these (currently) don't work for BUS memory.
* 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 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<<SPARSE) : (long)x)
#define SIZE (64*1024)
caddr_t base;
int fd;
if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
{
ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM,
strerror(errno));
return(-1);
}
base = mmap((caddr_t)0, JENSEN_SHIFT(SIZE), PROT_READ,
MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE));
if (base == (caddr_t)-1UL)
{
ErrorF("xf86ReadBios: Failed to mmap %s (%s)\n", DEV_MEM,
strerror(errno));
return(-1);
}
SlowBCopyFromBus(base+JENSEN_SHIFT(Offset), Buf, Len);
munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(SIZE));
close(fd);
return(Len);
#else /* __alpha__ */
int fd;
if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
{
ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM,
strerror(errno));
return(-1);
}
if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
{
ErrorF("xf86ReadBios: %s seek failed (%s)\n", DEV_MEM,
strerror(errno));
close(fd);
return(-1);
}
if (read(fd, Buf, Len) != Len)
{
ErrorF("xf86ReadBios: %s read failed (%s)\n", DEV_MEM,
strerror(errno));
close(fd);
return(-1);
}
close(fd);
return(Len);
#endif /* __alpha__ */
}

View file

@ -0,0 +1,60 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.1 1996/12/23 06:50:59 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the 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.
*
*/
/* $Xorg: ioperm_noop.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
/*
* Amoeba, Minix and 386BSD don't bother with I/O permissions,
* or the permissions are implicit with opening/enabling the console.
*/
void xf86ClearIOPortList(ScreenNum)
int ScreenNum;
{
return;
}
/* ARGSUSED */
void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
int ScreenNum;
int NumPorts;
unsigned *Ports;
{
return;
}
void xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
return;
}
void xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
return;
}
void xf86DisableIOPrivs()
{
return;
}

View file

@ -0,0 +1,174 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.8.2.1 1998/02/07 14:27:25 dawes Exp $ */
/*
* 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 name of David Dawes
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission.
* David Dawes makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL 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.
*
*/
/* $Xorg: posix_tty.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "xf86Procs.h"
#include "xf86_OSlib.h"
#include "xf86_Config.h"
static Bool not_a_tty = FALSE;
void xf86SetMouseSpeed(mouse, old, new, cflag)
MouseDevPtr mouse;
int old;
int new;
unsigned cflag;
{
struct termios tty;
char *c;
if (not_a_tty)
return;
if (tcgetattr(mouse->mseFd, &tty) < 0)
{
not_a_tty = TRUE;
ErrorF("Warning: %s unable to get status of mouse fd (%s)\n",
mouse->mseDevice, strerror(errno));
return;
}
/* this will query the initial baudrate only once */
if (mouse->oldBaudRate < 0) {
switch (cfgetispeed(&tty))
{
case B9600:
mouse->oldBaudRate = 9600;
break;
case B4800:
mouse->oldBaudRate = 4800;
break;
case B2400:
mouse->oldBaudRate = 2400;
break;
case B1200:
default:
mouse->oldBaudRate = 1200;
break;
}
}
tty.c_iflag = IGNBRK | IGNPAR;
tty.c_oflag = 0;
tty.c_lflag = 0;
tty.c_cflag = (tcflag_t)cflag;
tty.c_cc[VTIME] = 0;
tty.c_cc[VMIN] = 1;
switch (old)
{
case 9600:
cfsetispeed(&tty, B9600);
cfsetospeed(&tty, B9600);
break;
case 4800:
cfsetispeed(&tty, B4800);
cfsetospeed(&tty, B4800);
break;
case 2400:
cfsetispeed(&tty, B2400);
cfsetospeed(&tty, B2400);
break;
case 1200:
default:
cfsetispeed(&tty, B1200);
cfsetospeed(&tty, B1200);
}
if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
{
if (xf86AllowMouseOpenFail) {
ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
strerror(errno));
return;
}
xf86FatalError("Unable to set status of mouse fd (%s)\n",
strerror(errno));
}
switch (new)
{
case 9600:
c = "*q";
cfsetispeed(&tty, B9600);
cfsetospeed(&tty, B9600);
break;
case 4800:
c = "*p";
cfsetispeed(&tty, B4800);
cfsetospeed(&tty, B4800);
break;
case 2400:
c = "*o";
cfsetispeed(&tty, B2400);
cfsetospeed(&tty, B2400);
break;
case 1200:
default:
c = "*n";
cfsetispeed(&tty, B1200);
cfsetospeed(&tty, B1200);
}
if (mouse->mseType == P_LOGIMAN || mouse->mseType == P_LOGI)
{
if (write(mouse->mseFd, c, 2) != 2)
{
if (xf86AllowMouseOpenFail) {
ErrorF("Unable to write to mouse fd (%s) - Continuing...\n",
strerror(errno));
return;
}
xf86FatalError("Unable to write to mouse fd (%s)\n",
strerror(errno));
}
}
usleep(100000);
if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
{
if (xf86AllowMouseOpenFail) {
ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
strerror(errno));
return;
}
xf86FatalError("Unable to set status of mouse fd (%s)\n",
strerror(errno));
}
}
int
xf86FlushInput(fd)
int fd;
{
return tcflush(fd, TCIFLUSH);
}

View file

@ -0,0 +1,49 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c,v 3.1 1996/12/23 06:51:02 dawes 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.
*
*/
/* $Xorg: std_kbdEv.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "xf86Procs.h"
#include "xf86_OSlib.h"
void xf86KbdEvents()
{
unsigned char rBuf[64];
int nBytes, i;
if ((nBytes = read( xf86Info.consoleFd, (char *)rBuf, sizeof(rBuf)))
> 0)
{
for (i = 0; i < nBytes; i++)
xf86PostKbdEvent(rBuf[i]);
}
}

View file

@ -0,0 +1,105 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c,v 3.2 1996/12/23 06:51:07 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Dawes <dawes@XFree86.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Thomas Roell and David 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.
*
*/
/* $Xorg: sysv_kbd.c,v 1.3 2000/08/17 19:51:30 cpqbld 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"
int xf86GetKbdLeds()
{
int leds;
ioctl(xf86Info.consoleFd, KDGETLED, &leds);
return(leds);
}
#if NeedFunctionPrototypes
void xf86SetKbdRepeat(char rad)
#else
void xf86SetKbdRepeat(rad)
char rad;
#endif
{
#ifdef KDSETRAD
ioctl(xf86Info.consoleFd, KDSETRAD, rad);
#endif
}
static int kbdtrans;
static struct termio kbdtty;
static char *kbdemap = NULL;
void xf86KbdInit()
{
#ifdef KDGKBMODE
ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
#endif
ioctl (xf86Info.consoleFd, TCGETA, &kbdtty);
#if defined(E_TABSZ) && !defined(SCO325)
kbdemap = (char *)xalloc(E_TABSZ);
if (ioctl(xf86Info.consoleFd, LDGMAP, kbdemap) < 0)
{
xfree(kbdemap);
kbdemap = NULL;
}
#endif
}
int xf86KbdOn()
{
struct termio nTty;
ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
ioctl(xf86Info.consoleFd, LDNMAP, 0); /* disable mapping completely */
nTty = kbdtty;
nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
nTty.c_oflag = 0;
nTty.c_cflag = CREAD | CS8 | B9600;
nTty.c_lflag = 0;
nTty.c_cc[VTIME]=0;
nTty.c_cc[VMIN]=1;
ioctl(xf86Info.consoleFd, TCSETA, &nTty);
return(xf86Info.consoleFd);
}
int xf86KbdOff()
{
if (kbdemap)
{
ioctl(xf86Info.consoleFd, LDSMAP, kbdemap);
}
ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
ioctl(xf86Info.consoleFd, TCSETA, &kbdtty);
return(xf86Info.consoleFd);
}

View file

@ -0,0 +1,257 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c,v 3.4.2.1 1998/02/06 22:36:54 hohndel Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Thomas Roell and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Thomas Roell and
* David Wexelblat makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: sysv_init.c,v 1.3 2000/08/17 19:51:32 cpqbld 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 Bool KeepTty = FALSE;
#ifdef SVR4
static Bool Protect0 = FALSE;
#endif
static int VTnum = -1;
extern void xf86VTRequest(
#if NeedFunctionPrototypes
int
#endif
);
void xf86OpenConsole()
{
int fd;
struct vt_mode VT;
char vtname1[10],vtname2[10];
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");
}
#ifdef SVR4
/* Protect page 0 to help find NULL dereferencing */
/* mprotect() doesn't seem to work */
if (Protect0)
{
int fd = -1;
if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
{
ErrorF("xf86OpenConsole: cannot open /dev/zero (%s)\n",
strerror(errno));
}
else
{
if ((int)mmap(0, 0x1000, PROT_NONE,
MAP_FIXED | MAP_SHARED, fd, 0) == -1)
{
ErrorF("xf86OpenConsole: failed to protect page 0 (%s)\n",
strerror(errno));
}
close(fd);
}
}
#endif
/*
* setup the virtual terminal manager
*/
if (VTnum != -1)
{
xf86Info.vtno = VTnum;
}
else
{
if ((fd = open("/dev/console",O_WRONLY,0)) < 0)
{
FatalError(
"xf86OpenConsole: Cannot open /dev/console (%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/vc%02d",xf86Info.vtno); /* ESIX */
sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */
xf86Config(FALSE); /* Read XF86Config */
if (!KeepTty)
{
setpgrp();
}
if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) &&
((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0))
{
FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n",
vtname2, vtname1, strerror(errno));
}
/* change ownership of the vt */
if (chown(vtname1, getuid(), getgid()) < 0)
{
chown(vtname2, getuid(), getgid());
}
/*
* now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
}
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
{
FatalError("xf86OpenConsole: VT_GETMODE failed\n");
}
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");
}
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
{
FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS 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 (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
{
ErrorF("xf86OpenConsole: VT_WAITACTIVE 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
ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
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;
{
/*
* Keep server from detaching from controlling tty. This is useful
* when debugging (so the server can receive keyboard signals.
*/
if (!strcmp(argv[i], "-keeptty"))
{
KeepTty = TRUE;
return(1);
}
#ifdef SVR4
/*
* Undocumented flag to protect page 0 from read/write to help
* catch NULL pointer dereferences. This is purely a debugging
* flag.
*/
if (!strcmp(argv[i], "-protect0"))
{
Protect0 = TRUE;
return(1);
}
#endif
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");
ErrorF("-keeptty ");
ErrorF("don't detach controlling tty (for debugging only)\n");
return;
}

View file

@ -0,0 +1,98 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c,v 3.4 1996/12/23 06:51:26 dawes 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.
*
*/
/* $Xorg: sysv_io.c,v 1.3 2000/08/17 19:51:32 cpqbld 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"
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,
((1193190 / pitch) & 0xffff) |
(((unsigned long)duration *
loudness / 50) << 16));
#else
ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
usleep(xf86Info.bell_duration * loudness * 20);
ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
#endif
}
}
void xf86SetKbdLeds(leds)
int leds;
{
#ifdef KBIO_SETMODE
ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_AT);
ioctl(xf86Info.consoleFd, KDSETLED, leds);
ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_XT);
#endif
}
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));
}
xf86SetupMouse(mouse);
/* Flush any pending input */
ioctl(mouse->mseFd, TCFLSH, 0);
return(mouse->mseFd);
}

View file

@ -0,0 +1,589 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.9 1996/12/23 06:51:27 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Thomas Roell and David Wexelblat
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. Thomas Roell and
* David Wexelblat makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
* ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/* $Xorg: sysv_video.c,v 1.3 2000/08/17 19:51:33 cpqbld Exp $ */
#include "X.h"
#include "input.h"
#include "scrnintstr.h"
#define _NEED_SYSI86
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#ifndef SI86IOPL
#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
#else
#define SET_IOPL() sysi86(SI86IOPL,3)
#define RESET_IOPL() sysi86(SI86IOPL,0)
#endif
/***************************************************************************/
/* Video Memory Mapping section */
/***************************************************************************/
struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS];
pointer AllocAddress[MAXSCREENS][NUM_REGIONS];
#ifndef SVR4
static int mmapFd = -2;
#endif
#if 0
/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */
#if defined(SVR4) || defined(HAS_SVR3_MMAPDRV)
static struct xf86memMap {
int offset;
int memSize;
} xf86memMaps[MAXSCREENS];
#endif
#endif
Bool xf86LinearVidMem()
{
#ifdef SVR4
return TRUE;
#else
#ifdef HAS_SVR3_MMAPDRV
if(mmapFd >= 0)
{
return TRUE;
}
if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1)
{
if(ioctl(mmapFd, GETVERSION) < 0x0222) {
ErrorF("xf86LinearVidMem: MMAP 2.2.2 or above required\n");
ErrorF(" linear memory access disabled\n");
return FALSE;
}
return TRUE;
}
ErrorF("xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
strerror(errno));
ErrorF(" linear memory access disabled\n");
#endif
return FALSE;
#endif
}
pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
pointer base;
int fd;
#if defined(SVR4)
if ((fd = open(DEV_MEM, O_RDWR)) < 0)
{
FatalError("xf86MapVidMem: failed to open %s (%s)\n",
DEV_MEM, strerror(errno));
}
base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
MAP_SHARED, fd, (off_t)Base);
close(fd);
if ((long)base == -1)
{
FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
"xf86MapVidMem", Size, Base, strerror(errno));
}
#else /* SVR4 */
#ifdef HAS_SVR3_MMAPDRV
if (mmapFd == -2)
{
mmapFd = open("/dev/mmap", O_RDWR);
}
#endif
if (mmapFd >= 0)
{
/* To force the MMAP driver to provide the address */
base = (pointer)0;
}
else
{
AllocAddress[ScreenNum][Region] = (pointer)xalloc(Size + 0x1000);
if (AllocAddress[ScreenNum][Region] == (pointer)0)
{
FatalError("xf86MapVidMem: can't alloc framebuffer space\n");
/* NOTREACHED */
}
base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region]
& ~0xFFF) + 0x1000);
}
MapDSC[ScreenNum][Region].vaddr = (char *)base;
MapDSC[ScreenNum][Region].physaddr = (char *)Base;
MapDSC[ScreenNum][Region].length = Size;
MapDSC[ScreenNum][Region].ioflg = 1;
#ifdef HAS_SVR3_MMAPDRV
if(mmapFd >= 0)
{
if((base = (pointer)ioctl(mmapFd, MAP,
&(MapDSC[ScreenNum][Region]))) == (pointer)-1)
{
FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
"xf86MapVidMem", Size, Base, strerror(errno));
/* NOTREACHED */
}
/* Next time we want the same address! */
MapDSC[ScreenNum][Region].vaddr = (char *)base;
#if 0
/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */
xf86memMaps[ScreenNum].offset = (int) Base;
xf86memMaps[ScreenNum].memSize = Size;
#endif
return((pointer)base);
}
#endif
if (ioctl(xf86Info.consoleFd, KDMAPDISP,
&(MapDSC[ScreenNum][Region])) < 0)
{
FatalError("xf86MapVidMem: Failed to map video mem (%x,%x) (%s)\n",
Base, Size, strerror(errno));
/* NOTREACHED */
}
#endif /* SVR4 */
#if 0
xf86memMaps[ScreenNum].offset = (int) Base;
xf86memMaps[ScreenNum].memSize = Size;
#endif
return((pointer)base);
}
#if 0
/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */
#if defined(SVR4) || defined(HAS_SVR3_MMAPDRV)
void xf86GetVidMemData(ScreenNum, Base, Size)
int ScreenNum;
int *Base;
int *Size;
{
*Base = xf86memMaps[ScreenNum].offset;
*Size = xf86memMaps[ScreenNum].memSize;
}
#endif
#endif
/* ARGSUSED */
void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
int ScreenNum;
int Region;
pointer Base;
unsigned long Size;
{
#if defined (SVR4)
munmap(Base, Size);
#else /* SVR4 */
#ifdef HAS_SVR3_MMAPDRV
if(mmapFd >= 0)
{
ioctl(mmapFd, UNMAPRM, MapDSC[ScreenNum][Region].vaddr);
return;
}
#endif
/* XXXX This is a problem because it unmaps all regions */
ioctl(xf86Info.consoleFd, KDUNMAPDISP, 0);
xfree(AllocAddress[ScreenNum][Region]);
#endif /* SVR4 */
}
/* ARGSUSED */
void xf86MapDisplay(ScreenNum, Region)
int ScreenNum;
int Region;
{
#if !defined(SVR4)
#ifdef HAS_SVR3_MMAPDRV
if(mmapFd >= 0)
{
ioctl(mmapFd, MAP, &(MapDSC[ScreenNum][Region]));
return;
}
#endif
ioctl(xf86Info.consoleFd, KDMAPDISP, &(MapDSC[ScreenNum][Region]));
#endif /* SVR4 */
return;
}
/* ARGSUSED */
void xf86UnMapDisplay(ScreenNum, Region)
int ScreenNum;
int Region;
{
#if !defined(SVR4)
#ifdef HAS_SVR3_MMAPDRV
if(mmapFd > 0)
{
ioctl(mmapFd, UNMAP, MapDSC[ScreenNum][Region].vaddr);
return;
}
#endif
ioctl(xf86Info.consoleFd, KDUNMAPDISP, 0);
#endif /* SVR4 */
return;
}
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
#define ALWAYS_USE_EXTENDED
#ifdef ALWAYS_USE_EXTENDED
static Bool ScreenEnabled[MAXSCREENS];
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
void
xf86ClearIOPortList(ScreenNum)
int ScreenNum;
{
if (!InitDone)
{
int i;
for (i = 0; i < MAXSCREENS; i++)
ScreenEnabled[i] = FALSE;
InitDone = TRUE;
}
return;
}
void
xf86AddIOPorts(ScreenNum, NumPorts, Ports)
int ScreenNum;
int NumPorts;
unsigned *Ports;
{
return;
}
void
xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
ScreenEnabled[ScreenNum] = TRUE;
if (ExtendedEnabled)
return;
if (SET_IOPL() < 0)
{
FatalError("%s: Failed to set IOPL for extended I/O\n",
"xf86EnableIOPorts");
}
ExtendedEnabled = TRUE;
return;
}
void
xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
int i;
ScreenEnabled[ScreenNum] = FALSE;
if (!ExtendedEnabled)
return;
for (i = 0; i < MAXSCREENS; i++)
if (ScreenEnabled[i])
return;
RESET_IOPL();
ExtendedEnabled = FALSE;
return;
}
#else /* !ALWAYS_USE_EXTENDED */
#define DISABLED 0
#define NON_EXTENDED 1
#define EXTENDED 2
static unsigned *EnabledPorts[MAXSCREENS];
static int NumEnabledPorts[MAXSCREENS];
static Bool ScreenEnabled[MAXSCREENS];
static Bool ExtendedPorts[MAXSCREENS];
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
static struct kd_disparam OrigParams;
void xf86ClearIOPortList(ScreenNum)
int ScreenNum;
{
if (!InitDone)
{
xf86InitPortLists(EnabledPorts, NumEnabledPorts, ScreenEnabled,
ExtendedPorts, MAXSCREENS);
if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &OrigParams) < 0)
{
FatalError("%s: Could not get display parameters\n",
"xf86ClearIOPortList");
}
InitDone = TRUE;
return;
}
ExtendedPorts[ScreenNum] = FALSE;
if (EnabledPorts[ScreenNum] != (unsigned *)NULL)
xfree(EnabledPorts[ScreenNum]);
EnabledPorts[ScreenNum] = (unsigned *)NULL;
NumEnabledPorts[ScreenNum] = 0;
}
void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
int ScreenNum;
int NumPorts;
unsigned *Ports;
{
int i;
if (!InitDone)
{
FatalError("xf86AddIOPorts: I/O control lists not initialised\n");
}
EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum],
(NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned));
for (i = 0; i < NumPorts; i++)
{
EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] =
Ports[i];
if (Ports[i] > 0x3FF)
ExtendedPorts[ScreenNum] = TRUE;
}
NumEnabledPorts[ScreenNum] += NumPorts;
}
void xf86EnableIOPorts(ScreenNum)
int ScreenNum;
{
struct kd_disparam param;
int i, j;
if (ScreenEnabled[ScreenNum])
return;
for (i = 0; i < MAXSCREENS; i++)
{
if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum))
{
if (SET_IOPL() < 0)
{
FatalError("%s: Failed to set IOPL for extended I/O\n",
"xf86EnableIOPorts");
}
ExtendedEnabled = TRUE;
break;
}
}
/* If extended I/O was used, but isn't any more */
if (ExtendedEnabled && i == MAXSCREENS)
{
RESET_IOPL();
ExtendedEnabled = FALSE;
}
/*
* Turn on non-extended ports even when using extended I/O
* so they are there if extended I/O gets turned off when it's no
* longer needed.
*/
if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &param) < 0)
{
FatalError("%s: Could not get display parameters\n",
"xf86EnableIOPorts");
}
for (i = 0; i < NumEnabledPorts[ScreenNum]; i++)
{
unsigned port = EnabledPorts[ScreenNum][i];
if (port > 0x3FF)
continue;
if (!xf86CheckPorts(port, EnabledPorts, NumEnabledPorts,
ScreenEnabled, MAXSCREENS))
{
continue;
}
for (j=0; j < MKDIOADDR; j++)
{
if (param.ioaddr[j] == port)
{
break;
}
}
if (j == MKDIOADDR)
{
if (ioctl(xf86Info.consoleFd, KDADDIO, port) < 0)
{
FatalError("%s: Failed to enable port 0x%x\n",
"xf86EnableIOPorts", port);
}
}
}
if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
{
FatalError("xf86EnableIOPorts: I/O port enable failed (%s)\n",
strerror(errno));
}
ScreenEnabled[ScreenNum] = TRUE;
return;
}
void xf86DisableIOPorts(ScreenNum)
int ScreenNum;
{
struct kd_disparam param;
int i, j;
if (!ScreenEnabled[ScreenNum])
return;
ScreenEnabled[ScreenNum] = FALSE;
for (i = 0; i < MAXSCREENS; i++)
{
if (ScreenEnabled[i] && ExtendedPorts[i])
break;
}
if (ExtendedEnabled && i == MAXSCREENS)
{
RESET_IOPL();
ExtendedEnabled = FALSE;
}
/* Turn off I/O before changing the access list */
ioctl(xf86Info.consoleFd, KDDISABIO, 0);
if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &param) < 0)
{
ErrorF("%s: Could not get display parameters\n",
"xf86DisableIOPorts");
return;
}
for (i=0; i < MKDIOADDR; i++)
{
/* 0 indicates end of list */
if (param.ioaddr[i] == 0)
{
break;
}
if (!xf86CheckPorts(param.ioaddr[i], EnabledPorts,
NumEnabledPorts, ScreenEnabled, MAXSCREENS))
{
continue;
}
for (j=0; j < MKDIOADDR; j++)
{
if (param.ioaddr[i] == OrigParams.ioaddr[j])
{
/*
* Port was one of the original ones; don't
* touch it.
*/
break;
}
}
if (j == MKDIOADDR)
{
/*
* We added this port, so remove it.
*/
ioctl(xf86Info.consoleFd, KDDELIO, param.ioaddr[i]);
}
}
/* If any other screens are enabled, turn I/O back on */
for (i = 0; i < MAXSCREENS; i++)
{
if (ScreenEnabled[i])
{
ioctl(xf86Info.consoleFd, KDENABIO, 0);
break;
}
}
return;
}
#endif /* ALWAYS_USE_EXTENDED */
void xf86DisableIOPrivs()
{
if (ExtendedEnabled)
RESET_IOPL();
return;
}
/***************************************************************************/
/* Interrupt Handling section */
/***************************************************************************/
Bool xf86DisableInterrupts()
{
if (!ExtendedEnabled)
{
if (SET_IOPL() < 0)
{
return(FALSE);
}
}
#ifdef __GNUC__
__asm__ __volatile__("cli");
#else
asm("cli");
#endif /* __GNUC__ */
if (!ExtendedEnabled)
{
RESET_IOPL();
}
return(TRUE);
}
void xf86EnableInterrupts()
{
if (!ExtendedEnabled)
{
if (SET_IOPL() < 0)
{
return;
}
}
#ifdef __GNUC__
__asm__ __volatile__("sti");
#else
asm("sti");
#endif /* __GNUC__ */
if (!ExtendedEnabled)
{
RESET_IOPL();
}
return;
}

View file

@ -0,0 +1,406 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c,v 3.8.2.1 1997/07/13 14:45:04 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
*
* 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 Roell not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Thomas Roell makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THOMAS ROELL 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.
*
*/
/* $Xorg: xqueue.c,v 1.3 2000/08/17 19:51:33 cpqbld Exp $ */
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "inputstr.h"
#include "scrnintstr.h"
#include "compiler.h"
#include "xf86.h"
#include "xf86Procs.h"
#include "xf86_OSlib.h"
#ifdef XQUEUE
static xqEventQueue *XqueQaddr;
static int xqueFd = -1;
#ifndef XQUEUE_ASYNC
static int xquePipe[2];
#endif
#ifdef XKB
#include <X11/extensions/XKB.h>
#include <X11/extensions/XKBstr.h>
#include <X11/extensions/XKBsrv.h>
extern Bool noXkbExtension;
#endif
#ifdef XINPUT
#include "xf86_Config.h"
#include "xf86Xinput.h"
#endif
extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
unsigned long start, unsigned long stop,
ScreenPtr pScreen);
#ifndef XQUEUE_ASYNC
/*
* xf86XqueSignal --
* Trap the signal from xqueue and let it be known that events are
* ready for collection
*/
static void
xf86XqueSignal(int signum)
{
xf86Info.mouseDev->xquePending = 1;
/*
* This is a hack, but it is the only reliable way I can find of letting
* the main select() loop know that there is more input waiting. Receiving
* a signal will interrupt select(), but there is no way I can find of
* dealing with events that come in between the end of processing the
* last set and when select() gets called.
*
* Suggestions for better ways of dealing with this without going back to
* asynchronous event processing are welcome.
*/
write(xquePipe[1], "X", 1);
signal(SIGUSR2, xf86XqueSignal);
}
#endif
/*
* xf86XqueRequest --
* Notice an i/o request from the xqueue.
*/
void
xf86XqueRequest()
{
xqEvent *XqueEvents = XqueQaddr->xq_events;
int XqueHead = XqueQaddr->xq_head;
char buf[100];
while (XqueHead != XqueQaddr->xq_tail)
{
switch(XqueEvents[XqueHead].xq_type) {
case XQ_BUTTON:
xf86PostMseEvent(xf86Info.pMouse,
~(XqueEvents[XqueHead].xq_code) & 0x07, 0, 0);
break;
case XQ_MOTION:
xf86PostMseEvent(xf86Info.pMouse,
~(XqueEvents[XqueHead].xq_code) & 0x07,
XqueEvents[XqueHead].xq_x,
XqueEvents[XqueHead].xq_y);
break;
case XQ_KEY:
xf86PostKbdEvent(XqueEvents[XqueHead].xq_code);
break;
default:
ErrorF("Unknown Xque Event: 0x%02x\n", XqueEvents[XqueHead].xq_type);
}
if ((++XqueHead) == XqueQaddr->xq_size) XqueHead = 0;
}
/* reenable the signal-processing */
xf86Info.inputPending = TRUE;
#ifdef XQUEUE_ASYNC
signal(SIGUSR2, (void (*)()) xf86XqueRequest);
#else
#if 0
signal(SIGUSR2, (void (*)()) xf86XqueSignal);
#endif
#endif
#ifndef XQUEUE_ASYNC
{
int rval;
while ((rval = read(xquePipe[0], buf, sizeof(buf))) > 0)
#ifdef DEBUG
ErrorF("Read %d bytes from xquePipe[0]\n", rval);
#else
;
#endif
}
#endif
XqueQaddr->xq_head = XqueQaddr->xq_tail;
xf86Info.mouseDev->xquePending = 0;
XqueQaddr->xq_sigenable = 1; /* UNLOCK */
}
/*
* xf86XqueEnable --
* Enable the handling of the Xque
*/
static int
xf86XqueEnable()
{
static struct kd_quemode xqueMode;
static Bool was_here = FALSE;
if (!was_here) {
if ((xqueFd = open("/dev/mouse", O_RDONLY|O_NDELAY)) < 0)
{
if (xf86AllowMouseOpenFail) {
ErrorF("Cannot open /dev/mouse (%s) - Continuing...\n",
strerror(errno));
return (Success);
} else {
Error ("Cannot open /dev/mouse");
return (!Success);
}
}
#ifndef XQUEUE_ASYNC
pipe(xquePipe);
fcntl(xquePipe[0],F_SETFL,fcntl(xquePipe[0],F_GETFL,0)|O_NDELAY);
fcntl(xquePipe[1],F_SETFL,fcntl(xquePipe[1],F_GETFL,0)|O_NDELAY);
#endif
was_here = TRUE;
}
if (xf86Info.mouseDev->xqueSema++ == 0)
{
#ifdef XQUEUE_ASYNC
(void) signal(SIGUSR2, (void (*)()) xf86XqueRequest);
#else
(void) signal(SIGUSR2, (void (*)()) xf86XqueSignal);
#endif
xqueMode.qsize = 64; /* max events */
xqueMode.signo = SIGUSR2;
ioctl(xf86Info.consoleFd, KDQUEMODE, NULL);
if (ioctl(xf86Info.consoleFd, KDQUEMODE, &xqueMode) < 0) {
Error ("Cannot set KDQUEMODE");
/* CONSTCOND */
return (!Success);
}
XqueQaddr = (xqEventQueue *)xqueMode.qaddr;
XqueQaddr->xq_sigenable = 1; /* UNLOCK */
}
return(Success);
}
/*
* xf86XqueDisable --
* disable the handling of the Xque
*/
static int
xf86XqueDisable()
{
if (xf86Info.mouseDev->xqueSema-- == 1)
{
XqueQaddr->xq_sigenable = 0; /* LOCK */
if (ioctl(xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
Error ("Cannot unset KDQUEMODE");
/* CONSTCOND */
return (!Success);
}
}
return(Success);
}
/*
* xf86XqueMseProc --
* Handle the initialization, etc. of a mouse
*/
int
xf86XqueMseProc(pPointer, what)
DeviceIntPtr pPointer;
int what;
{
MouseDevPtr mouse = MOUSE_DEV(pPointer);
unchar map[4];
int ret;
mouse->device = pPointer;
switch (what)
{
case DEVICE_INIT:
pPointer->public.on = FALSE;
map[1] = 1;
map[2] = 2;
map[3] = 3;
InitPointerDeviceStruct((DevicePtr)pPointer,
map,
3,
miPointerGetMotionEvents,
(PtrCtrlProcPtr)xf86MseCtrl,
miPointerGetMotionBufferSize());
break;
case DEVICE_ON:
mouse->lastButtons = 0;
mouse->emulateState = 0;
pPointer->public.on = TRUE;
ret = xf86XqueEnable();
#ifndef XQUEUE_ASYNC
if (xquePipe[0] != -1)
AddEnabledDevice(xquePipe[0]);
#endif
return(ret);
case DEVICE_CLOSE:
case DEVICE_OFF:
pPointer->public.on = FALSE;
ret = xf86XqueDisable();
#ifndef XQUEUE_ASYNC
if (xquePipe[0] != -1)
RemoveEnabledDevice(xquePipe[0]);
#endif
return(ret);
}
return Success;
}
/*
* xf86XqueKbdProc --
* Handle the initialization, etc. of a keyboard.
*/
int
xf86XqueKbdProc (pKeyboard, what)
DeviceIntPtr pKeyboard; /* Keyboard to manipulate */
int what; /* What to do to it */
{
KeySymsRec keySyms;
CARD8 modMap[MAP_LENGTH];
switch (what) {
case DEVICE_INIT:
xf86KbdGetMapping(&keySyms, modMap);
/*
* Get also the initial led settings
*/
ioctl(xf86Info.consoleFd, KDGETLED, &xf86Info.leds);
/*
* Perform final initialization of the system private keyboard
* structure and fill in various slots in the device record
* itself which couldn't be filled in before.
*/
pKeyboard->public.on = FALSE;
#ifdef XKB
if (noXkbExtension) {
#endif
InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
&keySyms,
modMap,
xf86KbdBell,
(KbdCtrlProcPtr)xf86KbdCtrl);
#ifdef XKB
} else {
XkbComponentNamesRec names;
if (XkbInitialMap) {
if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL)
xf86Info.xkbkeymap++;
else
xf86Info.xkbkeymap = XkbInitialMap;
}
if (xf86Info.xkbkeymap) {
names.keymap = xf86Info.xkbkeymap;
names.keycodes = NULL;
names.types = NULL;
names.compat = NULL;
names.symbols = NULL;
names.geometry = NULL;
} else {
names.keymap = NULL;
names.keycodes = xf86Info.xkbkeycodes;
names.types = xf86Info.xkbtypes;
names.compat = xf86Info.xkbcompat;
names.symbols = xf86Info.xkbsymbols;
names.geometry = xf86Info.xkbgeometry;
}
if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
&& (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
xf86Info.xkbrules = NULL;
}
XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
xf86Info.xkblayout, xf86Info.xkbvariant,
xf86Info.xkboptions);
XkbInitKeyboardDeviceStruct(pKeyboard,
&names,
&keySyms,
modMap,
xf86KbdBell,
(KbdCtrlProcPtr)xf86KbdCtrl);
}
#endif
xf86InitKBD(TRUE);
break;
case DEVICE_ON:
pKeyboard->public.on = TRUE;
xf86InitKBD(FALSE);
return(xf86XqueEnable());
case DEVICE_CLOSE:
case DEVICE_OFF:
pKeyboard->public.on = FALSE;
return(xf86XqueDisable());
}
return (Success);
}
/*
* xf86XqueEvents --
* Get some events from our queue. Nothing to do here ...
*/
void
xf86XqueEvents()
{
}
#endif /* XQUEUE */

View file

@ -0,0 +1,533 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.36.2.5 1998/02/15 16:09:30 hohndel Exp $ */
/*
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1992 by David Dawes <dawes@XFree86.org>
* Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu>
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
* Copyright 1992 by Orest Zborowski <obz@eskimo.com>
* Copyright 1993 by Vrije Universiteit, The Netherlands
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
* Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
* Copyright 1994, 1995 by The XFree86 Project, Inc
*
* 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 the above listed copyright holders
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The above listed
* copyright holders make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS 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.
*
*/
/* $Xorg: xf86_OSlib.h,v 1.3 2000/08/17 19:51:20 cpqbld Exp $ */
#ifndef _XF86_OSLIB_H
#define _XF86_OSLIB_H
#include <X11/Xos.h>
#include <X11/Xfuncproto.h>
#include "compiler.h"
#if defined(MACH386) || defined(__OSF__)
# undef NULL
#endif /* MACH386 || __OSF__ */
#include <stdio.h>
#include <ctype.h>
/**************************************************************************/
/* SYSV386 (SVR3, SVR4) */
/**************************************************************************/
#if defined(SYSV) || defined(SVR4)
# ifdef SCO325
# define _SVID3
# endif
# include <sys/ioctl.h>
# include <signal.h>
# include <termio.h>
# include <sys/stat.h>
# include <sys/types.h>
# if defined(SCO) || defined(ISC)
# include <sys/param.h>
# endif
# include <errno.h>
# if defined(_NEED_SYSI86)
# include <sys/immu.h>
# if !(defined (sun) && defined (i386) && defined (SVR4))
# include <sys/region.h>
# endif
# include <sys/proc.h>
# include <sys/tss.h>
# include <sys/sysi86.h>
# if defined(SVR4) && !defined(sun)
# include <sys/seg.h>
# endif /* SVR4 && !sun */
# include <sys/v86.h>
# if defined(sun) && defined (i386) && defined (SVR4)
# include <sys/psw.h>
# endif
# endif /* _NEED_SYSI86 */
#if defined(HAS_SVR3_MMAPDRV)
# include <sys/sysmacros.h>
# if !defined(_NEED_SYSI86)
# include <sys/immu.h>
# include <sys/region.h>
# endif
# include <sys/mmap.h> /* MMAP driver header */
#endif
# define HAS_USL_VTS
# if !defined(sun)
# include <sys/emap.h>
# endif
# if defined(SCO)
# include <sys/vtkd.h>
# include <sys/console.h>
# include <sys/keyboard.h>
# include <sys/vid.h>
# define LED_CAP 0x01
# define LED_NUM 0x02
# define LED_SCR 0x04
# else /* SCO */
# include <sys/at_ansi.h>
# include <sys/kd.h>
# include <sys/vt.h>
# endif /* SCO */
# if !defined(VT_ACKACQ)
# define VT_ACKACQ 2
# endif /* !VT_ACKACQ */
# if defined(SCO)
# include <sys/sysmacros.h>
# define POSIX_TTY
# endif /* SCO */
# if defined(SVR4) || defined(SCO325)
# include <sys/mman.h>
# if !(defined(sun) && defined (i386) && defined (SVR4))
# define DEV_MEM "/dev/pmem"
# endif
# ifdef SCO325
# undef DEV_MEM
# define DEV_MEM "/dev/mem"
# endif
# define CLEARDTR_SUPPORT
# define POSIX_TTY
# endif /* SVR4 */
# ifdef ISC
# include <termios.h>
# define POSIX_TTY
# endif
# if defined(sun) && defined (i386) && defined (SVR4)
# define USE_VT_SYSREQ
# define VT_SYSREQ_DEFAULT TRUE
# endif
# if defined(ATT) && !defined(i386)
# define i386 /* note defined in ANSI C mode */
# endif /* ATT && !i386 */
# if (defined(ATT) || defined(SVR4)) && !(defined(sun) && defined (i386) && defined (SVR4)) && !defined(SCO325)
# define XQUEUE
# include <sys/xque.h>
# endif /* ATT || SVR4 */
/* Hack on SVR3 and SVR4 to avoid linking in Xenix or BSD support */
#if defined (sun) && defined (i386) && defined (SVR4)
extern int xf86_solx86usleep(unsigned long);
# define usleep(usec) xf86_solx86usleep(usec)
#else
# define usleep(usec) syscall(3112, (usec) / 1000 + 1)
#endif /* sun && i386 && SVR4 */
# ifdef SYSV
# if !defined(ISC) || defined(ISC202) || defined(ISC22)
# define NEED_STRERROR
# endif
# endif
#ifndef NULL
# define NULL 0
#endif
#endif /* SYSV || SVR4 */
/**************************************************************************/
/* Linux */
/**************************************************************************/
#if defined(linux)
# include <sys/ioctl.h>
# include <signal.h>
# include <termio.h>
# include <errno.h>
extern int errno;
# include <sys/stat.h>
# define HAS_USL_VTS
# include <sys/mman.h>
# include <sys/kd.h>
# include <sys/vt.h>
# define LDGMAP GIO_SCRNMAP
# define LDSMAP PIO_SCRNMAP
# define LDNMAP LDSMAP
# define CLEARDTR_SUPPORT
# define USE_VT_SYSREQ
# define POSIX_TTY
#endif /* linux */
/**************************************************************************/
/* LynxOS AT */
/**************************************************************************/
#if defined(Lynx)
# include <termio.h>
# include <sys/ioctl.h>
# include <param.h>
# include <signal.h>
# include <kd.h>
# include <vt.h>
# include <sys/stat.h>
# include <errno.h>
extern int errno;
/* smem_create et.al. to access physical memory */
# include <smem.h>
/* keyboard types */
# define KB_84 1
# define KB_101 2
# define KB_OTHER 3
/* atc drivers ignores argument to VT_RELDISP ioctl */
# define VT_ACKACQ 2
# include <termios.h>
# define POSIX_TTY
#endif /* Lynx */
/**************************************************************************/
/* 386BSD and derivatives, BSD/386 */
/**************************************************************************/
#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
# undef __386BSD__
#endif
#ifdef CSRG_BASED
# include <sys/ioctl.h>
# if defined(__OpenBSD__) && defined(_status)
# undef _status
# endif
# include <signal.h>
# include <termios.h>
# define termio termios
# define POSIX_TTY
# include <errno.h>
extern int errno;
# if !defined(LINKKIT)
/* Don't need this stuff for the Link Kit */
# if defined(__bsdi__)
# include <i386/isa/pcconsioctl.h>
# define CONSOLE_X_MODE_ON PCCONIOCRAW
# define CONSOLE_X_MODE_OFF PCCONIOCCOOK
# define CONSOLE_X_BELL PCCONIOCBEEP
# else /* __bsdi__ */
# if defined(__OpenBSD__)
# ifdef PCCONS_SUPPORT
# include <machine/pccons.h>
# undef CONSOLE_X_MODE_ON
# undef CONSOLE_X_MODE_OFF
# undef CONSOLE_X_BELL
# endif
# endif
# ifdef CODRV_SUPPORT
# define COMPAT_CO011
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <machine/ioctl_pc.h>
# else
# include <sys/ioctl_pc.h>
# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
# endif /* CODRV_SUPPORT */
# ifdef SYSCONS_SUPPORT
# define COMPAT_SYSCONS
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <machine/console.h>
# else
# include <sys/console.h>
# endif /* __FreeBSD__ || __NetBSD__ || defined(__OpenBSD__) */
# endif /* SYSCONS_SUPPORT */
# if defined(PCVT_SUPPORT)
# if !defined(SYSCONS_SUPPORT)
/* no syscons, so include pcvt specific header file */
# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# include <machine/pcvt_ioctl.h>
# else
# include <sys/pcvt_ioctl.h>
# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
# else /* pcvt and syscons: hard-code the ID magic */
# define VGAPCVTID _IOWR('V',113, struct pcvtid)
struct pcvtid {
char name[16];
int rmajor, rminor;
};
# endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */
# endif /* PCVT_SUPPORT */
# if defined(__FreeBSD__)
# undef MOUSE_GETINFO
# include <machine/mouse.h>
# endif
/* Include these definitions in case ioctl_pc.h didn't get included */
# ifndef CONSOLE_X_MODE_ON
# define CONSOLE_X_MODE_ON _IO('t',121)
# endif
# ifndef CONSOLE_X_MODE_OFF
# define CONSOLE_X_MODE_OFF _IO('t',122)
# endif
# ifndef CONSOLE_X_BELL
# define CONSOLE_X_BELL _IOW('t',123,int[2])
# endif
# endif /* __bsdi__ */
# endif /* !LINKKIT */
# include <sys/types.h>
# include <sys/mman.h>
# include <sys/stat.h>
# if defined(__bsdi__)
# include <sys/param.h>
# if (_BSDI_VERSION < 199510)
# include <i386/isa/vgaioctl.h>
# endif
# endif /* __bsdi__ */
# define CLEARDTR_SUPPORT
# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
# define USE_VT_SYSREQ
# endif
# ifndef NULL
# define NULL 0
# endif
#endif /* CSRG_BASED */
/**************************************************************************/
/* Mach and OSF/1 */
/**************************************************************************/
#if defined(MACH386) || defined(__OSF__)
# include <sys/ioctl.h>
# include <signal.h>
# include <errno.h>
extern int errno;
# if defined(__OSF__)
# include <sys/param.h>
# include <machine/kd.h>
# else /* __OSF__ */
# if !defined(__STDC__)
# define __STDC__ 1
# include <i386at/kd.h>
# include <i386at/kd_queue.h>
# undef __STDC__
# else /* !__STDC__ */
# include <i386at/kd.h>
# include <i386at/kd_queue.h>
# endif /* !__STDC__ */
# include <sys/file.h>
# define SEEK_SET L_SET
# endif /* __OSF__ */
# ifdef MACH386
# define NEED_STRERROR
# endif
# include <sys/mman.h>
# include <sys/stat.h>
# define MOUSE_PROTOCOL_IN_KERNEL
#endif /* MACH386 || __OSF__ */
/**************************************************************************/
/* Minix */
/**************************************************************************/
#if defined(MINIX)
# include <sys/ioctl.h>
# include <signal.h>
# include <termios.h>
# define termio termios
# define POSIX_TTY
# include <errno.h>
# include <assert.h>
# include <limits.h>
# include <sys/memio.h>
# include <sys/kbdio.h>
# include <sys/stat.h>
#endif /* MINIX */
/**************************************************************************/
/* Amoeba */
/**************************************************************************/
#if defined(AMOEBA)
# define port am_port_t
# include <amoeba.h>
# include <cmdreg.h>
# include <stderr.h>
# include <ampolicy.h>
# include <proc.h>
# include <signal.h>
# include <server/iop/iop.h>
# include <errno.h>
# undef port
# undef _POSIX_SOURCE /* to get the BSD-compatible symbols */
# include <sys/stat.h>
/* keyboard types */
# define KB_84 1
# define KB_101 2
# define KB_OTHER 3
extern capability iopcap;
# define MOUSE_PROTOCOL_IN_KERNEL
#endif /* AMOEBA */
/**************************************************************************/
/* OS/2 */
/**************************************************************************/
/* currently OS/2 with EMX/GCC compiler only */
#if defined(__EMX__)
# include <signal.h>
# include <errno.h>
# include <sys/stat.h>
/* I would have liked to have this included here always, but
* it causes clashes for BYTE and BOOL with Xmd.h, which is too dangerous.
* So I'll include it in place where I know it does no harm.
*/
#if defined(I_NEED_OS2_H)
# undef BOOL
# undef BYTE
# include <os2.h>
#endif
/* keyboard types */
# define KB_84 1
# define KB_101 2
/* could detect more keyboards */
# define KB_OTHER 3
/* LEDs */
# define LED_CAP 0x40
# define LED_NUM 0x20
# define LED_SCR 0x10
/* mouse driver */
# define OSMOUSE_ONLY
# define MOUSE_PROTOCOL_IN_KERNEL
extern char* __XOS2RedirRoot(char*);
#endif
/**************************************************************************/
/* Generic */
/**************************************************************************/
/*
* Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
* and it's safe, so just do it.
*/
#if !defined(O_NDELAY) && defined(O_NONBLOCK)
# define O_NDELAY O_NONBLOCK
#endif /* !O_NDELAY && O_NONBLOCK */
#if !defined(MAXHOSTNAMELEN)
# define MAXHOSTNAMELEN 32
#endif /* !MAXHOSTNAMELEN */
#if !defined(X_NOT_POSIX)
# if defined(_POSIX_SOURCE)
# include <limits.h>
# else
# define _POSIX_SOURCE
# include <limits.h>
# undef _POSIX_SOURCE
# endif /* _POSIX_SOURCE */
#endif /* !X_NOT_POSIX */
#if !defined(PATH_MAX)
# if defined(MAXPATHLEN)
# define PATH_MAX MAXPATHLEN
# else
# define PATH_MAX 1024
# endif /* MAXPATHLEN */
#endif /* !PATH_MAX */
#ifdef NEED_STRERROR
# ifndef strerror
extern char *sys_errlist[];
extern int sys_nerr;
# define strerror(n) \
((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error"
# endif /* !strerror */
#endif /* NEED_STRERROR */
#if defined(ISC) || defined(Lynx)
#define rint(x) RInt(x)
double RInt(
#if NeedFunctionPrototypes
double x
#endif
);
#endif
#ifndef VT_SYSREQ_DEFAULT
#define VT_SYSREQ_DEFAULT FALSE
#endif
#ifdef OSMOUSE_ONLY
# ifndef MOUSE_PROTOCOL_IN_KERNEL
# define MOUSE_PROTOCOL_IN_KERNEL
# endif
#endif
#include "xf86_OSproc.h"
#endif /* _XF86_OSLIB_H */

View file

@ -0,0 +1,394 @@
/* $Xorg: xf86_OSproc.h,v 1.3 2000/08/17 19:51:20 cpqbld Exp $ */
/*
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1992 by David Dawes <dawes@XFree86.org>
* Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu>
* Copyright 1992 by Rich Murphey <Rich@Rice.edu>
* Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
* Copyright 1992 by Orest Zborowski <obz@eskimo.com>
* Copyright 1993 by Vrije Universiteit, The Netherlands
* Copyright 1993 by David Wexelblat <dwex@XFree86.org>
* Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
* Copyright 1994, 1995 by The XFree86 Project, Inc
*
* 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 the above listed copyright holders
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The above listed
* copyright holders make no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS 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/xf86_OSproc.h,v 3.0.2.1 1998/02/07 14:27:24 dawes Exp $ */
#ifndef _XF86_OSPROC_H
#define _XF86_OSPROC_H
/*
* The actual prototypes have been pulled into this seperate file so
* that they can can be used without pulling in all of the OS specific
* stuff like sys/stat.h, etc. This casues problem for loadable modules.
*/
/* The Region arg to xf86[Un]Map* */
#define NUM_REGIONS 4
#define VGA_REGION 0
#define LINEAR_REGION 1
#define EXTENDED_REGION 2
#define MMIO_REGION 3
#ifndef NO_OSLIB_PROTOTYPES
/*
* This is to prevent re-entrancy to FatalError() when aborting.
* Anything that can be called as a result of AbortDDX() should use this
* instead of FatalError(). (xf86Exiting gets set to TRUE the first time
* AbortDDX() is called.)
*/
extern Bool xf86Exiting;
#define xf86FatalError(a, b) \
if (xf86Exiting) { \
ErrorF(a, b); \
return; \
} else FatalError(a, b)
/***************************************************************************/
/* Prototypes */
/***************************************************************************/
#include <X11/Xfuncproto.h>
_XFUNCPROTOBEGIN
/* xf86_Util.c */
extern int StrCaseCmp(
#if NeedFunctionPrototypes
const char *,
const char *
#endif
);
/* OS-support layer */
extern void xf86OpenConsole(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86CloseConsole(
#if NeedFunctionPrototypes
void
#endif
);
extern Bool xf86VTSwitchPending(
#if NeedFunctionPrototypes
void
#endif
);
extern Bool xf86VTSwitchAway(
#if NeedFunctionPrototypes
void
#endif
);
extern Bool xf86VTSwitchTo(
#if NeedFunctionPrototypes
void
#endif
);
extern Bool xf86LinearVidMem(
#if NeedFunctionPrototypes
void
#endif
);
extern pointer xf86MapVidMem(
#if NeedFunctionPrototypes
int,
int,
pointer,
unsigned long
#endif
);
extern void xf86UnMapVidMem(
#if NeedFunctionPrototypes
int,
int,
pointer,
unsigned long
#endif
);
#if defined(__alpha__)
/* entry points for SPARSE memory access routines */
extern pointer xf86MapVidMemSparse(
#if NeedFunctionPrototypes
int,
int,
pointer,
unsigned long
#endif
);
extern void xf86UnMapVidMemSparse(
#if NeedFunctionPrototypes
int,
int,
pointer,
unsigned long
#endif
);
extern int xf86ReadSparse8(
#if NeedFunctionPrototypes
pointer,
unsigned long
#endif
);
extern int xf86ReadSparse16(
#if NeedFunctionPrototypes
pointer,
unsigned long
#endif
);
extern int xf86ReadSparse32(
#if NeedFunctionPrototypes
pointer,
unsigned long
#endif
);
extern void xf86WriteSparse8(
#if NeedFunctionPrototypes
int,
pointer,
unsigned long
#endif
);
extern void xf86WriteSparse16(
#if NeedFunctionPrototypes
int,
pointer,
unsigned long
#endif
);
extern void xf86WriteSparse32(
#if NeedFunctionPrototypes
int,
pointer,
unsigned long
#endif
);
#endif /* __alpha__ */
extern void xf86MapDisplay(
#if NeedFunctionPrototypes
int,
int
#endif
);
extern void xf86UnMapDisplay(
#if NeedFunctionPrototypes
int,
int
#endif
);
extern int xf86ReadBIOS(
#if NeedFunctionPrototypes
unsigned long,
unsigned long,
unsigned char *,
int
#endif
);
extern void xf86ClearIOPortList(
#if NeedFunctionPrototypes
int
#endif
);
extern void xf86AddIOPorts(
#if NeedFunctionPrototypes
int,
int,
unsigned *
#endif
);
void xf86EnableIOPorts(
#if NeedFunctionPrototypes
int
#endif
);
void xf86DisableIOPorts(
#if NeedFunctionPrototypes
int
#endif
);
void xf86DisableIOPrivs(
#if NeedFunctionPrototypes
void
#endif
);
extern Bool xf86DisableInterrupts(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86EnableInterrupts(
#if NeedFunctionPrototypes
void
#endif
);
extern int xf86ProcessArgument(
#if NeedFunctionPrototypes
int,
char **,
int
#endif
);
extern void xf86UseMsg(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86SoundKbdBell(
#if NeedFunctionPrototypes
int,
int,
int
#endif
);
extern void xf86SetKbdLeds(
#if NeedFunctionPrototypes
int
#endif
);
extern int xf86GetKbdLeds(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86SetKbdRepeat(
#if NeedFunctionPrototypes
char
#endif
);
extern void xf86KbdInit(
#if NeedFunctionPrototypes
void
#endif
);
extern int xf86KbdOn(
#if NeedFunctionPrototypes
void
#endif
);
extern int xf86KbdOff(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86KbdEvents(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86SetMouseSpeed(
#if NeedFunctionPrototypes
MouseDevPtr,
int,
int,
unsigned
#endif
);
extern void xf86MouseInit(
#if NeedFunctionPrototypes
MouseDevPtr
#endif
);
extern int xf86MouseOn(
#if NeedFunctionPrototypes
MouseDevPtr
#endif
);
extern int xf86MouseOff(
#if NeedFunctionPrototypes
MouseDevPtr,
Bool
#endif
);
extern void xf86MouseEvents(
#if NeedFunctionPrototypes
MouseDevPtr
#endif
);
extern int xf86FlushInput(
#if NeedFunctionPrototypes
int
#endif
);
extern int xf86XqueKbdProc(
#if NeedFunctionPrototypes
DeviceIntPtr,
int
#endif
);
extern int xf86XqueMseProc(
#if NeedFunctionPrototypes
DeviceIntPtr,
int
#endif
);
extern void xf86XqueEvents(
#if NeedFunctionPrototypes
void
#endif
);
/* These are privates */
extern void xf86InitPortLists(
#if NeedFunctionPrototypes
unsigned **,
int *,
Bool *,
Bool *,
int
#endif
);
extern Bool xf86CheckPorts(
#if NeedFunctionPrototypes
unsigned,
unsigned **,
int *,
Bool *,
int
#endif
);
extern int xf86OsMouseProc(
#if NeedFunctionPrototypes
DeviceIntPtr,
int
#endif
);
extern void xf86OsMouseEvents(
#if NeedFunctionPrototypes
void
#endif
);
extern void xf86OsMouseOption(
#if NeedFunctionPrototypes
int,
pointer /* gets cast to LexPtr later, saves include file hassles */
#endif
);
_XFUNCPROTOEND
#endif /* NO_OSLIB_PROTOTYPES */
#endif /* _XF86_OSPROC_H */