diff options
author | Adam Jackson <ajax@redhat.com> | 2008-05-12 13:52:33 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2008-05-12 13:52:33 -0400 |
commit | 46f6e0d89e2f695e8980b76c7120358e07fe4f74 (patch) | |
tree | 02f4c4ba64f0a15cb2f44d0bf10b33d117d98a77 /hw/xfree86/os-support | |
parent | f9fae16456c30479b0cb9317e57200af36795785 (diff) |
Delete all DDXes besides xprint.
Diffstat (limited to 'hw/xfree86/os-support')
144 files changed, 0 insertions, 32668 deletions
diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am deleted file mode 100644 index f9a82c68d..000000000 --- a/hw/xfree86/os-support/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) -DIST_SUBDIRS = bsd bus misc linux lynxos solaris sysv sco usl hurd - -sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h \ - assyntax.h xf86OSmouse.h - -EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib - -# to get the grouping semantics right, you have to glom these three together -# as one library, otherwise libtool will actively defeat your attempts to -# list them multiple times on the link line. -noinst_LTLIBRARIES = libxorgos.la -libxorgos_la_SOURCES = xorgos.c -libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ - bus/libbus.la \ - misc/libmisc.la - -AM_CFLAGS = $(DIX_CFLAGS) - -xorgos.c: - touch $@ - -DISTCLEANFILES = xorgos.c - -# FIXME: These don't seem to be used anywhere -EXTRA_DIST += \ - shared/bios_devmem.c \ - shared/inout.S diff --git a/hw/xfree86/os-support/README.OS-lib b/hw/xfree86/os-support/README.OS-lib deleted file mode 100644 index e410906f9..000000000 --- a/hw/xfree86/os-support/README.OS-lib +++ /dev/null @@ -1,505 +0,0 @@ - - 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. - 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. - 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 xf86Info. Most of this code comes from xf86Init.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, 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, 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 xf86EnableIOPorts(int ScreenNum) -{ - /* - * Enables I/O permissions. The OS layer should - * enable all I/O port access. - */ -} - -void xf86DisableIOPorts(int ScreenNum) -{ - /* - * Disables I/O permissions. - */ -} - -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 xf86PostKbdEvent(). 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 xf86PostMseEvent(). 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 xf86PostMseEvent(). - * - * 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. - */ -} - -/* - * The following functions are simply wrappers around the OS specific - * libc functions - */ - -void * -xf86memmove(void * dest, const void * src, INT32 n) -{ - return(memmove(dest,src,n)); -} - -void * -xf86memset(void * s, int c, INT32 n) -{ - return(memset(s,c,n)); -} - -void * -xf86memcpy(void * dest, const void * src, INT32 n) -{ - return(memcpy(dest,src,n)); -} - -int -xf86memcmp(const void * s1, const void * s2, INT32 n) -{ - return(memcmp(s1,s2,n)); -} - -char * -xf86strcat(char * dest, const char * src) -{ - return(strcat(dest,src)); -} - -char * -xf86strcpy(char * dest, const char * src) -{ - return(strcpy(dest,src)); -} - -int -xf86strcmp(const char * s1, const char * s2) -{ - return(strcmp(s1,s2)); -} - -int -xf86strncmp(const char * s1, const char * s2, INT32 n) -{ - return(strncmp(s1,s2,n)); -} - -size_t -xf86strlen(const char * s) -{ - return(strlen(s)); -} - -void -xf86getsecs(INT32 * secs, INT32 * usecs) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - *secs = tv.tv_sec; - *usecs= tv.tv_usec; - - return; -} - -double -xf86exp(double x) -{ - return(exp(x)); -} - -double -xf86log(double x) -{ - return(log(x)); -} - -double -xf86pow(double x, double y) -{ - return(pow(x,y)); -} - -double -xf86sqrt(double x) -{ - return(sqrt(x)); -} - -double -xf86cos(double x) -{ - return(cos(x)); -} - - - - -$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.10 2001/12/17 20:00:45 dawes Exp $ - - - - - -$XConsortium: README.OS-lib /main/5 1996/02/21 17:50:28 kaleb $ diff --git a/hw/xfree86/os-support/assyntax.h b/hw/xfree86/os-support/assyntax.h deleted file mode 100644 index d3e96e5fd..000000000 --- a/hw/xfree86/os-support/assyntax.h +++ /dev/null @@ -1,749 +0,0 @@ -#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. - */ -/* - * Copyright (c) 1993-1999 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - /* - * 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(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) -#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__ */ diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am deleted file mode 100644 index 678903056..000000000 --- a/hw/xfree86/os-support/bsd/Makefile.am +++ /dev/null @@ -1,85 +0,0 @@ -noinst_LTLIBRARIES = libbsd.la - -# FIXME: Add USB mouse support? - -# FIXME: APM support. -APM_SOURCES = $(srcdir)/../shared/pm_noop.c - -if FREEBSD_KLDLOAD -KMOD_SOURCES = bsd_kmod.c -else -KMOD_SOURCES = $(srcdir)/../shared/kmod_noop.c -endif - -# FIXME: Non-i386/ia64 resource support. -RES_SOURCES = $(srcdir)/../shared/stdResource.c - -if AGP -AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c -else -AGP_SOURCES = $(srcdir)/../shared/agp_noop.c -endif - -if ALPHA_VIDEO -# Cheat here and piggyback other alpha bits on ALPHA_VIDEO. -ARCH_SOURCES = \ - alpha_video.c \ - bsd_ev56.c \ - bsd_axp.c \ - $(srcdir)/../shared/xf86Axp.c -endif - -if ARM_VIDEO -ARCH_SOURCES = arm_video.c -endif - -if I386_VIDEO -ARCH_SOURCES = i386_video.c -endif - -if PPC_VIDEO -ARCH_SOURCES = ppc_video.c -endif - -if SPARC64_VIDEO -# Cheat here and piggyback other sparc64 bits on SPARC64_VIDEO. -ARCH_SOURCES = \ - sparc64_video.c \ - $(srcdir)/../shared/ioperm_noop.c -endif - -# FIXME: NetBSD Aperture defines (configure.ac) -AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS) - -INCLUDES = $(XORG_INCS) - -libbsd_la_SOURCES = \ - $(srcdir)/../shared/posix_tty.c \ - $(srcdir)/../shared/sigio.c \ - $(srcdir)/../shared/vidmem.c \ - bsd_VTsw.c \ - bsd_init.c \ - bsd_mouse.c \ - bsd_bell.c \ - $(ARCH_SOURCES) \ - $(AGP_SOURCES) \ - $(APM_SOURCES) \ - $(AXP_SOURCES) \ - $(DRI_SOURCES) \ - $(KMOD_SOURCES) \ - $(RES_SOURCES) - -# FIXME: Add these files to the build as needed -EXTRA_DIST = \ - bsd_apm.c \ - bsd_kqueue_apm.c \ - bsdResource.c \ - memrange.h \ - libusb/data.c \ - libusb/descr.c \ - libusb/parse.c \ - libusb/usage.c \ - libusb/usb.3 \ - libusb/usb.h \ - libusb/usb_hid_usages \ - libusb/usbvar.h diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c deleted file mode 100644 index 523c4488e..000000000 --- a/hw/xfree86/os-support/bsd/alpha_video.c +++ /dev/null @@ -1,732 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" - -#include <sys/param.h> -#ifndef __NetBSD__ -# include <sys/sysctl.h> -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -# include <machine/sysarch.h> -# endif -# else -# include <machine/sysarch.h> -#endif - -#include "xf86Axp.h" - -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - -axpDevice bsdGetAXP(void); - -#ifndef __NetBSD__ -extern unsigned long dense_base(void); - -static int axpSystem = -1; -static unsigned long hae_thresh; -static unsigned long hae_mask; -static unsigned long bus_base; -static unsigned long sparse_size; - -static unsigned long -memory_base(void) -{ - static unsigned long base = 0; - - if (base == 0) { - size_t len = sizeof(base); - int error; -#ifdef __OpenBSD__ - int mib[3]; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_MEM; - - if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0) -#else - if ((error = sysctlbyname("hw.chipset.memory", &base, &len, - 0, 0)) < 0) -#endif - FatalError("xf86MapVidMem: can't find memory\n"); - } - - return base; -} - -static int -has_bwx(void) -{ - static int bwx = 0; - size_t len = sizeof(bwx); - int error; -#ifdef __OpenBSD__ - int mib[3]; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_BWX; - - if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0) - return FALSE; - else - return bwx; -#else - if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0) - return FALSE; - else - return bwx; -#endif -} -#else /* __NetBSD__ */ -static unsigned long hae_thresh = (1UL << 24); -static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */ -static struct alpha_bus_window *abw; -static int abw_count = -1; - -static void -init_abw(void) -{ - if (abw_count < 0) { - abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw); - if (abw_count <= 0) - FatalError("init_abw: alpha_bus_getwindows failed\n"); - } -} - -static int -has_bwx(void) -{ - if (abw_count < 0) - init_abw(); - - xf86Msg(X_INFO, "has_bwx = %d\n", - abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */ - return abw[0].abw_abst.abst_flags & ABST_BWX; -} - -static unsigned long -dense_base(void) -{ - if (abw_count < 0) - init_abw(); - - /* XXX check abst_flags for ABST_DENSE just to be safe? */ - xf86Msg(X_INFO, "dense base = %#lx\n", - abw[0].abw_abst.abst_sys_start); /* XXXX */ - return abw[0].abw_abst.abst_sys_start; -} - -static unsigned long -memory_base(void) -{ - if (abw_count < 0) - init_abw(); - - if (abw_count > 0) { - xf86Msg(X_INFO, "memory base = %#lx\n", - abw[1].abw_abst.abst_sys_start); /* XXXX */ - return abw[1].abw_abst.abst_sys_start; - } else { - xf86Msg(X_INFO, "no memory base\n"); /* XXXX */ - return 0; - } -} -#endif /* __NetBSD__ */ - -#define BUS_BASE dense_base() -#define BUS_BASE_BWX memory_base() - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -#ifdef __OpenBSD__ -#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ - "\tin /etc/sysctl.conf and reboot your machine\n" \ - "\trefer to xf86(4) for details" -#endif - -static Bool useDevMem = FALSE; -static int devMemFd = -1; - -#ifdef HAS_APERTURE_DRV -#define DEV_APERTURE "/dev/xf86" -#endif -#define DEV_MEM "/dev/mem" - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); -static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); -static void unmapVidMemSparse(int, pointer, unsigned long); - -/* - * Check if /dev/mem can be mmap'd. If it can't print a warning when - * "warn" is TRUE. - */ -static void -checkDevMem(Bool warn) -{ - static Bool devMemChecked = FALSE; - int fd; - pointer base; - - if (devMemChecked) - return; - devMemChecked = TRUE; - -#ifdef HAS_APERTURE_DRV - /* Try the aperture driver first */ - if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", - DEV_APERTURE); - return; - } else { - if (warn) { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_APERTURE, strerror(errno)); - } - } - } -#endif - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - return; - } else { - if (warn) { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - } - } - } - if (warn) { -#ifndef HAS_APERTURE_DRV - xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n", - DEV_MEM, strerror(errno)); -#else -#ifndef __OpenBSD__ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno)); -#else /* __OpenBSD__ */ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno), - SYSCTL_MSG); -#endif /* __OpenBSD__ */ -#endif - xf86ErrorF("\tlinear framebuffer access unavailable\n"); - } - useDevMem = FALSE; - return; -} - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - - if (has_bwx()) { - xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n"); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - } else { - xf86Msg(X_PROBED,"Machine needs sparse mapping\n"); - pVidMem->mapMem = mapVidMemSparse; - pVidMem->unmapMem = unmapVidMemSparse; -#ifndef __NetBSD__ - if (axpSystem == -1) - axpSystem = bsdGetAXP(); - hae_thresh = xf86AXPParams[axpSystem].hae_thresh; - hae_mask = xf86AXPParams[axpSystem].hae_mask; - sparse_size = xf86AXPParams[axpSystem].size; -#endif /* __NetBSD__ */ - } - pVidMem->initialised = TRUE; -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - - checkDevMem(FALSE); - Base = Base & ((1L<<32) - 1); - - if (useDevMem) - { - if (devMemFd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); - if (base == MAP_FAILED) - { - FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, - strerror(errno)); - } - return(base); - } - - /* else, mmap /dev/vga */ - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) - { - FatalError("%s: Address 0x%lx outside allowable range\n", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base + BUS_BASE); - if (base == MAP_FAILED) - { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return(base); -} - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap((caddr_t)Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); - if ((long)ptr == -1) - { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return(-1); - } -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return(Len); -} - - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) - -extern int ioperm(unsigned long from, unsigned long num, int on); - -_X_EXPORT Bool -xf86EnableIO() -{ - if (!ioperm(0, 65536, TRUE)) - return TRUE; - return FALSE; -} - -_X_EXPORT void -xf86DisableIO() -{ - return; -} - -#endif /* __FreeBSD_kernel__ || __OpenBSD__ */ - -#ifdef USE_ALPHA_PIO - -Bool -xf86EnableIO() -{ - alpha_pci_io_enable(1); - return TRUE; -} - -void -xf86DisableIO() -{ - alpha_pci_io_enable(0); -} - -#endif /* USE_ALPHA_PIO */ - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - return; -} - - -#define vuip volatile unsigned int * - -static unsigned long msb_set = 0; -static pointer memSBase = 0; -static pointer memBase = 0; - -extern int readDense8(pointer Base, register unsigned long Offset); -extern int readDense16(pointer Base, register unsigned long Offset); -extern int readDense32(pointer Base, register unsigned long Offset); -extern void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset); -extern void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset); -extern void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense8(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense16(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense32(int Value, pointer Base, register unsigned long Offset); - -static int readSparse8(pointer Base, register unsigned long Offset); -static int readSparse16(pointer Base, register unsigned long Offset); -static int readSparse32(pointer Base, register unsigned long Offset); -static void -writeSparseNB8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseNB16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseNB32(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse32(int Value, pointer Base, register unsigned long Offset); - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -extern int sysarch(int, void *); -#endif - -struct parms { - u_int64_t hae; -}; - -#ifndef __NetBSD__ -static int -sethae(u_int64_t hae) -{ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -#ifndef ALPHA_SETHAE -#define ALPHA_SETHAE 0 -#endif - struct parms p; - p.hae = hae; - return (sysarch(ALPHA_SETHAE, (char *)&p)); -#endif -#ifdef __OpenBSD__ - return -1; -#endif -} -#endif /* __NetBSD__ */ - -static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - static Bool was_here = FALSE; - - if (!was_here) { - was_here = TRUE; - - checkDevMem(FALSE); - - xf86WriteMmio8 = writeSparse8; - xf86WriteMmio16 = writeSparse16; - xf86WriteMmio32 = writeSparse32; - xf86WriteMmioNB8 = writeSparseNB8; - xf86WriteMmioNB16 = writeSparseNB16; - xf86WriteMmioNB32 = writeSparseNB32; - xf86ReadMmio8 = readSparse8; - xf86ReadMmio16 = readSparse16; - xf86ReadMmio32 = readSparse32; - - memBase = mmap((caddr_t)0, 0x100000000, - PROT_READ | PROT_WRITE, - MAP_SHARED, devMemFd, - (off_t) BUS_BASE); - memSBase = mmap((caddr_t)0, 0x100000000, - PROT_READ | PROT_WRITE, - MAP_SHARED, devMemFd, - (off_t) BUS_BASE_BWX); - - if (memSBase == MAP_FAILED || memBase == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", - strerror(errno)); - } - } - return (pointer)((unsigned long)memBase + Base); -} - -static void -unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size) -{ -} - -static int -readSparse8(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - shift = (Offset & 0x3) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - result = *(vuip) ((unsigned long)memSBase + (Offset << 5)); - result >>= shift; - return 0xffUL & result; -} - -static int -readSparse16(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - shift = (Offset & 0x2) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))); - result >>= shift; - return 0xffffUL & result; -} - -static int -readSparse32(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(vuip)((unsigned long)Base+(Offset)); -} - -static void -writeSparse8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - write_mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparse16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - write_mem_barrier(); - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = - w * 0x00010001; - -} - -static void -writeSparse32(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(vuip)((unsigned long)Base + (Offset)) = Value; - return; -} - -static void -writeSparseNB8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparseNB16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - Offset += (unsigned long)Base - (unsigned long)memBase; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask ; - Offset -= msb; - if (msb_set != msb) { -#ifndef __NetBSD__ - sethae(msb); -#endif - msb_set = msb; - } - } - *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = - w * 0x00010001; -} - -static void -writeSparseNB32(int Value, pointer Base, register unsigned long Offset) -{ - *(vuip)((unsigned long)Base + (Offset)) = Value; - return; -} - -_X_EXPORT void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) - = writeDense8; -_X_EXPORT void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset) - = writeDense16; -_X_EXPORT void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset) - = writeDense32; -_X_EXPORT void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB8; -_X_EXPORT void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB16; -_X_EXPORT void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB32; -_X_EXPORT int (*xf86ReadMmio8)(pointer Base, unsigned long Offset) - = readDense8; -_X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) - = readDense16; -_X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) - = readDense32; - diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c deleted file mode 100644 index 23948b5d6..000000000 --- a/hw/xfree86/os-support/bsd/arm_video.c +++ /dev/null @@ -1,687 +0,0 @@ -/* - * 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. - * - */ - -/* - * The ARM32 code here carries the following copyright: - * - * Copyright 1997 - * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is - * transferred hereby. - * - * 1) Any source code used, modified or distributed must reproduce and retain - * this copyright notice and list of conditions as they appear in the - * source file. - * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" - * name nor any trademark or logo of Digital Equipment Corporation may be - * used to endorse or promote products derived from this software without - * the prior written permission of Digital Equipment Corporation. - * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. - * In no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for lost profits, loss - * of revenue or loss of use, whether such damages arise in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even - * if advised of the possibility of such damage. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifdef __arm32__ -#include "machine/devmap.h" -struct memAccess -{ - int ioctl; - struct map_info memInfo; - pointer regionVirtBase; - Bool Checked; - Bool OK; -}; - -static pointer xf86MapInfoMap(); -static void xf86MapInfoUnmap(); -static struct memAccess *checkMapInfo(); -extern int vgaPhysLinearBase; - -/* A memAccess structure is needed for each possible region */ -struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, - FALSE, FALSE }; -struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, - FALSE, FALSE }; -struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, - FALSE, FALSE }; -#endif /* __arm32__ */ - -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - - -#define BUS_BASE 0L -#define BUS_BASE_BWX 0L - - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static Bool useDevMem = FALSE; -static int devMemFd = -1; - -#define DEV_MEM "/dev/mem" - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); - -/* - * Check if /dev/mem can be mmap'd. If it can't print a warning when - * "warn" is TRUE. - */ -static void -checkDevMem(Bool warn) -{ - static Bool devMemChecked = FALSE; - int fd; - pointer base; - - if (devMemChecked) - return; - devMemChecked = TRUE; - - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) - { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); - - if (base != MAP_FAILED) - { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - return; - } else { - /* This should not happen */ - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; - } - } - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; -} - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = armMapVidMem; - pVidMem->unmapVidMem = armUnmapVidMem; - - pVidMem->initialised = TRUE; -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - - checkDevMem(FALSE); - - if (useDevMem) - { - if (devMemFd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); - if (base == MAP_FAILED) - { - FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", DEV_MEM, Size, Base, - strerror(errno)); - } - return(base); - } - - /* else, mmap /dev/vga */ - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) - { - FatalError("%s: Address 0x%x outside allowable range\n", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base - 0xA0000); - if (base == MAP_FAILED) - { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", - strerror(errno)); - } - return(base); -} - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap((caddr_t)Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); - if ((long)ptr == -1) - { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); - return(-1); - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return(Len); -} - - -/* XXX This needs to be updated for the ND */ - -/* -** Find out whether the console driver provides memory mapping information -** for the specified region and return the map_info pointer. Print a warning if required. -*/ -static struct memAccess * -checkMapInfo(Bool warn, int Region) -{ - struct memAccess *memAccP; - - switch (Region) - { - case VGA_REGION: - memAccP = &vgaMemInfo; - break; - - case LINEAR_REGION: - memAccP = &linearMemInfo; - break; - - case MMIO_REGION: - memAccP = &ioMemInfo; - break; - - default: - return NULL; - break; - } - - if(!memAccP->Checked) - { - if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) - { - if(warn) - { - xf86Msg(X_WARNING, - "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", - Region, strerror(errno)); - } - } - else - { - if(memAccP->memInfo.u.map_info_mmap.map_offset - != MAP_INFO_UNKNOWN) - memAccP->OK = TRUE; - } - memAccP->Checked = TRUE; - } - if (memAccP->OK) - { - return memAccP; - } - else - { - return NULL; - } -} - -static pointer -xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) - { - Size = (unsigned long)Base + Size; - } - else - { - Size = mapInfoP->u.map_info_mmap.map_size; - } - - switch(mapInfoP->method) - { - case MAP_MMAP: - /* Need to remap if size is unknown because we may not have - mapped the whole region initially */ - if(memInfoP->regionVirtBase == NULL || - mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) - { - if((memInfoP->regionVirtBase = - mmap((caddr_t)0, - Size, - PROT_READ | PROT_WRITE, - MAP_SHARED, - xf86Info.screenFd, - (unsigned long)mapInfoP->u.map_info_mmap.map_offset)) - == (pointer)-1) - { - FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", - mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); - } - if(mapInfoP->u.map_info_mmap.internal_offset > 0) - memInfoP->regionVirtBase += - mapInfoP->u.map_info_mmap.internal_offset; - } - break; - - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } - - return (pointer)((int)memInfoP->regionVirtBase + (int)Base); -} - -static void -xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) -{ - struct map_info *mapInfoP = &(memInfoP->memInfo); - - switch(mapInfoP->method) - { - case MAP_MMAP: - if(memInfoP->regionVirtBase != NULL) - { - if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) - Size = mapInfoP->u.map_info_mmap.map_size; - munmap((caddr_t)memInfoP->regionVirtBase, Size); - memInfoP->regionVirtBase = NULL; - } - break; - default: - FatalError("xf86MapInfoMap: Unsuported mapping method\n"); - break; - } -} - -static pointer -armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct memAccess *memInfoP; - - if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) - { - /* - ** xf86 passes in a physical address offset from the start - ** of physical memory, but xf86MapInfoMap expects an - ** offset from the start of the specified region - it gets - ** the physical address of the region from the display driver. - */ - switch(Region) - { - case LINEAR_REGION: - if (vgaPhysLinearBase) - { - Base -= vgaPhysLinearBase; - } - break; - case VGA_REGION: - Base -= 0xA0000; - break; - } - - base = xf86MapInfoMap(memInfoP, Base, Size); - return (base); - } - return mapVidMem(ScreenNum, Base, Size, flags); -} - -static void -armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - struct memAccess *memInfoP; - - if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) - { - xf86MapInfoUnmap(memInfoP, Base, Size); - } - unmapVidMem(ScreenNum, Base, Size); -} - -#ifdef USE_DEV_IO -static int IoFd = -1; - -_X_EXPORT Bool -xf86EnableIO() -{ - if (IoFd >= 0) - return TRUE; - - if ((IoFd = open("/dev/io", O_RDWR)) == -1) - { - xf86Msg(X_WARNING,"xf86EnableIO: " - "Failed to open /dev/io for extended I/O\n"); - return FALSE; - } - return TRUE; -} - -_X_EXPORT void -xf86DisableIO() -{ - if (IoFd < 0) - return; - - close(IoFd); - IoFd = -1; - return; -} - -#endif - -#if defined(USE_ARC_MMAP) || defined(__arm32__) - -Bool -xf86EnableIO() -{ - int fd; - pointer base; - - if (ExtendedEnabled) - return TRUE; - - if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { - /* Try to map a page at the pccons I/O space */ - base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0x0000); - - if (base != (pointer)-1) { - IOPortBase = base; - } - else { - xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - return FALSE; - } - } - else { - xf86Msg("EnableIO: failed to open %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - return FALSE; - } - - ExtendedEnabled = TRUE; - - return TRUE; -} - -void -xf86DisableIO() -{ - return; -} - -#endif /* USE_ARC_MMAP */ - - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - - return; -} - - - -#if 0 -/* - * XXX This is here for reference. It needs to be handled differently for the - * ND. - */ -#if defined(USE_ARC_MMAP) || defined(__arm32__) - -#ifdef USE_ARM32_MMAP -#define DEV_MEM_IOBASE 0x43000000 -#endif - -static Bool ScreenEnabled[MAXSCREENS]; -static Bool ExtendedEnabled = FALSE; -static Bool InitDone = FALSE; - -Bool -xf86EnableIOPorts(ScreenNum) -int ScreenNum; -{ - int i; - int fd; - pointer base; - -#ifdef __arm32__ - struct memAccess *memInfoP; - int *Size; -#endif - - ScreenEnabled[ScreenNum] = TRUE; - - if (ExtendedEnabled) - return TRUE; - -#ifdef USE_ARC_MMAP - if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { - /* Try to map a page at the pccons I/O space */ - base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0x0000); - - if (base != (pointer)-1) { - IOPortBase = base; - } - else { - xf86Msg(X_ERROR, - "EnableIOPorts: failed to mmap %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - } - } - else { - xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n", - "/dev/ttyC0", strerror(errno)); - } -#endif - -#ifdef __arm32__ - IOPortBase = (unsigned int)-1; - - if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) - { - /* - * xf86MapInfoMap maps an offset from the start of video IO - * space (e.g. 0x3B0), but IOPortBase is expected to map to - * physical address 0x000, so subtract the start of video I/O - * space from the result. This is safe for now becase we - * actually mmap the start of the page, then the start of video - * I/O space is added as an internal offset. - */ - IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP, - (caddr_t)0x0, 0L) - - memInfoP->memInfo.u.map_info_mmap.internal_offset; - ExtendedEnabled = TRUE; - return TRUE; - } -#ifdef USE_ARM32_MMAP - checkDevMem(TRUE); - - if (devMemFd >= 0 && useDevMem) - { - base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE, - MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE); - - if (base != (pointer)-1) - IOPortBase = (unsigned int)base; - } - - if (IOPortBase == (unsigned int)-1) - { - xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ -Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n"); - return FALSE; - } -#else - /* We don't have the IOBASE, so we can't map the address */ - xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ -Try building the server with USE_ARM32_MMAP defined\n"); - return FALSE; -#endif -#endif - - ExtendedEnabled = TRUE; - - return TRUE; -} - -void -xf86DisableIOPorts(ScreenNum) -int ScreenNum; -{ - int i; -#ifdef __arm32__ - struct memAccess *memInfoP; -#endif - - ScreenEnabled[ScreenNum] = FALSE; - -#ifdef __arm32__ - if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) - { - xf86MapInfoUnmap(memInfoP, 0); - } -#endif - -#ifdef USE_ARM32_MMAP - if (!ExtendedEnabled) - return; - - for (i = 0; i < MAXSCREENS; i++) - if (ScreenEnabled[i]) - return; - - munmap((caddr_t)IOPortBase, 0x400); - IOPortBase = (unsigned int)-1; - ExtendedEnabled = FALSE; -#endif - - return; -} - -#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */ -#endif - - diff --git a/hw/xfree86/os-support/bsd/bsdResource.c b/hw/xfree86/os-support/bsd/bsdResource.c deleted file mode 100644 index d1ee787f1..000000000 --- a/hw/xfree86/os-support/bsd/bsdResource.c +++ /dev/null @@ -1,92 +0,0 @@ - -/* Resource information code */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86Privstr.h" -#include "xf86Pci.h" -#include "xf86Resources.h" -#define NEED_OS_RAC_PROTOS -#include "xf86_OSlib.h" - -/* Avoid Imakefile changes */ -#include "bus/Pci.h" - -#ifdef INCLUDE_XF86_NO_DOMAIN - -#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__x86_64__) - -resPtr -xf86AccResFromOS(resPtr ret) -{ - resRange range; - - /* - * Fallback is to claim the following areas: - * - * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS - */ - - RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - - /* - * Fallback would be to claim well known ports in the 0x0 - 0x3ff range - * along with their sparse I/O aliases, but that's too imprecise. Instead - * claim a bare minimum here. - */ - RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ - ret = xf86AddResToList(ret, &range, -1); - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ - RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); -/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); */ - RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); - - /* XXX add others */ - return ret; -} - -#elif defined(__powerpc__) - -resPtr -xf86AccResFromOS(resPtr ret) -{ - resRange range; - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ - RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); - - return ret; -} - -#else - -#error : Put your platform dependent code here!! - -#endif - -#endif /* INCLUDE_XF86_NO_DOMAIN */ diff --git a/hw/xfree86/os-support/bsd/bsd_VTsw.c b/hw/xfree86/os-support/bsd/bsd_VTsw.c deleted file mode 100644 index 476a0e957..000000000 --- a/hw/xfree86/os-support/bsd/bsd_VTsw.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.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(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); -} diff --git a/hw/xfree86/os-support/bsd/bsd_apm.c b/hw/xfree86/os-support/bsd/bsd_apm.c deleted file mode 100644 index 43eda7421..000000000 --- a/hw/xfree86/os-support/bsd/bsd_apm.c +++ /dev/null @@ -1,139 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include "xf86_OSlib.h" - -#include <machine/apmvar.h> - -#define APM_DEVICE "/dev/apm" - -static pointer APMihPtr = NULL; -static void bsdCloseAPM(void); - -static struct { - u_int apmBsd; - pmEvent xf86; -} bsdToXF86Array [] = { - { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, - { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, - { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, - { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, - { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, - { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, - { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, - { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, - { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, - { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, - { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, -#ifdef APM_CAPABILITY_CHANGE - { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, -#endif -}; - -#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0])) - -static pmEvent -bsdToXF86(int type) -{ - int i; - - for (i = 0; i < numApmEvents; i++) { - if (type == bsdToXF86Array[i].apmBsd) { - return bsdToXF86Array[i].xf86; - } - } - return XF86_APM_UNKNOWN; -} - -/* - * APM events can be requested direclty from /dev/apm - */ -static int -bsdPMGetEventFromOS(int fd, pmEvent *events, int num) -{ - struct apm_event_info bsdEvent; - int i; - - for (i = 0; i < num; i++) { - - if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) { - if (errno != EAGAIN) { - xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT" - " %s\n", strerror(errno)); - } - break; - } - events[i] = bsdToXF86(bsdEvent.type); - } - return i; -} - -/* - * XXX This won't work on /dev/apm ! - * We should either use /dev/apm_ctl (and kill apmd(8)) - * or talk to apmd (but its protocol is not publically available)... - */ -static pmWait -bsdPMConfirmEventToOs(int fd, pmEvent event) -{ - switch (event) { - case XF86_APM_SYS_STANDBY: - case XF86_APM_USER_STANDBY: - if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0) - return PM_WAIT; /* should we stop the Xserver in standby, too? */ - else - return PM_NONE; - case XF86_APM_SYS_SUSPEND: - case XF86_APM_CRITICAL_SUSPEND: - case XF86_APM_USER_SUSPEND: - if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) - return PM_WAIT; - else - return PM_NONE; - case XF86_APM_STANDBY_RESUME: - case XF86_APM_NORMAL_RESUME: - case XF86_APM_CRITICAL_RESUME: - case XF86_APM_STANDBY_FAILED: - case XF86_APM_SUSPEND_FAILED: - return PM_CONTINUE; - default: - return PM_NONE; - } -} - -PMClose -xf86OSPMOpen(void) -{ - int fd; - - if (APMihPtr || !xf86Info.pmFlag) { - return NULL; - } - - if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { - return NULL; - } - xf86PMGetEventFromOs = bsdPMGetEventFromOS; - xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; - APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL); - return bsdCloseAPM; -} - -static void -bsdCloseAPM(void) -{ - int fd; - - if (APMihPtr) { - fd = xf86RemoveInputHandler(APMihPtr); - close(fd); - APMihPtr = NULL; - } -} diff --git a/hw/xfree86/os-support/bsd/bsd_axp.c b/hw/xfree86/os-support/bsd/bsd_axp.c deleted file mode 100644 index 51ffef148..000000000 --- a/hw/xfree86/os-support/bsd/bsd_axp.c +++ /dev/null @@ -1,72 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86Axp.h" -#include <sys/param.h> -#include "xf86_OSlib.h" -#include <stdio.h> -#include <sys/sysctl.h> - -axpDevice bsdGetAXP(void); - -/* - * BSD does a very nice job providing system information to - * user space programs. Unfortunately it doesn't provide all - * the information required. Therefore we just obtain the - * system type and look up the rest from a list we maintain - * ourselves. - */ - -typedef struct { - char *name; - int type; -} _AXP; - -static _AXP axpList[] = { - {"apecs",APECS}, - {"pyxis",PYXIS}, - {"cia",CIA}, - {"irongate",IRONGATE}, - {"lca",LCA}, - {"t2",T2}, - {"tsunami",TSUNAMI}, - {NULL,NONE} -}; - -axpDevice -bsdGetAXP(void) -{ - int i; - char sysname[64]; - size_t len = sizeof(sysname); - -#ifdef __OpenBSD__ - int mib[3]; - int error; - - mib[0] = CTL_MACHDEP; - mib[1] = CPU_CHIPSET; - mib[2] = CPU_CHIPSET_TYPE; - - if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0) -#else - if ((sysctlbyname("hw.chipset.type", &sysname, &len, - 0, 0)) < 0) -#endif - FatalError("bsdGetAXP: can't find machine type\n"); -#ifdef DEBUG - xf86Msg(X_INFO,"AXP is a: %s\n",sysname); -#endif - for (i=0;;i++) { - if (axpList[i].name == NULL) - return NONE; - if (!strcmp(sysname, axpList[i].name)) - return axpList[i].type; - } -} diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c deleted file mode 100644 index 0d2420102..000000000 --- a/hw/xfree86/os-support/bsd/bsd_bell.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 1992 by Rich Murphey <Rich@Rice.edu> - * 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 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#if defined (SYSCONS_SUPPORT) -#include <sys/kbio.h> -#endif - -#include <termios.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifdef WSCONS_SUPPORT -#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd) -#endif - -_X_EXPORT void -xf86OSRingBell(int loudness, int pitch, int duration) -{ -#ifdef WSCONS_SUPPORT - struct wskbd_bell_data wsb; -#endif - - if (loudness && pitch) - { -#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 -#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 -#if defined (WSCONS_SUPPORT) - case WSCONS: - wsb.which = WSKBD_BELL_DOALL; - wsb.pitch = pitch; - wsb.period = duration; - wsb.volume = loudness; - ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL, - &wsb); - break; -#endif - } - } -} diff --git a/hw/xfree86/os-support/bsd/bsd_ev56.c b/hw/xfree86/os-support/bsd/bsd_ev56.c deleted file mode 100644 index b2141192e..000000000 --- a/hw/xfree86/os-support/bsd/bsd_ev56.c +++ /dev/null @@ -1,90 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -int readDense8(pointer Base, register unsigned long Offset); -int readDense16(pointer Base, register unsigned long Offset); -int readDense32(pointer Base, register unsigned long Offset); -void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset); -void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset); -void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset); -void -writeDense8(int Value, pointer Base, register unsigned long Offset); -void -writeDense16(int Value, pointer Base, register unsigned long Offset); -void -writeDense32(int Value, pointer Base, register unsigned long Offset); - -int -readDense8(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(volatile CARD8*) ((unsigned long)Base+(Offset)); -} - -int -readDense16(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(volatile CARD16*) ((unsigned long)Base+(Offset)); -} - -int -readDense32(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(volatile CARD32*)((unsigned long)Base+(Offset)); -} - -void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset) -{ - *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset) -{ - *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value; -} - -void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset) -{ - *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDense8(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDense16(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDense32(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value; -} diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c deleted file mode 100644 index 2c6a0256b..000000000 --- a/hw/xfree86/os-support/bsd/bsd_init.c +++ /dev/null @@ -1,739 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include <sys/utsname.h> -#include <sys/ioctl.h> -#include <stdlib.h> -#include <errno.h> - -static Bool KeepTty = FALSE; -static int devConsoleFd = -1; -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) -static int VTnum = -1; -static int initialVT = -1; -#endif - -#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 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 - -#if defined(WSCONS_SUPPORT) && defined(__NetBSD__) -/* NetBSD's new console driver */ -#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0" -#endif - -#ifdef __GLIBC__ -#define setpgrp setpgid -#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 SYSCONS_SUPPORT - "syscons", -#endif -#ifdef PCVT_SUPPORT - "pcvt", -#endif -#ifdef WSCONS_SUPPORT - "wscons", -#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)(void); - -#ifdef PCCONS_SUPPORT -static int xf86OpenPccons(void); -#endif /* PCCONS_SUPPORT */ - -#ifdef SYSCONS_SUPPORT -static int xf86OpenSyscons(void); -#endif /* SYSCONS_SUPPORT */ - -#ifdef PCVT_SUPPORT -static int xf86OpenPcvt(void); -#endif /* PCVT_SUPPORT */ - -#ifdef WSCONS_SUPPORT -static int xf86OpenWScons(void); -#endif - -/* - * 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.) - */ -static xf86ConsOpen_t xf86ConsTab[] = { -#ifdef PCVT_SUPPORT - xf86OpenPcvt, -#endif -#ifdef SYSCONS_SUPPORT - xf86OpenSyscons, -#endif -#ifdef PCCONS_SUPPORT - xf86OpenPccons, -#endif -#ifdef WSCONS_SUPPORT - xf86OpenWScons, -#endif - (xf86ConsOpen_t)NULL -}; - - -void -xf86OpenConsole() -{ - int i, fd = -1; - xf86ConsOpen_t *driver; -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - int result; -#ifdef __FreeBSD__ - struct utsname uts; -#endif - vtmode_t vtmode; -#endif - - if (serverGeneration == 1) - { - /* check if we are run with euid==0 */ - if (geteuid() != 0) - { - FatalError("xf86OpenConsole: Server must be suid root"); - } - - 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", - "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); - } -#if 0 /* stdin is already closed in OsInit() */ - fclose(stdin); -#endif - xf86Info.consoleFd = fd; - xf86Info.screenFd = fd; - - switch (xf86Info.consType) - { -#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", - "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) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: couldn't open /dev/console (%s)\n", - strerror(errno)); - } - break; -#endif -#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) - case SYSCONS: - /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt - * switching anymore. Here we check for FreeBSD 3.1 and up. - * Add cases for other *BSD that behave the same. - */ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - uname (&uts); - i = atof(uts.release) * 100; - if (i >= 310) goto acquire_vt; -#endif - /* otherwise fall through */ - case PCVT: -#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)) - /* - * 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) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - sleep(1); - } -#endif -acquire_vt: - /* - * now get the VT - */ - SYSCALL(result = - ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); - if (result != 0) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - SYSCALL(result = - ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); - if (result != 0) - { - xf86Msg(X_WARNING, "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"); - } -#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) - if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) - { - FatalError("xf86OpenConsole: KDENABIO failed (%s)", - strerror(errno)); - } -#endif - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) - { - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed"); - } - break; -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ -#ifdef WSCONS_SUPPORT - case WSCONS: - fprintf(stderr, "xf86OpenConsole\n"); - /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */ - break; -#endif - } - } - 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) - { - xf86Msg(X_WARNING, "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", - "xf86OpenPccons", - strerror(errno), - "Was expecting pccons driver with X support", - CHECK_DRIVER_MSG); - } - xf86Info.consType = PCCONS; - xf86Msg(X_PROBED, "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; - MessageType from; - - /* 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; - from = X_CMDLINE; - -#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. - * XXX stdin is already closed, so this won't work. - */ - 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", - "xf86OpenSyscons"); - } - /* Should no longer reach here */ - FatalError("%s: %s %s\n\t%s %s", - "xf86OpenSyscons", - "syscons versions prior to 1.0 require", - "either the", - "server's stdin be a VT", - "or the use of the vtxx server option"); - } - } - from = X_PROBED; - } - - 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)", - vtname, strerror(errno)); - } - if (ioctl(fd, VT_GETMODE, &vtmode) < 0) - { - FatalError("xf86OpenSyscons: VT_GETMODE failed"); - } - xf86Info.consType = SYSCONS; - xf86Msg(X_PROBED, "Using syscons driver with X support"); - if (syscons_version >= 0x100) - { - xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8, - syscons_version & 0xFF); - } - else - { - xf86ErrorF(" (version 0.x)\n"); - } - xf86Msg(from, "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 PCVT_SUPPORT - -static int -xf86OpenPcvt() -{ - /* This looks much like syscons, since pcvt is API compatible */ - int fd = -1; - vtmode_t vtmode; - char vtname[12], *vtprefix; - struct stat status; - struct pcvtid pcvt_version; - -#ifndef __OpenBSD__ - vtprefix = "/dev/ttyv"; -#else - vtprefix = "/dev/ttyC"; -#endif - - fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); -#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV - if (fd < 0) - { - fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); - vtprefix = "/dev/ttyE"; - } -#endif - if (fd >= 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", - "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. - * XXX stdin is already closed, so this won't work. - */ - 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", - "xf86OpenPcvt"); - } - } - } - - close(fd); - sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); - if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) - { - FatalError("xf86OpenPcvt: Cannot open %s (%s)", - vtname, strerror(errno)); - } - if (ioctl(fd, VT_GETMODE, &vtmode) < 0) - { - FatalError("xf86OpenPcvt: VT_GETMODE failed"); - } - xf86Info.consType = PCVT; -#ifdef WSCONS_SUPPORT - xf86Msg(X_PROBED, - "Using wscons driver in pcvt compatibility mode " - "(version %d.%d)\n", - pcvt_version.rmajor, pcvt_version.rminor); -#else - xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n", - pcvt_version.rmajor, pcvt_version.rminor); -#endif - } - else - { - /* Not pcvt */ - close(fd); - fd = -1; - } - } - return fd; -} - -#endif /* PCVT_SUPPORT */ - -#ifdef WSCONS_SUPPORT - -static int -xf86OpenWScons() -{ - int fd = -1; - int mode = WSDISPLAYIO_MODE_MAPPED; - int i; - char ttyname[16]; - - /* XXX Is this ok? */ - for (i = 0; i < 8; i++) { -#if defined(__NetBSD__) - sprintf(ttyname, "/dev/ttyE%d", i); -#elif defined(__OpenBSD__) - sprintf(ttyname, "/dev/ttyC%d", i); -#endif - if ((fd = open(ttyname, 2)) != -1) - break; - } - if (fd != -1) { - if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) { - FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s", - "xf86OpenConsole", strerror(errno), - CHECK_DRIVER_MSG); - } - xf86Info.consType = WSCONS; - xf86Msg(X_PROBED, "Using wscons driver\n"); - } - return fd; -} - -#endif /* WSCONS_SUPPORT */ - -void -xf86CloseConsole() -{ -#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) - struct vt_mode VT; -#endif - - switch (xf86Info.consType) - { -#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 !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) - if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) - { - xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)", - strerror(errno)); - } -#endif - if (initialVT != -1) - ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); - break; -#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ -#ifdef WSCONS_SUPPORT - case WSCONS: - { - int mode = WSDISPLAYIO_MODE_EMUL; - ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); - break; - } -#endif - } - - 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)", - strerror(errno)); - } - } - close(xf86Info.consoleFd); - if (devConsoleFd >= 0) - close(devConsoleFd); - return; -} - -int -xf86ProcessArgument(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; -} diff --git a/hw/xfree86/os-support/bsd/bsd_kmod.c b/hw/xfree86/os-support/bsd/bsd_kmod.c deleted file mode 100644 index b6c755852..000000000 --- a/hw/xfree86/os-support/bsd/bsd_kmod.c +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <errno.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/param.h> -#include <sys/linker.h> - -#include "xf86_OSproc.h" - -/* - * Load a FreeBSD kernel module. - * This is used by the DRI/DRM to load a DRM kernel module when - * the X server starts. It could be used for other purposes in the future. - * Input: - * modName - name of the kernel module (Ex: "tdfx") - * Return: - * 0 for failure, 1 for success - */ -_X_EXPORT int xf86LoadKernelModule(const char *modName) -{ - if (kldload(modName) != -1) - return 1; - else - return 0; -} diff --git a/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c deleted file mode 100644 index b37070c37..000000000 --- a/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * from the XFree86 Project. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include "xf86_OSlib.h" - -#include <sys/event.h> -#include <machine/apmvar.h> - -#define _PATH_APM_SOCKET "/var/run/apmdev" -#define _PATH_APM_DEV "/dev/apm" -#define _PATH_APM_CTLDEV "/dev/apmctl" - -static pointer APMihPtr = NULL; -static int devFd = -1; -static int ctlFd = -1; -static void bsdCloseAPM(void); - -static struct { - u_int apmBsd; - pmEvent xf86; -} bsdToXF86Array [] = { - { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, - { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, - { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, - { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, - { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, - { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, - { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, - { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, - { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, - { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, - { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, -#ifdef APM_CAPABILITY_CHANGE - { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, -#endif -}; - -#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0])) - -static pmEvent -bsdToXF86(int type) -{ - int i; - - for (i = 0; i < numApmEvents; i++) { - if (type == bsdToXF86Array[i].apmBsd) { - return bsdToXF86Array[i].xf86; - } - } - return XF86_APM_UNKNOWN; -} - -/* - * APM events can be requested direclty from /dev/apm - */ -static int -bsdPMGetEventFromOS(int kq, pmEvent *events, int num) -{ - struct kevent ev; - int i, result; - struct timespec ts = { 0, 0 }; - - for (i = 0; i < num; i++) { - result = kevent(kq, NULL, 0, &ev, 1, &ts); - if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) { - /* no event */ - break; - } else if (result < 0) { - xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns" - " %s\n", strerror(errno)); - break; - } - events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data)); - } - return i; -} - -/* - * If apmd(8) is running, he will get the events and handle them, - * so, we've nothing to do here. - * Otherwise, opening /dev/apmctl will succeed and we have to send the - * confirmations to /dev/apmctl. - */ -static pmWait -bsdPMConfirmEventToOs(int dummyfd, pmEvent event) -{ - if (ctlFd < 0) { - if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) { - return PM_NONE; - } - } - /* apmctl open succeedeed */ - switch (event) { - case XF86_APM_SYS_STANDBY: - case XF86_APM_USER_STANDBY: - if (ioctl( ctlFd, APM_IOC_STANDBY, NULL ) == 0) - return PM_WAIT; /* should we stop the Xserver in standby, too? */ - else - return PM_NONE; - - case XF86_APM_SYS_SUSPEND: - case XF86_APM_CRITICAL_SUSPEND: - case XF86_APM_USER_SUSPEND: - if (ioctl( ctlFd, APM_IOC_SUSPEND, NULL ) == 0) - return PM_WAIT; - else - return PM_NONE; - break; - case XF86_APM_STANDBY_RESUME: - case XF86_APM_NORMAL_RESUME: - case XF86_APM_CRITICAL_RESUME: - case XF86_APM_STANDBY_FAILED: - case XF86_APM_SUSPEND_FAILED: - return PM_CONTINUE; - break; - default: - return PM_NONE; - } -} - -PMClose -xf86OSPMOpen(void) -{ - int kq; - struct kevent ev; - - if (APMihPtr || !xf86Info.pmFlag) { - return NULL; - } - if ((devFd = open(_PATH_APM_DEV, O_RDONLY)) == -1) { - return NULL; - } - if ((kq = kqueue()) <= 0) { - close(devFd); - return NULL; - } - EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR, - 0, 0, NULL); - if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0) { - close(devFd); - return NULL; - } - - xf86PMGetEventFromOs = bsdPMGetEventFromOS; - xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; - APMihPtr = xf86AddInputHandler(kq, xf86HandlePMEvents, NULL); - return bsdCloseAPM; -} - -static void -bsdCloseAPM(void) -{ - int kq; - - if (APMihPtr) { - kq = xf86RemoveInputHandler(APMihPtr); - close(devFd); - devFd = -1; - close(kq); - if (ctlFd >= 0) { - close(ctlFd); - ctlFd = -1; - } - APMihPtr = NULL; - } -} diff --git a/hw/xfree86/os-support/bsd/bsd_mouse.c b/hw/xfree86/os-support/bsd/bsd_mouse.c deleted file mode 100644 index ca2c1bbd5..000000000 --- a/hw/xfree86/os-support/bsd/bsd_mouse.c +++ /dev/null @@ -1,791 +0,0 @@ - -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" -#include "xisb.h" -#include "mipointer.h" -#ifdef WSCONS_SUPPORT -#include <dev/wscons/wsconsio.h> -#endif -#ifdef USBMOUSE_SUPPORT -#ifdef HAS_LIB_USB_HID -#include <usbhid.h> -#else -#include "usb.h" -#endif - -#include <dev/usb/usb.h> -#ifdef USB_GET_REPORT_ID -#define USB_NEW_HID -#endif - -#define HUP_GENERIC_DESKTOP 0x0001 -#define HUP_BUTTON 0x0009 - -#define HUG_X 0x0030 -#define HUG_Y 0x0031 -#define HUG_Z 0x0032 -#define HUG_WHEEL 0x0038 - -#define HID_USAGE2(p,u) (((p) << 16) | u) - -/* The UMS mices have middle button as number 3 */ -#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i)) -#endif /* USBMOUSE_SUPPORT */ - -#ifdef USBMOUSE_SUPPORT -static void usbSigioReadInput (int fd, void *closure); -#endif - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -/* These are for FreeBSD and DragonFly */ -#define DEFAULT_MOUSE_DEV "/dev/mouse" -#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse" -#define DEFAULT_PS2_DEV "/dev/psm0" - -static const char *mouseDevs[] = { - DEFAULT_MOUSE_DEV, - DEFAULT_SYSMOUSE_DEV, - DEFAULT_PS2_DEV, - NULL -}; -#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) -/* Only wsmouse mices are autoconfigured for now on OpenBSD */ -#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse" -#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0" - -static const char *mouseDevs[] = { - DEFAULT_WSMOUSE_DEV, - DEFAULT_WSMOUSE0_DEV, - NULL -}; -#endif - -static int -SupportedInterfaces(void) -{ -#if defined(__NetBSD__) - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO; -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC; -#else - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; -#endif -} - -/* Names of protocols that are handled internally here. */ -static const char *internalNames[] = { -#if defined(WSCONS_SUPPORT) - "WSMouse", -#endif -#if defined(USBMOUSE_SUPPORT) - "usb", -#endif - NULL -}; - -/* - * Names of MSC_MISC protocols that the OS supports. These are decoded by - * main "mouse" driver. - */ -static const char *miscNames[] = { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - "SysMouse", -#endif - NULL -}; - -static const char ** -BuiltinNames(void) -{ - return internalNames; -} - -static Bool -CheckProtocol(const char *protocol) -{ - int i; - - for (i = 0; internalNames[i]; i++) - if (xf86NameCmp(protocol, internalNames[i]) == 0) - return TRUE; - for (i = 0; miscNames[i]; i++) - if (xf86NameCmp(protocol, miscNames[i]) == 0) - return TRUE; - return FALSE; -} - -static const char * -DefaultProtocol(void) -{ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - return "Auto"; -#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) - return "WSMouse"; -#else - return NULL; -#endif -} - -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE) -static struct { - int dproto; - const char *name; -} devproto[] = { - { MOUSE_PROTO_MS, "Microsoft" }, - { MOUSE_PROTO_MSC, "MouseSystems" }, - { MOUSE_PROTO_LOGI, "Logitech" }, - { MOUSE_PROTO_MM, "MMSeries" }, - { MOUSE_PROTO_LOGIMOUSEMAN, "MouseMan" }, - { MOUSE_PROTO_BUS, "BusMouse" }, - { MOUSE_PROTO_INPORT, "BusMouse" }, - { MOUSE_PROTO_PS2, "PS/2" }, - { MOUSE_PROTO_HITTAB, "MMHitTab" }, - { MOUSE_PROTO_GLIDEPOINT, "GlidePoint" }, - { MOUSE_PROTO_INTELLI, "Intellimouse" }, - { MOUSE_PROTO_THINK, "ThinkingMouse" }, - { MOUSE_PROTO_SYSMOUSE, "SysMouse" } -}; - -static const char * -SetupAuto(InputInfoPtr pInfo, int *protoPara) -{ - int i; - mousehw_t hw; - mousemode_t mode; - - if (pInfo->fd == -1) - return NULL; - - /* set the driver operation level, if applicable */ - i = 1; - ioctl(pInfo->fd, MOUSE_SETLEVEL, &i); - - /* interrogate the driver and get some intelligence on the device. */ - hw.iftype = MOUSE_IF_UNKNOWN; - hw.model = MOUSE_MODEL_GENERIC; - ioctl(pInfo->fd, MOUSE_GETHWINFO, &hw); - xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: hw.iftype is %d, hw.model is %d\n", - pInfo->name, hw.iftype, hw.model); - if (ioctl(pInfo->fd, MOUSE_GETMODE, &mode) == 0) { - for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) { - if (mode.protocol == devproto[i].dproto) { - /* override some parameters */ - if (protoPara) { - protoPara[4] = mode.packetsize; - protoPara[0] = mode.syncmask[0]; - protoPara[1] = mode.syncmask[1]; - } - xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n", - pInfo->name, devproto[i].name); - return devproto[i].name; - } - } - } - return NULL; -} - -static void -SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) -{ - mousemode_t mode; - MouseDevPtr pMse; - - pMse = pInfo->private; - - mode.rate = rate > 0 ? rate : -1; - mode.resolution = res > 0 ? res : -1; - mode.accelfactor = -1; -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - if (pMse->autoProbe || - (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) { - /* - * As the FreeBSD sysmouse driver defaults to protocol level 0 - * everytime it is opened we enforce protocol level 1 again at - * this point. - */ - mode.level = 1; - } else - mode.level = -1; -#else - mode.level = -1; -#endif - ioctl(pInfo->fd, MOUSE_SETMODE, &mode); -} -#endif - -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) - -#define MOUSED_PID_FILE "/var/run/moused.pid" - -/* - * Try to check if moused is running. DEFAULT_SYSMOUSE_DEV is useless without - * it. There doesn't seem to be a better way of checking. - */ -static Bool -MousedRunning(void) -{ - FILE *f = NULL; - unsigned int pid; - - if ((f = fopen(MOUSED_PID_FILE, "r")) != NULL) { - if (fscanf(f, "%u", &pid) == 1 && pid > 0) { - if (kill(pid, 0) == 0) { - fclose(f); - return TRUE; - } - } - fclose(f); - } - return FALSE; -} - -static const char * -FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) -{ - int fd = -1; - const char **pdev, *dev = NULL; - Bool devMouse = FALSE; - struct stat devMouseStat; - struct stat sb; - - for (pdev = mouseDevs; *pdev; pdev++) { - SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); - if (fd == -1) { -#ifdef DEBUG - ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); -#endif - } else { - /* - * /dev/mouse is held until checks for matches with other devices - * are done. This is so that when it points to /dev/sysmouse, - * the test for whether /dev/sysmouse is usable can be made. - */ - if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) { - if (fstat(fd, &devMouseStat) == 0) - devMouse = TRUE; - close(fd); - continue; - } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) { - /* Check if /dev/mouse is the same as /dev/sysmouse. */ - if (devMouse && fstat(fd, &sb) == 0 && - devMouseStat.st_dev == sb.st_dev && - devMouseStat.st_ino == sb.st_ino) { - /* If the same, use /dev/sysmouse. */ - devMouse = FALSE; - } - close(fd); - if (MousedRunning()) - break; - else { -#ifdef DEBUG - ErrorF("moused isn't running\n"); -#endif - } - } else { - close(fd); - break; - } - } - } - - if (*pdev) - dev = *pdev; - else if (devMouse) - dev = DEFAULT_MOUSE_DEV; - - if (dev) { - /* Set the Device option. */ - pInfo->conf_idev->commonOptions = - xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", dev); - xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", - pInfo->name, dev); - } - - return *pdev; -} -#endif - -#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) - -/* Only support wsmouse configuration for now */ -static const char * -SetupAuto(InputInfoPtr pInfo, int *protoPara) -{ - - xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n", - pInfo->name, "wsmouse"); - return "wsmouse"; -} - -static void -SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) -{ - - xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n", - pInfo->name, protocol, rate, res); -} - -static const char * -FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) -{ - int fd = -1; - const char **pdev; - - for (pdev = mouseDevs; *pdev; pdev++) { - SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK)); - if (fd != -1) { - /* Set the Device option. */ - pInfo->conf_idev->commonOptions = - xf86AddNewOption(pInfo->conf_idev->commonOptions, - "Device", *pdev); - xf86Msg(X_INFO, "%s: found Device \"%s\"\n", - pInfo->name, *pdev); - close(fd); - break; - } - } - return *pdev; -} -#endif /* __OpenBSD__ || __NetBSD__ && WSCONS_SUPPORT */ - -#ifdef WSCONS_SUPPORT -#define NUMEVENTS 64 - -static void -wsconsReadInput(InputInfoPtr pInfo) -{ - MouseDevPtr pMse; - static struct wscons_event eventList[NUMEVENTS]; - int n, c; - struct wscons_event *event = eventList; - unsigned char *pBuf; - - pMse = pInfo->private; - - XisbBlockDuration(pMse->buffer, -1); - pBuf = (unsigned char *)eventList; - n = 0; - while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0) { - pBuf[n++] = (unsigned char)c; - } - - if (n == 0) - return; - - n /= sizeof(struct wscons_event); - while( n-- ) { - int buttons = pMse->lastButtons; - int dx = 0, dy = 0, dz = 0, dw = 0; - switch (event->type) { - case WSCONS_EVENT_MOUSE_UP: -#define BUTBIT (1 << (event->value <= 2 ? 2 - event->value : event->value)) - buttons &= ~BUTBIT; - break; - case WSCONS_EVENT_MOUSE_DOWN: - buttons |= BUTBIT; - break; - case WSCONS_EVENT_MOUSE_DELTA_X: - dx = event->value; - break; - case WSCONS_EVENT_MOUSE_DELTA_Y: - dy = -event->value; - break; -#ifdef WSCONS_EVENT_MOUSE_DELTA_Z - case WSCONS_EVENT_MOUSE_DELTA_Z: - dz = event->value; - break; -#endif - default: - xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name, - event->type); - ++event; - continue; - } - - pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); - ++event; - } - return; -} - - -/* This function is called when the protocol is "wsmouse". */ -static Bool -wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - MouseDevPtr pMse = pInfo->private; - - pMse->protocol = protocol; - xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); - - /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); - xf86ProcessCommonOptions(pInfo, pInfo->options); - - /* Check if the device can be opened. */ - pInfo->fd = xf86OpenSerial(pInfo->options); - if (pInfo->fd == -1) { - if (xf86GetAllowMouseOpenFail()) - xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); - else { - xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); - xfree(pMse); - return FALSE; - } - } - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - - /* Process common mouse options (like Emulate3Buttons, etc). */ - pMse->CommonOptions(pInfo); - - /* Setup the local input proc. */ - pInfo->read_input = wsconsReadInput; - pMse->xisbscale = sizeof(struct wscons_event); - - pInfo->flags |= XI86_CONFIGURED; - return TRUE; -} -#endif - -#if defined(USBMOUSE_SUPPORT) - -typedef struct _UsbMseRec { - int packetSize; - int iid; - hid_item_t loc_x; /* x locator item */ - hid_item_t loc_y; /* y locator item */ - hid_item_t loc_z; /* z (wheel) locator item */ - hid_item_t loc_btn[MSE_MAXBUTTONS]; /* buttons locator items */ - unsigned char *buffer; -} UsbMseRec, *UsbMsePtr; - -static int -usbMouseProc(DeviceIntPtr pPointer, int what) -{ - InputInfoPtr pInfo; - MouseDevPtr pMse; - UsbMsePtr pUsbMse; - unsigned char map[MSE_MAXBUTTONS + 1]; - int nbuttons; - - pInfo = pPointer->public.devicePrivate; - pMse = pInfo->private; - pMse->device = pPointer; - pUsbMse = pMse->mousePriv; - - switch (what) { - case DEVICE_INIT: - pPointer->public.on = FALSE; - - for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons) - map[nbuttons + 1] = nbuttons + 1; - - InitPointerDeviceStruct((DevicePtr)pPointer, - map, - min(pMse->buttons, MSE_MAXBUTTONS), - miPointerGetMotionEvents, - pMse->Ctrl, - miPointerGetMotionBufferSize()); - - /* X valuator */ - xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); - xf86InitValuatorDefaults(pPointer, 0); - /* Y valuator */ - xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); - xf86InitValuatorDefaults(pPointer, 1); - xf86MotionHistoryAllocate(pInfo); - break; - - case DEVICE_ON: - pInfo->fd = xf86OpenSerial(pInfo->options); - if (pInfo->fd == -1) - xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); - else { - pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize); - if (!pMse->buffer) { - xfree(pMse); - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - } else { - xf86FlushInput(pInfo->fd); - if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput, - pInfo)) - AddEnabledDevice(pInfo->fd); - } - } - pMse->lastButtons = 0; - pMse->lastMappedButtons = 0; - pMse->emulateState = 0; - pPointer->public.on = TRUE; - break; - - case DEVICE_OFF: - case DEVICE_CLOSE: - if (pInfo->fd != -1) { - RemoveEnabledDevice(pInfo->fd); - if (pUsbMse->packetSize > 8 && pUsbMse->buffer) { - xfree(pUsbMse->buffer); - } - if (pMse->buffer) { - XisbFree(pMse->buffer); - pMse->buffer = NULL; - } - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - } - pPointer->public.on = FALSE; - usleep(300000); - break; - } - return Success; -} - -static void -usbReadInput(InputInfoPtr pInfo) -{ - MouseDevPtr pMse; - UsbMsePtr pUsbMse; - int buttons = pMse->lastButtons; - int dx = 0, dy = 0, dz = 0, dw = 0; - int n, c; - unsigned char *pBuf; - - pMse = pInfo->private; - pUsbMse = pMse->mousePriv; - - XisbBlockDuration(pMse->buffer, -1); - pBuf = pUsbMse->buffer; - n = 0; - while ((c = XisbRead(pMse->buffer)) >= 0 && n < pUsbMse->packetSize) { - pBuf[n++] = (unsigned char)c; - } - if (n == 0) - return; - if (n != pUsbMse->packetSize) { - xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name, - n); - } - /* discard packets with an id that don't match the mouse */ - /* XXX this is probably not the right thing */ - if (pUsbMse->iid != 0) { - if (*pBuf++ != pUsbMse->iid) - return; - } - dx = hid_get_data(pBuf, &pUsbMse->loc_x); - dy = hid_get_data(pBuf, &pUsbMse->loc_y); - dz = hid_get_data(pBuf, &pUsbMse->loc_z); - - buttons = 0; - for (n = 0; n < pMse->buttons; n++) { - if (hid_get_data(pBuf, &pUsbMse->loc_btn[n])) - buttons |= (1 << UMS_BUT(n)); - } - pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); - return; -} - -static void -usbSigioReadInput (int fd, void *closure) -{ - usbReadInput ((InputInfoPtr) closure); -} - -/* This function is called when the protocol is "usb". */ -static Bool -usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - MouseDevPtr pMse = pInfo->private; - UsbMsePtr pUsbMse; - report_desc_t reportDesc; - int i; - - pUsbMse = xalloc(sizeof(UsbMseRec)); - if (pUsbMse == NULL) { - xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name); - xfree(pMse); - return FALSE; - } - - pMse->protocol = protocol; - xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); - - /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); - xf86ProcessCommonOptions(pInfo, pInfo->options); - - /* Check if the device can be opened. */ - pInfo->fd = xf86OpenSerial(pInfo->options); - if (pInfo->fd == -1) { - if (xf86GetAllowMouseOpenFail()) - xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); - else { - xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); - xfree(pUsbMse); - xfree(pMse); - return FALSE; - } - } - /* Get USB informations */ - reportDesc = hid_get_report_desc(pInfo->fd); - /* Get packet size & iid */ -#ifdef USB_NEW_HID - if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) { - xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n", - pInfo->name, strerror(errno)); - return FALSE; - } - pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, - pUsbMse->iid); -#else - pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, - &pUsbMse->iid); -#endif - /* Allocate buffer */ - if (pUsbMse->packetSize <= 8) { - pUsbMse->buffer = pMse->protoBuf; - } else { - pUsbMse->buffer = xalloc(pUsbMse->packetSize); - } - if (pUsbMse->buffer == NULL) { - xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name); - xfree(pUsbMse); - xfree(pMse); - xf86CloseSerial(pInfo->fd); - return FALSE; - } -#ifdef USB_NEW_HID - if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), - hid_input, &pUsbMse->loc_x, pUsbMse->iid) < 0) { - xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name); - } - if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), - hid_input, &pUsbMse->loc_y, pUsbMse->iid) < 0) { - xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name); - } - if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), - hid_input, &pUsbMse->loc_z, pUsbMse->iid) < 0) { - } -#else - if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), - hid_input, &pUsbMse->loc_x) < 0) { - xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name); - } - if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), - hid_input, &pUsbMse->loc_y) < 0) { - xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name); - } - if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), - hid_input, &pUsbMse->loc_z) < 0) { - } -#endif - /* Probe for number of buttons */ - for (i = 1; i <= MSE_MAXBUTTONS; i++) { - if (!hid_locate(reportDesc, HID_USAGE2(HUP_BUTTON, i), - hid_input, &pUsbMse->loc_btn[i-1] -#ifdef USB_NEW_HID - , pUsbMse->iid -#endif - )) - break; - } - pMse->buttons = i-1; - - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - - /* Private structure */ - pMse->mousePriv = pUsbMse; - - /* Process common mouse options (like Emulate3Buttons, etc). */ - pMse->CommonOptions(pInfo); - - /* Setup the local procs. */ - pInfo->device_control = usbMouseProc; - pInfo->read_input = usbReadInput; - - pInfo->flags |= XI86_CONFIGURED; - return TRUE; -} -#endif /* USBMOUSE */ - -static Bool -bsdMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - /* The protocol is guaranteed to be one of the internalNames[] */ -#ifdef WSCONS_SUPPORT - if (xf86NameCmp(protocol, "WSMouse") == 0) { - return wsconsPreInit(pInfo, protocol, flags); - } -#endif -#ifdef USBMOUSE_SUPPORT - if (xf86NameCmp(protocol, "usb") == 0) { - return usbPreInit(pInfo, protocol, flags); - } -#endif - return TRUE; -} - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - p->SupportedInterfaces = SupportedInterfaces; - p->BuiltinNames = BuiltinNames; - p->DefaultProtocol = DefaultProtocol; - p->CheckProtocol = CheckProtocol; -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE) - p->SetupAuto = SetupAuto; - p->SetPS2Res = SetSysMouseRes; - p->SetBMRes = SetSysMouseRes; - p->SetMiscRes = SetSysMouseRes; -#endif -#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) - p->SetupAuto = SetupAuto; - p->SetMiscRes = SetMouseRes; -#endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) - p->FindDevice = FindDevice; -#endif - p->PreInit = bsdMousePreInit; - return p; -} diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c deleted file mode 100644 index e2f6420d8..000000000 --- a/hw/xfree86/os-support/bsd/i386_video.c +++ /dev/null @@ -1,1006 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" - -#include <errno.h> -#include <sys/mman.h> - -#ifdef HAS_MTRR_SUPPORT -#ifndef __NetBSD__ -#include <sys/types.h> -#include <sys/memrange.h> -#else -#include "memrange.h" -#endif -#define X_MTRR_ID "XFree86" -#endif - -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) -#include <machine/mtrr.h> -#include <machine/sysarch.h> -#include <sys/queue.h> -#ifdef __x86_64__ -#define i386_set_mtrr x86_64_set_mtrr -#define i386_get_mtrr x86_64_get_mtrr -#define i386_iopl x86_64_iopl -#endif -#endif - -#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__)) -#include <machine/mtrr.h> -#include <machine/sysarch.h> -#endif - -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#if defined(__NetBSD__) && !defined(MAP_FILE) -#define MAP_FLAGS MAP_SHARED -#else -#define MAP_FLAGS (MAP_FILE | MAP_SHARED) -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - -#ifdef __OpenBSD__ -#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ - "\tin /etc/sysctl.conf and reboot your machine\n" \ - "\trefer to xf86(4) for details" -#define SYSCTL_MSG2 \ - "Check that you have set 'machdep.allowaperture=2'\n" \ - "\tin /etc/sysctl.conf and reboot your machine\n" \ - "\trefer to xf86(4) for details" -#endif - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static Bool useDevMem = FALSE; -static int devMemFd = -1; - -#ifdef HAS_APERTURE_DRV -#define DEV_APERTURE "/dev/xf86" -#endif -#define DEV_MEM "/dev/mem" - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); - -#ifdef HAS_MTRR_SUPPORT -static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); -static void undoWC(int, pointer); -static Bool cleanMTRR(void); -#endif -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) -static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool, - MessageType); -static void NetBSDundoWC(int, pointer); -#endif -#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__) -static pointer amd64setWC(int, unsigned long, unsigned long, Bool, - MessageType); -static void amd64undoWC(int, pointer); -#endif - -/* - * Check if /dev/mem can be mmap'd. If it can't print a warning when - * "warn" is TRUE. - */ -static void -checkDevMem(Bool warn) -{ - static Bool devMemChecked = FALSE; - int fd; - pointer base; - - if (devMemChecked) - return; - devMemChecked = TRUE; - - if ((fd = open(DEV_MEM, O_RDWR)) >= 0) - { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000); - - if (base != MAP_FAILED) - { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - return; - } else { - /* This should not happen */ - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; - } - } -#ifndef HAS_APERTURE_DRV - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - useDevMem = FALSE; - return; -#else - /* Failed to open /dev/mem, try the aperture driver */ - if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) - { - /* Try to map a page at the VGA address */ - base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, - MAP_FLAGS, fd, (off_t)0xA0000); - - if (base != MAP_FAILED) - { - munmap((caddr_t)base, 4096); - devMemFd = fd; - useDevMem = TRUE; - xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", - DEV_APERTURE); - return; - } else { - - if (warn) - { - xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", - DEV_APERTURE, strerror(errno)); - } - } - } else { - if (warn) - { -#ifndef __OpenBSD__ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno)); -#else /* __OpenBSD__ */ - xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" - "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno), - SYSCTL_MSG); -#endif /* __OpenBSD__ */ - } - } - - useDevMem = FALSE; - return; - -#endif -} - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - checkDevMem(TRUE); - pVidMem->linearSupported = useDevMem; - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - -#if HAVE_PCI_SYSTEM_INIT_DEV_MEM - if (useDevMem) - pci_system_init_dev_mem(devMemFd); -#endif - -#ifdef HAS_MTRR_SUPPORT - if (useDevMem) { - if (cleanMTRR()) { - pVidMem->setWC = setWC; - pVidMem->undoWC = undoWC; - } - } -#endif -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) - pVidMem->setWC = NetBSDsetWC; - pVidMem->undoWC = NetBSDundoWC; -#endif -#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__) - pVidMem->setWC = amd64setWC; - pVidMem->undoWC = amd64undoWC; -#endif - pVidMem->initialised = TRUE; -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - - checkDevMem(FALSE); - - if (useDevMem) - { - if (devMemFd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, devMemFd, (off_t)Base); - if (base == MAP_FAILED) - { - FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)", - "xf86MapVidMem", DEV_MEM, Size, Base, - strerror(errno)); - } - return(base); - } - - /* else, mmap /dev/vga */ - if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) - { - FatalError("%s: Address 0x%lx outside allowable range", - "xf86MapVidMem", Base); - } - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_FLAGS, xf86Info.screenFd, - (unsigned long)Base - 0xA0000 - ); - if (base == MAP_FAILED) - { - FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)", - strerror(errno)); - } - return(base); -} - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap((caddr_t)Base, Size); -} - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - unsigned char *ptr; - int psize; - int mlen; - - checkDevMem(TRUE); - if (devMemFd == -1) { - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, devMemFd, (off_t)Base); - if ((long)ptr == -1) - { - xf86Msg(X_WARNING, - "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", - DEV_MEM, Len, Base, Offset, strerror(errno)); -#ifdef __OpenBSD__ - if (Base < 0xa0000) { - xf86Msg(X_WARNING, SYSCTL_MSG2); - } -#endif - return(-1); - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" - "-> %02x %02x %02x %02x...\n", - Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); -#endif - return(Len); -} - -#ifdef USE_I386_IOPL -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -static Bool ExtendedEnabled = FALSE; - -_X_EXPORT Bool -xf86EnableIO() -{ - if (ExtendedEnabled) - return TRUE; - - if (i386_iopl(TRUE) < 0) - { -#ifndef __OpenBSD__ - xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O", - "xf86EnableIO"); -#else - xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s", - "xf86EnableIO", SYSCTL_MSG); -#endif - return FALSE; - } - ExtendedEnabled = TRUE; - - return TRUE; -} - -_X_EXPORT void -xf86DisableIO() -{ - if (!ExtendedEnabled) - return; - - i386_iopl(FALSE); - ExtendedEnabled = FALSE; - - return; -} - -#endif /* USE_I386_IOPL */ - -#ifdef USE_AMD64_IOPL -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -static Bool ExtendedEnabled = FALSE; - -Bool -xf86EnableIO() -{ - if (ExtendedEnabled) - return TRUE; - - if (amd64_iopl(TRUE) < 0) - { -#ifndef __OpenBSD__ - xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O", - "xf86EnableIO"); -#else - xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s", - "xf86EnableIO", SYSCTL_MSG); -#endif - return FALSE; - } - ExtendedEnabled = TRUE; - - return TRUE; -} - -void -xf86DisableIO() -{ - if (!ExtendedEnabled) - return; - - if (amd64_iopl(FALSE) == 0) { - ExtendedEnabled = FALSE; - } - /* Otherwise, the X server has revoqued its root uid, - and thus cannot give up IO privileges any more */ - - return; -} - -#endif /* USE_AMD64_IOPL */ - -#ifdef USE_DEV_IO -static int IoFd = -1; - -Bool -xf86EnableIO() -{ - if (IoFd >= 0) - return TRUE; - - if ((IoFd = open("/dev/io", O_RDWR)) == -1) - { - xf86Msg(X_WARNING,"xf86EnableIO: " - "Failed to open /dev/io for extended I/O"); - return FALSE; - } - return TRUE; -} - -void -xf86DisableIO() -{ - if (IoFd < 0) - return; - - close(IoFd); - IoFd = -1; - return; -} - -#endif - - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - asm("cli"); -#endif /* __GNUC__ */ - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - asm("sti"); -#endif /* __GNUC__ */ - - return; -} - - -#ifdef __NetBSD__ -/***************************************************************************/ -/* Set TV output mode */ -/***************************************************************************/ -void -xf86SetTVOut(int mode) -{ - switch (xf86Info.consType) - { -#ifdef PCCONS_SUPPORT - case PCCONS:{ - - if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_ON, &mode) < 0) - { - xf86Msg(X_WARNING, - "xf86SetTVOut: Could not set console to TV output, %s\n", - strerror(errno)); - } - } - break; -#endif /* PCCONS_SUPPORT */ - - default: - FatalError("Xf86SetTVOut: Unsupported console"); - break; - } - return; -} - -void -xf86SetRGBOut() -{ - switch (xf86Info.consType) - { -#ifdef PCCONS_SUPPORT - case PCCONS:{ - - if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_OFF, 0) < 0) - { - xf86Msg(X_WARNING, - "xf86SetTVOut: Could not set console to RGB output, %s\n", - strerror(errno)); - } - } - break; -#endif /* PCCONS_SUPPORT */ - - default: - FatalError("Xf86SetTVOut: Unsupported console"); - break; - } - return; -} -#endif - -#ifdef HAS_MTRR_SUPPORT -/* memory range (MTRR) support for FreeBSD */ - -/* - * This code is experimental. Some parts may be overkill, and other parts - * may be incomplete. - */ - -/* - * getAllRanges returns the full list of memory ranges with attributes set. - */ - -static struct mem_range_desc * -getAllRanges(int *nmr) -{ - struct mem_range_desc *mrd; - struct mem_range_op mro; - - /* - * Find how many ranges there are. If this fails, then the kernel - * probably doesn't have MTRR support. - */ - mro.mo_arg[0] = 0; - if (ioctl(devMemFd, MEMRANGE_GET, &mro)) - return NULL; - *nmr = mro.mo_arg[0]; - mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); - mro.mo_arg[0] = *nmr; - mro.mo_desc = mrd; - if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { - xfree(mrd); - return NULL; - } - return mrd; -} - -/* - * cleanMTRR removes any memory attribute that may be left by a previous - * X server. Normally there won't be any, but this takes care of the - * case where a server crashed without being able finish cleaning up. - */ - -static Bool -cleanMTRR() -{ - struct mem_range_desc *mrd; - struct mem_range_op mro; - int nmr, i; - - /* This shouldn't happen */ - if (devMemFd < 0) - return FALSE; - - if (!(mrd = getAllRanges(&nmr))) - return FALSE; - - for (i = 0; i < nmr; i++) { - if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 && - (mrd[i].mr_flags & MDF_ACTIVE)) { -#ifdef DEBUG - ErrorF("Clean for (0x%lx,0x%lx)\n", - (unsigned long)mrd[i].mr_base, - (unsigned long)mrd[i].mr_len); -#endif - if (mrd[i].mr_flags & MDF_FIXACTIVE) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - mrd[i].mr_flags = MDF_UNCACHEABLE; - } else { - mro.mo_arg[0] = MEMRANGE_SET_REMOVE; - } - mro.mo_desc = mrd + i; - ioctl(devMemFd, MEMRANGE_SET, &mro); - } - } -#ifdef DEBUG - sleep(10); -#endif - xfree(mrd); - return TRUE; -} - -typedef struct x_RangeRec { - struct mem_range_desc mrd; - Bool wasWC; - struct x_RangeRec * next; -} RangeRec, *RangePtr; - -static void -freeRangeList(RangePtr range) -{ - RangePtr rp; - - while (range) { - rp = range; - range = rp->next; - xfree(rp); - } -} - -static RangePtr -dupRangeList(RangePtr list) -{ - RangePtr new = NULL, rp, p; - - rp = list; - while (rp) { - p = xnfalloc(sizeof(RangeRec)); - *p = *rp; - p->next = new; - new = p; - rp = rp->next; - } - return new; -} - -static RangePtr -sortRangeList(RangePtr list) -{ - RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev; - unsigned long minBase; - - /* Sort by base address */ - rp1 = copy = dupRangeList(list); - while (rp1) { - minBase = rp1->mrd.mr_base; - minp = rp1; - minprev = NULL; - prev = rp1; - rp2 = rp1->next; - while (rp2) { - if (rp2->mrd.mr_base < minBase) { - minBase = rp2->mrd.mr_base; - minp = rp2; - minprev = prev; - } - prev = rp2; - rp2 = rp2->next; - } - if (minprev) { - minprev->next = minp->next; - rp1 = copy; - } else { - rp1 = minp->next; - } - minp->next = sorted; - sorted = minp; - } - return sorted; -} - -/* - * findRanges returns a list of ranges that overlap the specified range. - */ - -static void -findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp) -{ - struct mem_range_desc *mrd; - int nmr, i; - RangePtr rp, *p; - - if (!(mrd = getAllRanges(&nmr))) - return; - - for (i = 0; i < nmr; i++) { - if ((mrd[i].mr_flags & MDF_ACTIVE) && - mrd[i].mr_base < base + size && - mrd[i].mr_base + mrd[i].mr_len > base) { - if (mrd[i].mr_flags & MDF_WRITECOMBINE) - p = wcp; - else if (mrd[i].mr_flags & MDF_UNCACHEABLE) - p = ucp; - else - continue; - rp = xnfalloc(sizeof(RangeRec)); - rp->mrd = mrd[i]; - rp->next = *p; - *p = rp; - } - } - xfree(mrd); -} - -/* - * This checks if the existing overlapping ranges fully cover the requested - * range. Is this overkill? - */ - -static Bool -fullCoverage(unsigned long base, unsigned long size, RangePtr overlap) -{ - RangePtr rp1, sorted = NULL; - unsigned long end; - - sorted = sortRangeList(overlap); - /* Look for gaps */ - rp1 = sorted; - end = base + size; - while (rp1) { - if (rp1->mrd.mr_base > base) { - freeRangeList(sorted); - return FALSE; - } else { - base = rp1->mrd.mr_base + rp1->mrd.mr_len; - } - if (base >= end) { - freeRangeList(sorted); - return TRUE; - } - rp1 = rp1->next; - } - freeRangeList(sorted); - return FALSE; -} - -static pointer -addWC(int screenNum, unsigned long base, unsigned long size, MessageType from) -{ - RangePtr uc = NULL, wc = NULL, retlist = NULL; - struct mem_range_desc mrd; - struct mem_range_op mro; - - findRanges(base, size, &uc, &wc); - - /* See of the full range is already WC */ - if (!uc && fullCoverage(base, size, wc)) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx) was already set\n", - base, size); - return NULL; - } - - /* Otherwise, try to add the new range */ - mrd.mr_base = base; - mrd.mr_len = size; - strcpy(mrd.mr_owner, X_MTRR_ID); - mrd.mr_flags = MDF_WRITECOMBINE; - mro.mo_desc = &mrd; - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to set write-combining range " - "(0x%lx,0x%lx)\n", base, size); - return NULL; - } else { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx)\n", base, size); - retlist = xnfalloc(sizeof(RangeRec)); - retlist->mrd = mrd; - retlist->wasWC = FALSE; - retlist->next = NULL; - return retlist; - } -} - -static pointer -delWC(int screenNum, unsigned long base, unsigned long size, MessageType from) -{ - RangePtr uc = NULL, wc = NULL, retlist = NULL; - struct mem_range_desc mrd; - struct mem_range_op mro; - - findRanges(base, size, &uc, &wc); - - /* - * See of the full range is already not WC, or if there is full - * coverage from UC ranges. - */ - if (!wc || fullCoverage(base, size, uc)) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx) was already clear\n", - base, size); - return NULL; - } - - /* Otherwise, try to add the new range */ - mrd.mr_base = base; - mrd.mr_len = size; - strcpy(mrd.mr_owner, X_MTRR_ID); - mrd.mr_flags = MDF_UNCACHEABLE; - mro.mo_desc = &mrd; - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to remove write-combining range " - "(0x%lx,0x%lx)\n", base, size); - /* XXX Should then remove all of the overlapping WC ranges */ - return NULL; - } else { - xf86DrvMsg(screenNum, from, - "Removed Write-combining range (0x%lx,0x%lx)\n", - base, size); - retlist = xnfalloc(sizeof(RangeRec)); - retlist->mrd = mrd; - retlist->wasWC = TRUE; - retlist->next = NULL; - return retlist; - } -} - -static pointer -setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - if (enable) - return addWC(screenNum, base, size, from); - else - return delWC(screenNum, base, size, from); -} - -static void -undoWC(int screenNum, pointer list) -{ - RangePtr rp; - struct mem_range_op mro; - Bool failed; - - rp = list; - while (rp) { -#ifdef DEBUG - ErrorF("Undo for (0x%lx,0x%lx), %d\n", - (unsigned long)rp->mrd.mr_base, - (unsigned long)rp->mrd.mr_len, rp->wasWC); -#endif - failed = FALSE; - if (rp->wasWC) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - rp->mrd.mr_flags = MDF_WRITECOMBINE; - strcpy(rp->mrd.mr_owner, "unknown"); - } else { - mro.mo_arg[0] = MEMRANGE_SET_REMOVE; - } - mro.mo_desc = &rp->mrd; - - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - if (!rp->wasWC) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - rp->mrd.mr_flags = MDF_UNCACHEABLE; - strcpy(rp->mrd.mr_owner, "unknown"); - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) - failed = TRUE; - } else - failed = TRUE; - } - if (failed) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to restore MTRR range (0x%lx,0x%lx)\n", - (unsigned long)rp->mrd.mr_base, - (unsigned long)rp->mrd.mr_len); - } - rp = rp->next; - } -} - -#endif /* HAS_MTRR_SUPPORT */ - - -#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) -static pointer -NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - struct mtrr *mtrrp; - int n; - - xf86DrvMsg(screenNum, X_WARNING, - "%s MTRR %lx - %lx\n", enable ? "set" : "remove", - base, (base + size)); - - mtrrp = xnfalloc(sizeof (struct mtrr)); - mtrrp->base = base; - mtrrp->len = size; - mtrrp->type = MTRR_TYPE_WC; - - /* - * MTRR_PRIVATE will make this MTRR get reset automatically - * if this process exits, so we have no need for an explicit - * cleanup operation when starting a new server. - */ - - if (enable) - mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; - else - mtrrp->flags = 0; - n = 1; - - if (i386_set_mtrr(mtrrp, &n) < 0) { - xfree(mtrrp); - return NULL; - } - return mtrrp; -} - -static void -NetBSDundoWC(int screenNum, pointer list) -{ - struct mtrr *mtrrp = (struct mtrr *)list; - int n; - - if (mtrrp == NULL) - return; - n = 1; - mtrrp->flags &= ~MTRR_VALID; - i386_set_mtrr(mtrrp, &n); - xfree(mtrrp); -} -#endif - -#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__)) -static pointer -amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - struct mtrr *mtrrp; - int n; - - xf86DrvMsg(screenNum, X_WARNING, - "%s MTRR %lx - %lx\n", enable ? "set" : "remove", - base, (base + size)); - - mtrrp = xnfalloc(sizeof (struct mtrr)); - mtrrp->base = base; - mtrrp->len = size; - mtrrp->type = MTRR_TYPE_WC; - - /* - * MTRR_PRIVATE will make this MTRR get reset automatically - * if this process exits, so we have no need for an explicit - * cleanup operation when starting a new server. - */ - - if (enable) - mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; - else - mtrrp->flags = 0; - n = 1; - - if (amd64_set_mtrr(mtrrp, &n) < 0) { - xfree(mtrrp); - return NULL; - } - return mtrrp; -} - -static void -amd64undoWC(int screenNum, pointer list) -{ - struct mtrr *mtrrp = (struct mtrr *)list; - int n; - - if (mtrrp == NULL) - return; - n = 1; - mtrrp->flags &= ~MTRR_VALID; - amd64_set_mtrr(mtrrp, &n); - xfree(mtrrp); -} -#endif /* OpenBSD/amd64 */ - diff --git a/hw/xfree86/os-support/bsd/libusb/data.c b/hw/xfree86/os-support/bsd/libusb/data.c deleted file mode 100644 index 292e5d885..000000000 --- a/hw/xfree86/os-support/bsd/libusb/data.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <assert.h> -#include <stdlib.h> -#include "usb.h" - -int -hid_get_data(void *p, hid_item_t *h) -{ - unsigned char *buf; - unsigned int hpos; - unsigned int hsize; - int data; - int i, end, offs; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(h != NULL); - - buf = p; - hpos = h->pos; /* bit position of data */ - hsize = h->report_size; /* bit length of data */ - - if (hsize == 0) - return (0); - offs = hpos / 8; - end = (hpos + hsize) / 8 - offs; - data = 0; - for (i = 0; i <= end; i++) - data |= buf[offs + i] << (i*8); - data >>= hpos % 8; - data &= (1 << hsize) - 1; - if (h->logical_minimum < 0) { - /* Need to sign extend */ - hsize = sizeof data * 8 - hsize; - data = (data << hsize) >> hsize; - } - return (data); -} - -void -hid_set_data(void *p, hid_item_t *h, int data) -{ - unsigned char *buf; - unsigned int hpos; - unsigned int hsize; - int i, end, offs; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(h != NULL); - - buf = p; - hpos = h->pos; /* bit position of data */ - hsize = h->report_size; /* bit length of data */ - - if (hsize != 32) - data &= (1 << hsize) - 1; - data <<= (hpos % 8); - - offs = hpos / 8; - end = (hpos + hsize) / 8 - offs; - data = 0; - for (i = 0; i <= end; i++) - buf[offs + i] |= (data >> (i*8)) & 0xff; -} diff --git a/hw/xfree86/os-support/bsd/libusb/descr.c b/hw/xfree86/os-support/bsd/libusb/descr.c deleted file mode 100644 index 4dc3524d5..000000000 --- a/hw/xfree86/os-support/bsd/libusb/descr.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/types.h> - -#include <assert.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/time.h> - -#include <dev/usb/usb.h> - -#include "usb.h" -#include "usbvar.h" - -report_desc_t -hid_get_report_desc(fd) - int fd; -{ - struct usb_ctl_report_desc rep; - report_desc_t r; - - _DIAGASSERT(fd != -1); - - rep.size = 0; - if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) - return (0); - r = malloc(sizeof *r + rep.size); - if (r == 0) { - errno = ENOMEM; - return (0); - } - r->size = rep.size; - memcpy(r->data, rep.data, (unsigned int)rep.size); - return (r); -} - -void -hid_dispose_report_desc(r) - report_desc_t r; -{ - - free(r); -} diff --git a/hw/xfree86/os-support/bsd/libusb/parse.c b/hw/xfree86/os-support/bsd/libusb/parse.c deleted file mode 100644 index 0a846e42b..000000000 --- a/hw/xfree86/os-support/bsd/libusb/parse.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#include <sys/time.h> - -#include <dev/usb/usb.h> -#include <dev/usb/usbhid.h> - -#include "usb.h" -#include "usbvar.h" - -#define MAXUSAGE 100 -struct hid_data { - u_char *start; - u_char *end; - u_char *p; - hid_item_t cur; - unsigned int usages[MAXUSAGE]; - int nusage; - int minset; - int multi; - int multimax; - int kindset; -}; - -static int min(int x, int y) { return x < y ? x : y; } - -static void -hid_clear_local(hid_item_t *c) -{ - - _DIAGASSERT(c != NULL); - - c->usage = 0; - c->usage_minimum = 0; - c->usage_maximum = 0; - c->designator_index = 0; - c->designator_minimum = 0; - c->designator_maximum = 0; - c->string_index = 0; - c->string_minimum = 0; - c->string_maximum = 0; - c->set_delimiter = 0; -} - -hid_data_t -hid_start_parse(report_desc_t d, int kindset) -{ - struct hid_data *s; - - _DIAGASSERT(d != NULL); - - s = malloc(sizeof *s); - memset(s, 0, sizeof *s); - s->start = s->p = d->data; - s->end = d->data + d->size; - s->kindset = kindset; - return (s); -} - -void -hid_end_parse(hid_data_t s) -{ - - _DIAGASSERT(s != NULL); - - while (s->cur.next) { - hid_item_t *hi = s->cur.next->next; - free(s->cur.next); - s->cur.next = hi; - } - free(s); -} - -int -hid_get_item(hid_data_t s, hid_item_t *h) -{ - hid_item_t *c; - unsigned int bTag = 0, bType = 0, bSize; - unsigned char *data; - int dval; - unsigned char *p; - hid_item_t *hi; - int i; - - _DIAGASSERT(s != NULL); - _DIAGASSERT(h != NULL); - - c = &s->cur; - - top: - if (s->multimax) { - if (s->multi < s->multimax) { - c->usage = s->usages[min(s->multi, s->nusage-1)]; - s->multi++; - *h = *c; - c->pos += c->report_size; - h->next = 0; - return (1); - } else { - c->report_count = s->multimax; - s->multimax = 0; - s->nusage = 0; - hid_clear_local(c); - } - } - for (;;) { - p = s->p; - if (p >= s->end) - return (0); - - bSize = *p++; - if (bSize == 0xfe) { - /* long item */ - bSize = *p++; - bSize |= *p++ << 8; - bTag = *p++; - data = p; - p += bSize; - } else { - /* short item */ - bTag = bSize >> 4; - bType = (bSize >> 2) & 3; - bSize &= 3; - if (bSize == 3) bSize = 4; - data = p; - p += bSize; - } - s->p = p; - /* - * The spec is unclear if the data is signed or unsigned. - */ - switch(bSize) { - case 0: - dval = 0; - break; - case 1: - dval = (int8_t)*data++; - break; - case 2: - dval = *data++; - dval |= *data++ << 8; - dval = (int16_t)dval; - break; - case 4: - dval = *data++; - dval |= *data++ << 8; - dval |= *data++ << 16; - dval |= *data++ << 24; - break; - default: - return (-1); - } - - switch (bType) { - case 0: /* Main */ - switch (bTag) { - case 8: /* Input */ - if (!(s->kindset & (1 << hid_input))) - continue; - c->kind = hid_input; - c->flags = dval; - ret: - if (c->flags & HIO_VARIABLE) { - s->multimax = c->report_count; - s->multi = 0; - c->report_count = 1; - if (s->minset) { - for (i = c->usage_minimum; - i <= c->usage_maximum; - i++) { - s->usages[s->nusage] = i; - if (s->nusage < MAXUSAGE-1) - s->nusage++; - } - s->minset = 0; - } - goto top; - } else { - if (s->minset) - c->usage = c->usage_minimum; - *h = *c; - h->next = 0; - c->pos += c->report_size * c->report_count; - hid_clear_local(c); - s->minset = 0; - return (1); - } - case 9: /* Output */ - if (!(s->kindset & (1 << hid_output))) - continue; - c->kind = hid_output; - c->flags = dval; - goto ret; - case 10: /* Collection */ - c->kind = hid_collection; - c->collection = dval; - c->collevel++; - *h = *c; - hid_clear_local(c); - s->nusage = 0; - return (1); - case 11: /* Feature */ - if (!(s->kindset & (1 << hid_feature))) - continue; - c->kind = hid_feature; - c->flags = dval; - goto ret; - case 12: /* End collection */ - c->kind = hid_endcollection; - c->collevel--; - *h = *c; - hid_clear_local(c); - s->nusage = 0; - return (1); - default: - return (-2); - } - - case 1: /* Global */ - switch (bTag) { - case 0: - c->_usage_page = dval << 16; - break; - case 1: - c->logical_minimum = dval; - break; - case 2: - c->logical_maximum = dval; - break; - case 3: - c->physical_maximum = dval; - break; - case 4: - c->physical_maximum = dval; - break; - case 5: - c->unit_exponent = dval; - break; - case 6: - c->unit = dval; - break; - case 7: - c->report_size = dval; - break; - case 8: - c->report_ID = dval; - break; - case 9: - c->report_count = dval; - break; - case 10: /* Push */ - hi = malloc(sizeof *hi); - *hi = s->cur; - c->next = hi; - break; - case 11: /* Pop */ - hi = c->next; - s->cur = *hi; - free(hi); - break; - default: - return (-3); - } - break; - case 2: /* Local */ - switch (bTag) { - case 0: - if (bSize == 1) - dval = c->_usage_page | (dval&0xff); - else if (bSize == 2) - dval = c->_usage_page | (dval&0xffff); - c->usage = dval; - if (s->nusage < MAXUSAGE) - s->usages[s->nusage++] = dval; - /* else XXX */ - break; - case 1: - s->minset = 1; - if (bSize == 1) - dval = c->_usage_page | (dval&0xff); - else if (bSize == 2) - dval = c->_usage_page | (dval&0xffff); - c->usage_minimum = dval; - break; - case 2: - if (bSize == 1) - dval = c->_usage_page | (dval&0xff); - else if (bSize == 2) - dval = c->_usage_page | (dval&0xffff); - c->usage_maximum = dval; - break; - case 3: - c->designator_index = dval; - break; - case 4: - c->designator_minimum = dval; - break; - case 5: - c->designator_maximum = dval; - break; - case 7: - c->string_index = dval; - break; - case 8: - c->string_minimum = dval; - break; - case 9: - c->string_maximum = dval; - break; - case 10: - c->set_delimiter = dval; - break; - default: - return (-4); - } - break; - default: - return (-5); - } - } -} - -int -hid_report_size(report_desc_t r, enum hid_kind k, int *idp) -{ - struct hid_data *d; - hid_item_t h; - int size, id; - - _DIAGASSERT(r != NULL); - /* idp may be NULL */ - - id = 0; - if (idp) - *idp = 0; - memset(&h, 0, sizeof h); - for (d = hid_start_parse(r, 1<<k); hid_get_item(d, &h); ) { - if (h.report_ID != 0) { - if (idp) - *idp = h.report_ID; - id = 8; - } - } - hid_end_parse(d); - size = h.pos + id; - return ((size + 7) / 8); -} - -int -hid_locate(desc, u, k, h) - report_desc_t desc; - unsigned int u; - enum hid_kind k; - hid_item_t *h; -{ - hid_data_t d; - - _DIAGASSERT(desc != NULL); - _DIAGASSERT(h != NULL); - - for (d = hid_start_parse(desc, 1<<k); hid_get_item(d, h); ) { - if (h->kind == k && !(h->flags & HIO_CONST) && h->usage == u) { - hid_end_parse(d); - return (1); - } - } - hid_end_parse(d); - h->report_size = 0; - return (0); -} diff --git a/hw/xfree86/os-support/bsd/libusb/usage.c b/hw/xfree86/os-support/bsd/libusb/usage.c deleted file mode 100644 index 9b491c57a..000000000 --- a/hw/xfree86/os-support/bsd/libusb/usage.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <ctype.h> -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "usb.h" - -#define _PATH_HIDTABLE "/usr/share/misc/usb_hid_usages" - -struct usage_in_page { - char *name; - int usage; -}; - -static struct usage_page { - char *name; - int usage; - struct usage_in_page *page_contents; - int pagesize, pagesizemax; -} *pages; -static int npages, npagesmax; - -#ifdef DEBUG -void -dump_hid_table(void) -{ - int i, j; - - for (i = 0; i < npages; i++) { - printf("%d\t%s\n", pages[i].usage, pages[i].name); - for (j = 0; j < pages[i].pagesize; j++) { - printf("\t%d\t%s\n", pages[i].page_contents[j].usage, - pages[i].page_contents[j].name); - } - } -} -#endif - -void -hid_init(char *hidname) -{ - FILE *f; - char line[100], name[100], *p, *n; - int no; - int lineno; - struct usage_page *curpage = 0; - - if (hidname == 0) - hidname = _PATH_HIDTABLE; - - f = fopen(hidname, "r"); - if (f == NULL) - err(1, "%s", hidname); - for (lineno = 1; ; lineno++) { - if (fgets(line, sizeof line, f) == NULL) - break; - if (line[0] == '#') - continue; - for (p = line; *p && isspace(*p); p++) - ; - if (!*p) - continue; - if (sscanf(line, " * %[^\n]", name) == 1) - no = -1; - else if (sscanf(line, " 0x%x %[^\n]", &no, name) != 2 && - sscanf(line, " %d %[^\n]", &no, name) != 2) - errx(1, "file %s, line %d, syntax error\n", - hidname, lineno); - for (p = name; *p; p++) - if (isspace(*p) || *p == '.') - *p = '_'; - n = strdup(name); - if (!n) - err(1, "strdup"); - if (isspace(line[0])) { - if (!curpage) - errx(1, "file %s, line %d, syntax error\n", - hidname, lineno); - if (curpage->pagesize >= curpage->pagesizemax) { - curpage->pagesizemax += 10; - curpage->page_contents = - realloc(curpage->page_contents, - curpage->pagesizemax * - sizeof (struct usage_in_page)); - if (!curpage->page_contents) - err(1, "realloc"); - } - curpage->page_contents[curpage->pagesize].name = n; - curpage->page_contents[curpage->pagesize].usage = no; - curpage->pagesize++; - } else { - if (npages >= npagesmax) { - if (pages == 0) { - npagesmax = 5; - pages = malloc(npagesmax * - sizeof (struct usage_page)); - } else { - npagesmax += 5; - pages = realloc(pages, - npagesmax * - sizeof (struct usage_page)); - } - if (!pages) - err(1, "alloc"); - } - curpage = &pages[npages++]; - curpage->name = n; - curpage->usage = no; - curpage->pagesize = 0; - curpage->pagesizemax = 10; - curpage->page_contents = - malloc(curpage->pagesizemax * - sizeof (struct usage_in_page)); - if (!curpage->page_contents) - err(1, "malloc"); - } - } - fclose(f); -#ifdef DEBUG - dump_hid_table(); -#endif -} - -char * -hid_usage_page(int i) -{ - static char b[10]; - int k; - - if (!pages) - errx(1, "no hid table\n"); - - for (k = 0; k < npages; k++) - if (pages[k].usage == i) - return pages[k].name; - sprintf(b, "0x%02x", i); - return b; -} - -char * -hid_usage_in_page(unsigned int u) -{ - int page = HID_PAGE(u); - int i = HID_USAGE(u); - static char b[100]; - int j, k, us; - - for (k = 0; k < npages; k++) - if (pages[k].usage == page) - break; - if (k >= npages) - goto bad; - for (j = 0; j < pages[k].pagesize; j++) { - us = pages[k].page_contents[j].usage; - if (us == -1) { - sprintf(b, pages[k].page_contents[j].name, i); - return b; - } - if (us == i) - return pages[k].page_contents[j].name; - } - bad: - sprintf(b, "0x%02x", i); - return b; -} diff --git a/hw/xfree86/os-support/bsd/libusb/usb.3 b/hw/xfree86/os-support/bsd/libusb/usb.3 deleted file mode 100644 index f88a28cd6..000000000 --- a/hw/xfree86/os-support/bsd/libusb/usb.3 +++ /dev/null @@ -1,191 +0,0 @@ -.\" $NetBSD: usb.3,v 1.9 1999/11/08 22:33:40 augustss Exp $ -.\" -.\" Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3,v 1.1 2000/02/11 18:06:50 dawes Exp $ -.\" -.Dd May 11, 1999 -.Dt USB 3 -.Os -.Sh NAME -.Nm usb , -.Nm hid_get_report_desc , -.Nm hid_dispose_report_desc , -.Nm hid_start_parse , -.Nm hid_end_parse , -.Nm hid_get_item , -.Nm hid_report_size , -.Nm hid_locate , -.Nm hid_usage_page , -.Nm hid_usage_in_page , -.Nm hid_init , -.Nm hid_get_data , -.Nm hid_set_data -.Nd USB HID access routines -.Sh LIBRARY -.Lb libusb -.Sh SYNOPSIS -.Fd #include <usb.h> -.Ft report_desc_t -.Fn hid_get_report_desc "int file" -.Ft void -.Fn hid_dispose_report_desc "report_desc_t d" -.Ft hid_data_t -.Fn hid_start_parse "report_desc_t d" "int kindset" -.Ft void -.Fn hid_end_parse "hid_data_t s" -.Ft int -.Fn hid_get_item "hid_data_t s" "hid_item_t *h" -.Ft int -.Fn hid_report_size "report_desc_t d" "hid_kind_t k" "int *idp" -.Ft int -.Fn hid_locate "report_desc_t d" "u_int usage" "hid_kind_t k" "hid_item_t *h" -.Ft char * -.Fn hid_usage_page "int i" -.Ft char * -.Fn hid_usage_in_page "u_int u" -.Ft void -.Fn hid_init "char *file" -.Ft int -.Fn hid_get_data "void *data" "hid_item_t *h" -.Ft void -.Fn hid_set_data "void *data" "hid_item_t *h" "u_int data" -.Sh DESCRIPTION -The -.Nm -library provides routines to extract data from USB Human Interface Devices. -.Ss INTRODUCTION -USB HID devices send and receive data layed out a device dependent -way. The -.Nm -library contains routines to extract the -.Em report descriptor -which contains the data layout information and then use this information. -.Pp -The routines can be divided into four parts: extraction of the descriptor, -parsing of the descriptor, translating to/from symbolic names, and -data manipulation. -.Ss DESCRIPTOR FUNCTIONS -A report descriptor can be obtained by calling -.Fn hid_get_report_desc -with a file descriptor obtained by opening a -.Xr uhid 4 -device. -When the report descriptor is no longer needed it should be freed -by calling -.Fn hid_dispose_report_desc . -The type -.Fa report_desc_t -is opaque and should be used when calling the parsing functions. -.Ss DESCRIPTOR PARSING FUNCTIONS -To parse the report descriptor the -.Fn hid_start_parse -function should be called with a report descriptor and a set that -describes which items that are interesting. The set is obtained -by oring together values -.Fa "(1 << k)" -where -.Fa k -is an item of type -.Fa hid_kind_t . -The function returns -.Fa NULL -if the initialization fails, otherwise an opaque value to be used -in subsequent calls. -After parsing the -.Fn hid_end_parse -function should be called to free internal data structures. -.Pp -To iterate through all the items in the report descriptor -.Fn hid_get_item -should be called while it returns a value greater than 0. -When the report descriptor ends it will returns 0; a syntax -error within the report descriptor will cause a return value less -than 0. -The struct pointed to by -.Fa h -will be filled with the relevant data for the item. -The definition of -.Fa hid_item_t -can be found in -.Pa <usb.h> -and the meaning of the components in the USB HID documentation. -.Pp -Data should be read/written to the device in the size of -the report. The size of a report (of a certain kind) can be -computed by the -.Fn hid_report_size -function. If the report is prefixed by an ID byte it is -stored at -.Fa idp , -otherwise it will contain 0. -.Pp -To locate a single item the -.Fn hid_locate -function can be used. It should be given the usage code of -the item and its kind and it will fill the item and return -non-zero if the item was found. -.Pp -.Ss NAME TRANSLATION FUNCTIONS -The function -.Fn hid_usage_page -will return the symbolic name of a usage page, and the function -.Fn hid_usage_in_page -will return the symbolic name of the usage within the page. -Both these functions may return a pointer to static data. -Before either of these functions can be called the usage table -must be parsed, this is done by calling -.Fn hid_init -with the name of the table. Passing -.Fa NULL -to this function will cause it to use the default table. -.Ss DATA EXTRACTION FUNCTIONS -Given the data obtained from a HID device and an item in the -report descriptor the -.Fn hid_get_data -function extracts the value of the item. -Conversely -.Fn hid_set_data -can be used to put data into a report (which must be zeroed first). -.Sh EXAMPLE -Not yet. -.Sh FILES -.Pa /usr/share/misc/usb_hid_usages -The default HID usage table. -.Sh BUGS -This man page is woefully incomplete. -.Sh SEE ALSO -The -.Tn USB -specifications can be found at -.Dv http://www.usb.org/developers/docs.htm . -.Pp -.Xr hid 4 , -.Xr usb 4 . -.Sh HISTORY -The -.Nm -library first appeared in -.Nx 1.5 . diff --git a/hw/xfree86/os-support/bsd/libusb/usb.h b/hw/xfree86/os-support/bsd/libusb/usb.h deleted file mode 100644 index c39dc063a..000000000 --- a/hw/xfree86/os-support/bsd/libusb/usb.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define _DIAGASSERT(e) assert(e) - -typedef struct report_desc *report_desc_t; - -typedef struct hid_data *hid_data_t; - -typedef enum hid_kind { - hid_input, hid_output, hid_feature, hid_collection, hid_endcollection -}hid_kind_t; - -typedef struct hid_item { - /* Global */ - int _usage_page; - int logical_minimum; - int logical_maximum; - int physical_minimum; - int physical_maximum; - int unit_exponent; - int unit; - int report_size; - int report_ID; - int report_count; - /* Local */ - unsigned int usage; - int usage_minimum; - int usage_maximum; - int designator_index; - int designator_minimum; - int designator_maximum; - int string_index; - int string_minimum; - int string_maximum; - int set_delimiter; - /* Misc */ - int collection; - int collevel; - enum hid_kind kind; - unsigned int flags; - /* Absolute data position (bits) */ - unsigned int pos; - /* */ - struct hid_item *next; -} hid_item_t; - -#define HID_PAGE(u) ((u) >> 16) -#define HID_USAGE(u) ((u) & 0xffff) - -/* Obtaining a report descriptor, descr.c: */ -report_desc_t hid_get_report_desc __P((int file)); -void hid_dispose_report_desc __P((report_desc_t)); - -/* Parsing of a HID report descriptor, parse.c: */ -hid_data_t hid_start_parse __P((report_desc_t d, int kindset)); -void hid_end_parse __P((hid_data_t s)); -int hid_get_item __P((hid_data_t s, hid_item_t *h)); -int hid_report_size __P((report_desc_t d, enum hid_kind k, int *idp)); -int hid_locate __P((report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h)); - -/* Conversion to/from usage names, usage.c: */ -char *hid_usage_page __P((int i)); -char *hid_usage_in_page __P((unsigned int u)); -void hid_init __P((char *file)); - -/* Extracting/insertion of data, data.c: */ -int hid_get_data __P((void *p, hid_item_t *h)); -void hid_set_data __P((void *p, hid_item_t *h, int data)); diff --git a/hw/xfree86/os-support/bsd/libusb/usb_hid_usages b/hw/xfree86/os-support/bsd/libusb/usb_hid_usages deleted file mode 100644 index 02f122028..000000000 --- a/hw/xfree86/os-support/bsd/libusb/usb_hid_usages +++ /dev/null @@ -1,1079 +0,0 @@ -# $NetBSD: usb_hid_usages,v 1.3 1999/07/02 15:46:53 simonb Exp $ -# -# USB HID usage table -# Syntax: -# - lines that do not start with a white space give the number and name of -# a usage page. -# - lines that start with a white space give the number and name of -# a usage with the last given page. -# If the number is * then the line matches all usages and the name -# is a printf formatting string that will be given the usage number. -# -# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usb_hid_usages,v 1.1.2.2 1999/12/03 10:12:43 hohndel Exp $ -# -1 Generic Desktop - 0x00 Undefined - 0x01 Pointer - 0x02 Mouse - 0x03 Reserved - 0x04 Joystick - 0x05 Game Pad - 0x06 Keyboard - 0x07 Keypad - 0x08 Multi-axis Controller - 0x30 X - 0x31 Y - 0x32 Z - 0x33 Rx - 0x34 Ry - 0x35 Rz - 0x36 Slider - 0x37 Dial - 0x38 Wheel - 0x39 Hat Switch - 0x3A Counted Buffer - 0x3B Byte Count - 0x3C Motion Wakeup - 0x40 Vx - 0x41 Vy - 0x42 Vz - 0x43 Vbrx - 0x44 Vbry - 0x45 Vbrx - 0x46 Vno - 0x80 System Control - 0x81 System Power Down - 0x82 System Sleep - 0x83 System Wake Up - 0x84 System Context Menu - 0x85 System Main Menu - 0x86 System App Menu - 0x87 System Menu Help - 0x88 System Menu Exit - 0x89 System Menu Select - 0x8A System Menu Right - 0x8B System Menu Left - 0x8C System Menu Up - 0x8D System Menu Down - 0x90 D-pad Up - 0x91 D-pad Down - 0x92 D-pad Right - 0x93 D-pad Left - -2 Simulation Controls - 0x00 Undefined - 0x01 Flight Simulation Device - 0x02 Automobile Simulation Device - 0x03 Tank Simulation Device - 0x04 Spaceship Simulation Device - 0x05 Submarine Simulation Device - 0x06 Sailing Simulation Device - 0x07 Motorcycle Simulation Device - 0x08 Sports Simulation Device - 0x09 Airplane Simulation Device - 0x0A Helicopter Simulation Device - 0x0B Magic Carpet Simulation Device - 0x0C Bicycle - 0x20 Flight Control Stick - 0x21 Flight Stick - 0x22 Cyclic Control - 0x23 Cyclic Trim - 0x24 Flight Yoke - 0x25 Track Control - 0x26 Driving Control - 0xB0 Aileron - 0xB1 Aileron Trim - 0xB2 Anti-Torque Control - 0xB3 Auto-pilot Enable - 0xB4 Chaff Release - 0xB5 Collective Control - 0xB6 Dive Brake - 0xB7 Electronic Counter Measures - 0xB8 Elevator - 0xB9 Elevator Trim - 0xBA Rudder - 0xBB Throttle - 0xBC Flight Communication - 0xBD Flare Release - 0xBE Landing Gear - 0xBF Toe Brake - 0xC0 Trigger - 0xC1 Weapons Arm - 0xC2 Weapons Select - 0xC3 Wing Flaps - 0xC4 Accelerator - 0xC5 Brake - 0xC6 Clutch - 0xC7 Shifter - 0xC8 Steering - 0xC9 Turret Direction - 0xCA Barrel Elevation - 0xCB Dive Plane - 0xCC Ballast - 0xCD Bicycle Crank - 0xCE Handle Bars - 0xCF Front Brake - 0xD0 Rear Brake - -3 VR Controls - 0x00 Unidentified - 0x01 Belt - 0x02 Body Suit - 0x03 Flexor - 0x04 Glove - 0x05 Head Tracker - 0x06 Head Mounted Display - 0x07 Hand Tracker - 0x08 Oculometer - 0x09 Vest - 0x0A Animatronic Device - 0x20 Stereo Enable - 0x21 Display Enable - -4 Sports Controls - 0x00 Unidentified - 0x01 Baseball Bat - 0x02 Golf Club - 0x03 Rowing Machine - 0x04 Treadmill - 0x30 Oar - 0x31 Slope - 0x32 Rate - 0x33 Stick Speed - 0x34 Stick Face Angle - 0x35 Stick Heel/Toe - 0x36 Stick Follow Through - 0x37 Stick Tempo - 0x38 Stick Type - 0x39 Stick Height - 0x50 Putter - 0x51 1 Iron - 0x52 2 Iron - 0x53 3 Iron - 0x54 4 Iron - 0x55 5 Iron - 0x56 6 Iron - 0x57 7 Iron - 0x58 8 Iron - 0x59 9 Iron - 0x5A 10 Iron - 0x5B 11 Iron - 0x5C Sand Wedge - 0x5D Loft Wedge - 0x5E Power Wedge - 0x5F 1 Wood - 0x60 3 Wood - 0x61 5 Wood - 0x62 7 Wood - 0x63 9 Wood - -5 Game Controls - 0x00 Undefined - 0x01 3D Game Controller - 0x02 Pinball Device - 0x03 Gun Device - 0x20 Point of View - 0x21 Turn Right/Left - 0x22 Pitch Right/Left - 0x23 Roll Forward/Backward - 0x24 Move Right/Left - 0x25 Move Forward/Backward - 0x26 Move Up/Down - 0x27 Lean Right/Left - 0x28 Lean Forward/Backward - 0x29 Height of POV - 0x2A Flipper - 0x2B Secondary Flipper - 0x2C Bump - 0x2D New Game - 0x2E Shoot Ball - 0x2F Player - 0x30 Gun Bolt - 0x31 Gun Clip - 0x32 Gun Selector - 0x33 Gun Single Shot - 0x34 Gun Burst - 0x35 Gun Automatic - 0x36 Gun Safety - 0x37 Gamepad Fire/Jump - 0x39 Gamepad Trigger - -7 Keyboard - 0x00 Reserved (no event indicated) - 0x01 Keyboard ErrorRollOver - 0x02 Keyboard POSTFail - 0x03 Keyboard ErrorUndefined - 0x04 Keyboard a and A - 0x05 Keyboard b and B - 0x06 Keyboard c and C - 0x07 Keyboard d and D - 0x08 Keyboard e and E - 0x09 Keyboard f and F - 0x0A Keyboard g and G - 0x0B Keyboard h and H - 0x0C Keyboard i and I - 0x0D Keyboard j and J - 0x0E Keyboard k and K - 0x0F Keyboard l and L - 0x10 Keyboard m and M - 0x11 Keyboard n and N - 0x12 Keyboard o and O - 0x13 Keyboard p and P - 0x14 Keyboard q and Q - 0x15 Keyboard r and R - 0x16 Keyboard s and S - 0x17 Keyboard t and T - 0x18 Keyboard u and U - 0x19 Keyboard v and V - 0x1A Keyboard w and W - 0x1B Keyboard x and X - 0x1C Keyboard y and Y - 0x1D Keyboard z and Z - 0x1E Keyboard 1 and ! - 0x1F Keyboard 2 and @ - 0x20 Keyboard 3 and # - 0x21 Keyboard 4 and $ - 0x22 Keyboard 5 and % - 0x23 Keyboard 6 and ^ - 0x24 Keyboard 7 and & - 0x25 Keyboard 8 and * - 0x26 Keyboard 9 and ( - 0x27 Keyboard 0 and ) - 0x28 Keyboard Return (ENTER) - 0x29 Keyboard ESCAPE - 0x2A Keyboard DELETE (Backspace) - 0x2B Keyboard Tab - 0x2C Keyboard Spacebar - 0x2D Keyboard - and (underscore) - 0x2E Keyboard = and + - 0x2F Keyboard [ and { - 0x30 Keyboard ] and } - 0x31 Keyboard \ and | - 0x32 Keyboard Non-US # and ~ - 0x33 Keyboard ; and : - 0x34 Keyboard ' and " - 0x35 Keyboard Grave Accent and Tilde - 0x36 Keyboard, and < - 0x37 Keyboard . and > - 0x38 Keyboard / and ? - 0x39 Keyboard Caps Lock - 0x3A Keyboard F1 - 0x3B Keyboard F2 - 0x3C Keyboard F3 - 0x3D Keyboard F4 - 0x3E Keyboard F5 - 0x3F Keyboard F6 - 0x40 Keyboard F7 - 0x41 Keyboard F8 - 0x42 Keyboard F9 - 0x43 Keyboard F10 - 0x44 Keyboard F11 - 0x45 Keyboard F12 - 0x46 Keyboard PrintScreen - 0x47 Keyboard Scroll Lock - 0x48 Keyboard Pause - 0x49 Keyboard Insert - 0x4A Keyboard Home - 0x4B Keyboard PageUp - 0x4C Keyboard Delete Forward - 0x4D Keyboard End - 0x4E Keyboard PageDown - 0x4F Keyboard RightArrow - 0x50 Keyboard LeftArrow - 0x51 Keyboard DownArrow - 0x52 Keyboard UpArrow - 0x53 Keypad Num Lock and Clear - 0x54 Keypad / - 0x55 Keypad * - 0x56 Keypad - - 0x57 Keypad + - 0x58 Keypad ENTER - 0x59 Keypad 1 and End - 0x5A Keypad 2 and Down Arrow - 0x5B Keypad 3 and PageDn - 0x5C Keypad 4 and Left Arrow - 0x5D Keypad 5 - 0x5E Keypad 6 and Right Arrow - 0x5F Keypad 7 and Home - 0x60 Keypad 8 and Up Arrow - 0x61 Keypad 9 and PageUp - 0x62 Keypad 0 and Insert - 0x63 Keypad . and Delete - 0x64 Keyboard Non-US \ and | - 0x65 Keyboard Application - 0x66 Keyboard Power - 0x67 Keypad = - 0x68 Keyboard F13 - 0x69 Keyboard F14 - 0x6A Keyboard F15 - 0x6B Keyboard F16 - 0x6C Keyboard F17 - 0x6D Keyboard F18 - 0x6E Keyboard F19 - 0x6F Keyboard F20 - 0x70 Keyboard F21 - 0x71 Keyboard F22 - 0x72 Keyboard F23 - 0x73 Keyboard F24 - 0x74 Keyboard Execute - 0x75 Keyboard Help - 0x76 Keyboard Menu - 0x77 Keyboard Select - 0x78 Keyboard Stop - 0x79 Keyboard Again - 0x7A Keyboard Undo - 0x7B Keyboard Cut - 0x7C Keyboard Copy - 0x7D Keyboard Paste - 0x7E Keyboard Find - 0x7F Keyboard Mute - 0x80 Keyboard Volume Up - 0x81 Keyboard Volume Down - 0x82 Keyboard Locking Caps Lock - 0x83 Keyboard Locking Num Lock - 0x84 Keyboard Locking Scroll Lock - 0x85 Keypad Comma - 0x86 Keypad Equal Sign - 0x87 Keyboard International1 - 0x88 Keyboard International2 - 0x89 Keyboard International3 - 0x8A Keyboard International4 - 0x8B Keyboard International5 - 0x8C Keyboard International6 - 0x8D Keyboard International7 - 0x8E Keyboard International8 - 0x8F Keyboard International9 - 0x90 Keyboard LANG1 - 0x91 Keyboard LANG2 - 0x92 Keyboard LANG3 - 0x93 Keyboard LANG4 - 0x94 Keyboard LANG5 - 0x95 Keyboard LANG6 - 0x96 Keyboard LANG7 - 0x97 Keyboard LANG8 - 0x98 Keyboard LANG9 - 0x99 Keyboard Alternate Erase - 0x9A Keyboard SysReq/Attention - 0x9B Keyboard Cancel - 0x9C Keyboard Clear - 0x9D Keyboard Prior - 0x9E Keyboard Return - 0x9F Keyboard Separator - 0xA0 Keyboard Out - 0xA1 Keyboard Oper - 0xA2 Keyboard Clear/Again - 0xA3 Keyboard CrSel/Props - 0xA4 Keyboard ExSel - 0xE0 Keyboard LeftControl - 0xE1 Keyboard LeftShift - 0xE2 Keyboard LeftAlt - 0xE3 Keyboard Left GUI - 0xE4 Keyboard RightControl - 0xE5 Keyboard RightShift - 0xE6 Keyboard RightAlt - 0xE7 Keyboard Right GUI - -8 LEDs - 0x00 Undefined - 0x01 Num Lock - 0x02 Caps Lock - 0x03 Scroll Lock - 0x04 Compose - 0x05 Kana - 0x06 Power - 0x07 Shift - 0x08 Do Not Disturb - 0x09 Mute - 0x0A Tone Enable - 0x0B High Cut Filter - 0x0C Low Cut Filter - 0x0D Equalizer Enable - 0x0E Sound Field On - 0x0F Surround Field On - 0x10 Repeat - 0x11 Stereo - 0x12 Sampling Rate Detect - 0x13 Spinning - 0x14 CAV - 0x15 CLV - 0x16 Recording Format Detect - 0x17 Off-Hook - 0x18 Ring - 0x19 Message Waiting - 0x1A Data Mode - 0x1B Battery Operation - 0x1C Battery OK - 0x1D Battery Low - 0x1E Speaker - 0x1F Head Set - 0x20 Hold - 0x21 Microphone - 0x22 Coverage - 0x23 Night Mode - 0x24 Send Calls - 0x25 Call Pickup - 0x26 Conference - 0x27 Stand-by - 0x28 Camera On - 0x29 Camera Off - 0x2A On-Line - 0x2B Off-Line - 0x2C Busy - 0x2D Ready - 0x2E Paper-Out - 0x2F Paper-Jam - 0x30 Remote - 0x31 Forward - 0x32 Reverse - 0x33 Stop - 0x34 Rewind - 0x35 Fast Forward - 0x36 Play - 0x37 Pause - 0x38 Record - 0x39 Error - 0x3A Usage Selected Indicator - 0x3B Usage In Use Indicator - 0x3C Usage Multi Mode Indicator - 0x3D Indicator On - 0x3E Indicator Flash - 0x3F Indicator Slow Blink - 0x40 Indicator Fast Blink - 0x41 Indicator Off - 0x42 Flash On Time - 0x43 Slow Blink On Time - 0x44 Slow Blink Off Time - 0x45 Fast Blink On Time - 0x46 Fast Blink Off Time - 0x47 Usage Indicator Color - 0x48 Red - 0x49 Green - 0x4A Amber - 0x4B Generic Indicator - 0x4C System Suspend - 0x4D External Power Connected - 0x4C-FFFF Reserved - -9 Button - 0x00 No Button Pressed - * Button %d - -10 Ordinal - 0x00 Unused - * Instance %d - -11 Telephony - 0x00 Unassigned - 0x01 Phone - 0x02 Answering Machine - 0x03 Message Controls - 0x04 Handset - 0x05 Headset - 0x06 Telephony Key Pad - 0x07 Programmable Button - 0x20 Hook Switch - 0x21 Flash - 0x22 Feature - 0x23 Hold - 0x24 Redial - 0x25 Transfer - 0x26 Drop - 0x27 Park - 0x28 Forward Calls - 0x29 Alternate Function - 0x2A Line - 0x2B Speaker Phone - 0x2C Conference - 0x2D Ring Enable - 0x2E Ring Select - 0x2F Phone Mute - 0x30 Caller ID - 0x50 Speed Dial - 0x51 Store Number - 0x52 Recall Number - 0x53 Phone Directory - 0x70 Voice Mail - 0x71 Screen Calls - 0x72 Do Not Disturb - 0x73 Message - 0x74 Answer On/Off - 0x90 Inside Dial Tone - 0x91 Outside Dial Tone - 0x92 Inside Ring Tone - 0x93 Outside Ring Tone - 0x94 Priority Ring Tone - 0x95 Inside Ringback - 0x96 Priority Ringback - 0x97 Line Busy Tone - 0x98 Reorder Tone - 0x99 Call Waiting Tone - 0x9A Confirmation Tone 1 - 0x9B Confirmation Tone 2 - 0x9C Tones Off - 0xB0 Phone Key 0 - 0xB1 Phone Key 1 - 0xB2 Phone Key 2 - 0xB3 Phone Key 3 - 0xB4 Phone Key 4 - 0xB5 Phone Key 5 - 0xB6 Phone Key 6 - 0xB7 Phone Key 7 - 0xB8 Phone Key 8 - 0xB9 Phone Key 9 - 0xBA Phone Key Star - 0xBB Phone Key Pound - 0xBC Phone Key A - 0xBD Phone Key B - 0xBE Phone Key C - 0xBF Phone Key D - -12 Consumer - 0x00 Unassigned - 0x01 Consumer Control - 0x02 Numeric Key Pad - 0x03 Programmable Buttons - 0x20 +10 - 0x21 +100 - 0x22 AM/PM - 0x30 Power - 0x31 Reset - 0x32 Sleep - 0x33 Sleep After - 0x34 Sleep Mode - 0x35 Illumination - 0x36 Function Buttons - 0x40 Menu - 0x41 Menu Pick - 0x42 Menu Up - 0x43 Menu Down - 0x44 Menu Left - 0x45 Menu Right - 0x46 Menu Escape - 0x47 Menu Value Increase - 0x48 Menu Value Decrease - 0x60 Data On Screen - 0x61 Closed Caption - 0x62 Closed Caption Select - 0x63 VCR/TV - 0x64 Broadcast Mode - 0x65 Snapshot - 0x66 Still - 0x80 Selection - 0x81 Assign Selection - 0x82 Mode Step - 0x83 Recall Last - 0x84 Enter Channel - 0x85 Order Movie - 0x86 Channel - 0x87 Media Selection - 0x88 Media Select Computer - 0x89 Media Select TV - 0x8A Media Select WWW - 0x8B Media Select DVD - 0x8C Media Select Telephone - 0x8D Media Select Program Guide - 0x8E Media Select Video Phone - 0x8F Media Select Games - 0x90 Media Select Messages - 0x91 Media Select CD - 0x92 Media Select VCR - 0x93 Media Select Tuner - 0x94 Quit - 0x95 Help - 0x96 Media Select Tape - 0x97 Media Select Cable - 0x98 Media Select Satellite - 0x99 Media Select Security - 0x9A Media Select Home - 0x9B Media Select Call - 0x9C Channel Increment - 0x9D Channel Decrement - 0x9E Media Select SAP - 0xA0 VCR Plus - 0xA1 Once - 0xA2 Daily - 0xA3 Weekly - 0xA4 Monthly - 0xB0 Play - 0xB1 Pause - 0xB2 Record - 0xB3 Fast Forward - 0xB4 Rewind - 0xB5 Scan Next Track - 0xB6 Scan Previous Track - 0xB7 Stop - 0xB8 Eject - 0xB9 Random Play - 0xBA Select DisC - 0xBB Enter Disc - 0xBC Repeat - 0xBD Tracking - 0xBE Track Normal - 0xBF Slow Tracking - 0xC0 Frame Forward - 0xC1 Frame Back - 0xC2 Mark - 0xC3 Clear Mark - 0xC4 Repeat From Mark - 0xC5 Return To Mark - 0xC6 Search Mark Forward - 0xC7 Search Mark Backwards - 0xC8 Counter Reset - 0xC9 Show Counter - 0xCA Tracking Increment - 0xCB Tracking Decrement - 0xE0 Volume - 0xE1 Balance - 0xE2 Mute - 0xE3 Bass - 0xE4 Treble - 0xE5 Bass Boost - 0xE6 Surround Mode - 0xE7 Loudness - 0xE8 MPX - 0xE9 Volume Up - 0xEA Volume Down - 0xF0 Speed Select - 0xF1 Playback Speed - 0xF2 Standard Play - 0xF3 Long Play - 0xF4 Extended Play - 0xF5 Slow - 0x100 Fan Enable - 0x101 Fan Speed - 0x102 Light - 0x103 Light Illumination Level - 0x104 Climate Control Enable - 0x105 Room Temperature - 0x106 Security Enable - 0x107 Fire Alarm - 0x108 Police Alarm - 0x150 Balance Right - 0x151 Balance Left - 0x152 Bass Increment - 0x153 Bass Decrement - 0x154 Treble Increment - 0x155 Treble Decrement - 0x160 Speaker System - 0x161 Channel Left - 0x162 Channel Right - 0x163 Channel Center - 0x164 Channel Front - 0x165 Channel Center Front - 0x166 Channel Side - 0x167 Channel Surround - 0x168 Channel Low Frequency Enhancement - 0x169 Channel Top - 0x16A Channel Unknown - 0x170 Sub-channel - 0x171 Sub-channel Increment - 0x172 Sub-channel Decrement - 0x173 Alternate Audio Increment - 0x174 Alternate Audio Decrement - 0x180 Application Launch Buttons - 0x181 AL Launch Button Configuration Tool - 0x182 AL Programmable Button Configuration - 0x183 AL Consumer Control Configuration - 0x184 AL Word Processor - 0x185 AL Text Editor - 0x186 AL Spreadsheet - 0x187 AL Graphics Editor - 0x188 AL Presentation App - 0x189 AL Database App - 0x18A AL Email Reader - 0x18B AL Newsreader - 0x18C AL Voicemail - 0x18D AL Contacts/Address Book - 0x18E AL Calendar/Schedule - 0x18F AL Task/Project Manager - 0x190 AL Log/Journal/Timecard - 0x191 AL Checkbook/Finance - 0x192 AL Calculator - 0x193 AL A/V Capture/Playback - 0x194 AL Local Machine Browser - 0x195 AL LAN/WAN Browser - 0x196 AL Internet Browser - 0x197 AL Remote Networking/ISP Connect - 0x198 AL Network Conference - 0x199 AL Network Chat - 0x19A AL Telephony/Dialer - 0x19B AL Logon - 0x19C AL Logoff - 0x19D AL Logon/Logoff - 0x19E AL Terminal Lock/Screensaver - 0x19F AL Control Panel - 0x1A0 AL Command Line Processor/Run - 0x1A1 AL Process/Task Manager - 0x1A2 AL Select Tast/Application - 0x1A3 AL Next Task/Application - 0x1A4 AL Previous Task/Application - 0x1A5 AL Preemptive Halt Task/Application - 0x200 Generic GUI Application Controls - 0x201 AC New - 0x202 AC Open - 0x203 AC Close - 0x204 AC Exit - 0x205 AC Maximize - 0x206 AC Minimize - 0x207 AC Save - 0x208 AC Print - 0x209 AC Properties - 0x21A AC Undo - 0x21B AC Copy - 0x21C AC Cut - 0x21D AC Paste - 0x21E AC Select All - 0x21F AC Find - 0x220 AC Find and Replace - 0x221 AC Search - 0x222 AC Go To - 0x223 AC Home - 0x224 AC Back - 0x225 AC Forward - 0x226 AC Stop - 0x227 AC Refresh - 0x228 AC Previous Link - 0x229 AC Next Link - 0x22A AC Bookmarks - 0x22B AC History - 0x22C AC Subscriptions - 0x22D AC Zoom In - 0x22E AC Zoom Out - 0x22F AC Zoom - 0x230 AC Full Screen View - 0x231 AC Normal View - 0x232 AC View Toggle - 0x233 AC Scroll Up - 0x234 AC Scroll Down - 0x235 AC Scroll - 0x236 AC Pan Left - 0x237 AC Pan Right - 0x238 AC Pan - 0x239 AC New Window - 0x23A AC Tile Horizontally - 0x23B AC Tile Vertically - 0x23C AC Format - -13 Digitizer - 0x00 Undefined - 0x01 Digitizer - 0x02 Pen - 0x03 Light Pen - 0x04 Touch Screen - 0x05 Touch Pad - 0x06 White Board - 0x07 Coordinate Measuring Machine - 0x08 3-D Digitizer - 0x09 Stereo Plotter - 0x0A Articulated Arm - 0x0B Armature - 0x0C Multiple Point Digitizer - 0x0D Free Space Wand - 0x20 Stylus - 0x21 Puck - 0x22 Finger - 0x30 Tip Pressure - 0x31 Barrel Pressure - 0x32 In Range - 0x33 Touch - 0x34 Untouch - 0x35 Tap - 0x36 Quality - 0x37 Data Valid - 0x38 Transducer Index - 0x39 Tablet Function Keys - 0x3A Program Change Keys - 0x3B Battery Strength - 0x3C Invert - 0x3D X Tilt - 0x3E Y Tilt - 0x3F Azimuth - 0x40 Altitude - 0x41 Twist - 0x42 Tip Switch - 0x43 Secondary Tip Switch - 0x44 Barrel Switch - 0x45 Eraser - 0x46 Tablet Pick - -15 Physical Interface Device - -16 Unicode - * Unicode Char u%04x - -20 Alphnumeric Display - 0x00 Undefined - 0x01 Alphanumeric Display - 0x20 Display Attributes Report - 0x21 ASCII Character Set - 0x22 Data Read Back - 0x23 Font Read Back - 0x24 Display Control Report - 0x25 Clear Display - 0x26 Display Enable - 0x27 Screen Saver Delay - 0x28 Screen Saver Enable - 0x29 Vertical Scroll - 0x2A Horizontal Scroll - 0x2B Character Report - 0x2C Display Data - 0x2D Display Status - 0x2E Stat Not Ready - 0x2F Stat Ready - 0x30 Err Not a loadable character - 0x31 Err Font data cannot be read - 0x32 Cursor Position Report - 0x33 Row - 0x34 Column - 0x35 Rows - 0x36 Columns - 0x37 Cursor Pixel Positioning - 0x38 Cursor Mode - 0x39 Cursor Enable - 0x3A Cursor Blink - 0x3B Font Report - 0x3C Font Data - 0x3D Character Width - 0x3E Character Height - 0x3F Character Spacing Horizontal - 0x40 Character Spacing Vertical - 0x41 Unicode Character Set - -128 Monitor - 0x00 Undefined - 0x01 Monitor Control - 0x02 EDID Information - 0x03 VDIF Information - 0x04 VESA Version - 0x05 On Screen Display - 0x06 Auto Size Center - 0x07 Polarity Horz Synch - 0x08 Polarity Vert Synch - 0x09 Sync Type - 0x0A Screen Position - 0x0B Horizontal Frequency - 0x0C Vertical Frequency - -129 Monitor Enumerated Values - 0x00 unassigned - * ENUM %d - -130 VESA Virtual Controls - 0x10 Brightness - 0x12 Contrast - 0x16 Video Gain Red - 0x18 Video Gain Green - 0x1A Video Gain Blue - 0x1C Focus - 0x20 Horizontal Position - 0x22 Horizontal Size - 0x24 Horizontal Pincushion - 0x26 Horizontal Pincushion Balance - 0x28 Horizontal Misconvergence - 0x2A Horizontal Linearity - 0x2C Horizontal Linearity Balance - 0x30 Vertical Position - 0x32 Vertical Size - 0x34 Vertical Pincushion - 0x36 Vertical Pincushion Balance - 0x38 Vertical Misconvergence - 0x3A Vertical Linearity - 0x3C Vertical Linearity Balance - 0x40 Parallelogram Distortion - 0x42 Trapezoidal Distortion - 0x44 Tilt - 0x46 Top Corner Distortion Control - 0x48 Top Corner Distortion Balance - 0x4A Bottom Corner Distortion Control - 0x4C Bottom Corner Distortion Balance - 0x56 Moiré Horizontal - 0x58 Moiré Vertical - 0x5E Input Level Select - 0x60 Input Source Select - 0x62 Stereo Mode - 0x6C Video Black Level Red - 0x6E Video Black Level Green - 0x70 Video Black Level Blue - -131 VESA Command - 0x00 Undefined - 0x01 Settings - 0x02 Degauss - -132 Power Device - 0x00 Undefined - 0x01 iName - 0x02 PresentStatus - 0x03 ChangedStatus - 0x04 UPS - 0x05 PowerSupply - 0x10 BatterySystem - 0x11 BatterySystemID - 0x12 Battery - 0x13 BatteryID - 0x14 Charger - 0x15 ChargerID - 0x16 PowerConverter - 0x17 PowerConverterID - 0x18 OutletSystem - 0x19 OutletSystemID - 0x1A Input - 0x1B InputID - 0x1C Output - 0x1D OutputID - 0x1E Flow - 0x1F FlowID - 0x20 Outlet - 0x21 OutletID - 0x22 Gang - 0x23 GangID - 0x24 Sink - 0x25 SinkID - 0x30 Voltage - 0x31 Current - 0x32 Frequency - 0x33 ApparentPower - 0x34 ActivePower - 0x35 PercentLoad - 0x36 Temperature - 0x37 Humidity - 0x40 ConfigVoltage - 0x41 ConfigCurrent - 0x42 ConfigFrequency - 0x43 ConfigApparentPower - 0x44 ConfigActivePower - 0x45 ConfigPercentLoad - 0x46 ConfigTemperature - 0x47 ConfigHumidity - 0x50 SwitchOnControl - 0x51 SwitchOffControl - 0x52 ToggleControl - 0x53 LowVoltageTransfer - 0x54 HighVoltageTransfer - 0x55 DelayBeforeReboot - 0x56 DelayBeforeStartup - 0x57 DelayBeforeShutdown - 0x58 Test - 0x59 Vendorspecificcommand - 0x60 Present - 0x61 Good - 0x62 InternalFailure - 0x63 VoltageOutOfRange - 0x64 FrequencyOutOfRange - 0x65 Overload - 0x66 OverCharged - 0x67 OverTemperature - 0x68 ShutdownRequested - 0x69 ShutdownImminent - 0x6A VendorSpecificAnswerValid - 0x6B SwitchOn/Off - 0x6C Switcheble - 0x6D Used - 0x6E Boost - 0x6F Buck - 0x70 Initialized - 0x71 Tested - -133 Battery System - 0x00 Undefined - 0x01 SMBBatteryMode - 0x02 SMBBatteryStatus - 0x03 SMBAlarmWarning - 0x04 SMBChargerMode - 0x05 SMBChargerStatus - 0x06 SMBChargerSpecInfo - 0x07 SMBSelectorState - 0x08 SMBSelectorPreset - 0x09 SMBSelectorInfo - 0x10 OptionalMfgFunction1 - 0x11 OptionalMfgFunction2 - 0x12 OptionalMfgFunction3 - 0x13 OptionalMfgFunction4 - 0x14 OptionalMfgFunction5 - 0x15 ConnectionToSMBus - 0x16 OutputConnection - 0x17 ChargerConnection - 0x18 BatteryInsertion - 0x19 Usenext - 0x1A OKToUse - 0x28 ManufacturerAccess - 0x29 RemainingCapacityLimit - 0x2A RemainingTimeLimit - 0x2B AtRate - 0x2C CapacityMode - 0x2D BroadcastToCharger - 0x2E PrimaryBattery - 0x2F ChargeController - 0x40 TerminateCharge - 0x41 TermminateDischarge - 0x42 BelowRemainingCapacityLimit - 0x43 RemainingTimeLimitExpired - 0x44 Charging - 0x45 Discharging - 0x46 FullyCharged - 0x47 FullyDischarged - 0x48 ConditionningFlag - 0x49 AtRateOK - 0x4A SMBErrorCode - 0x4B NeedReplacement - 0x60 AtRateTimeToFull - 0x61 AtRateTimeToEmpty - 0x62 AverageCurrent - 0x63 Maxerror - 0x64 RelativeStateOfCharge - 0x65 AbsoluteStateOfCharge - 0x66 RemainingCapacity - 0x67 FullChargeCapacity - 0x68 RunTimeToEmpty - 0x69 AverageTimeToEmpty - 0x6A AverageTimeToFull - 0x6B CycleCount - 0x80 BattPackModelLevel - 0x81 InternalChargeController - 0x82 PrimaryBatterySupport - 0x83 DesignCapacity - 0x84 SpecificationInfo - 0x85 ManufacturerDate - 0x86 SerialNumber - 0x87 iManufacturerName - 0x88 iDevicename - 0x89 iDeviceChemistery - 0x8A iManufacturerData - 0x8B Rechargeable - 0x8C WarningCapacityLimit - 0x8D CapacityGranularity1 - 0x8E CapacityGranularity2 - 0xC0 InhibitCharge - 0xC1 EnablePolling - 0xC2 ResetToZero - 0xD0 ACPresent - 0xD1 BatteryPresent - 0xD2 PowerFail - 0xD3 AlarmInhibited - 0xD4 ThermistorUnderRange - 0xD5 ThermistorHot - 0xD6 ThermistorCold - 0xD7 ThermistorOverRange - 0xD8 VoltageOutOfRange - 0xD9 CurrentOutOfRange - 0xDA CurrentNotRegulated - 0xDB VoltageNotRegulated - 0xDC MasterMode - 0xDD ChargerBattery/HostControlled - 0xF0 ChargerSpecInfo - 0xF1 ChargerSpecRef - 0xF2 Level2 - 0xF3 Level3 - -140 Bar Code Scanner - -141 Scale Device - -144 Camera Control - -145 Arcade Device - -# Some Micro$oft non-standard extensions -0xff00 Microsoft - 0xe9 Base Up - 0xea Base Down diff --git a/hw/xfree86/os-support/bsd/libusb/usbvar.h b/hw/xfree86/os-support/bsd/libusb/usbvar.h deleted file mode 100644 index ce38a0730..000000000 --- a/hw/xfree86/os-support/bsd/libusb/usbvar.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -struct report_desc { - unsigned int size; - unsigned char data[1]; -}; - diff --git a/hw/xfree86/os-support/bsd/memrange.h b/hw/xfree86/os-support/bsd/memrange.h deleted file mode 100644 index 03c479144..000000000 --- a/hw/xfree86/os-support/bsd/memrange.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Memory range attribute operations, peformed on /dev/mem - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _MEMRANGE_H -#define _MEMRANGE_H - -/* Memory range attributes */ -#define MDF_UNCACHEABLE (1<<0) /* region not cached */ -#define MDF_WRITECOMBINE (1<<1) /* region supports "write combine" - * action */ -#define MDF_WRITETHROUGH (1<<2) /* write-through cached */ -#define MDF_WRITEBACK (1<<3) /* write-back cached */ -#define MDF_WRITEPROTECT (1<<4) /* read-only region */ -#define MDF_ATTRMASK (0x00ffffff) - -#define MDF_FIXBASE (1<<24) /* fixed base */ -#define MDF_FIXLEN (1<<25) /* fixed length */ -#define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */ -#define MDF_ACTIVE (1<<27) /* currently active */ -#define MDF_BOGUS (1<<28) /* we don't like it */ -#define MDF_FIXACTIVE (1<<29) /* can't be turned off */ -#define MDF_BUSY (1<<30) /* range is in use */ - -struct mem_range_desc { - u_int64_t mr_base; - u_int64_t mr_len; - int mr_flags; - char mr_owner[8]; -}; - -struct mem_range_op { - struct mem_range_desc *mo_desc; - int mo_arg[2]; -#define MEMRANGE_SET_UPDATE 0 -#define MEMRANGE_SET_REMOVE 1 - /* XXX want a flag that says "set and undo when I exit" */ -}; -#define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op) -#define MEMRANGE_SET _IOW('m', 51, struct mem_range_op) - -#ifdef _KERNEL - -struct mem_range_softc; -struct mem_range_ops { - void (*init) __P((struct mem_range_softc * sc)); - int (*set) __P((struct mem_range_softc * sc, struct mem_range_desc * mrd, int *arg)); - void (*initAP) __P((struct mem_range_softc * sc)); -}; - -struct mem_range_softc { - struct mem_range_ops *mr_op; - int mr_cap; - int mr_ndesc; - struct mem_range_desc *mr_desc; -}; - -extern struct mem_range_softc mem_range_softc; - -extern int mem_range_attr_get __P((struct mem_range_desc * mrd, int *arg)); -extern int mem_range_attr_set __P((struct mem_range_desc * mrd, int *arg)); -extern void mem_range_AP_init __P((void)); -#endif - -#endif diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c deleted file mode 100644 index 06be654e1..000000000 --- a/hw/xfree86/os-support/bsd/ppc_video.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" - -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#include "bus/Pci.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -#ifndef __OpenBSD__ -#define DEV_MEM "/dev/mem" -#else -#define DEV_MEM "/dev/xf86" -#endif - -static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags); -static void ppcUnmapVidMem(int, pointer, unsigned long); - -Bool xf86EnableIO(void); -void xf86DisableIO(void); - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = ppcMapVidMem; - pVidMem->unmapMem = ppcUnmapVidMem; - pVidMem->initialised = TRUE; - xf86EnableIO(); -} - - -_X_EXPORT volatile unsigned char *ioBase = MAP_FAILED; - -static pointer -ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - int fd = xf86Info.screenFd; - pointer base; -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", - Base, Size, fd); -#endif - - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, Base); - if (base == MAP_FAILED) - FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", - "xf86MapVidMem", Size, Base, strerror(errno)); - - return base; -} - -static void -ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap(Base, Size); -} - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int rv; - static int kmem = -1; - - if (kmem == -1) { - kmem = open(DEV_MEM, 2); - if (kmem == -1) { - FatalError("xf86ReadBIOS: open %s", DEV_MEM); - } - } - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", - Base, Offset, Len); -#endif - - - lseek(kmem, Base + Offset, 0); - rv = read(kmem, Buf, Len); - - return rv; -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - - return; -} - -Bool xf86EnableIO() -{ - int fd = xf86Info.screenFd; - - xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd); - if (ioBase == MAP_FAILED) - { - ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, - 0xf2000000); - xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase); - if (ioBase == MAP_FAILED) { - xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n"); - return FALSE; - } - } - return TRUE; -} - -void xf86DisableIO() -{ - - if (ioBase != MAP_FAILED) - { - munmap(__UNVOLATILE(ioBase), 0x10000); - ioBase = MAP_FAILED; - } -} - diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c deleted file mode 100644 index fb5e8529b..000000000 --- a/hw/xfree86/os-support/bsd/sparc64_video.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" - -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t)-1) -#endif - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int); -static void sparc64UnmapVidMem(int, pointer, unsigned long); - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = sparc64MapVidMem; - pVidMem->unmapMem = sparc64UnmapVidMem; - pVidMem->initialised = TRUE; -} - -static pointer -sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, - int flags) -{ - int fd = xf86Info.screenFd; - pointer base; - -#ifdef DEBUG - xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", - Base, Size, fd); -#endif - - base = mmap(0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, Base); - if (base == MAP_FAILED) - FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", - "xf86MapVidMem", Size, Base, strerror(errno)); - return base; -} - -static void -sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap(Base, Size); -} - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - - return (0); -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - - return; -} diff --git a/hw/xfree86/os-support/bus/460gxPCI.c b/hw/xfree86/os-support/bus/460gxPCI.c deleted file mode 100644 index 44ee97687..000000000 --- a/hw/xfree86/os-support/bus/460gxPCI.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -/* - * This file contains the glue necessary for support of Intel's 460GX chipset. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "460gxPCI.h" -#include "xf86.h" -#include "Pci.h" - -/* 460GX register definitions */ -/* SAC at 0:10:0 */ -#define CBN 0x0040 -/* SAC at CBN:0:0 */ -#define DEVNPRES 0x0070 -/* SAC at CBN:1[0-7]:0 */ -#define BUSNO 0x0048 -#define SUBNO 0x0049 -#define VGASE 0x0080 -#define PCIS 0x0084 -#define IOR 0x008C -#define IORD 0x008E /* CBN:10:0 only */ -/* PXB at CBN:1[0-7]:1 */ -#define ERRCMD 0x0046 - -static int cbn_460gx = -1; -static CARD32 cbdevs_460gx = 0; -static CARD16 iord_460gx; -static int busno_460gx[8], subno_460gx[8]; -static CARD8 pcis_460gx[8], ior_460gx[8]; -static CARD8 has_err_460gx[8], err_460gx[8]; -static CARD8 iomap_460gx[16]; /* One for each 4k */ -static pciBusFuncs_t BusFuncs_460gx; - -static pciConfigPtr -Verify460GXBus(int bus) -{ - pciConfigPtr pPCI; - - if ((bus < 0) || (bus >= pciNumBuses) || - !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) || - (pPCI->busnum != cbn_460gx) || (pPCI->funcnum != 0) || - (pPCI->devnum < 0x10) || (pPCI->devnum > 0x17)) - return NULL; - - return pPCI; -} - -/* - * This function is called to emulate the various settings in a P2P or CardBus - * bridge's control register using one of a 460GX's SAC host bridges. - */ -static CARD16 -Control460GXBridge(int bus, CARD16 mask, CARD16 value) -{ - pciConfigPtr pPCI; - PCITAG tag; - CARD16 current = 0; - CARD8 tmp; - - if ((pPCI = Verify460GXBus(bus))) { - /* Start with VGA enablement */ - tmp = pciReadByte(pPCI->tag, VGASE); - if (tmp & 0x01) { - current |= PCI_PCI_BRIDGE_VGA_EN; - if ((mask & PCI_PCI_BRIDGE_VGA_EN) && - !(value & PCI_PCI_BRIDGE_VGA_EN)) - pciWriteByte(pPCI->tag, VGASE, tmp & ~0x01); - } else { - if (mask & value & PCI_PCI_BRIDGE_VGA_EN) - pciWriteByte(pPCI->tag, VGASE, tmp | 0x01); - } - - /* Move on to master abort failure enablement */ - if (has_err_460gx[pPCI->devnum - 0x10]) { - tag = PCI_MAKE_TAG(pPCI->busnum, pPCI->devnum, pPCI->funcnum + 1); - tmp = pciReadByte(tag, ERRCMD); - if (tmp & 0x01) { - current |= PCI_PCI_BRIDGE_MASTER_ABORT_EN; - if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) && - !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) - pciWriteByte(tag, ERRCMD, tmp & ~0x01); - } else { - if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) - pciWriteByte(tag, ERRCMD, tmp | 0x01); - } - } - - /* Put emulation of any other P2P bridge control here */ - } - - return (current & ~mask) | (value & mask); -} - -/* - * Retrieve various bus numbers representing the connections provided by 460GX - * host bridges. - */ -static void -Get460GXBridgeBuses(int bus, int *primary, int *secondary, int *subordinate) -{ - pciConfigPtr pPCI = Verify460GXBus(bus); - int i; - - /* The returned bus numbers are initialised by the caller */ - - if (!pPCI) - return; - - i = pPCI->devnum - 0x10; - - /* These are not modified, so no need to re-read them */ - if (primary) - *primary = pPCI->busnum; - if (secondary) - *secondary = busno_460gx[i]; - if (subordinate) - *subordinate = subno_460gx[i]; -} - -/* Retrieves a list of the resources routed to a host bridge's secondary bus */ -static void -Get460GXBridgeResources(int bus, - pointer *ppIoRes, - pointer *ppMemRes, - pointer *ppPmemRes) -{ - pciConfigPtr pPCI = Verify460GXBus(bus); - resRange range; - unsigned int i, j; - - if (ppIoRes) { - xf86FreeResList(*ppIoRes); - *ppIoRes = NULL; - - if (pPCI) { - for (i = 0; i <= 0x0F; i++) { - if (iomap_460gx[i] != pPCI->devnum) - continue; - - RANGE(range, i << 12, ((i + 1) << 12) - 1, - RANGE_TYPE(ResExcIoBlock, 0)); - *ppIoRes = xf86AddResToList(*ppIoRes, &range, -1); - } - } - } - - if (ppMemRes) { - xf86FreeResList(*ppMemRes); - *ppMemRes = NULL; - - if (pPCI) { - if (!(i = (pPCI->devnum - 0x10))) - j = 127; /* (4GB - 32M) / 32M */ - else - j = pcis_460gx[i - 1] & 0x7F; - - i = pcis_460gx[i] & 0x7F; - if (i < j) { - RANGE(range, i << 25, (j << 25) - 1, - RANGE_TYPE(ResExcMemBlock, 0)); - *ppMemRes = xf86AddResToList(*ppMemRes, &range, -1); - } - } - } - - if (ppPmemRes) { - xf86FreeResList(*ppPmemRes); - *ppPmemRes = NULL; - } -} - -/* - * This checks for, and validates, the presence of the 460GX chipset, and sets - * cbn_460gx to a positive value accordingly. This function returns TRUE if - * the chipset scan is to be stopped, or FALSE if the scan is to move on to the - * next chipset. - */ - -Bool -xorgProbe460GX(scanpciWrapperOpt flags) -{ - pciBusInfo_t *pBusInfo; - PCITAG tag; - - /* Bus zero should already be set up */ - if (!(pBusInfo = pciBusInfo[0])) { - cbn_460gx = -1; - return FALSE; - } - /* First look for a 460GX's primary host bridge */ - tag = PCI_MAKE_TAG(0, 0x10, 0); - if (pciReadLong(tag, PCI_ID_REG) == DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) { - return TRUE; - } - - cbn_460gx = -1; - - return FALSE; -} - -void -xf86PreScan460GX(void) -{ - pciBusInfo_t *pBusInfo; - PCITAG tag; - CARD32 tmp; - int i, devno; - - if (!(pBusInfo = pciBusInfo[0])) - return; - - /* Get CBN (Chipset bus number) */ - tag = PCI_MAKE_TAG(0, 0x10, 0); - if (!(cbn_460gx = (unsigned int)pciReadByte(tag, CBN))) { - /* Sanity check failed */ - cbn_460gx = -1; - return; - } - - if (pciNumBuses <= cbn_460gx) - pciNumBuses = cbn_460gx + 1; - - /* Set up bus CBN */ - if (!pciBusInfo[cbn_460gx]) { - pciBusInfo[cbn_460gx] = xnfalloc(sizeof(pciBusInfo_t)); - *pciBusInfo[cbn_460gx] = *pBusInfo; - } - - tag = PCI_MAKE_TAG(cbn_460gx, 0, 0); - if (pciReadLong(tag, PCI_ID_REG) != DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) { - /* Sanity check failed */ - cbn_460gx = -1; - return; - } - - /* - * Find out which CBN devices the firmware thinks are present. Of these, - * we are only interested in devices 0x10 through 0x17. - */ - cbdevs_460gx = pciReadLong(tag, DEVNPRES); - - for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { - tag = PCI_MAKE_TAG(cbn_460gx, devno, 0); - if (pciReadLong(tag, PCI_ID_REG) != - DEVID(VENDOR_INTEL, CHIP_460GX_SAC)) { - /* Sanity check failed */ - cbn_460gx = -1; - return; - } - - if (devno == 0x10) - iord_460gx = pciReadWord(tag, IORD); - - busno_460gx[i] = (unsigned int)pciReadByte(tag, BUSNO); - subno_460gx[i] = (unsigned int)pciReadByte(tag, SUBNO); - pcis_460gx[i] = pciReadByte(tag, PCIS); - ior_460gx[i] = pciReadByte(tag, IOR); - - has_err_460gx[i] = err_460gx[i] = 0; /* Insurance */ - - tag = PCI_MAKE_TAG(cbn_460gx, devno, 1); - tmp = pciReadLong(tag, PCI_ID_REG); - switch (tmp) { - case DEVID(VENDOR_INTEL, CHIP_460GX_PXB): - case DEVID(VENDOR_INTEL, CHIP_460GX_WXB): - if (cbdevs_460gx & (1 << devno)) { - /* Sanity check failed */ - cbn_460gx = -1; - return; - } - - /* - * XXX I don't have WXB docs, but PCI register dumps indicate that - * the registers we are interested in are consistent with those of - * the PXB. - */ - err_460gx[i] = pciReadByte(tag, ERRCMD); - has_err_460gx[i] = 1; - break; - - case DEVID(VENDOR_INTEL, CHIP_460GX_GXB_1): - if (cbdevs_460gx & (1 << devno)) { - /* Sanity check failed */ - cbn_460gx = -1; - return; - } - - /* - * XXX GXB isn't documented to have an ERRCMD register, nor any - * other means of failing master aborts. For now, assume master - * aborts are always allowed to complete normally. - */ - break; - - default: - if (((CARD16)(tmp + 1U) <= (CARD16)1U) && - (cbdevs_460gx & (1U << devno))) - break; - /* Sanity check failed */ - cbn_460gx = -1; - return; - } - } - - /* Allow master aborts to complete normally */ - for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { - if (!(err_460gx[i] & 0x01)) - continue; - - pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1), - ERRCMD, err_460gx[i] & ~0x01); - } - - /* - * The 460GX spec says that any access to buses higher than CBN will be - * master-aborted. It seems possible however that this is not the case in - * all 460GX implementations. For now, limit the bus scan to CBN, unless - * we have already found a higher bus number. - */ - for (i = 0; subno_460gx[i] < cbn_460gx; ) { - if (++i < 8) - continue; - - pciMaxBusNum = cbn_460gx + 1; - break; - } - - return; -} - -/* This does some 460GX-related processing after the PCI bus scan */ -void -xf86PostScan460GX(void) -{ - pciConfigPtr pPCI, *ppPCI; - pciBusInfo_t *pBusInfo; - int i, j, devno; - - if (cbn_460gx <= 0) - return; - - /* Set up our extra bus functions */ - BusFuncs_460gx = *(pciBusInfo[0]->funcs); - BusFuncs_460gx.pciControlBridge = Control460GXBridge; - BusFuncs_460gx.pciGetBridgeBuses = Get460GXBridgeBuses; - BusFuncs_460gx.pciGetBridgeResources = Get460GXBridgeResources; - - /* - * Mark all host bridges so that they are ignored by the upper-level - * xf86GetPciBridgeInfo() function. This marking is later clobbered by the - * tail end of xf86scanpci() for those bridges that actually have bus - * segments associated with them. - */ - ppPCI = xf86scanpci(0); /* Recursion is only apparent */ - while ((pPCI = *ppPCI++)) { - if ((pPCI->pci_base_class == PCI_CLASS_BRIDGE) && - (pPCI->pci_sub_class == PCI_SUBCLASS_BRIDGE_HOST)) - pPCI->businfo = HOST_NO_BUS; - } - - ppPCI = xf86scanpci(0); /* Recursion is only apparent */ - j = 0; - - /* - * Fix up CBN bus linkage. This is somewhat arbitrary. The bridge chosen - * for this must be a CBN device so that bus CBN can be recognised as the - * root segment. It also cannot be any of the bus expanders (devices - * CBN:0x10:0 through CBN:0x17:0 nor any of their functions). For now, we - * chose the SAC host bridge at CBN:0:0. - */ - pBusInfo = pciBusInfo[cbn_460gx]; - pBusInfo->bridge = pciBusInfo[0]->bridge; /* Just in case */ - while ((pPCI = *ppPCI++)) { - if (pPCI->busnum < cbn_460gx) - continue; - if (pPCI->busnum > cbn_460gx) - break; - if (pPCI->devnum < 0) - continue; - if (pPCI->devnum > 0) - break; - if (pPCI->funcnum < 0) - continue; - if (pPCI->funcnum > 0) - break; - - pBusInfo->bridge = pPCI; - pBusInfo->secondary = FALSE; - pBusInfo->primary_bus = cbn_460gx; - break; - } - - for (i = 0, devno = 0x10; devno <= 0x17; i++, devno++) { - /* Restore ERRCMD registers */ - if (err_460gx[i] & 0x01) - pciWriteByte(PCI_MAKE_TAG(cbn_460gx, devno, 1), - ERRCMD, err_460gx[i]); - - if (!(cbdevs_460gx & (1 << devno))) { - while ((pPCI = *ppPCI++)) { - if (pPCI->busnum < cbn_460gx) - continue; - if (pPCI->busnum > cbn_460gx) - break; - if (pPCI->devnum < devno) - continue; - if (pPCI->devnum > devno) - break; - if (pPCI->funcnum < 0) - continue; - if (pPCI->funcnum > 0) - break; - - if ((pBusInfo == pciBusInfo[busno_460gx[i]])) - break; - - /* Fix bus linkage */ - pBusInfo->bridge = pPCI; - pBusInfo->secondary = TRUE; - pBusInfo->primary_bus = cbn_460gx; - - /* Plug in chipset routines */ - pBusInfo->funcs = &BusFuncs_460gx; - break; - } - } - - /* Decode IOR registers */ - for(; j <= (ior_460gx[i] & 0x0F); j++) - iomap_460gx[j] = devno; - } - - /* The bottom 4k of I/O space is always routed to PCI0a */ - iomap_460gx[0] = 0x10; - - /* Decode IORD register */ - for (j = 1; j <= 0x0F; j++) - if (iord_460gx & (1 << j)) - iomap_460gx[j] = 0x10; -} diff --git a/hw/xfree86/os-support/bus/460gxPCI.h b/hw/xfree86/os-support/bus/460gxPCI.h deleted file mode 100644 index 2905d4787..000000000 --- a/hw/xfree86/os-support/bus/460gxPCI.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef PCI_460GX_H -#define PCI_460GX_H 1 - -#include <X11/Xdefs.h> -#include <Pci.h> - -Bool xorgProbe460GX(scanpciWrapperOpt flags); -void xf86PreScan460GX(void); -void xf86PostScan460GX(void); - -#endif diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am deleted file mode 100644 index 5a15430c1..000000000 --- a/hw/xfree86/os-support/bus/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -noinst_LTLIBRARIES = libbus.la -sdk_HEADERS = xf86Pci.h - -PCI_SOURCES = - -if XORG_BUS_LINUXPCI -PCI_SOURCES += linuxPci.c -endif - -if XORG_BUS_BSDPCI -PCI_SOURCES += bsd_pci.c -endif - -if XORG_BUS_IX86PCI -PCI_SOURCES += ix86Pci.c -endif - -if XORG_BUS_PPCPCI -PCI_SOURCES += ppcPci.c -endif - -if XORG_BUS_SPARCPCI -PCI_SOURCES += sparcPci.c -endif - -if LINUX_ALPHA -PCI_SOURCES += axpPci.c -endif - -if XORG_BUS_SPARC -PLATFORM_SOURCES = Sbus.c -sdk_HEADERS += xf86Sbus.h -endif - -libbus_la_SOURCES = Pci.c Pci.h $(PCI_SOURCES) $(PLATFORM_PCI_SOURCES) \ - $(PLATFORM_SOURCES) - -INCLUDES = $(XORG_INCS) - -AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) - -EXTRA_DIST = $(sdk_HEADERS) diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c deleted file mode 100644 index 064533c77..000000000 --- a/hw/xfree86/os-support/bus/Pci.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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. - * - * This software is derived from the original XFree86 PCI code - * which includes the following copyright notices as well: - * - * Copyright 1995 by Robin Cutshaw <robin@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 the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) 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 HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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. - * - * This code is also based heavily on the code in FreeBSD-current, which was - * written by Wolfgang Stanglmeier, and contains the following copyright: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <errno.h> -#include <signal.h> -#include <X11/Xarch.h> -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include "Pci.h" - -#include <pciaccess.h> - -#define PCI_MFDEV_SUPPORT 1 /* Include PCI multifunction device support */ -#define PCI_BRIDGE_SUPPORT 1 /* Include support for PCI-to-PCI bridges */ - -/* - * Global data - */ - -pciBusInfo_t *pciBusInfo[MAX_PCI_BUSES] = { NULL, }; -_X_EXPORT int pciNumBuses = 0; /* Actual number of PCI buses */ -int pciMaxBusNum = MAX_PCI_BUSES; - - -_X_EXPORT ADDRESS -pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr) -{ - int bus = PCI_BUS_FROM_TAG(tag); - - if ((bus >= 0) && (bus < pciNumBuses) && pciBusInfo[bus] && - pciBusInfo[bus]->funcs->pciAddrBusToHost) - return (*pciBusInfo[bus]->funcs->pciAddrBusToHost)(tag, type, addr); - else - return(addr); -} - -_X_EXPORT PCITAG -pciTag(int busnum, int devnum, int funcnum) -{ - return(PCI_MAKE_TAG(busnum,devnum,funcnum)); -} - -ADDRESS -pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS addr) -{ - return(addr); -} - -_X_EXPORT Bool -xf86scanpci(void) -{ - Bool success = FALSE; - - success = (pci_system_init() == 0); - - /* XXX */ -#if defined(DEBUGPCI) - if (DEBUGPCI >= xf86Verbose) { - xf86Verbose = DEBUGPCI; - } -#endif - - /* choose correct platform/OS specific PCI init routine */ - ARCH_PCI_INIT(); - - return success; -} diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h deleted file mode 100644 index 1385eee85..000000000 --- a/hw/xfree86/os-support/bus/Pci.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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. - * - * This file is derived in part from the original xf86_PCI.h that included - * following copyright message: - * - * Copyright 1995 by Robin Cutshaw <robin@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 the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) 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 HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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. - * - */ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* - * This file has the private Pci definitions. The public ones are imported - * from xf86Pci.h. Drivers should not use this file. - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _PCI_H -#define _PCI_H 1 - -#include <X11/Xarch.h> -#include <X11/Xfuncproto.h> -#include "xf86Pci.h" -#include "xf86PciInfo.h" - -/* - * Global Definitions - */ -#define MAX_PCI_DEVICES 128 /* Max number of devices accomodated */ - /* by xf86scanpci */ -#if defined(sun) && defined(SVR4) && defined(sparc) -# define MAX_PCI_BUSES 4096 /* Max number of PCI buses */ -#elif (defined(__alpha__) || defined(__ia64__)) && defined (linux) -# define MAX_PCI_DOMAINS 512 -# define PCI_DOM_MASK 0x01fful -# define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */ -#else -# define MAX_PCI_BUSES 256 /* Max number of PCI buses */ -#endif - -#define DEVID(vendor, device) \ - ((CARD32)((PCI_##device << 16) | PCI_##vendor)) - -#ifndef PCI_DOM_MASK -# define PCI_DOM_MASK 0x0ffu -#endif -#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu) - -/* - * "b" contains an optional domain number. - */ -#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \ - (((d) & 0x00001fu) << 11) | \ - (((f) & 0x000007u) << 8)) - -#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu)) - -#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK)) -#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) -#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) -#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) - -#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8) -#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u) - -#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK)) -#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) -#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u) - -/* - * Debug Macros/Definitions - */ -/* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */ - -#if defined(DEBUGPCI) - -# define PCITRACE(lvl,printfargs) \ - if (lvl > xf86Verbose) { \ - ErrorF printfargs; \ - } - -#else /* !defined(DEBUGPCI) */ - -# define PCITRACE(lvl,printfargs) - -#endif /* !defined(DEBUGPCI) */ - -/* - * PCI Config mechanism definitions - */ -#define PCI_EN 0x80000000 - -#define PCI_CFGMECH1_ADDRESS_REG 0xCF8 -#define PCI_CFGMECH1_DATA_REG 0xCFC - -#define PCI_CFGMECH1_MAXDEV 32 - -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ - defined(__DragonFly__) -#define ARCH_PCI_INIT bsdPciInit -#endif - -#if !defined(ARCH_PCI_INIT) -/* - * Select architecture specific PCI init function - */ -#if defined(__alpha__) -# if defined(linux) -# define ARCH_PCI_INIT axpPciInit -# endif -#elif defined(__arm__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__hppa__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__ia64__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__i386__) || defined(__i386) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# else -# define ARCH_PCI_INIT ix86PciInit -# endif -#elif defined(__mc68000__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__mips__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__powerpc__) || defined(__powerpc64__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# else -# define ARCH_PCI_INIT ppcPciInit -# endif -#elif defined(__s390__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__sh__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# endif -#elif defined(__m32r__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# define INCLUDE_XF86_MAP_PCI_MEM -# define INCLUDE_XF86_NO_DOMAIN -# endif -#elif defined(__sparc__) || defined(sparc) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# elif defined(sun) -# define ARCH_PCI_INIT sparcPciInit -# endif -# if !defined(__FreeBSD__) && !defined(linux) -# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge -# endif -#elif defined(__amd64__) || defined(__amd64) || defined(__x86_64__) -# if defined(linux) -# define ARCH_PCI_INIT linuxPciInit -# else -# define ARCH_PCI_INIT ix86PciInit -# endif -#endif -#endif /* !defined(ARCH_PCI_INIT) */ - -#ifndef ARCH_PCI_INIT -#error No PCI support available for this architecture/OS combination -#endif - -extern void ARCH_PCI_INIT(void); - -#if defined(XF86SCANPCI_WRAPPER) -typedef enum { - SCANPCI_INIT, - SCANPCI_TERM -} scanpciWrapperOpt; -extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags); -#endif - -/* - * Table of functions used to access a specific PCI bus domain - * (e.g. a primary PCI bus and all of its secondaries) - */ -typedef struct pci_bus_funcs { - ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS); -} pciBusFuncs_t, *pciBusFuncs_p; - -/* - * pciBusInfo_t - One structure per defined PCI bus - */ -typedef struct pci_bus_info { - unsigned char configMech; /* PCI config type to use */ - unsigned char numDevices; /* Range of valid devnums */ - unsigned char secondary; /* Boolean: bus is a secondary */ - int primary_bus; /* Parent bus */ - pciBusFuncs_p funcs; /* PCI access functions */ - void *pciBusPriv; /* Implementation private data */ - struct pci_device *bridge; /* bridge that opens this bus */ -} pciBusInfo_t; - -#define HOST_NO_BUS ((pciBusInfo_t *)(-1)) - -/* configMech values */ -#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */ -#define PCI_CFG_MECH_1 1 /* Most machines */ -#define PCI_CFG_MECH_2 2 /* Older PC's */ -#define PCI_CFG_MECH_OTHER 3 /* Something else */ - -/* Generic PCI service functions and helpers */ -CARD32 pciCfgMech1Read(PCITAG tag, int offset); -void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val); -void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask, - CARD32 val); -ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS); - -extern int pciMaxBusNum; - -extern pciBusInfo_t *pciBusInfo[]; - -#endif /* _PCI_H */ diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c deleted file mode 100644 index ff257a8c7..000000000 --- a/hw/xfree86/os-support/bus/Sbus.c +++ /dev/null @@ -1,636 +0,0 @@ -/* - * SBUS and OpenPROM access functions. - * - * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <fcntl.h> -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <sys/ioctl.h> -#include <sys/mman.h> -#ifdef sun -#include <sys/utsname.h> -#endif -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include "xf86sbusBus.h" -#include "xf86Sbus.h" - -int promRootNode; - -static int promFd = -1; -static int promCurrentNode; -static int promOpenCount = 0; -static int promP1275 = -1; -#define MAX_PROP 128 -#define MAX_VAL (4096-128-4) -static struct openpromio *promOpio; - -sbusDevicePtr *xf86SbusInfo = NULL; - -struct sbus_devtable sbusDeviceTable[] = { - { SBUS_DEVICE_BW2, FBTYPE_SUN2BW, "bwtwo", "Sun Monochrome (bwtwo)" }, - { SBUS_DEVICE_CG2, FBTYPE_SUN2COLOR, "cgtwo", "Sun Color2 (cgtwo)" }, - { SBUS_DEVICE_CG3, FBTYPE_SUN3COLOR, "cgthree", "Sun Color3 (cgthree)" }, - { SBUS_DEVICE_CG4, FBTYPE_SUN4COLOR, "cgfour", "Sun Color4 (cgfour)" }, - { SBUS_DEVICE_CG6, FBTYPE_SUNFAST_COLOR, "cgsix", "Sun GX" }, - { SBUS_DEVICE_CG8, FBTYPE_MEMCOLOR, "cgeight", "Sun CG8/RasterOps" }, - { SBUS_DEVICE_CG12, FBTYPE_SUNGP3, "cgtwelve", "Sun GS (cgtwelve)" }, - { SBUS_DEVICE_CG14, FBTYPE_MDICOLOR, "cgfourteen", "Sun SX" }, - { SBUS_DEVICE_GT, FBTYPE_SUNGT, "gt", "Sun Graphics Tower" }, - { SBUS_DEVICE_MGX, -1, "mgx", "Quantum 3D MGXplus" }, - { SBUS_DEVICE_LEO, FBTYPE_SUNLEO, "leo", "Sun ZX or Turbo ZX" }, - { SBUS_DEVICE_TCX, FBTYPE_TCXCOLOR, "tcx", "Sun TCX" }, - { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "ffb", "Sun FFB" }, - { SBUS_DEVICE_FFB, FBTYPE_CREATOR, "afb", "Sun Elite3D" }, - { 0, 0, NULL } -}; - -int -promGetSibling(int node) -{ - promOpio->oprom_size = sizeof(int); - - if (node == -1) return 0; - *(int *)promOpio->oprom_array = node; - if (ioctl(promFd, OPROMNEXT, promOpio) < 0) - return 0; - promCurrentNode = *(int *)promOpio->oprom_array; - return *(int *)promOpio->oprom_array; -} - -int -promGetChild(int node) -{ - promOpio->oprom_size = sizeof(int); - - if (!node || node == -1) return 0; - *(int *)promOpio->oprom_array = node; - if (ioctl(promFd, OPROMCHILD, promOpio) < 0) - return 0; - promCurrentNode = *(int *)promOpio->oprom_array; - return *(int *)promOpio->oprom_array; -} - -char * -promGetProperty(const char *prop, int *lenp) -{ - promOpio->oprom_size = MAX_VAL; - - strcpy(promOpio->oprom_array, prop); - if (ioctl(promFd, OPROMGETPROP, promOpio) < 0) - return 0; - if (lenp) *lenp = promOpio->oprom_size; - return promOpio->oprom_array; -} - -int -promGetBool(const char *prop) -{ - promOpio->oprom_size = 0; - - *(int *)promOpio->oprom_array = 0; - for (;;) { - promOpio->oprom_size = MAX_PROP; - if (ioctl(promFd, OPROMNXTPROP, promOpio) < 0) - return 0; - if (!promOpio->oprom_size) - return 0; - if (!strcmp(promOpio->oprom_array, prop)) - return 1; - } -} - -#define PROM_NODE_SIBLING 0x01 -#define PROM_NODE_PREF 0x02 -#define PROM_NODE_SBUS 0x04 -#define PROM_NODE_EBUS 0x08 -#define PROM_NODE_PCI 0x10 - -static int -promSetNode(sbusPromNodePtr pnode) -{ - int node; - - if (!pnode->node || pnode->node == -1) - return -1; - if (pnode->cookie[0] & PROM_NODE_SIBLING) - node = promGetSibling(pnode->cookie[1]); - else - node = promGetChild(pnode->cookie[1]); - if (pnode->node != node) - return -1; - return 0; -} - -static void -promIsP1275(void) -{ -#ifdef linux - FILE *f; - char buffer[1024]; - - if (promP1275 != -1) - return; - promP1275 = 0; - f = fopen("/proc/cpuinfo","r"); - if (!f) return; - while (fgets(buffer, 1024, f) != NULL) - if (!strncmp (buffer, "type", 4) && strstr (buffer, "sun4u")) { - promP1275 = 1; - break; - } - fclose(f); -#elif defined(sun) - struct utsname buffer; - - if ((uname(&buffer) >= 0) && !strcmp(buffer.machine, "sun4u")) - promP1275 = TRUE; - else - promP1275 = FALSE; -#elif defined(__FreeBSD__) - promP1275 = TRUE; -#else -#error Missing promIsP1275() function for this OS -#endif -} - -_X_EXPORT void -sparcPromClose(void) -{ - if (promOpenCount > 1) { - promOpenCount--; - return; - } - if (promFd != -1) { - close(promFd); - promFd = -1; - } - if (promOpio) { - xfree(promOpio); - promOpio = NULL; - } - promOpenCount = 0; -} - -_X_EXPORT int -sparcPromInit(void) -{ - if (promOpenCount) { - promOpenCount++; - return 0; - } - promFd = open("/dev/openprom", O_RDONLY, 0); - if (promFd == -1) - return -1; - promOpio = (struct openpromio *)xalloc(4096); - if (!promOpio) { - sparcPromClose(); - return -1; - } - promRootNode = promGetSibling(0); - if (!promRootNode) { - sparcPromClose(); - return -1; - } - promIsP1275(); - promOpenCount++; - - return 0; -} - -_X_EXPORT char * -sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp) -{ - if (promSetNode(pnode)) - return NULL; - return promGetProperty(prop, lenp); -} - -_X_EXPORT int -sparcPromGetBool(sbusPromNodePtr pnode, const char *prop) -{ - if (promSetNode(pnode)) - return 0; - return promGetBool(prop); -} - -static void -promWalkAssignNodes(int node, int oldnode, int flags, sbusDevicePtr *devicePtrs) -{ - int nextnode; - int len, sbus = flags & PROM_NODE_SBUS; - char *prop; - int devId, i, j; - sbusPromNode pNode, pNode2; - - prop = promGetProperty("device_type", &len); - if (prop && (len > 0)) do { - if (!strcmp(prop, "display")) { - prop = promGetProperty("name", &len); - if (!prop || len <= 0) - break; - while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',') - prop++; - for (i = 0; sbusDeviceTable[i].devId; i++) - if (!strcmp(prop, sbusDeviceTable[i].promName)) - break; - devId = sbusDeviceTable[i].devId; - if (!devId) - break; - if (!sbus) { - if (devId == SBUS_DEVICE_FFB) { - /* - * All /SUNW,ffb outside of SBUS tree come before all - * /SUNW,afb outside of SBUS tree in Linux. - */ - if (!strcmp(prop, "afb")) - flags |= PROM_NODE_PREF; - } else if (devId != SBUS_DEVICE_CG14) - break; - } - for (i = 0; i < 32; i++) { - if (!devicePtrs[i] || devicePtrs[i]->devId != devId) - continue; - if (devicePtrs[i]->node.node) { - if ((devicePtrs[i]->node.cookie[0] & ~PROM_NODE_SIBLING) <= - (flags & ~PROM_NODE_SIBLING)) - continue; - for (j = i + 1, pNode = devicePtrs[i]->node; j < 32; j++) { - if (!devicePtrs[j] || devicePtrs[j]->devId != devId) - continue; - pNode2 = devicePtrs[j]->node; - devicePtrs[j]->node = pNode; - pNode = pNode2; - } - } - devicePtrs[i]->node.node = node; - devicePtrs[i]->node.cookie[0] = flags; - devicePtrs[i]->node.cookie[1] = oldnode; - break; - } - break; - } - } while (0); - - prop = promGetProperty("name", &len); - if (prop && len > 0) { - if (!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) - sbus = PROM_NODE_SBUS; - } - - nextnode = promGetChild(node); - if (nextnode) - promWalkAssignNodes(nextnode, node, sbus, devicePtrs); - - nextnode = promGetSibling(node); - if (nextnode) - promWalkAssignNodes(nextnode, node, PROM_NODE_SIBLING | sbus, devicePtrs); -} - -void -sparcPromAssignNodes(void) -{ - sbusDevicePtr psdp, *psdpp; - int n, holes = 0, i, j; - FILE *f; - sbusDevicePtr devicePtrs[32]; - - (void)memset(devicePtrs, 0, sizeof(devicePtrs)); - for (psdpp = xf86SbusInfo, n = 0; (psdp = *psdpp); psdpp++, n++) { - if (psdp->fbNum != n) - holes = 1; - devicePtrs[psdp->fbNum] = psdp; - } - if (holes && (f = fopen("/proc/fb", "r")) != NULL) { - /* We could not open one of fb devices, check /proc/fb to see what - * were the types of the cards missed. */ - char buffer[64]; - int fbNum, devId; - static struct { - int devId; - char *prefix; - } procFbPrefixes[] = { - { SBUS_DEVICE_BW2, "BWtwo" }, - { SBUS_DEVICE_CG14, "CGfourteen" }, - { SBUS_DEVICE_CG6, "CGsix" }, - { SBUS_DEVICE_CG3, "CGthree" }, - { SBUS_DEVICE_FFB, "Creator" }, - { SBUS_DEVICE_FFB, "Elite 3D" }, - { SBUS_DEVICE_LEO, "Leo" }, - { SBUS_DEVICE_TCX, "TCX" }, - { 0, NULL }, - }; - - while (fscanf(f, "%d %63s\n", &fbNum, buffer) == 2) { - for (i = 0; procFbPrefixes[i].devId; i++) - if (! strncmp(procFbPrefixes[i].prefix, buffer, - strlen(procFbPrefixes[i].prefix))) - break; - devId = procFbPrefixes[i].devId; - if (! devId) continue; - if (devicePtrs[fbNum]) { - if (devicePtrs[fbNum]->devId != devId) - xf86ErrorF("Inconsistent /proc/fb with FBIOGATTR\n"); - } else if (!devicePtrs[fbNum]) { - devicePtrs[fbNum] = psdp = xnfcalloc(sizeof (sbusDevice), 1); - psdp->devId = devId; - psdp->fbNum = fbNum; - psdp->fd = -2; - } - } - fclose(f); - } - promGetSibling(0); - promWalkAssignNodes(promRootNode, 0, PROM_NODE_PREF, devicePtrs); - for (i = 0, j = 0; i < 32; i++) - if (devicePtrs[i] && devicePtrs[i]->fbNum == -1) - j++; - xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (n + j + 1)); - for (i = 0, psdpp = xf86SbusInfo; i < 32; i++) - if (devicePtrs[i]) { - if (devicePtrs[i]->fbNum == -1) { - memmove(psdpp + 1, psdpp, sizeof(psdpp) * (n + 1)); - *psdpp = devicePtrs[i]; - } else - n--; - } -} - -static char * -promGetReg(int type) -{ - char *prop; - int len; - static char regstr[40]; - - regstr[0] = 0; - prop = promGetProperty("reg", &len); - if (prop && len >= 4) { - unsigned int *reg = (unsigned int *)prop; - if (!promP1275 || (type == PROM_NODE_SBUS) || (type == PROM_NODE_EBUS)) - sprintf (regstr, "@%x,%x", reg[0], reg[1]); - else if (type == PROM_NODE_PCI) { - if ((reg[0] >> 8) & 7) - sprintf (regstr, "@%x,%x", (reg[0] >> 11) & 0x1f, (reg[0] >> 8) & 7); - else - sprintf (regstr, "@%x", (reg[0] >> 11) & 0x1f); - } else if (len == 4) - sprintf (regstr, "@%x", reg[0]); - else { - unsigned int regs[2]; - - /* Things get more complicated on UPA. If upa-portid exists, - then address is @upa-portid,second-int-in-reg, otherwise - it is @first-int-in-reg/16,second-int-in-reg (well, probably - upa-portid always exists, but just to be safe). */ - memcpy (regs, reg, sizeof(regs)); - prop = promGetProperty("upa-portid", &len); - if (prop && len == 4) { - reg = (unsigned int *)prop; - sprintf (regstr, "@%x,%x", reg[0], regs[1]); - } else - sprintf (regstr, "@%x,%x", regs[0] >> 4, regs[1]); - } - } - return regstr; -} - -static int -promWalkNode2Pathname(char *path, int parent, int node, int searchNode, int type) -{ - int nextnode; - int len, ntype = type; - char *prop, *p; - - prop = promGetProperty("name", &len); - *path = '/'; - if (!prop || len <= 0) - return 0; - if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type) - ntype = PROM_NODE_SBUS; - else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI) - ntype = PROM_NODE_EBUS; - else if (!strcmp(prop, "pci") && !type) - ntype = PROM_NODE_PCI; - strcpy (path + 1, prop); - p = promGetReg(type); - if (*p) - strcat (path, p); - if (node == searchNode) - return 1; - nextnode = promGetChild(node); - if (nextnode && - promWalkNode2Pathname(strchr(path, 0), node, nextnode, searchNode, ntype)) - return 1; - nextnode = promGetSibling(node); - if (nextnode && - promWalkNode2Pathname(path, parent, nextnode, searchNode, type)) - return 1; - return 0; -} - -char * -sparcPromNode2Pathname(sbusPromNodePtr pnode) -{ - char *ret; - - if (!pnode->node) return NULL; - ret = xalloc(4096); - if (!ret) return NULL; - if (promWalkNode2Pathname(ret, promRootNode, promGetChild(promRootNode), pnode->node, 0)) - return ret; - xfree(ret); - return NULL; -} - -static int -promWalkPathname2Node(char *name, char *regstr, int parent, int type) -{ - int len, node, ret; - char *prop, *p; - - for (;;) { - prop = promGetProperty("name", &len); - if (!prop || len <= 0) - return 0; - if ((!strcmp(prop, "sbus") || !strcmp(prop, "sbi")) && !type) - type = PROM_NODE_SBUS; - else if (!strcmp(prop, "ebus") && type == PROM_NODE_PCI) - type = PROM_NODE_EBUS; - else if (!strcmp(prop, "pci") && !type) - type = PROM_NODE_PCI; - for (node = promGetChild(parent); node; node = promGetSibling(node)) { - prop = promGetProperty("name", &len); - if (!prop || len <= 0) - continue; - if (*name && strcmp(name, prop)) - continue; - if (*regstr) { - p = promGetReg(type); - if (! *p || strcmp(p + 1, regstr)) - continue; - } - break; - } - if (!node) { - for (node = promGetChild(parent); node; node = promGetSibling(node)) { - ret = promWalkPathname2Node(name, regstr, node, type); - if (ret) return ret; - } - return 0; - } - name = strchr(regstr, 0) + 1; - if (! *name) - return node; - p = strchr(name, '/'); - if (p) - *p = 0; - else - p = strchr(name, 0); - regstr = strchr(name, '@'); - if (regstr) - *regstr++ = 0; - else - regstr = p; - if (name == regstr) - return 0; - parent = node; - } -} - -int -sparcPromPathname2Node(const char *pathName) -{ - int i; - char *name, *regstr, *p; - - i = strlen(pathName); - name = xalloc(i + 2); - if (! name) return 0; - strcpy (name, pathName); - name [i + 1] = 0; - if (name[0] != '/') - return 0; - p = strchr(name + 1, '/'); - if (p) - *p = 0; - else - p = strchr(name, 0); - regstr = strchr(name, '@'); - if (regstr) - *regstr++ = 0; - else - regstr = p; - if (name + 1 == regstr) - return 0; - promGetSibling(0); - i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0); - xfree(name); - return i; -} - -_X_EXPORT pointer -xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size) -{ - pointer ret; - unsigned long pagemask = getpagesize() - 1; - unsigned long off = offset & ~pagemask; - unsigned long len = ((offset + size + pagemask) & ~pagemask) - off; - - if (psdp->fd == -1) { - psdp->fd = open(psdp->device, O_RDWR); - if (psdp->fd == -1) - return NULL; - } else if (psdp->fd < 0) - return NULL; - - ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, - psdp->fd, off); - if (ret == (pointer) -1) { - ret = (pointer) mmap (NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, - psdp->fd, off); - } - if (ret == (pointer) -1) - return NULL; - - return (char *)ret + (offset - off); -} - -_X_EXPORT void -xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size) -{ - unsigned long mask = getpagesize() - 1; - unsigned long base = (unsigned long)addr & ~mask; - unsigned long len = (((unsigned long)addr + size + mask) & ~mask) - base; - - munmap ((pointer)base, len); -} - -/* Tell OS that we are driving the HW cursor ourselves. */ -_X_EXPORT void -xf86SbusHideOsHwCursor(sbusDevicePtr psdp) -{ - struct fbcursor fbcursor; - unsigned char zeros[8]; - - memset(&fbcursor, 0, sizeof(fbcursor)); - memset(&zeros, 0, sizeof(zeros)); - fbcursor.cmap.count = 2; - fbcursor.cmap.red = zeros; - fbcursor.cmap.green = zeros; - fbcursor.cmap.blue = zeros; - fbcursor.image = (char *)zeros; - fbcursor.mask = (char *)zeros; - fbcursor.size.x = 32; - fbcursor.size.y = 1; - fbcursor.set = FB_CUR_SETALL; - ioctl(psdp->fd, FBIOSCURSOR, &fbcursor); -} - -/* Set HW cursor colormap. */ -_X_EXPORT void -xf86SbusSetOsHwCursorCmap(sbusDevicePtr psdp, int bg, int fg) -{ - struct fbcursor fbcursor; - unsigned char red[2], green[2], blue[2]; - - memset(&fbcursor, 0, sizeof(fbcursor)); - red[0] = bg >> 16; - green[0] = bg >> 8; - blue[0] = bg; - red[1] = fg >> 16; - green[1] = fg >> 8; - blue[1] = fg; - fbcursor.cmap.count = 2; - fbcursor.cmap.red = red; - fbcursor.cmap.green = green; - fbcursor.cmap.blue = blue; - fbcursor.set = FB_CUR_SETCMAP; - ioctl(psdp->fd, FBIOSCURSOR, &fbcursor); -} diff --git a/hw/xfree86/os-support/bus/altixPCI.c b/hw/xfree86/os-support/bus/altixPCI.c deleted file mode 100644 index bab255e4d..000000000 --- a/hw/xfree86/os-support/bus/altixPCI.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file contains the glue necessary for support of SGI's Altix chipset. - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include <unistd.h> -#include "altixPCI.h" -#include "xf86.h" -#include "Pci.h" - -void xf86PreScanAltix(void) -{ - /* Nothing to see here... */ -} - -void xf86PostScanAltix(void) -{ - pciConfigPtr *pdev; - int idx, free_idx; - - /* - * Some altix pci chipsets do not expose themselves as host - * bridges. - * - * Walk the devices looking for buses for which there is not a - * corresponding pciDevice entry (ie. pciBusInfo[]->bridge is NULL). - * - * It is assumed that this indicates a root bridge for which we will - * construct a fake pci host bridge device. - */ - - pdev = xf86scanpci(0); - for (idx = 0; pdev[idx] != NULL; idx++) - ; - - free_idx = idx; - - for (idx = 0; idx < free_idx; idx++) { - pciConfigPtr dev, fakedev; - pciBusInfo_t *businfo; - - dev = pdev[idx]; - businfo = pciBusInfo[dev->busnum]; - - if (! businfo) { - /* device has no bus ... should this be an error? */ - continue; - } - - if (businfo->bridge) { - /* bus has a device ... no need for fixup */ - continue; - } - - if (free_idx >= MAX_PCI_DEVICES) - FatalError("SN: No room for fake root bridge device\n"); - - /* - * Construct a fake device and stick it at the end of the - * pdev array. Make it look like a host bridge. - */ - fakedev = xnfcalloc(1, sizeof(pciDevice)); - fakedev->tag = PCI_MAKE_TAG(dev->busnum, 0, 0);; - fakedev->busnum = dev->busnum; - fakedev->devnum = 0; - fakedev->funcnum = 0; - fakedev->fakeDevice = 1; - /* should figure out a better DEVID */ - fakedev->pci_device_vendor = DEVID(VENDOR_GENERIC, CHIP_VGA); - fakedev->pci_base_class = PCI_CLASS_BRIDGE; - - businfo->secondary = 0; - businfo->primary_bus = dev->busnum; - businfo->bridge = fakedev; - - fakedev->businfo = businfo; - - pdev[free_idx++] = fakedev; - } -} diff --git a/hw/xfree86/os-support/bus/altixPCI.h b/hw/xfree86/os-support/bus/altixPCI.h deleted file mode 100644 index 2a738f362..000000000 --- a/hw/xfree86/os-support/bus/altixPCI.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef PCI_ALTIX_H -#define PCI_ALTIX_H 1 - -#include <X11/Xdefs.h> -#include <Pci.h> - -Bool xorgProbeAltix(scanpciWrapperOpt flags); -void xf86PreScanAltix(void); -void xf86PostScanAltix(void); - -/* Some defines for PCI */ -#define VENDOR_SGI 0x10A9 -#define CHIP_TIO_CA 0x1010 -#define CHIP_PIC_PCI 0x1011 - -#endif diff --git a/hw/xfree86/os-support/bus/axpPci.c b/hw/xfree86/os-support/bus/axpPci.c deleted file mode 100644 index c59c06804..000000000 --- a/hw/xfree86/os-support/bus/axpPci.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#include <asm/unistd.h> -#include "../linux/lnx.h" /* for _iobase */ - -/* - * Alpha/Linux platform specific PCI access functions - */ -static CARD32 axpPciCfgRead(PCITAG tag, int off); -static void axpPciCfgWrite(PCITAG, int off, CARD32 val); -static void axpPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits); - -static pciBusFuncs_t axpFuncs0 = { -/* pciReadLong */ axpPciCfgRead, -/* pciWriteLong */ axpPciCfgWrite, -/* pciSetBitsLong */ axpPciCfgSetBits, -/* pciAddrHostToBus */ pciAddrNOOP, -/* pciAddrBusToHost */ pciAddrNOOP -}; - -typedef struct _axpDomainRec { - int domain, hose; - int root_bus; - unsigned long dense_io, sparse_io; - unsigned long dense_mem, sparse_mem; - IOADDRESS mapped_io; -} axpDomainRec, *axpDomainPtr; - -#define MAX_DOMAINS (MAX_PCI_BUSES / 256) -static axpDomainPtr xf86DomainInfo[MAX_DOMAINS] = { NULL, }; -static int pciNumDomains = 0; - -/* - * For debug, domain assignment can start downward from a fixed base - * (instead of up from 0) by defining FORCE_HIGH_DOMAINS. This allows - * debug of large domain numbers and sparse domain numbering on systems - * which don't have as many hoses. - */ -#if 0 -# define FORCE_HIGH_DOMAINS MAX_DOMAINS /* assign domains downward from here */ -#endif - -/* - * If FORCE_HIGH_DOMAINS is set, make sure it's not larger than the - * max domain - */ -#if defined(FORCE_HIGH_DOMAINS) && (FORCE_HIGH_DOMAINS > MAX_DOMAINS) -# undef FORCE_HIGH_DOMAINS -# define FORCE_HIGH_DOMAINS MAX_DOMAINS -#endif - -static int -axpSetupDomains(void) -{ - axpDomainRec axpDomain; - int numDomains = 0; - int hose; - -#ifndef INCLUDE_XF86_NO_DOMAIN - -#ifdef FORCE_HIGH_DOMAINS - xf86Msg(X_WARNING, - "DEBUG OPTION FORCE_HIGH_DOMAINS in use - DRI will *NOT* work\n"); - numDomains = FORCE_HIGH_DOMAINS; -#endif - - /* - * Since each hose has a different address space, hoses are a perfect - * overlay for domains, so set up one domain for each hose present - * in the system. We have to loop through all possible hoses because - * some systems allow sparse I/O controllers. - */ - for(hose = 0; hose < MAX_DOMAINS; hose++) { - axpDomain.root_bus = _iobase(IOBASE_ROOT_BUS, hose, -1, -1); - if (axpDomain.root_bus < 0) continue; - - axpDomain.hose = hose; - -#ifndef FORCE_HIGH_DOMAINS - - axpDomain.domain = axpDomain.hose = hose; - numDomains = axpDomain.domain + 1; - -#else /* FORCE_HIGH_DOMAINS */ - - axpDomain.domain = numDomains - hose - 1; - - xf86Msg(X_WARNING, - "FORCE_HIGH_DOMAINS - assigned hose %d to domain %d\n", - axpDomain.hose, axpDomain.domain); - -#endif /* FORCE_HIGH_DOMAINS */ - - axpDomain.dense_io = _iobase(IOBASE_DENSE_IO, hose, -1, -1); - axpDomain.sparse_io = _iobase(IOBASE_SPARSE_IO, hose, -1, -1); - axpDomain.mapped_io = 0; - axpDomain.dense_mem = _iobase(IOBASE_DENSE_MEM, hose, -1, -1); - axpDomain.sparse_mem = _iobase(IOBASE_SPARSE_MEM, hose, -1, -1); - - xf86DomainInfo[axpDomain.domain] = xnfalloc(sizeof(axpDomainRec)); - *(xf86DomainInfo[axpDomain.domain]) = axpDomain; - - /* - * For now, only allow a single domain (hose) on sparse i/o systems. - * - * Allowing multiple domains on sparse systems would require: - * 1) either - * a) revamping the sparse video mapping code to allow - * for multiple unrelated address regions - * -- OR -- - * b) implementing sparse mapping directly in - * xf86MapDomainMemory - * 2) revaming read/write sparse routines to correctly handle - * the solution to 1) - * 3) implementing a sparse I/O system (mapping, inX/outX) - * independent of glibc, since the glibc version only - * supports hose 0 - */ - if (axpDomain.sparse_io) { - if (_iobase(IOBASE_ROOT_BUS, hose + 1, -1, -1) >= 0) { - /* - * It's a sparse i/o system with (at least) one more hose, - * show a message indicating that video is constrained to - * hose 0 - */ - xf86Msg(X_INFO, - "Sparse I/O system - constraining video to hose 0\n"); - } - break; - } - } - -#else /* INCLUDE_XF86_NO_DOMAIN */ - - /* - * domain support is not included, so just set up a single domain (0) - * to represent the first hose so that axpPciInit will still have - * be able to set up the root bus - */ - xf86DomainInfo[0] = xnfalloc(sizeof(axpDomainRec)); - *(xf86DomainInfo[0]) = axpDomain; - numDomains = 1; - -#endif /* INCLUDE_XF86_NO_DOMAIN */ - - return numDomains; -} - -void -axpPciInit() -{ - axpDomainPtr pDomain; - int domain, bus; - - pciNumDomains = axpSetupDomains(); - - for(domain = 0; domain < pciNumDomains; domain++) { - if (!(pDomain = xf86DomainInfo[domain])) continue; - - /* - * Since any bridged buses will be behind a probed pci-pci bridge, - * only set up the root bus for each domain (hose) and the bridged - * buses will be set up as they are found. - */ - /* make a bus with both the domain and the root bus in it */ - bus = PCI_MAKE_BUS(domain, pDomain->root_bus); - pciBusInfo[bus] = xnfalloc(sizeof(pciBusInfo_t)); - (void)memset(pciBusInfo[bus], 0, sizeof(pciBusInfo_t)); - - pciBusInfo[bus]->configMech = PCI_CFG_MECH_OTHER; - pciBusInfo[bus]->numDevices = 32; - pciBusInfo[bus]->funcs = &axpFuncs0; - pciBusInfo[bus]->pciBusPriv = pDomain; - - pciNumBuses = bus + 1; - } -} - -/* - * Alpha/Linux PCI configuration space access routines - */ -static int -axpPciBusFromTag(PCITAG tag) -{ - pciBusInfo_t *pBusInfo; - axpDomainPtr pDomain; - int bus, dfn; - - bus = PCI_BUS_FROM_TAG(tag); - if ((bus >= pciNumBuses) - || !(pBusInfo = pciBusInfo[bus]) - || !(pDomain = pBusInfo->pciBusPriv) - || (pDomain->domain != PCI_DOM_FROM_TAG(tag))) return -1; - - bus = PCI_BUS_NO_DOMAIN(bus); /* should just be root_bus */ - dfn = PCI_DFN_FROM_TAG(tag); - if (_iobase(IOBASE_HOSE, -1, bus, dfn) != pDomain->hose) return -1; - - return bus; -} - -static CARD32 -axpPciCfgRead(PCITAG tag, int off) -{ - int bus, dfn; - CARD32 val = 0xffffffff; - - if ((bus = axpPciBusFromTag(tag)) >= 0) { - dfn = PCI_DFN_FROM_TAG(tag); - - syscall(__NR_pciconfig_read, bus, dfn, off, 4, &val); - } - return(val); -} - -static void -axpPciCfgWrite(PCITAG tag, int off, CARD32 val) -{ - int bus, dfn; - - if ((bus = axpPciBusFromTag(tag)) >= 0) { - dfn = PCI_DFN_FROM_TAG(tag); - syscall(__NR_pciconfig_write, bus, dfn, off, 4, &val); - } -} - -static void -axpPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits) -{ - int bus, dfn; - CARD32 val = 0xffffffff; - - if ((bus = axpPciBusFromTag(tag)) >= 0) { - dfn = PCI_DFN_FROM_TAG(tag); - - syscall(__NR_pciconfig_read, bus, dfn, off, 4, &val); - val = (val & ~mask) | (bits & mask); - syscall(__NR_pciconfig_write, bus, dfn, off, 4, &val); - } -} - -#ifndef INCLUDE_XF86_NO_DOMAIN - -/* - * Alpha/Linux addressing domain support - */ - -_X_EXPORT int -xf86GetPciDomain(PCITAG Tag) -{ - return PCI_DOM_FROM_TAG(Tag); -} - -_X_EXPORT pointer -xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, - ADDRESS Base, unsigned long Size) -{ - axpDomainPtr pDomain; - int domain = PCI_DOM_FROM_TAG(Tag); - - if ((domain < 0) || (domain >= pciNumDomains) || - !(pDomain = xf86DomainInfo[domain])) - FatalError("%s called with invalid parameters\n", __FUNCTION__); - - /* - * xf86MapVidMem already does what we need, but remember to subtract - * _bus_base() (the physical dense memory root of hose 0) since - * xf86MapVidMem is expecting an offset relative to _bus_base() rather - * than an actual physical address. - */ - return xf86MapVidMem(ScreenNum, Flags, - pDomain->dense_mem + Base - _bus_base(), Size); -} - -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - axpDomainPtr pDomain; - const int domain = dev->domain; - - if ((domain < 0) || (domain >= pciNumDomains) || - !(pDomain = xf86DomainInfo[domain])) - FatalError("%s called with invalid parameters\n", __FUNCTION__); - - /* - * Use glibc inx/outx routines for sparse I/O, so just return the - * base [this is ok since we also constrain sparse I/O systems to - * a single domain in axpSetupDomains()] - */ - if (pDomain->sparse_io) return 0; - - /* - * I/O addresses on Alpha are really just different physical memory - * addresses that the system corelogic turns into I/O commands on the - * bus, so just use xf86MapVidMem to map I/O as well, but remember - * to subtract _bus_base() (the physical dense memory root of hose 0) - * since xf86MapVidMem is expecting an offset relative to _bus_base() - * rather than an actual physical address. - * - * Map the entire I/O space (64kB) at once and only once. - */ - if (!pDomain->mapped_io) - pDomain->mapped_io = (IOADDRESS)xf86MapVidMem(-1, VIDMEM_MMIO, - pDomain->dense_io - _bus_base(), - 0x10000); - - return pDomain->mapped_io; -} - -resPtr -xf86AccResFromOS(resPtr pRes) -{ - resRange range; - int domain; - - for(domain = 0; domain < pciNumDomains; domain++) { - if (!xf86DomainInfo[domain]) continue; - - /* - * Fallback is to claim the following areas: - * - * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS - */ - - RANGE(range, 0x000c0000, 0x000effff, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - - /* - * Fallback would be to claim well known ports in the 0x0 - 0x3ff - * range along with their sparse I/O aliases, but that's too - * imprecise. Instead claim a bare minimum here. - */ - RANGE(range, 0x00000000, 0x000000ff, - RANGE_TYPE(ResExcIoBlock, domain)); /* For mainboard */ - pRes = xf86AddResToList(pRes, &range, -1); - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ - RANGE(range, 0x00000000, 0x00000000, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, 0xffffffff, 0xffffffff, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); -/* RANGE(range, 0x00000000, 0x00000000, - RANGE_TYPE(ResExcIoBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); */ - RANGE(range, 0xffffffff, 0xffffffff, - RANGE_TYPE(ResExcIoBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - } - - return pRes; -} - -#endif /* !INCLUDE_XF86_NO_DOMAIN */ - diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c deleted file mode 100644 index 57ad09b6a..000000000 --- a/hw/xfree86/os-support/bus/bsd_pci.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright © 2007 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - * Authors: - * Eric Anholt <eric@anholt.net> - * - */ - -/** - * @file bsd_pci.c - * - * This is a trivial implementation of the remaining PCI support hooks in the - * X Server that is unaware of domains. - * - * Most of even this should go away once drivers are converted and the - * old interfaces are confirmed to all be obsolete. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#include "pciaccess.h" - -static pciBusFuncs_t bsd_funcs = { - .pciAddrBusToHost = pciAddrNOOP, -}; - -static pciBusInfo_t bsd_pci = { - .configMech = PCI_CFG_MECH_OTHER, - .numDevices = 32, - .secondary = FALSE, - .primary_bus = 0, - .funcs = &bsd_funcs, - .pciBusPriv = NULL, - .bridge = NULL, -}; - -_X_EXPORT pointer -xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size) -{ - return xf86MapVidMem(ScreenNum, Flags, Base, Size); -} - -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - (void)dev; - return 0; -} - -void -bsdPciInit(void) -{ - pciNumBuses = 1; - pciBusInfo[0] = &bsd_pci; - - xf86InitVidMem(); -} diff --git a/hw/xfree86/os-support/bus/e8870PCI.c b/hw/xfree86/os-support/bus/e8870PCI.c deleted file mode 100644 index 8e0f95ac0..000000000 --- a/hw/xfree86/os-support/bus/e8870PCI.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -/* - * This file contains the glue necessary for support of Intel's E8870 chipset. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "e8870PCI.h" -#include "xf86.h" -#include "Pci.h" - -Bool -xorgProbeE8870(scanpciWrapperOpt flags) -{ - PCITAG tag; - - /* Look for an E8870's Hub interface */ - tag = PCI_MAKE_TAG(0, 0x1E, 0); - if (pciReadLong(tag, PCI_ID_REG) == DEVID(VENDOR_INTEL, CHIP_82801_P2P)) - return TRUE; - - return FALSE; -} - -void -xf86PreScanE8870(void) -{ - /* XXX Fill me in... */ - return; -} - -void -xf86PostScanE8870(void) -{ - /* XXX Fill me in... */ -} diff --git a/hw/xfree86/os-support/bus/e8870PCI.h b/hw/xfree86/os-support/bus/e8870PCI.h deleted file mode 100644 index 89726270a..000000000 --- a/hw/xfree86/os-support/bus/e8870PCI.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef PCI_E8870_H -#define PCI_E8870_H 1 - -#include <X11/Xdefs.h> -#include <Pci.h> - -Bool xorgProbeE8870(scanpciWrapperOpt flags); -void xf86PreScanE8870(void); -void xf86PostScanE8870(void); - -#endif diff --git a/hw/xfree86/os-support/bus/ix86Pci.c b/hw/xfree86/os-support/bus/ix86Pci.c deleted file mode 100644 index e54246355..000000000 --- a/hw/xfree86/os-support/bus/ix86Pci.c +++ /dev/null @@ -1,718 +0,0 @@ -/* - * ix86Pci.c - x86 PCI driver - * - * The XFree86 server PCI access functions have been reimplemented as a - * framework that allows each supported platform/OS to have their own - * platform/OS specific PCI driver. - * - * Most of the code of these functions was simply lifted from the - * Intel architecture specifric portion of the original Xfree86 - * PCI code in hw/xfree86/common_hw/xf86_PCI.C... - * - * Gary Barton - * Concurrent Computer Corporation - * garyb@gate.net - */ - -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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. - * - * This software is derived from the original XFree86 PCI code - * which includes the following copyright notices as well: - * - * Copyright 1995 by Robin Cutshaw <robin@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 the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) 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 HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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. - * - * This code is also based heavily on the code in FreeBSD-current, which was - * written by Wolfgang Stanglmeier, and contains the following copyright: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#ifdef PC98 -#define outb(port,data) _outb(port,data) -#define outl(port,data) _outl(port,data) -#define inb(port) _inb(port) -#define inl(port) _inl(port) -#endif - -#define PCI_CFGMECH2_ENABLE_REG 0xCF8 -#ifdef PC98 -#define PCI_CFGMECH2_FORWARD_REG 0xCF9 -#else -#define PCI_CFGMECH2_FORWARD_REG 0xCFA -#endif - -#define PCI_CFGMECH2_MAXDEV 16 - -#define PCI_ADDR_FROM_TAG_CFG1(tag,reg) (PCI_EN | tag | (reg & 0xfc)) -#define PCI_FORWARD_FROM_TAG(tag) PCI_BUS_FROM_TAG(tag) -#define PCI_ENABLE_FROM_TAG(tag) (0xf0 | (((tag) & 0x00000700) >> 7)) -#define PCI_ADDR_FROM_TAG_CFG2(tag,reg) (0xc000 | (((tag) & 0x0000f800) >> 3) \ - | (reg & 0xfc)) - -/* - * Intel x86 platform specific PCI access functions - */ -#if 0 -static CARD32 ix86PciReadLongSetup(PCITAG tag, int off); -static void ix86PciWriteLongSetup(PCITAG, int off, CARD32 val); -static void ix86PciSetBitsLongSetup(PCITAG, int off, CARD32 mask, CARD32 val); -static CARD32 ix86PciReadLongCFG1(PCITAG tag, int off); -static void ix86PciWriteLongCFG1(PCITAG, int off, CARD32 val); -static void ix86PciSetBitsLongCFG1(PCITAG, int off, CARD32 mask, CARD32 val); -static CARD32 ix86PciReadLongCFG2(PCITAG tag, int off); -static void ix86PciWriteLongCFG2(PCITAG, int off, CARD32 val); -static void ix86PciSetBitsLongCFG2(PCITAG, int off, CARD32 mask, CARD32 val); -#endif - -static pciBusFuncs_t ix86Funcs0 = { -#if 0 -/* pciReadLong */ ix86PciReadLongSetup, -/* pciWriteLong */ ix86PciWriteLongSetup, -/* pciSetBitsLong */ ix86PciSetBitsLongSetup, -/* pciAddrHostToBus */ pciAddrNOOP, -#endif -/* pciAddrBusToHost */ pciAddrNOOP -}; - -static pciBusFuncs_t ix86Funcs1 = { -#if 0 -/* pciReadLong */ ix86PciReadLongCFG1, -/* pciWriteLong */ ix86PciWriteLongCFG1, -/* pciSetBitsLong */ ix86PciSetBitsLongCFG1, -/* pciAddrHostToBus */ pciAddrNOOP, -#endif -/* pciAddrBusToHost */ pciAddrNOOP -}; - -static pciBusFuncs_t ix86Funcs2 = { -#if 0 -/* pciReadLong */ ix86PciReadLongCFG2, -/* pciWriteLong */ ix86PciWriteLongCFG2, -/* pciSetBitsLong */ ix86PciSetBitsLongCFG2, -/* pciAddrHostToBus */ pciAddrNOOP, -#endif -/* pciAddrBusToHost */ pciAddrNOOP -}; - -static pciBusInfo_t ix86Pci0 = { -/* configMech */ PCI_CFG_MECH_UNKNOWN, /* Set by ix86PciInit() */ -/* numDevices */ 0, /* Set by ix86PciInit() */ -/* secondary */ FALSE, -/* primary_bus */ 0, -/* funcs */ &ix86Funcs0, /* Set by ix86PciInit() */ -/* pciBusPriv */ NULL, -/* bridge */ NULL -}; - -_X_EXPORT pointer -xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size) -{ - return xf86MapVidMem(ScreenNum, Flags, Base, Size); -} - -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - (void)dev; - return 0; -} - -static Bool -ix86PciBusCheck(void) -{ -#if 0 - PCITAG tag; - CARD32 id, class; - CARD8 device; - - for (device = 0; device < ix86Pci0.numDevices; device++) { - tag = PCI_MAKE_TAG(0, device, 0); - id = (*ix86Pci0.funcs->pciReadLong)(tag, PCI_ID_REG); - - if ((CARD16)(id + 1U) <= (CARD16)1UL) - continue; - - /* The rest of this is inspired by the Linux kernel */ - class = (*ix86Pci0.funcs->pciReadLong)(tag, PCI_CLASS_REG); - - /* Ignore revision id and programming interface */ - switch (class >> 16) { - case (PCI_CLASS_PREHISTORIC << 8) | PCI_SUBCLASS_PREHISTORIC_MISC: - /* Check for vendors of known buggy chipsets */ - id &= 0x0000ffff; - if ((id == PCI_VENDOR_INTEL) || (id == PCI_VENDOR_COMPAQ)) - return TRUE; - continue; - - case (PCI_CLASS_PREHISTORIC << 8) | PCI_SUBCLASS_PREHISTORIC_VGA: - case (PCI_CLASS_DISPLAY << 8) | PCI_SUBCLASS_DISPLAY_VGA: - case (PCI_CLASS_BRIDGE << 8) | PCI_SUBCLASS_BRIDGE_HOST: - return TRUE; - - default: - break; - } - } -#endif - return FALSE; -} - -static -void ix86PciSelectCfgmech(void) -{ - static Bool beenhere = FALSE; - CARD32 mode1Res1 = 0, mode1Res2 = 0, oldVal1 = 0; - CARD8 mode2Res1 = 0, mode2Res2 = 0, oldVal2 = 0; - int stages = 0; - - if (beenhere) - return; /* Been there, done that */ - - beenhere = TRUE; - - /* - * Determine if motherboard chipset supports PCI Config Mech 1 or 2 - * We rely on xf86Info.pciFlags to tell which mechanisms to try.... - */ - switch (xf86Info.pciFlags) { - case PCIOsConfig: - case PCIProbe1: - if (!xf86EnableIO()) - return; - - xf86MsgVerb(X_INFO, 2, - "PCI: Probing config type using method 1\n"); - oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("Checking config type 1:\n" - "\tinitial value of MODE1_ADDR_REG is 0x%08x\n", oldVal1); - ErrorF("\tChecking that all bits in mask 0x7f000000 are clear\n"); - } -#endif - - /* Assuming config type 1 to start with */ - if ((oldVal1 & 0x7f000000) == 0) { - - stages |= 0x01; - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tValue indicates possibly config type 1\n"); - ErrorF("\tWriting 32-bit value 0x%08x to MODE1_ADDR_REG\n", PCI_EN); -#if 0 - ErrorF("\tWriting 8-bit value 0x00 to MODE1_ADDR_REG + 3\n"); -#endif - } -#endif - - ix86Pci0.configMech = PCI_CFG_MECH_1; - ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; - ix86Pci0.funcs = &ix86Funcs1; - - outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN); - -#if 0 - /* - * This seems to cause some Neptune-based PCI machines to switch - * from config type 1 to config type 2 - */ - outb(PCI_CFGMECH1_ADDRESS_REG + 3, 0); -#endif - mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG); - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n", - mode1Res1); - ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n"); - } -#endif - - outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); - - if (mode1Res1) { - - stages |= 0x02; - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tValue read back is non-zero, and indicates possible" - " config type 1\n"); - } -#endif - - if (ix86PciBusCheck()) { - -#ifdef DEBUGPCI - if (xf86Verbose > 2) - ErrorF("\tBus check Confirms this: "); -#endif - - xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); - xf86MsgVerb(X_INFO, 3, - "PCI: stages = 0x%02x, oldVal1 = 0x%08lx, mode1Res1" - " = 0x%08lx\n", stages, (unsigned long)oldVal1, - (unsigned long)mode1Res1); - return; - } - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tBus check fails to confirm this, continuing type 1" - " check ...\n"); - } -#endif - - } - - stages |= 0x04; - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tWriting 0xff000001 to MODE1_ADDR_REG\n"); - } -#endif - outl(PCI_CFGMECH1_ADDRESS_REG, 0xff000001); - mode1Res2 = inl(PCI_CFGMECH1_ADDRESS_REG); - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tValue read back from MODE1_ADDR_REG is 0x%08x\n", - mode1Res2); - ErrorF("\tRestoring original contents of MODE1_ADDR_REG\n"); - } -#endif - - outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); - - if ((mode1Res2 & 0x80000001) == 0x80000000) { - - stages |= 0x08; - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tValue read back has only the msb set\n" - "\tThis indicates possible config type 1\n"); - } -#endif - - if (ix86PciBusCheck()) { - -#ifdef DEBUGPCI - if (xf86Verbose > 2) - ErrorF("\tBus check Confirms this: "); -#endif - - xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); - xf86MsgVerb(X_INFO, 3, - "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" - "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", - stages, (unsigned long)oldVal1, - (unsigned long)mode1Res1, (unsigned long)mode1Res2); - return; - } - -#ifdef DEBUGPCI - if (xf86Verbose > 2) { - ErrorF("\tBus check fails to confirm this.\n"); - } -#endif - - } - } - - xf86MsgVerb(X_INFO, 3, "PCI: Standard check for type 1 failed.\n"); - xf86MsgVerb(X_INFO, 3, "PCI: stages = 0x%02x, oldVal1 = 0x%08lx,\n" - "\tmode1Res1 = 0x%08lx, mode1Res2 = 0x%08lx\n", - stages, (unsigned long)oldVal1, (unsigned long)mode1Res1, - (unsigned long)mode1Res2); - - /* Try config type 2 */ - oldVal2 = inb(PCI_CFGMECH2_ENABLE_REG); - if ((oldVal2 & 0xf0) == 0) { - ix86Pci0.configMech = PCI_CFG_MECH_2; - ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; - ix86Pci0.funcs = &ix86Funcs2; - - outb(PCI_CFGMECH2_ENABLE_REG, 0x0e); - mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG); - outb(PCI_CFGMECH2_ENABLE_REG, oldVal2); - - if (mode2Res1 == 0x0e) { - if (ix86PciBusCheck()) { - xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n"); - return; - } - } - } - break; /* } */ - - case PCIProbe2: /* { */ - if (!xf86EnableIO()) - return; - - /* The scanpci-style detection method */ - - xf86MsgVerb(X_INFO, 2, "PCI: Probing config type using method 2\n"); - - outb(PCI_CFGMECH2_ENABLE_REG, 0x00); - outb(PCI_CFGMECH2_FORWARD_REG, 0x00); - mode2Res1 = inb(PCI_CFGMECH2_ENABLE_REG); - mode2Res2 = inb(PCI_CFGMECH2_FORWARD_REG); - - if (mode2Res1 == 0 && mode2Res2 == 0) { - xf86MsgVerb(X_INFO, 2, "PCI: Config type is 2\n"); - ix86Pci0.configMech = PCI_CFG_MECH_2; - ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; - ix86Pci0.funcs = &ix86Funcs2; - return; - } - - oldVal1 = inl(PCI_CFGMECH1_ADDRESS_REG); - outl(PCI_CFGMECH1_ADDRESS_REG, PCI_EN); - mode1Res1 = inl(PCI_CFGMECH1_ADDRESS_REG); - outl(PCI_CFGMECH1_ADDRESS_REG, oldVal1); - if (mode1Res1 == PCI_EN) { - xf86MsgVerb(X_INFO, 2, "PCI: Config type is 1\n"); - ix86Pci0.configMech = PCI_CFG_MECH_1; - ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; - ix86Pci0.funcs = &ix86Funcs1; - return; - } - break; /* } */ - - case PCIForceConfig1: - if (!xf86EnableIO()) - return; - - xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 1\n"); - - ix86Pci0.configMech = PCI_CFG_MECH_1; - ix86Pci0.numDevices = PCI_CFGMECH1_MAXDEV; - ix86Pci0.funcs = &ix86Funcs1; - return; - - case PCIForceConfig2: - if (!xf86EnableIO()) - return; - - xf86MsgVerb(X_INFO, 2, "PCI: Forcing config type 2\n"); - - ix86Pci0.configMech = PCI_CFG_MECH_2; - ix86Pci0.numDevices = PCI_CFGMECH2_MAXDEV; - ix86Pci0.funcs = &ix86Funcs2; - return; - - case PCIForceNone: - break; - } - - /* No PCI found */ - ix86Pci0.configMech = PCI_CFG_MECH_UNKNOWN; - xf86MsgVerb(X_INFO, 2, "PCI: No PCI bus found or probed for\n"); -} - -#if 0 -static pciTagRec -ix86PcibusTag(CARD8 bus, CARD8 cardnum, CARD8 func) -{ - pciTagRec tag; - - tag.cfg1 = 0; - - if (func > 7 || cardnum >= pciBusInfo[bus]->numDevices) - return tag; - - switch (ix86Pci0.configMech) { - case PCI_CFG_MECH_1: - tag.cfg1 = PCI_EN | ((CARD32)bus << 16) | - ((CARD32)cardnum << 11) | - ((CARD32)func << 8); - break; - - case PCI_CFG_MECH_2: - tag.cfg2.port = 0xc000 | ((CARD16)cardnum << 8); - tag.cfg2.enable = 0xf0 | (func << 1); - tag.cfg2.forward = bus; - break; - } - - return tag; -} -#endif - -#if 0 -static CARD32 -ix86PciReadLongSetup(PCITAG Tag, int reg) -{ - ix86PciSelectCfgmech(); - return (*ix86Pci0.funcs->pciReadLong)(Tag,reg); -} - -static CARD32 -ix86PciReadLongCFG1(PCITAG Tag, int reg) -{ - CARD32 addr, data = 0; - -#ifdef DEBUGPCI - ErrorF("ix86PciReadLong 0x%lx, %d\n", Tag, reg); -#endif - - addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg); - outl(PCI_CFGMECH1_ADDRESS_REG, addr); - data = inl(PCI_CFGMECH1_DATA_REG); - outl(PCI_CFGMECH1_ADDRESS_REG, 0); - -#ifdef DEBUGPCI - ErrorF("ix86PciReadLong 0x%lx\n", data); -#endif - - return data; -} - -static CARD32 -ix86PciReadLongCFG2(PCITAG Tag, int reg) -{ - CARD32 addr, data = 0; - CARD8 forward, enable; - -#ifdef DEBUGPCI - ErrorF("ix86PciReadLong 0x%lx, %d\n", Tag, reg); -#endif - - forward = PCI_FORWARD_FROM_TAG(Tag); - enable = PCI_ENABLE_FROM_TAG(Tag); - addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg); - - outb(PCI_CFGMECH2_ENABLE_REG, enable); - outb(PCI_CFGMECH2_FORWARD_REG, forward); - data = inl((CARD16)addr); - outb(PCI_CFGMECH2_ENABLE_REG, 0); - outb(PCI_CFGMECH2_FORWARD_REG, 0); - -#ifdef DEBUGPCI - ErrorF("ix86PciReadLong 0x%lx\n", data); -#endif - - return data; -} - -static void -ix86PciWriteLongSetup(PCITAG Tag, int reg, CARD32 data) -{ - ix86PciSelectCfgmech(); - (*ix86Pci0.funcs->pciWriteLong)(Tag,reg,data); -} - -static void -ix86PciWriteLongCFG1(PCITAG Tag, int reg, CARD32 data) -{ - CARD32 addr; - - addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg); - outl(PCI_CFGMECH1_ADDRESS_REG, addr); - outl(PCI_CFGMECH1_DATA_REG, data); - outl(PCI_CFGMECH1_ADDRESS_REG, 0); -} - -static void -ix86PciWriteLongCFG2(PCITAG Tag, int reg, CARD32 data) -{ - CARD32 addr; - CARD8 forward, enable; - - forward = PCI_FORWARD_FROM_TAG(Tag); - enable = PCI_ENABLE_FROM_TAG(Tag); - addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg); - - outb(PCI_CFGMECH2_ENABLE_REG, enable); - outb(PCI_CFGMECH2_FORWARD_REG, forward); - outl((CARD16)addr, data); - outb(PCI_CFGMECH2_ENABLE_REG, 0); - outb(PCI_CFGMECH2_FORWARD_REG, 0); -} - -static void -ix86PciSetBitsLongSetup(PCITAG Tag, int reg, CARD32 mask, CARD32 val) -{ - ix86PciSelectCfgmech(); - (*ix86Pci0.funcs->pciSetBitsLong)(Tag,reg,mask,val); -} - -static void -ix86PciSetBitsLongCFG1(PCITAG Tag, int reg, CARD32 mask, CARD32 val) -{ - CARD32 addr, data = 0; - -#ifdef DEBUGPCI - ErrorF("ix86PciSetBitsLong 0x%lx, %d\n", Tag, reg); -#endif - - addr = PCI_ADDR_FROM_TAG_CFG1(Tag,reg); - outl(PCI_CFGMECH1_ADDRESS_REG, addr); - data = inl(PCI_CFGMECH1_DATA_REG); - data = (data & ~mask) | (val & mask); - outl(PCI_CFGMECH1_DATA_REG, data); - outl(PCI_CFGMECH1_ADDRESS_REG, 0); -} - -static void -ix86PciSetBitsLongCFG2(PCITAG Tag, int reg, CARD32 mask, CARD32 val) -{ - CARD32 addr, data = 0; - CARD8 enable, forward; - -#ifdef DEBUGPCI - ErrorF("ix86PciSetBitsLong 0x%lx, %d\n", Tag, reg); -#endif - - forward = PCI_FORWARD_FROM_TAG(Tag); - enable = PCI_ENABLE_FROM_TAG(Tag); - addr = PCI_ADDR_FROM_TAG_CFG2(Tag,reg); - - outb(PCI_CFGMECH2_ENABLE_REG, enable); - outb(PCI_CFGMECH2_FORWARD_REG, forward); - data = inl((CARD16)addr); - data = (data & ~mask) | (val & mask); - outl((CARD16)addr, data); - outb(PCI_CFGMECH2_ENABLE_REG, 0); - outb(PCI_CFGMECH2_FORWARD_REG, 0); -} -#endif - -void -ix86PciInit() -{ - /* Initialize pciBusInfo[] array and function pointers */ - pciNumBuses = 1; - pciBusInfo[0] = &ix86Pci0; - - /* Make sure that there is a PCI bus present. */ - ix86PciSelectCfgmech(); - if (ix86Pci0.configMech == PCI_CFG_MECH_UNKNOWN) { - pciNumBuses = 0; - pciBusInfo[0] = NULL; - } -} diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c deleted file mode 100644 index 11eb4f9e8..000000000 --- a/hw/xfree86/os-support/bus/linuxPci.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" -#include <dirent.h> - -/* - * linux platform specific PCI access functions -- using /proc/bus/pci - * needs kernel version 2.2.x - */ -static ADDRESS linuxTransAddrBusToHost(PCITAG tag, PciAddrType type, ADDRESS addr); -#if defined(__powerpc__) -static ADDRESS linuxPpcBusAddrToHostAddr(PCITAG, PciAddrType, ADDRESS); -#endif - -static pciBusFuncs_t linuxFuncs0 = { -#if defined(__powerpc__) -/* pciAddrBusToHost */ linuxPpcBusAddrToHostAddr, -#else -/* linuxTransAddrBusToHost is busted on sparc64 but the PCI rework tree - * makes it all moot, so we kludge it for now */ -#if defined(__sparc__) -/* pciAddrBusToHost */ pciAddrNOOP, -#else -/* pciAddrBusToHost */ linuxTransAddrBusToHost, -#endif /* __sparc64__ */ -#endif -}; - -static pciBusInfo_t linuxPci0 = { -/* configMech */ PCI_CFG_MECH_OTHER, -/* numDevices */ 32, -/* secondary */ FALSE, -/* primary_bus */ 0, -/* funcs */ &linuxFuncs0, -/* pciBusPriv */ NULL, -/* bridge */ NULL -}; - -static const struct pci_id_match match_host_bridge = { - PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, - (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8), - 0x0000ffff00, 0 -}; - -#ifndef INCLUDE_XF86_NO_DOMAIN -#define MAX_DOMAINS 257 -static pointer DomainMmappedIO[MAX_DOMAINS]; -#endif - -void -linuxPciInit(void) -{ - struct stat st; - -#ifndef INCLUDE_XF86_NO_DOMAIN - (void) memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO)); -#endif - - if ((xf86Info.pciFlags == PCIForceNone) || - (-1 == stat("/proc/bus/pci", &st))) { - /* when using this as default for all linux architectures, - we'll need a fallback for 2.0 kernels here */ - return; - } - pciNumBuses = 1; - pciBusInfo[0] = &linuxPci0; -} - -/** - * \bug - * The generation of the procfs file name for the domain != 0 case may not be - * correct. - */ -static int -linuxPciOpenFile(struct pci_device *dev, Bool write) -{ - static struct pci_device *last_dev = NULL; - static int fd = -1,is_write = 0; - char file[64]; - struct stat ignored; - static int is26 = -1; - - if (dev == NULL) { - return -1; - } - - if (is26 == -1) { - is26 = (stat("/sys/bus/pci", &ignored) < 0) ? 0 : 1; - } - - if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) { - if (fd != -1) { - close(fd); - fd = -1; - } - - if (is26) { - sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config", - dev->domain, dev->bus, dev->dev, dev->func); - } else { - if (dev->domain == 0) { - sprintf(file,"/proc/bus/pci/%02x", dev->bus); - if (stat(file, &ignored) < 0) { - sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x", - dev->bus, dev->dev, dev->func); - } else { - sprintf(file, "/proc/bus/pci/%02x/%02x.%1x", - dev->bus, dev->dev, dev->func); - } - } else { - sprintf(file,"/proc/bus/pci/%02x%02x", dev->domain, dev->bus); - if (stat(file, &ignored) < 0) { - sprintf(file, "/proc/bus/pci/%04x:%04x/%02x.%1x", - dev->domain, dev->bus, dev->dev, dev->func); - } else { - sprintf(file, "/proc/bus/pci/%02x%02x/%02x.%1x", - dev->domain, dev->bus, dev->dev, dev->func); - } - } - } - - if (write) { - fd = open(file,O_RDWR); - if (fd != -1) is_write = TRUE; - } else { - switch (is_write) { - case TRUE: - fd = open(file,O_RDWR); - if (fd > -1) - break; - default: - fd = open(file,O_RDONLY); - is_write = FALSE; - } - } - - last_dev = dev; - } - - return fd; -} - -/* - * This function will convert a BAR address into a host address - * suitable for passing into the mmap function of a /proc/bus - * device. - */ -ADDRESS linuxTransAddrBusToHost(PCITAG tag, PciAddrType type, ADDRESS addr) -{ - ADDRESS ret = xf86GetOSOffsetFromPCI(tag, PCI_MEM|PCI_IO, addr); - - if (ret) - return ret; - - /* - * if it is not a BAR address, it must be legacy, (or wrong) - * return it as is.. - */ - return addr; -} - - -#if defined(__powerpc__) - -#ifndef __NR_pciconfig_iobase -#define __NR_pciconfig_iobase 200 -#endif - -static ADDRESS -linuxPpcBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr) -{ - if (type == PCI_MEM) - { - ADDRESS membase = syscall(__NR_pciconfig_iobase, 1, - PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag)); - return (addr + membase); - } - else if (type == PCI_IO) - { - ADDRESS iobase = syscall(__NR_pciconfig_iobase, 2, - PCI_BUS_FROM_TAG(tag), PCI_DFN_FROM_TAG(tag)); - return (addr + iobase); - } - else return addr; -} - -#endif /* __powerpc__ */ - -#ifndef INCLUDE_XF86_NO_DOMAIN - -/* - * Compiling the following simply requires the presence of <linux/pci.c>. - * Actually running this is another matter altogether... - * - * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O - * and memory spaces through its /proc/bus/pci/BUS/DFN entry. Which one is - * determined by a prior ioctl(). - * - * For the sparc64 port, this means 2.4.12 or later. For ppc, this - * functionality is almost, but not quite there yet. Alpha and other kernel - * ports to multi-domain architectures still need to implement this. - * - * This scheme is also predicated on the use of an IOADDRESS compatible type to - * designate I/O addresses. Although IOADDRESS is defined as an unsigned - * integral type, it is actually the virtual address of, i.e. a pointer to, the - * I/O port to access. And so, the inX/outX macros in "compiler.h" need to be - * #define'd appropriately (as is done on SPARC's). - * - * Another requirement to port this scheme to another multi-domain architecture - * is to add the appropriate entries in the pciControllerSizes array below. - * - * TO DO: Address the deleterious reaction some host bridges have to master - * aborts. This is already done for secondary PCI buses, but not yet - * for accesses to primary buses (except for the SPARC port, where - * master aborts are avoided during PCI scans). - */ - -#include <linux/pci.h> - -#ifndef PCIIOC_BASE /* Ioctls for /proc/bus/pci/X/Y nodes. */ -#define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8) - -/* Get controller for PCI device. */ -#define PCIIOC_CONTROLLER (PCIIOC_BASE | 0x00) -/* Set mmap state to I/O space. */ -#define PCIIOC_MMAP_IS_IO (PCIIOC_BASE | 0x01) -/* Set mmap state to MEM space. */ -#define PCIIOC_MMAP_IS_MEM (PCIIOC_BASE | 0x02) -/* Enable/disable write-combining. */ -#define PCIIOC_WRITE_COMBINE (PCIIOC_BASE | 0x03) - -#endif - -/* This probably shouldn't be Linux-specific */ -static struct pci_device * -get_parent_bridge(struct pci_device *dev) -{ - struct pci_id_match bridge_match = { - PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, - (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8), - 0 - }; - struct pci_device *bridge; - struct pci_device_iterator *iter; - - if (dev == NULL) { - return NULL; - } - - iter = pci_id_match_iterator_create(& bridge_match); - if (iter == NULL) { - return NULL; - } - - while ((bridge = pci_device_next(iter)) != NULL) { - if (bridge->domain == dev->domain) { - const struct pci_bridge_info *info = - pci_device_get_bridge_info(bridge); - - if (info != NULL) { - if (info->secondary_bus == dev->bus) { - break; - } - } - } - } - - pci_iterator_destroy(iter); - - return bridge; -} - -/* - * This is ugly, but until I can extract this information from the kernel, - * it'll have to do. The default I/O space size is 64K, and 4G for memory. - * Anything else needs to go in this table. (PowerPC folk take note.) - * - * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here. - * - * Please keep this table in ascending vendor/device order. - */ -static const struct pciSizes { - unsigned short vendor, device; - unsigned long io_size, mem_size; -} pciControllerSizes[] = { - { - PCI_VENDOR_SUN, PCI_CHIP_PSYCHO, - 1U << 16, 1U << 31 - }, - { - PCI_VENDOR_SUN, PCI_CHIP_SCHIZO, - 1U << 24, 1U << 31 /* ??? */ - }, - { - PCI_VENDOR_SUN, PCI_CHIP_SABRE, - 1U << 24, (unsigned long)(1ULL << 32) - }, - { - PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD, - 1U << 24, (unsigned long)(1ULL << 32) - } -}; -#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0])) - -static const struct pciSizes * -linuxGetSizesStruct(const struct pci_device *dev) -{ - static const struct pciSizes default_size = { - 0, 0, 1U << 16, (unsigned long)(1ULL << 32) - }; - int i; - - /* Look up vendor/device */ - if (dev != NULL) { - for (i = 0; i < NUM_SIZES; i++) { - if ((dev->vendor_id == pciControllerSizes[i].vendor) - && (dev->device_id == pciControllerSizes[i].device)) { - return & pciControllerSizes[i]; - } - } - } - - /* Default to 64KB I/O and 4GB memory. */ - return & default_size; -} - -static __inline__ unsigned long -linuxGetIOSize(const struct pci_device *dev) -{ - const struct pciSizes * const sizes = linuxGetSizesStruct(dev); - return sizes->io_size; -} - -static pointer -linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size, int mmap_ioctl) -{ - /* Align to page boundary */ - const ADDRESS realBase = Base & ~(getpagesize() - 1); - const ADDRESS Offset = Base - realBase; - - do { - unsigned char *result; - int fd, mmapflags, prot; - - xf86InitVidMem(); - - /* If dev is NULL, linuxPciOpenFile will return -1, and this routine - * will fail gracefully. - */ - prot = ((Flags & VIDMEM_READONLY) == 0); - if (((fd = linuxPciOpenFile(dev, prot)) < 0) || - (ioctl(fd, mmap_ioctl, 0) < 0)) - break; - -/* Note: IA-64 doesn't compile this and doesn't need to */ -#ifdef __ia64__ - -# ifndef MAP_WRITECOMBINED -# define MAP_WRITECOMBINED 0x00010000 -# endif -# ifndef MAP_NONCACHED -# define MAP_NONCACHED 0x00020000 -# endif - - if (Flags & VIDMEM_FRAMEBUFFER) - mmapflags = MAP_SHARED | MAP_WRITECOMBINED; - else - mmapflags = MAP_SHARED | MAP_NONCACHED; - -#else /* !__ia64__ */ - - mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER; - - if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0) - break; - - mmapflags = MAP_SHARED; - -#endif /* ?__ia64__ */ - - - if (Flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase); - - if (!result || ((pointer)result == MAP_FAILED)) - return NULL; - - xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result); - - return result + Offset; - } while (0); - - if (mmap_ioctl == PCIIOC_MMAP_IS_MEM) - return xf86MapVidMem(ScreenNum, Flags, Base, Size); - - return NULL; -} - -static int -linuxOpenLegacy(struct pci_device *dev, char *name) -{ - static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s"; - char path[sizeof(PREFIX) + 10]; - int fd = -1; - - while (dev != NULL) { - snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name); - fd = open(path, O_RDWR); - if (fd >= 0) { - return fd; - } - - dev = get_parent_bridge(dev); - } - - return fd; -} - -/* - * xf86MapDomainMemory - memory map PCI domain memory - * - * This routine maps the memory region in the domain specified by Tag and - * returns a pointer to it. The pointer is saved for future use if it's in - * the legacy ISA memory space (memory in a domain between 0 and 1MB). - */ -_X_EXPORT pointer -xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size) -{ - int fd = -1; - pointer addr; - - /* - * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs - * legacy_mem interface is unavailable. - */ - if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0)) - return linuxMapPci(ScreenNum, Flags, dev, Base, Size, - PCIIOC_MMAP_IS_MEM); - else - addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base); - - if (fd >= 0) - close(fd); - if (addr == NULL || addr == MAP_FAILED) { - perror("mmap failure"); - FatalError("xf86MapDomainMem(): mmap() failure\n"); - } - return addr; -} - -/** - * Map I/O space in this domain - * - * Each domain has a legacy ISA I/O space. This routine will try to - * map it using the Linux sysfs legacy_io interface. If that fails, - * it'll fall back to using /proc/bus/pci. - * - * If the legacy_io interface \b does exist, the file descriptor (\c fd below) - * will be saved in the \c DomainMmappedIO array in the upper bits of the - * pointer. Callers will do I/O with small port numbers (<64k values), so - * the platform I/O code can extract the port number and the \c fd, \c lseek - * to the port number in the legacy_io file, and issue the read or write. - * - * This has no means of returning failure, so all errors are fatal - */ -IOADDRESS -xf86MapLegacyIO(struct pci_device *dev) -{ - const int domain = dev->domain; - struct pci_device *bridge = get_parent_bridge(dev); - int fd; - - if (domain >= MAX_DOMAINS) - FatalError("xf86MapLegacyIO(): domain out of range\n"); - - if (DomainMmappedIO[domain] == NULL) { - /* Permanently map all of I/O space */ - fd = linuxOpenLegacy(bridge, "legacy_io"); - if (fd < 0) { - DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge, - 0, linuxGetIOSize(bridge), - PCIIOC_MMAP_IS_IO); - } - else { /* legacy_io file exists, encode fd */ - DomainMmappedIO[domain] = (pointer)(fd << 24); - } - } - - return (IOADDRESS)DomainMmappedIO[domain]; -} - -resPtr -xf86AccResFromOS(resPtr pRes) -{ - struct pci_device *dev; - struct pci_device_iterator *iter; - resRange range; - - iter = pci_id_match_iterator_create(& match_host_bridge); - while ((dev = pci_device_next(iter)) != NULL) { - const int domain = dev->domain; - const struct pciSizes * const sizes = linuxGetSizesStruct(dev); - - /* - * At minimum, the top and bottom resources must be claimed, so - * that resources that are (or appear to be) unallocated can be - * relocated. - */ - RANGE(range, 0x00000000u, 0x0009ffffu, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, 0x000c0000u, 0x000effffu, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, 0x000f0000u, 0x000fffffu, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - - RANGE(range, (ADDRESS)(sizes->mem_size - 1), - (ADDRESS)(sizes->mem_size - 1), - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - - RANGE(range, 0x00000000u, 0x00000000u, - RANGE_TYPE(ResExcIoBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, (IOADDRESS)(sizes->io_size - 1), - (IOADDRESS)(sizes->io_size - 1), - RANGE_TYPE(ResExcIoBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - - /* FIXME: The old code reserved domain 0 for a special purpose. The - * FIXME: new code just uses whatever domains the kernel tells it, - * FIXME: but there is no way to get a domain < 0. What should - * FIXME: happen here? - * - if (domain <= 0) - break; - */ - } - - pci_iterator_destroy(iter); - - return pRes; -} - -#endif /* !INCLUDE_XF86_NO_DOMAIN */ diff --git a/hw/xfree86/os-support/bus/ppcPci.c b/hw/xfree86/os-support/bus/ppcPci.c deleted file mode 100644 index 49c1a2a39..000000000 --- a/hw/xfree86/os-support/bus/ppcPci.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * ppcPci.c - PowerPC PCI access functions - * - * PCI driver functions supporting Motorola PowerPC platforms - * including Powerstack(RiscPC/RiscPC+), PowerStackII, MTX, and - * MVME 160x/260x/360x/460x VME boards - * - * Gary Barton - * Concurrent Computer Corporation - * garyb@gate.net - * - */ - -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include "compiler.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#ifndef MAP_FAILED -#define MAP_FAILED (pointer)(-1) -#endif - -void -ppcPciInit() -{ - - static void motoppcPciInit(void); - motoppcPciInit(); - -} diff --git a/hw/xfree86/os-support/bus/sparcPci.c b/hw/xfree86/os-support/bus/sparcPci.c deleted file mode 100644 index 2d8039c29..000000000 --- a/hw/xfree86/os-support/bus/sparcPci.c +++ /dev/null @@ -1,979 +0,0 @@ -/* - * Copyright (C) 2001-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "Pci.h" -#include "xf86sbusBus.h" - -#if defined(sun) - -extern char *apertureDevName; -static int apertureFd = -1; - -/* - * A version of xf86MapVidMem() that allows for 64-bit displacements (but not - * sizes). Areas thus mapped can be unmapped by xf86UnMapVidMem(). - */ -static pointer -sparcMapAperture(int iScreen, int Flags, - unsigned long long Base, unsigned long Size) -{ - pointer result; - static int lastFlags = 0; - - /* Assume both Base & Size are multiples of the page size */ - - if ((apertureFd < 0) || (Flags != lastFlags)) { - if (apertureFd >= 0) - close(apertureFd); - lastFlags = Flags; - apertureFd = open(apertureDevName, - (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (apertureFd < 0) - FatalError("sparcMapAperture: open failure: %s\n", - strerror(errno)); - } - - result = mmap(NULL, Size, - (Flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, apertureFd, (off_t)Base); - - if (result == MAP_FAILED) - FatalError("sparcMapAperture: mmap failure: %s\n", strerror(errno)); - - return result; -} - -/* - * Platform-specific bus privates. - */ -typedef struct _sparcDomainRec { - unsigned long long io_addr, io_size; - unsigned long long mem_addr, mem_size; - pointer pci, io; - int bus_min, bus_max; - unsigned char dfn_mask[256 / 8]; -} sparcDomainRec, *sparcDomainPtr; - -#define SetBitInMap(bit, map) \ - do { \ - int _bit = (bit); \ - (map)[_bit >> 3] |= 1 << (_bit & 7); \ - } while (0) - -#define IsBitSetInMap(bit, map) \ - ((map)[(bit) >> 3] & (1 << ((bit) & 7))) - -/* - * Domain 0 is reserved for the one that represents the system as a whole, i.e. - * the one without any resource relocations. - */ -#define MAX_DOMAINS (MAX_PCI_BUSES / 256) -static sparcDomainPtr xf86DomainInfo[MAX_DOMAINS]; -static int pciNumDomains = 1; - -/* Variables that are assigned this must be declared volatile */ -#define PciReg(base, tag, off, type) \ - *(volatile type *)(pointer)((char *)(base) + \ - (PCI_TAG_NO_DOMAIN(tag) | (off))) - -/* Generic SPARC PCI access functions */ -static CARD32 -sparcPciCfgRead32(PCITAG tag, int off) -{ - pciBusInfo_t *pBusInfo; - sparcDomainPtr pDomain; - volatile CARD32 result = (CARD32)(-1); /* Must be volatile */ - int bus; - - if ((off >= 0) && (off <= 252) && !(off & 3) && - ((bus = PCI_BUS_FROM_TAG(tag)) < pciNumBuses) && - (pBusInfo = pciBusInfo[bus]) && (pDomain = pBusInfo->pciBusPriv) && - (bus >= pDomain->bus_min) && (bus < pDomain->bus_max) && - ((bus > pDomain->bus_min) || - IsBitSetInMap(PCI_DFN_FROM_TAG(tag), pDomain->dfn_mask))) { - result = PciReg(pDomain->pci, tag, off, CARD32); - - result = PCI_CPU(result); - } - - return result; -} - -static void -sparcPciCfgWrite32(PCITAG tag, int off, CARD32 val) -{ - pciBusInfo_t *pBusInfo; - sparcDomainPtr pDomain; - int bus; - - if ((off < 0) || (off > 252) || (off & 3) || - ((bus = PCI_BUS_FROM_TAG(tag)) >= pciNumBuses) || - !(pBusInfo = pciBusInfo[bus]) || !(pDomain = pBusInfo->pciBusPriv) || - (bus < pDomain->bus_min) || (bus >= pDomain->bus_max) || - ((bus == pDomain->bus_min) && - !IsBitSetInMap(PCI_DFN_FROM_TAG(tag), pDomain->dfn_mask))) - return; - - val = PCI_CPU(val); - PciReg(pDomain->pci, tag, off, CARD32) = val; -} - -static void -sparcPciCfgSetBits32(PCITAG tag, int off, CARD32 mask, CARD32 bits) -{ - CARD32 PciVal; - - PciVal = sparcPciCfgRead32(tag, off); - PciVal &= ~mask; - PciVal |= bits; - sparcPciCfgWrite32(tag, off, PciVal); -} - -static pciBusFuncs_t sparcPCIFunctions = -{ - sparcPciCfgRead32, - sparcPciCfgWrite32, - sparcPciCfgSetBits32, - pciAddrNOOP, - pciAddrNOOP -}; - -/* - * Sabre-specific versions of the above because of its peculiar access size - * requirements. - */ -static CARD32 -sabrePciCfgRead32(PCITAG tag, int off) -{ - pciBusInfo_t *pBusInfo; - sparcDomainPtr pDomain; - volatile CARD32 result; /* Must be volatile */ - int bus; - - if (PCI_BDEV_FROM_TAG(tag)) - return sparcPciCfgRead32(tag, off); - - if (PCI_FUNC_FROM_TAG(tag) || (off < 0) || (off > 252) || (off & 3) || - ((bus = PCI_BUS_FROM_TAG(tag)) >= pciNumBuses) || - !(pBusInfo = pciBusInfo[bus]) || !(pDomain = pBusInfo->pciBusPriv) || - (bus != pDomain->bus_min)) - return (CARD32)(-1); - - if (off < 8) { - result = (PciReg(pDomain->pci, tag, off, CARD16) << 16) | - PciReg(pDomain->pci, tag, off + 2, CARD16); - return PCI_CPU(result); - } - - result = (PciReg(pDomain->pci, tag, off + 3, CARD8) << 24) | - (PciReg(pDomain->pci, tag, off + 2, CARD8) << 16) | - (PciReg(pDomain->pci, tag, off + 1, CARD8) << 8) | - (PciReg(pDomain->pci, tag, off , CARD8) ); - return result; -} - -static void -sabrePciCfgWrite32(PCITAG tag, int off, CARD32 val) -{ - pciBusInfo_t *pBusInfo; - sparcDomainPtr pDomain; - int bus; - - if (PCI_BDEV_FROM_TAG(tag)) - sparcPciCfgWrite32(tag, off, val); - else if (!PCI_FUNC_FROM_TAG(tag) && - (off >= 0) && (off <= 252) && !(off & 3) && - ((bus = PCI_BUS_FROM_TAG(tag)) < pciNumBuses) && - (pBusInfo = pciBusInfo[bus]) && - (pDomain = pBusInfo->pciBusPriv) && - (bus == pDomain->bus_min)) { - if (off < 8) { - val = PCI_CPU(val); - PciReg(pDomain->pci, tag, off , CARD16) = val >> 16; - PciReg(pDomain->pci, tag, off + 2, CARD16) = val; - } else { - PciReg(pDomain->pci, tag, off , CARD8) = val; - PciReg(pDomain->pci, tag, off + 1, CARD8) = val >> 8; - PciReg(pDomain->pci, tag, off + 2, CARD8) = val >> 16; - PciReg(pDomain->pci, tag, off + 3, CARD8) = val >> 24; - } - } -} - -static void -sabrePciCfgSetBits32(PCITAG tag, int off, CARD32 mask, CARD32 bits) -{ - CARD32 PciVal; - - PciVal = sabrePciCfgRead32(tag, off); - PciVal &= ~mask; - PciVal |= bits; - sabrePciCfgWrite32(tag, off, PciVal); -} - -static pciBusFuncs_t sabrePCIFunctions = -{ - sabrePciCfgRead32, - sabrePciCfgWrite32, - sabrePciCfgSetBits32, - pciAddrNOOP, - pciAddrNOOP -}; - -static int pagemask; - -/* Scan PROM for all PCI host bridges in the system */ -void -sparcPciInit(void) -{ - int node, node2; - - if (!xf86LinearVidMem()) - return; - - apertureFd = open(apertureDevName, O_RDWR); - if (apertureFd < 0) { - xf86Msg(X_ERROR, - "sparcPciInit: open failure: %s\n", strerror(errno)); - return; - } - - sparcPromInit(); - pagemask = getpagesize() - 1; - - for (node = promGetChild(promRootNode); - node; - node = promGetSibling(node)) { - unsigned long long pci_addr; - sparcDomainRec domain; - sparcDomainPtr pDomain; - pciBusFuncs_p pFunctions; - char *prop_val; - int prop_len, bus; - - prop_val = promGetProperty("name", &prop_len); - /* Some PROMs include the trailing null; some don't */ - if (!prop_val || (prop_len < 3) || (prop_len > 4) || - strcmp(prop_val, "pci")) - continue; - - prop_val = promGetProperty("model", &prop_len); - if (!prop_val || (prop_len <= 0)) { - prop_val = promGetProperty("compatible", &prop_len); - if (!prop_val || (prop_len <= 0)) - continue; - } - - pFunctions = &sparcPCIFunctions; - (void)memset(&domain, 0, sizeof(domain)); - - if (!strncmp("SUNW,sabre", prop_val, prop_len) || - !strncmp("pci108e,a000", prop_val, prop_len) || - !strncmp("pci108e,a001", prop_val, prop_len)) { - /* - * There can only be one "Sabre" bridge in a system. It provides - * PCI configuration space, a 24-bit I/O space and a 32-bit memory - * space, all three of which are at fixed physical CPU addresses. - */ - static Bool sabre_seen = FALSE; - - xf86Msg(X_INFO, - "Sabre or Hummingbird PCI host bridge found (\"%s\")\n", - prop_val); - - /* There can only be one Sabre */ - if (sabre_seen) - continue; - sabre_seen = TRUE; - - /* Get "bus-range" property */ - prop_val = promGetProperty("bus-range", &prop_len); - if (!prop_val || (prop_len != 8) || - (((unsigned int *)prop_val)[0]) || - (((unsigned int *)prop_val)[1] >= 256)) - continue; - - pci_addr = 0x01fe01000000ull; - domain.io_addr = 0x01fe02000000ull; - domain.io_size = 0x000001000000ull; - domain.mem_addr = 0x01ff00000000ull; - domain.mem_size = 0x000100000000ull; - domain.bus_min = 0; /* Always */ - domain.bus_max = ((int *)prop_val)[1]; - - pFunctions = &sabrePCIFunctions; - } else - if (!strncmp("SUNW,psycho", prop_val, prop_len) || - !strncmp("pci108e,8000", prop_val, prop_len)) { - /* - * A "Psycho" host bridge provides two PCI interfaces, each with - * its own 16-bit I/O and 31-bit memory spaces. Both share the - * same PCI configuration space. Here, they are assigned separate - * domain numbers to prevent unintentional I/O and/or memory - * resource conflicts. - */ - xf86Msg(X_INFO, - "Psycho PCI host bridge found (\"%s\")\n", prop_val); - - /* Get "bus-range" property */ - prop_val = promGetProperty("bus-range", &prop_len); - if (!prop_val || (prop_len != 8) || - (((unsigned int *)prop_val)[1] >= 256) || - (((unsigned int *)prop_val)[0] > ((unsigned int *)prop_val)[1])) - continue; - - domain.bus_min = ((int *)prop_val)[0]; - domain.bus_max = ((int *)prop_val)[1]; - - /* Get "ranges" property */ - prop_val = promGetProperty("ranges", &prop_len); - if (!prop_val || (prop_len != 112) || - prop_val[0] || (prop_val[28] != 0x01u) || - (prop_val[56] != 0x02u) || (prop_val[84] != 0x03u) || - (((unsigned int *)prop_val)[4] != 0x01000000u) || - ((unsigned int *)prop_val)[5] || - ((unsigned int *)prop_val)[12] || - (((unsigned int *)prop_val)[13] != 0x00010000u) || - ((unsigned int *)prop_val)[19] || - (((unsigned int *)prop_val)[20] != 0x80000000u) || - ((((unsigned int *)prop_val)[11] & ~0x00010000u) != - 0x02000000u) || - (((unsigned int *)prop_val)[18] & ~0x80000000u) || - (((unsigned int *)prop_val)[3] != - ((unsigned int *)prop_val)[10]) || - (((unsigned int *)prop_val)[17] != - ((unsigned int *)prop_val)[24]) || - (((unsigned int *)prop_val)[18] != - ((unsigned int *)prop_val)[25]) || - (((unsigned int *)prop_val)[19] != - ((unsigned int *)prop_val)[26]) || - (((unsigned int *)prop_val)[20] != - ((unsigned int *)prop_val)[27])) - continue; - - /* Use memcpy() to avoid alignment issues */ - (void)memcpy(&pci_addr, prop_val + 12, - sizeof(pci_addr)); - (void)memcpy(&domain.io_addr, prop_val + 40, - sizeof(domain.io_addr)); - (void)memcpy(&domain.mem_addr, prop_val + 68, - sizeof(domain.mem_addr)); - - domain.io_size = 0x000000010000ull; - domain.mem_size = 0x000080000000ull; - } else - if (!strncmp("SUNW,schizo", prop_val, prop_len) || - !strncmp("pci108e,8001", prop_val, prop_len)) { - /* - * I have no docs on the "Schizo", but judging from the Linux - * kernel, it also provides two PCI domains. Each PCI - * configuration space is the usual 16M in size, followed by a - * variable-length I/O space. Each domain also provides a - * variable-length memory space. The kernel seems to think the I/O - * spaces are 16M long, and the memory spaces, 2G, but these - * assumptions are actually only present in source code comments. - * Sun has, however, confirmed to me the validity of these - * assumptions. - */ - volatile unsigned long long mem_match, mem_mask, io_match, io_mask; - unsigned long Offset; - pointer pSchizo; - - xf86Msg(X_INFO, - "Schizo PCI host bridge found (\"%s\")\n", prop_val); - - /* Get "bus-range" property */ - prop_val = promGetProperty("bus-range", &prop_len); - if (!prop_val || (prop_len != 8) || - (((unsigned int *)prop_val)[1] >= 256) || - (((unsigned int *)prop_val)[0] > ((unsigned int *)prop_val)[1])) - continue; - - domain.bus_min = ((int *)prop_val)[0]; - domain.bus_max = ((int *)prop_val)[1]; - - /* Get "reg" property */ - prop_val = promGetProperty("reg", &prop_len); - if (!prop_val || (prop_len != 48)) - continue; - - /* Temporarily map some of Schizo's registers */ - pSchizo = sparcMapAperture(-1, VIDMEM_MMIO, - ((unsigned long long *)prop_val)[2] - 0x000000010000ull, - 0x00010000ul); - - /* Determine where PCI config, I/O and memory spaces reside */ - if ((((unsigned long long *)prop_val)[0] & 0x000000700000ull) == - 0x000000600000ull) - Offset = 0x0040; - else - Offset = 0x0060; - - mem_match = PciReg(pSchizo, 0, Offset, unsigned long long); - mem_mask = PciReg(pSchizo, 0, Offset + 8, unsigned long long); - io_match = PciReg(pSchizo, 0, Offset + 16, unsigned long long); - io_mask = PciReg(pSchizo, 0, Offset + 24, unsigned long long); - - /* Unmap Schizo registers */ - xf86UnMapVidMem(-1, pSchizo, 0x00010000ul); - - /* Calculate sizes */ - mem_mask = (((mem_mask - 1) ^ mem_mask) >> 1) + 1; - io_mask = (((io_mask - 1) ^ io_mask ) >> 1) + 1; - - if (io_mask <= 0x000001000000ull) /* Nothing left for I/O */ - continue; - - domain.mem_addr = mem_match & ~0x8000000000000000ull; - domain.mem_size = mem_mask; - pci_addr = io_match & ~0x8000000000000000ull; - domain.io_addr = pci_addr + 0x0000000001000000ull; - domain.io_size = io_mask - 0x0000000001000000ull; - } else { - xf86Msg(X_WARNING, "Unknown PCI host bridge: \"%s\"\n", prop_val); - continue; - } - - /* Only map as much PCI configuration as we need */ - domain.pci = (char *)sparcMapAperture(-1, VIDMEM_MMIO, - pci_addr + PCI_MAKE_TAG(domain.bus_min, 0, 0), - PCI_MAKE_TAG(domain.bus_max - domain.bus_min + 1, 0, 0)) - - PCI_MAKE_TAG(domain.bus_min, 0, 0); - - /* Allocate a domain record */ - pDomain = xnfalloc(sizeof(sparcDomainRec)); - *pDomain = domain; - - /* - * Allocate and prime pciBusInfo records. These are allocated one at a - * time because those for empty buses are eventually released. - */ - bus = pDomain->bus_min = - PCI_MAKE_BUS(pciNumDomains, domain.bus_min); - pciNumBuses = pDomain->bus_max = - PCI_MAKE_BUS(pciNumDomains, domain.bus_max) + 1; - - pciBusInfo[bus] = xnfcalloc(1, sizeof(pciBusInfo_t)); - pciBusInfo[bus]->configMech = PCI_CFG_MECH_OTHER; - pciBusInfo[bus]->numDevices = 32; - pciBusInfo[bus]->funcs = pFunctions; - pciBusInfo[bus]->pciBusPriv = pDomain; - while (++bus < pciNumBuses) { - pciBusInfo[bus] = xnfalloc(sizeof(pciBusInfo_t)); - *(pciBusInfo[bus]) = *(pciBusInfo[bus - 1]); - pciBusInfo[bus]->funcs = &sparcPCIFunctions; - } - - /* Next domain, please... */ - xf86DomainInfo[pciNumDomains++] = pDomain; - - /* - * OK, enough of the straight-forward stuff. Time to deal with some - * brokenness... - * - * The PCI specs require that when a bus transaction remains unclaimed - * for too long, the master entity on that bus is to cancel the - * transaction it issued or passed on with a master abort. Two - * outcomes are possible: - * - * - the master abort can be treated as an error that is propogated - * back through the bus tree to the entity that ultimately originated - * the transaction; or - * - the transaction can be allowed to complete normally, which means - * that writes are ignored and reads return all ones. - * - * In the first case, if the CPU happens to be at the tail end of the - * tree path through one of its host bridges, it will be told there is - * a hardware mal-function, despite being generated by software. - * - * For a software function (be it firmware, OS or userland application) - * to determine how a PCI bus tree is populated, it must be able to - * detect when master aborts occur. Obviously, PCI discovery is much - * simpler when master aborts are allowed to complete normally. - * - * Unfortunately, a number of non-Intel PCI implementations have chosen - * to treat master aborts as severe errors. The net effect is to - * cripple PCI discovery algorithms in userland. - * - * On SPARCs, master aborts cause a number of different behaviours, - * including delivering a signal to the userland application, rebooting - * the system, "dropping down" to firmware, or, worst of all, bus - * lockouts. Even in the first case, the SIGBUS signal that is - * eventually generated isn't delivered in a timely enough fashion to - * allow an application to reliably detect the master abort that - * ultimately caused it. - * - * This can be somewhat mitigated. On all architectures, master aborts - * that occur on secondary buses can be forced to complete normally - * because the PCI-to-PCI bridges that serve them are governed by an - * industry-wide specification. (This is just another way of saying - * that whatever justification there might be for erroring out master - * aborts is deemed by the industry as insufficient to generate more - * PCI non-compliance than there already is...) - * - * This leaves us with master aborts that occur on primary buses. - * There is no specification for host-to-PCI bridges. Bridges used in - * SPARCs can be told to ignore all PCI errors, but not specifically - * master aborts. Not only is this too coarse-grained, but - * master-aborted read transactions on the primary bus end up returning - * garbage rather than all ones. - * - * I have elected to work around this the only way I can think of doing - * so right now. The following scans an additional PROM level and - * builds a device/function map for the primary bus. I can only hope - * this PROM information represents all devices on the primary bus, - * rather than only a subset of them. - * - * Master aborts are useful in other ways too, that are not addressed - * here. These include determining whether or not a domain provides - * VGA, or if a PCI device actually implements PCI disablement. - * - * --- TSI @ UQV 2001.09.19 - */ - for (node2 = promGetChild(node); - node2; - node2 = promGetSibling(node2)) { - /* Get "reg" property */ - prop_val = promGetProperty("reg", &prop_len); - if (!prop_val || (prop_len % 20)) - continue; - - /* - * It's unnecessary to scan the entire "reg" property, but I'll do - * so anyway. - */ - prop_len /= 20; - for (; prop_len--; prop_val += 20) - SetBitInMap(PCI_DFN_FROM_TAG(*(PCITAG *)prop_val), - pDomain->dfn_mask); - } - - /* Assume the host bridge is device 0, function 0 on its bus */ - SetBitInMap(0, pDomain->dfn_mask); - } - - sparcPromClose(); - - close(apertureFd); - apertureFd = -1; -} - -#ifndef INCLUDE_XF86_NO_DOMAIN - -_X_EXPORT int -xf86GetPciDomain(PCITAG Tag) -{ - return PCI_DOM_FROM_TAG(Tag); -} - -_X_EXPORT pointer -xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag, - ADDRESS Base, unsigned long Size) -{ - sparcDomainPtr pDomain; - pointer result; - int domain = PCI_DOM_FROM_TAG(Tag); - - if ((domain <= 0) || (domain >= pciNumDomains) || - !(pDomain = xf86DomainInfo[domain]) || - (((unsigned long long)Base + (unsigned long long)Size) > - pDomain->mem_size)) - FatalError("xf86MapDomainMemory() called with invalid parameters.\n"); - - result = sparcMapAperture(ScreenNum, Flags, pDomain->mem_addr + Base, Size); - - if (apertureFd >= 0) { - close(apertureFd); - apertureFd = -1; - } - - return result; -} - -_X_EXPORT IOADDRESS -xf86MapLegacyIO(int ScreenNum, int Flags, PCITAG Tag, - IOADDRESS Base, unsigned long Size) -{ - sparcDomainPtr pDomain; - int domain = PCI_DOM_FROM_TAG(Tag); - - if ((domain <= 0) || (domain >= pciNumDomains) || - !(pDomain = xf86DomainInfo[domain]) || - (((unsigned long long)Base + (unsigned long long)Size) > - pDomain->io_size)) - FatalError("xf86MapLegacyIO() called with invalid parameters.\n"); - - /* Permanently map all of I/O space */ - if (!pDomain->io) { - pDomain->io = sparcMapAperture(ScreenNum, Flags, - pDomain->io_addr, pDomain->io_size); - - if (apertureFd >= 0) { - close(apertureFd); - apertureFd = -1; - } - } - - return (IOADDRESS)pDomain->io + Base; -} - -resPtr -xf86AccResFromOS(resPtr pRes) -{ - sparcDomainPtr pDomain; - resRange range; - int domain; - - for (domain = 1; domain < pciNumDomains; domain++) { - if (!(pDomain = xf86DomainInfo[domain])) - continue; - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ - RANGE(range, 0x00000000u, 0x0009ffffu, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, 0x000c0000u, 0x000effffu, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, 0x000f0000u, 0x000fffffu, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - - RANGE(range, pDomain->mem_size - 1, pDomain->mem_size - 1, - RANGE_TYPE(ResExcMemBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - - RANGE(range, 0x00000000u, 0x00000000u, - RANGE_TYPE(ResExcIoBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - RANGE(range, pDomain->io_size - 1, pDomain->io_size - 1, - RANGE_TYPE(ResExcIoBlock, domain)); - pRes = xf86AddResToList(pRes, &range, -1); - } - - return pRes; -} - -#endif /* !INCLUDE_XF86_NO_DOMAIN */ - -#endif /* defined(sun) */ - -#if defined(ARCH_PCI_PCI_BRIDGE) - -/* Definitions specific to Sun's APB P2P bridge (a.k.a. Simba) */ -#define APB_IO_ADDRESS_MAP 0xDE -#define APB_MEM_ADDRESS_MAP 0xDF - -/* - * Simba's can only occur on bus 0. Furthermore, Simba's must have a non-zero - * device/function number because the Sabre interface they must connect to - * occupies the 0:0:0 slot. Also, there can be only one Sabre interface in the - * system, and therefore, only one Simba function can route any particular - * resource. Thus, it is appropriate to use a single set of static variables - * to hold the tag of the Simba function routing a VGA resource range at any - * one time, and to test these variables for non-zero to determine whether or - * not the Sabre would master-abort a VGA access (and kill the system). - * - * The trick is to determine when it is safe to re-route VGA, because doing so - * re-routes much more. - */ -static PCITAG simbavgaIOTag = 0, simbavgaMemTag = 0; -static Bool simbavgaRoutingAllow = TRUE; - -/* - * Scan the bus subtree rooted at 'bus' for a non-display device that might be - * decoding the bottom 2 MB of I/O space and/or the bottom 512 MB of memory - * space. Reset simbavgaRoutingAllow if such a device is found. - * - * XXX For now, this is very conservative and should be made less so as the - * need arises. - */ -static void -simbaCheckBus(CARD16 pcicommand, int bus) -{ - pciConfigPtr pPCI, *ppPCI = xf86scanpci(0); - - while ((pPCI = *ppPCI++)) { - if (pPCI->busnum < bus) - continue; - if (pPCI->busnum > bus) - break; - - /* XXX Assume all devices respect PCI disablement */ - if (!(pcicommand & pPCI->pci_command)) - continue; - - /* XXX This doesn't deal with mis-advertised classes */ - switch (pPCI->pci_base_class) { - case PCI_CLASS_PREHISTORIC: - if (pPCI->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA) - continue; /* Ignore VGA */ - break; - - case PCI_CLASS_DISPLAY: - continue; - - case PCI_CLASS_BRIDGE: - switch (pPCI->pci_sub_class) { - case PCI_SUBCLASS_BRIDGE_PCI: - case PCI_SUBCLASS_BRIDGE_CARDBUS: - /* Scan secondary bus */ - /* XXX First check bridge routing? */ - simbaCheckBus(pcicommand & pPCI->pci_command, - PCI_SECONDARY_BUS_EXTRACT(pPCI->pci_pp_bus_register, - pPCI->tag)); - if (!simbavgaRoutingAllow) - return; - - default: - break; - } - - default: - break; - } - - /* - * XXX We could check the device's bases here, but PCI doesn't limit - * the device's decoding to them. - */ - - simbavgaRoutingAllow = FALSE; - break; - } -} - -static pciConfigPtr -simbaVerifyBus(int bus) -{ - pciConfigPtr pPCI; - if ((bus < 0) || (bus >= pciNumBuses) || - !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) || - (pPCI->pci_device_vendor != DEVID(VENDOR_SUN, CHIP_SIMBA))) - return NULL; - - return pPCI; -} - -static CARD16 -simbaControlBridge(int bus, CARD16 mask, CARD16 value) -{ - pciConfigPtr pPCI; - CARD16 current = 0, tmp; - CARD8 iomap, memmap; - - if ((pPCI = simbaVerifyBus(bus))) { - /* - * The Simba does not implement VGA enablement as described in the P2P - * spec. It does however route I/O and memory in large enough chunks - * so that we can determine were VGA resources would be routed - * (including ISA VGA I/O aliases). We can allow changes to that - * routing only under certain circumstances. - */ - iomap = pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP); - memmap = pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP); - if (iomap & memmap & 0x01) { - current |= PCI_PCI_BRIDGE_VGA_EN; - if ((mask & PCI_PCI_BRIDGE_VGA_EN) && - !(value & PCI_PCI_BRIDGE_VGA_EN)) { - if (!simbavgaRoutingAllow) { - xf86MsgVerb(X_WARNING, 3, "Attempt to disable VGA routing" - " through Simba at %x:%x:%x disallowed.\n", - pPCI->busnum, pPCI->devnum, pPCI->funcnum); - value |= PCI_PCI_BRIDGE_VGA_EN; - } else { - pciWriteByte(pPCI->tag, APB_IO_ADDRESS_MAP, - iomap & ~0x01); - pciWriteByte(pPCI->tag, APB_MEM_ADDRESS_MAP, - memmap & ~0x01); - simbavgaIOTag = simbavgaMemTag = 0; - } - } - } else { - if (mask & value & PCI_PCI_BRIDGE_VGA_EN) { - if (!simbavgaRoutingAllow) { - xf86MsgVerb(X_WARNING, 3, "Attempt to enable VGA routing" - " through Simba at %x:%x:%x disallowed.\n", - pPCI->busnum, pPCI->devnum, pPCI->funcnum); - value &= ~PCI_PCI_BRIDGE_VGA_EN; - } else { - if (pPCI->tag != simbavgaIOTag) { - if (simbavgaIOTag) { - tmp = pciReadByte(simbavgaIOTag, - APB_IO_ADDRESS_MAP); - pciWriteByte(simbavgaIOTag, APB_IO_ADDRESS_MAP, - tmp & ~0x01); - } - - pciWriteByte(pPCI->tag, APB_IO_ADDRESS_MAP, - iomap | 0x01); - simbavgaIOTag = pPCI->tag; - } - - if (pPCI->tag != simbavgaMemTag) { - if (simbavgaMemTag) { - tmp = pciReadByte(simbavgaMemTag, - APB_MEM_ADDRESS_MAP); - pciWriteByte(simbavgaMemTag, APB_MEM_ADDRESS_MAP, - tmp & ~0x01); - } - - pciWriteByte(pPCI->tag, APB_MEM_ADDRESS_MAP, - memmap | 0x01); - simbavgaMemTag = pPCI->tag; - } - } - } - } - - /* Move on to master abort failure enablement (as per P2P spec) */ - tmp = pciReadWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG); - current |= tmp; - if (tmp & PCI_PCI_BRIDGE_MASTER_ABORT_EN) { - if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) && - !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) - pciWriteWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG, - tmp & ~PCI_PCI_BRIDGE_MASTER_ABORT_EN); - } else { - if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) - pciWriteWord(pPCI->tag, PCI_PCI_BRIDGE_CONTROL_REG, - tmp | PCI_PCI_BRIDGE_MASTER_ABORT_EN); - } - - /* Insert emulation of other P2P controls here */ - } - - return (current & ~mask) | (value & mask); -} - -static void -simbaGetBridgeResources(int bus, - pointer *ppIoRes, - pointer *ppMemRes, - pointer *ppPmemRes) -{ - pciConfigPtr pPCI = simbaVerifyBus(bus); - resRange range; - int i; - - if (!pPCI) - return; - - if (ppIoRes) { - xf86FreeResList(*ppIoRes); - *ppIoRes = NULL; - - if (pPCI->pci_command & PCI_CMD_IO_ENABLE) { - unsigned char iomap = pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP); - if (simbavgaRoutingAllow) - iomap |= 0x01; - for (i = 0; i < 8; i++) { - if (iomap & (1 << i)) { - RANGE(range, i << 21, ((i + 1) << 21) - 1, - RANGE_TYPE(ResExcIoBlock, - xf86GetPciDomain(pPCI->tag))); - *ppIoRes = xf86AddResToList(*ppIoRes, &range, -1); - } - } - } - } - - if (ppMemRes) { - xf86FreeResList(*ppMemRes); - *ppMemRes = NULL; - - if (pPCI->pci_command & PCI_CMD_MEM_ENABLE) { - unsigned char memmap = pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP); - if (simbavgaRoutingAllow) - memmap |= 0x01; - for (i = 0; i < 8; i++) { - if (memmap & (1 << i)) { - RANGE(range, i << 29, ((i + 1) << 29) - 1, - RANGE_TYPE(ResExcMemBlock, - xf86GetPciDomain(pPCI->tag))); - *ppMemRes = xf86AddResToList(*ppMemRes, &range, -1); - } - } - } - } - - if (ppPmemRes) { - xf86FreeResList(*ppPmemRes); - *ppPmemRes = NULL; - } -} - -void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI) -{ - static pciBusFuncs_t simbaBusFuncs; - pciBusInfo_t *pBusInfo; - CARD16 pcicommand; - - if (pPCI->pci_device_vendor != DEVID(VENDOR_SUN, CHIP_SIMBA)) - return; - - pBusInfo = pPCI->businfo; - - simbaBusFuncs = *(pBusInfo->funcs); - simbaBusFuncs.pciControlBridge = simbaControlBridge; - simbaBusFuncs.pciGetBridgeResources = simbaGetBridgeResources; - - pBusInfo->funcs = &simbaBusFuncs; - - if (!simbavgaRoutingAllow) - return; - - pcicommand = 0; - - if (pciReadByte(pPCI->tag, APB_IO_ADDRESS_MAP) & 0x01) { - pcicommand |= PCI_CMD_IO_ENABLE; - simbavgaIOTag = pPCI->tag; - } - - if (pciReadByte(pPCI->tag, APB_MEM_ADDRESS_MAP) & 0x01) { - pcicommand |= PCI_CMD_MEM_ENABLE; - simbavgaMemTag = pPCI->tag; - } - - if (!pcicommand) - return; - - simbaCheckBus(pcicommand, - PCI_SECONDARY_BUS_EXTRACT(pPCI->pci_pp_bus_register, pPCI->tag)); -} - -#endif /* defined(ARCH_PCI_PCI_BRIDGE) */ diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h deleted file mode 100644 index 2b8a4f76b..000000000 --- a/hw/xfree86/os-support/bus/xf86Pci.h +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 1998 by Concurrent Computer Corporation - * - * 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 Concurrent Computer - * Corporation not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Concurrent Computer Corporation makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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. - * - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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. - * - * This file is derived in part from the original xf86_PCI.h that included - * following copyright message: - * - * Copyright 1995 by Robin Cutshaw <robin@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 the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) 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 HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) 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. - * - */ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -/* - * This file contains just the public interface to the PCI code. - * Drivers should use this file rather than Pci.h. - */ - -#ifndef _XF86PCI_H -#define _XF86PCI_H 1 -#include <X11/Xarch.h> -#include <X11/Xfuncproto.h> -#include "misc.h" -#include <pciaccess.h> - -/* - * PCI cfg space definitions (e.g. stuff right out of the PCI spec) - */ - -/* Device identification register */ -#define PCI_ID_REG 0x00 - -/* Command and status register */ -#define PCI_CMD_STAT_REG 0x04 -#define PCI_CMD_BASE_REG 0x10 -#define PCI_CMD_BIOS_REG 0x30 -#define PCI_CMD_MASK 0xffff -#define PCI_CMD_IO_ENABLE 0x01 -#define PCI_CMD_MEM_ENABLE 0x02 -#define PCI_CMD_MASTER_ENABLE 0x04 -#define PCI_CMD_SPECIAL_ENABLE 0x08 -#define PCI_CMD_INVALIDATE_ENABLE 0x10 -#define PCI_CMD_PALETTE_ENABLE 0x20 -#define PCI_CMD_PARITY_ENABLE 0x40 -#define PCI_CMD_STEPPING_ENABLE 0x80 -#define PCI_CMD_SERR_ENABLE 0x100 -#define PCI_CMD_BACKTOBACK_ENABLE 0x200 -#define PCI_CMD_BIOS_ENABLE 0x01 - -/* base class */ -#define PCI_CLASS_REG 0x08 -#define PCI_CLASS_MASK 0xff000000 -#define PCI_CLASS_SHIFT 24 -#define PCI_CLASS_EXTRACT(x) \ - (((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT) - -/* base class values */ -#define PCI_CLASS_PREHISTORIC 0x00 -#define PCI_CLASS_MASS_STORAGE 0x01 -#define PCI_CLASS_NETWORK 0x02 -#define PCI_CLASS_DISPLAY 0x03 -#define PCI_CLASS_MULTIMEDIA 0x04 -#define PCI_CLASS_MEMORY 0x05 -#define PCI_CLASS_BRIDGE 0x06 -#define PCI_CLASS_COMMUNICATIONS 0x07 -#define PCI_CLASS_SYSPERIPH 0x08 -#define PCI_CLASS_INPUT 0x09 -#define PCI_CLASS_DOCKING 0x0a -#define PCI_CLASS_PROCESSOR 0x0b -#define PCI_CLASS_SERIALBUS 0x0c -#define PCI_CLASS_WIRELESS 0x0d -#define PCI_CLASS_I2O 0x0e -#define PCI_CLASS_SATELLITE 0x0f -#define PCI_CLASS_CRYPT 0x10 -#define PCI_CLASS_DATA_ACQUISTION 0x11 -#define PCI_CLASS_UNDEFINED 0xff - -/* sub class */ -#define PCI_SUBCLASS_MASK 0x00ff0000 -#define PCI_SUBCLASS_SHIFT 16 -#define PCI_SUBCLASS_EXTRACT(x) \ - (((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT) - -/* Sub class values */ -/* 0x00 prehistoric subclasses */ -#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00 -#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 - -/* 0x03 display subclasses */ -#define PCI_SUBCLASS_DISPLAY_VGA 0x00 -#define PCI_SUBCLASS_DISPLAY_XGA 0x01 -#define PCI_SUBCLASS_DISPLAY_MISC 0x80 - -/* 0x04 multimedia subclasses */ -#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00 -#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01 -#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80 - -/* 0x06 bridge subclasses */ -#define PCI_SUBCLASS_BRIDGE_HOST 0x00 -#define PCI_SUBCLASS_BRIDGE_ISA 0x01 -#define PCI_SUBCLASS_BRIDGE_EISA 0x02 -#define PCI_SUBCLASS_BRIDGE_MC 0x03 -#define PCI_SUBCLASS_BRIDGE_PCI 0x04 -#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05 -#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06 -#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 -#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 -#define PCI_SUBCLASS_BRIDGE_MISC 0x80 -#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01 - -/* 0x0b processor subclasses */ -#define PCI_SUBCLASS_PROCESSOR_386 0x00 -#define PCI_SUBCLASS_PROCESSOR_486 0x01 -#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02 -#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10 -#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20 -#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30 -#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40 - -/* PCI-PCI bridge mapping registers */ -#define PCI_PCI_BRIDGE_BUS_REG 0x18 -#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000 -#define PCI_SECONDARY_BUS_MASK 0x0000ff00 -#define PCI_PRIMARY_BUS_MASK 0x000000ff - -#define PCI_PCI_BRIDGE_IO_REG 0x1c -#define PCI_PCI_BRIDGE_MEM_REG 0x20 -#define PCI_PCI_BRIDGE_PMEM_REG 0x24 - -#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E -#define PCI_PCI_BRIDGE_PARITY_EN 0x01 -#define PCI_PCI_BRIDGE_SERR_EN 0x02 -#define PCI_PCI_BRIDGE_ISA_EN 0x04 -#define PCI_PCI_BRIDGE_VGA_EN 0x08 -#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20 -#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40 -#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80 - -/* Subsystem identification register */ -#define PCI_SUBSYSTEM_ID_REG 0x2c - -/* User defined cfg space regs */ -#define PCI_REG_USERCONFIG 0x40 -#define PCI_OPTION_REG 0x40 - -/* - * Typedefs, etc... - */ - -/* Primitive Types */ -typedef unsigned long ADDRESS; /* Memory/PCI address */ -typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */ -typedef unsigned long PCITAG; - -typedef enum { - PCI_MEM, - PCI_MEM_SIZE, - PCI_MEM_SPARSE_BASE, - PCI_MEM_SPARSE_MASK, - PCI_IO, - PCI_IO_SIZE, - PCI_IO_SPARSE_BASE, - PCI_IO_SPARSE_MASK -} PciAddrType; - - -/* Public PCI access functions */ -ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr); -PCITAG pciTag(int busnum, int devnum, int funcnum); -Bool xf86scanpci(void); - -extern int pciNumBuses; - -/* Domain access functions. Some of these probably shouldn't be public */ -pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev, - ADDRESS Base, unsigned long Size); -IOADDRESS xf86MapLegacyIO(struct pci_device *dev); - -#endif /* _XF86PCI_H */ diff --git a/hw/xfree86/os-support/bus/xf86Sbus.h b/hw/xfree86/os-support/bus/xf86Sbus.h deleted file mode 100644 index cff5e808a..000000000 --- a/hw/xfree86/os-support/bus/xf86Sbus.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Platform specific SBUS and OpenPROM access declarations. - * - * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _XF86_SBUS_H -#define _XF86_SBUS_H - -#if defined(linux) -#include <asm/types.h> -#include <linux/fb.h> -#include <asm/fbio.h> -#include <asm/openpromio.h> -#elif defined(SVR4) -#include <sys/fbio.h> -#include <sys/openpromio.h> -#elif defined(__OpenBSD__) && defined(__sparc64__) -/* XXX */ -#elif defined(CSRG_BASED) -#if defined(__FreeBSD__) -#include <sys/types.h> -#include <sys/fbio.h> -#include <dev/ofw/openpromio.h> -#else -#include <machine/fbio.h> -#endif -#else -#include <sun/fbio.h> -#endif - -#ifndef FBTYPE_SUNGP3 -#define FBTYPE_SUNGP3 -1 -#endif -#ifndef FBTYPE_MDICOLOR -#define FBTYPE_MDICOLOR -1 -#endif -#ifndef FBTYPE_SUNLEO -#define FBTYPE_SUNLEO -1 -#endif -#ifndef FBTYPE_TCXCOLOR -#define FBTYPE_TCXCOLOR -1 -#endif -#ifndef FBTYPE_CREATOR -#define FBTYPE_CREATOR -1 -#endif - -#endif /* _XF86_SBUS_H */ diff --git a/hw/xfree86/os-support/bus/zx1PCI.c b/hw/xfree86/os-support/bus/zx1PCI.c deleted file mode 100644 index d78e0c434..000000000 --- a/hw/xfree86/os-support/bus/zx1PCI.c +++ /dev/null @@ -1,1140 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -/* - * This file contains the glue necessary for support of HP's ZX1 chipset. - * Keep in mind that this chipset is used in both Itanium2 and PA-RISC - * architectures. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "zx1PCI.h" -#include "xf86.h" -#include "xf86_OSlib.h" -#include "Pci.h" - -#define MIO_BASE 0xFED00000UL /* mio register base */ -#define MIO_SIZE 0x00002000UL /* 8k, minimum */ - -/* ZX1 mio register definitions */ -#define MIO_FUNCTION0 0x0000U - -#define MODULE_INFO 0x0100U -#define STATUS_CONTROL 0x0108U -#define DILLON_PRESENT 0x02UL - -#define LMMIO_DIR_BASE0 0x0300U -#define LMMIO_DIR_MASK0 0x0308U -#define LMMIO_DIR_ROUTE0 0x0310U -#define LMMIO_DIR_BASE1 0x0318U -#define LMMIO_DIR_MASK1 0x0320U -#define LMMIO_DIR_ROUTE1 0x0328U -#define LMMIO_DIR_BASE2 0x0330U -#define LMMIO_DIR_MASK2 0x0338U -#define LMMIO_DIR_ROUTE2 0x0340U -#define LMMIO_DIR_BASE3 0x0348U -#define LMMIO_DIR_MASK3 0x0350U -#define LMMIO_DIR_ROUTE3 0x0358U -#define LMMIO_DIST_BASE 0x0360U -#define LMMIO_DIST_MASK 0x0368U -#define LMMIO_DIST_ROUTE 0x0370U -#define GMMIO_DIST_BASE 0x0378U -#define PORT_DISABLE 0x02UL -#define MAP_TO_LMMIO 0x04UL -#define GMMIO_DIST_MASK 0x0380U -#define GMMIO_DIST_ROUTE 0x0388U -#define IOS_DIST_BASE 0x0390U -#define IOS_DIST_MASK 0x0398U -#define IOS_DIST_ROUTE 0x03A0U -#define ROPE_CONFIG_BASE 0x03A8U -#define VGA_ROUTE 0x03B0U -#define VGA_ENABLE 0x8000000000000000UL -#define VGA_LIGHT 0x4000000000000000UL - -#define IOS_DIR_BASE 0x03C0U -#define IOS_DIR_MASK 0x03C8U -#define IOS_DIR_ROUTE 0x03D0U -#define IOS_BASE 0x03D8U - -#define MIO_FUNCTION1 0x1000U - -#define ROPE_CONFIG 0x1040U -#define ROPE_D0 0x0100UL -#define ROPE_D2 0x0200UL -#define ROPE_D4 0x0400UL -#define ROPE_D6 0x0800UL -#define ROPE_Q0 0x1000UL -#define ROPE_Q4 0x2000UL - -#define LBA_PORT0_CNTRL 0x1200U -#define LBA_PORT1_CNTRL 0x1208U -#define LBA_PORT2_CNTRL 0x1210U -#define LBA_PORT3_CNTRL 0x1218U -#define LBA_PORT4_CNTRL 0x1220U -#define LBA_PORT5_CNTRL 0x1228U -#define LBA_PORT6_CNTRL 0x1230U -#define LBA_PORT7_CNTRL 0x1238U -#define LBA_RESET_FUNCTION 0x0000000001UL -#define LBA_CLEAR_ERROR 0x0000000010UL -#define LBA_HARD_FAIL 0x0000000040UL -#define LBA_RESET_COMPLETE 0x0100000000UL -#define LBA_RESET_TIMEOUT 0x0200000000UL - -#define ROPE_PAGE_CONTROL 0x1418U - -/* - * Total ioa configuration space size is actually 128k, but we only need the - * first 64k. - */ -#define IOA_SIZE 0x00010000UL - -/* ZX1 ioa register definitions */ -#define IOA_CONFIG_ADDR 0x0040U -#define IOA_CONFIG_DATA 0x0048U - -#define IOA_SECONDARY_BUS 0x0058U -#define IOA_SUBORDINATE_BUS 0x0059U - -#define IOA_CONTROL 0x0108U -#define IOA_RESET_FUNCTION 0x0000000001UL -#define IOA_FORWARD_VGA 0x0000000008UL -#define IOA_CLEAR_ERROR 0x0000000010UL -#define IOA_HARD_FAIL 0x0000000040UL -#define IOA_RESET_COMPLETE 0x0100000000UL - -#define IOA_LMMIO_BASE 0x0200U -#define IOA_LMMIO_MASK 0x0208U -#define IOA_GMMIO_BASE 0x0210U -#define IOA_GMMIO_MASK 0x0218U -#define IOA_WLMMIO_BASE 0x0220U -#define IOA_WLMMIO_MASK 0x0228U -#define IOA_WGMMIO_BASE 0x0230U -#define IOA_WGMMIO_MASK 0x0238U -#define IOA_IOS_BASE 0x0240U -#define IOA_IOS_MASK 0x0248U -#define IOA_ELMMIO_BASE 0x0250U -#define IOA_ELMMIO_MASK 0x0258U -#define IOA_EIOS_BASE 0x0260U -#define IOA_EIOS_MASK 0x0268U -#define IOA_GLOBAL_MASK 0x0270U -#define IOA_SLAVE_CONTROL 0x0278U -#define IOA_VGA_PEER_ENABLE 0x2000UL -#define IOA_MSI_BASE 0x0280U -#define IOA_MSI_MASK 0x0288U - -#define IOA_DMA_BASE 0x02B0U -#define IOA_DMA_MASK 0x02B8U - -#define IOA_ERROR_CONFIG 0x0680U -#define IOA_ERROR_PIOWRITE 0x0001UL -#define IOA_ERROR_PIOREAD 0x0002UL -#define IOA_ERROR_DMAWRITE 0x0004UL -#define IOA_ERROR_DMAREAD 0x0008UL -#define IOA_ERROR_CONFIG_MASTER 0x0010UL -#define IOA_ERROR_SMART 0x0020UL -#define IOA_ERROR_FATAL_SERR 0x0040UL -#define IOA_ERROR_ASSERT_SERR 0x0080UL -/* ? 0x0100UL */ -#define IOA_ERROR_LOOPBACK 0x0200UL -#define IOA_ERROR_CONFIG_TARGET 0x0400UL -#define IOA_ERROR_IO_MASTER 0x0800UL -#define IOA_ERROR_IO_TARGET 0x1000UL -#define IOA_ERROR_MEM_MASTER 0x2000UL -#define IOA_ERROR_MEM_TARGET 0x4000UL -#define IOA_ERROR_HF_IO_FATAL 0x8000UL - -#define RANGE_ENABLE 0x01UL /* In various base registers */ - -#define IO_MASK ((1UL << 16) - 1UL) -#define LMMIO_MASK ((1UL << 32) - 1UL) -#ifdef __ia64__ -#define GMMIO_MASK ((1UL << 44) - 1UL) -#else /* PA-RISC */ -#define GMMIO_MASK ((1UL << 40) - 1UL) -#endif - -#define PDH_START 0xFF000000UL -#define PDH_LAST 0xFFFFFFFFUL - -static CARD8 *pZX1mio = NULL, - *pZX1ioa = NULL; - -/* Per-rope data */ -static INT8 zx1_ropemap[8]; -static CARD32 zx1_pciids[8]; -static CARD64 zx1_lbacntl[8]; -static int zx1_busno[8], zx1_subno[8]; - -/* Array of Booleans for non-empty buses */ -static INT8 zx1_busnmpt[MAX_PCI_BUSES]; - -static pciBusFuncs_t zx1BusFuncs; -static int zx1_fakebus = -1; -static Bool zx1_hasvga = FALSE; - -static pointer pZX1IoRes[8], pZX1MemRes[8]; /* Rope resources */ - -/* Non-PCI configuration space access macros */ -#define MIO_BYTE(offset) \ - (*(volatile CARD8 *)(pointer)(pZX1mio + (offset))) -#define MIO_WORD(offset) \ - (*(volatile CARD16 *)(pointer)(pZX1mio + (offset))) -#define MIO_LONG(offset) \ - (*(volatile CARD32 *)(pointer)(pZX1mio + (offset))) -#define MIO_QUAD(offset) \ - (*(volatile CARD64 *)(pointer)(pZX1mio + (offset))) -#define IOA_BYTE(ioa, offset) \ - (*(volatile CARD8 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) -#define IOA_WORD(ioa, offset) \ - (*(volatile CARD16 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) -#define IOA_LONG(ioa, offset) \ - (*(volatile CARD32 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) -#define IOA_QUAD(ioa, offset) \ - (*(volatile CARD64 *)(pointer)(pZX1ioa + ((offset) + ((ioa) << 13)))) - -/* Range definitions */ -#define MAX_RANGE 16 -static CARD64 bot[MAX_RANGE], top[MAX_RANGE], msk[MAX_RANGE], siz[MAX_RANGE]; -static INT8 *pDecode[MAX_RANGE]; -static int nRange = 0; - -/* Track a resource range and assign a granularity to it */ -static void -SetRange(CARD64 base, CARD64 last, CARD8 width) -{ - int i; - - bot[nRange] = base; - top[nRange] = last; - msk[nRange] = (CARD64)(-1L); - if (base) - msk[nRange] &= (base ^ (base - 1UL)) >> 1; - if (last + 1UL) - msk[nRange] &= (last ^ (last + 1UL)) >> 1; - if (width < 64) - msk[nRange] &= (1UL << width) - 1UL; - - /* Look for overlapping ranges */ - for (i = 0; i < nRange; i++) { - if ((bot[i] > top[i]) || - (top[nRange] < bot[i]) || - (top[i] < bot[nRange])) - continue; - - /* Merge in overlapping range */ - if (bot[nRange] > bot[i]) - bot[nRange] = bot[i]; - if (top[nRange] < top[i]) - top[nRange] = top[i]; - - /* Assign finer granularity */ - msk[nRange] &= msk[i]; - bot[i] = 1UL; - top[i] = 0; - } - - nRange++; -} - -/* Lookup granularity associated with the range containing 'base' */ -static int -GetRange(CARD64 base) -{ - int i; - - for (i = 0; i < nRange; i++) { - if ((bot[i] > top[i]) || - (base < bot[i]) || - (base > top[i])) - continue; - - if (pDecode[i]) - break; - - /* Allocate decoding array */ - msk[i]++; - siz[i] = ((top[i] - bot[i] + 1UL) / msk[i]) + 1UL; - pDecode[i] = xnfalloc(siz[i]); - (void)memset(pDecode[i], -1, siz[i]); - break; - } - - return i; -} - -/* - * Verify that 'bus' is a rope's secondary bus and return the pciConfigPtr of - * the associated fake PCI-to-PCI bridge. - */ -static pciConfigPtr -VerifyZX1Bus(int bus) -{ - pciConfigPtr pPCI; - - if ((bus < 0) || (bus >= pciNumBuses) || - !pciBusInfo[bus] || !(pPCI = pciBusInfo[bus]->bridge) || - (pPCI->busnum != zx1_fakebus) || (pPCI->funcnum != 0) || - (pPCI->devnum < 0x10) || (pPCI->devnum > 0x17)) - return NULL; - - return pPCI; -} - -/* - * This function is called to emulate the various settings in a P2P or CardBus - * bridge's control register on a ZX1-based system. - */ -static CARD16 -ControlZX1Bridge(int bus, CARD16 mask, CARD16 value) -{ - pciConfigPtr pPCI; - CARD64 tmp1, tmp2, tmp3, ropenum; - CARD16 current = 0; - - if ((pPCI = VerifyZX1Bus(bus))) { - ropenum = pPCI->devnum & 0x07; - - /* - * Start with VGA enablement. This preserves the "VGA-lite" bit - * in mio's VGA_ROUTE register, and the VPE bit in each ioa's - * SLAVE_CONTROL register. - */ - tmp1 = MIO_QUAD(VGA_ROUTE); - tmp2 = IOA_QUAD(ropenum, IOA_CONTROL) & - ~(IOA_RESET_FUNCTION | IOA_CLEAR_ERROR); - if ((tmp1 & VGA_ENABLE) && ((tmp1 & 0x07UL) == ropenum)) { - current |= PCI_PCI_BRIDGE_VGA_EN; - if ((mask & PCI_PCI_BRIDGE_VGA_EN) && - !(value & PCI_PCI_BRIDGE_VGA_EN)) { - MIO_QUAD(VGA_ROUTE) = tmp1 & ~VGA_ENABLE; - tmp2 &= ~IOA_FORWARD_VGA; - IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; - } - } else if (mask & value & PCI_PCI_BRIDGE_VGA_EN) { - if (!zx1_hasvga) { - xf86MsgVerb(X_WARNING, 3, - "HP ZX1: Attempt to enable VGA routing to bus %d" - " through rope %ld disallowed\n", bus, ropenum); - value &= ~PCI_PCI_BRIDGE_VGA_EN; - } else { - if (tmp1 & VGA_ENABLE) { - /* - * VGA is routed somewhere else. Disable it. - */ - MIO_QUAD(VGA_ROUTE) = 0UL; - tmp3 = IOA_QUAD(tmp1 & 0x07UL, IOA_CONTROL); - if (tmp3 & IOA_FORWARD_VGA) - IOA_QUAD(tmp1 & 0x07UL, IOA_CONTROL) = tmp3 & - ~(IOA_RESET_FUNCTION | IOA_FORWARD_VGA | - IOA_CLEAR_ERROR); - } - if (!(tmp2 & IOA_FORWARD_VGA)) { - tmp2 |= IOA_FORWARD_VGA; - IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; - } - tmp1 = (tmp1 & ~0x07UL) | ropenum | VGA_ENABLE; - MIO_QUAD(VGA_ROUTE) = tmp1; - } - } - - /* Move on to master abort failure enablement */ - tmp1 = MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) & - ~(LBA_RESET_FUNCTION | LBA_CLEAR_ERROR); - if ((tmp1 & LBA_HARD_FAIL) || (tmp2 & IOA_HARD_FAIL)) { - current |= PCI_PCI_BRIDGE_MASTER_ABORT_EN; - if ((mask & PCI_PCI_BRIDGE_MASTER_ABORT_EN) && - !(value & PCI_PCI_BRIDGE_MASTER_ABORT_EN)) { - if (tmp1 & LBA_HARD_FAIL) - MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) = - tmp1 & ~LBA_HARD_FAIL; - if (tmp2 & IOA_HARD_FAIL) { - tmp2 &= ~IOA_HARD_FAIL; - IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; - } - } - } else { - if (mask & value & PCI_PCI_BRIDGE_MASTER_ABORT_EN) { - if (!(tmp1 & LBA_HARD_FAIL)) - MIO_QUAD((ropenum << 3) + LBA_PORT0_CNTRL) = - tmp1 | LBA_HARD_FAIL; - if (!(tmp2 & IOA_HARD_FAIL)) { - tmp2 |= IOA_HARD_FAIL; - IOA_QUAD(ropenum, IOA_CONTROL) = tmp2; - } - } - } - - /* Put emulation of any other P2P bridge control here */ - } - - return (current & ~mask) | (value & mask); -} - -/* Retrieves a list of the resources routed to a rope's secondary bus */ -static void -GetZX1BridgeResources(int bus, - pointer *ppIoRes, - pointer *ppMemRes, - pointer *ppPmemRes) -{ - pciConfigPtr pPCI = VerifyZX1Bus(bus); - - if (ppIoRes) { - xf86FreeResList(*ppIoRes); - *ppIoRes = - pPCI ? xf86DupResList(pZX1IoRes[pPCI->devnum & 0x07]) : NULL; - } - - if (ppMemRes) { - xf86FreeResList(*ppMemRes); - *ppMemRes = - pPCI ? xf86DupResList(pZX1MemRes[pPCI->devnum & 0x07]) : NULL; - } - - if (ppPmemRes) { - xf86FreeResList(*ppPmemRes); - *ppPmemRes = NULL; - } -} - -/* The fake bus */ -static CARD32 -zx1FakeReadLong(PCITAG tag, int offset) -{ - FatalError("zx1FakeReadLong(0x%lX, 0x%X) called\n", - (unsigned long)tag, offset); -} - -static void -zx1FakeWriteLong(PCITAG tag, int offset, CARD32 val) -{ - FatalError("zx1FakeWriteLong(0x%lX, 0x%X, 0x%08X) called\n", - (unsigned long)tag, offset, val); -} - -static void -zx1FakeSetBits(PCITAG tag, int offset, CARD32 mask, CARD32 bits) -{ - CARD32 val; - - val = zx1FakeReadLong(tag, offset); - val &= ~mask; - val |= bits; - zx1FakeWriteLong(tag, offset, val); -} - -static pciBusFuncs_t zx1FakeBusFuncs = { - zx1FakeReadLong, - zx1FakeWriteLong, - zx1FakeSetBits -}; - -static pciBusInfo_t zx1FakeBus = { - 0, /* configMech -- copied from bus 0 */ - 0, /* numDevices -- copied from bus 0 */ - FALSE, /* secondary */ - 0, /* primary_bus -- dynamically set */ - &zx1FakeBusFuncs, /* funcs */ - NULL, /* pciBusPriv -- none */ - NULL, /* bridge -- dynamically set */ -}; - -void -xf86PreScanZX1(void) -{ - resRange range; - unsigned long mapSize = getpagesize(); - unsigned long tmp, base, ioaaddr; - unsigned long flagsd, based, lastd, maskd, routed; - unsigned long flags0, base0, last0, mask0, route0; - unsigned long flags1, base1, last1, mask1, route1; - unsigned long flags2, base2, last2, mask2, route2; - unsigned long flags3, base3, last3, mask3, route3; - unsigned long flagsg, baseg, lastg, maskg, routeg; - unsigned long flagsl, basel, lastl; - int i, rope; - - /* Map mio registers (minimum 8k) */ - if (mapSize < MIO_SIZE) - mapSize = MIO_SIZE; - - if (!(pZX1mio = xf86MapVidMem(-1, VIDMEM_MMIO, MIO_BASE, mapSize))) - return; - - /* Look for ZX1's SBA and IOC */ - if (((MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) != - DEVID(VENDOR_HP, CHIP_ZX1_SBA)) || - (MIO_LONG(MIO_FUNCTION1 + PCI_ID_REG) != - DEVID(VENDOR_HP, CHIP_ZX1_IOC))) && - ((MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) != - DEVID(VENDOR_HP, CHIP_ZX2_SBA)) || - (MIO_LONG(MIO_FUNCTION1 + PCI_ID_REG) != - DEVID(VENDOR_HP, CHIP_ZX2_IOC)))) { - xf86UnMapVidMem(-1, pZX1mio, mapSize); - pZX1mio = NULL; - return; - } - - /* Map rope configuration space */ - ioaaddr = MIO_QUAD(ROPE_CONFIG_BASE); - if (!(ioaaddr & RANGE_ENABLE) || /* No ropes */ - ((ioaaddr = ioaaddr & ~RANGE_ENABLE) & 0x01FFFFUL) || /* Not aligned */ - !(pZX1ioa = xf86MapVidMem(-1, VIDMEM_MMIO, ioaaddr, IOA_SIZE))) { - xf86UnMapVidMem(-1, pZX1mio, mapSize); - pZX1mio = NULL; - return; - } - - for (i = 0; i < 8; i++) { - zx1_ropemap[i] = i; - zx1_lbacntl[i] = 0; - xf86FreeResList(pZX1IoRes[i]); - xf86FreeResList(pZX1MemRes[i]); - pZX1IoRes[i] = pZX1MemRes[i] = NULL; - } - - /* - * Determine which of 8 possible ropes exist in the system. This is done - * by looking at their "coupling" to generate a list of candidates, - * whittling this list down by factoring in ROPE_PAGE_CONTROL register - * contents, then poking each candidate's configuration space to determine - * its existence. - */ - tmp = MIO_QUAD(ROPE_CONFIG); - if (tmp & ROPE_D0) - zx1_ropemap[1] = 0; - if (tmp & ROPE_D2) - zx1_ropemap[3] = 2; - if (tmp & ROPE_D4) - zx1_ropemap[5] = 4; - if (tmp & ROPE_D6) - zx1_ropemap[7] = 6; - if (tmp & ROPE_Q0) - zx1_ropemap[1] = zx1_ropemap[2] = zx1_ropemap[3] = 0; - if (tmp & ROPE_Q4) - zx1_ropemap[5] = zx1_ropemap[6] = zx1_ropemap[7] = 4; - - /* - * zx2 should allow better probing support via hard-fails, so no need to - * use the ROPE_PAGE_CONTROL register. Also, zx2 always has ropes 3 & 7 - * active regardless of bundling. - */ - if (MIO_LONG(MIO_FUNCTION0 + PCI_ID_REG) != - DEVID(VENDOR_HP, CHIP_ZX2_SBA)) { - - tmp = MIO_QUAD(ROPE_PAGE_CONTROL); - for (i = 0; i < 8; i++, tmp >>= 8) - if (!(CARD8)tmp) - zx1_ropemap[i] = -1; - } else { - zx1_ropemap[3] = 3; - zx1_ropemap[7] = 7; - } - - for (i = 0; i < 8; ) { - if (zx1_ropemap[i] == i) { - - /* Prevent hard-fails */ - zx1_lbacntl[i] = MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) & - ~(LBA_RESET_FUNCTION | LBA_CLEAR_ERROR); - - if (zx1_lbacntl[i] & LBA_RESET_TIMEOUT) { - /* Ignore this rope and its couplings */ - do { - zx1_ropemap[i++] = -1; - } while ((i < 8) && (zx1_ropemap[i] < i)); - continue; /* Avoid over-incrementing 'i' */ - } - - if (zx1_lbacntl[i] & LBA_HARD_FAIL) - MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = - zx1_lbacntl[i] & ~LBA_HARD_FAIL; - - /* Poke for an ioa */ - zx1_pciids[i] = IOA_LONG(i, PCI_ID_REG); - switch (zx1_pciids[i]) { - case DEVID(VENDOR_HP, CHIP_ELROY): - case DEVID(VENDOR_HP, CHIP_ZX1_LBA): /* Mercury */ - case DEVID(VENDOR_HP, CHIP_ZX1_AGP8): /* QuickSilver */ - case DEVID(VENDOR_HP, CHIP_ZX2_LBA): - case DEVID(VENDOR_HP, CHIP_ZX2_PCIE): - /* Expected vendor/device IDs */ - zx1_busno[i] = - (unsigned int)IOA_BYTE(i, IOA_SECONDARY_BUS); - zx1_subno[i] = - (unsigned int)IOA_BYTE(i, IOA_SUBORDINATE_BUS); - break; - - default: - if ((CARD16)(zx1_pciids[i] + 1U) > (CARD16)1U) - xf86MsgVerb(X_NOTICE, 0, - "HP ZX1: Unexpected vendor/device id 0x%08X" - " on rope %d\n", zx1_pciids[i], i); - /* Nobody home, or not the "right" kind of rope guest */ - - /* - * Restore hard-fail setting. For "active" ropes, this is done - * later. - */ - if (zx1_lbacntl[i] & LBA_HARD_FAIL) { - MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = zx1_lbacntl[i]; - zx1_lbacntl[i] = 0; - } - - /* Ignore this rope and its couplings */ - do { - zx1_ropemap[i++] = -1; - } while ((i < 8) && (zx1_ropemap[i] < i)); - continue; /* Avoid over-incrementing 'i' */ - } - } - i++; - } - - /* Determine if VGA is currently routed */ - tmp = MIO_QUAD(VGA_ROUTE); - if (tmp & VGA_ENABLE) - zx1_hasvga = TRUE; - - /* - * Decode mio resource "coarse" routing (i.e. ignoring VGA). Due to the - * rather unusual flexibility of this chipset, this is done in a number of - * stages. For each of I/O and memory, first decode the relevant registers - * to generate ranges with an associated granularity. Overlapping ranges - * are merged into a larger range with the finer granularity. Each - * original range is then more thoroughly decoded using the granularity - * associated with the merged range that contains it. The result is then - * converted into resource lists for the common layer. - * - * Note that this doesn't care whether or not read-only bits are actually - * set as documented, nor that mask bits are contiguous. This does, - * however, factor in upper limits on I/O, LMMIO anf GMMIO addresses, and - * thus assumes high-order address bits are ignored rather than decoded. - * For example, an I/O address of 0x76543210 will be treated as 0x3210 - * rather than considered out-of-range. In part, this handling is a - * consequence of the fact that high-order mask bits are zeroes instead of - * ones. - */ - - flagsd = 0; based = 0; lastd = 0; maskd = 0; routed = 0; - flags0 = 0; base0 = 0; last0 = 0; mask0 = 0; route0 = 0; - flags1 = 0; base1 = 0; last1 = 0; mask1 = 0; route1 = 0; - flags2 = 0; base2 = 0; last2 = 0; mask2 = 0; route2 = 0; - flags3 = 0; base3 = 0; last3 = 0; mask3 = 0; route3 = 0; - flagsg = 0; baseg = 0; lastg = 0; maskg = 0; routeg = 0; - flagsl = 0; basel = 0; lastl = 0; - - if ((tmp = MIO_QUAD(IOS_DIST_BASE)) & RANGE_ENABLE) { - flagsd = RANGE_ENABLE; - maskd = MIO_QUAD(IOS_DIST_MASK); - based = tmp & maskd & (~RANGE_ENABLE & IO_MASK); - lastd = based | (~maskd & IO_MASK); - routed = MIO_QUAD(IOS_DIST_ROUTE) >> 58; - SetRange(based, lastd, routed); - } - - if ((tmp = MIO_QUAD(IOS_DIR_BASE)) & RANGE_ENABLE) { - flags0 = RANGE_ENABLE; - mask0 = MIO_QUAD(IOS_DIR_MASK); - base0 = tmp & mask0 & (~RANGE_ENABLE & IO_MASK); - last0 = base0 | (~mask0 & IO_MASK); - route0 = MIO_QUAD(IOS_DIR_ROUTE) & 0x07U; - SetRange(base0, last0, 64); - } - - if (flagsd) { - i = GetRange(based); - for (tmp = based; tmp <= lastd; tmp += msk[i]) { - if ((tmp & maskd) == based) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[(tmp >> routed) & 0x07U]; - } - } - - flagsd = 0; - } - - if (flags0) { - i = GetRange(base0); - for (tmp = base0; tmp <= last0; tmp += msk[i]) { - if ((tmp & mask0) == base0) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[route0]; - } - } - - flags0 = 0; - } - - for (i = 0; i < nRange; i++) { - if (!pDecode[i]) - continue; - - rope = pDecode[i][0]; - for (base = tmp = 0; ++tmp < siz[i]; ) { - if (rope == pDecode[i][tmp]) - continue; - - if (rope >= 0) { - RANGE(range, (base * msk[i]) + bot[i], - (tmp * msk[i]) + bot[i] - 1UL, - RANGE_TYPE(ResExcIoBlock, 0)); - pZX1IoRes[rope] = - xf86AddResToList(pZX1IoRes[rope], &range, -1); - } - - base = tmp; - rope = pDecode[i][base]; - } - - xfree(pDecode[i]); - pDecode[i] = NULL; - } - - nRange = 0; - - /* - * Move on to CPU memory access decoding. For now, don't tell the common - * layer about CPU memory ranges that are either relocated to 0 or - * translated into PCI I/O. - */ - - SetRange(MIO_BASE, MIO_BASE + MIO_SIZE - 1UL, 64); /* mio */ - SetRange(ioaaddr, ioaaddr + ((IOA_SIZE << 1) - 1UL), 64); /* ioa */ - SetRange(PDH_START, PDH_LAST, 64); /* PDH */ - - SetRange(MIO_BASE, LMMIO_MASK, 64); /* Completeness */ - - if ((tmp = MIO_QUAD(LMMIO_DIST_BASE)) & RANGE_ENABLE) { - flagsd = RANGE_ENABLE; - maskd = MIO_QUAD(LMMIO_DIST_MASK); - based = tmp & maskd & (~RANGE_ENABLE & LMMIO_MASK); - lastd = based | (~maskd & LMMIO_MASK); - routed = MIO_QUAD(LMMIO_DIST_ROUTE) >> 58; - SetRange(based, lastd, routed); - } - - if ((tmp = MIO_QUAD(LMMIO_DIR_BASE0)) & RANGE_ENABLE) { - flags0 = RANGE_ENABLE; - mask0 = MIO_QUAD(LMMIO_DIR_MASK0); - base0 = tmp & mask0 & (~RANGE_ENABLE & LMMIO_MASK); - last0 = base0 | (~mask0 & LMMIO_MASK); - route0 = MIO_QUAD(LMMIO_DIR_ROUTE0) & 0x07U; - SetRange(base0, last0, 64); - } - - if ((tmp = MIO_QUAD(LMMIO_DIR_BASE1)) & RANGE_ENABLE) { - flags1 = RANGE_ENABLE; - mask1 = MIO_QUAD(LMMIO_DIR_MASK1); - base1 = tmp & mask1 & (~RANGE_ENABLE & LMMIO_MASK); - last1 = base1 | (~mask1 & LMMIO_MASK); - route1 = MIO_QUAD(LMMIO_DIR_ROUTE1) & 0x07U; - SetRange(base1, last1, 64); - } - - if ((tmp = MIO_QUAD(LMMIO_DIR_BASE2)) & RANGE_ENABLE) { - flags2 = RANGE_ENABLE; - mask2 = MIO_QUAD(LMMIO_DIR_MASK2); - base2 = tmp & mask2 & (~RANGE_ENABLE & LMMIO_MASK); - last2 = base2 | (~mask2 & LMMIO_MASK); - route2 = MIO_QUAD(LMMIO_DIR_ROUTE2) & 0x07U; - SetRange(base2, last2, 64); - } - - if ((tmp = MIO_QUAD(LMMIO_DIR_BASE3)) & RANGE_ENABLE) { - flags3 = RANGE_ENABLE; - mask3 = MIO_QUAD(LMMIO_DIR_MASK3); - base3 = tmp & mask3 & (~RANGE_ENABLE & LMMIO_MASK); - last3 = base3 | (~mask3 & LMMIO_MASK); - route3 = MIO_QUAD(LMMIO_DIR_ROUTE3) & 0x07U; - SetRange(base3, last3, 64); - } - - if ((tmp = MIO_QUAD(GMMIO_DIST_BASE)) & RANGE_ENABLE) { - flagsg = tmp & (RANGE_ENABLE | PORT_DISABLE | MAP_TO_LMMIO); - maskg = MIO_QUAD(GMMIO_DIST_MASK); - baseg = tmp & maskg & - (~(RANGE_ENABLE | PORT_DISABLE | MAP_TO_LMMIO) & GMMIO_MASK); - lastg = baseg | (~maskg & GMMIO_MASK); - tmp = routeg = MIO_QUAD(GMMIO_DIST_ROUTE) >> 58; - if (!(flagsg & (PORT_DISABLE & MAP_TO_LMMIO)) && (tmp > 26)) - tmp = 26; - SetRange(baseg, lastg, tmp); - } - - if ((tmp = MIO_QUAD(IOS_BASE)) & RANGE_ENABLE) { - flagsl = RANGE_ENABLE; - basel = tmp & (~RANGE_ENABLE & GMMIO_MASK); - lastl = basel | 0x001FFFFFUL; - SetRange(basel, lastl, 64); - } - - if (flagsd) { - i = GetRange(based); - for (tmp = based; tmp <= lastd; tmp += msk[i]) { - if ((tmp & maskd) == based) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[(tmp >> routed) & 0x07U]; - } - } - - flagsd = 0; - } - - /* LMMIO distributed range does not address anything beyond 0xFED00000 */ - i = GetRange(MIO_BASE); - for (tmp = MIO_BASE; tmp <= LMMIO_MASK; tmp += msk[i]) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = -1; - } - - /* Dillon space can sometimes be redirected to rope 0 */ - tmp = MIO_QUAD(STATUS_CONTROL); - if (!(tmp & DILLON_PRESENT)) { - i = GetRange(PDH_START); - for (tmp = PDH_START; tmp <= PDH_LAST; tmp += msk[i]) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[0]; - } - } - - if (flagsg) { - unsigned long mask = (0x07UL << routeg) | maskg; - - i = GetRange(baseg); - for (tmp = baseg; tmp <= lastg; tmp += msk[i]) { - if ((tmp & maskg) == baseg) { - base = (tmp - bot[i]) / msk[i]; - - if ((flagsg & MAP_TO_LMMIO) || - (!(flagsg & PORT_DISABLE) && - (tmp <= ((tmp & mask) | 0x03FFFFFFUL)))) { - pDecode[i][base] = -1; - } else { - pDecode[i][base] = zx1_ropemap[(tmp >> routeg) & 0x07U]; - } - } - } - - flagsg = 0; - } - - if (flagsl) { - i = GetRange(basel); - for (tmp = basel; tmp <= lastl; tmp += msk[i]) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = -1; - } - - flagsl = 0; - } - - /* For now, assume directed LMMIO ranges don't overlap with each other */ - if (flags0) { - i = GetRange(base0); - for (tmp = base0; tmp <= last0; tmp += msk[i]) { - if ((tmp & mask0) == base0) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[route0]; - } - } - - flags0 = 0; - } - - if (flags1) { - i = GetRange(base1); - for (tmp = base1; tmp <= last1; tmp += msk[i]) { - if ((tmp & mask1) == base1) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[route1]; - } - } - - flags1 = 0; - } - - if (flags2) { - i = GetRange(base2); - for (tmp = base2; tmp <= last2; tmp += msk[i]) { - if ((tmp & mask2) == base2) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[route2]; - } - } - - flags2 = 0; - } - - if (flags3) { - i = GetRange(base3); - for (tmp = base3; tmp <= last3; tmp += msk[i]) { - if ((tmp & mask3) == base3) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = zx1_ropemap[route3]; - } - } - - flags3 = 0; - } - - /* Claim iao config area */ - i = GetRange(ioaaddr); - for (tmp = ioaaddr; tmp < ioaaddr + (IOA_SIZE << 1); tmp += msk[i]) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = -1; - } - - /* Claim mio config area */ - i = GetRange(MIO_BASE); - for (tmp = MIO_BASE; tmp < (MIO_BASE + MIO_SIZE); tmp += msk[i]) { - base = (tmp - bot[i]) / msk[i]; - pDecode[i][base] = -1; - } - - for (i = 0; i < nRange; i++) { - if (!pDecode[i]) - continue; - - rope = pDecode[i][0]; - for (base = tmp = 0; ++tmp < siz[i]; ) { - if (rope == pDecode[i][tmp]) - continue; - - if (rope >= 0) { - RANGE(range, (base * msk[i]) + bot[i], - (tmp * msk[i]) + bot[i] - 1UL, - RANGE_TYPE(ResExcMemBlock, 0)); - pZX1MemRes[rope] = - xf86AddResToList(pZX1MemRes[rope], &range, -1); - } - - base = tmp; - rope = pDecode[i][base]; - } - - xfree(pDecode[i]); - pDecode[i] = NULL; - } - - nRange = 0; - - return; -} - -/* This is called to finalise the results of a PCI bus scan */ -void -xf86PostScanZX1(void) -{ - pciConfigPtr pPCI, *ppPCI, *ppPCI2; - pciBusInfo_t *pBusInfo; - int i, idx; - - if (!pZX1mio) - return; - - (void)memset(zx1_busnmpt, FALSE, sizeof(zx1_busnmpt)); - pBusInfo = pciBusInfo[0]; - - /* - * Certain 2.4 & 2.5 Linux kernels add fake PCI devices. Remove them to - * prevent any possible interference with our PCI validation. - * - * Also, if VGA isn't routed on server entry, determine if VGA routing - * needs to be enabled while the server is running. - */ - idx = 0; - ppPCI = ppPCI2 = xf86scanpci(0); /* Recursion is only apparent */ - while ((pPCI = *ppPCI2++)) { - switch (pPCI->pci_device_vendor) { - case DEVID(VENDOR_HP, CHIP_ELROY): - case DEVID(VENDOR_HP, CHIP_ZX1_SBA): /* Pluto function 0 */ - case DEVID(VENDOR_HP, CHIP_ZX1_IOC): /* Pluto function 1 */ - case DEVID(VENDOR_HP, CHIP_ZX1_LBA): /* Mercury */ - case DEVID(VENDOR_HP, CHIP_ZX1_AGP8): /* QuickSilver */ - case DEVID(VENDOR_HP, CHIP_ZX2_SBA): - case DEVID(VENDOR_HP, CHIP_ZX2_IOC): - case DEVID(VENDOR_HP, CHIP_ZX2_LBA): - case DEVID(VENDOR_HP, CHIP_ZX2_PCIE): - xfree(pPCI); /* Remove it */ - continue; - - default: - *ppPCI++ = pPCI; - idx++; - - zx1_busnmpt[pPCI->busnum] = TRUE; - - if (zx1_hasvga) - continue; - - switch (pPCI->pci_base_class) { - case PCI_CLASS_PREHISTORIC: - if (pPCI->pci_sub_class == PCI_SUBCLASS_PREHISTORIC_VGA) - break; - continue; - - case PCI_CLASS_DISPLAY: - if (pPCI->pci_sub_class == PCI_SUBCLASS_DISPLAY_VGA) - break; - continue; - - default: - continue; - } - - zx1_hasvga = TRUE; - continue; - } - } - - /* - * Restore hard-fail settings and figure out the actual secondary and - * subordinate bus numbers. - */ - for (i = 0; i < 8; i++) { - if (zx1_ropemap[i] != i) - continue; - - if (zx1_lbacntl[i] & LBA_HARD_FAIL) - MIO_QUAD((i << 3) + LBA_PORT0_CNTRL) = zx1_lbacntl[i]; - - while ((zx1_busno[i] < zx1_subno[i]) && !pciBusInfo[zx1_subno[i]]) - zx1_subno[i]--; - - if (zx1_fakebus <= zx1_subno[i]) - zx1_fakebus = zx1_subno[i] + 1; - - while (!zx1_busnmpt[zx1_busno[i]]) { - if (zx1_busno[i]) /* Info for bus zero is in static storage */ - xfree(pciBusInfo[zx1_busno[i]]); - pciBusInfo[zx1_busno[i]++] = NULL; - if (zx1_busno[i] > zx1_subno[i]) - break; - } - } - - if (zx1_fakebus >= pciNumBuses) { - if (zx1_fakebus >= pciMaxBusNum) - FatalError("HP ZX1: No room for fake PCI bus\n"); - pciNumBuses = zx1_fakebus + 1; - } - - /* Set up our extra bus functions */ - zx1BusFuncs = *(pBusInfo->funcs); - zx1BusFuncs.pciControlBridge = ControlZX1Bridge; - zx1BusFuncs.pciGetBridgeResources = GetZX1BridgeResources; - - /* Set up our own fake bus to act as the root segment */ - zx1FakeBus.configMech = pBusInfo->configMech; - zx1FakeBus.numDevices = pBusInfo->numDevices; - zx1FakeBus.primary_bus = zx1_fakebus; - pciBusInfo[zx1_fakebus] = &zx1FakeBus; - - /* Add the fake bus' host bridge */ - if (++idx >= MAX_PCI_DEVICES) - FatalError("HP ZX1: No room for fake Host-to-PCI bridge\n"); - *ppPCI++ = zx1FakeBus.bridge = pPCI = xnfcalloc(1, sizeof(pciDevice)); - pPCI->tag = PCI_MAKE_TAG(zx1_fakebus, 0, 0); - pPCI->busnum = zx1_fakebus; - /* pPCI->devnum = pPCI->funcnum = 0; */ - pPCI->pci_device_vendor = DEVID(VENDOR_HP, CHIP_ZX1_SBA); - pPCI->pci_base_class = PCI_CLASS_BRIDGE; - /* pPCI->pci_sub_class = PCI_SUBCLASS_BRIDGE_HOST; */ - pPCI->fakeDevice = TRUE; - -#ifdef OLD_FORMAT - xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " - "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", - pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_rev_id, - pPCI->pci_base_class, pPCI->pci_sub_class); -#else - xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" - " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", - pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->_pci_device, - pPCI->pci_subsys_vendor, pPCI->pci_subsys_card, - pPCI->pci_rev_id, pPCI->pci_base_class, - pPCI->pci_sub_class, pPCI->pci_prog_if, - pPCI->pci_header_type); -#endif - - /* Add a fake PCI-to-PCI bridge to represent each active rope */ - for (i = 0; i < 8; i++) { - if ((zx1_ropemap[i] != i) || (zx1_busno[i] > zx1_subno[i]) || - !(pBusInfo = pciBusInfo[zx1_busno[i]])) - continue; - - if (++idx >= MAX_PCI_DEVICES) - FatalError("HP ZX1: No room for fake PCI-to-PCI bridge\n"); - *ppPCI++ = pPCI = xnfcalloc(1, sizeof(pciDevice)); - pPCI->busnum = zx1_fakebus; - pPCI->devnum = i | 0x10; - /* pPCI->funcnum = 0; */ - pPCI->tag = PCI_MAKE_TAG(zx1_fakebus, pPCI->devnum, 0); - pPCI->pci_device_vendor = zx1_pciids[i]; - pPCI->pci_base_class = PCI_CLASS_BRIDGE; - pPCI->pci_sub_class = PCI_SUBCLASS_BRIDGE_PCI; - pPCI->pci_header_type = 1; - pPCI->pci_primary_bus_number = zx1_fakebus; - pPCI->pci_secondary_bus_number = zx1_busno[i]; - pPCI->pci_subordinate_bus_number = zx1_subno[i]; - pPCI->fakeDevice = TRUE; - - pBusInfo->bridge = pPCI; - pBusInfo->secondary = TRUE; - pBusInfo->primary_bus = zx1_fakebus; - - /* Plug in chipset routines */ - pBusInfo->funcs = &zx1BusFuncs; - - /* Set bridge control register for scanpci utility */ - pPCI->pci_bridge_control = ControlZX1Bridge(zx1_busno[i], 0, 0); - -#ifdef OLD_FORMAT - xf86MsgVerb(X_INFO, 2, "PCI: BusID 0x%.2x,0x%02x,0x%1x " - "ID 0x%04x,0x%04x Rev 0x%02x Class 0x%02x,0x%02x\n", - pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->_pci_device, pPCI->pci_rev_id, - pPCI->pci_base_class, pPCI->pci_sub_class); -#else - xf86MsgVerb(X_INFO, 2, "PCI: %.2x:%02x:%1x: chip %04x,%04x" - " card %04x,%04x rev %02x class %02x,%02x,%02x hdr %02x\n", - pPCI->busnum, pPCI->devnum, pPCI->funcnum, - pPCI->pci_vendor, pPCI->_pci_device, - pPCI->pci_subsys_vendor, pPCI->pci_subsys_card, - pPCI->pci_rev_id, pPCI->pci_base_class, - pPCI->pci_sub_class, pPCI->pci_prog_if, - pPCI->pci_header_type); -#endif - } - - *ppPCI = NULL; /* Terminate array */ -} diff --git a/hw/xfree86/os-support/bus/zx1PCI.h b/hw/xfree86/os-support/bus/zx1PCI.h deleted file mode 100644 index f2b279382..000000000 --- a/hw/xfree86/os-support/bus/zx1PCI.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef PCI_ZX1_H -#define PCI_ZX1_H 1 - -#include <X11/Xdefs.h> - -void xf86PreScanZX1(void); -void xf86PostScanZX1(void); - -#endif diff --git a/hw/xfree86/os-support/hurd/Makefile.am b/hw/xfree86/os-support/hurd/Makefile.am deleted file mode 100644 index 2214b1c2d..000000000 --- a/hw/xfree86/os-support/hurd/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -noinst_LTLIBRARIES = libhurd.la - -libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \ - hurd_mouse.c hurd_video.c \ - $(srcdir)/../shared/VTsw_noop.c \ - $(srcdir)/../shared/posix_tty.c \ - $(srcdir)/../shared/stdResource.c \ - $(srcdir)/../shared/sigiostubs.c \ - $(srcdir)/../shared/pm_noop.c \ - $(srcdir)/../shared/kmod_noop.c \ - $(srcdir)/../shared/agp_noop.c - -AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) - -INCLUDES = $(XORG_INCS) diff --git a/hw/xfree86/os-support/hurd/hurd_bell.c b/hw/xfree86/os-support/hurd/hurd_bell.c deleted file mode 100644 index 732a1cadb..000000000 --- a/hw/xfree86/os-support/hurd/hurd_bell.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright © 2006 Daniel Stone - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Author: Daniel Stone <daniel@fooishbar.org> - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86Priv.h" - -_X_EXPORT void -xf86OSRingBell(int loudness, int pitch, int duration) -{ - return; -} diff --git a/hw/xfree86/os-support/hurd/hurd_init.c b/hw/xfree86/os-support/hurd/hurd_init.c deleted file mode 100644 index 8cd8f54d6..000000000 --- a/hw/xfree86/os-support/hurd/hurd_init.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 1997,1998 by UCHIYAMA Yasushi - * - * 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 UCHIYAMA Yasushi not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. UCHIYAMA Yasushi makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "input.h" -#include "scrnintstr.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include <stdio.h> -#include <errno.h> -#include <sys/time.h> -#include <sys/file.h> -#include <assert.h> -#include <mach.h> - -int -xf86ProcessArgument( int argc,char **argv, int i ) -{ - return 0; -} -void -xf86UseMsg() -{ - return; -} - - -void -xf86OpenConsole() -{ - if( serverGeneration == 1 ) - { - kern_return_t err; - mach_port_t device; - int fd; - err = get_privileged_ports( NULL, &device ); - if( err ) - { - errno = err; - FatalError( "xf86KbdInit can't get_privileged_ports. (%s)\n" , strerror(errno) ); - } - mach_port_deallocate (mach_task_self (), device); - - if( ( fd = open( "/dev/kbd" , O_RDONLY|O_NONBLOCK ) ) < 0 ) - { - fprintf( stderr , "Cannot open keyboard (%s)\n",strerror(errno) ); - exit(1); - } - xf86Info.consoleFd = fd; - } - return; -} - -void -xf86CloseConsole() -{ - close( xf86Info.consoleFd ); - return; -} diff --git a/hw/xfree86/os-support/hurd/hurd_mmap.c b/hw/xfree86/os-support/hurd/hurd_mmap.c deleted file mode 100644 index ccef5f218..000000000 --- a/hw/xfree86/os-support/hurd/hurd_mmap.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 1997 by UCHIYAMA Yasushi - * - * 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 UCHIYAMA Yasushi not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. UCHIYAMA Yasushi makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include<mach.h> -#include<device/device.h> -#include<mach/machine/mach_i386.h> - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#define BIOS_SIZE 0x20000 - -int -xf86ReadBIOS(unsigned long Base,unsigned long Offset,unsigned char *Buf,int Len) -{ - mach_port_t device,iopl_dev; - memory_object_t iopl_mem; - vm_address_t addr = (vm_address_t)0; /* serach starting address */ - kern_return_t err; - - - err = get_privileged_ports (NULL, &device); - if( err ) - { - errno = err; - FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",strerror(errno)); - } - err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev); - mach_port_deallocate (mach_task_self (), device); - if( err ) - { - errno = err; - FatalError("xf86ReadBIOS() can't device_open. (%s)\n",strerror(errno)); - } - err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , BIOS_SIZE ,&iopl_mem,0); - if( err ) - { - errno = err; - FatalError("xf86ReadBIOS() can't device_map. (%s)\n",strerror(errno)); - } - err = vm_map(mach_task_self(), - &addr, - BIOS_SIZE, - 0, - TRUE, - iopl_mem, - Base, - FALSE, - VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE, - VM_INHERIT_SHARE); - mach_port_deallocate(mach_task_self(),iopl_mem); - if( err ) - { - errno = err; - FatalError("xf86ReadBIOS() can't vm_map. (%s)\n",strerror(errno)); - } - - memcpy(Buf,(void*)((int)addr + Offset), Len); - - err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE); - if( err ) - { - errno = err; - FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",strerror(errno)); - } - - return Len; -} diff --git a/hw/xfree86/os-support/hurd/hurd_mouse.c b/hw/xfree86/os-support/hurd/hurd_mouse.c deleted file mode 100644 index 089cba38d..000000000 --- a/hw/xfree86/os-support/hurd/hurd_mouse.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 1997,1998 by UCHIYAMA Yasushi - * - * 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 UCHIYAMA Yasushi not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. UCHIYAMA Yasushi makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL UCHIYAMA YASUSHI 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. - * - */ - -#define NEED_EVENTS -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xproto.h> -#include "inputstr.h" -#include "scrnintstr.h" -#include "mipointer.h" - -#include "xf86.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" -#include "xf86_OSlib.h" -#include "xisb.h" - -#include <stdio.h> -#include <errno.h> -#include <sys/time.h> -#include <sys/file.h> -#include <assert.h> -#include <mach.h> -#include <sys/ioctl.h> - -#define DEFAULT_MOUSE_DEV "/dev/mouse" - -typedef unsigned short kev_type; /* kd event type */ -typedef unsigned char Scancode; - -struct mouse_motion { - short mm_deltaX; /* units? */ - short mm_deltaY; -}; - -typedef struct { - kev_type type; /* see below */ - struct timeval time; /* timestamp */ - union { /* value associated with event */ - boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */ - Scancode sc; /* KEYBD_EVENT */ - struct mouse_motion mmotion; /* MOUSE_MOTION */ - } value; -} kd_event; - -/* - * kd_event ID's. - */ -#define MOUSE_LEFT 1 /* mouse left button up/down */ -#define MOUSE_MIDDLE 2 -#define MOUSE_RIGHT 3 -#define MOUSE_MOTION 4 /* mouse motion */ -#define KEYBD_EVENT 5 /* key up/down */ - -#define NUMEVENTS 64 - -/* - * OsMouseReadInput -- - * Get some events from our queue. Process all outstanding events now. - */ -static void -OsMouseReadInput(InputInfoPtr pInfo) -{ - MouseDevPtr pMse; - static kd_event eventList[NUMEVENTS]; - int n, c; - kd_event *event = eventList; - unsigned char *pBuf; - - pMse = pInfo->private; - - XisbBlockDuration(pMse->buffer, -1); - pBuf = (unsigned char *)eventList; - n = 0; - while ((c = XisbRead(pMse->buffer)) >= 0 && n < sizeof(eventList)) - pBuf[n++] = (unsigned char)c; - - if (n == 0) - return; - - n /= sizeof(kd_event); - while( n-- ) { - int buttons = pMse->lastButtons; - int dx = 0, dy = 0; - switch (event->type) { - case MOUSE_RIGHT: - buttons = buttons & 6 |(event->value.up ? 0 : 1); - break; - case MOUSE_MIDDLE: - buttons = buttons & 5 |(event->value.up ? 0 : 2); - break; - case MOUSE_LEFT: - buttons = buttons & 3 |(event->value.up ? 0 : 4) ; - break; - case MOUSE_MOTION: - dx = event->value.mmotion.mm_deltaX; - dy = - event->value.mmotion.mm_deltaY; - break; - default: - ErrorF("Bad mouse event (%d)\n",event->type); - continue; - } - pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0); - ++event; - } - return; -} - -static Bool -OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - MouseDevPtr pMse; - - /* This is called when the protocol is "OSMouse". */ - - pMse = pInfo->private; - pMse->protocol = protocol; - xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); - - /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); - xf86ProcessCommonOptions(pInfo, pInfo->options); - - /* Check if the device can be opened. */ - pInfo->fd = xf86OpenSerial(pInfo->options); - if (pInfo->fd == -1) { - if (xf86GetAllowMouseOpenFail()) - xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); - else { - xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); - xfree(pMse); - return FALSE; - } - } - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - - /* Process common mouse options (like Emulate3Buttons, etc). */ - pMse->CommonOptions(pInfo); - - /* Setup the local procs. */ - pInfo->read_input = OsMouseReadInput; - - pInfo->flags |= XI86_CONFIGURED; - return TRUE; -} - -static const char * -FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) -{ - const char path[] = DEFAULT_MOUSE_DEV; - int fd; - - SYSCALL (fd = open(path, O_RDWR | O_NONBLOCK | O_EXCL)); - - if (fd == -1) - return NULL; - - close(fd); - pInfo->conf_idev->commonOptions = - xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", path); - xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", pInfo->name, - path); - - return path; -} - -static int -SupportedInterfaces(void) -{ - /* XXX Need to check this. */ - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; -} - -static const char *internalNames[] = { - "OSMouse", - NULL -}; - -static const char ** -BuiltinNames(void) -{ - return internalNames; -} - -static Bool -CheckProtocol(const char *protocol) -{ - int i; - - for (i = 0; internalNames[i]; i++) - if (xf86NameCmp(protocol, internalNames[i]) == 0) - return TRUE; - return FALSE; -} - -static const char * -DefaultProtocol(void) -{ - return "OSMouse"; -} - -OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - p->SupportedInterfaces = SupportedInterfaces; - p->BuiltinNames = BuiltinNames; - p->FindDevice = FindDevice; - p->DefaultProtocol = DefaultProtocol; - p->CheckProtocol = CheckProtocol; - p->PreInit = OsMousePreInit; - return p; -} - diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c deleted file mode 100644 index 04763ada7..000000000 --- a/hw/xfree86/os-support/hurd/hurd_video.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 1997, 1998 by UCHIYAMA Yasushi - * - * 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 UCHIYAMA Yasushi not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. UCHIYAMA Yasushi makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <mach.h> -#include <device/device.h> -#include <mach/machine/mach_i386.h> - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -/************************************************************************** - * Video Memory Mapping section - ***************************************************************************/ -pointer -xf86MapVidMem(int ScreenNum,int Flags, unsigned long Base, unsigned long Size) -{ - mach_port_t device,iopl_dev; - memory_object_t iopl_mem; - kern_return_t err; - vm_address_t addr=(vm_address_t)0; - - err = get_privileged_ports (NULL, &device); - if( err ) - { - errno = err; - FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",strerror(errno)); - } - err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev); - mach_port_deallocate (mach_task_self(), device); - if( err ) - { - errno = err; - FatalError("xf86MapVidMem() can't device_open. (%s)\n",strerror(errno)); - } - - err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , Size ,&iopl_mem,0); - if( err ) - { - errno = err; - FatalError("xf86MapVidMem() can't device_map. (%s)\n",strerror(errno)); - } - err = vm_map(mach_task_self(), - &addr, - Size, - 0, /* mask */ - TRUE, /* anywhere */ - iopl_mem, - (vm_offset_t)Base, - FALSE, /* copy on write */ - VM_PROT_READ|VM_PROT_WRITE, - VM_PROT_READ|VM_PROT_WRITE, - VM_INHERIT_SHARE); - mach_port_deallocate(mach_task_self(),iopl_mem); - if( err ) - { - errno = err; - FatalError("xf86MapVidMem() can't vm_map.(iopl_mem) (%s)\n",strerror(errno)); - } - mach_port_deallocate(mach_task_self(),iopl_dev); - if( err ) - { - errno = err; - FatalError("xf86MapVidMem() can't mach_port_deallocate.(iopl_dev) (%s)\n",strerror(errno)); - } - return (pointer)addr; -} - -void -xf86UnMapVidMem(int ScreenNum,pointer Base,unsigned long Size) -{ - kern_return_t err = vm_deallocate(mach_task_self(), (int)Base, Size); - if( err ) - { - errno = err; - ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",strerror(errno)); - } - return; -} - -Bool -xf86LinearVidMem() -{ - return(TRUE); -} - -/************************************************************************** - * I/O Permissions section - ***************************************************************************/ - -/* - * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare - * this. - */ -extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on); - -Bool -xf86EnableIO() -{ - if (ioperm(0, 0x10000, 1)) { - FatalError("xf86EnableIO: ioperm() failed (%s)\n", strerror(errno)); - return FALSE; - } - ioperm(0x40,4,0); /* trap access to the timer chip */ - ioperm(0x60,4,0); /* trap access to the keyboard controller */ - return TRUE; -} - -void -xf86DisableIO() -{ - ioperm(0,0x10000,0); - return; -} - -/************************************************************************** - * Interrupt Handling section - **************************************************************************/ -Bool -xf86DisableInterrupts() -{ - return TRUE; -} -void -xf86EnableInterrupts() -{ - return; -} - -void -xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, - unsigned long Size) -{ -} - -Bool -xf86CheckMTRR(int s) -{ - return FALSE; -} - diff --git a/hw/xfree86/os-support/int10Defines.h b/hw/xfree86/os-support/int10Defines.h deleted file mode 100644 index d942fbdad..000000000 --- a/hw/xfree86/os-support/int10Defines.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2000-2001 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _INT10DEFINES_H_ -#define _INT10DEFINES_H_ 1 - -#ifdef _VM86_LINUX - -#include <asm/vm86.h> - -#define CPU_R(type,name,num) \ - (((type *)&(((struct vm86_struct *)REG->cpuRegs)->regs.name))[num]) -#define CPU_RD(name,num) CPU_R(CARD32,name,num) -#define CPU_RW(name,num) CPU_R(CARD16,name,num) -#define CPU_RB(name,num) CPU_R(CARD8,name,num) - -#define X86_EAX CPU_RD(eax,0) -#define X86_EBX CPU_RD(ebx,0) -#define X86_ECX CPU_RD(ecx,0) -#define X86_EDX CPU_RD(edx,0) -#define X86_ESI CPU_RD(esi,0) -#define X86_EDI CPU_RD(edi,0) -#define X86_EBP CPU_RD(ebp,0) -#define X86_EIP CPU_RD(eip,0) -#define X86_ESP CPU_RD(esp,0) -#define X86_EFLAGS CPU_RD(eflags,0) - -#define X86_FLAGS CPU_RW(eflags,0) -#define X86_AX CPU_RW(eax,0) -#define X86_BX CPU_RW(ebx,0) -#define X86_CX CPU_RW(ecx,0) -#define X86_DX CPU_RW(edx,0) -#define X86_SI CPU_RW(esi,0) -#define X86_DI CPU_RW(edi,0) -#define X86_BP CPU_RW(ebp,0) -#define X86_IP CPU_RW(eip,0) -#define X86_SP CPU_RW(esp,0) -#define X86_CS CPU_RW(cs,0) -#define X86_DS CPU_RW(ds,0) -#define X86_ES CPU_RW(es,0) -#define X86_SS CPU_RW(ss,0) -#define X86_FS CPU_RW(fs,0) -#define X86_GS CPU_RW(gs,0) - -#define X86_AL CPU_RB(eax,0) -#define X86_BL CPU_RB(ebx,0) -#define X86_CL CPU_RB(ecx,0) -#define X86_DL CPU_RB(edx,0) - -#define X86_AH CPU_RB(eax,1) -#define X86_BH CPU_RB(ebx,1) -#define X86_CH CPU_RB(ecx,1) -#define X86_DH CPU_RB(edx,1) - -#elif defined(_X86EMU) - -#include "xf86x86emu.h" - -#endif - -#endif diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am deleted file mode 100644 index 93f09c10c..000000000 --- a/hw/xfree86/os-support/linux/Makefile.am +++ /dev/null @@ -1,57 +0,0 @@ -noinst_LTLIBRARIES = liblinux.la - -if LINUX_IA64 -PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c -PLATFORM_DEFINES = -DOS_PROBE_PCI_CHIPSET=lnxProbePciChipset -PLATFORM_INCLUDES = -I$(srcdir)/../shared -endif -if LINUX_ALPHA -noinst_LTLIBRARIES += liblinuxev56.la -PLATFORM_PCI_SUPPORT = \ - $(srcdir)/lnx_axp.c \ - $(srcdir)/../shared/xf86Axp.c - -liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56 - -liblinuxev56_la_SOURCES = lnx_ev56.c -endif - -if LNXACPI -ACPI_SRCS = lnx_acpi.c lnx_apm.c -XORG_CFLAGS += -DHAVE_ACPI -endif - -if LNXAPM -APM_SRCS = lnx_apm.c -XORG_CFLAGS += -DHAVE_APM -endif - -liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \ - lnx_pci.c lnx_agp.c lnx_kmod.c lnx_bell.c \ - $(srcdir)/../shared/bios_mmap.c \ - $(srcdir)/../shared/VTsw_usl.c \ - $(srcdir)/../shared/posix_tty.c \ - $(srcdir)/../shared/vidmem.c \ - $(srcdir)/../shared/sigio.c \ - $(srcdir)/../shared/stdResource.c \ - $(ACPI_SRCS) \ - $(APM_SRCS) \ - $(PLATFORM_PCI_SUPPORT) - -AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES) - -INCLUDES = $(XORG_INCS) $(PLATFORM_INCLUDES) -I/usr/include/drm # FIXME this last part is crack - -# FIXME: These need to be added to the build -LNX_EXTRA_SRCS = \ - lnx_font.c \ - lnxResource.c - -EXTRA_DIST = \ - $(LNX_EXTRA_SRCS) \ - lnx.h \ - $(srcdir)/../shared/xf86Axp.h - -if LINUX_ALPHA -liblinux_la_LIBADD = liblinuxev56.la -endif diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c deleted file mode 100644 index 574843473..000000000 --- a/hw/xfree86/os-support/linux/int10/linux.c +++ /dev/null @@ -1,553 +0,0 @@ -/* - * linux specific part of the int10 module - * Copyright 1999, 2000, 2001, 2002, 2003, 2004 Egbert Eich - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Pci.h" -#include "compiler.h" -#define _INT10_PRIVATE -#include "xf86int10.h" -#ifdef __sparc__ -#define DEV_MEM "/dev/fb" -#else -#define DEV_MEM "/dev/mem" -#endif -#define ALLOC_ENTRIES(x) ((V_RAM / x) - 1) -#define SHMERRORPTR (pointer)(-1) - -#include <fcntl.h> -#include <errno.h> -#include <sys/mman.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <unistd.h> -#include <string.h> - -static int counter = 0; -static unsigned long int10Generation = 0; - -static CARD8 read_b(xf86Int10InfoPtr pInt, int addr); -static CARD16 read_w(xf86Int10InfoPtr pInt, int addr); -static CARD32 read_l(xf86Int10InfoPtr pInt, int addr); -static void write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val); -static void write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val); -static void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val); - -int10MemRec linuxMem = { - read_b, - read_w, - read_l, - write_b, - write_w, - write_l -}; - -typedef struct { - int lowMem; - int highMem; - char* base; - char* base_high; - int screen; - char* alloc; -} linuxInt10Priv; - -#if defined DoSubModules - -typedef enum { - INT10_NOT_LOADED, - INT10_LOADED_VM86, - INT10_LOADED_X86EMU, - INT10_LOAD_FAILED -} Int10LinuxSubModuleState; - -static Int10LinuxSubModuleState loadedSubModule = INT10_NOT_LOADED; - -static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn); - -#endif /* DoSubModules */ - -xf86Int10InfoPtr -xf86ExtendedInitInt10(int entityIndex, int Flags) -{ - xf86Int10InfoPtr pInt = NULL; - int screen; - int fd; - static void* vidMem = NULL; - static void* sysMem = NULL; - void* vMem = NULL; - void *options = NULL; - int low_mem; - int high_mem = -1; - char *base = SHMERRORPTR; - char *base_high = SHMERRORPTR; - int pagesize; - memType cs; - legacyVGARec vga; - Bool videoBiosMapped = FALSE; - - if (int10Generation != serverGeneration) { - counter = 0; - int10Generation = serverGeneration; - } - - screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex; - - options = xf86HandleInt10Options(xf86Screens[screen],entityIndex); - - if (int10skip(options)) { - xfree(options); - return NULL; - } - -#if defined DoSubModules - if (loadedSubModule == INT10_NOT_LOADED) - loadedSubModule = int10LinuxLoadSubModule(xf86Screens[screen]); - - if (loadedSubModule == INT10_LOAD_FAILED) - return NULL; -#endif - - if ((!vidMem) || (!sysMem)) { - if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { - if (!sysMem) { -#ifdef DEBUG - ErrorF("Mapping sys bios area\n"); -#endif - if ((sysMem = mmap((void *)(SYS_BIOS), BIOS_SIZE, - PROT_READ | PROT_EXEC, - MAP_SHARED | MAP_FIXED, fd, SYS_BIOS)) - == MAP_FAILED) { - xf86DrvMsg(screen, X_ERROR, "Cannot map SYS BIOS\n"); - close(fd); - goto error0; - } - } - if (!vidMem) { -#ifdef DEBUG - ErrorF("Mapping VRAM area\n"); -#endif - if ((vidMem = mmap((void *)(V_RAM), VRAM_SIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_SHARED | MAP_FIXED, fd, V_RAM)) - == MAP_FAILED) { - xf86DrvMsg(screen, X_ERROR, "Cannot map V_RAM\n"); - close(fd); - goto error0; - } - } - close(fd); - } else { - xf86DrvMsg(screen, X_ERROR, "Cannot open %s\n", DEV_MEM); - goto error0; - } - } - - pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec)); - pInt->scrnIndex = screen; - pInt->entityIndex = entityIndex; - pInt->dev = xf86GetPciInfoForEntity(entityIndex); - - if (!xf86Int10ExecSetup(pInt)) - goto error0; - pInt->mem = &linuxMem; - pagesize = getpagesize(); - pInt->private = (pointer)xnfcalloc(1, sizeof(linuxInt10Priv)); - ((linuxInt10Priv*)pInt->private)->screen = screen; - ((linuxInt10Priv*)pInt->private)->alloc = - (pointer)xnfcalloc(1, ALLOC_ENTRIES(pagesize)); - - if (!xf86IsEntityPrimary(entityIndex)) { -#ifdef DEBUG - ErrorF("Mapping high memory area\n"); -#endif - if ((high_mem = shmget(counter++, HIGH_MEM_SIZE, - IPC_CREAT | SHM_R | SHM_W)) == -1) { - if (errno == ENOSYS) - xf86DrvMsg(screen, X_ERROR, "shmget error\n Please reconfigure" - " your kernel to include System V IPC support\n"); - else - xf86DrvMsg(screen, X_ERROR, - "shmget(highmem) error: %s\n",strerror(errno)); - goto error1; - } - } else { -#ifdef DEBUG - ErrorF("Mapping Video BIOS\n"); -#endif - videoBiosMapped = TRUE; - if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { - if ((vMem = mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_SHARED | MAP_FIXED, fd, V_BIOS)) - == MAP_FAILED) { - xf86DrvMsg(screen, X_ERROR, "Cannot map V_BIOS\n"); - close(fd); - goto error1; - } - close (fd); - } else - goto error1; - } - ((linuxInt10Priv*)pInt->private)->highMem = high_mem; - -#ifdef DEBUG - ErrorF("Mapping 640kB area\n"); -#endif - if ((low_mem = shmget(counter++, V_RAM, - IPC_CREAT | SHM_R | SHM_W)) == -1) { - xf86DrvMsg(screen, X_ERROR, - "shmget(lowmem) error: %s\n",strerror(errno)); - goto error2; - } - - ((linuxInt10Priv*)pInt->private)->lowMem = low_mem; - base = shmat(low_mem, 0, 0); - if (base == SHMERRORPTR) { - xf86DrvMsg(screen, X_ERROR, - "shmat(low_mem) error: %s\n",strerror(errno)); - goto error3; - } - ((linuxInt10Priv *)pInt->private)->base = base; - if (high_mem > -1) { - base_high = shmat(high_mem, 0, 0); - if (base_high == SHMERRORPTR) { - xf86DrvMsg(screen, X_ERROR, - "shmat(high_mem) error: %s\n",strerror(errno)); - goto error3; - } - ((linuxInt10Priv*)pInt->private)->base_high = base_high; - } else - ((linuxInt10Priv*)pInt->private)->base_high = NULL; - - if (!MapCurrentInt10(pInt)) - goto error3; - - Int10Current = pInt; - -#ifdef DEBUG - ErrorF("Mapping int area\n"); -#endif - if (xf86ReadBIOS(0, 0, (unsigned char *)0, LOW_PAGE_SIZE) < 0) { - xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n"); - goto error3; - } -#ifdef DEBUG - ErrorF("done\n"); -#endif - /* - * Read in everything between V_BIOS and SYS_BIOS as some system BIOSes - * have executable code there. Note that xf86ReadBIOS() can only bring in - * 64K bytes at a time. - */ - if (!videoBiosMapped) { - (void)memset((pointer)V_BIOS, 0, SYS_BIOS - V_BIOS); -#ifdef DEBUG - ErrorF("Reading BIOS\n"); -#endif - for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE) - if (xf86ReadBIOS(cs, 0, (pointer)cs, V_BIOS_SIZE) < V_BIOS_SIZE) - xf86DrvMsg(screen, X_WARNING, - "Unable to retrieve all of segment 0x%06lX.\n", cs); -#ifdef DEBUG - ErrorF("done\n"); -#endif - } - - if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) { - if (!xf86int10GetBiosSegment(pInt, NULL)) - goto error3; - - set_return_trap(pInt); -#ifdef _PC - pInt->Flags = Flags & (SET_BIOS_SCRATCH | RESTORE_BIOS_SCRATCH); - if (! (pInt->Flags & SET_BIOS_SCRATCH)) - pInt->Flags &= ~RESTORE_BIOS_SCRATCH; - xf86Int10SaveRestoreBIOSVars(pInt, TRUE); -#endif - } else { - const BusType location_type = xf86int10GetBiosLocationType(pInt); - - switch (location_type) { - case BUS_PCI: { - int err; - struct pci_device *rom_device = - xf86GetPciInfoForEntity(pInt->entityIndex); - - err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS)); - if (err) { - xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n", - strerror(err)); - goto error3; - } - - pInt->BIOSseg = V_BIOS >> 4; - break; - } - case BUS_ISA: - if (!xf86int10GetBiosSegment(pInt, NULL)) - goto error3; - break; - default: - goto error3; - } - - pInt->num = 0xe6; - reset_int_vect(pInt); - set_return_trap(pInt); - LockLegacyVGA(pInt, &vga); - xf86ExecX86int10(pInt); - UnlockLegacyVGA(pInt, &vga); - } -#ifdef DEBUG - dprint(0xc0000, 0x20); -#endif - - xfree(options); - return pInt; - -error3: - if (base_high) - shmdt(base_high); - shmdt(base); - shmdt(0); - if (base_high) - shmdt((char*)HIGH_MEM); - shmctl(low_mem, IPC_RMID, NULL); - Int10Current = NULL; -error2: - if (high_mem > -1) - shmctl(high_mem, IPC_RMID,NULL); -error1: - if (vMem) - munmap(vMem, SYS_BIOS - V_BIOS); - xfree(((linuxInt10Priv*)pInt->private)->alloc); - xfree(pInt->private); -error0: - xfree(options); - xfree(pInt); - return NULL; -} - -Bool -MapCurrentInt10(xf86Int10InfoPtr pInt) -{ - pointer addr; - int fd = -1; - - if (Int10Current) { - shmdt(0); - if (((linuxInt10Priv*)Int10Current->private)->highMem >= 0) - shmdt((char*)HIGH_MEM); - else - munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS)); - } - addr = shmat(((linuxInt10Priv*)pInt->private)->lowMem, (char*)1, SHM_RND); - if (addr == SHMERRORPTR) { - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot shmat() low memory\n"); - xf86DrvMsg(pInt->scrnIndex, X_ERROR, - "shmat(low_mem) error: %s\n",strerror(errno)); - return FALSE; - } - - if (((linuxInt10Priv*)pInt->private)->highMem >= 0) { - addr = shmat(((linuxInt10Priv*)pInt->private)->highMem, - (char*)HIGH_MEM, 0); - if (addr == SHMERRORPTR) { - xf86DrvMsg(pInt->scrnIndex, X_ERROR, - "Cannot shmat() high memory\n"); - xf86DrvMsg(pInt->scrnIndex, X_ERROR, - "shmget error: %s\n",strerror(errno)); - return FALSE; - } - } else { - if ((fd = open(DEV_MEM, O_RDWR, 0)) >= 0) { - if (mmap((void *)(V_BIOS), SYS_BIOS - V_BIOS, - PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_SHARED | MAP_FIXED, fd, V_BIOS) - == MAP_FAILED) { - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot map V_BIOS\n"); - close (fd); - return FALSE; - } - } else { - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "Cannot open %s\n",DEV_MEM); - return FALSE; - } - close (fd); - } - - return TRUE; -} - -void -xf86FreeInt10(xf86Int10InfoPtr pInt) -{ - if (!pInt) - return; - -#ifdef _PC - xf86Int10SaveRestoreBIOSVars(pInt, FALSE); -#endif - if (Int10Current == pInt) { - shmdt(0); - if (((linuxInt10Priv*)pInt->private)->highMem >= 0) - shmdt((char*)HIGH_MEM); - else - munmap((pointer)V_BIOS, (SYS_BIOS - V_BIOS)); - Int10Current = NULL; - } - - if (((linuxInt10Priv*)pInt->private)->base_high) - shmdt(((linuxInt10Priv*)pInt->private)->base_high); - shmdt(((linuxInt10Priv*)pInt->private)->base); - shmctl(((linuxInt10Priv*)pInt->private)->lowMem, IPC_RMID, NULL); - if (((linuxInt10Priv*)pInt->private)->highMem >= 0) - shmctl(((linuxInt10Priv*)pInt->private)->highMem, IPC_RMID, NULL); - xfree(((linuxInt10Priv*)pInt->private)->alloc); - xfree(pInt->private); - xfree(pInt); -} - -void * -xf86Int10AllocPages(xf86Int10InfoPtr pInt, int num, int *off) -{ - int pagesize = getpagesize(); - int num_pages = ALLOC_ENTRIES(pagesize); - int i, j; - - for (i = 0; i < (num_pages - num); i++) { - if (((linuxInt10Priv*)pInt->private)->alloc[i] == 0) { - for (j = i; j < (num + i); j++) - if ((((linuxInt10Priv*)pInt->private)->alloc[j] != 0)) - break; - if (j == (num + i)) - break; - else - i = i + num; - } - } - if (i == (num_pages - num)) - return NULL; - - for (j = i; j < (i + num); j++) - ((linuxInt10Priv*)pInt->private)->alloc[j] = 1; - - *off = (i + 1) * pagesize; - - return ((linuxInt10Priv*)pInt->private)->base + ((i + 1) * pagesize); -} - -void -xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num) -{ - int pagesize = getpagesize(); - int first = (((unsigned long)pbase - - (unsigned long)((linuxInt10Priv*)pInt->private)->base) - / pagesize) - 1; - int i; - - for (i = first; i < (first + num); i++) - ((linuxInt10Priv*)pInt->private)->alloc[i] = 0; -} - -static CARD8 -read_b(xf86Int10InfoPtr pInt, int addr) -{ - return *((CARD8 *)(memType)addr); -} - -static CARD16 -read_w(xf86Int10InfoPtr pInt, int addr) -{ - return *((CARD16 *)(memType)addr); -} - -static CARD32 -read_l(xf86Int10InfoPtr pInt, int addr) -{ - return *((CARD32 *)(memType)addr); -} - -static void -write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val) -{ - *((CARD8 *)(memType)addr) = val; -} - -static void -write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val) -{ - *((CARD16 *)(memType)addr) = val; -} - -static -void write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val) -{ - *((CARD32 *)(memType) addr) = val; -} - -pointer -xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr) -{ - if (addr < V_RAM) - return ((linuxInt10Priv*)pInt->private)->base + addr; - else if (addr < V_BIOS) - return (pointer)(memType)addr; - else if (addr < SYS_BIOS) { - if (((linuxInt10Priv*)pInt->private)->base_high) - return (pointer)(((linuxInt10Priv*)pInt->private)->base_high - - V_BIOS + addr); - else - return (pointer) (memType)addr; - } else - return (pointer) (memType)addr; -} - -#if defined DoSubModules - -static Bool -vm86_tst(void) -{ - int __res; - -#ifdef __PIC__ - /* When compiling with -fPIC, we can't use asm constraint "b" because - %ebx is already taken by gcc. */ - __asm__ __volatile__("pushl %%ebx\n\t" - "movl %2,%%ebx\n\t" - "movl %1,%%eax\n\t" - "int $0x80\n\t" - "popl %%ebx" - :"=a" (__res) - :"n" ((int)113), "r" (NULL)); -#else - __asm__ __volatile__("int $0x80\n\t" - :"=a" (__res):"a" ((int)113), - "b" ((struct vm86_struct *)NULL)); -#endif - - if (__res < 0 && __res == -ENOSYS) - return FALSE; - - return TRUE; -} - -static Int10LinuxSubModuleState -int10LinuxLoadSubModule(ScrnInfoPtr pScrn) -{ - if (vm86_tst()) { - if (xf86LoadSubModule(pScrn,"vm86")) - return INT10_LOADED_VM86; - } - if (xf86LoadSubModule(pScrn,"x86emu")) - return INT10_LOADED_X86EMU; - - return INT10_LOAD_FAILED; -} - -#endif /* DoSubModules */ diff --git a/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c b/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c deleted file mode 100644 index 9412b07a4..000000000 --- a/hw/xfree86/os-support/linux/int10/vm86/linux_vm86.c +++ /dev/null @@ -1,302 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <errno.h> -#include <string.h> - -#include "xf86.h" -#include "xf86_OSproc.h" -#include "xf86Pci.h" -#include "compiler.h" -#define _INT10_PRIVATE -#include "xf86int10.h" - -#define REG pInt - -#ifdef _VM86_LINUX -#include "int10Defines.h" - -static int vm86_rep(struct vm86_struct *ptr); -static struct vm86_struct vm86_s; - -Bool -xf86Int10ExecSetup(xf86Int10InfoPtr pInt) -{ -#define VM86S ((struct vm86_struct *)pInt->cpuRegs) - - pInt->cpuRegs = &vm86_s; - VM86S->flags = 0; - VM86S->screen_bitmap = 0; - VM86S->cpu_type = CPU_586; - memset(&VM86S->int_revectored, 0xff, sizeof(VM86S->int_revectored)); - memset(&VM86S->int21_revectored, 0xff, sizeof(VM86S->int21_revectored)); - return TRUE; -} - -/* get the linear address */ -#define LIN_PREF_SI ((pref_seg << 4) + X86_SI) -#define LWECX ((prefix66 ^ prefix67) ? X86_ECX : X86_CX) -#define LWECX_ZERO {if (prefix66 ^ prefix67) X86_ECX = 0; else X86_CX = 0;} -#define DF (1 << 10) - -/* vm86 fault handling */ -static Bool -vm86_GP_fault(xf86Int10InfoPtr pInt) -{ - unsigned char *csp, *lina; - CARD32 org_eip; - int pref_seg; - int done, is_rep, prefix66, prefix67; - - csp = lina = SEG_ADR((unsigned char *), X86_CS, IP); - - is_rep = 0; - prefix66 = prefix67 = 0; - pref_seg = -1; - - /* eat up prefixes */ - done = 0; - do { - switch (MEM_RB(pInt, (int)csp++)) { - case 0x66: /* operand prefix */ prefix66=1; break; - case 0x67: /* address prefix */ prefix67=1; break; - case 0x2e: /* CS */ pref_seg=X86_CS; break; - case 0x3e: /* DS */ pref_seg=X86_DS; break; - case 0x26: /* ES */ pref_seg=X86_ES; break; - case 0x36: /* SS */ pref_seg=X86_SS; break; - case 0x65: /* GS */ pref_seg=X86_GS; break; - case 0x64: /* FS */ pref_seg=X86_FS; break; - case 0xf0: /* lock */ break; - case 0xf2: /* repnz */ - case 0xf3: /* rep */ is_rep=1; break; - default: done=1; - } - } while (!done); - csp--; /* oops one too many */ - org_eip = X86_EIP; - X86_IP += (csp - lina); - - switch (MEM_RB(pInt, (int)csp)) { - case 0x6c: /* insb */ - /* NOTE: ES can't be overwritten; prefixes 66,67 should use esi,edi,ecx - * but is anyone using extended regs in real mode? */ - /* WARNING: no test for DI wrapping! */ - X86_EDI += port_rep_inb(pInt, X86_DX, SEG_EADR((CARD32), X86_ES, DI), - X86_FLAGS & DF, is_rep ? LWECX : 1); - if (is_rep) LWECX_ZERO; - X86_IP++; - break; - - case 0x6d: /* (rep) insw / insd */ - /* NOTE: ES can't be overwritten */ - /* WARNING: no test for _DI wrapping! */ - if (prefix66) { - X86_DI += port_rep_inl(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI), - X86_EFLAGS & DF, is_rep ? LWECX : 1); - } - else { - X86_DI += port_rep_inw(pInt, X86_DX, SEG_ADR((CARD32), X86_ES, DI), - X86_FLAGS & DF, is_rep ? LWECX : 1); - } - if (is_rep) LWECX_ZERO; - X86_IP++; - break; - - case 0x6e: /* (rep) outsb */ - if (pref_seg < 0) pref_seg = X86_DS; - /* WARNING: no test for _SI wrapping! */ - X86_SI += port_rep_outb(pInt, X86_DX, (CARD32)LIN_PREF_SI, - X86_FLAGS & DF, is_rep ? LWECX : 1); - if (is_rep) LWECX_ZERO; - X86_IP++; - break; - - case 0x6f: /* (rep) outsw / outsd */ - if (pref_seg < 0) pref_seg = X86_DS; - /* WARNING: no test for _SI wrapping! */ - if (prefix66) { - X86_SI += port_rep_outl(pInt, X86_DX, (CARD32)LIN_PREF_SI, - X86_EFLAGS & DF, is_rep ? LWECX : 1); - } - else { - X86_SI += port_rep_outw(pInt, X86_DX, (CARD32)LIN_PREF_SI, - X86_FLAGS & DF, is_rep ? LWECX : 1); - } - if (is_rep) LWECX_ZERO; - X86_IP++; - break; - - case 0xe5: /* inw xx, inl xx */ - if (prefix66) X86_EAX = x_inl(csp[1]); - else X86_AX = x_inw(csp[1]); - X86_IP += 2; - break; - - case 0xe4: /* inb xx */ - X86_AL = x_inb(csp[1]); - X86_IP += 2; - break; - - case 0xed: /* inw dx, inl dx */ - if (prefix66) X86_EAX = x_inl(X86_DX); - else X86_AX = x_inw(X86_DX); - X86_IP += 1; - break; - - case 0xec: /* inb dx */ - X86_AL = x_inb(X86_DX); - X86_IP += 1; - break; - - case 0xe7: /* outw xx */ - if (prefix66) x_outl(csp[1], X86_EAX); - else x_outw(csp[1], X86_AX); - X86_IP += 2; - break; - - case 0xe6: /* outb xx */ - x_outb(csp[1], X86_AL); - X86_IP += 2; - break; - - case 0xef: /* outw dx */ - if (prefix66) x_outl(X86_DX, X86_EAX); - else x_outw(X86_DX, X86_AX); - X86_IP += 1; - break; - - case 0xee: /* outb dx */ - x_outb(X86_DX, X86_AL); - X86_IP += 1; - break; - - case 0xf4: -#ifdef DEBUG - ErrorF("hlt at %p\n", lina); -#endif - return FALSE; - - case 0x0f: - xf86DrvMsg(pInt->scrnIndex, X_ERROR, - "CPU 0x0f Trap at CS:EIP=0x%4.4x:0x%8.8lx\n", X86_CS, X86_EIP); - goto op0ferr; - - default: - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown reason for exception\n"); - - op0ferr: - dump_registers(pInt); - stack_trace(pInt); - dump_code(pInt); - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "cannot continue\n"); - return FALSE; - } /* end of switch() */ - return TRUE; -} - -static int -do_vm86(xf86Int10InfoPtr pInt) -{ - int retval, signo; - - xf86InterceptSignals(&signo); - retval = vm86_rep(VM86S); - xf86InterceptSignals(NULL); - - if (signo >= 0) { - xf86DrvMsg(pInt->scrnIndex, X_ERROR, - "vm86() syscall generated signal %d.\n", signo); - dump_registers(pInt); - dump_code(pInt); - stack_trace(pInt); - return 0; - } - - switch (VM86_TYPE(retval)) { - case VM86_UNKNOWN: - if (!vm86_GP_fault(pInt)) return 0; - break; - case VM86_STI: - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "vm86_sti :-((\n"); - dump_registers(pInt); - dump_code(pInt); - stack_trace(pInt); - return 0; - case VM86_INTx: - pInt->num = VM86_ARG(retval); - if (!int_handler(pInt)) { - xf86DrvMsg(pInt->scrnIndex, X_ERROR, - "Unknown vm86_int: 0x%X\n\n", VM86_ARG(retval)); - dump_registers(pInt); - dump_code(pInt); - stack_trace(pInt); - return 0; - } - /* I'm not sure yet what to do if we can handle ints */ - break; - case VM86_SIGNAL: - return 1; - /* - * we used to warn here and bail out - but now the sigio stuff - * always fires signals at us. So we just ignore them for now. - */ - xf86DrvMsg(pInt->scrnIndex, X_WARNING, "received signal\n"); - return 0; - default: - xf86DrvMsg(pInt->scrnIndex, X_ERROR, "unknown type(0x%x)=0x%x\n", - VM86_ARG(retval), VM86_TYPE(retval)); - dump_registers(pInt); - dump_code(pInt); - stack_trace(pInt); - return 0; - } - - return 1; -} - -void -xf86ExecX86int10(xf86Int10InfoPtr pInt) -{ - int sig = setup_int(pInt); - - if (int_handler(pInt)) - while(do_vm86(pInt)) {}; - - finish_int(pInt, sig); -} - -static int -vm86_rep(struct vm86_struct *ptr) -{ - int __res; - -#ifdef __PIC__ - /* When compiling with -fPIC, we can't use asm constraint "b" because - %ebx is already taken by gcc. */ - __asm__ __volatile__("pushl %%ebx\n\t" - "push %%gs\n\t" - "movl %2,%%ebx\n\t" - "movl %1,%%eax\n\t" - "int $0x80\n\t" - "pop %%gs\n\t" - "popl %%ebx" - :"=a" (__res) - :"n" ((int)113), "r" ((struct vm86_struct *)ptr)); -#else - __asm__ __volatile__("push %%gs\n\t" - "int $0x80\n\t" - "pop %%gs" - :"=a" (__res):"a" ((int)113), - "b" ((struct vm86_struct *)ptr)); -#endif - - if (__res < 0) { - errno = -__res; - __res = -1; - } - else errno = 0; - return __res; -} - -#endif diff --git a/hw/xfree86/os-support/linux/lnx.h b/hw/xfree86/os-support/linux/lnx.h deleted file mode 100644 index 085c94265..000000000 --- a/hw/xfree86/os-support/linux/lnx.h +++ /dev/null @@ -1,53 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef LNX_H_ -# ifdef __alpha__ -extern unsigned long _bus_base __P ((void)) __attribute__ ((const)); -extern unsigned long _bus_base_sparse __P ((void)) __attribute__ ((const)); -extern int iopl __P ((int __level)); - -/* new pciconfig_iobase syscall added in 2.2.15 and 2.3.99 */ -# include <linux/unistd.h> -extern long (*_iobase)(unsigned, int, int, int); - -/* - * _iobase deals with the case the __NR_pciconfig_iobase is either undefined - * or unsupported by the kernel, but we need to make sure that the `which' - * argument symbols are defined. - */ -# ifndef IOBASE_HOSE -# define IOBASE_HOSE 0 -# endif -# ifndef IOBASE_SPARSE_MEM -# define IOBASE_SPARSE_MEM 1 -# endif -# ifndef IOBASE_DENSE_MEM -# define IOBASE_DENSE_MEM 2 -# endif -# ifndef IOBASE_SPARSE_IO -# define IOBASE_SPARSE_IO 3 -# endif -# ifndef IOBASE_DENSE_IO -# define IOBASE_DENSE_IO 4 -# endif -# ifndef IOBASE_ROOT_BUS -# define IOBASE_ROOT_BUS 5 -# endif -# ifndef IOBASE_FROM_HOSE -# define IOBASE_FROM_HOSE 0x10000 -# endif -# endif /* __alpha__ */ - -# if defined(DO_OS_FONTRESTORE) -Bool lnx_savefont(void); -Bool lnx_restorefont(void); -Bool lnx_switchaway(void); -void lnx_freefontdata(void); -# endif - -#define LNX_H_ - -#endif diff --git a/hw/xfree86/os-support/linux/lnxResource.c b/hw/xfree86/os-support/linux/lnxResource.c deleted file mode 100644 index 734f4d674..000000000 --- a/hw/xfree86/os-support/linux/lnxResource.c +++ /dev/null @@ -1,105 +0,0 @@ - -/* Resource information code */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86Privstr.h" -#include "xf86Pci.h" -#include "xf86Resources.h" -#define NEED_OS_RAC_PROTOS -#include "xf86_OSlib.h" -#include "lnx.h" - -/* Avoid Imakefile changes */ -#include "bus/Pci.h" - -#ifdef INCLUDE_XF86_NO_DOMAIN - -#ifdef __alpha__ - -resPtr -xf86AccResFromOS(resPtr ret) -{ - resRange range; - - /* - * Fallback is to claim the following areas: - * - * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS - */ - - RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - - /* - * Fallback would be to claim well known ports in the 0x0 - 0x3ff range - * along with their sparse I/O aliases, but that's too imprecise. Instead - * claim a bare minimum here. - */ - RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ - ret = xf86AddResToList(ret, &range, -1); - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ - RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); -/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); */ - RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); - - /* XXX add others */ - return ret; -} - -#elif defined(__powerpc__) || \ - defined(__sparc__) || \ - defined(__mips__) || \ - defined(__sh__) || \ - defined(__m32r__) || \ - defined(__mc68000__) || \ - defined(__arm__) || \ - defined(__s390__) || \ - defined(__hppa__) - -resPtr -xf86AccResFromOS(resPtr ret) -{ - resRange range; - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ - RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); -#if defined(__sparc__) || defined(__powerpc__) - RANGE(range, 0x00ffffff, 0x00ffffff, ResExcIoBlock); -#else - RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); -#endif - ret = xf86AddResToList(ret, &range, -1); - - return ret; -} - -#else - -#error : Put your platform dependent code here!! - -#endif - -#endif /* INCLUDE_XF86_NO_DOMAIN */ diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c deleted file mode 100644 index bb975cc5d..000000000 --- a/hw/xfree86/os-support/linux/lnx_acpi.c +++ /dev/null @@ -1,181 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include "xorg-config.h" -#endif - -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/un.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> - -#define ACPI_SOCKET "/var/run/acpid.socket" - -#define ACPI_VIDEO_NOTIFY_SWITCH 0x80 -#define ACPI_VIDEO_NOTIFY_PROBE 0x81 -#define ACPI_VIDEO_NOTIFY_CYCLE 0x82 -#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 -#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 - -#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85 -#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86 -#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87 -#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88 -#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89 - -#define ACPI_VIDEO_HEAD_INVALID (~0u - 1) -#define ACPI_VIDEO_HEAD_END (~0u) - -static void lnxCloseACPI(void); -static pointer ACPIihPtr = NULL; -PMClose lnxACPIOpen(void); - -/* in milliseconds */ -#define ACPI_REOPEN_DELAY 1000 - -static CARD32 -lnxACPIReopen(OsTimerPtr timer, CARD32 time, pointer arg) -{ - if (lnxACPIOpen()) { - TimerFree(timer); - return 0; - } - - return ACPI_REOPEN_DELAY; -} - -#define LINE_LENGTH 80 - -static int -lnxACPIGetEventFromOs(int fd, pmEvent *events, int num) -{ - char ev[LINE_LENGTH]; - int n; - - memset(ev, 0, LINE_LENGTH); - - do { - n = read( fd, ev, LINE_LENGTH ); - } while ((n == -1) && (errno == EAGAIN || errno == EINTR)); - - if (n <= 0) { - lnxCloseACPI(); - TimerSet(NULL, 0, ACPI_REOPEN_DELAY, lnxACPIReopen, NULL); - return 0; - } - /* FIXME: this only processes the first read ACPI event & might break - * with interrupted reads. */ - - /* Check that we have a video event */ - if (!strncmp(ev, "video", 5)) { - char *video = NULL; - char *GFX = NULL; - char *notify = NULL; - char *data = NULL; /* doesn't appear to be used in the kernel */ - unsigned long int notify_l, data_l; - - video = strtok(ev, " "); - - GFX = strtok(NULL, " "); -#if 0 - ErrorF("GFX: %s\n",GFX); -#endif - - notify = strtok(NULL, " "); - notify_l = strtoul(notify, NULL, 16); -#if 0 - ErrorF("notify: 0x%lx\n",notify_l); -#endif - - data = strtok(NULL, " "); - data_l = strtoul(data, NULL, 16); -#if 0 - ErrorF("data: 0x%lx\n",data_l); -#endif - - /* Differentiate between events */ - switch (notify_l) { - case ACPI_VIDEO_NOTIFY_SWITCH: - case ACPI_VIDEO_NOTIFY_CYCLE: - case ACPI_VIDEO_NOTIFY_NEXT_OUTPUT: - case ACPI_VIDEO_NOTIFY_PREV_OUTPUT: - events[0] = XF86_APM_CAPABILITY_CHANGED; - return 1; - case ACPI_VIDEO_NOTIFY_PROBE: - return 0; - default: - return 0; - } - } - - return 0; -} - -static pmWait -lnxACPIConfirmEventToOs(int fd, pmEvent event) -{ - /* No ability to send back to the kernel in ACPI */ - switch (event) { - default: - return PM_NONE; - } -} - -PMClose -lnxACPIOpen(void) -{ - int fd; - struct sockaddr_un addr; - int r = -1; - -#ifdef DEBUG - ErrorF("ACPI: OSPMOpen called\n"); -#endif - if (ACPIihPtr || !xf86Info.pmFlag) - return NULL; - -#ifdef DEBUG - ErrorF("ACPI: Opening device\n"); -#endif - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) > -1) { - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_UNIX; - strcpy(addr.sun_path, ACPI_SOCKET); - if ((r = connect(fd, (struct sockaddr*)&addr, sizeof(addr))) == -1) { - xf86MsgVerb(X_WARNING,3,"Open ACPI failed (%s) (%s)\n", ACPI_SOCKET, - strerror(errno)); - shutdown(fd, 2); - close(fd); - return NULL; - } - } - - xf86PMGetEventFromOs = lnxACPIGetEventFromOs; - xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs; - ACPIihPtr = xf86AddGeneralHandler(fd,xf86HandlePMEvents,NULL); - xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET); - - return lnxCloseACPI; -} - -static void -lnxCloseACPI(void) -{ - int fd; - -#ifdef DEBUG - ErrorF("ACPI: Closing device\n"); -#endif - if (ACPIihPtr) { - fd = xf86RemoveGeneralHandler(ACPIihPtr); - shutdown(fd, 2); - close(fd); - ACPIihPtr = NULL; - } -} diff --git a/hw/xfree86/os-support/linux/lnx_agp.c b/hw/xfree86/os-support/linux/lnx_agp.c deleted file mode 100644 index ded9e0fae..000000000 --- a/hw/xfree86/os-support/linux/lnx_agp.c +++ /dev/null @@ -1,374 +0,0 @@ -/* - * Abstraction of the AGP GART interface. - * - * This version is for Linux and Free/Open/NetBSD. - * - * Copyright © 2000 VA Linux Systems, Inc. - * Copyright © 2001 The XFree86 Project, Inc. - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#if defined(linux) -#include <asm/ioctl.h> -#include <linux/agpgart.h> -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -#include <sys/ioctl.h> -#include <sys/agpio.h> -#endif - -#ifndef AGP_DEVICE -#define AGP_DEVICE "/dev/agpgart" -#endif -/* AGP page size is independent of the host page size. */ -#ifndef AGP_PAGE_SIZE -#define AGP_PAGE_SIZE 4096 -#endif -#define AGPGART_MAJOR_VERSION 0 -#define AGPGART_MINOR_VERSION 99 - -static int gartFd = -1; -static int acquiredScreen = -1; -static Bool initDone = FALSE; -/* - * Close /dev/agpgart. This frees all associated memory allocated during - * this server generation. - */ -_X_EXPORT Bool -xf86GARTCloseScreen(int screenNum) -{ - if(gartFd != -1) { - close(gartFd); - acquiredScreen = -1; - gartFd = -1; - initDone = FALSE; - } - return TRUE; -} - -/* - * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called. - */ -static Bool -GARTInit(int screenNum) -{ - struct _agp_info agpinf; - - if (initDone) - return (gartFd != -1); - - initDone = TRUE; - - if (gartFd == -1) - gartFd = open(AGP_DEVICE, O_RDWR, 0); - else - return FALSE; - - if (gartFd == -1) { - xf86DrvMsg(screenNum, X_ERROR, - "GARTInit: Unable to open " AGP_DEVICE " (%s)\n", - strerror(errno)); - return FALSE; - } - - xf86AcquireGART(-1); - /* Check the kernel driver version. */ - if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { - xf86DrvMsg(screenNum, X_ERROR, - "GARTInit: AGPIOC_INFO failed (%s)\n", strerror(errno)); - close(gartFd); - gartFd = -1; - return FALSE; - } - xf86ReleaseGART(-1); - -#if defined(linux) - /* Per Dave Jones, every effort will be made to keep the - * agpgart interface backwards compatible, so allow all - * future versions. - */ - if ( -#if (AGPGART_MAJOR_VERSION > 0) /* quiet compiler */ - agpinf.version.major < AGPGART_MAJOR_VERSION || -#endif - (agpinf.version.major == AGPGART_MAJOR_VERSION && - agpinf.version.minor < AGPGART_MINOR_VERSION)) { - xf86DrvMsg(screenNum, X_ERROR, - "GARTInit: Kernel agpgart driver version is not current" - " (%d.%d vs %d.%d)\n", - agpinf.version.major, agpinf.version.minor, - AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION); - close(gartFd); - gartFd = -1; - return FALSE; - } -#endif - - return TRUE; -} - -_X_EXPORT Bool -xf86AgpGARTSupported() -{ - return GARTInit(-1); -} - -_X_EXPORT AgpInfoPtr -xf86GetAGPInfo(int screenNum) -{ - struct _agp_info agpinf; - AgpInfoPtr info; - - if (!GARTInit(screenNum)) - return NULL; - - - if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); - return NULL; - } - - memset((char*)&agpinf, 0, sizeof(agpinf)); - - if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", - strerror(errno)); - return NULL; - } - - info->bridgeId = agpinf.bridge_id; - info->agpMode = agpinf.agp_mode; - info->base = agpinf.aper_base; - info->size = agpinf.aper_size; - info->totalPages = agpinf.pg_total; - info->systemPages = agpinf.pg_system; - info->usedPages = agpinf.pg_used; - - xf86DrvMsg(screenNum, X_INFO, "Kernel reported %d total, %d used\n", agpinf.pg_total, agpinf.pg_used); - - return info; -} - -/* - * XXX If multiple screens can acquire the GART, should we have a reference - * count instead of using acquiredScreen? - */ - -_X_EXPORT Bool -xf86AcquireGART(int screenNum) -{ - if (screenNum != -1 && !GARTInit(screenNum)) - return FALSE; - - if (screenNum == -1 || acquiredScreen != screenNum) { - if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { - xf86DrvMsg(screenNum, X_WARNING, - "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n", - strerror(errno)); - return FALSE; - } - acquiredScreen = screenNum; - } - return TRUE; -} - -_X_EXPORT Bool -xf86ReleaseGART(int screenNum) -{ - if (screenNum != -1 && !GARTInit(screenNum)) - return FALSE; - - if (acquiredScreen == screenNum) { - /* - * The FreeBSD agp driver removes allocations on release. - * The Linux driver doesn't. xf86ReleaseGART() is expected - * to give up access to the GART, but not to remove any - * allocations. - */ -#if !defined(linux) - if (screenNum == -1) -#endif - { - if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { - xf86DrvMsg(screenNum, X_WARNING, - "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n", - strerror(errno)); - return FALSE; - } - acquiredScreen = -1; - } - return TRUE; - } - return FALSE; -} - -_X_EXPORT int -xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, - unsigned long *physical) -{ - struct _agp_allocate alloc; - int pages; - - /* - * Allocates "size" bytes of GART memory (rounds up to the next - * page multiple) or type "type". A handle (key) for the allocated - * memory is returned. On error, the return value is -1. - */ - - if (!GARTInit(screenNum) || acquiredScreen != screenNum) - return -1; - - pages = (size / AGP_PAGE_SIZE); - if (size % AGP_PAGE_SIZE != 0) - pages++; - - /* XXX check for pages == 0? */ - - alloc.pg_count = pages; - alloc.type = type; - - if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: " - "allocation of %d pages failed\n\t(%s)\n", pages, - strerror(errno)); - return -1; - } - - if (physical) - *physical = alloc.physical; - - return alloc.key; -} - -_X_EXPORT Bool -xf86DeallocateGARTMemory(int screenNum, int key) -{ - if (!GARTInit(screenNum) || acquiredScreen != screenNum) - return FALSE; - - if (acquiredScreen != screenNum) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86UnbindGARTMemory: AGP not acquired by this screen\n"); - return FALSE; - } - -#ifdef __linux__ - if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) { -#else - if (ioctl(gartFd, AGPIOC_DEALLOCATE, &key) != 0) { -#endif - xf86DrvMsg(screenNum, X_WARNING,"xf86DeAllocateGARTMemory: " - "deallocation gart memory with key %d failed\n\t(%s)\n", - key, strerror(errno)); - return FALSE; - } - - return TRUE; -} - -/* Bind GART memory with "key" at "offset" */ -_X_EXPORT Bool -xf86BindGARTMemory(int screenNum, int key, unsigned long offset) -{ - struct _agp_bind bind; - int pageOffset; - - if (!GARTInit(screenNum) || acquiredScreen != screenNum) - return FALSE; - - if (acquiredScreen != screenNum) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86BindGARTMemory: AGP not acquired by this screen\n"); - return FALSE; - } - - if (offset % AGP_PAGE_SIZE != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " - "offset (0x%lx) is not page-aligned (%d)\n", - offset, AGP_PAGE_SIZE); - return FALSE; - } - pageOffset = offset / AGP_PAGE_SIZE; - - xf86DrvMsgVerb(screenNum, X_INFO, 3, - "xf86BindGARTMemory: bind key %d at 0x%08lx " - "(pgoffset %d)\n", key, offset, pageOffset); - - bind.pg_start = pageOffset; - bind.key = key; - - if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " - "binding of gart memory with key %d\n" - "\tat offset 0x%lx failed (%s)\n", - key, offset, strerror(errno)); - return FALSE; - } - - return TRUE; -} - - -/* Unbind GART memory with "key" */ -_X_EXPORT Bool -xf86UnbindGARTMemory(int screenNum, int key) -{ - struct _agp_unbind unbind; - - if (!GARTInit(screenNum) || acquiredScreen != screenNum) - return FALSE; - - if (acquiredScreen != screenNum) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86UnbindGARTMemory: AGP not acquired by this screen\n"); - return FALSE; - } - - unbind.priority = 0; - unbind.key = key; - - if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: " - "unbinding of gart memory with key %d " - "failed (%s)\n", key, strerror(errno)); - return FALSE; - } - - xf86DrvMsgVerb(screenNum, X_INFO, 3, - "xf86UnbindGARTMemory: unbind key %d\n", key); - - return TRUE; -} - - -/* XXX Interface may change. */ -_X_EXPORT Bool -xf86EnableAGP(int screenNum, CARD32 mode) -{ - agp_setup setup; - - if (!GARTInit(screenNum) || acquiredScreen != screenNum) - return FALSE; - - setup.agp_mode = mode; - if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: " - "AGPIOC_SETUP with mode %ld failed (%s)\n", - (unsigned long)mode, strerror(errno)); - return FALSE; - } - - return TRUE; -} - diff --git a/hw/xfree86/os-support/linux/lnx_apm.c b/hw/xfree86/os-support/linux/lnx_apm.c deleted file mode 100644 index 16ac80db8..000000000 --- a/hw/xfree86/os-support/linux/lnx_apm.c +++ /dev/null @@ -1,206 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" - -#ifdef HAVE_ACPI -extern PMClose lnxACPIOpen(void); -#endif - -#ifdef HAVE_APM - -#include "lnx.h" -#include <linux/apm_bios.h> -#include <unistd.h> -#include <sys/ioctl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <errno.h> - -#define APM_PROC "/proc/apm" -#define APM_DEVICE "/dev/apm_bios" - -#ifndef APM_STANDBY_FAILED -# define APM_STANDBY_FAILED 0xf000 -#endif -#ifndef APM_SUSPEND_FAILED -# define APM_SUSPEND_FAILED 0xf001 -#endif - -static PMClose lnxAPMOpen(void); -static void lnxCloseAPM(void); -static pointer APMihPtr = NULL; - -static struct { - apm_event_t apmLinux; - pmEvent xf86; -} LinuxToXF86[] = { - { APM_SYS_STANDBY, XF86_APM_SYS_STANDBY }, - { APM_SYS_SUSPEND, XF86_APM_SYS_SUSPEND }, - { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, - { APM_CRITICAL_RESUME, XF86_APM_CRITICAL_RESUME }, - { APM_LOW_BATTERY, XF86_APM_LOW_BATTERY }, - { APM_POWER_STATUS_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, - { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, - { APM_CRITICAL_SUSPEND, XF86_APM_CRITICAL_SUSPEND }, - { APM_USER_STANDBY, XF86_APM_USER_STANDBY }, - { APM_USER_SUSPEND, XF86_APM_USER_SUSPEND }, - { APM_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, -#if defined(APM_CAPABILITY_CHANGED) - { APM_CAPABILITY_CHANGED, XF86_CAPABILITY_CHANGED }, -#endif -#if 0 - { APM_STANDBY_FAILED, XF86_APM_STANDBY_FAILED }, - { APM_SUSPEND_FAILED, XF86_APM_SUSPEND_FAILED } -#endif -}; - -#define numApmEvents (sizeof(LinuxToXF86) / sizeof(LinuxToXF86[0])) - -/* - * APM is still under construction. - * I'm not sure if the places where I initialize/deinitialize - * apm is correct. Also I don't know what to do in SETUP state. - * This depends if wakeup gets called in this situation, too. - * Also we need to check if the action that is taken on an - * event is reasonable. - */ -static int -lnxPMGetEventFromOs(int fd, pmEvent *events, int num) -{ - int i,j,n; - apm_event_t linuxEvents[8]; - - if ((n = read( fd, linuxEvents, num * sizeof(apm_event_t) )) == -1) - return 0; - n /= sizeof(apm_event_t); - if (n > num) - n = num; - for (i = 0; i < n; i++) { - for (j = 0; j < numApmEvents; j++) - if (LinuxToXF86[j].apmLinux == linuxEvents[i]) { - events[i] = LinuxToXF86[j].xf86; - break; - } - if (j == numApmEvents) - events[i] = XF86_APM_UNKNOWN; - } - return n; -} - -static pmWait -lnxPMConfirmEventToOs(int fd, pmEvent event) -{ - switch (event) { - case XF86_APM_SYS_STANDBY: - case XF86_APM_USER_STANDBY: - if (ioctl( fd, APM_IOC_STANDBY, NULL )) - return PM_FAILED; - return PM_CONTINUE; - case XF86_APM_SYS_SUSPEND: - case XF86_APM_CRITICAL_SUSPEND: - case XF86_APM_USER_SUSPEND: - if (ioctl( fd, APM_IOC_SUSPEND, NULL )) { - /* I believe this is wrong (EE) - EBUSY is sent when a device refuses to be suspended. - In this case we still need to undo everything we have - done to suspend ourselves or we will stay in suspended - state forever. */ - if (errno == EBUSY) - return PM_CONTINUE; - else - return PM_FAILED; - } - return PM_CONTINUE; - case XF86_APM_STANDBY_RESUME: - case XF86_APM_NORMAL_RESUME: - case XF86_APM_CRITICAL_RESUME: - case XF86_APM_STANDBY_FAILED: - case XF86_APM_SUSPEND_FAILED: - return PM_CONTINUE; - default: - return PM_NONE; - } -} - -#endif // HAVE_APM - -PMClose -xf86OSPMOpen(void) -{ - PMClose ret = NULL; - -#ifdef HAVE_ACPI - /* Favour ACPI over APM, but only when enabled */ - - if (!xf86acpiDisableFlag) - ret = lnxACPIOpen(); - - if (!ret) -#endif -#ifdef HAVE_APM - ret = lnxAPMOpen(); -#endif - - return ret; -} - -#ifdef HAVE_APM - -static PMClose -lnxAPMOpen(void) -{ - int fd, pfd; - -#ifdef DEBUG - ErrorF("APM: OSPMOpen called\n"); -#endif - if (APMihPtr || !xf86Info.pmFlag) - return NULL; - -#ifdef DEBUG - ErrorF("APM: Opening device\n"); -#endif - if ((fd = open( APM_DEVICE, O_RDWR )) > -1) { - if (access( APM_PROC, R_OK ) || - ((pfd = open( APM_PROC, O_RDONLY)) == -1)) { - xf86MsgVerb(X_WARNING,3,"Cannot open APM (%s) (%s)\n", - APM_PROC, strerror(errno)); - close(fd); - return NULL; - } else - close(pfd); - xf86PMGetEventFromOs = lnxPMGetEventFromOs; - xf86PMConfirmEventToOs = lnxPMConfirmEventToOs; - APMihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL); - xf86MsgVerb(X_INFO,3,"Open APM successful\n"); - return lnxCloseAPM; - } - xf86MsgVerb(X_INFO,3,"No APM support in BIOS or kernel\n"); - return NULL; -} - -static void -lnxCloseAPM(void) -{ - int fd; - -#ifdef DEBUG - ErrorF("APM: Closing device\n"); -#endif - if (APMihPtr) { - fd = xf86RemoveInputHandler(APMihPtr); - close(fd); - APMihPtr = NULL; - } -} - -#endif // HAVE_APM diff --git a/hw/xfree86/os-support/linux/lnx_axp.c b/hw/xfree86/os-support/linux/lnx_axp.c deleted file mode 100644 index a8ad161b6..000000000 --- a/hw/xfree86/os-support/linux/lnx_axp.c +++ /dev/null @@ -1,199 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <stdio.h> -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#include "shared/xf86Axp.h" - -axpDevice lnxGetAXP(void); - -typedef struct - { char* sysName; - char* sysVari; - char* cpu; - axpDevice sys; } -AXP; - -static AXP axpList[] = { - { "Tsunami", NULL, NULL, TSUNAMI }, - { "Eiger", NULL, NULL, TSUNAMI }, - {"Noname", NULL, NULL, LCA }, - { "AlphaBook1", NULL, NULL, LCA }, - {"EB66", NULL, NULL, LCA}, - {"EB64+",NULL,NULL, APECS}, - {"Noritake",NULL,"EV5",CIA}, - {"Noritake",NULL,"EV56",CIA}, - {"Noritake",NULL,NULL,APECS}, - {"XL",NULL,NULL,APECS}, - {"Avanti",NULL,NULL,APECS}, - {"Mikasa",NULL,"EV5",CIA}, - {"Mikasa",NULL,"EV56",CIA}, - {"Mikasa",NULL,NULL,APECS}, - {"EB164","EB164",NULL,CIA}, - {"EB164","PC164", NULL,CIA}, - {"EB164","LX164",NULL, PYXIS}, - {"EB164","SX164",NULL, PYXIS}, - {"EB164","RX164",NULL, POLARIS}, - {"Alcor",NULL,NULL,CIA}, - {"Takara",NULL,NULL,CIA}, - {"Sable",NULL, "EV5",T2_GAMMA}, - {"Sable",NULL,"EV56",T2_GAMMA}, - {"Sable",NULL,NULL,T2}, - {"Rawhide",NULL,NULL,MCPCIA}, - {"Jensen",NULL,NULL,JENSEN}, - {"Miata",NULL,NULL,PYXIS_CIA}, - {"Ruffian",NULL,NULL,PYXIS_CIA}, - {"Nautilus",NULL,NULL,IRONGATE}, - {NULL,NULL,NULL,NONE} -}; - - -axpDevice -lnxGetAXP(void) -{ - FILE *file; - int count = 0; - char res[256]; - char cpu[255]; - char systype[255]; - char sysvari[255]; - if (!(file = fopen("/proc/cpuinfo","r"))) - return SYS_NONE; - do { - if (!fgets(res,0xff,file)) return SYS_NONE; - switch (count) { - case 1: - sscanf(res, "cpu model : %s",cpu); -#ifdef DEBUG - ErrorF("CPU %s\n",cpu); -#endif - break; - case 5: - sscanf(res, "system type : %s",systype); -#ifdef DEBUG - ErrorF("system type : %s\n",systype); -#endif - break; - case 6: - sscanf(res, "system variation : %s",sysvari); -#ifdef DEBUG - ErrorF("system variation: %s\n",sysvari); -#endif - break; - } - count++; - } while (count < 8); - - fclose(file); - - count = 0; - - do { - if (!axpList[count].sysName || !strcmp(axpList[count].sysName,systype)) { - if (axpList[count].sysVari && strcmp(axpList[count].sysVari,sysvari)) { - count++; - continue; - }; - if (axpList[count].cpu && strcmp(axpList[count].cpu,cpu)) { - count++; - continue; - } - return axpList[count].sys; - } - count++; - } while (1); -} - -/* - * pciconfig_iobase wrappers and dynamic i/o selection - */ -#include "lnx.h" -#include <unistd.h> -#include <errno.h> - -/* glibc versions (single hose only) */ -extern void _outb(char val, unsigned long port); -extern void _outw(short val, unsigned long port); -extern void _outl(int val, unsigned long port); -extern unsigned int _inb(unsigned long port); -extern unsigned int _inw(unsigned long port); -extern unsigned int _inl(unsigned long port); - -extern void _dense_outb(char, unsigned long); -extern void _dense_outw(short, unsigned long); -extern void _dense_outl(int, unsigned long); -extern unsigned int _dense_inb(unsigned long); -extern unsigned int _dense_inw(unsigned long); -extern unsigned int _dense_inl(unsigned long); - -_X_EXPORT void (*_alpha_outb)(char, unsigned long) = _outb; -_X_EXPORT void (*_alpha_outw)(short, unsigned long) = _outw; -_X_EXPORT void (*_alpha_outl)(int, unsigned long) = _outl; -_X_EXPORT unsigned int (*_alpha_inb)(unsigned long) = _inb; -_X_EXPORT unsigned int (*_alpha_inw)(unsigned long) = _inw; -_X_EXPORT unsigned int (*_alpha_inl)(unsigned long) = _inl; - -static long _alpha_iobase_query(unsigned, int, int, int); -long (*_iobase)(unsigned, int, int, int) = _alpha_iobase_query; - -static long -_alpha_iobase(unsigned flags, int hose, int bus, int devfn) -{ -#ifdef __NR_pciconfig_iobase - if (bus < 0) { - bus = hose; - flags |= IOBASE_FROM_HOSE; - } - - return syscall(__NR_pciconfig_iobase, flags, bus, devfn); -#else - return -ENOSYS -#endif -} - -static long -_alpha_iobase_legacy(unsigned flags, int hose, int bus, int devfn) -{ - if (hose > 0) return -ENODEV; - if (flags & IOBASE_DENSE_MEM) return _bus_base(); - if (flags & IOBASE_SPARSE_MEM) return _bus_base_sparse(); - return 0; -} - -static long -_alpha_iobase_query(unsigned flags, int hose, int bus, int devfn) -{ - /* - * Only use iobase if the syscall is supported *and* it's - * a dense io system - */ - if (_alpha_iobase(IOBASE_DENSE_IO, 0, 0, 0) > 0) { - /* - * The syscall worked and it's a dense io system - take over the - * io subsystem - */ - _iobase = _alpha_iobase; - -#ifndef INCLUDE_XF86_NO_DOMAIN - /* - * Only take over the inx/outx functions if this is a dense I/O - * system *and* addressing domains are being used. The dense I/O - * routines expect I/O to be mapped (as done in xf86MapLegacyIO) - */ - _alpha_outb = _dense_outb; - _alpha_outw = _dense_outw; - _alpha_outl = _dense_outl; - _alpha_inb = _dense_inb; - _alpha_inw = _dense_inw; - _alpha_inl = _dense_inl; -#endif /* !INCLUDE_XF86_NO_DOMAIN */ - } else _iobase = _alpha_iobase_legacy; - - return _iobase(flags, hose, bus, devfn); -} - diff --git a/hw/xfree86/os-support/linux/lnx_bell.c b/hw/xfree86/os-support/linux/lnx_bell.c deleted file mode 100644 index 93ad680d7..000000000 --- a/hw/xfree86/os-support/linux/lnx_bell.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2006 Daniel Stone - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Author: Daniel Stone <daniel@fooishbar.org> - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/ioctl.h> -#include <linux/kd.h> - -#include "xf86.h" -#include "xf86Priv.h" - -_X_EXPORT void -xf86OSRingBell(int loudness, int pitch, int duration) -{ - if (xf86Info.consoleFd == -1 || !pitch || !loudness) - return; - - ioctl(xf86Info.consoleFd, KDMKTONE, - ((1193190 / pitch) & 0xffff) | - (((unsigned long)duration * loudness / 50) << 16)); -} diff --git a/hw/xfree86/os-support/linux/lnx_ev56.c b/hw/xfree86/os-support/linux/lnx_ev56.c deleted file mode 100644 index 11c45e538..000000000 --- a/hw/xfree86/os-support/linux/lnx_ev56.c +++ /dev/null @@ -1,150 +0,0 @@ -/* This file has to be built with -mcpu=ev56 */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -int readDense8(pointer Base, register unsigned long Offset); -int readDense16(pointer Base, register unsigned long Offset); -int readDense32(pointer Base, register unsigned long Offset); -void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset); -void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset); -void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset); -void -writeDense8(int Value, pointer Base, register unsigned long Offset); -void -writeDense16(int Value, pointer Base, register unsigned long Offset); -void -writeDense32(int Value, pointer Base, register unsigned long Offset); - -int -readDense8(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(volatile CARD8*) ((unsigned long)Base+(Offset)); -} - -int -readDense16(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(volatile CARD16*) ((unsigned long)Base+(Offset)); -} - -int -readDense32(pointer Base, register unsigned long Offset) -{ - mem_barrier(); - return *(volatile CARD32*)((unsigned long)Base+(Offset)); -} - -void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset) -{ - *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset) -{ - *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value; -} - -void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset) -{ - *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDense8(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDense16(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value; -} - -void -writeDense32(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value; -} - - -#ifndef INCLUDE_XF86_NO_DOMAIN - -void -_dense_outb(char val, unsigned long port) -{ - if ((port & ~0xffff) == 0) return _outb(val, port); - - write_mem_barrier(); - *(volatile CARD8 *)port = val; -} - -void -_dense_outw(short val, unsigned long port) -{ - if ((port & ~0xffff) == 0) return _outw(val, port); - - write_mem_barrier(); - *(volatile CARD16 *)port = val; -} - -void -_dense_outl(int val, unsigned long port) -{ - if ((port & ~0xffff) == 0) return _outl(val, port); - - write_mem_barrier(); - *(volatile CARD32 *)port = val; -} - -unsigned int -_dense_inb(unsigned long port) -{ - if ((port & ~0xffff) == 0) return _inb(port); - - mem_barrier(); - return *(volatile CARD8 *)port; -} - -unsigned int -_dense_inw(unsigned long port) -{ - if ((port & ~0xffff) == 0) return _inw(port); - - mem_barrier(); - return *(volatile CARD16 *)port; -} - -unsigned int -_dense_inl(unsigned long port) -{ - if ((port & ~0xffff) == 0) return _inl(port); - - mem_barrier(); - return *(volatile CARD32 *)port; -} - -#endif /* !INCLUDE_XF86_NO_DOMAIN */ - diff --git a/hw/xfree86/os-support/linux/lnx_font.c b/hw/xfree86/os-support/linux/lnx_font.c deleted file mode 100644 index e9a5b6aef..000000000 --- a/hw/xfree86/os-support/linux/lnx_font.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright 2004, Egbert Eich - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- - * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Egbert Eich shall not - * be used in advertising or otherwise to promote the sale, use or other deal- - *ings in this Software without prior written authorization from Egbert Eich. - * - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "lnx.h" - -#include <sys/stat.h> -#include <string.h> -#include <errno.h> - -struct { - int width; - int height; - int charcount; - unsigned char *data; -} lnxfont = { 0, 0, 0, NULL }; - - -static Bool -getfont(int *width, int *height, - int *charcount, unsigned char *data) -{ - struct console_font_op op; - struct consolefontdesc ds; - int result; - - op.op = KD_FONT_OP_GET; - op.width = *width; - op.height = *height; - op.charcount = *charcount; - op.data = data; - op.flags = 0; - - SYSCALL(result = ioctl(xf86Info.consoleFd, KDFONTOP, &op)); -#ifdef DEBUG - ErrorF("Console font read: h: %i count: %i\n",op.height,op.charcount); -#endif - - if (!result) { - - *width = op.width; - *height = op.height; - *charcount = op.charcount; - - return TRUE; - } - - if (errno != ENOSYS && errno != EINVAL) - return FALSE; - - /* GIO_FONTX fallback */ - ds.charcount = *charcount; - ds.charheight = *height; - ds.chardata = (char *)data; - *width = 8; - - SYSCALL(result = ioctl(xf86Info.consoleFd, GIO_FONTX, &ds)); - - if (!result) { - - *charcount = ds.charcount; - *height = ds.charheight; - - return TRUE; - } - - if (errno != ENOSYS && errno != EINVAL) - return FALSE; - - /* GIO_FONT fallback */ - if (*charcount < 256) - return FALSE; - - SYSCALL(result = ioctl(xf86Info.consoleFd, GIO_FONT, data)); - - if (!result) { - *height = 0; - *charcount = 512; - return TRUE; - } - - return FALSE; - -} - -#define VERSION_LEN 31 - -Bool -lnx_savefont(void) -{ - unsigned char *fontdata; -#if CHECK_OS_VERSION - char kernel_version[VERSION_LEN + 1]; - int k_major, k_minor, k_release; -#endif - int size; - int fd; - int width = 32, height = 32, charcount = 2048; - -#ifdef DEBUG - ErrorF("SAVE font\n"); -#endif - -#if CHECK_OS_VERSION - /* Check if the kernel has full support for this */ - if ((fd = open ("/proc/sys/kernel/osrelease",O_RDONLY)) == -1) { - close (fd); - return TRUE; - } - size = read(fd, kernel_version, VERSION_LEN); - close (fd); - - if (size < 0) - return TRUE; - - size = sscanf(kernel_version, "%d.%d.%d",&k_major,&k_minor,&k_release); - if (size < 3 - || (k_major < 2) - || ((k_major == 2) - && ((k_minor < 6) - || ( k_minor == 6 - && k_release < 11)))) - return TRUE; -#endif - - /* if we are in fbdev mode we don't bother saving fonts */ - if ((fd = open ("/dev/fb0",O_RDWR)) != -1) { - close (fd); - return TRUE; - } - - if (!getfont(&width, &height, &charcount, NULL)) { - xf86Msg(X_WARNING, - "lnx_savefont: cannot obtain font info\n"); - goto error; - } else if (charcount == 2048) { - xf86Msg(X_WARNING, "lnx_savefont: " - "kernel bug: kernel doesn't report font info\n"); - return FALSE; - } - - size = (width + 7)/8 * 32 * charcount; - fontdata = (unsigned char *)xnfalloc(size); - if (!fontdata) { - xf86Msg(X_WARNING, - "lnx_savefont: cannot allocate memory to save font\n"); - goto error; - } - - if (!getfont(&width, &height, &charcount, fontdata)) { - xf86Msg(X_WARNING,"lnx_savefont: cannot read font data\n"); - goto error; - } - lnxfont.width = width; - lnxfont.height = height; - lnxfont.charcount = charcount; - lnxfont.data = fontdata; - - return TRUE; - - error: - return FALSE; -} - -static Bool -setfont(int width, int height, - int charcount, unsigned char *data) -{ - struct console_font_op op; - struct consolefontdesc ds; - int result; - - op.op = KD_FONT_OP_SET; - op.flags = 0; - op.charcount = charcount; - op.width = width; - op.height = height; - op.data = data; - - SYSCALL(result = ioctl(xf86Info.consoleFd, KDFONTOP, &op)); - - if (!result) - return TRUE; - - if (errno != ENOSYS && errno != EINVAL) - return FALSE; - - /* PIO_FONTX fallback */ - if (width != 8) - return FALSE; - - ds.charcount = charcount; - ds.chardata = (char *)data; - ds.charheight = height; - SYSCALL(result = ioctl(xf86Info.consoleFd, PIO_FONTX, &ds)); - - if (!result) - return TRUE; - - if (errno != ENOSYS && errno != EINVAL) - return FALSE; - - /* PIO_FONT fallback */ - SYSCALL(result = ioctl(xf86Info.consoleFd, PIO_FONT, data)); - - if (!result) - return TRUE; - - return FALSE; -} - -Bool -lnx_restorefont(void) -{ - if (lnxfont.data == NULL) - return FALSE; -#ifdef DEBUG - ErrorF("RESTORE font\n"); -#endif -#if 0 - /* must wack the height to make the kernel reprogram the VGA registers */ - if (!setfont(lnxfont.width, lnxfont.height + 1, lnxfont.charcount, - lnxfont.data)) { - xf86Msg(X_WARNING,"lnx_fontretore: cannot write font data\n"); - return FALSE; - } -#endif - if (!setfont(lnxfont.width, lnxfont.height, lnxfont.charcount, - lnxfont.data)) { - xf86Msg(X_WARNING,"lnx_restorefont: cannot write font data\n"); - return FALSE; - } - - return TRUE; -} - -Bool -lnx_switchaway(void) -{ - Bool ret; - - /* temporarily switch to text mode */ - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); - ret = lnx_restorefont(); - ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS); - return ret; -} - -void -lnx_freefontdata(void) -{ - if (lnxfont.data == NULL) - return; - - xfree(lnxfont.data); - lnxfont.data = NULL; - lnxfont.width = lnxfont.height = lnxfont.charcount = 0; -} diff --git a/hw/xfree86/os-support/linux/lnx_ia64.c b/hw/xfree86/os-support/linux/lnx_ia64.c deleted file mode 100644 index 5f742d01f..000000000 --- a/hw/xfree86/os-support/linux/lnx_ia64.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2004, Egbert Eich - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- - * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Egbert Eich shall not - * be used in advertising or otherwise to promote the sale, use or other deal- - *ings in this Software without prior written authorization from Egbert Eich. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/utsname.h> -#include <unistd.h> -#include <stdlib.h> - -#include "ia64Pci.h" -#include "Pci.h" - -#if defined OS_PROBE_PCI_CHIPSET -IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags) -{ - struct stat unused; - struct utsname utsName; - - if (!stat("/proc/bus/mckinley/zx1",&unused) - || !stat("/proc/bus/mckinley/zx2",&unused)) - return ZX1_CHIPSET; - - if (!stat("/proc/sgi_sn/licenseID", &unused)) { - int major, minor, patch; - char *c; - - /* We need a 2.6.11 or better kernel for Altix support */ - uname(&utsName); - c = utsName.release; - - major = atoi(c); - c = strstr(c, ".") + 1; - minor = atoi(c); - c = strstr(c, ".") + 1; - patch = atoi(c); - - if (major < 2 || (major == 2 && minor < 6) || - (major == 2 && minor == 6 && patch < 11)) { - ErrorF("Kernel 2.6.11 or better needed for Altix support\n"); - return NONE_CHIPSET; - } - return ALTIX_CHIPSET; - } - - return NONE_CHIPSET; -} -#endif diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c deleted file mode 100644 index 4c36b7cf4..000000000 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ /dev/null @@ -1,416 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "lnx.h" - -#include <sys/stat.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 Bool VTSwitch = TRUE; -static Bool ShareVTs = FALSE; -static int activeVT = -1; - -static int vtPermSave[4]; -static char vtname[11]; - -static int -saveVtPerms(void) -{ - /* We need to use stat to get permissions. */ - struct stat svtp; - - /* Do them numerically ordered, hard coded tty0 first. */ - if (stat("/dev/tty0", &svtp) != 0) - return 0; - vtPermSave[0] = (int)svtp.st_uid; - vtPermSave[1] = (int)svtp.st_gid; - - /* Now check the console we are dealing with. */ - if (stat(vtname, &svtp) != 0) - return 0; - vtPermSave[2] = (int)svtp.st_uid; - vtPermSave[3] = (int)svtp.st_gid; - - return 1; -} - -static void -restoreVtPerms(void) -{ - /* Set the terminal permissions back to before we started. */ - chown("/dev/tty0", vtPermSave[0], vtPermSave[1]); - chown(vtname, vtPermSave[2], vtPermSave[3]); -} - -void -xf86OpenConsole(void) -{ - int i, fd = -1; - struct vt_mode VT; - struct vt_stat vts; - MessageType from = X_PROBED; -#ifdef USE_DEV_FB - struct fb_var_screeninfo var; - int fbfd; -#endif - char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL }; - char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL }; - - if (serverGeneration == 1) { - - /* when KeepTty check if we're run with euid==0 */ - if (KeepTty && geteuid() != 0) - FatalError("xf86OpenConsole:" - " Server must be suid root for option \"KeepTTY\"\n"); - - /* - * setup the virtual terminal manager - */ - if (VTnum != -1) { - xf86Info.vtno = VTnum; - from = X_CMDLINE; - } else { - - i=0; - while (tty0[i] != NULL) { - if ((fd = open(tty0[i],O_WRONLY,0)) >= 0) - break; - i++; - } - - if (fd < 0) - FatalError( - "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n", - strerror(errno)); - - if (ShareVTs) - { - if (ioctl(fd, VT_GETSTATE, &vts) == 0) - xf86Info.vtno = vts.v_active; - else - FatalError("xf86OpenConsole: Cannot find the current" - " VT (%s)\n", strerror(errno)); - } else { - if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || - (xf86Info.vtno == -1)) - FatalError("xf86OpenConsole: Cannot find a free VT: %s\n", - strerror(errno)); - } - close(fd); - } - -#ifdef USE_DEV_FB - if (!ShareVTs) - { - 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) < 0) - FatalError("xf86OpenConsole: Unable to get screen info %s\n", - strerror(errno)); - } -#endif - xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); - - if (!KeepTty) { - pid_t ppid = getppid(); - pid_t ppgid; - ppgid = getpgid(ppid); - - /* - * change to parent process group that pgid != pid so - * that setsid() doesn't fail and we become process - * group leader - */ - if (setpgid(0,ppgid) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n", - strerror(errno)); - - /* become process group leader */ - if ((setsid() < 0)) - xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n", - strerror(errno)); - } - - i=0; - while (vcs[i] != NULL) { - sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */ - if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0) - break; - i++; - } - - if (xf86Info.consoleFd < 0) - FatalError("xf86OpenConsole: Cannot open virtual console" - " %d (%s)\n", xf86Info.vtno, strerror(errno)); - - if (!ShareVTs) - { - /* - * Grab the vt ownership before we overwrite it. - * Hard coded /dev/tty0 into this function as well for below. - */ - if (!saveVtPerms()) - xf86Msg(X_WARNING, - "xf86OpenConsole: Could not save ownership of VT\n"); - - /* change ownership of the vt */ - if (chown(vtname, getuid(), getgid()) < 0) - xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n", - vtname, strerror(errno)); - - /* - * the current VT device we're running on is not "console", we want - * to grab all consoles too - * - * Why is this needed?? - */ - if (chown("/dev/tty0", getuid(), getgid()) < 0) - xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n", - strerror(errno)); - } - - /* - * 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) - xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n", - strerror(errno)); - else - activeVT = vts.v_active; - -#if 0 - 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); - } - } -#endif - - if (!ShareVTs) - { -#if defined(DO_OS_FONTRESTORE) - lnx_savefont(); -#endif - /* - * now get the VT. This _must_ succeed, or else fail completely. - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) - FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) - FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %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; - - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) - FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n", - strerror(errno)); - - /* we really should have a InitOSInputDevices() function instead - * of Init?$#*&Device(). So I just place it here */ - -#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 { /* ShareVTs */ - close(xf86Info.consoleFd); - } - signal(SIGUSR2, xf86ReloadInputDevs); - } else { /* serverGeneration != 1 */ - if (!ShareVTs && VTSwitch) - { - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n", - strerror(errno)); - } - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n", - strerror(errno)); - } - return; -} - -void -xf86CloseConsole() -{ - struct vt_mode VT; -#if defined(DO_OS_FONTRESTORE) - struct vt_stat vts; - int vtno = -1; -#endif - - if (ShareVTs) return; - -#if defined(DO_OS_FONTRESTORE) - if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETSTATE failed: %s\n", - strerror(errno)); - else - vtno = vts.v_active; -#endif - - /* Back to text mode ... */ - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n", - strerror(errno)); - else { - /* set dflt vt handling */ - VT.mode = VT_AUTO; - if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n", - strerror(errno)); - } - - if (VTSwitch) - { - /* - * Perform a switch back to the active VT when we were started - */ - if (activeVT >= 0) { - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0) - xf86Msg(X_WARNING, - "xf86CloseConsole: VT_WAITACTIVE failed: %s\n", - strerror(errno)); - activeVT = -1; - } - -#if defined(DO_OS_FONTRESTORE) - if (xf86Info.vtno == vtno) /* check if we are active */ - lnx_restorefont(); - lnx_freefontdata(); -#endif - } - close(xf86Info.consoleFd); /* make the vt-manager happy */ - - restoreVtPerms(); /* restore the permissions */ - - return; -} - -int -xf86ProcessArgument(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 (!strcmp(argv[i], "-novtswitch")) - { - VTSwitch = FALSE; - return(1); - } - if (!strcmp(argv[i], "-sharevts")) - { - ShareVTs = 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"); - ErrorF("-novtswitch don't immediately switch to new VT\n"); - ErrorF("-sharevts share VTs with another X server\n"); - return; -} diff --git a/hw/xfree86/os-support/linux/lnx_kmod.c b/hw/xfree86/os-support/linux/lnx_kmod.c deleted file mode 100644 index 4e6f2d25d..000000000 --- a/hw/xfree86/os-support/linux/lnx_kmod.c +++ /dev/null @@ -1,112 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <errno.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/wait.h> -#include <signal.h> -#include "xf86_OSlib.h" -#include "xf86.h" - - -#define MODPROBE_PATH_FILE "/proc/sys/kernel/modprobe" -#define MAX_PATH 1024 - - -#if 0 -/* XFree86 #defines execl to be the xf86execl() function which does - * a fork AND exec. We don't want that. We want the regular, - * standard execl(). - */ -#ifdef execl -#undef execl -#endif -#endif - - -/* - * Load a Linux kernel module. - * This is used by the DRI/DRM to load a DRM kernel module when - * the X server starts. It could be used for other purposes in the future. - * Input: - * modName - name of the kernel module (Ex: "tdfx") - * Return: - * 0 for failure, 1 for success - */ -_X_EXPORT int -xf86LoadKernelModule(const char *modName) -{ - char mpPath[MAX_PATH] = ""; - int fd = -1, status, n; - pid_t pid; - - /* get the path to the modprobe program */ - fd = open(MODPROBE_PATH_FILE, O_RDONLY); - if (fd >= 0) { - int count = read(fd, mpPath, MAX_PATH - 1); - if (count <= 0) { - mpPath[0] = 0; - } - else if (mpPath[count - 1] == '\n') { - mpPath[count - 1] = 0; /* replaces \n with \0 */ - } - close(fd); - /* if this worked, mpPath will be "/sbin/modprobe" or similar. */ - } - - if (mpPath[0] == 0) { - /* we failed to get the path from the system, use a default */ - strcpy(mpPath, "/sbin/modprobe"); - } - - /* now fork/exec the modprobe command */ - /* - * It would be good to capture stdout/stderr so that it can be directed - * to the log file. modprobe errors currently are missing from the log - * file. - */ - switch (pid = fork()) { - case 0: /* child */ - /* change real/effective user ID to 0/0 as we need to - * preinstall agpgart module for some DRM modules - */ - if (setreuid(0,0)) { - xf86Msg(X_WARNING,"LoadKernelModule: " - "Setting of real/effective user Id to 0/0 failed"); - } - setenv("PATH","/sbin",1); - n = execl(mpPath, "modprobe", modName, NULL); - xf86Msg(X_WARNING,"LoadKernelModule %s\n",strerror(errno)); - exit(EXIT_FAILURE); /* if we get here the child's exec failed */ - break; - case -1: /* fork failed */ - return 0; - default: /* fork worked */ - { - /* XXX we loop over waitpid() because it sometimes fails on - * the first attempt. Don't know why! - */ - int count = 0, p; - do { - p = waitpid(pid, &status, 0); - } while (p == -1 && count++ < 4); - - if (p == -1) { - return 0; - } - - if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { - return 1; /* success! */ - } - else { - return 0; - } - } - } - - /* never get here */ - return 0; -} diff --git a/hw/xfree86/os-support/linux/lnx_mouse.c b/hw/xfree86/os-support/linux/lnx_mouse.c deleted file mode 100644 index d2822153f..000000000 --- a/hw/xfree86/os-support/linux/lnx_mouse.c +++ /dev/null @@ -1,221 +0,0 @@ - -/* - * Copyright 1999 by The XFree86 Project, Inc. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" -#include "xf86_OSlib.h" -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> - -static int -SupportedInterfaces(void) -{ - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; -} - -static const char * -DefaultProtocol(void) -{ - return "Auto"; -} - -#define DEFAULT_MOUSE_DEV "/dev/input/mice" -#define DEFAULT_PS2_DEV "/dev/psaux" -#define DEFAULT_GPM_DATA_DEV "/dev/gpmdata" -#define DEFAULT_GPM_CTL_DEV "/dev/gpmdata" - -static const char *mouseDevs[] = { - DEFAULT_MOUSE_DEV, - DEFAULT_PS2_DEV, - DEFAULT_GPM_DATA_DEV, - NULL -}; - -typedef enum { - MOUSE_PROTO_UNKNOWN = 0, - MOUSE_PROTO_SERIAL, - MOUSE_PROTO_PS2, - MOUSE_PROTO_MSC, - MOUSE_PROTO_GPM, - MOUSE_PROTO_EXPPS2, -} protocolTypes; - -static struct { - protocolTypes proto; - const char *name; -} devproto[] = { - { MOUSE_PROTO_UNKNOWN, NULL }, - { MOUSE_PROTO_PS2, "PS/2" }, - { MOUSE_PROTO_MSC, "MouseSystems" }, - { MOUSE_PROTO_GPM, "GPM" }, - { MOUSE_PROTO_EXPPS2, "ExplorerPS/2" }, -}; - -static const char * -FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) -{ - int fd = -1; - const char **pdev; - - for (pdev = mouseDevs; *pdev; pdev++) { - SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK | O_EXCL)); - if (fd == -1) { -#ifdef DEBUG - ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); -#endif - } else - break; - } - - if (*pdev) { - close(fd); - /* Set the Device option. */ - pInfo->conf_idev->commonOptions = - xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", *pdev); - xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", - pInfo->name, *pdev); - } - - return *pdev; -} - -static const char * -lnxMouseMagic(InputInfoPtr pInfo) -{ - int fd = -1; - const char *dev; - char *realdev; - struct stat sbuf; - int i; - int proto = MOUSE_PROTO_UNKNOWN; - - dev = xf86SetStrOption(pInfo->conf_idev->commonOptions, "Device", NULL); - if (!dev) { -#ifdef DEBUG - ErrorF("xf86SetStrOption failed to return the device name\n"); -#endif - return NULL; - } - /* Look at the device name to guess the protocol. */ - realdev = NULL; - if (strcmp(dev, DEFAULT_MOUSE_DEV) == 0) { - if (lstat(dev, &sbuf) != 0) { -#ifdef DEBUG - ErrorF("lstat failed for %s (%s)\n", dev, strerror(errno)); -#endif - return NULL; - } - if (S_ISLNK(sbuf.st_mode)) { - realdev = xnfalloc(PATH_MAX + 1); - i = readlink(dev, realdev, PATH_MAX); - if (i <= 0) { -#ifdef DEBUG - ErrorF("readlink failed for %s (%s)\n", dev, strerror(errno)); -#endif - xfree(realdev); - return NULL; - } - realdev[i] = '\0'; - } - } - if (!realdev) - realdev = xnfstrdup(dev); - else { - /* If realdev doesn't contain a '/' then prepend "/dev/" */ - if (!strchr(realdev, '/')) { - char *tmp = xnfalloc(strlen(realdev) + 5 + 1); - sprintf(tmp, "/dev/%s", realdev); - xfree(realdev); - realdev = tmp; - } - } - - if (strcmp(realdev, DEFAULT_MOUSE_DEV) == 0) - proto = MOUSE_PROTO_EXPPS2; - else if (strcmp(realdev, DEFAULT_PS2_DEV) == 0) - proto = MOUSE_PROTO_EXPPS2; - else if (strcmp(realdev, DEFAULT_GPM_DATA_DEV) == 0) - proto = MOUSE_PROTO_MSC; - else if (strcmp(realdev, DEFAULT_GPM_CTL_DEV) == 0) - proto = MOUSE_PROTO_GPM; - xfree(realdev); - /* - * If the protocol can't be guessed from the device name, - * try to characterise it. - */ - if (proto == MOUSE_PROTO_UNKNOWN) { - SYSCALL (fd = open(dev, O_RDWR | O_NONBLOCK | O_EXCL)); - if (isatty(fd)) { - /* Serial PnP has already failed, so give up. */ - } else { - if (fstat(fd, &sbuf) != 0) { -#ifdef DEBUG - ErrorF("fstat failed for %s (%s)\n", dev, strerror(errno)); -#endif - close(fd); - return NULL; - } - if (S_ISFIFO(sbuf.st_mode)) { - /* Assume GPM data in MSC format. */ - proto = MOUSE_PROTO_MSC; - } else { - /* Default to PS/2 */ - proto = MOUSE_PROTO_PS2; - } - } - close(fd); - } - if (proto == MOUSE_PROTO_UNKNOWN) { - xf86Msg(X_ERROR, "%s: Cannot find mouse protocol.\n", - pInfo->name); - return NULL; - } else { - for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); i++) { - if (devproto[i].proto == proto) { - xf86Msg(X_INFO, - "%s: Setting mouse protocol to \"%s\"\n", - pInfo->name, devproto[i].name); - return devproto[i].name; - } - } - } - return NULL; -} - -static const char * -GuessProtocol(InputInfoPtr pInfo, int flags) -{ - return lnxMouseMagic(pInfo); -} - -static const char * -SetupAuto(InputInfoPtr pInfo, int *protoPara) -{ - return lnxMouseMagic(pInfo); -} - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - p->SupportedInterfaces = SupportedInterfaces; - p->DefaultProtocol = DefaultProtocol; - p->FindDevice = FindDevice; - p->GuessProtocol = GuessProtocol; - p->SetupAuto = SetupAuto; - return p; -} - diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c deleted file mode 100644 index 8eedfa49f..000000000 --- a/hw/xfree86/os-support/linux/lnx_pci.c +++ /dev/null @@ -1,193 +0,0 @@ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/types.h> -#include <stdio.h> -#include <dirent.h> -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include "xf86Pci.h" -#include "Pci.h" - -#ifdef __sparc__ -#define PCIADDR_TYPE long long -#define PCIADDR_IGNORE_FMT "%*x" -#define PCIADDR_FMT "%llx" -#else -#define PCIADDR_TYPE long -#define PCIADDR_IGNORE_FMT "%*x" -#define PCIADDR_FMT "%lx" -#endif - -struct pci_dev { - unsigned int domain; - unsigned int bus; - unsigned int dev; - unsigned int fn; - PCIADDR_TYPE offset[7]; - PCIADDR_TYPE size[7]; - struct pci_dev *next; -}; - -struct pci_dev *xf86OSLinuxPCIDevs = NULL; -int xf86OSLinuxNumPciDevs = 0; - -static struct pci_dev *xf86OSLinuxGetPciDevs(void) { - char c[0x200]; - FILE *file = NULL; - DIR *dir; - struct dirent *dirent; - struct pci_dev *tmp, *ret = NULL; - unsigned int i, num, devfn; - unsigned PCIADDR_TYPE begin, end; - char *res; - - /* Try 2.6 devices first, with domain support */ - if ( (dir = opendir ("/sys/bus/pci/devices")) ) { - xf86OSLinuxNumPciDevs = 0; - while ( (dirent = readdir (dir)) ) { - unsigned int domain, bus, dev, fn; - if (sscanf (dirent->d_name, "%04x:%02x:%02x.%01x", - &domain, &bus, &dev, &fn) == 4) { - tmp = xcalloc (sizeof(struct pci_dev), 1); - tmp->domain = domain; - tmp->bus = bus; - tmp->dev = dev; - tmp->fn = fn; - sprintf (c, "/sys/bus/pci/devices/%12s/resource", - dirent->d_name); - i = 0; - if ( (file = fopen (c, "r")) ) { - while (i < 7 && fgets (c, 0x200, file)) { - if (sscanf (c, PCIADDR_FMT " " PCIADDR_FMT " " - PCIADDR_IGNORE_FMT, &begin, &end) == 2) { - tmp->offset[i] = begin; - tmp->size[i] = begin ? end-begin+1 : 0; - i++; - } - } - fclose (file); - } - if (i > 0) { - tmp->next = ret; - ret = tmp; - xf86OSLinuxNumPciDevs++; - } else - xfree (tmp); - } - } - closedir (dir); - } - - if (ret) - return ret; - - file = fopen("/proc/bus/pci/devices", "r"); - if (!file) return NULL; - - xf86OSLinuxNumPciDevs = 0; - - do { - res = fgets(c, 0x1ff, file); - if (res) { - tmp = xcalloc(sizeof(struct pci_dev),1); - num = sscanf(res, - /*bus+dev vendorid deviceid irq */ - "%02x%02x\t%*04x%*04x\t%*x" - /* 7 PCI resource base addresses */ - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - /* 7 PCI resource sizes, and then optionally a driver name */ - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT - "\t" PCIADDR_FMT, - &tmp->bus,&devfn,&tmp->offset[0],&tmp->offset[1],&tmp->offset[2],&tmp->offset[3], - &tmp->offset[4],&tmp->offset[5],&tmp->offset[6], &tmp->size[0], &tmp->size[1], &tmp->size[2], - &tmp->size[3], &tmp->size[4], &tmp->size[5], &tmp->size[6]); - tmp->dev = devfn >> 3; - tmp->fn = devfn & 0x7; - if (num != 16) { /* apparantly not 2.3 style */ - xfree(tmp); - fclose(file); - return NULL; - } - if (ret) { - tmp->next = ret; - } - ret = tmp; - xf86OSLinuxNumPciDevs++; - } - } while (res); - fclose(file); - return ret; -} - -/* Query the kvirt address (64bit) of a BAR range from size for a given TAG */ -unsigned long -xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) -{ - unsigned int ndx; - struct pci_dev *device; - struct pci_device *dev; - - if (!xf86OSLinuxPCIDevs) { - xf86OSLinuxPCIDevs = xf86OSLinuxGetPciDevs(); - } - if (!xf86OSLinuxPCIDevs) { - return FALSE; - } - - for (device = xf86OSLinuxPCIDevs; device; device = device->next) { - dev = pci_device_find_by_slot(device->domain, device->bus, - device->dev, device->fn); - if (dev != NULL) { - /* ok now look through all the BAR values of this device */ - for (ndx=0; ndx<7; ndx++) { - uint32_t savePtr; - uint32_t flagMask; - - /* The ROM BAR isn't with the other BARs. - */ - const pciaddr_t offset = (ndx == 6) - ? (4 * 12) : (4 * ndx) + 16; - - pci_device_cfg_read_u32(dev, &savePtr, offset); - - /* Ignore unset base addresses. The kernel may have reported - * non-zero size and address even if they are disabled (e.g., - * disabled ROM BAR). - */ - if (savePtr == 0) - continue; - - /* Remove memory attribute bits, different for IO - * and memory ranges. - */ - flagMask = (savePtr & 0x1) ? ~0x3UL : ~0xFUL; - savePtr &= flagMask; - - /* find the index of the incoming base */ - if (base >= savePtr && base < (savePtr + device->size[ndx])) { - return (device->offset[ndx] & flagMask) + (base - savePtr); - } - } - } - } - - return 0; -} diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c deleted file mode 100644 index 429593784..000000000 --- a/hw/xfree86/os-support/linux/lnx_video.c +++ /dev/null @@ -1,1106 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <errno.h> -#include <string.h> - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" -#include "lnx.h" -#ifdef __alpha__ -#include "shared/xf86Axp.h" -#endif - -#ifdef HAS_MTRR_SUPPORT -#include <asm/mtrr.h> -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -static Bool ExtendedEnabled = FALSE; - -#ifdef __ia64__ - -#include "compiler.h" -#include <sys/io.h> - -#elif !defined(__powerpc__) && \ - !defined(__mc68000__) && \ - !defined(__sparc__) && \ - !defined(__mips__) && \ - !defined(__arm__) - -/* - * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare - * these. - */ -extern int ioperm(unsigned long __from, unsigned long __num, int __turn_on); -extern int iopl(int __level); - -#endif - -#ifdef __alpha__ - -# ifdef LIBC_IS_FIXED -extern void sethae(unsigned long hae); -# else -# include <unistd.h> -# define sethae(x) syscall(301,x); -# endif - -/* define to test the Sparse addressing on a non-Jensen */ -# ifdef TEST_JENSEN_CODE -# define isJensen (1) -# else -# define isJensen (axpSystem == JENSEN) -# endif - -# define BUS_BASE bus_base - -#else - -#define BUS_BASE (0) - -#endif /* __alpha__ */ - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static pointer mapVidMem(int, unsigned long, unsigned long, int); -static void unmapVidMem(int, pointer, unsigned long); -#if defined (__alpha__) -static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); -extern axpDevice lnxGetAXP(void); -static void unmapVidMemSparse(int, pointer, unsigned long); -# if defined(JENSEN_SUPPORT) -static pointer mapVidMemJensen(int, unsigned long, unsigned long, int); -static void unmapVidMemJensen(int, pointer, unsigned long); -# endif -static axpDevice axpSystem = -1; -static Bool needSparse; -static unsigned long hae_thresh; -static unsigned long hae_mask; -static unsigned long bus_base; -static unsigned long sparse_size; -#endif - -#ifdef HAS_MTRR_SUPPORT - -#define SPLIT_WC_REGIONS 1 - -static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); -static void undoWC(int, pointer); - -/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr - driver will clean up when we exit. */ -#define MTRR_FD_UNOPENED (-1) /* We have yet to open /proc/mtrr */ -#define MTRR_FD_PROBLEM (-2) /* We tried to open /proc/mtrr, but had - a problem. */ -static int mtrr_fd = MTRR_FD_UNOPENED; - -/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, - and will fail on Linux 2.2 with MTRR support configured out, - so verbosity should be chosen appropriately. */ -static Bool -mtrr_open(int verbosity) -{ - /* Only report absence of /proc/mtrr once. */ - static Bool warned = FALSE; - - if (mtrr_fd == MTRR_FD_UNOPENED) { - mtrr_fd = open("/proc/mtrr", O_WRONLY); - - if (mtrr_fd < 0) - mtrr_fd = MTRR_FD_PROBLEM; - } - - if (mtrr_fd == MTRR_FD_PROBLEM) { - /* To make sure we only ever warn once, need to check - verbosity outside xf86MsgVerb */ - if (!warned && verbosity <= xf86GetVerbosity()) { - xf86MsgVerb(X_WARNING, verbosity, - "System lacks support for changing MTRRs\n"); - warned = TRUE; - } - - return FALSE; - } - else - return TRUE; -} - -/* - * We maintain a list of WC regions for each physical mapping so they can - * be undone when unmapping. - */ - -struct mtrr_wc_region { - struct mtrr_sentry sentry; - Bool added; /* added WC or removed it */ - struct mtrr_wc_region * next; -}; - - -static struct mtrr_wc_region * -mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size, - MessageType from) -{ - /* Some BIOS writers thought that setting wc over the mmio - region of a graphics devices was a good idea. Try to fix - it. */ - - struct mtrr_gentry gent; - struct mtrr_wc_region *wcreturn = NULL, *wcr; - int count, ret=0; - - /* Linux 2.0 users should not get a warning without -verbose */ - if (!mtrr_open(2)) - return NULL; - - for (gent.regnum = 0; - ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; - gent.regnum++) { - if (gent.type != MTRR_TYPE_WRCOMB - || gent.base + gent.size <= base - || base + size <= gent.base) - continue; - - /* Found an overlapping region. Delete it. */ - - wcr = xalloc(sizeof(*wcr)); - if (!wcr) - return NULL; - wcr->sentry.base = gent.base; - wcr->sentry.size = gent.size; - wcr->sentry.type = MTRR_TYPE_WRCOMB; - wcr->added = FALSE; - - count = 3; - while (count-- && - (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0); - - if (ret >= 0) { - xf86DrvMsg(screenNum, from, - "Removed MMIO write-combining range " - "(0x%lx,0x%lx)\n", - (unsigned long) gent.base, (unsigned long) gent.size); - wcr->next = wcreturn; - wcreturn = wcr; - gent.regnum--; - } else { - xfree(wcr); - xf86DrvMsgVerb(screenNum, X_WARNING, 0, - "Failed to remove MMIO " - "write-combining range (0x%lx,0x%lx)\n", - gent.base, (unsigned long) gent.size); - } - } - return wcreturn; -} - - -static struct mtrr_wc_region * -mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size, - MessageType from) -{ - struct mtrr_gentry gent; - struct mtrr_wc_region *wcreturn = NULL, **wcr; - - if (!mtrr_open(2)) - return NULL; - - wcr = &wcreturn; - for (gent.regnum = 0; - ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++ ) { - if (gent.type == MTRR_TYPE_WRCOMB - && ((gent.base >= base && gent.base + gent.size < base + size) || - (gent.base > base && gent.base + gent.size <= base + size))) { - *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from); - if (*wcr) gent.regnum--; - while(*wcr) { - wcr = &((*wcr)->next); - } - } - } - return wcreturn; -} - - -static struct mtrr_wc_region * -mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size, - MessageType from) -{ - struct mtrr_wc_region **wcr, *wcreturn, *curwcr; - - /* - * There can be only one.... - */ - - wcreturn = mtrr_remove_offending(screenNum, base, size, from); - wcr = &wcreturn; - while (*wcr) { - wcr = &((*wcr)->next); - } - - /* Linux 2.0 should not warn, unless the user explicitly asks for - WC. */ - - if (!mtrr_open(from == X_CONFIG ? 0 : 2)) - return wcreturn; - - *wcr = curwcr = xalloc(sizeof(**wcr)); - if (!curwcr) - return wcreturn; - - curwcr->sentry.base = base; - curwcr->sentry.size = size; - curwcr->sentry.type = MTRR_TYPE_WRCOMB; - curwcr->added = TRUE; - curwcr->next = NULL; - -#if SPLIT_WC_REGIONS - /* - * Splits up the write-combining region if it is not aligned on a - * size boundary. - */ - - { - unsigned long lbase, d_size = 1; - unsigned long n_size = size; - unsigned long n_base = base; - - for (lbase = n_base, d_size = 1; !(lbase & 1); - lbase = lbase >> 1, d_size <<= 1); - while (d_size > n_size) - d_size = d_size >> 1; -#ifdef DEBUG - ErrorF("WC_BASE: 0x%lx WC_END: 0x%lx\n",base,base+d_size-1); -#endif - n_base += d_size; - n_size -= d_size; - if (n_size) { - xf86DrvMsgVerb(screenNum,X_INFO,3,"Splitting WC range: " - "base: 0x%lx, size: 0x%lx\n",base,size); - curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size,from); - } - curwcr->sentry.size = d_size; - } - - /*****************************************************************/ -#endif /* SPLIT_WC_REGIONS */ - - if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) { - /* Avoid printing on every VT switch */ - if (xf86ServerIsInitialising()) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx)\n", - base, size); - } - return wcreturn; - } - else { - *wcr = curwcr->next; - xfree(curwcr); - - /* Don't complain about the VGA region: MTRR fixed - regions aren't currently supported, but might be in - the future. */ - if ((unsigned long)base >= 0x100000) { - xf86DrvMsgVerb(screenNum, X_WARNING, 0, - "Failed to set up write-combining range " - "(0x%lx,0x%lx)\n", base, size); - } - return wcreturn; - } -} - -static void -mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr) -{ - struct mtrr_wc_region *p, *prev; - - if (mtrr_fd > 0) { - p = wcr; - while (p) { - if (p->added) - ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry); - prev = p; - p = p->next; - xfree(prev); - } - } -} - -static pointer -setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - if (enable) - return mtrr_add_wc_region(screenNum, base, size, from); - else - return mtrr_cull_wc_region(screenNum, base, size, from); -} - -static void -undoWC(int screenNum, pointer regioninfo) -{ - mtrr_undo_wc_region(screenNum, regioninfo); -} - -#endif /* HAS_MTRR_SUPPORT */ - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = TRUE; -#ifdef __alpha__ - if (axpSystem == -1) { - axpSystem = lnxGetAXP(); - if ((needSparse = (_bus_base_sparse() > 0))) { - hae_thresh = xf86AXPParams[axpSystem].hae_thresh; - hae_mask = xf86AXPParams[axpSystem].hae_mask; - sparse_size = xf86AXPParams[axpSystem].size; - } - bus_base = _bus_base(); - } - if (isJensen) { -# ifndef JENSEN_SUPPORT - FatalError("Jensen is not supported any more\n" - "If you are intereseted in fixing Jensen support\n" - "please contact xorg@lists.freedesktop.org\n"); -# else - xf86Msg(X_INFO,"Machine type is Jensen\n"); - pVidMem->mapMem = mapVidMemJensen; - pVidMem->unmapMem = unmapVidMemJensen; -# endif /* JENSEN_SUPPORT */ - } else if (needSparse) { - xf86Msg(X_INFO,"Machine needs sparse mapping\n"); - pVidMem->mapMem = mapVidMemSparse; - pVidMem->unmapMem = unmapVidMemSparse; - } else { - xf86Msg(X_INFO,"Machine type has 8/16 bit access\n"); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - } -#else - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; -#endif /* __alpha__ */ - - -#ifdef HAS_MTRR_SUPPORT - pVidMem->setWC = setWC; - pVidMem->undoWC = undoWC; -#endif - pVidMem->initialised = TRUE; -} - -#ifdef __sparc__ -/* Basically, you simply cannot do this on Sparc. You have to do something portable - * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM - */ -static pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - return NULL; -} -#else -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - int fd; - int mapflags = MAP_SHARED; - int prot; - memType realBase, alignOff; - - realBase = Base & ~(getpagesize() - 1); - alignOff = Base - realBase; -#ifdef DEBUG - ErrorF("base: %lx, realBase: %lx, alignOff: %lx \n", - Base,realBase,alignOff); -#endif - -#if defined(__ia64__) || defined(__arm__) || defined(__s390__) -#ifndef MAP_WRITECOMBINED -#define MAP_WRITECOMBINED 0x00010000 -#endif -#ifndef MAP_NONCACHED -#define MAP_NONCACHED 0x00020000 -#endif - if(flags & VIDMEM_FRAMEBUFFER) - mapflags |= MAP_WRITECOMBINED; - else - mapflags |= MAP_NONCACHED; -#endif - -#if 0 - /* this will disappear when people upgrade their kernels */ - fd = open(DEV_MEM, - ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC); -#else - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); -#endif - if (fd < 0) - { - FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", - strerror(errno)); - } - - if (flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - /* This requires linux-0.99.pl10 or above */ - base = mmap((caddr_t)0, Size + alignOff, prot, mapflags, fd, - (off_t)realBase + BUS_BASE); - close(fd); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer" - " (0x%08lx,0x%lx) (%s)\n", Base, Size, - strerror(errno)); - } -#ifdef DEBUG - ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff); -#endif - return (char *)base + alignOff; -} -#endif /* !(__sparc__) */ - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - memType alignOff = (memType)Base - - ((memType)Base & ~(getpagesize() - 1)); - -#ifdef DEBUG - ErrorF("alignment offset: %lx\n",alignOff); -#endif - munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff)); -} - - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -#if defined(__powerpc__) -_X_EXPORT volatile unsigned char *ioBase = NULL; - -#ifndef __NR_pciconfig_iobase -#define __NR_pciconfig_iobase 200 -#endif - -#endif - -_X_EXPORT Bool -xf86EnableIO(void) -{ -#if defined(__powerpc__) - int fd; - unsigned int ioBase_phys; -#endif - - if (ExtendedEnabled) - return TRUE; - -#if defined(__powerpc__) - ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0); - - fd = open("/dev/mem", O_RDWR); - if (ioBase == NULL) { - ioBase = (volatile unsigned char *)mmap(0, 0x20000, - PROT_READ | PROT_WRITE, MAP_SHARED, fd, - ioBase_phys); -/* Should this be fatal or just a warning? */ -#if 0 - if (ioBase == MAP_FAILED) { - xf86Msg(X_WARNING, - "xf86EnableIOPorts: Failed to map iobase (%s)\n", - strerror(errno)); - return FALSE; - } -#endif - } - close(fd); -#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__) - if (ioperm(0, 1024, 1) || iopl(3)) { - if (errno == ENODEV) - ErrorF("xf86EnableIOPorts: no I/O ports found\n"); - else - FatalError("xf86EnableIOPorts: failed to set IOPL" - " for I/O (%s)\n", strerror(errno)); - return FALSE; - } -# if !defined(__alpha__) - ioperm(0x40,4,0); /* trap access to the timer chip */ - ioperm(0x60,4,0); /* trap access to the keyboard controller */ -# endif -#endif - ExtendedEnabled = TRUE; - - return TRUE; -} - -_X_EXPORT void -xf86DisableIO(void) -{ - if (!ExtendedEnabled) - return; -#if defined(__powerpc__) - munmap(ioBase, 0x20000); - ioBase = NULL; -#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__) - iopl(0); - ioperm(0, 1024, 0); -#endif - ExtendedEnabled = FALSE; - - return; -} - -/* - * Don't use these two functions. They can't possibly work. If you actually - * need interrupts off for something, you ought to be doing it in the kernel - * anyway. - */ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - return (TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - return; -} - -#if defined (__alpha__) - -#define vuip volatile unsigned int * - -extern int readDense8(pointer Base, register unsigned long Offset); -extern int readDense16(pointer Base, register unsigned long Offset); -extern int readDense32(pointer Base, register unsigned long Offset); -extern void -writeDenseNB8(int Value, pointer Base, register unsigned long Offset); -extern void -writeDenseNB16(int Value, pointer Base, register unsigned long Offset); -extern void -writeDenseNB32(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense8(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense16(int Value, pointer Base, register unsigned long Offset); -extern void -writeDense32(int Value, pointer Base, register unsigned long Offset); - -static int readSparse8(pointer Base, register unsigned long Offset); -static int readSparse16(pointer Base, register unsigned long Offset); -static int readSparse32(pointer Base, register unsigned long Offset); -static void -writeSparseNB8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseNB16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseNB32(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparse32(int Value, pointer Base, register unsigned long Offset); - -#define DENSE_BASE 0x2ff00000000UL -#define SPARSE_BASE 0x30000000000UL - -static unsigned long msb_set = 0; - -static pointer -mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - int fd, prot; - unsigned long ret, rets = 0; - - static Bool was_here = FALSE; - - if (!was_here) { - was_here = TRUE; - - xf86WriteMmio8 = writeSparse8; - xf86WriteMmio16 = writeSparse16; - xf86WriteMmio32 = writeSparse32; - xf86WriteMmioNB8 = writeSparseNB8; - xf86WriteMmioNB16 = writeSparseNB16; - xf86WriteMmioNB32 = writeSparseNB32; - xf86ReadMmio8 = readSparse8; - xf86ReadMmio16 = readSparse16; - xf86ReadMmio32 = readSparse32; - } - - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", - strerror(errno)); - } - -#if 0 - xf86Msg(X_INFO,"mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n", - Base, Size, flags); -#endif - - if (flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - /* This requirers linux-0.99.pl10 or above */ - - /* - * Always do DENSE mmap, since read32/write32 currently require it. - */ - ret = (unsigned long)mmap((caddr_t)(DENSE_BASE + Base), Size, - prot, MAP_SHARED, fd, - (off_t) (bus_base + Base)); - - /* - * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER - * and SPARSE (which should require the use of read/write macros). - * - * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K - * bytes worth of pagetable (32 pages). - */ - if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) || - ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) - { - rets = (unsigned long)mmap((caddr_t)(SPARSE_BASE + (Base << 5)), - Size << 5, prot, MAP_SHARED, fd, - (off_t) _bus_base_sparse() + (Base << 5)); - } - - close(fd); - - if (ret == (unsigned long)MAP_FAILED) { - FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n", - strerror(errno)); - } - - if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) || - ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) - { - if (rets == (unsigned long)MAP_FAILED || - rets != (SPARSE_BASE + (Base << 5))) - { - FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n", - strerror(errno)); - } - } - -#if 1 - if (rets) - xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx" - " to DENSE at 0x%lx and SPARSE at 0x%lx\n", - Base, Size, ret, rets); - else - xf86Msg(X_INFO,"mapVidMemSparse: mapped Base 0x%lx size 0x%lx" - " to DENSE only at 0x%lx\n", - Base, Size, ret); - -#endif - return (pointer) ret; -} - -static void -unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size) -{ - unsigned long Offset = (unsigned long)Base - DENSE_BASE; -#if 1 - xf86Msg(X_INFO,"unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n", - Base, Size); -#endif - /* Unmap DENSE always. */ - munmap((caddr_t)Base, Size); - - /* Unmap SPARSE always, and ignore error in case we did not map it. */ - munmap((caddr_t)(SPARSE_BASE + (Offset << 5)), Size << 5); -} - -static int -readSparse8(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long)Base - DENSE_BASE; - shift = (Offset & 0x3) << 3; - if (Offset >= (hae_thresh)) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - mem_barrier(); - result = *(vuip) (SPARSE_BASE + (Offset << 5)); - result >>= shift; - return 0xffUL & result; -} - -static int -readSparse16(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - register unsigned long msb; - - mem_barrier(); - Offset += (unsigned long)Base - DENSE_BASE; - shift = (Offset & 0x2) << 3; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - mem_barrier(); - result = *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))); - result >>= shift; - return 0xffffUL & result; -} - -static int -readSparse32(pointer Base, register unsigned long Offset) -{ - /* NOTE: this is really using DENSE. */ - mem_barrier(); - return *(vuip)((unsigned long)Base+(Offset)); -} - -static void -writeSparse8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - write_mem_barrier(); - Offset += (unsigned long)Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - write_mem_barrier(); - *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparse16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - write_mem_barrier(); - Offset += (unsigned long)Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - - write_mem_barrier(); - *(vuip)(SPARSE_BASE + (Offset<<5) + (1<<(5-2))) = w * 0x00010001; -} - -static void -writeSparse32(int Value, pointer Base, register unsigned long Offset) -{ - /* NOTE: this is really using DENSE. */ - write_mem_barrier(); - *(vuip)((unsigned long)Base + (Offset)) = Value; - return; -} - -static void -writeSparseNB8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int b = Value & 0xffU; - - Offset += (unsigned long)Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101; -} - -static void -writeSparseNB16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned long msb; - register unsigned int w = Value & 0xffffU; - - Offset += (unsigned long)Base - DENSE_BASE; - if (Offset >= hae_thresh) { - msb = Offset & hae_mask; - Offset -= msb; - if (msb_set != msb) { - sethae(msb); - msb_set = msb; - } - } - *(vuip)(SPARSE_BASE+(Offset<<5)+(1<<(5-2))) = w * 0x00010001; -} - -static void -writeSparseNB32(int Value, pointer Base, register unsigned long Offset) -{ - /* NOTE: this is really using DENSE. */ - *(vuip)((unsigned long)Base + (Offset)) = Value; - return; -} - -_X_EXPORT void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) - = writeDense8; -_X_EXPORT void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset) - = writeDense16; -_X_EXPORT void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset) - = writeDense32; -_X_EXPORT void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB8; -_X_EXPORT void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB16; -_X_EXPORT void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset) - = writeDenseNB32; -_X_EXPORT int (*xf86ReadMmio8)(pointer Base, unsigned long Offset) - = readDense8; -_X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) - = readDense16; -_X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) - = readDense32; - -#ifdef JENSEN_SUPPORT - -static int -readSparseJensen8(pointer Base, register unsigned long Offset); -static int -readSparseJensen16(pointer Base, register unsigned long Offset); -static int -readSparseJensen32(pointer Base, register unsigned long Offset); -static void -writeSparseJensen8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseJensen16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseJensen32(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset); -static void -writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset); - -/* - * 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 SPARSE (5) -#else -#define SPARSE (7) -#endif - -#define JENSEN_SHIFT(x) ((long)x<<SPARSE) - -static pointer -mapVidMemJensen(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - int fd, prot; - - xf86WriteMmio8 = writeSparseJensen8; - xf86WriteMmio16 = writeSparseJensen16; - xf86WriteMmio32 = writeSparseJensen32; - xf86WriteMmioNB8 = writeSparseJensenNB8; - xf86WriteMmioNB16 = writeSparseJensenNB16; - xf86WriteMmioNB32 = writeSparseJensenNB32; - xf86ReadMmio8 = readSparseJensen8; - xf86ReadMmio16 = readSparseJensen16; - xf86ReadMmio32 = readSparseJensen32; - - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n", - strerror(errno)); - } - - if (flags & VIDMEM_READONLY) - prot = PROT_READ; - else - prot = PROT_READ | PROT_WRITE; - - /* This requires linux-0.99.pl10 or above */ - base = mmap((caddr_t)0, JENSEN_SHIFT(Size), - prot, MAP_SHARED, fd, - (off_t)(JENSEN_SHIFT((off_t)Base) + _bus_base_sparse())); - close(fd); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer" - " (0x%08x,0x%x) (%s)\n", Base, Size, - strerror(errno)); - } - return base; -} - -static void -unmapVidMemJensen(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap((caddr_t)Base, JENSEN_SHIFT(Size)); -} - -static int -readSparseJensen8(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - - mem_barrier(); - shift = (Offset & 0x3) << 3; - - result = *(vuip) ((unsigned long)Base + (Offset << SPARSE)); - - result >>= shift; - return 0xffUL & result; -} - -static int -readSparseJensen16(pointer Base, register unsigned long Offset) -{ - register unsigned long result, shift; - - mem_barrier(); - shift = (Offset & 0x2) << 3; - - result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))); - - result >>= shift; - return 0xffffUL & result; -} - -static int -readSparseJensen32(pointer Base, register unsigned long Offset) -{ - register unsigned long result; - - mem_barrier(); - result = *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))); - - return result; -} - -static void -writeSparseJensen8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned int b = Value & 0xffU; - - write_mem_barrier(); - *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101; -} - -static void -writeSparseJensen16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned int w = Value & 0xffffU; - - write_mem_barrier(); - *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) = - w * 0x00010001; -} - -static void -writeSparseJensen32(int Value, pointer Base, register unsigned long Offset) -{ - write_mem_barrier(); - *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value; -} - -static void -writeSparseJensenNB8(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned int b = Value & 0xffU; - - *(vuip) ((unsigned long)Base + (Offset << SPARSE)) = b * 0x01010101; -} - -static void -writeSparseJensenNB16(int Value, pointer Base, register unsigned long Offset) -{ - register unsigned int w = Value & 0xffffU; - - *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(1<<(SPARSE-2))) = - w * 0x00010001; -} - -static void -writeSparseJensenNB32(int Value, pointer Base, register unsigned long Offset) -{ - *(vuip)((unsigned long)Base+(Offset<<SPARSE)+(3<<(SPARSE-2))) = Value; -} -#endif /* JENSEN_SUPPORT */ - -#endif /* __alpha__ */ diff --git a/hw/xfree86/os-support/lynxos/Makefile.am b/hw/xfree86/os-support/lynxos/Makefile.am deleted file mode 100644 index 4085c49a9..000000000 --- a/hw/xfree86/os-support/lynxos/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_DIST = \ - lynx_init.c \ - lynx_mmap.c \ - lynx_mouse.c \ - lynx_noinline.c \ - lynx_ppc.c \ - lynx_video.c \ - lynx_ppc.S diff --git a/hw/xfree86/os-support/lynxos/lynx_init.c b/hw/xfree86/os-support/lynxos/lynx_init.c deleted file mode 100644 index 03f72ca19..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_init.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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. - * - */ - - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static int VTnum = -1; - -void -xf86OpenConsole() -{ - struct vt_mode VT; - char vtname1[11]; - int fd, pgrp; - MessageType from = X_PROBED; - - if (serverGeneration == 1) - { - /* check if we're run with euid==0 */ - if (geteuid() != 0) - { - FatalError("xf86OpenConsole: Server must be 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; - from = X_CMDLINE; - } - 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); - } - xf86Msg(from, "using VT number %d\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()); - - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "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) - { - xf86Msg(X_WARNING, "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 (!xf86Screens[0]->vtSema) - 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(int argc, char *argv[], int i) -{ - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) - { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) - { - UseMsg(); - VTnum = -1; - return(0); - } - return(1); - } - return(0); -} - -void -xf86UseMsg() -{ - ErrorF("vtXX use the specified VT number\n"); - return; -} - diff --git a/hw/xfree86/os-support/lynxos/lynx_mmap.c b/hw/xfree86/os-support/lynxos/lynx_mmap.c deleted file mode 100644 index 3364399aa..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_mmap.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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. - * - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/* - * Read BIOS using smem_create facility - */ - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ -#if defined(__powerpc__) - xf86Msg(X_WARNING, "xf86ReadBios: no BIOS-probe on PowerPC\n"); - return(-1); -#else - char *p; - int mlen; - - mlen = (Offset + Len + 4095) & ~4095; - 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) { - xf86Msg(X_INFO, - "xf86ReadBios: removed stale smem_ segment\n"); - p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); - } - if (p == NULL) { - xf86Msg(X_WARNING, "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); -#endif -} diff --git a/hw/xfree86/os-support/lynxos/lynx_mouse.c b/hw/xfree86/os-support/lynxos/lynx_mouse.c deleted file mode 100644 index b48202977..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_mouse.c +++ /dev/null @@ -1,33 +0,0 @@ - -/* - * Copyright 1999 by The XFree86 Project, Inc. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" - -static int -SupportedInterfaces(void) -{ - /* XXX Need to check this. */ - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO; -} - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - p->SupportedInterfaces = SupportedInterfaces; - return p; -} - diff --git a/hw/xfree86/os-support/lynxos/lynx_noinline.c b/hw/xfree86/os-support/lynxos/lynx_noinline.c deleted file mode 100644 index d4db82cca..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_noinline.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, - * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#if /* NO_INLINE && */ defined(__powerpc__) - -#include "xf86Pci.h" - -extern volatile unsigned char *ioBase; - -_X_EXPORT void -eieio() -{ - __asm__ __volatile__ ("eieio"); -} - -_X_EXPORT unsigned long -ldl_brx(volatile unsigned char *base, int ndx) -{ - register unsigned long tmp = *(volatile unsigned long *)(base+ndx); - return( ((tmp & 0x000000ff) << 24) | - ((tmp & 0x0000ff00) << 8) | - ((tmp & 0x00ff0000) >> 8) | - ((tmp & 0xff000000) >> 24) ); -} - -_X_EXPORT unsigned short -ldw_brx(volatile unsigned char *base, int ndx) -{ - register unsigned short tmp = *(volatile unsigned short *)(base+ndx); - return((tmp << 8) | (tmp >> 8)); -} - -_X_EXPORT void -stl_brx(unsigned long val, volatile unsigned char *base, int ndx) -{ - unsigned char *p = (unsigned char *)&val; - unsigned long tmp = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0); - *(volatile unsigned long *)(base+ndx) = tmp; -} - -_X_EXPORT void -stw_brx(unsigned short val, volatile unsigned char *base, int ndx) -{ - unsigned char *p = (unsigned char *)&val; - unsigned short tmp = (p[1] << 8) | p[0]; - *(volatile unsigned short *)(base+ndx) = tmp; -} - -_X_EXPORT void -outb(IOADDRESS port, unsigned char value) -{ - *((volatile unsigned char *)(ioBase + port)) = value; eieio(); -} - -_X_EXPORT void -outw(IOADDRESS port, unsigned short value) -{ - stw_brx(value, ioBase, port); eieio(); -} - -_X_EXPORT void -outl(IOADDRESS port, unsigned int value) -{ - stl_brx(value, ioBase, port); eieio(); -} - -_X_EXPORT unsigned char -inb(IOADDRESS port) -{ - unsigned char val; - - val = *((volatile unsigned char *)(ioBase + port)); eieio(); - return(val); -} - -_X_EXPORT unsigned short -inw(IOADDRESS port) -{ - unsigned short val; - - val = ldw_brx(ioBase, port); eieio(); - return(val); -} - -_X_EXPORT unsigned int -inl(IOADDRESS port) -{ - unsigned int val; - - val = ldl_brx(ioBase, port); eieio(); - return(val); -} - -_X_EXPORT unsigned long -ldl_u(void *p) -{ - return (((*(unsigned char *)(p)) | - (*((unsigned char *)(p)+1)<<8) | - (*((unsigned char *)(p)+2)<<16) | - (*((unsigned char *)(p)+3)<<24))); -} - -_X_EXPORT unsigned long -ldq_u(void *p) -{ - return ldl_u(p); -} - -_X_EXPORT unsigned short -ldw_u(void *p) -{ - return(((*(unsigned char *)(p)) | - (*((unsigned char *)(p)+1)<<8))); -} - -_X_EXPORT void -stl_u(unsigned long v, void *p) -{ - - (*(unsigned char *)(p)) = (v); - (*((unsigned char *)(p)+1)) = ((v) >> 8); - (*((unsigned char *)(p)+2)) = ((v) >> 16); - (*((unsigned char *)(p)+3)) = ((v) >> 24); -} - -_X_EXPORT void -stq_u(unsigned long v, void *p) -{ - stl_u(v,p); -} - -_X_EXPORT void -stw_u(unsigned short v, void *p) -{ - (*(unsigned char *)(p)) = (v); - (*((unsigned char *)(p)+1)) = ((v) >> 8); -} - - -_X_EXPORT void -mem_barrier(void) -{ - __asm__ __volatile__("eieio"); -} - -_X_EXPORT void -write_mem_barrier(void) -{ - __asm__ __volatile__("eieio"); -} - -#endif /* NO_INLINE && __powerpc__ */ diff --git a/hw/xfree86/os-support/lynxos/lynx_ppc.S b/hw/xfree86/os-support/lynxos/lynx_ppc.S deleted file mode 100644 index 3865850d1..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_ppc.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_ppc.S,v 1.1 1999/07/10 07:24:49 dawes Exp $ */ -/* - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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. - */ - - .file "ppc.s" -.toc - .csect .text[PR] - .balign 4 - .globl ppc_flush_icache - .globl .ppc_flush_icache -.csect ppc_flush_icache[DS] -ppc_flush_icache: - .long .ppc_flush_icache, TOC[tc0], 0 -.csect .text[PR] -.ppc_flush_icache: - mflr 0 - stw 31,-4(1) - stw 0,8(1) - stwu 1,-64(1) - mr 31,1 - stw 3,88(31) - li 6, 0 /* __inst_dcbf (addr, 0); */ - dcbf 3, 6 - li 5, 32 /* __inst_dcbf (addr, LINESIZE); */ - dcbf 3, 5 - sync /* __inst_sync (); */ - li 4,0 /* __inst_icbi (addr, 0); */ - icbi 3,4 - li 7,32 /* __inst_icbi (addr, LINESIZE); */ - icbi 3,7 - sync /* __inst_sync (); */ - isync /* __inst_isync (); */ -L..1: - lwz 1,0(1) - lwz 0,8(1) - mtlr 0 - lwz 31,-4(1) - blr -LT..ppc_flush_icache: - .long 0 - .byte 0,0,32,97,128,1,1,1 - .long 0 - .long LT..ppc_flush_icache-.ppc_flush_icache - .short 16 - .byte "ppc_flush_icache" - .byte 31 -_section_.text: - .csect .data[RW] - .long _section_.text diff --git a/hw/xfree86/os-support/lynxos/lynx_ppc.c b/hw/xfree86/os-support/lynxos/lynx_ppc.c deleted file mode 100644 index 6300f38c8..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_ppc.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 1998 by Metro Link Incorporated - * - * 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 Metro Link - * Incorporated not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. Metro Link Incorporated makes no representations - * about the suitability of this software for any purpose. It is - * provided "as is" without express or implied warranty. - * - * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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. - */ - -void ppc_flush_icache() -{ -__asm__ __volatile__ (" \ - mflr 0 ;\ - stw 31,-4(1) ;\ - stw 0,8(1) ;\ - stwu 1,-64(1) ;\ - mr 31,1 ;\ - stw 3,88(31) ;\ - li 6, 0 ;\ - dcbf 3, 6 ;\ - li 5, 32 ;\ - dcbf 3, 5 ;\ - sync ;\ - li 4,0 ;\ - icbi 3,4 ;\ - li 7,32 ;\ - icbi 3,7 ;\ - sync ;\ - isync ;\ - lwz 1,0(1) ;\ - lwz 0,8(1) ;\ - mtlr 0 ;\ - lwz 31,-4(1) ;\ - blr ;\ -"); -} diff --git a/hw/xfree86/os-support/lynxos/lynx_video.c b/hw/xfree86/os-support/lynxos/lynx_video.c deleted file mode 100644 index 4602076c7..000000000 --- a/hw/xfree86/os-support/lynxos/lynx_video.c +++ /dev/null @@ -1,710 +0,0 @@ -/* - * 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. - * - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#if defined(__powerpc__) - -# if defined(USE_MACHINE_ABSOLUTE) -# include <machine/absolute.h> -# else -# define __USER_SPACE_INCLUDE -# include <hw_absolute.h> -# endif - -void ppcPciIoMap(int bus); -#endif - -#if 0 -#define DEBUG -#endif - -#ifdef HAS_MTRR_SUPPORT -#include <sys/memrange.h> -#define X_MTRR_ID "XFree86" - -static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); -static void undoWC(int, pointer); -static Bool cleanMTRR(void); -static int devMemFd = -1; -#define MTRR_DEVICE "/dev/mtrr" -#endif - - -#if !defined(NO_MMAP) -#include <sys/mman.h> - -int smem_remove(char *name) -{ - return(0); -} - -char *smem_create(char *name, char *arg_addr, long size, int mode) -{ - int fd; - void *addr = 0; - char *retval; - size_t len = size; - int prot = PROT_READ|PROT_WRITE|PROT_UNCACHE; - int flags = MAP_SHARED; - off_t off = (off_t)arg_addr; - - if ((fd = open("/dev/mem" , O_RDWR)) < 0) - { - retval = (char *)-1; - } - else - { - if (mode == SM_DETACH) - { - munmap(arg_addr, len); - retval = 0; - } - else - { - if ((retval = mmap (addr, len, prot, flags, fd, off) ) == MAP_FAILED) - { - retval = (char *)-1; - } - } - - close(fd); - } - - return(retval); -} - -#endif - - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -typedef struct -{ - char name[16]; - unsigned long Base; - unsigned long Size; - char *ptr; - int RefCnt; -} -_SMEMS; - -#define MAX_SMEMS 16 - -static _SMEMS smems[MAX_SMEMS]; - - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -static void -smemCleanup(void) -{ - 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 = 0; - smems[i].Size = 0; - smems[i].RefCnt = 0; - } - } -} - -static pointer -MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - 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("MapVidMem: 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; - - xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x\n", - Base, Size); - -#if defined(__powerpc__) - if (((unsigned long)Base & PHYS_IO_MEM_START) != PHYS_IO_MEM_START) { - Base = Base | PHYS_IO_MEM_START; - } -#endif - - smems[i].ptr = smem_create(smems[i].name, (char *)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) { - xf86Msg(X_INFO, - "MapVidMem: removed stale smem_ segment %s\n", - smems[i].name); - smems[i].ptr = smem_create(smems[i].name, - (char *)Base, Size, SM_READ|SM_WRITE); - } - if (smems[i].ptr == NULL) { - *smems[i].name = '\0'; - FatalError("MapVidMem: failed to smem_create Base %x Size %x (%s)\n", - Base, Size, strerror(errno)); - } - } - xf86MsgVerb(X_INFO, 3, "MapVidMem: Base=0x%x Size=0x%x Ptr=0x%x\n", - Base, Size, smems[i].ptr); - return smems[i].ptr; -} - -static void -UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - int i; - - xf86MsgVerb(X_INFO, 3, "UnMapVidMem: Base/Ptr=0x%x Size=0x%x\n", - Base, Size); - 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); - xf86MsgVerb(X_INFO, 3, - "UnMapVidMem: smem_create(%s, 0x%08x, ... " - "SM_DETACH)\n", smems[i].name, smems[i].ptr); - (void)smem_remove(smems[i].name); - *smems[i].name = '\0'; - smems[i].RefCnt = 0; - return; - } - } - xf86MsgVerb(X_WARNING, 2, - "UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n", - Base, Size); -} - - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = TRUE; - pVidMem->mapMem = MapVidMem; - pVidMem->unmapMem = UnMapVidMem; - pVidMem->setWC = 0; - pVidMem->undoWC = 0; -#ifdef HAS_MTRR_SUPPORT - if (cleanMTRR()) { - pVidMem->setWC = setWC; - pVidMem->undoWC = undoWC; - } -#endif - pVidMem->initialised = TRUE; -} - - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - return; -} - -/***************************************************************************/ -/* I/O Permissions section for PowerPC */ -/***************************************************************************/ - -#if defined(__powerpc__) - -_X_EXPORT volatile unsigned char *ioBase = MAP_FAILED; -volatile unsigned char *pciConfBase = MAP_FAILED; - -static int IOEnabled; - - -static void -removeIOSmem(void) -{ - smem_create(NULL, (char *) ioBase, 0, SM_DETACH); - smem_remove("IOBASE"); - ioBase = MAP_FAILED; -} - -_X_EXPORT Bool -xf86EnableIO() -{ - if (IOEnabled++ == 0) { - ioBase = (unsigned char *) smem_create("IOBASE", - (char *)PHYS_ISA_IO_SPACE, 64*1024, SM_READ|SM_WRITE); - if (ioBase == MAP_FAILED) { - --IOEnabled; - xf86Msg(X_WARNING,"xf86EnableIO: Failed to map I/O\n"); - return FALSE; - } else { -#ifdef DEBUG - ErrorF("xf86EnableIO: mapped I/O at vaddr 0x%08x\n", - ioBase); -#endif - atexit(removeIOSmem); - } - } - return TRUE; -} - -_X_EXPORT void -xf86DisableIO() -{ - if (!IOEnabled) - return; - - if (--IOEnabled == 0) - removeIOSmem(); - return; -} - -#if 0 -void -xf86DisableIOPrivs(void) -{ - return; -} -#endif -void -ppcPciIoMap(int bus) -{ - xf86EnableIO(); -} - -#endif - - -#ifdef HAS_MTRR_SUPPORT -/* memory range (MTRR) support for LynxOS (taken from BSD MTRR support) */ - -/* - * This code is experimental. Some parts may be overkill, and other parts - * may be incomplete. - */ - -/* - * getAllRanges returns the full list of memory ranges with attributes set. - */ - -static struct mem_range_desc * -getAllRanges(int *nmr) -{ - struct mem_range_desc *mrd; - struct mem_range_op mro; - - /* - * Find how many ranges there are. If this fails, then the kernel - * probably doesn't have MTRR support. - */ - mro.mo_arg[0] = 0; - if (ioctl(devMemFd, MEMRANGE_GET, &mro)) - return NULL; - *nmr = mro.mo_arg[0]; - mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); - mro.mo_arg[0] = *nmr; - mro.mo_desc = mrd; - if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { - xfree(mrd); - return NULL; - } - return mrd; -} - -/* - * cleanMTRR removes any memory attribute that may be left by a previous - * X server. Normally there won't be any, but this takes care of the - * case where a server crashed without being able finish cleaning up. - */ - -static Bool -cleanMTRR() -{ - struct mem_range_desc *mrd; - struct mem_range_op mro; - int nmr, i; - - /* This shouldn't happen */ - if (devMemFd < 0) { - if ((devMemFd = open(MTRR_DEVICE, O_RDONLY)) < 0) { -perror("open MTRR"); - return FALSE; - } - } - - if (!(mrd = getAllRanges(&nmr))) - return FALSE; - - for (i = 0; i < nmr; i++) { - if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 && - (mrd[i].mr_flags & MDF_ACTIVE)) { -#ifdef DEBUG - ErrorF("Clean for (0x%lx,0x%lx)\n", - (unsigned long)mrd[i].mr_base, - (unsigned long)mrd[i].mr_len); -#endif - if (mrd[i].mr_flags & MDF_FIXACTIVE) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - mrd[i].mr_flags = MDF_UNCACHEABLE; - } else { - mro.mo_arg[0] = MEMRANGE_SET_REMOVE; - } - mro.mo_desc = mrd + i; - ioctl(devMemFd, MEMRANGE_SET, &mro); - } - } -#ifdef DEBUG - sleep(10); -#endif - xfree(mrd); - return TRUE; -} - -typedef struct x_RangeRec { - struct mem_range_desc mrd; - Bool wasWC; - struct x_RangeRec * next; -} RangeRec, *RangePtr; - -static void -freeRangeList(RangePtr range) -{ - RangePtr rp; - - while (range) { - rp = range; - range = rp->next; - xfree(rp); - } -} - -static RangePtr -dupRangeList(RangePtr list) -{ - RangePtr new = NULL, rp, p; - - rp = list; - while (rp) { - p = xnfalloc(sizeof(RangeRec)); - *p = *rp; - p->next = new; - new = p; - rp = rp->next; - } - return new; -} - -static RangePtr -sortRangeList(RangePtr list) -{ - RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev; - unsigned long minBase; - - /* Sort by base address */ - rp1 = copy = dupRangeList(list); - while (rp1) { - minBase = rp1->mrd.mr_base; - minp = rp1; - minprev = NULL; - prev = rp1; - rp2 = rp1->next; - while (rp2) { - if (rp2->mrd.mr_base < minBase) { - minBase = rp2->mrd.mr_base; - minp = rp2; - minprev = prev; - } - prev = rp2; - rp2 = rp2->next; - } - if (minprev) { - minprev->next = minp->next; - rp1 = copy; - } else { - rp1 = minp->next; - } - minp->next = sorted; - sorted = minp; - } - return sorted; -} - -/* - * findRanges returns a list of ranges that overlap the specified range. - */ - -static void -findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp) -{ - struct mem_range_desc *mrd; - int nmr, i; - RangePtr rp, *p; - - if (!(mrd = getAllRanges(&nmr))) - return; - - for (i = 0; i < nmr; i++) { - if ((mrd[i].mr_flags & MDF_ACTIVE) && - mrd[i].mr_base < base + size && - mrd[i].mr_base + mrd[i].mr_len > base) { - if (mrd[i].mr_flags & MDF_WRITECOMBINE) - p = wcp; - else if (mrd[i].mr_flags & MDF_UNCACHEABLE) - p = ucp; - else - continue; - rp = xnfalloc(sizeof(RangeRec)); - rp->mrd = mrd[i]; - rp->next = *p; - *p = rp; - } - } - xfree(mrd); -} - -/* - * This checks if the existing overlapping ranges fully cover the requested - * range. Is this overkill? - */ - -static Bool -fullCoverage(unsigned long base, unsigned long size, RangePtr overlap) -{ - RangePtr rp1, sorted = NULL; - unsigned long end; - - sorted = sortRangeList(overlap); - /* Look for gaps */ - rp1 = sorted; - end = base + size; - while (rp1) { - if (rp1->mrd.mr_base > base) { - freeRangeList(sorted); - return FALSE; - } else { - base = rp1->mrd.mr_base + rp1->mrd.mr_len; - } - if (base >= end) { - freeRangeList(sorted); - return TRUE; - } - rp1 = rp1->next; - } - freeRangeList(sorted); - return FALSE; -} - -static pointer -addWC(int screenNum, unsigned long base, unsigned long size, MessageType from) -{ - RangePtr uc = NULL, wc = NULL, retlist = NULL; - struct mem_range_desc mrd; - struct mem_range_op mro; - - findRanges(base, size, &uc, &wc); - - /* See of the full range is already WC */ - if (!uc && fullCoverage(base, size, wc)) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx) was already set\n", - base, size); - return NULL; - } - - /* Otherwise, try to add the new range */ - mrd.mr_base = base; - mrd.mr_len = size; - strcpy(mrd.mr_owner, X_MTRR_ID); - mrd.mr_flags = MDF_WRITECOMBINE; - mro.mo_desc = &mrd; - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to set write-combining range " - "(0x%lx,0x%lx)\n", base, size); - return NULL; - } else { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx)\n", base, size); - retlist = xnfalloc(sizeof(RangeRec)); - retlist->mrd = mrd; - retlist->wasWC = FALSE; - retlist->next = NULL; - return retlist; - } -} - -static pointer -delWC(int screenNum, unsigned long base, unsigned long size, MessageType from) -{ - RangePtr uc = NULL, wc = NULL, retlist = NULL; - struct mem_range_desc mrd; - struct mem_range_op mro; - - findRanges(base, size, &uc, &wc); - - /* - * See of the full range is already not WC, or if there is full - * coverage from UC ranges. - */ - if (!wc || fullCoverage(base, size, uc)) { - xf86DrvMsg(screenNum, from, - "Write-combining range (0x%lx,0x%lx) was already clear\n", - base, size); - return NULL; - } - - /* Otherwise, try to add the new range */ - mrd.mr_base = base; - mrd.mr_len = size; - strcpy(mrd.mr_owner, X_MTRR_ID); - mrd.mr_flags = MDF_UNCACHEABLE; - mro.mo_desc = &mrd; - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to remove write-combining range " - "(0x%lx,0x%lx)\n", base, size); - /* XXX Should then remove all of the overlapping WC ranges */ - return NULL; - } else { - xf86DrvMsg(screenNum, from, - "Removed Write-combining range (0x%lx,0x%lx)\n", - base, size); - retlist = xnfalloc(sizeof(RangeRec)); - retlist->mrd = mrd; - retlist->wasWC = TRUE; - retlist->next = NULL; - return retlist; - } -} - -static pointer -setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, - MessageType from) -{ - if (enable) - return addWC(screenNum, base, size, from); - else - return delWC(screenNum, base, size, from); -} - -static void -undoWC(int screenNum, pointer list) -{ - RangePtr rp; - struct mem_range_op mro; - Bool failed; - - rp = list; - while (rp) { -#ifdef DEBUG - ErrorF("Undo for (0x%lx,0x%lx), %d\n", - (unsigned long)rp->mrd.mr_base, - (unsigned long)rp->mrd.mr_len, rp->wasWC); -#endif - failed = FALSE; - if (rp->wasWC) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - rp->mrd.mr_flags = MDF_WRITECOMBINE; - strcpy(rp->mrd.mr_owner, "unknown"); - } else { - mro.mo_arg[0] = MEMRANGE_SET_REMOVE; - } - mro.mo_desc = &rp->mrd; - - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { - if (!rp->wasWC) { - mro.mo_arg[0] = MEMRANGE_SET_UPDATE; - rp->mrd.mr_flags = MDF_UNCACHEABLE; - strcpy(rp->mrd.mr_owner, "unknown"); - if (ioctl(devMemFd, MEMRANGE_SET, &mro)) - failed = TRUE; - } else - failed = TRUE; - } - if (failed) { - xf86DrvMsg(screenNum, X_WARNING, - "Failed to restore MTRR range (0x%lx,0x%lx)\n", - (unsigned long)rp->mrd.mr_base, - (unsigned long)rp->mrd.mr_len); - } - rp = rp->next; - } -} - -#endif /* HAS_MTRR_SUPPORT */ - diff --git a/hw/xfree86/os-support/misc/BUSmemcpy.S b/hw/xfree86/os-support/misc/BUSmemcpy.S deleted file mode 100644 index 373723c7d..000000000 --- a/hw/xfree86/os-support/misc/BUSmemcpy.S +++ /dev/null @@ -1,153 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/BUSmemcpy.s,v 1.2 1998/07/25 16:56:49 dawes Exp $ */ -/****************************************************************************** - Copyright 1993 by Glenn G. Lai - - All Rights Reserved - -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 Glenn G. Lai not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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. - -Glenn G. Lai -P.O. Box 4314 -Austin, Tx 78765 -(glenn@cs.utexas.edu) -8/9/93 -******************************************************************************/ -/* $XConsortium: BUSmemcpy.s /main/4 1996/02/21 17:39:34 kaleb $ */ - -/* - * Modified to use long-alignment of video memory rather than word-alignment - * to improve performance for LocalBus video cards. Function names changed - * from ISAToMem and MemToISA to BusToMem and MemToBus. - * - * David Dawes <dawes@XFree86.org>, 25 August 1993. - */ - - -#include "assyntax.h" - - FILE("BUSmemcpy.s") - - AS_BEGIN - -/* BusToMem copies from video memory to main memory - MemToBus copies from main memory to video memory - - void xf86BusToMem(unsigned char *dst, unsigned char *src, int len); - void xf86MemToBus(unsigned char *dst, unsigned char *src, int len); -*/ - -#define dst REGOFF(4,ESP) -#define src REGOFF(8,ESP) -#define len REGOFF(12,ESP) - - GLOBL GLNAME(xf86BusToMem) - GLOBL GLNAME(xf86MemToBus) - - SEG_DATA -copyright: - STRING("Copyright 8/9/1993 by Glenn G. Lai") - - SEG_TEXT - ALIGNTEXT4 -GLNAME(xf86BusToMem): - CLD - PUSH_L (ESI) - MOV_L (EDI, EDX) - - MOV_L (src, ESI) - MOV_L (dst, EDI) - MOV_L (len, ECX) - - CMP_L (CONST(7), ECX) - JC (quickBM) - - TEST_L (CONST(1), ESI) - JZ (BwM) - - MOVS_B - DEC_L (ECX) - -BwM: - TEST_L (CONST(2), ESI) - JZ (BlM) - - MOVS_W - DEC_L (ECX) - DEC_L (ECX) - -BlM: - MOV_L (ECX, EAX) - AND_L (CONST(3), EAX) - SHR_L (CONST(2), ECX) - REP - MOVS_L - MOV_L (EAX, ECX) -quickBM: - OR_L (ECX, ECX) - JZ (return) - REP - MOVS_B -return: - POP_L (ESI) - MOV_L (EDX, EDI) - RET -/************************/ - - ALIGNTEXT4 -GLNAME(xf86MemToBus): - CLD - PUSH_L (ESI) - MOV_L (EDI, EDX) - - MOV_L (src, ESI) - MOV_L (dst, EDI) - MOV_L (len, ECX) - - CMP_L (CONST(7), ECX) - JC (quickMB) - - TEST_L (CONST(1), EDI) - JZ (MwB) - - MOVS_B - DEC_L (ECX) - -MwB: - TEST_L (CONST(2), EDI) - JZ (MlB) - - MOVS_W - DEC_L (ECX) - DEC_L (ECX) - -MlB: - MOV_L (ECX, EAX) - AND_L (CONST(3), EAX) - SHR_L (CONST(2), ECX) - REP - MOVS_L - MOV_L (EAX, ECX) -quickMB: - OR_L (ECX, ECX) - JZ (return) - REP - MOVS_B - - POP_L (ESI) - MOV_L (EDX, EDI) - RET - diff --git a/hw/xfree86/os-support/misc/BUSmemcpy.c b/hw/xfree86/os-support/misc/BUSmemcpy.c deleted file mode 100644 index b482b867a..000000000 --- a/hw/xfree86/os-support/misc/BUSmemcpy.c +++ /dev/null @@ -1,412 +0,0 @@ - -/**************************************************************************** - - For Alpha Linux, BusToMem() and MemToBus() can be simply memcpy(), BUT: - we need to prevent unaligned operations when accessing DENSE space on the BUS, - as the video memory is mmap'd that way. The below code does this. - -NOTE: we could simply use the "memcpy()" from LIBC here, but that, currently, is - not as fast. - -Thanks to Linus Torvalds for contributing this code. - -****************************************************************************/ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifdef __alpha__ - -#include "compiler.h" - -/* - * The Jensen lacks dense memory, thus we have to address the bus via - * the sparse addressing scheme. These routines are only used in s3im.c - * Non time critical code uses SlowBCopy_{from/to} bus. - * - * 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 LWORD_CODING (0x18) -#define SPARSE (5) -#else -#define LWORD_CODING (0x60) -#define SPARSE (7) -#endif - -void -xf86JensenMemToBus(char *Base, long dst, long src, int count) -{ - if( ((long)src^((long)dst)) & 3) { - /* src & dst are NOT aligned to each other */ - unsigned long addr; - unsigned long low_word, high_word,last_read; - long rm,loop; - unsigned long tmp,org,org2,mask,src_org,count_org; - - src_org=src; - count_org=count; - - /* add EISA longword coding and round off*/ - addr = (long)(Base+(dst<<SPARSE) + LWORD_CODING) & ~(3<<SPARSE); - rm = (long)dst & 3; - count += rm; - - count = count_org + rm; - org = *(volatile unsigned int *)addr; - __asm__("ldq_u %0,%1" - :"=r" (low_word):"m" (*(unsigned long *)(src_org))); - src = src_org - rm; - if( count > 4 ) { - last_read = src_org+count_org - 1; - __asm__("ldq_u %0,%1" - :"=r" (high_word):"m" (*(unsigned long *)(src+4))); - __asm__("extll %1,%2,%0" - :"=r" (low_word) - :"r" (low_word), "r" ((unsigned long)(src))); - __asm__("extlh %1,%2,%0" - :"=r" (tmp) - :"r" (high_word), "r" ((unsigned long)(src))); - tmp |= low_word; - src += 4; - __asm__("mskqh %1,%2,%0" - :"=r" (tmp) - :"r" (tmp), "r" (rm)); - __asm__("mskql %1,%2,%0" - :"=r" (org2) - :"r" (org), "r" (rm)); - tmp |= org2; - - loop = (count-4) >> 2; /* loop eqv. count>=4 ; count -= 4 */ - while (loop) { - /* tmp to be stored completly -- need to read next word*/ - low_word = high_word; - *(volatile unsigned int *) (addr) = tmp; - __asm__("ldq_u %0,%1" - :"=r" (high_word):"m" (*(unsigned long*)(src+4))); - loop --; - __asm__("extll %1,%2,%0" - :"=r" (low_word) - :"r" (low_word), "r" ((unsigned long)src)); - __asm__("extlh %1,%2,%0" - :"=r" (tmp) - :"r" (high_word), "r" ((unsigned long)src)); - src += 4; - tmp |= low_word; - addr += 4<<SPARSE; - } - if ( count & 3 ) { - /* Store tmp completly, and possibly read one more word.*/ - *(volatile unsigned int *) (addr) = tmp; - __asm__("ldq_u %0,%1" - :"=r" (tmp):"m" (*((unsigned long *)(last_read)) )); - addr += 4<<SPARSE; - __asm__("extll %1,%2,%0" - :"=r" (low_word) - :"r" (high_word), "r" ((unsigned long)src)); - __asm__("extlh %1,%2,%0" - :"=r" (tmp) - :"r" (tmp), "r" ((unsigned long)src)); - tmp |= low_word; - org = *(volatile unsigned int *)addr; - - __asm__("mskql %1,%2,%0" - :"=r" (tmp) - :"r" (tmp), "r" (count&3)); - __asm__("mskqh %1,%2,%0" - :"=r" (org) - :"r" (org), "r" (count&3)); - - tmp |= org; - } - *(volatile unsigned int *) (addr) = tmp; - return; - } else { /* count > 4 */ - __asm__("ldq_u %0,%1" - :"=r" (high_word):"m" (*(unsigned long *)(src+4))); - __asm__("extll %1,%2,%0" - :"=r" (low_word) - :"r" (low_word), "r" ((unsigned long)(src))); - __asm__("extlh %1,%2,%0" - :"=r" (tmp) - :"r" (high_word), "r" ((unsigned long)(src))); - tmp |= low_word; - if( count < 4 ) { - - mask = -1; - __asm__("mskqh %1,%2,%0" - :"=r" (mask) - :"r" (mask), "r" (rm)); - __asm__("mskql %1,%2,%0" - :"=r" (mask) - :"r" (mask), "r" (count)); - tmp = (tmp & mask) | (org & ~mask); - *(volatile unsigned int *) (addr) = tmp; - return; - } else { - __asm__("mskqh %1,%2,%0" - :"=r" (tmp) - :"r" (tmp), "r" (rm)); - __asm__("mskql %1,%2,%0" - :"=r" (org2) - :"r" (org), "r" (rm)); - - tmp |= org2; - *(volatile unsigned int *) (addr) = tmp; - return; - } - } - } else { /* src & dst are aligned to each other */ - unsigned long addr; - unsigned int tmp,org,rm; - unsigned int *src_r; - - /* add EISA longword coding and round off*/ - addr = (long)(Base+(dst<<SPARSE) + LWORD_CODING) & ~(3<<SPARSE); - - src_r = (unsigned int*)((long)src & ~3L); - rm=(long)src & 3; - count += rm; - - tmp = *src_r; - org = *(volatile unsigned int *)addr; - - __asm__("mskqh %1,%2,%0" - :"=r" (tmp) - :"r" (tmp), "r" (rm)); - __asm__("mskql %1,%2,%0" - :"=r" (org) - :"r" (org), "r" (rm)); - - tmp |= org; - - while (count > 4) { - *(volatile unsigned int *) addr = tmp; - addr += 4<<SPARSE; - src_r += 1; - tmp = *src_r; - count -= 4; - } - - org = *(volatile unsigned int *)addr; - __asm__("mskql %1,%2,%0" - :"=r" (tmp) - :"r" (tmp), "r" (count)); - __asm__("mskqh %1,%2,%0" - :"=r" (org) - :"r" (org), "r" (count)); - tmp |= org; - *(volatile unsigned int *) (addr) = tmp; - } -} - -void -xf86JensenBusToMem(char *Base, char *dst, unsigned long src, int count) -{ -#if 0 - /* Optimization of BusToMem() is left as an exercise to the reader ;-) - * Consider that ldq_u/extlh/extll won't work because of the bus being - * only 4 bytes wide! - */ -#else - unsigned long addr; - long result; - - addr = (unsigned long)(Base+(src<<SPARSE)) ; - while( addr & (3<<SPARSE) ){ - if(count <= 0) return; - result = *(volatile int *) addr; - result >>= ((addr>>SPARSE) & 3) * 8; - *dst++ = (char) result; - addr += 1<<SPARSE; - count--; - } - count -=4; - while(count >= 0){ - int i; - - result = *(volatile int *) (addr+LWORD_CODING); - for(i=4;i--;) { - *dst++ = (char) result; - result >>= 8; - } - addr += 4<<SPARSE; - count -= 4; - } - count +=4; - - while( count ){ - result = *(volatile int *) addr; - result >>= ((addr>>SPARSE) & 3) * 8; - *dst++ = (char) result; - addr += 1<<SPARSE; - count--; - } -#endif -} - - -static unsigned long __memcpy(unsigned long dest, unsigned long src, int n); - -_X_EXPORT void -xf86BusToMem(unsigned char *dst, unsigned char *src, int len) -{ - __memcpy((unsigned long)dst, (unsigned long)src, len); -} -_X_EXPORT void -xf86MemToBus(unsigned char *dst, unsigned char *src, int len) -{ - if (len == sizeof(int)) - if (!(((long)src | (long)dst) & 3)) - *((unsigned int*)dst) = *((unsigned int*)(src)); - else { - int i; - if (((long)src) & 3) - i = ldl_u((unsigned int*)src); - else - i = *(unsigned int*)src; - if (((long)dst) & 3) - stl_u(i,(unsigned int*)dst); - else - *(unsigned int*)dst = i; - } - else - __memcpy((unsigned long)dst, (unsigned long)src, len); -} - -/* - * linux/arch/alpha/lib/memcpy.c - * - * Copyright (C) 1995 Linus Torvalds, used with his permission. - */ - -/* - * This is a reasonably optimized memcpy() routine. - */ - -/* - * Note that the C code is written to be optimized into good assembly. However, - * at this point gcc is unable to sanely compile "if (n >= 0)", resulting in a - * explicit compare against 0 (instead of just using the proper "blt reg, xx" or - * "bge reg, xx"). I hope alpha-gcc will be fixed to notice this eventually.. - */ - -/* - * This should be done in one go with ldq_u*2/mask/stq_u. Do it - * with a macro so that we can fix it up later.. - */ -#define ALIGN_DEST_TO8(d,s,n) \ - while (d & 7) { \ - if (n <= 0) return; \ - n--; \ - *(char *) d = *(char *) s; \ - d++; s++; \ - } - -/* - * This should similarly be done with ldq_u*2/mask/stq. The destination - * is aligned, but we don't fill in a full quad-word - */ -#define DO_REST(d,s,n) \ - while (n > 0) { \ - n--; \ - *(char *) d = *(char *) s; \ - d++; s++; \ - } - -/* - * This should be done with ldq/mask/stq. The source and destination are - * aligned, but we don't fill in a full quad-word - */ -#define DO_REST_ALIGNED(d,s,n) DO_REST(d,s,n) - -/* - * This does unaligned memory copies. We want to avoid storing to - * an unaligned address, as that would do a read-modify-write cycle. - * We also want to avoid double-reading the unaligned reads. - * - * Note the ordering to try to avoid load (and address generation) latencies. - */ -static __inline__ void __memcpy_unaligned(unsigned long d, unsigned long s, long n) -{ - ALIGN_DEST_TO8(d,s,n); - n -= 8; /* to avoid compare against 8 in the loop */ - if (n >= 0) { - unsigned long low_word, high_word; - __asm__("ldq_u %0,%1":"=r" (low_word):"m" (*(unsigned long *) s)); - do { - unsigned long tmp; - __asm__("ldq_u %0,%1":"=r" (high_word):"m" (*(unsigned long *)(s+8))); - n -= 8; - __asm__("extql %1,%2,%0" - :"=r" (low_word) - :"r" (low_word), "r" (s)); - __asm__("extqh %1,%2,%0" - :"=r" (tmp) - :"r" (high_word), "r" (s)); - s += 8; - *(unsigned long *) d = low_word | tmp; - d += 8; - low_word = high_word; - } while (n >= 0); - } - n += 8; - DO_REST(d,s,n); -} - -/* - * Hmm.. Strange. The __asm__ here is there to make gcc use a integer register - * for the load-store. I don't know why, but it would seem that using a floating - * point register for the move seems to slow things down (very small difference, - * though). - * - * Note the ordering to try to avoid load (and address generation) latencies. - */ -static __inline__ void __memcpy_aligned(unsigned long d, unsigned long s, long n) -{ - ALIGN_DEST_TO8(d,s,n); - n -= 8; - while (n >= 0) { - unsigned long tmp; - __asm__("ldq %0,%1":"=r" (tmp):"m" (*(unsigned long *) s)); - n -= 8; - s += 8; - *(unsigned long *) d = tmp; - d += 8; - } - n += 8; - DO_REST_ALIGNED(d,s,n); -} - -static unsigned long __memcpy(unsigned long dest, unsigned long src, int n) -{ - if (!((dest ^ src) & 7)) { - __memcpy_aligned(dest, src, n); - return dest; - } - __memcpy_unaligned(dest, src, n); - return dest; -} - -#else /* __alpha__ */ - -void -xf86BusToMem(unsigned char *dst, unsigned char *src, int len) -{ - memcpy(dst, src, len); -} -void -xf86MemToBus(unsigned char *dst, unsigned char *src, int len) -{ - memcpy(dst, src, len); -} - -#endif /* __alpha__ */ diff --git a/hw/xfree86/os-support/misc/Delay.c b/hw/xfree86/os-support/misc/Delay.c deleted file mode 100644 index b18789a3a..000000000 --- a/hw/xfree86/os-support/misc/Delay.c +++ /dev/null @@ -1,39 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include <time.h> - -_X_EXPORT void -xf86UDelay(long usec) -{ -#if 0 - struct timeval start, interrupt; -#else - int sigio; - - sigio = xf86BlockSIGIO(); - usleep(usec); - xf86UnblockSIGIO(sigio); -#endif - -#if 0 - gettimeofday(&start,NULL); - - do { - usleep(usec); - gettimeofday(&interrupt,NULL); - - if ((usec = usec - (interrupt.tv_sec - start.tv_sec) * 1000000 - - (interrupt.tv_usec - start.tv_usec)) < 0) - break; - start = interrupt; - } while (1); -#endif -} - diff --git a/hw/xfree86/os-support/misc/IODelay.S b/hw/xfree86/os-support/misc/IODelay.S deleted file mode 100644 index 4c6e32f3f..000000000 --- a/hw/xfree86/os-support/misc/IODelay.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/IODelay.S,v 1.1 1999/07/10 07:24:50 dawes Exp $ */ -/******************************************************************************* - Copyright 1994 by Glenn G. Lai - - All Rights Reserved - -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 copyr notice appear in all copies and that -both that copyr notice and this permission notice appear in -supporting documentation, and that the name of Glenn G. Lai not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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. - -Glenn G. Lai -P.O. Box 4314 -Austin, Tx 78765 -glenn@cs.utexas.edu) -7/21/94 -*******************************************************************************/ -/* $XConsortium: IODelay.s /main/4 1996/02/21 17:40:21 kaleb $ */ - -/* - * All we really need is a delay of about 40ns for I/O recovery for just - * about any occasion, but we'll be more conservative here: On a - * 100-MHz CPU, produce at least a delay of 1,000ns. - */ - -#include "assyntax.h" - - FILE("DACDelay.s") - - AS_BEGIN - - GLOBL GLNAME(xf86IODelay) - - SEG_TEXT - ALIGNTEXT4 -GLNAME(xf86IODelay): - MOV_L (CONST(100), EAX) -delay_it: - DEC_L (EAX) - JNE (delay_it) - RET - diff --git a/hw/xfree86/os-support/misc/IODelay.c b/hw/xfree86/os-support/misc/IODelay.c deleted file mode 100644 index e4422f234..000000000 --- a/hw/xfree86/os-support/misc/IODelay.c +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - Stub for Alpha Linux -*******************************************************************************/ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/* - * All we really need is a delay of about 40ns for I/O recovery for just - * about any occasion, but we'll be more conservative here: On a - * 100-MHz CPU, produce at least a delay of 1,000ns. - */ -_X_EXPORT void -xf86IODelay() -{ - xf86UDelay(1); -} - diff --git a/hw/xfree86/os-support/misc/Makefile.am b/hw/xfree86/os-support/misc/Makefile.am deleted file mode 100644 index 65fbe92b4..000000000 --- a/hw/xfree86/os-support/misc/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# FIXME: Add the *.S files to build when applicable -I386_SRCS = BUSmemcpy.S IODelay.S SlowBcopy.S -OTHER_SRCS = BUSmemcpy.c IODelay.c SlowBcopy.c - -ARCH_SRCS = $(OTHER_SRCS) - -# FIXME: Add to the build (NeedPortIO) -PORTIO_SRCS = PortIO.S - -# FIXME: Add to the build (if HasGcc || HasGcc2) -ILHACK_SRCS = xf86_IlHack.c - -noinst_LTLIBRARIES = libmisc.la - -libmisc_la_SOURCES = xf86_Util.c Delay.c $(ARCH_SRCS) - -#AM_LDFLAGS = -r - -INCLUDES = $(XORG_INCS) - -AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) - -EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS) $(ILHACK_SRCS) diff --git a/hw/xfree86/os-support/misc/PortIO.S b/hw/xfree86/os-support/misc/PortIO.S deleted file mode 100644 index 75db31156..000000000 --- a/hw/xfree86/os-support/misc/PortIO.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $XFree86$ */ - -/* Port I/O functions for platforms with no inlining. */ - -#include "assyntax.h" - - FILE("PortIO.s") - - AS_BEGIN - - GLOBL GLNAME(outb) - GLOBL GLNAME(outw) - GLOBL GLNAME(outl) - GLOBL GLNAME(inb) - GLOBL GLNAME(inw) - GLOBL GLNAME(inl) - - SEG_TEXT - ALIGNTEXT4 -GLNAME(outb): - MOV_L (REGOFF(4,ESP), EDX) - MOV_L (REGOFF(8,ESP), EAX) - OUT_B - RET - - ALIGNTEXT4 -GLNAME(outw): - MOV_L (REGOFF(4,ESP), EDX) - MOV_L (REGOFF(8,ESP), EAX) - OUT_W - RET - - ALIGNTEXT4 -GLNAME(outl): - MOV_L (REGOFF(4,ESP), EDX) - MOV_L (REGOFF(8,ESP), EAX) - OUT_L - RET - - ALIGNTEXT4 -GLNAME(inb): - MOV_L (REGOFF(4,ESP), EDX) - IN_B - RET - - ALIGNTEXT4 -GLNAME(inw): - MOV_L (REGOFF(4,ESP), EDX) - IN_L - RET - - ALIGNTEXT4 -GLNAME(inl): - MOV_L (REGOFF(4,ESP), EDX) - IN_L - RET - diff --git a/hw/xfree86/os-support/misc/SlowBcopy.S b/hw/xfree86/os-support/misc/SlowBcopy.S deleted file mode 100644 index 9b6af1d69..000000000 --- a/hw/xfree86/os-support/misc/SlowBcopy.S +++ /dev/null @@ -1,108 +0,0 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/SlowBcopy.S,v 1.1 1999/07/10 07:24:51 dawes Exp $ */ -/******************************************************************************* - Copyright 1994 by Glenn G. Lai - - All Rights Reserved - -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 copyr notice appear in all copies and that -both that copyr notice and this permission notice appear in -supporting documentation, and that the name of Glenn G. Lai not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -Glenn G. Lai DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL 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. - -Glenn G. Lai -P.O. Box 4314 -Austin, Tx 78765 -glenn@cs.utexas.edu) -7/21/94 -*******************************************************************************/ -/* $XConsortium: SlowBcopy.s /main/4 1996/02/21 17:40:52 kaleb $ */ - -/* - * Modified from the output generated by GCC - * - * Create a dependency that should be immune from the effect of register - * renaming as is commonly seen in superscalar processors. This should - * insert a minimum of 100-ns delays between reads/writes at clock rates - * up to 100 MHz---GGL - * - * Slowbcopy(char *src, char *dst, int count) - * - */ - -#include "assyntax.h" - - FILE("SlowBcopy.s") - - AS_BEGIN - -gcc2_compiled.: -___gnu_compiled_c: - - GLOBL GLNAME(xf86SlowBcopy) - - SEG_TEXT - ALIGNTEXT4 -GLNAME(xf86SlowBcopy): - PUSH_L (EBP) - MOV_L (ESP,EBP) - PUSH_L (ESI) - PUSH_L (EBX) - MOV_L (REGOFF(8,EBP),ECX) - MOV_L (REGOFF(12,EBP),EDX) - MOV_L (REGOFF(16,EBP),ESI) - XOR_L (EAX,EAX) - CMP_L (ESI,EAX) - JGE (L3) - - ALIGNTEXT4 -L5: - MOV_B (REGIND(ECX),BL) - - MOV_B (BL, BH) - MOV_B (BH, BL) - MOV_B (BL, BH) - MOV_B (BH, BL) - MOV_B (BL, BH) - MOV_B (BH, BL) - MOV_B (BL, BH) - MOV_B (BH, BL) - MOV_B (BL, BH) - MOV_B (BH, BL) - - MOV_B (BL,REGIND(EDX)) - - INC_L (ECX) - DEC_L (ECX) - INC_L (ECX) - DEC_L (ECX) - INC_L (ECX) - DEC_L (ECX) - INC_L (ECX) - DEC_L (ECX) - INC_L (ECX) - DEC_L (ECX) - - INC_L (ECX) - INC_L (EDX) - INC_L (EAX) - CMP_L (ESI,EAX) - JL (L5) -L3: - LEA_L (REGOFF(-8,EBP),ESP) - POP_L (EBX) - POP_L (ESI) - MOV_L (EBP,ESP) - POP_L (EBP) - RET - diff --git a/hw/xfree86/os-support/misc/SlowBcopy.c b/hw/xfree86/os-support/misc/SlowBcopy.c deleted file mode 100644 index 5cd716823..000000000 --- a/hw/xfree86/os-support/misc/SlowBcopy.c +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - for Alpha Linux -*******************************************************************************/ - -/* - * Create a dependency that should be immune from the effect of register - * renaming as is commonly seen in superscalar processors. This should - * insert a minimum of 100-ns delays between reads/writes at clock rates - * up to 100 MHz---GGL - * - * Slowbcopy(char *src, char *dst, int count) - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "compiler.h" - -static int really_slow_bcopy; - -_X_EXPORT void -xf86SetReallySlowBcopy(void) -{ - really_slow_bcopy = 1; -} - -#if defined(__i386__) || defined(__x86_64__) -static void xf86_really_slow_bcopy(unsigned char *src, unsigned char *dst, int len) -{ - while(len--) - { - *dst++ = *src++; - outb(0x80, 0x00); - } -} -#endif - -/* The outb() isn't needed on my machine, but who knows ... -- ost */ -_X_EXPORT void -xf86SlowBcopy(unsigned char *src, unsigned char *dst, int len) -{ -#if defined(__i386__) || defined(__x86_64__) - if (really_slow_bcopy) { - xf86_really_slow_bcopy(src, dst, len); - return; - } -#endif - while(len--) - *dst++ = *src++; -} - -#ifdef __alpha__ -/* - * The Jensen lacks dense memory, thus we have to address the bus via - * the sparse addressing scheme. Time critical code uses routines from - * BUSmemcpy.c - * - * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 - */ - -#ifdef linux - -unsigned long _bus_base(void); - -#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ -#define SPARSE (5) -#else -#define SPARSE (7) -#endif - -#define isJensen() (!_bus_base()) - -#else - -#define isJensen() 0 -#define SPARSE 0 - -#endif - -_X_EXPORT void -xf86SlowBCopyFromBus(unsigned char *src, unsigned char *dst, int count) -{ - if (isJensen()) - { - unsigned long addr; - long result; - - addr = (unsigned long) src; - while( count ){ - result = *(volatile int *) addr; - result >>= ((addr>>SPARSE) & 3) * 8; - *dst++ = (unsigned char) (0xffUL & result); - addr += 1<<SPARSE; - count--; - outb(0x80, 0x00); - } - } - else - xf86SlowBcopy(src,dst,count); -} - -_X_EXPORT void -xf86SlowBCopyToBus(unsigned char *src, unsigned char *dst, int count) -{ - if (isJensen()) - { - unsigned long addr; - - addr = (unsigned long) dst; - while(count) { - *(volatile unsigned int *) addr = (unsigned short)(*src) * 0x01010101; - src++; - addr += 1<<SPARSE; - count--; - outb(0x80, 0x00); - } - } - else - xf86SlowBcopy(src,dst,count); -} -#endif diff --git a/hw/xfree86/os-support/misc/xf86_IlHack.c b/hw/xfree86/os-support/misc/xf86_IlHack.c deleted file mode 100644 index 6c9871d93..000000000 --- a/hw/xfree86/os-support/misc/xf86_IlHack.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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. - */ - -#define static /**/ -#define __inline__ /**/ -#undef NO_INLINE -#define DO_PROTOTYPES -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "compiler.h" diff --git a/hw/xfree86/os-support/misc/xf86_Util.c b/hw/xfree86/os-support/misc/xf86_Util.c deleted file mode 100644 index 9e690591d..000000000 --- a/hw/xfree86/os-support/misc/xf86_Util.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - * - */ - -/* - * 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. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <ctype.h> - -/* To prevent empty source file warnings */ -int _xf86misc; - -#if 0 -/* For use only with gcc */ -#ifdef __GNUC__ - -#include "os.h" - -char * -debug_alloca(char *file, int line, int size) -{ - char *ptr; - - ptr = Xalloc(size); - ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line, - ptr, size); - return ptr; -} - -void -debug_dealloca(char *file, int line, char *ptr) -{ - ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr); - Xfree(ptr); -} -#endif -#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 diff --git a/hw/xfree86/os-support/sco/Makefile.am b/hw/xfree86/os-support/sco/Makefile.am deleted file mode 100644 index 9cb5011fb..000000000 --- a/hw/xfree86/os-support/sco/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -EXTRA_DIST = \ - VTsw_sco.c \ - sco_init.c \ - sco_iop.c \ - sco_mouse.c \ - sco_video.c diff --git a/hw/xfree86/os-support/sco/VTsw_sco.c b/hw/xfree86/os-support/sco/VTsw_sco.c deleted file mode 100644 index d126e7869..000000000 --- a/hw/xfree86/os-support/sco/VTsw_sco.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/* For the event driver prototypes */ -#include <sys/event.h> -#include <mouse.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. NOTE: we do NOT need - * to re-arm the signal here, since we used sigaction() to set the signal - * disposition in sco_init.c. If we had used signal(), we would need to - * re-arm the signal here. All we need to do now is record the fact that - * we got the signal. XFree86 handles the rest. - */ -void -xf86VTRequest(int sig) -{ - xf86Info.vtRequestsPending = TRUE; - return; -} - -Bool -xf86VTSwitchPending(void) -{ - return(xf86Info.vtRequestsPending ? TRUE : FALSE); -} - -/* - * When we switch away, we need to flush and suspend the event driver - * before the VT_RELDISP. We also need to get the current LED status - * and preserve it, so that we can restore it when we come back. - */ -static int sco_ledstatus = -1; -static unsigned int sco_ledstate = 0; - -Bool -xf86VTSwitchAway(void) -{ - ev_flush(); - ev_suspend(); - - sco_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &sco_ledstate); - - xf86Info.vtRequestsPending = FALSE; - if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) { - return(FALSE); - } else { - return(TRUE); - } -} - -/* - * When we come back to the X server, we need to resume the event driver, - * and we need to restore the LED settings to what they were when we - * switched away. - */ -Bool -xf86VTSwitchTo(void) -{ - ev_resume(); - - xf86Info.vtRequestsPending = FALSE; - if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) { - return(FALSE); - } else { - if (sco_ledstatus >= 0) { - ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate); - } - sco_ledstatus = -1; - - /* - * Convince the console driver this screen is in graphics mode, - * otherwise it assumes it can do more to the screen than it should. - */ - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { - ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); - } - - return TRUE; - } -} diff --git a/hw/xfree86/os-support/sco/sco_init.c b/hw/xfree86/os-support/sco/sco_init.c deleted file mode 100644 index 5f7db3437..000000000 --- a/hw/xfree86/os-support/sco/sco_init.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON 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. - */ - -/* Re-written May 2001 to represent the current state of reality */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static Bool KeepTty = FALSE; -static int VTnum = -1; -static char vtdevice[48]; -static int sco_console_mode = -1; - -extern Bool mpxLock; - -void -xf86OpenConsole(void) -{ - int i, ioctl_ret; - struct vt_mode VT; - struct vid_info vidinf; - struct sigaction sigvtsw; - char *ttn; - - if (serverGeneration == 1) { - /* check if we're run with euid==0 */ - if (geteuid() != 0) { - FatalError("xf86OpenConsole: Server must be setuid root\n"); - } - - /* If we are run in the background we will get SIGTTOU. Ignore it. */ - OsSignal (SIGTTOU, SIG_IGN); - - /* - * Set up the virtual terminal (multiscreen in SCO parlance). - * For the actual console itself, screens are numbered from - * 1 to (usually) 16. However, it is possible to have a nested - * server, and it is also possible to be on a multi-console - * system such as MaxSpeed or SunRiver. Therefore, we should - * not make any assumptions about the TTY name we are on, and - * instead we rely on ttyname() to give us the real TTY name. - * Previously, we tried to determine the TTY name manually. - * This is wrong. The only time we need to futz with the TTY name - * is if we were given the name of a TTY to run on explicity on - * the command line. - */ - - if (VTnum == -1) { - /* - * No device was specified. We need to query the kernel to see which - * console device we are on (and in fact if we are on a console at all). - */ - ttn = ttyname (1); - - if (ttn == (char *)0) { - FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n", - strerror(errno)); - } - strlcpy (vtdevice, ttn, sizeof(vtdevice)); - } else if (VTnum >= 0) { - snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum); - } - - /* - * Now we can dispose of stdin/stdout - */ - fclose (stdin); - fclose (stdout); - - if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) { - FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice, - strerror(errno)); - } - - /* - * We make 100% sure we use the correct VT number. This can get ugly - * where there are multi-consoles in use, so we make sure we query - * the kernel for the correct VT number. It knows best, we don't. - */ - vidinf.size = sizeof(vidinf); - if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) { - FatalError ("xf86OpenConsole: %s not a console device " - "or error querying device: %s\n", vtdevice, strerror (errno)); - } - xf86Info.vtno = vidinf.m_num; - VTnum = vidinf.m_num + 1; /* 0-based */ - - ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice); - - /* We activate the console just in case its not the one we are on */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { - ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno)); - } - - /* Disassociate from controling TTY */ - if (!KeepTty) { - setpgrp(); - } - - /* - * Now we get the current mode that the console device is in. We will - * use this later when we close the console device to restore it to - * that same mode. - */ - if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) { - FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n", - strerror(errno)); - } - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) { - FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno)); - } - - sigvtsw.sa_handler = xf86VTRequest; - sigfillset(&sigvtsw.sa_mask); - sigvtsw.sa_flags = 0; - - /* NOTE: Using sigaction means we dont have to re-arm the signal */ - sigaction(SIGUSR1, &sigvtsw, NULL); - - VT.mode = VT_PROCESS; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - VT.frsig = SIGINT; /* Not implemented */ - VT.waitv = 0; - - /* - * The SCO X server tries the following call 5 times. Lets do the same - * thing. It shouldn't really be required but sometimes things take a - * while to settle down when switching screens. *helpless shrug* I know - * its sucks but ... - */ - - ioctl_ret = 0; - for (i = 0; i < 5; i++) { - ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); - if (ioctl_ret >= 0) - break; - usleep(999999); /* Dont use nap() - it forces linking with -lx */ - } - - if (ioctl_ret < 0) { - FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno)); - } - - /* - * Convince the console driver we are in graphics mode. - */ - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { - ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); - } - } else { /* serverGeneration != 1 */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { - ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno)); - } - } -} - -/* - * Restore the console to its previous state. This may cause flicker if - * the screen was previous in a graphics mode, because we first set it - * to text mode. This has the advantage of getting the console driver - * to do a soft reset on the card, which really does help settle the - * video card down again after coming out of Xfree86. - */ -void -xf86CloseConsole(void) -{ - struct vt_mode VT; - struct sigaction sigvtsw; - - /* Set text mode (possibly briefly) */ - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0); - - /* Restore the original mode */ - if (sco_console_mode != -1) { - ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L); - } - - ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */ - - sigvtsw.sa_handler = SIG_DFL; - sigfillset(&sigvtsw.sa_mask); - sigvtsw.sa_flags = 0; - - sigaction(SIGUSR1, &sigvtsw, NULL); - - VT.mode = VT_AUTO; - VT.waitv = 0; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - VT.frsig = SIGINT; - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */ - - close(xf86Info.consoleFd); /* We're done with the device */ -} - -int -xf86ProcessArgument(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); - } - - /* - * By default, the X server wants to bind itself to CPU 0. This makes - * sure that the server has full access to the I/O ports at IOPL 3. - * Some SMP systems have trouble with I/O on CPU's other than 0. If, - * however, you have a system that is well behaved, you can specify - * this argument and let the scheduler decide which CPU the server - * should run on. - */ - if (!strcmp(argv[i], "-nompxlock")) { - mpxLock = FALSE; - return (1); - } - - /* - * Specify the VT number to run on (NOT the device). - */ - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) { - UseMsg(); - VTnum = -1; - return(0); - } - if (VTnum <= 0) { - UseMsg(); - VTnum = -1; - return(0); - } - return(1); - } - - /* - * Use a device the user specifies. - */ - if (!strcmp(argv[i], "-crt")) { - if (++i > argc) { - UseMsg(); - VTnum = -1; - return(0); - } else { - VTnum = -2; - strlcpy (vtdevice, argv[i], sizeof(vtdevice)); - return(2); - } - } - return(0); -} - -void -xf86UseMsg(void) -{ - ErrorF("vtXX use the specified VT number\n"); - ErrorF("-crt DEVICE use the specified VT device\n"); - ErrorF("-nompxlock dont bind X server to CPU 0\n"); - ErrorF("-keeptty "); - ErrorF("don't detach controlling tty (for debugging only)\n"); -} diff --git a/hw/xfree86/os-support/sco/sco_iop.c b/hw/xfree86/os-support/sco/sco_iop.c deleted file mode 100644 index bb8d06d2e..000000000 --- a/hw/xfree86/os-support/sco/sco_iop.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2001 by J. Kean Johnston <jkj@caldera.com> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "compiler.h" - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86OSpriv.h" -#include "xf86_OSlib.h" - - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -/* - * There is a right way and a wrong way of doing this. Unfortunately, we - * are forced to do it the wrong way. The right way is to be told the range - * or ranges of I/O ports the driver(s) need access to, in order to use the - * CONS_IOPERM ioctl() to grant access only to those ports we care about. - * This way we can guarantee some small level of stability because a driver - * does not have access to all ports (which would mean it could play with - * the PIT and thus affect scheduling times, or a whole slew of other - * nasty things). However, because XFree86 currently only enables or disables - * ALL port access, we need to run at IOPL 3, which basically means the - * X Server runs at the same level as the kernel. You can image why this is - * unsafe. Oh, and this is not a problem unique to OSR5, other OSes are - * affected by this as well. - * - * So, for the time being, we change our IOPL until such time as the XFree86 - * architecture is changed to allow for tighter control of I/O ports. If and - * when it is, then the CONS_ADDIOP/DELIOP ioctl() should be used to enable - * or disable access to the desired ports. - */ - -extern long sysi86 (int cmd, ...); - -static Bool IOEnabled = FALSE; - -_X_EXPORT Bool -xf86EnableIO(void) -{ - if (IOEnabled) - return TRUE; - - if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) { - xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n"); - return FALSE; - } - - IOEnabled = TRUE; - return TRUE; -} - -_X_EXPORT void -xf86DisableIO(void) -{ - if (!IOEnabled) - return; - - sysi86(SI86V86, V86SC_IOPL, 0); - IOEnabled = FALSE; -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts(void) -{ - if (!IOEnabled) { - if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) - return FALSE; - } - -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - asm("cli"); -#endif /* __GNUC__ */ - - if (!IOEnabled) { - sysi86(SI86V86, V86SC_IOPL, PS_IOPL); - } - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts(void) -{ - if (!IOEnabled) { - if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) - return; - } - -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - asm("sti"); -#endif /* __GNUC__ */ - - if (!IOEnabled) { - sysi86(SI86V86, V86SC_IOPL, PS_IOPL); - } -} diff --git a/hw/xfree86/os-support/sco/sco_mouse.c b/hw/xfree86/os-support/sco/sco_mouse.c deleted file mode 100644 index af57cdedf..000000000 --- a/hw/xfree86/os-support/sco/sco_mouse.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2001 by J. Kean Johnston <jkj@sco.com> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" -#include "mipointer.h" -#include <sys/event.h> -#include <mouse.h> - -static int -SupportedInterfaces (void) -{ - return MSE_MISC; -} - -static const char *internalNames[] = { - "OSMouse", - NULL -}; - -static const char ** -BuiltinNames (void) -{ - return internalNames; -} - -static Bool -CheckProtocol (const char *protocol) -{ - int i; - - for (i = 0; internalNames[i]; i++) { - if (xf86NameCmp (protocol, internalNames[i]) == 0) - return TRUE; - } - - return FALSE; -} - -static const char * -DefaultProtocol (void) -{ - return "OSMouse"; -} - -static const char * -evtErrStr (int evterr) -{ - switch (evterr) { - case -1: return "error in config files"; - case -2: return "no mouse devices to attach"; - case -3: return "unable to open device"; - case -4: return "unable to open event queue"; - case -999: return "unable to initialize event driver"; - default: return "unknown event driver error"; - } -} - -static int -OsMouseProc (DeviceIntPtr pPointer, int what) -{ - InputInfoPtr pInfo; - MouseDevPtr pMse; - unsigned char map[9]; - dmask_t dmask; - MessageType from = X_CONFIG; - int evi; - - pInfo = pPointer->public.devicePrivate; - pMse = pInfo->private; - pMse->device = pPointer; - - switch (what) { - case DEVICE_INIT: - pPointer->public.on = FALSE; - - dmask = D_ABS | D_REL | D_BUTTON; - if ((evi = ev_initf(xf86Info.consoleFd)) < 0) { - FatalError ("OsMouseProc: Event driver initialization failed (%s)\n", - evtErrStr(evi)); - } - pInfo->fd = ev_open (&dmask); - if (pInfo->fd < 0) { - FatalError ("OsMouseProc: DEVICE_INIT failed (%s)\n", evtErrStr(pInfo->fd)); - } - - pMse->buttons = xf86SetIntOption (pInfo->options, "Buttons", 0); - if (pMse->buttons == 0) { - pMse->buttons = 8; - from = X_DEFAULT; - } - xf86Msg (from, "%s: Buttons: %d\n", pInfo->name, pMse->buttons); - - for (evi = 0; evi <= 8; evi++) - map[evi] = evi; - - InitPointerDeviceStruct((DevicePtr)pPointer, map, 8, - miPointerGetMotionEvents, pMse->Ctrl, - miPointerGetMotionBufferSize()); - - /* X valuator */ - xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); - xf86InitValuatorDefaults(pPointer, 0); - - /* Y valuator */ - xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); - xf86InitValuatorDefaults(pPointer, 1); - - xf86MotionHistoryAllocate(pInfo); - - ev_flush(); - ev_suspend(); - break; - - case DEVICE_ON: - pMse->lastButtons = 0; - pMse->lastMappedButtons = 0; - pMse->emulateState = 0; - pPointer->public.on = TRUE; - ev_resume(); - AddEnabledDevice (pInfo->fd); - break; - - case DEVICE_OFF: - case DEVICE_CLOSE: - pPointer->public.on = FALSE; - RemoveEnabledDevice (pInfo->fd); - if (what == DEVICE_CLOSE) { - ev_close(); - pInfo->fd = -1; - } else { - ev_suspend(); - } - break; - } - - return Success; -} - -static void -OsMouseReadInput (InputInfoPtr pInfo) -{ - MouseDevPtr pMse; - EVENT *evp; - - pMse = pInfo->private; - - while ((evp = ev_read()) != (EVENT *)0) { - int buttons = EV_BUTTONS(*evp); - int dx = EV_DX(*evp), dy = -(EV_DY(*evp)), dz = 0; - - if (buttons & WHEEL_FWD) - dz = -1; - else if (buttons & WHEEL_BACK) - dz = 1; - - buttons &= ~(WHEEL_FWD | WHEEL_BACK); - - pMse->PostEvent (pInfo, buttons, dx, dy, dz, 0); - ev_pop(); - } -} - -static Bool -OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - MouseDevPtr pMse; - - /* This is called when the protocol is "OSMouse". */ - - pMse = pInfo->private; - pMse->protocol = protocol; - xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); - - /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); - xf86ProcessCommonOptions(pInfo, pInfo->options); - - /* Check if the device can be opened. */ - pInfo->fd = ev_initf(xf86Info.consoleFd); - if (pInfo->fd != -1) { - dmask_t dmask = (D_ABS | D_REL | D_BUTTON); - pInfo->fd = ev_open(&dmask); - } else { - pInfo->fd = -999; - } - - if (pInfo->fd < 0) { - if (xf86GetAllowMouseOpenFail()) - xf86Msg(X_WARNING, "%s: cannot open event manager (%s)\n", - pInfo->name, evtErrStr(pInfo->fd)); - else { - xf86Msg(X_ERROR, "%s: cannot open event manager (%s)\n", - pInfo->name, evtErrStr(pInfo->fd)); - xfree(pMse); - return FALSE; - } - } - ev_close(); - pInfo->fd = -1; - - /* Process common mouse options (like Emulate3Buttons, etc). */ - pMse->CommonOptions(pInfo); - - /* Setup the local procs. */ - pInfo->device_control = OsMouseProc; - pInfo->read_input = OsMouseReadInput; - - pInfo->flags |= XI86_CONFIGURED; - return TRUE; -} - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit (int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - - p->SupportedInterfaces = SupportedInterfaces; - p->BuiltinNames = BuiltinNames; - p->DefaultProtocol = DefaultProtocol; - p->CheckProtocol = CheckProtocol; - p->PreInit = OsMousePreInit; - - return p; -} diff --git a/hw/xfree86/os-support/sco/sco_video.c b/hw/xfree86/os-support/sco/sco_video.c deleted file mode 100644 index 7edf71db3..000000000 --- a/hw/xfree86/os-support/sco/sco_video.c +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright 2001 by J. Kean Johnston <jkj@sco.com> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON 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. - */ - -/* Re-written May 2001 to represent the current state of reality */ - -/* - * This file contains the completely re-written SCO OpenServer video - * routines for XFree86 4.x. Much of this is based on the SCO X server - * code (which is an X11R5 server) and will probably only work on - * OpenServer versions 5.0.5, 5.0.6 and later. Please send me (jkj@sco.com) - * email if you have any questions. - * - * Ideally, you should use OSR5.0.6A or later, with the updated console - * driver for 5.0.6A (its the default driver in 5.0.7 and later). - * However, if you are running on an older system, this code will detect - * that and adjust accordingly. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86OSpriv.h" -#include "xf86_OSlib.h" - -#include <sys/ci/ciioctl.h> -#define MPXNAME "/dev/atp1" -#define BASECPU 1 - -Bool mpxLock = TRUE; - -#define USE_VASMETHOD 1 - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static int sco_mcdone = 0, sco_ismc = 0; - -/***************************************************************************/ -/* - * To map the video memory, we first need to see if we are on a multi-console - * system. If we are, we need to try to use an existing video class in the - * kernel. We do this by retrieving the list of currently defined classes - * (via the new CONS_GETCLASS ioctl()) to see if we have a class that will - * match the range of memory we desire. If we can't find one, we have an - * error and we abort. - * - * If we are not using a multi-console, we can simply use mmap() to map in - * the frame buffer, using the classs-access method as a fall-back only if - * the mmap() fails (it shouldn't). We always set the appropriate pointers - * in the config structure to point ot the right function to map and unmap - * the video memory. An alternative to using mmap() is to use the new - * CONS_ADDVAS call, which will use vasmalloc() and vasbind() in the kernel - * to map the physical address to a virtual one, which it then returns. - * I am not 100% sure if this is faster or not, but it may prove easier to - * debug things. Just to be on the safe side, I have included both methods - * here, and the mmap() method can be used by setting USE_VASMETHOD to 0 - * above. - */ - -#if !defined(CONS_ADDVAS) -# undef USE_VASMETHOD -# define USE_VASMETHOD 0 -#endif - -static int -scoIsMultiConsole (void) -{ - int x; - - if (sco_mcdone) - return sco_ismc; - x = access ("/usr/lib/vidconf/.multiconsole", F_OK); - if (x == 0) - sco_ismc = 1; - sco_mcdone = 1; - return sco_ismc; -} - -/* - * This maps memory using mmap() - */ -static pointer -mapVidMemMMAP(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - int fd; - unsigned long realBase, alignOff; - pointer base; - - fd = open (DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM, - strerror(errno)); - return 0; /* NOTREACHED */ - } - - realBase = Base & ~(getpagesize() - 1); - alignOff = Base - realBase; - -#ifdef DEBUG - ErrorF("base: %lx, realBase: %lx, alignOff: %lx\n", Base,realBase,alignOff); -#endif - - base = mmap((caddr_t)0, Size + alignOff, - (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, (off_t)realBase); - close(fd); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer (0x%08x,0x%x) (%s)\n", - Base, Size, strerror(errno)); - return 0; /* NOTREACHED */ - } - -#ifdef DEBUG - ErrorF("base: %lx aligned base: %lx\n",base, base + alignOff); -#endif - return (pointer)((char *)base + alignOff); -} - -#if (USE_VASMETHOD) -/* - * This maps memory using the virtual address space (VAS) console calls. - */ -static pointer -mapVidMemVAS(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct vidvasmem vas; - pointer base; - - vas.base = (long)Base; - vas.size = (long)Size; - - base = (pointer)ioctl (xf86Info.consoleFd, CONS_ADDVAS, &vas); - if (base == (pointer)-1) { - return mapVidMemMMAP(ScreenNum, Base, Size, flags); - } - return base; -} -#endif /* USE_VASMETHOD */ - -struct vidclass vidclasslist[] = { - { "VBE", "", 0xf0000000, 0x2000000, 0 }, - { "P9000", "", 0xc0000000, 0x400000, 0 }, - { "TULIP", "", 0x80000000, 0x400000, 0 }, - { "VIPER", "", 0xa0000000, 0x400000, 0 }, - { "S3T", "", 0xa0000000, 0x200000, 0 }, - { "S3DT", "", 0x4000000, 0x400000, 0 }, - { "MGA", "", 0x2200000, 0x4000, 0 }, - { "CLVGA", "", 0xa0000, 0x20000, 0 }, - { "OLIVE", "", 0xd8000000, 0x400000, 0 }, - { "S3C", "", 0xa0000, 0x10000, 0 }, - { "MGAVLB", "", 0xac000, 0x34000, 0 }, - { "ATI8514", "", 0xFF000, 0x1000, 0 }, - { "GXREGS", "", 0xb0000, 0x10000, 0 }, - { "GX", "", 0xa0000, 0x10000, 0 }, - { "CT64300", "", 0xa0000000, 0x400000, 0 }, - { "SVGA", "", 0xa0000, 0x20000, 0 }, - { "S3V", "", 0xa0000000, 0x400000, 0 }, - { "8514A", "", 0xFF000, 0x1000, 0 }, - { "VGA", "", 0xa0000, 0x10000, 0 }, - { 0 } -}; - -static pointer -mapVidMemVC(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct vidclass *vcp; - char *class = NULL; - pointer base; - - for (vcp = vidclasslist; vcp->name; vcp++) { - if ((vcp->base == Base) && (vcp->size == Size)) { - class = vcp->name; - break; - } - } - - if (class == NULL) { - /* - * As a fall-back, we will try and use the mmap() approach. This may - * prove to be the wrong thing to do, but time and testing will tell. - */ - ErrorF("xf86MapVidMem: No class map defined for (0x%08x,0x%08x)\n", Base, Size); -#if USE_VASMETHOD - return mapVidMemVAS(ScreenNum, Base, Size, flags); -#else /* !USE_VASMETHOD */ - return mapVidMemMMAP(ScreenNum, Base, Size, flags); -#endif - } - - /* - * We found a suitable class. Try and use it. - */ - base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class); - if ((int)base == -1) { - FatalError("xf86MapVidMem: Failed to map video memory class `%s'\n", class); - return 0; /* NOTREACHED */ - } - - return base; -} - -/* - * Unmapping the video memory is easy. We always call munmap(), as it is - * safe to do so even if we haven't actually mapped in any pages via mmap(). - * In the case where we used the video class, we don't need to do anything - * as the kernel will clean up the TSS when we exit, and will undo the - * vasbind() that was done when the class was originally mapped. If we used - * vasmap, we simply undo the map. Again, it is benign to call vasunmap - * even if we got the frame buffer via some other mechanism (like mmap). - */ - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ -#if USE_VASMETHOD - struct vidvasmem vas; - int x; - - vas.base = (long)Base; - vas.size = (long)Size; - - x = ioctl (xf86Info.consoleFd, CONS_DELVAS, &vas); - if (x == 0) - return; -#endif /* USE_VASMETHOD */ - - munmap(Base, Size); -} - -/* - * Set things up to point to our local functions. When the kernel gets - * MTRR support, we will need to add the required functions for that - * here too. MTRR support will most likely appear in 5.0.8 or 5.1.0. - * - * We also want to lock the X server process to the base CPU in an MPX - * system, since we will be going to IOPL 3. Most engine drivers can cope - * with I/O access on any CPU but there are a few (AST Manhattan I believe) - * that can't, so the server needs to be locked to CPU0. - */ -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - int mpx_fd; - - if (scoIsMultiConsole ()) { - pVidMem->mapMem = mapVidMemVC; - } else { -#if USE_VASMETHOD - pVidMem->mapMem = mapVidMemVAS; -#else - pVidMem->mapMem = mapVidMemMMAP; -#endif - } - - pVidMem->unmapMem = unmapVidMem; - pVidMem->linearSupported = TRUE; - pVidMem->initialised = TRUE; - - if (mpxLock && (mpx_fd = open (MPXNAME, O_RDONLY)) > 0) { - if (ioctl (mpx_fd, ACPU_XLOCK, BASECPU) < 0) - ErrorF ("xf86OSInitVidMem: Can not bind to CPU 0 (%s)\n", - strerror(errno)); - close (mpx_fd); - } -} - diff --git a/hw/xfree86/os-support/shared/VTsw_noop.c b/hw/xfree86/os-support/shared/VTsw_noop.c deleted file mode 100644 index a3cfe40b9..000000000 --- a/hw/xfree86/os-support/shared/VTsw_noop.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.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); -} diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c deleted file mode 100644 index 4d473147f..000000000 --- a/hw/xfree86/os-support/shared/VTsw_usl.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifdef OSHEADER -# include OSHEADER -#endif - -/* - * Handle the VT-switching interface for OSs that use USL-style ioctl()s - * (the sysv, sco, and linux subdirs). - */ - -/* - * This function is the signal handler for the VT-switching signal. It - * is only referenced inside the OS-support layer. - */ -void -xf86VTRequest(int sig) -{ - signal(sig, (void(*)(int))xf86VTRequest); - xf86Info.vtRequestsPending = TRUE; - return; -} - -Bool -xf86VTSwitchPending() -{ - return(xf86Info.vtRequestsPending ? TRUE : FALSE); -} - -Bool -xf86VTSwitchAway() -{ - xf86Info.vtRequestsPending = FALSE; - if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) - { - return(FALSE); - } - else - { -#ifdef OSSWITCHAWAY - OSSWITCHAWAY; -#endif - return(TRUE); - } -} - -Bool -xf86VTSwitchTo() -{ - xf86Info.vtRequestsPending = FALSE; - if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) - { - return(FALSE); - } - else - { - return(TRUE); - } -} diff --git a/hw/xfree86/os-support/shared/agp_noop.c b/hw/xfree86/os-support/shared/agp_noop.c deleted file mode 100644 index 5774bc231..000000000 --- a/hw/xfree86/os-support/shared/agp_noop.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2000-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* - * Abstraction of the AGP GART interface. Stubs for platforms without - * AGP GART support. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -_X_EXPORT Bool -xf86GARTCloseScreen(int screenNum) -{ - return FALSE; -} - -_X_EXPORT Bool -xf86AgpGARTSupported() -{ - return FALSE; -} - -_X_EXPORT AgpInfoPtr -xf86GetAGPInfo(int screenNum) -{ - return NULL; -} - -_X_EXPORT Bool -xf86AcquireGART(int screenNum) -{ - return FALSE; -} - -_X_EXPORT Bool -xf86ReleaseGART(int screenNum) -{ - return FALSE; -} - -_X_EXPORT int -xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, - unsigned long *physical) -{ - return -1; -} - -_X_EXPORT Bool -xf86DeallocateGARTMemory(int screenNum, int key) -{ - return FALSE; -} - -_X_EXPORT Bool -xf86BindGARTMemory(int screenNum, int key, unsigned long offset) -{ - return FALSE; -} - - -_X_EXPORT Bool -xf86UnbindGARTMemory(int screenNum, int key) -{ - return FALSE; -} - -_X_EXPORT Bool -xf86EnableAGP(int screenNum, CARD32 mode) -{ - return FALSE; -} diff --git a/hw/xfree86/os-support/shared/bios_devmem.c b/hw/xfree86/os-support/shared/bios_devmem.c deleted file mode 100644 index 7288239be..000000000 --- a/hw/xfree86/os-support/shared/bios_devmem.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.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 - -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - -#ifdef __ia64__ - if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0) -#else - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) -#endif - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - - if (lseek(fd, (Base+Offset), SEEK_SET) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return(-1); - } - if (read(fd, Buf, Len) != Len) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return(-1); - } - close(fd); - return(Len); -} diff --git a/hw/xfree86/os-support/shared/bios_mmap.c b/hw/xfree86/os-support/shared/bios_mmap.c deleted file mode 100644 index 8bac87ebe..000000000 --- a/hw/xfree86/os-support/shared/bios_mmap.c +++ /dev/null @@ -1,162 +0,0 @@ -/* - * 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -/* - * Read BIOS via mmap()ing DEV_MEM - */ - -#ifndef __alpha__ -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - unsigned char *ptr; - int psize; - int mlen; - - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, fd, (off_t)Base); - if (ptr == MAP_FAILED) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n", - DEV_MEM, strerror(errno)); - close(fd); - return(-1); - } -#ifdef DEBUG - ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", - Base, ptr[0] | (ptr[1] << 8)); -#endif - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); - (void)close(fd); - return(Len); -} - -#else /* __alpha__ */ - - /* - * We trick "mmap" into mapping BUS memory for us via BUS_BASE, - * which is the KSEG address of the start of the DENSE memory - * area. - */ - - /* - * NOTE: there prolly ought to be more validity checks and all - * re: boundaries and sizes and such... - */ - -/* - * The Jensen lacks dense memory, thus we have to address the bus via - * the sparse addressing scheme. - * - * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 - */ - -#ifdef linux - -#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ -#define SPARSE (5) -#define isJensen (1) -#else -#define isJensen (!_bus_base()) -#define SPARSE (7) -#endif - -extern unsigned long _bus_base(void); -extern unsigned long _bus_base_sparse(void); -#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base()) -#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x) - -#else - -extern u_int64_t dense_base(void); -#define BUS_BASE dense_base() -#define JENSEN_SHIFT(x) ((long) x) - -#endif - -int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - caddr_t base; - int fd; - int psize; - int mlen; - - if ((fd = open(DEV_MEM, O_RDONLY)) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); - base = mmap((caddr_t)0, JENSEN_SHIFT(mlen), PROT_READ, - MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE)); - - if (base == MAP_FAILED) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n", - DEV_MEM, strerror(errno)); - return(-1); - } - - xf86SlowBCopyFromBus((unsigned char *)(base+JENSEN_SHIFT(Offset)), - Buf, Len); - - munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(mlen)); - close(fd); - return(Len); -} - -#endif /* __alpha__ */ diff --git a/hw/xfree86/os-support/shared/ia64Pci.c b/hw/xfree86/os-support/shared/ia64Pci.c deleted file mode 100644 index 6f6924b59..000000000 --- a/hw/xfree86/os-support/shared/ia64Pci.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2002-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -/* - * This file contains the glue needed to support various IA-64 chipsets. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <fcntl.h> -#include <unistd.h> -#include <signal.h> -#include <dirent.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <linux/pci.h> - -#include "compiler.h" -#include "Pci.h" - -/* - * We use special in/out routines here since Altix platforms require the - * use of the sysfs legacy_io interface. The legacy_io file maps to the I/O - * space of a given PCI domain; reads and writes are used to do port I/O. - * The file descriptor for the file is stored in the upper bits of the - * value passed in by the caller, and is created and populated by - * xf86MapLegacyIO. - * - * If the legacy_io interface doesn't exist, we fall back to the glibc in/out - * routines, which are prefixed by an underscore (e.g. _outb). - */ -static int ia64_port_to_fd(unsigned long port) -{ - return (port >> 24) & 0xffffffff; -} - -_X_EXPORT void outb(unsigned long port, unsigned char val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outb(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 1) != 1) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -_X_EXPORT void outw(unsigned long port, unsigned short val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outw(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 2) != 2) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -_X_EXPORT void outl(unsigned long port, unsigned int val) -{ - int fd = ia64_port_to_fd(port); - - if (!fd) { - _outl(val, port & 0xffff); - goto out; - } - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - goto out; - } - if (write(fd, &val, 4) != 4) { - ErrorF("I/O write failed\n"); - goto out; - } - out: - return; -} - -_X_EXPORT unsigned int inb(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned char val; - - if (!fd) - return _inb(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 1) != 1) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - -_X_EXPORT unsigned int inw(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned short val; - - if (!fd) - return _inw(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 2) != 2) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - -_X_EXPORT unsigned int inl(unsigned long port) -{ - int fd = ia64_port_to_fd(port); - unsigned int val; - - if (!fd) - return _inl(port & 0xffff); - - if (lseek(fd, port & 0xffff, SEEK_SET) == -1) { - ErrorF("I/O lseek failed\n"); - val = -1; - goto out; - } - if (read(fd, &val, 4) != 4) { - ErrorF("I/O read failed\n"); - val = -1; - goto out; - } - out: - return val; -} - diff --git a/hw/xfree86/os-support/shared/ia64Pci.h b/hw/xfree86/os-support/shared/ia64Pci.h deleted file mode 100644 index 978c9ff0e..000000000 --- a/hw/xfree86/os-support/shared/ia64Pci.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2004, Egbert Eich - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * EGBERT EICH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- - * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Egbert Eich shall not - * be used in advertising or otherwise to promote the sale, use or other deal- - *ings in this Software without prior written authorization from Egbert Eich. - * - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _IA64_PCI_H -# define _IA64_PCI_H - -#include "Pci.h" - -typedef enum { - NONE_CHIPSET, - I460GX_CHIPSET, - E8870_CHIPSET, - ZX1_CHIPSET, - ALTIX_CHIPSET -} IA64Chipset; - -# ifdef OS_PROBE_PCI_CHIPSET -extern IA64Chipset OS_PROBE_PCI_CHIPSET(scanpciWrapperOpt flags); -# endif -#endif diff --git a/hw/xfree86/os-support/shared/inout.S b/hw/xfree86/os-support/shared/inout.S deleted file mode 100644 index 80c47c419..000000000 --- a/hw/xfree86/os-support/shared/inout.S +++ /dev/null @@ -1,111 +0,0 @@ -/* $XConsortium: inout.s /main/6 1996/02/21 17:53:35 kaleb $ */ - - - - - -/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/inout.S,v 1.1 1999/07/10 07:24:52 dawes Exp $ */ - -#include "assyntax.h" - -/* - * Make i80386 io primitives available at C-level. - */ - - FILE("inout.s") - AS_BEGIN - SEG_TEXT - -/* - *----------------------------------------------------------------------- - * inb --- - * Input one byte. - * - * Results: - * Byte in al. - *----------------------------------------------------------------------- - */ - GLOBL GLNAME(inb) -GLNAME(inb): - MOV_L (REGOFF(4,ESP),EDX) - SUB_L (EAX,EAX) - IN_B - RET - -/* - *----------------------------------------------------------------------- - * outb --- - * Output one byte. - * - * Results: - * None. - *----------------------------------------------------------------------- - */ - GLOBL GLNAME(outb) -GLNAME(outb): - MOV_L (REGOFF(4,sp),EDX) - MOV_L (REGOFF(8,sp),EAX) - OUT_B - RET -/* - *----------------------------------------------------------------------- - * inw --- - * Input one 16-bit word. - * - * Results: - * Word in ax. - *----------------------------------------------------------------------- - */ - GLOBL GLNAME(inw) -GLNAME(inw): - MOV_L (REGOFF(4,ESP),EDX) - IN_W - RET - -/* - *----------------------------------------------------------------------- - * outw --- - * Output one 16-bit word. - * - * Results: - * None. - *----------------------------------------------------------------------- - */ - GLOBL GLNAME(outw) -GLNAME(outw): - MOV_L (REGOFF(4,ESP),EDX) - MOV_L (REGOFF(8,ESP),EAX) - OUT_W - RET - -/* - *----------------------------------------------------------------------- - * inl --- - * Input one 32-bit longword. - * - * Results: - * Word in eax. - *----------------------------------------------------------------------- - */ - GLOBL GLNAME(inl) -GLNAME(inl): - MOV_L (REGOFF(4,ESP),EDX) - IN_L - RET - -/* - *----------------------------------------------------------------------- - * outl --- - * Output one 32-bit longword. - * - * Results: - * None. - *----------------------------------------------------------------------- - */ - GLOBL GLNAME(outl) -GLNAME(outl): - MOV_L (REGOFF(4,ESP),EDX) - MOV_L (REGOFF(8,ESP),EAX) - OUT_L - RET - diff --git a/hw/xfree86/os-support/shared/ioperm_noop.c b/hw/xfree86/os-support/shared/ioperm_noop.c deleted file mode 100644 index 1d7851a5b..000000000 --- a/hw/xfree86/os-support/shared/ioperm_noop.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - * - */ - -/* - * Some platforms don't bother with I/O permissions, - * or the permissions are implicit with opening/enabling the console. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -_X_EXPORT Bool -xf86EnableIO() -{ - return TRUE; -} - -_X_EXPORT void -xf86DisableIO() -{ - return; -} - diff --git a/hw/xfree86/os-support/shared/kmod_noop.c b/hw/xfree86/os-support/shared/kmod_noop.c deleted file mode 100644 index 6525e8414..000000000 --- a/hw/xfree86/os-support/shared/kmod_noop.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2000 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86_OSproc.h" - -_X_EXPORT int xf86LoadKernelModule(const char *pathname) -{ - (void) pathname; - return 0; /* failure */ -} diff --git a/hw/xfree86/os-support/shared/pm_noop.c b/hw/xfree86/os-support/shared/pm_noop.c deleted file mode 100644 index bfac4b1c8..000000000 --- a/hw/xfree86/os-support/shared/pm_noop.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2000 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* Stubs for the OS-support layer power-management functions. */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" - -PMClose -xf86OSPMOpen(void) -{ - return NULL; -} - - diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c deleted file mode 100644 index 002e3a275..000000000 --- a/hw/xfree86/os-support/shared/posix_tty.c +++ /dev/null @@ -1,686 +0,0 @@ -/* - * Copyright 1993-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ -/* - * - * Copyright (c) 1997 Metro Link Incorporated - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of the Metro Link shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from Metro Link. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static int -GetBaud (int baudrate) -{ -#ifdef B300 - if (baudrate == 300) - return B300; -#endif -#ifdef B1200 - if (baudrate == 1200) - return B1200; -#endif -#ifdef B2400 - if (baudrate == 2400) - return B2400; -#endif -#ifdef B4800 - if (baudrate == 4800) - return B4800; -#endif -#ifdef B9600 - if (baudrate == 9600) - return B9600; -#endif -#ifdef B19200 - if (baudrate == 19200) - return B19200; -#endif -#ifdef B38400 - if (baudrate == 38400) - return B38400; -#endif -#ifdef B57600 - if (baudrate == 57600) - return B57600; -#endif -#ifdef B115200 - if (baudrate == 115200) - return B115200; -#endif -#ifdef B230400 - if (baudrate == 230400) - return B230400; -#endif -#ifdef B460800 - if (baudrate == 460800) - return B460800; -#endif - return (0); -} - -_X_EXPORT int -xf86OpenSerial (pointer options) -{ -#ifdef Lynx - struct sgttyb ms_sgtty; -#endif - struct termios t; - int fd, i; - char *dev; - - dev = xf86SetStrOption (options, "Device", NULL); - if (!dev) - { - xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n"); - return (-1); - } - - SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK)); - if (fd == -1) - { - xf86Msg (X_ERROR, - "xf86OpenSerial: Cannot open device %s\n\t%s.\n", - dev, strerror (errno)); - xfree(dev); - return (-1); - } - - if (!isatty (fd)) - { -#if 1 - /* Allow non-tty devices to be opened. */ - xfree(dev); - return (fd); -#else - xf86Msg (X_WARNING, - "xf86OpenSerial: Specified device %s is not a tty\n", - dev); - SYSCALL (close (fd)); - errno = EINVAL; - xfree(dev); - return (-1); -#endif - } - -#ifdef Lynx - /* LynxOS does not assert DTR without this */ - ioctl (fd, TIOCGETP, (char *) &ms_sgtty); - ioctl (fd, TIOCSDTR, (char *) &ms_sgtty); -#endif - - /* set up default port parameters */ - SYSCALL (tcgetattr (fd, &t)); - t.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR\ - |IGNCR|ICRNL|IXON); - t.c_oflag &= ~OPOST; - t.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); - t.c_cflag &= ~(CSIZE|PARENB); - t.c_cflag |= CS8|CLOCAL; - - cfsetispeed (&t, B9600); - cfsetospeed (&t, B9600); - t.c_cc[VMIN] = 1; - t.c_cc[VTIME] = 0; - - SYSCALL (tcsetattr (fd, TCSANOW, &t)); - - if (xf86SetSerial (fd, options) == -1) - { - SYSCALL (close (fd)); - xfree(dev); - return (-1); - } - - SYSCALL (i = fcntl (fd, F_GETFL, 0)); - if (i == -1) - { - SYSCALL (close (fd)); - xfree(dev); - return (-1); - } - i &= ~O_NONBLOCK; - SYSCALL (i = fcntl (fd, F_SETFL, i)); - if (i == -1) - { - SYSCALL (close (fd)); - xfree(dev); - return (-1); - } - xfree(dev); - return (fd); -} - -_X_EXPORT int -xf86SetSerial (int fd, pointer options) -{ - struct termios t; - int val; - const char *s; - int baud, r; - - if (fd < 0) - return -1; - - /* Don't try to set parameters for non-tty devices. */ - if (!isatty(fd)) - return 0; - - SYSCALL (tcgetattr (fd, &t)); - - if ((val = xf86SetIntOption (options, "BaudRate", 0))) - { - if ((baud = GetBaud (val))) - { - cfsetispeed (&t, baud); - cfsetospeed (&t, baud); - } - else - { - xf86Msg (X_ERROR, - "Invalid Option BaudRate value: %d\n", val); - return (-1); - } - } - - if ((val = xf86SetIntOption (options, "StopBits", 0))) - { - switch (val) - { - case 1: - t.c_cflag &= ~(CSTOPB); - break; - case 2: - t.c_cflag |= CSTOPB; - break; - default: - xf86Msg (X_ERROR, - "Invalid Option StopBits value: %d\n", val); - return (-1); - break; - } - } - - if ((val = xf86SetIntOption (options, "DataBits", 0))) - { - switch (val) - { - case 5: - t.c_cflag &= ~(CSIZE); - t.c_cflag |= CS5; - break; - case 6: - t.c_cflag &= ~(CSIZE); - t.c_cflag |= CS6; - break; - case 7: - t.c_cflag &= ~(CSIZE); - t.c_cflag |= CS7; - break; - case 8: - t.c_cflag &= ~(CSIZE); - t.c_cflag |= CS8; - break; - default: - xf86Msg (X_ERROR, - "Invalid Option DataBits value: %d\n", val); - return (-1); - break; - } - } - - if ((s = xf86SetStrOption (options, "Parity", NULL))) - { - if (xf86NameCmp (s, "Odd") == 0) - { - t.c_cflag |= PARENB | PARODD; - } - else if (xf86NameCmp (s, "Even") == 0) - { - t.c_cflag |= PARENB; - t.c_cflag &= ~(PARODD); - } - else if (xf86NameCmp (s, "None") == 0) - { - t.c_cflag &= ~(PARENB); - } - else - { - xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n", - s); - return (-1); - } - } - - if ((val = xf86SetIntOption (options, "Vmin", -1)) != -1) - { - t.c_cc[VMIN] = val; - } - if ((val = xf86SetIntOption (options, "Vtime", -1)) != -1) - { - t.c_cc[VTIME] = val; - } - - if ((s = xf86SetStrOption (options, "FlowControl", NULL))) - { - xf86MarkOptionUsedByName (options, "FlowControl"); - if (xf86NameCmp (s, "Xoff") == 0) - { - t.c_iflag |= IXOFF; - } - else if (xf86NameCmp (s, "Xon") == 0) - { - t.c_iflag |= IXON; - } - else if (xf86NameCmp (s, "XonXoff") == 0) - { - t.c_iflag |= IXON|IXOFF; - } - else if (xf86NameCmp (s, "None") == 0) - { - t.c_iflag &= ~(IXON | IXOFF); - } - else - { - xf86Msg (X_ERROR, - "Invalid Option FlowControl value: %s\n", s); - return (-1); - } - } - - if ((xf86SetBoolOption (options, "ClearDTR", FALSE))) - { -#ifdef CLEARDTR_SUPPORT -# if !defined(Lynx) || defined(TIOCMBIC) - val = TIOCM_DTR; - SYSCALL (ioctl(fd, TIOCMBIC, &val)); -# else - SYSCALL (ioctl(fd, TIOCCDTR, NULL)); -# endif -#else - xf86Msg (X_WARNING, - "Option ClearDTR not supported on this OS\n"); - return (-1); -#endif - xf86MarkOptionUsedByName (options, "ClearDTR"); - } - - if ((xf86SetBoolOption (options, "ClearRTS", FALSE))) - { -#ifdef CLEARRTS_SUPPORT - val = TIOCM_RTS; - SYSCALL (ioctl(fd, TIOCMBIC, &val)); -#else - xf86Msg (X_WARNING, - "Option ClearRTS not supported on this OS\n"); - return (-1); -#endif - xf86MarkOptionUsedByName (options, "ClearRTS"); - } - - SYSCALL (r = tcsetattr (fd, TCSANOW, &t)); - return (r); -} - -_X_EXPORT int -xf86SetSerialSpeed (int fd, int speed) -{ - struct termios t; - int baud, r; - - if (fd < 0) - return -1; - - /* Don't try to set parameters for non-tty devices. */ - if (!isatty(fd)) - return 0; - - SYSCALL (tcgetattr (fd, &t)); - - if ((baud = GetBaud (speed))) - { - cfsetispeed (&t, baud); - cfsetospeed (&t, baud); - } - else - { - xf86Msg (X_ERROR, - "Invalid Option BaudRate value: %d\n", speed); - return (-1); - } - - SYSCALL (r = tcsetattr (fd, TCSANOW, &t)); - return (r); -} - -_X_EXPORT int -xf86ReadSerial (int fd, void *buf, int count) -{ - int r; -#ifdef DEBUG - int i; -#endif - SYSCALL (r = read (fd, buf, count)); -#ifdef DEBUG - ErrorF("ReadingSerial: 0x%x", - (unsigned char)*(((unsigned char *)buf))); - for (i = 1; i < r; i++) - ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i)); - ErrorF("\n"); -#endif - return (r); -} - -_X_EXPORT int -xf86WriteSerial (int fd, const void *buf, int count) -{ - int r; -#ifdef DEBUG - int i; - - ErrorF("WritingSerial: 0x%x",(unsigned char)*(((unsigned char *)buf))); - for (i = 1; i < count; i++) - ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i)); - ErrorF("\n"); -#endif - SYSCALL (r = write (fd, buf, count)); - return (r); -} - -_X_EXPORT int -xf86CloseSerial (int fd) -{ - int r; - - SYSCALL (r = close (fd)); - return (r); -} - -_X_EXPORT int -xf86WaitForInput (int fd, int timeout) -{ - fd_set readfds; - struct timeval to; - int r; - - FD_ZERO(&readfds); - - if (fd >= 0) { - FD_SET(fd, &readfds); - } - - to.tv_sec = timeout / 1000000; - to.tv_usec = timeout % 1000000; - - if (fd >= 0) { - SYSCALL (r = select (FD_SETSIZE, &readfds, NULL, NULL, &to)); - } - else { - SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to)); - } - xf86ErrorFVerb (9,"select returned %d\n", r); - return (r); -} - -_X_EXPORT int -xf86SerialSendBreak (int fd, int duration) -{ - int r; - - SYSCALL (r = tcsendbreak (fd, duration)); - return (r); - -} - -_X_EXPORT int -xf86FlushInput(int fd) -{ - fd_set fds; - struct timeval timeout; - char c[4]; - -#ifdef DEBUG - ErrorF("FlushingSerial\n"); -#endif - if (tcflush(fd, TCIFLUSH) == 0) - return 0; - - timeout.tv_sec = 0; - timeout.tv_usec = 0; - FD_ZERO(&fds); - FD_SET(fd, &fds); - while (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) > 0) { - if (read(fd, &c, sizeof(c)) < 1) - return 0; - FD_ZERO(&fds); - FD_SET(fd, &fds); - } - return 0; -} - -static struct states { - int xf; - int os; -} modemStates[] = { -#ifdef TIOCM_LE - { XF86_M_LE, TIOCM_LE }, -#endif -#ifdef TIOCM_DTR - { XF86_M_DTR, TIOCM_DTR }, -#endif -#ifdef TIOCM_RTS - { XF86_M_RTS, TIOCM_RTS }, -#endif -#ifdef TIOCM_ST - { XF86_M_ST, TIOCM_ST }, -#endif -#ifdef TIOCM_SR - { XF86_M_SR, TIOCM_SR }, -#endif -#ifdef TIOCM_CTS - { XF86_M_CTS, TIOCM_CTS }, -#endif -#ifdef TIOCM_CAR - { XF86_M_CAR, TIOCM_CAR }, -#elif defined(TIOCM_CD) - { XF86_M_CAR, TIOCM_CD }, -#endif -#ifdef TIOCM_RNG - { XF86_M_RNG, TIOCM_RNG }, -#elif defined(TIOCM_RI) - { XF86_M_CAR, TIOCM_RI }, -#endif -#ifdef TIOCM_DSR - { XF86_M_DSR, TIOCM_DSR }, -#endif -}; - -static int numStates = sizeof(modemStates) / sizeof(modemStates[0]); - -static int -xf2osState(int state) -{ - int i; - int ret = 0; - - for (i = 0; i < numStates; i++) - if (state & modemStates[i].xf) - ret |= modemStates[i].os; - return ret; -} - -static int -os2xfState(int state) -{ - int i; - int ret = 0; - - for (i = 0; i < numStates; i++) - if (state & modemStates[i].os) - ret |= modemStates[i].xf; - return ret; -} - -static int -getOsStateMask(void) -{ - int i; - int ret = 0; - for (i = 0; i < numStates; i++) - ret |= modemStates[i].os; - return ret; -} - -static int osStateMask = 0; - -_X_EXPORT int -xf86SetSerialModemState(int fd, int state) -{ - int ret; - int s; - - if (fd < 0) - return -1; - - /* Don't try to set parameters for non-tty devices. */ - if (!isatty(fd)) - return 0; - -#ifndef TIOCMGET - return -1; -#else - if (!osStateMask) - osStateMask = getOsStateMask(); - - state = xf2osState(state); - SYSCALL((ret = ioctl(fd, TIOCMGET, &s))); - if (ret < 0) - return -1; - s &= ~osStateMask; - s |= state; - SYSCALL((ret = ioctl(fd, TIOCMSET, &s))); - if (ret < 0) - return -1; - else - return 0; -#endif -} - -_X_EXPORT int -xf86GetSerialModemState(int fd) -{ - int ret; - int s; - - if (fd < 0) - return -1; - - /* Don't try to set parameters for non-tty devices. */ - if (!isatty(fd)) - return 0; - -#ifndef TIOCMGET - return -1; -#else - SYSCALL((ret = ioctl(fd, TIOCMGET, &s))); - if (ret < 0) - return -1; - return os2xfState(s); -#endif -} - -_X_EXPORT int -xf86SerialModemSetBits(int fd, int bits) -{ - int ret; - int s; - - if (fd < 0) - return -1; - - /* Don't try to set parameters for non-tty devices. */ - if (!isatty(fd)) - return 0; - -#ifndef TIOCMGET - return -1; -#else - s = xf2osState(bits); - SYSCALL((ret = ioctl(fd, TIOCMBIS, &s))); - return ret; -#endif -} - -_X_EXPORT int -xf86SerialModemClearBits(int fd, int bits) -{ - int ret; - int s; - - if (fd < 0) - return -1; - - /* Don't try to set parameters for non-tty devices. */ - if (!isatty(fd)) - return 0; - -#ifndef TIOCMGET - return -1; -#else - s = xf2osState(bits); - SYSCALL((ret = ioctl(fd, TIOCMBIC, &s))); - return ret; -#endif -} diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c deleted file mode 100644 index c97f50302..000000000 --- a/hw/xfree86/os-support/shared/sigio.c +++ /dev/null @@ -1,279 +0,0 @@ - -/* sigio.c -- Support for SIGIO handler installation and removal - * Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com - * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: Rickard E. (Rik) Faith <faith@valinux.com> - */ -/* - * Copyright (c) 2002 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -# include <X11/X.h> -# include "xf86.h" -# include "xf86Priv.h" -# include "xf86_OSlib.h" -# include "inputstr.h" - -/* - * Linux libc5 defines FASYNC, but not O_ASYNC. Don't know if it is - * functional or not. - */ -#if defined(FASYNC) && !defined(O_ASYNC) -# define O_ASYNC FASYNC -#endif - -#ifdef MAX_DEVICES -/* MAX_DEVICES represents the maximimum number of input devices usable - * at the same time plus one entry for DRM support. - */ -# define MAX_FUNCS (MAX_DEVICES + 1) -#else -# define MAX_FUNCS 16 -#endif - -typedef struct _xf86SigIOFunc { - void (*f) (int, void *); - int fd; - void *closure; -} Xf86SigIOFunc; - -static Xf86SigIOFunc xf86SigIOFuncs[MAX_FUNCS]; -static int xf86SigIOMax; -static int xf86SigIOMaxFd; -static fd_set xf86SigIOMask; - -/* - * SIGIO gives no way of discovering which fd signalled, select - * to discover - */ -static void -xf86SIGIO (int sig) -{ - int i; - fd_set ready; - struct timeval to; - int r; - - ready = xf86SigIOMask; - to.tv_sec = 0; - to.tv_usec = 0; - SYSCALL (r = select (xf86SigIOMaxFd, &ready, 0, 0, &to)); - for (i = 0; r > 0 && i < xf86SigIOMax; i++) - if (xf86SigIOFuncs[i].f && FD_ISSET (xf86SigIOFuncs[i].fd, &ready)) - { - (*xf86SigIOFuncs[i].f)(xf86SigIOFuncs[i].fd, - xf86SigIOFuncs[i].closure); - r--; - } - if (r > 0) { - xf86Msg(X_ERROR, "SIGIO %d descriptors not handled\n", r); - } -} - -static int -xf86IsPipe (int fd) -{ - struct stat buf; - - if (fstat (fd, &buf) < 0) - return 0; - return S_ISFIFO(buf.st_mode); -} - -_X_EXPORT int -xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure) -{ - struct sigaction sa; - struct sigaction osa; - int i; - int blocked; - - for (i = 0; i < MAX_FUNCS; i++) - { - if (!xf86SigIOFuncs[i].f) - { - if (xf86IsPipe (fd)) - return 0; - blocked = xf86BlockSIGIO(); - if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_ASYNC) == -1) { - xf86Msg(X_WARNING, "fcntl(%d, O_ASYNC): %s\n", - fd, strerror(errno)); - xf86UnblockSIGIO(blocked); - return 0; - } - if (fcntl(fd, F_SETOWN, getpid()) == -1) { - xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n", - fd, strerror(errno)); - xf86UnblockSIGIO(blocked); - return 0; - } - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGIO); - sa.sa_flags = 0; - sa.sa_handler = xf86SIGIO; - sigaction(SIGIO, &sa, &osa); - xf86SigIOFuncs[i].fd = fd; - xf86SigIOFuncs[i].closure = closure; - xf86SigIOFuncs[i].f = f; - if (i >= xf86SigIOMax) - xf86SigIOMax = i+1; - if (fd >= xf86SigIOMaxFd) - xf86SigIOMaxFd = fd + 1; - FD_SET (fd, &xf86SigIOMask); - xf86UnblockSIGIO(blocked); - return 1; - } - /* Allow overwriting of the closure and callback */ - else if (xf86SigIOFuncs[i].fd == fd) - { - xf86SigIOFuncs[i].closure = closure; - xf86SigIOFuncs[i].f = f; - return 1; - } - } - return 0; -} - -_X_EXPORT int -xf86RemoveSIGIOHandler(int fd) -{ - struct sigaction sa; - struct sigaction osa; - int i; - int max; - int maxfd; - int ret; - - max = 0; - maxfd = -1; - ret = 0; - for (i = 0; i < MAX_FUNCS; i++) - { - if (xf86SigIOFuncs[i].f) - { - if (xf86SigIOFuncs[i].fd == fd) - { - xf86SigIOFuncs[i].f = 0; - xf86SigIOFuncs[i].fd = 0; - xf86SigIOFuncs[i].closure = 0; - FD_CLR (fd, &xf86SigIOMask); - ret = 1; - } - else - { - max = i + 1; - if (xf86SigIOFuncs[i].fd >= maxfd) - maxfd = xf86SigIOFuncs[i].fd + 1; - } - } - } - if (ret) - { - fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_ASYNC); - xf86SigIOMax = max; - xf86SigIOMaxFd = maxfd; - if (!max) - { - sigemptyset(&sa.sa_mask); - sigaddset(&sa.sa_mask, SIGIO); - sa.sa_flags = 0; - sa.sa_handler = SIG_DFL; - sigaction(SIGIO, &sa, &osa); - } - } - return ret; -} - -_X_EXPORT int -xf86BlockSIGIO (void) -{ - sigset_t set, old; - int ret; - - sigemptyset (&set); - sigaddset (&set, SIGIO); - sigprocmask (SIG_BLOCK, &set, &old); - ret = sigismember (&old, SIGIO); - return ret; -} - -_X_EXPORT void -xf86UnblockSIGIO (int wasset) -{ - sigset_t set; - - if (!wasset) - { - sigemptyset (&set); - sigaddset (&set, SIGIO); - sigprocmask (SIG_UNBLOCK, &set, NULL); - } -} - -void -xf86AssertBlockedSIGIO (char *where) -{ - sigset_t set, old; - - sigemptyset (&set); - sigprocmask (SIG_BLOCK, &set, &old); - if (!sigismember (&old, SIGIO)) - xf86Msg (X_ERROR, "SIGIO not blocked at %s\n", where); -} - -/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */ - -int -xf86SIGIOSupported (void) -{ - return 1; -} diff --git a/hw/xfree86/os-support/shared/sigiostubs.c b/hw/xfree86/os-support/shared/sigiostubs.c deleted file mode 100644 index 7113968c6..000000000 --- a/hw/xfree86/os-support/shared/sigiostubs.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -# include <X11/X.h> -# include "xf86.h" -# include "xf86Priv.h" -# include "xf86_OSlib.h" - -_X_EXPORT int -xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure) -{ - return 0; -} - -_X_EXPORT int -xf86RemoveSIGIOHandler(int fd) -{ - return 0; -} - -_X_EXPORT int -xf86BlockSIGIO (void) -{ - return 0; -} - -_X_EXPORT void -xf86UnblockSIGIO (int wasset) -{ -} - -void -xf86AssertBlockedSIGIO (char *where) -{ -} - -/* XXX This is a quick hack for the benefit of xf86SetSilkenMouse() */ -Bool -xf86SIGIOSupported () -{ - return FALSE; -} - diff --git a/hw/xfree86/os-support/shared/stdResource.c b/hw/xfree86/os-support/shared/stdResource.c deleted file mode 100644 index c144211f0..000000000 --- a/hw/xfree86/os-support/shared/stdResource.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* Standard resource information code */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86Privstr.h" -#include "xf86Pci.h" -#define NEED_OS_RAC_PROTOS -#include "xf86_OSlib.h" -#include "xf86Resources.h" - -/* Avoid Imakefile changes */ -#include "bus/Pci.h" - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ - defined(__DragonFly__) || defined(__sun) -#define xf86StdAccResFromOS xf86AccResFromOS -#endif - -resPtr -xf86StdAccResFromOS(resPtr ret) -{ - resRange range; - - /* - * Fallback is to claim the following areas: - * - * 0x00000000 - 0x0009ffff low 640k host memory - * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS - * 0x000f0000 - 0x000fffff system BIOS - * 0x00100000 - 0x3fffffff low 1G - 1MB host memory - * 0xfec00000 - 0xfecfffff default I/O APIC config space - * 0xfee00000 - 0xfeefffff default Local APIC config space - * 0xffe00000 - 0xffffffff high BIOS area (should this be included?) - * - * reference: Intel 440BX AGP specs - * - * The two APIC spaces appear to be BX-specific and should be dealt with - * elsewhere. - */ - - /* Fallback is to claim 0x0 - 0x9ffff and 0x100000 - 0x7fffffff */ - RANGE(range, 0x00000000, 0x0009ffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x000f0000, 0x000fffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x00100000, 0x3fffffff, - ResExcMemBlock | ResBios | ResEstimated); - ret = xf86AddResToList(ret, &range, -1); -#if 0 - RANGE(range, 0xfec00000, 0xfecfffff, ResExcMemBlock | ResBios); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0xfee00000, 0xfeefffff, ResExcMemBlock | ResBios); - ret = xf86AddResToList(ret, &range, -1); - /* airlied - remove BIOS range it shouldn't be here - this should use E820 - or THE OS */ - RANGE(range, 0xffe00000, 0xffffffff, ResExcMemBlock | ResBios); - ret = xf86AddResToList(ret, &range, -1); -#endif - /* - * Fallback would be to claim well known ports in the 0x0 - 0x3ff range - * along with their sparse I/O aliases, but that's too imprecise. Instead - * claim a bare minimum here. - */ - RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ - ret = xf86AddResToList(ret, &range, -1); - - /* - * At minimum, the top and bottom resources must be claimed, so that - * resources that are (or appear to be) unallocated can be relocated. - */ -/* RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); - ret = xf86AddResToList(ret, &range, -1); - RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); */ - RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); - ret = xf86AddResToList(ret, &range, -1); - - /* XXX add others */ - return ret; -} diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c deleted file mode 100644 index 0b4411604..000000000 --- a/hw/xfree86/os-support/shared/vidmem.c +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (c) 1993-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -/* - * This file contains the common part of the video memory mapping functions - */ - -/* - * Get a piece of the ScrnInfoRec. At the moment, this is only used to hold - * the MTRR option information, but it is likely to be expanded if we do - * auto unmapping of memory at VT switch. - * - */ - -typedef struct { - unsigned long physBase; - unsigned long size; - pointer virtBase; - pointer mtrrInfo; - int flags; -} MappingRec, *MappingPtr; - -typedef struct { - int numMappings; - MappingPtr * mappings; - Bool mtrrEnabled; - MessageType mtrrFrom; - Bool mtrrOptChecked; - ScrnInfoPtr pScrn; -} VidMapRec, *VidMapPtr; - -static int vidMapIndex = -1; - -#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr)) - -static VidMemInfo vidMemInfo = {FALSE, }; -static VidMapRec vidMapRec = {0, NULL, TRUE, X_DEFAULT, FALSE, NULL}; - -static VidMapPtr -getVidMapRec(int scrnIndex) -{ - VidMapPtr vp; - ScrnInfoPtr pScrn; - - if ((scrnIndex < 0) || - !(pScrn = xf86Screens[scrnIndex])) - return &vidMapRec; - - if (vidMapIndex < 0) - vidMapIndex = xf86AllocateScrnInfoPrivateIndex(); - - if (VIDMAPPTR(pScrn) != NULL) - return VIDMAPPTR(pScrn); - - vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1); - vp->mtrrEnabled = TRUE; /* default to enabled */ - vp->mtrrFrom = X_DEFAULT; - vp->mtrrOptChecked = FALSE; - vp->pScrn = pScrn; - return vp; -} - -static MappingPtr -newMapping(VidMapPtr vp) -{ - vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) * - (vp->numMappings + 1)); - vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1); - return vp->mappings[vp->numMappings++]; -} - -static MappingPtr -findMapping(VidMapPtr vp, pointer vbase, unsigned long size) -{ - int i; - - for (i = 0; i < vp->numMappings; i++) { - if (vp->mappings[i]->virtBase == vbase && - vp->mappings[i]->size == size) - return vp->mappings[i]; - } - return NULL; -} - -static void -removeMapping(VidMapPtr vp, MappingPtr mp) -{ - int i, found = 0; - - for (i = 0; i < vp->numMappings; i++) { - if (vp->mappings[i] == mp) { - found = 1; - xfree(vp->mappings[i]); - } else if (found) { - vp->mappings[i - 1] = vp->mappings[i]; - } - } - vp->numMappings--; - vp->mappings[vp->numMappings] = NULL; -} - -enum { OPTION_MTRR }; -static const OptionInfoRec opts[] = -{ - { OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE }, - { -1, NULL, OPTV_NONE, {0}, FALSE } -}; - -static void -checkMtrrOption(VidMapPtr vp) -{ - if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) { - OptionInfoPtr options; - - options = xnfalloc(sizeof(opts)); - (void)memcpy(options, opts, sizeof(opts)); - xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, - options); - if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled)) - vp->mtrrFrom = X_CONFIG; - xfree(options); - vp->mtrrOptChecked = TRUE; - } -} - -void -xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase) -{ - VidMapPtr vp; - MappingPtr mp; - - vp = getVidMapRec(ScreenNum); - mp = newMapping(vp); - mp->physBase = Base; - mp->size = Size; - mp->virtBase = Vbase; - mp->flags = Flags; -} - -void -xf86InitVidMem(void) -{ - if (!vidMemInfo.initialised) { - memset(&vidMemInfo, 0, sizeof(VidMemInfo)); - xf86OSInitVidMem(&vidMemInfo); - } -} - -_X_EXPORT pointer -xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) -{ - pointer vbase = NULL; - VidMapPtr vp; - MappingPtr mp; - - if (((Flags & VIDMEM_FRAMEBUFFER) && - (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)))) - FatalError("Mapping memory with more than one type\n"); - - xf86InitVidMem(); - if (!vidMemInfo.initialised || !vidMemInfo.mapMem) - return NULL; - - vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags); - - if (!vbase || vbase == (pointer)-1) - return NULL; - - vp = getVidMapRec(ScreenNum); - mp = newMapping(vp); - mp->physBase = Base; - mp->size = Size; - mp->virtBase = vbase; - mp->flags = Flags; - - /* - * Check the "mtrr" option even when MTRR isn't supported to avoid - * warnings about unrecognised options. - */ - checkMtrrOption(vp); - - if (vp->mtrrEnabled && vidMemInfo.setWC) { - if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT)) - mp->mtrrInfo = - vidMemInfo.setWC(ScreenNum, Base, Size, FALSE, - vp->mtrrFrom); - else if (Flags & VIDMEM_FRAMEBUFFER) - mp->mtrrInfo = - vidMemInfo.setWC(ScreenNum, Base, Size, TRUE, - vp->mtrrFrom); - } - return vbase; -} - -_X_EXPORT void -xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - VidMapPtr vp; - MappingPtr mp; - - if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) { - xf86DrvMsg(ScreenNum, X_WARNING, - "xf86UnMapVidMem() called before xf86MapVidMem()\n"); - return; - } - - vp = getVidMapRec(ScreenNum); - mp = findMapping(vp, Base, Size); - if (!mp) { - xf86DrvMsg(ScreenNum, X_WARNING, - "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n", - Base, Size); - return; - } - if (vp->mtrrEnabled && vidMemInfo.undoWC && mp) - vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo); - - vidMemInfo.unmapMem(ScreenNum, Base, Size); - removeMapping(vp, mp); -} - -_X_EXPORT Bool -xf86CheckMTRR(int ScreenNum) -{ - VidMapPtr vp = getVidMapRec(ScreenNum); - - /* - * Check the "mtrr" option even when MTRR isn't supported to avoid - * warnings about unrecognised options. - */ - checkMtrrOption(vp); - - if (vp->mtrrEnabled && vidMemInfo.setWC) - return TRUE; - - return FALSE; -} - -_X_EXPORT Bool -xf86LinearVidMem() -{ - xf86InitVidMem(); - return vidMemInfo.linearSupported; -} - -_X_EXPORT void -xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base, - unsigned long Size) -{ - if (!(Flags & VIDMEM_READSIDEEFFECT)) - return; - - if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects) - return; - - vidMemInfo.readSideEffects(ScreenNum, base, Size); -} - diff --git a/hw/xfree86/os-support/shared/xf86Axp.c b/hw/xfree86/os-support/shared/xf86Axp.c deleted file mode 100644 index e6511dd43..000000000 --- a/hw/xfree86/os-support/shared/xf86Axp.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2000 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86Axp.h" - -axpParams xf86AXPParams[] = { - {SYS_NONE, 0, 0, 0}, - {TSUNAMI, 0, 0, 0}, - {LCA, 1<<24,0xf8000000, 1UL << 32}, - {APECS, 1<<24,0xf8000000, 1UL << 32}, - {T2, 0,0xFC000000, 1UL << 31}, - {T2_GAMMA, 0,0xFC000000, 1UL << 31}, - {CIA, 0,0xE0000000, 1UL << 34}, - {MCPCIA, 0,0xf8000000, 1UL << 31}, - {JENSEN, 0, 0xE000000, 1UL << 32}, - {POLARIS, 0, 0, 0}, - {PYXIS, 0, 0, 0}, - {PYXIS_CIA, 0,0xE0000000, 1UL << 34}, - {IRONGATE, 0, 0, 0} -}; - diff --git a/hw/xfree86/os-support/shared/xf86Axp.h b/hw/xfree86/os-support/shared/xf86Axp.h deleted file mode 100644 index 5e9d6284c..000000000 --- a/hw/xfree86/os-support/shared/xf86Axp.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _XF86_AXP_H_ -#define _XF86_AXP_H_ - -typedef enum { - SYS_NONE, - TSUNAMI, - LCA, - APECS, - T2, - T2_GAMMA, - CIA, - MCPCIA, - JENSEN, - POLARIS, - PYXIS, - PYXIS_CIA, - IRONGATE -} axpDevice; - -typedef struct { - axpDevice id; - unsigned long hae_thresh; - unsigned long hae_mask; - unsigned long size; -} axpParams; - -extern axpParams xf86AXPParams[]; - -#endif - diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am deleted file mode 100644 index 68f6b4cd0..000000000 --- a/hw/xfree86/os-support/solaris/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -if SOLARIS_USL_CONSOLE -VTSW_SRC = $(srcdir)/../shared/VTsw_usl.c -else -VTSW_SRC = $(srcdir)/../shared/VTsw_noop.c -endif - -# TODO: Don't build agpgart on SPARC -#if defined(i386Architecture) || defined(AMD64Architecture) -AGP_SRC = sun_agp.c -#else -#AGP_SRC = $(srcdir)/../shared/agp_noop.c -#endif - -SOLARIS_INOUT_SRC = solaris-@SOLARIS_INOUT_ARCH@.S -DISTCLEANFILES = solaris-@SOLARIS_INOUT_ARCH@.il - -solaris-@SOLARIS_INOUT_ARCH@.il: solaris-@SOLARIS_INOUT_ARCH@.S - $(CPP) -P -DINLINE_ASM solaris-@SOLARIS_INOUT_ARCH@.S > $@ - -noinst_LTLIBRARIES = libsolaris.la -libsolaris_la_SOURCES = sun_bios.c sun_init.c \ - sun_mouse.c sun_vid.c sun_bell.c $(AGP_SRC) sun_apm.c \ - $(srcdir)/../shared/kmod_noop.c \ - $(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/sigiostubs.c \ - $(srcdir)/../shared/stdResource.c \ - $(VTSW_SRC) -nodist_libsolaris_la_SOURCES = $(SOLARIS_INOUT_SRC) - -sdk_HEADERS = agpgart.h -nodist_sdk_HEADERS = solaris-@SOLARIS_INOUT_ARCH@.il - -AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS) - -INCLUDES = $(XORG_INCS) - -EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S \ - apSolaris.shar sun_inout.s diff --git a/hw/xfree86/os-support/solaris/agpgart.h b/hw/xfree86/os-support/solaris/agpgart.h deleted file mode 100644 index 566de8046..000000000 --- a/hw/xfree86/os-support/solaris/agpgart.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * AGPGART module version 0.99 - * Copyright (C) 1999 Jeff Hartmann - * Copyright (C) 1999 Precision Insight, Inc. - * Copyright (C) 1999 Xi Graphics, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -#ifndef _AGPGART_H -#define _AGPGART_H - -#pragma ident "@(#)agpgart.h 1.1 05/04/04 SMI" - -typedef struct _agp_version { - uint16_t agpv_major; - uint16_t agpv_minor; -} agp_version_t; - -typedef struct _agp_info { - agp_version_t agpi_version; - uint32_t agpi_devid; /* bridge vendor + device */ - uint32_t agpi_mode; /* mode of bridge */ - ulong_t agpi_aperbase; /* base of aperture */ - size_t agpi_apersize; /* aperture range size */ - uint32_t agpi_pgtotal; /* max number of pages in aperture */ - uint32_t agpi_pgsystem; /* same as pg_total */ - uint32_t agpi_pgused; /* NUMBER of currently used pages */ -} agp_info_t; - -typedef struct _agp_setup { - uint32_t agps_mode; -} agp_setup_t; - -typedef struct _agp_allocate { - int32_t agpa_key; - uint32_t agpa_pgcount; - uint32_t agpa_type; - uint32_t agpa_physical; /* for i810/830 driver */ -} agp_allocate_t; - -typedef struct _agp_bind { - int32_t agpb_key; - uint32_t agpb_pgstart; -} agp_bind_t; - -typedef struct _agp_unbind { - int32_t agpu_key; - uint32_t agpu_pri; /* no use in solaris */ -} agp_unbind_t; - -#define AGPIOC_BASE 'G' -#define AGPIOC_INFO _IOR(AGPIOC_BASE, 0, 100) -#define AGPIOC_ACQUIRE _IO(AGPIOC_BASE, 1) -#define AGPIOC_RELEASE _IO(AGPIOC_BASE, 2) -#define AGPIOC_SETUP _IOW(AGPIOC_BASE, 3, agp_setup_t) -#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 4, agp_allocate_t) -#define AGPIOC_DEALLOCATE _IOW(AGPIOC_BASE, 5, int) -#define AGPIOC_BIND _IOW(AGPIOC_BASE, 6, agp_bind_t) -#define AGPIOC_UNBIND _IOW(AGPIOC_BASE, 7, agp_unbind_t) - -#define AGP_DEVICE "/dev/agpgart" - -#endif /* _AGPGART_H */ diff --git a/hw/xfree86/os-support/solaris/apSolaris.shar b/hw/xfree86/os-support/solaris/apSolaris.shar deleted file mode 100644 index a3548f7b4..000000000 --- a/hw/xfree86/os-support/solaris/apSolaris.shar +++ /dev/null @@ -1,806 +0,0 @@ -#!/bin/sh -# -# This is a shell archive. Save it in a file, remove anything before -# this line, and then unpack it by entering "sh file". Note, it may -# create directories; files and directories will be owned by you and -# have default permissions. -# Made on Sun Jun 25 20:24:59 CEST 2006 by Martin Bochnig at martux.org -# -# This archive contains: -# -# ./aperture -# -# ./aperture/Makefile -# ./aperture/Makefile.amd64 -# ./aperture/Makefile.sparcv9 -# ./aperture/README -# ./aperture/aperture.c -# ./aperture/aperture.conf -# ./aperture/devlink.tab -# -echo c - ./aperture -mkdir -p ./aperture > /dev/null 2>&1 -# -echo x - ./aperture/Makefile -sed 's/^X//' >./aperture/Makefile << 'END-of-./aperture/Makefile' -X# -X# File: makefile for aperture Framebuffer Driver -X# Author: Doug Anson (danson@lgc.com) -X# Date: 2/15/94 -X# Modified: David Holland (davidh@use.com) -X# Date: 2/23/94 -X# - Changed name, and debugging structure -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Date: 2001.06.08 -X# - SPARC support, cleanup and turf aptest. -X# -X# >>NOTE<< Have a look at Makefile.sparcv9 for specifics. -X# -X# Modified: Martin Bochnig (martin@martux.org) -X# Date: 2006.06.24 -X# - Slightly modified to also build on Solaris 10 and 11. -X# - amd64 64 bit kernel support -X# - cosmetical changes to also support sun4v, not only sun4u -X# -X# >>NOTE<< Have a look at Makefile.amd64 for amd64 specifics. -X# -X# GNU gcc compiler -XCC=gcc -XCFLGS=-fno-builtin -Wall -O3 -X -X# -X# SUNWspro compiler -X#CC=/opt/SUNWspro/bin/cc -X#CFLGS=-Xa -xnolib -xO3 -X -X# -X# Debug error reporting -X#DEBUG_FLG= -X#DEBUG_FLG=-DAPERTURE_DEBUG -X -X# -X# Files and object declarations -XKERNEL_FLGS=-D_KERNEL -DSUNDDI -XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) -XCFILES= aperture.c -XOBJS= aperture.o -XDRIVER= aperture -X -X# -X# Make rules -Xall: $(DRIVER) -X -X$(DRIVER): $(OBJS) -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` $(DRIVER); \ -X else \ -X rm -f $(DRIVER); \ -X ld -r -o $(DRIVER) $(OBJS); \ -X fi -X -Xinstall: $(DRIVER) -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` install; \ -X else \ -X cp aperture.conf /kernel/drv; \ -X cp $(DRIVER) /kernel/drv; \ -X fi -X -Xadd_drv: -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` add_drv; \ -X else \ -X add_drv aperture; \ -X fi -X -Xclean: -X rm -f *% *.BAK $(OBJS) $(DRIVER) core -X -X.SUFFIXES: .i -X -X.c.i: -X $(CC) -E $(CFLAGS) $*.c > $@ -X -X.c.o: -X @if [ -f "Makefile.`isainfo -k`" ]; then \ -X make -f Makefile.`isainfo -k` $@; \ -X else \ -X rm -f $@; \ -X $(CC) -c $(CFLAGS) $*.c -o $@; \ -X fi -END-of-./aperture/Makefile -echo x - ./aperture/Makefile.amd64 -sed 's/^X//' >./aperture/Makefile.amd64 << 'END-of-./aperture/Makefile.amd64' -X# -X# File: Makefile for aperture Framebuffer Driver -X# Author: Doug Anson (danson@lgc.com) -X# Date: 2/15/94 -X# Modified: David Holland (davidh@use.com) -X# Date: 2/23/94 -X# - Changed name, and debugging structure -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Date: 2001.06.08 -X# - SPARC support, cleanup and turf aptest. -X# Modified: Martin Bochnig (martin@martux.org) -X# - amd64 64 bit kernel support, cosmetics and also -X# supporting sun4v (and arbitrary sparcv9) platforms -X# as well as SunOS 5.10 or higher now -X# - Changed name -X# -X -X# -X# GNU gcc compiler, version 3.2 or later -X# -XCC=gcc -XCFLGS=-fno-builtin -Wall -O3 -m64 -mcmodel=kernel -X -X# -X# SUNWspro compiler (untested, might not properly work for amd64 here) -X#CC=/opt/SUNWspro/bin/cc -X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 -X -X# -X# Debug error reporting -X#DEBUG_FLG= -X#DEBUG_FLG=-DAPERTURE_DEBUG -X -X# -X# Files and object declarations -XKERNEL_FLGS=-D_KERNEL -DSUNDDI -XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) -XCFILES= aperture.c -XOBJS= aperture.o -XDRIVER= aperture -X -X# -X# Make rules -Xall: $(DRIVER) -X -X$(DRIVER): $(OBJS) -X rm -f $(DRIVER) -X ld -r -o $(DRIVER) $(OBJS) -X -Xinstall: $(DRIVER) -X cp aperture.conf /kernel/drv -X cp $(DRIVER) /kernel/drv/amd64 -X -Xadd_drv: -X add_drv aperture -X -Xclean: -X rm -f *% *.BAK $(OBJS) $(DRIVER) core -X -X.SUFFIXES: .i -X -X.c.i: -X $(CC) -E $(CFLAGS) $*.c > $@ -END-of-./aperture/Makefile.amd64 -echo x - ./aperture/Makefile.sparcv9 -sed 's/^X//' >./aperture/Makefile.sparcv9 << 'END-of-./aperture/Makefile.sparcv9' -X# -X# File: makefile for aperture Framebuffer Driver -X# Author: Doug Anson (danson@lgc.com) -X# Date: 2/15/94 -X# Modified: David Holland (davidh@use.com) -X# Date: 2/23/94 -X# - Changed name, and debugging structure -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Date: 2001.06.08 -X# - SPARC support, cleanup and turf aptest. -X# Modified: Martin Bochnig (martin@martux.org) -X# Date: 2006.06.24 -X# - Changed name for generic sparcv9 support -X# - updated to better work with Solaris 10 and 11 -X# -X -X# -X# GNU gcc compiler, version 3.2 or later -X# -XCC=gcc -XCFLGS=-fno-builtin -Wall -O3 -m64 -X -X# -X# SUNWspro compiler -X#CC=/opt/SUNWspro/bin/cc -X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 -X -X# -X# Debug error reporting -X#DEBUG_FLG= -X#DEBUG_FLG=-DAPERTURE_DEBUG -X -X# -X# Files and object declarations -XKERNEL_FLGS=-D_KERNEL -DSUNDDI -XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) -XCFILES= aperture.c -XOBJS= aperture.o -XDRIVER= aperture -X -X# -X# Make rules -Xall: $(DRIVER) -X -X$(DRIVER): $(OBJS) -X rm -f $(DRIVER) -X ld -r -o $(DRIVER) $(OBJS) -X -Xinstall: $(DRIVER) -X cp aperture.conf /kernel/drv -X cp $(DRIVER) /kernel/drv/sparcv9 -X -Xadd_drv: -X add_drv aperture -X -Xclean: -X rm -f *% *.BAK $(OBJS) $(DRIVER) core -X -X.SUFFIXES: .i -X -X.c.i: -X $(CC) -E $(CFLAGS) $*.c > $@ -END-of-./aperture/Makefile.sparcv9 -echo x - ./aperture/README -sed 's/^X//' >./aperture/README << 'END-of-./aperture/README' -XFramebuffer aperture driver. -X -XThis driver was written to provide a device that, unlike /dev/mem, allows -Xmmap()'ing of ranges beyond installed memory. -X -XThe original x86-based version of this driver was the collaborative work of -XDoug Anson (danson@lgc.com), and David Holland (davidh@use.com). It has since -Xbeen rewritten to also work on sparc machines and - later on - also on sparcv9 -Xand recently amd64 64 bit kernels. -XIt flawlessly compiles and installs on Solaris 10 and 11 now. -X -X -XInstallation instructions: -X -X1) Check the Makefile, for appropriate CC, and CFLAGS definitions. Compiling -X with APERTURE_DEBUG defined means the driver will generate reams of -X debugging output. You'll probably want to leave this off... -X -X2) Type 'make' (or 'gmake'). Both the driver and test program should compile -X without any problems. No warning messages should be generated. -X -X3) Become 'root'. -X -X4) Type 'make install' and 'make add_drv'. The screen should look something -X like this: -X -X # make install -X cp aperture aperture.conf /kernel/drv -X # make add_drv -X add_drv aperture -X -X On a sparcv9 machine this will mention the /kernel/drv/sparcv9 directory -X instead of /kernel/drv. Similarily /kernel/drv/amd64 should be used on amd64. -X -X This installs the driver to the system. -X -X5) While as root modify the file /etc/devlink.tab, adding these lines: -X -X# The following entry is for the framebuffer driver -Xtype=ddi_pseudo;name=aperture fbs/\M0 -X -X Add that line exactly as shown. You may also simply add the -X contents of the devlink.tab file supplied to /etc/devlink.tab. -X It contains the lines as well. (Yes, that is a tab between -X aperture and fbs, not spaces - very important) -X -X6) Perform a reconfiguration boot of the system. -X -X # touch /reconfigure -X # init 6 -X -XBug reports, questions, suggestions, etc can be sent to xfree86@xfree86.org. -END-of-./aperture/README -echo x - ./aperture/aperture.c -sed 's/^X//' >./aperture/aperture.c << 'END-of-./aperture/aperture.c' -X/* -X * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. -X * -X * Permission is hereby granted, free of charge, to any person obtaining a copy -X * of this software and associated documentation files (the "Software"), to -X * deal in the Software without restriction, including without limitation the -X * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -X * sell copies of the Software, and to permit persons to whom the Software is -X * furnished to do so, subject to the following conditions: -X * -X * The above copyright notice and this permission notice shall be included in -X * all copies or substantial portions of the Software. -X * -X * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -X * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -X * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -X * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -X * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -X * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -X * -X * Except as contained in this notice, the name of the XFree86 Project shall -X * not be used in advertising or otherwise to promote the sale, use or other -X * dealings in this Software without prior written authorization from the -X * XFree86 Project. -X */ -X -X/* -X * Aperture driver for Solaris. -X */ -X -X/* -X * Modified: Martin Bochnig (martin@martux.org) -X * Log: Commented out obsolete kernel interfaces DDI_IDENTIFIED and DDI_NOT_IDENTIFIED -X * not supported by SunOS 5.10 or higher anymore, -X * see http://docs.sun.com/app/docs/doc/819-2255/6n4ibnffr?a=view -X */ -X -X#include <sys/conf.h> -X#include <sys/ddi.h> -X#include <sys/modctl.h> -X#include <sys/open.h> -X#include <sys/stat.h> -X#include <sys/sunddi.h> -X -X#define DEV_IDENT "aperture" -X#define DEV_BANNER "XFree86 aperture driver" -X -X#ifndef D_64BIT -X#define D_64BIT 0 -X#endif -X -X#ifndef NULL -X#define NULL ((void *)0) -X#endif -X -X/* -X * open(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_open -X( -X#ifdef __STDC__ -X dev_t *devp, -X int flag, -X int typ, -X struct cred *cred -X#endif -X) -X#ifndef __STDC__ -X dev_t *devp; -X int flag; -X int typ; -X struct cred *cred; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering open()\n"); -X -X#endif -X -X if ((typ != OTYP_CHR) || (getminor(*devp))) -X error = EINVAL; -X else -X error = 0; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving open() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * mmap(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_mmap -X( -X#ifdef __STDC__ -X dev_t dev, -X off_t off, -X int prot -X#endif -X) -X#ifndef __STDC__ -X dev_t dev; -X off_t off; -X int prot; -X#endif -X{ -X pfn_t pf; -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering mmap(0x%016lx)\n", off); -X -X#endif -X -X pf = btop((unsigned long)off); -X -X /* Deal with mmap(9E) interface limits */ -X error = (int)pf; -X if ((error < 0) || (pf != (pfn_t)error)) -X error = -1; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving mmap() = 0x%08lx", error); -X -X#endif -X -X return error; -X} -X -Xstatic struct cb_ops aperture_cb_ops = -X{ -X aperture_open, /* open */ -X nulldev, /* close */ -X nodev, /* strategy */ -X nodev, /* print */ -X nodev, /* dump */ -X nodev, /* read */ -X nodev, /* write */ -X nodev, /* ioctl */ -X nodev, /* devmap */ -X aperture_mmap, /* mmap */ -X ddi_segmap, /* segmap */ -X nochpoll, /* poll */ -X ddi_prop_op, /* cb_prop_op */ -X 0, /* streamtab */ -X D_NEW | D_MP | D_64BIT /* Driver compatibility flag */ -X}; -X -X -Xstatic dev_info_t *aperture_dip; /* private copy of devinfo pointer */ -X -X/* -X * getinfo(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_getinfo -X( -X#ifdef __STDC__ -X dev_info_t *dip, -X ddi_info_cmd_t infocmd, -X void *arg, -X void **result -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X ddi_info_cmd_t infocmd; -X void *arg; -X void **result; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering getinfo()\n"); -X -X#endif -X -X switch (infocmd) { -X case DDI_INFO_DEVT2DEVINFO: -X *result = aperture_dip; -X error = DDI_SUCCESS; -X break; -X case DDI_INFO_DEVT2INSTANCE: -X *result = NULL; -X error = DDI_SUCCESS; -X break; -X default: -X error = DDI_FAILURE; -X } -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving getinfo() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * identify(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_identify -X( -X#ifdef __STDC__ -X dev_info_t *dip -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering identify()\n"); -X -X#endif -X -X if (strcmp(ddi_get_name(dip), DEV_IDENT)) -X error = 1 /* DDI_NOT_IDENTIFIED obsolete since SunOS 5.10 */ ; -X else -X error = 2 /* DDI_IDENTIFIED obsolete since SunOS 5.10 */ ; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving identify() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * attach(9E) -X */ -X/*ARGSUSED*/ -Xstatic int -Xaperture_attach -X( -X#ifdef __STDC__ -X dev_info_t *dip, -X ddi_attach_cmd_t cmd -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X ddi_attach_cmd_t cmd; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering attach()\n"); -X -X#endif -X -X if (cmd != DDI_ATTACH) -X { -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": not attach(, DDI_ATTACH)\n"); -X -X#endif -X -X error = DDI_FAILURE; -X } -X else -X { -X error = ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR, -X (minor_t)ddi_get_instance(dip), -X NULL, 0 /* NODESPECIFIC_DEV obsolete since SunOS 5.10 */ ); -X -X if (error == DDI_SUCCESS) -X { -X aperture_dip = dip; -X ddi_report_dev(dip); -X } -X } -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving attach() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * detach(9E) -X */ -Xstatic int -Xaperture_detach -X( -X#ifdef __STDC__ -X dev_info_t *dip, -X ddi_detach_cmd_t cmd -X#endif -X) -X#ifndef __STDC__ -X dev_info_t *dip; -X ddi_detach_cmd_t cmd; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering detach()\n"); -X -X#endif -X -X if (cmd != DDI_DETACH) -X { -X error = DDI_FAILURE; -X } -X else -X { -X ddi_remove_minor_node(dip, NULL); -X aperture_dip = NULL; -X error = DDI_SUCCESS; -X } -X -X#if APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving detach() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X -Xstatic struct dev_ops aperture_ops = -X{ -X DEVO_REV, /* revision */ -X 0, /* refcnt */ -X aperture_getinfo, /* getinfo */ -X aperture_identify, /* identify */ -X nulldev, /* probe */ -X aperture_attach, /* attach */ -X aperture_detach, /* detach */ -X nodev, /* reset */ -X &aperture_cb_ops, /* driver operations */ -X NULL /* bus operations */ -X}; -X -X -Xstatic struct modldrv modldrv = -X{ -X &mod_driverops, /* mod_ops structure pointer */ -X DEV_BANNER, /* driver banner string */ -X &aperture_ops, /* dev_ops structure pointer */ -X}; -X -X -Xstatic struct modlinkage modlinkage = -X{ -X MODREV_1, /* module API revision */ -X { -X &modldrv, /* module driver structure pointer */ -X NULL /* list termination */ -X } -X}; -X -X -X/* -X * _init(9E) -X */ -Xint -X_init -X( -X#ifdef __STDC__ -X void -X#endif -X) -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering _init()\n"); -X -X#endif -X -X error = mod_install(&modlinkage); -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving _init() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * _info(9E) -X */ -Xint -X_info -X( -X#ifdef __STDC__ -X struct modinfo *modinfop -X#endif -X) -X#ifndef __STDC__ -X struct modinfo *modinfop; -X#endif -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering _info()\n"); -X -X#endif -X -X error = mod_info(&modlinkage, modinfop); -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving _info() = %d\n", error); -X -X#endif -X -X return error; -X} -X -X/* -X * _fini(9E) -X */ -Xint -X_fini -X( -X#ifdef __STDC__ -X void -X#endif -X) -X{ -X int error; -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": entering _fini()\n"); -X -X#endif -X -X error = mod_remove(&modlinkage); -X -X#ifdef APERTURE_DEBUG -X -X cmn_err(CE_CONT, DEV_IDENT ": leaving _fini() = %d\n", error); -X -X#endif -X -X return error; -X} -END-of-./aperture/aperture.c -echo x - ./aperture/aperture.conf -sed 's/^X//' >./aperture/aperture.conf << 'END-of-./aperture/aperture.conf' -X# -X# Copyright 1994 Doug Anson, danson@lgc.com & David Holland, davidh@use.com -X# -X# File: aperture.conf -X# Author: Doug Anson (danson@lgc.com) -X# -X# Modified: David Holland (davidh@use.com) -X# Log: Change comments 02/23/94 -X# Change defaults/comments 09/25/94 -X# -X# Modified: Marc Aurele La France (tsi@xfree86.org) -X# Log: SPARC changes 2001.09 -X# -X# Purpose: This conf file is used by the aperture driver. -X# -Xname="aperture" parent="pseudo"; -END-of-./aperture/aperture.conf -echo x - ./aperture/devlink.tab -sed 's/^X//' >./aperture/devlink.tab << 'END-of-./aperture/devlink.tab' -X# The following entry is for the aperture driver -Xtype=ddi_pseudo;name=aperture fbs/\M0 -END-of-./aperture/devlink.tab -exit - diff --git a/hw/xfree86/os-support/solaris/solaris-amd64.S b/hw/xfree86/os-support/solaris/solaris-amd64.S deleted file mode 100644 index 9f5e58cb0..000000000 --- a/hw/xfree86/os-support/solaris/solaris-amd64.S +++ /dev/null @@ -1,73 +0,0 @@ -/ Copyright 2005 Sun Microsystems, Inc. All rights reserved. -/ -/ Permission is hereby granted, free of charge, to any person obtaining a -/ copy of this software and associated documentation files (the -/ "Software"), to deal in the Software without restriction, including -/ without limitation the rights to use, copy, modify, merge, publish, -/ distribute, and/or sell copies of the Software, and to permit persons -/ to whom the Software is furnished to do so, provided that the above -/ copyright notice(s) and this permission notice appear in all copies of -/ the Software and that both the above copyright notice(s) and this -/ permission notice appear in supporting documentation. -/ -/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -/ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -/ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. -/ -/ Except as contained in this notice, the name of a copyright holder -/ shall not be used in advertising or otherwise to promote the sale, use -/ or other dealings in this Software without prior written authorization -/ of the copyright holder. - -#ifdef INLINE_ASM -#define FUNCTION_START(f,n) .inline f,n -#define FUNCTION_END(f) .end -#else -#define _ASM -#include <sys/asm_linkage.h> -#define FUNCTION_START(f,n) ENTRY(f) -#define FUNCTION_END(f) SET_SIZE(f) -#endif - - FUNCTION_START(inb,4) - movq %rdi, %rdx - xorq %rax, %rax - inb (%dx) - FUNCTION_END(inb) - - FUNCTION_START(inw,4) - movq %rdi, %rdx - xorq %rax, %rax - inw (%dx) - FUNCTION_END(inw) - - FUNCTION_START(inl,4) - movq %rdi, %rdx - xorq %rax, %rax - inl (%dx) - FUNCTION_END(inl) - - FUNCTION_START(outb,8) - movq %rdi, %rdx - movq %rsi, %rax - outb (%dx) - FUNCTION_END(outb) - - FUNCTION_START(outw,8) - movq %rdi, %rdx - movq %rsi, %rax - outw (%dx) - FUNCTION_END(outw) - - FUNCTION_START(outl,8) - movq %rdi, %rdx - movq %rsi, %rax - outl (%dx) - FUNCTION_END(outl) - diff --git a/hw/xfree86/os-support/solaris/solaris-ia32.S b/hw/xfree86/os-support/solaris/solaris-ia32.S deleted file mode 100644 index e2d9cf60a..000000000 --- a/hw/xfree86/os-support/solaris/solaris-ia32.S +++ /dev/null @@ -1,73 +0,0 @@ -/ Copyright 2004 Sun Microsystems, Inc. All rights reserved. -/ -/ Permission is hereby granted, free of charge, to any person obtaining a -/ copy of this software and associated documentation files (the -/ "Software"), to deal in the Software without restriction, including -/ without limitation the rights to use, copy, modify, merge, publish, -/ distribute, and/or sell copies of the Software, and to permit persons -/ to whom the Software is furnished to do so, provided that the above -/ copyright notice(s) and this permission notice appear in all copies of -/ the Software and that both the above copyright notice(s) and this -/ permission notice appear in supporting documentation. -/ -/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -/ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -/ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. -/ -/ Except as contained in this notice, the name of a copyright holder -/ shall not be used in advertising or otherwise to promote the sale, use -/ or other dealings in this Software without prior written authorization -/ of the copyright holder. - -#ifdef INLINE_ASM -#define FUNCTION_START(f,n) .inline f,n -#define FUNCTION_END(f) .end -#else -#define _ASM -#include <sys/asm_linkage.h> -#define FUNCTION_START(f,n) ENTRY(f) -#define FUNCTION_END(f) SET_SIZE(f) -#endif - - FUNCTION_START(inb,4) - movl (%esp), %edx - xorl %eax, %eax - inb (%dx) - FUNCTION_END(inb) - - FUNCTION_START(inw,4) - movl (%esp), %edx - xorl %eax, %eax - inw (%dx) - FUNCTION_END(inw) - - FUNCTION_START(inl,4) - movl (%esp), %edx - xorl %eax, %eax - inl (%dx) - FUNCTION_END(inl) - - FUNCTION_START(outb,8) - movl (%esp), %edx - movl 4(%esp), %eax - outb (%dx) - FUNCTION_END(outb) - - FUNCTION_START(outw,8) - movl (%esp), %edx - movl 4(%esp), %eax - outw (%dx) - FUNCTION_END(outw) - - FUNCTION_START(outl,8) - movl (%esp), %edx - movl 4(%esp), %eax - outl (%dx) - FUNCTION_END(outl) - diff --git a/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S b/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S deleted file mode 100644 index fb23942ef..000000000 --- a/hw/xfree86/os-support/solaris/solaris-sparcv8plus.S +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -#ifdef INLINE_ASM -#define FUNCTION_START(f,n) .inline f,n -#define FUNCTION_END(f) .end -#else -#define _ASM -#include <sys/asm_linkage.h> -#define FUNCTION_START(f,n) ENTRY(f) -#define FUNCTION_END(f) SET_SIZE(f) -#endif - -/* Converted from common/compiler.h gcc inline format to Sun cc inline - * format by Kenjiro Tsuji - * - * The value 0x88 means ASI_PRIMARY_LITTLE. - * The store or load to/from the address space will be done - * as little-endian. In the original xrog code, the value - * is defined as the macro ASI_PL. - * - * In the original xorg code, "membar #StoreStore|#StoreLoad" - * is directly implemented as an instruction "0x8143e00a". - * - */ - - FUNCTION_START(outb, 0) - stba %o1, [%o0] 0x88 - membar #StoreStore|#StoreLoad - FUNCTION_END(outb) - - FUNCTION_START(outw, 0) - stha %o1, [%o0] 0x88 - membar #StoreStore|#StoreLoad - FUNCTION_END(outw) - - FUNCTION_START(outl, 0) - sta %o1, [%o0] 0x88 - membar #StoreStore|#StoreLoad - FUNCTION_END(outl) - - FUNCTION_START(inb, 0) - lduba [%o0] 0x88, %o0 - FUNCTION_END(inb) - - FUNCTION_START(inw, 0) - lduha [%o0] 0x88, %o0 - FUNCTION_END(inw) - - FUNCTION_START(inl, 0) - lda [%o0] 0x88, %o0 - FUNCTION_END(inl) - - FUNCTION_START(xf86ReadMmio8, 0) - lduba [%o0 + %o1] 0x88, %o0 - FUNCTION_END(xf86ReadMmio8) - - FUNCTION_START(xf86ReadMmio16Be, 0) - lduh [%o0 + %o1], %o0 - FUNCTION_END(xf86ReadMmio16Be) - - FUNCTION_START(xf86ReadMmio16Le, 0) - lduha [%o0 + %o1] 0x88, %o0 - FUNCTION_END(xf86ReadMmio16Le) - - FUNCTION_START(xf86ReadMmio32Be, 0) - ld [%o0 + %o1], %o0 - FUNCTION_END(xf86ReadMmio32Be) - - FUNCTION_START(xf86ReadMmio32Le, 0) - lda [%o0 + %o1] 0x88, %o0 - FUNCTION_END(xf86ReadMmio32Le) - - FUNCTION_START(xf86WriteMmio8, 0) - stba %o2, [%o0 + %o1] 0x88 - membar #StoreStore|#StoreLoad - FUNCTION_END(xf86WriteMmio8) - - FUNCTION_START(xf86WriteMmio16Be, 0) - sth %o2, [%o0 + %o1] - membar #StoreStore|#StoreLoad - FUNCTION_END(xf86WriteMmio16Be) - - FUNCTION_START(xf86WriteMmio16Le, 0) - stha %o2, [%o0 + %o1] 0x88 - membar #StoreStore|#StoreLoad - FUNCTION_END(xf86WriteMmio16Le) - - FUNCTION_START(xf86WriteMmio32Be, 0) - st %o2, [%o0 + %o1] - membar #StoreStore|#StoreLoad - FUNCTION_END(xf86WriteMmio32Be) - - FUNCTION_START(xf86WriteMmio32Le, 0) - sta %o2, [%o0 + %o1] 0x88 - membar #StoreStore|#StoreLoad - FUNCTION_END(xf86WriteMmio32Le) - - FUNCTION_START(xf86WriteMmio8NB, 0) - add %o0, %o1, %o0 - stba %o2, [%o0] 0x88 - FUNCTION_END(xf86WriteMmio8NB) - - FUNCTION_START(xf86WriteMmio16BeNB, 0) - sth %o2, [%o0 + %o1] - FUNCTION_END(xf86WriteMmio16BeNB) - - FUNCTION_START(xf86WriteMmio16LeNB, 0) - stha %o2, [%o0 + %o1] 0x88 - FUNCTION_END(xf86WriteMmio16LeNB) - - FUNCTION_START(xf86WriteMmio32BeNB, 0) - st %o2, [%o0 + %o1] - FUNCTION_END(xf86WriteMmio32BeNB) - - FUNCTION_START(xf86WriteMmio32LeNB, 0) - sta %o2, [%o0 + %o1] 0x88 - FUNCTION_END(xf86WriteMmio32LeNB) - diff --git a/hw/xfree86/os-support/solaris/sun_agp.c b/hw/xfree86/os-support/solaris/sun_agp.c deleted file mode 100644 index e97ab9ef9..000000000 --- a/hw/xfree86/os-support/solaris/sun_agp.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Abstraction of the AGP GART interface. - * - * This version is for Solaris. - * - * Copyright © 2000 VA Linux Systems, Inc. - * Copyright © 2001 The XFree86 Project, Inc. - */ -/* Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -#pragma ident "@(#)sun_agp.c 1.1 05/04/04 SMI" - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86_OSproc.h" -#include <unistd.h> -#include <sys/ioccom.h> -#include <sys/types.h> -#include <fcntl.h> -#include "agpgart.h" - -#ifndef AGP_DEVICE -#define AGP_DEVICE "/dev/agpgart" -#endif -/* AGP page size is independent of the host page size. */ -#ifndef AGP_PAGE_SIZE -#define AGP_PAGE_SIZE 4096 -#endif - -static int gartFd = -1; -static int acquiredScreen = -1; -static Bool initDone = FALSE; -/* - * Close /dev/agpgart. This frees all associated memory allocated during - * this server generation. - */ -_X_EXPORT Bool -xf86GARTCloseScreen(int screenNum) -{ - if (gartFd != -1) { - close(gartFd); - acquiredScreen = -1; - gartFd = -1; - initDone = FALSE; - - xf86DrvMsg(screenNum, X_INFO, - "xf86GARTCloseScreen: device closed successfully\n"); - - } - return TRUE; -} - -/* - * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called. - */ -static Bool -GARTInit(int screenNum) -{ - if (initDone) - return (gartFd != -1); - - if (gartFd == -1) - gartFd = open(AGP_DEVICE, O_RDWR); - else - return FALSE; - - if (gartFd == -1) { - xf86DrvMsg(screenNum, X_ERROR, - "GARTInit: Unable to open " AGP_DEVICE " (%s)\n", - strerror(errno)); - return FALSE; - } - - initDone = TRUE; - xf86DrvMsg(screenNum, X_INFO, - "GARTInit: " AGP_DEVICE " opened successfully\n"); - - return TRUE; -} - -_X_EXPORT Bool -xf86AgpGARTSupported(void) -{ - return (GARTInit(-1)); - -} - -_X_EXPORT AgpInfoPtr -xf86GetAGPInfo(int screenNum) -{ - agp_info_t agpinf; - AgpInfoPtr info; - - if (!GARTInit(screenNum)) - return NULL; - - if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86GetAGPInfo: Failed to allocate AgpInfo\n"); - return NULL; - } - - if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) { - xf86DrvMsg(screenNum, X_ERROR, - "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n", - strerror(errno)); - return NULL; - } - - info->bridgeId = agpinf.agpi_devid; - info->agpMode = agpinf.agpi_mode; - info->base = agpinf.agpi_aperbase; - info->size = agpinf.agpi_apersize; - info->totalPages = (unsigned long)agpinf.agpi_pgtotal; - info->systemPages = (unsigned long)agpinf.agpi_pgsystem; - info->usedPages = (unsigned long)agpinf.agpi_pgused; - - return info; -} - -_X_EXPORT Bool -xf86AcquireGART(int screenNum) -{ - - if (!GARTInit(screenNum)) - return FALSE; - - if (acquiredScreen != screenNum) { - if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) { - xf86DrvMsg(screenNum, X_WARNING, - "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n", - strerror(errno)); - return FALSE; - } - acquiredScreen = screenNum; - xf86DrvMsg(screenNum, X_INFO, - "xf86AcquireGART: AGPIOC_ACQUIRE succeeded\n"); - } - return TRUE; -} - -_X_EXPORT Bool -xf86ReleaseGART(int screenNum) -{ - - if (!GARTInit(screenNum)) - return FALSE; - - if (acquiredScreen == screenNum) { - /* - * The FreeBSD agp driver removes allocations on release. - * The Solaris driver doesn't. xf86ReleaseGART() is expected - * to give up access to the GART, but not to remove any - * allocations. - */ - - if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) { - xf86DrvMsg(screenNum, X_WARNING, - "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n", - strerror(errno)); - return FALSE; - } - acquiredScreen = -1; - xf86DrvMsg(screenNum, X_INFO, - "xf86ReleaseGART: AGPIOC_RELEASE succeeded\n"); - return TRUE; - } - return FALSE; -} - -_X_EXPORT int -xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, - unsigned long *physical) -{ - agp_allocate_t alloc; - int pages; - - /* - * Allocates "size" bytes of GART memory (rounds up to the next - * page multiple) or type "type". A handle (key) for the allocated - * memory is returned. On error, the return value is -1. - * "size" should be larger than 0, or AGPIOC_ALLOCATE ioctl will - * return error. - */ - - if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) - return -1; - - pages = (size / AGP_PAGE_SIZE); - if (size % AGP_PAGE_SIZE != 0) - pages++; - - alloc.agpa_pgcount = pages; - alloc.agpa_type = type; - - if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: " - "allocation of %d pages failed\n\t(%s)\n", pages, - strerror(errno)); - return -1; - } - - if (physical) - *physical = (unsigned long)alloc.agpa_physical; - - return alloc.agpa_key; -} - -_X_EXPORT Bool -xf86DeallocateGARTMemory(int screenNum, int key) -{ - if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) - return FALSE; - - if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: " - "deallocation of gart memory with key %d failed\n" - "\t(%s)\n", key, strerror(errno)); - return FALSE; - } - - return TRUE; -} - -/* Bind GART memory with "key" at "offset" */ -_X_EXPORT Bool -xf86BindGARTMemory(int screenNum, int key, unsigned long offset) -{ - agp_bind_t bind; - int pageOffset; - - if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) - return FALSE; - - if (offset % AGP_PAGE_SIZE != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " - "offset (0x%lx) is not page-aligned (%d)\n", - offset, AGP_PAGE_SIZE); - return FALSE; - } - pageOffset = offset / AGP_PAGE_SIZE; - - xf86DrvMsgVerb(screenNum, X_INFO, 3, - "xf86BindGARTMemory: bind key %d at 0x%08lx " - "(pgoffset %d)\n", key, offset, pageOffset); - - bind.agpb_pgstart = pageOffset; - bind.agpb_key = key; - - if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: " - "binding of gart memory with key %d\n" - "\tat offset 0x%lx failed (%s)\n", - key, offset, strerror(errno)); - return FALSE; - } - - return TRUE; -} - -/* Unbind GART memory with "key" */ -_X_EXPORT Bool -xf86UnbindGARTMemory(int screenNum, int key) -{ - agp_unbind_t unbind; - - if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) - return FALSE; - - unbind.agpu_pri = 0; - unbind.agpu_key = key; - - if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: " - "unbinding of gart memory with key %d " - "failed (%s)\n", key, strerror(errno)); - return FALSE; - } - - xf86DrvMsgVerb(screenNum, X_INFO, 3, - "xf86UnbindGARTMemory: unbind key %d\n", key); - - return TRUE; -} - - -/* XXX Interface may change. */ -_X_EXPORT Bool -xf86EnableAGP(int screenNum, CARD32 mode) -{ - agp_setup_t setup; - - if (!GARTInit(screenNum) || (acquiredScreen != screenNum)) - return FALSE; - - setup.agps_mode = mode; - if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) { - xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: " - "AGPIOC_SETUP with mode %x failed (%s)\n", - mode, strerror(errno)); - return FALSE; - } - - return TRUE; -} - diff --git a/hw/xfree86/os-support/solaris/sun_apm.c b/hw/xfree86/os-support/solaris/sun_apm.c deleted file mode 100644 index 7decc900f..000000000 --- a/hw/xfree86/os-support/solaris/sun_apm.c +++ /dev/null @@ -1,232 +0,0 @@ -/* Based on hw/xfree86/os-support/bsd/bsd_apm.c which bore no explicit - * copyright notice, so is covered by the following notice: - * - * Copyright (C) 1994-2003 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF - * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ - -/* Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "os.h" -#include "xf86.h" -#include "xf86Priv.h" -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" -#include "xf86_OSlib.h" - -#ifndef PLEASE_FIX_THIS -#define APM_STANDBY_REQ 0xa01 -#define APM_SUSPEND_REQ 0xa02 -#define APM_NORMAL_RESUME 0xa03 -#define APM_CRIT_RESUME 0xa04 -#define APM_BATTERY_LOW 0xa05 -#define APM_POWER_CHANGE 0xa06 -#define APM_UPDATE_TIME 0xa07 -#define APM_CRIT_SUSPEND_REQ 0xa08 -#define APM_USER_STANDBY_REQ 0xa09 -#define APM_USER_SUSPEND_REQ 0xa0a -#define APM_SYS_STANDBY_RESUME 0xa0b -#define APM_IOC_NEXTEVENT 0xa0c -#define APM_IOC_RESUME 0xa0d -#define APM_IOC_SUSPEND 0xa0e -#define APM_IOC_STANDBY 0xa0f -#endif - -typedef struct apm_event_info -{ - int type; -} apm_event_info; - -/* - This may be replaced with a better device name - very soon... -*/ -#define APM_DEVICE "/dev/srn" -#define APM_DEVICE1 "/dev/apm" - -static pointer APMihPtr = NULL; -static void sunCloseAPM(void); - -static struct { - u_int apmBsd; - pmEvent xf86; -} sunToXF86Array [] = { - { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, - { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, - { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, - { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, - { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, - { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, - { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, - { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, - { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, - { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, - { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, -#ifdef APM_CAPABILITY_CHANGE - { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, -#endif -}; - -#define numApmEvents (sizeof(sunToXF86Array) / sizeof(sunToXF86Array[0])) - -static pmEvent -sunToXF86(int type) -{ - int i; - - for (i = 0; i < numApmEvents; i++) { - if (type == sunToXF86Array[i].apmBsd) { - return sunToXF86Array[i].xf86; - } - } - return XF86_APM_UNKNOWN; -} - -/* - * APM events can be requested direclty from /dev/apm - */ -static int -sunPMGetEventFromOS(int fd, pmEvent *events, int num) -{ - struct apm_event_info sunEvent; - int i; - - for (i = 0; i < num; i++) { - - if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) { - if (errno != EAGAIN) { - xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT" - " %s\n", strerror(errno)); - } - break; - } - events[i] = sunToXF86(sunEvent.type); - } - xf86Msg(X_WARNING, "Got some events\n"); - return i; -} - -static pmWait -sunPMConfirmEventToOs(int fd, pmEvent event) -{ - switch (event) { -/* XXX: NOT CURRENTLY RETURNED FROM OS */ - case XF86_APM_SYS_STANDBY: - case XF86_APM_USER_STANDBY: - if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0) - return PM_WAIT; /* should we stop the Xserver in standby, too? */ - else - return PM_NONE; - case XF86_APM_SYS_SUSPEND: - case XF86_APM_CRITICAL_SUSPEND: - case XF86_APM_USER_SUSPEND: - xf86Msg(X_WARNING, "Got SUSPENDED\n"); - if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) - return PM_CONTINUE; - else { - xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND" - " %s\n", strerror(errno)); - return PM_FAILED; - } - case XF86_APM_STANDBY_RESUME: - case XF86_APM_NORMAL_RESUME: - case XF86_APM_CRITICAL_RESUME: - case XF86_APM_STANDBY_FAILED: - case XF86_APM_SUSPEND_FAILED: - xf86Msg(X_WARNING, "Got RESUME\n"); - if (ioctl( fd, APM_IOC_RESUME, NULL ) == 0) - return PM_CONTINUE; - else { - xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME" - " %s\n", strerror(errno)); - return PM_FAILED; - } - default: - return PM_NONE; - } -} - -PMClose -xf86OSPMOpen(void) -{ - int fd; - - if (APMihPtr || !xf86Info.pmFlag) { - return NULL; - } - - if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { - if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) { - return NULL; - } - } - xf86PMGetEventFromOs = sunPMGetEventFromOS; - xf86PMConfirmEventToOs = sunPMConfirmEventToOs; - APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL); - return sunCloseAPM; -} - -static void -sunCloseAPM(void) -{ - int fd; - - if (APMihPtr) { - fd = xf86RemoveInputHandler(APMihPtr); - close(fd); - APMihPtr = NULL; - } -} diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c deleted file mode 100644 index 29ecd7300..000000000 --- a/hw/xfree86/os-support/solaris/sun_bell.c +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/audio.h> -#include <sys/uio.h> -#include <limits.h> -#include <math.h> -#include <poll.h> - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#define BELL_RATE 48000 /* Samples per second */ -#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */ -#define BELL_MS (1000/BELL_HZ) /* MS */ -#define BELL_SAMPLES (BELL_RATE / BELL_HZ) -#define BELL_MIN 3 /* Min # of repeats */ - -#define AUDIO_DEVICE "/dev/audio" - -_X_EXPORT void -xf86OSRingBell(int loudness, int pitch, int duration) -{ - static short samples[BELL_SAMPLES]; - static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */ - static int lastFreq; - int cnt; - int i; - int written; - int repeats; - int freq; - audio_info_t audioInfo; - struct iovec iov[IOV_MAX]; - int iovcnt; - double ampl, cyclen, phase; - int audioFD; - - if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) { - return; - } - - lastFreq = 0; - bzero(silence, sizeof(silence)); - - audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK); - if (audioFD == -1) { - xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n", - AUDIO_DEVICE, strerror(errno)); - return; - } - - freq = pitch; - freq = min(freq, (BELL_RATE / 2) - 1); - freq = max(freq, 2 * BELL_HZ); - - /* - * Ensure full waves per buffer - */ - freq -= freq % BELL_HZ; - - if (freq != lastFreq) { - lastFreq = freq; - ampl = 16384.0; - - cyclen = (double) freq / (double) BELL_RATE; - phase = 0.0; - - for (i = 0; i < BELL_SAMPLES; i++) { - samples[i] = (short) (ampl * sin(2.0 * M_PI * phase)); - phase += cyclen; - if (phase >= 1.0) - phase -= 1.0; - } - } - - repeats = (duration + (BELL_MS / 2)) / BELL_MS; - repeats = max(repeats, BELL_MIN); - - loudness = max(0, loudness); - loudness = min(loudness, 100); - -#ifdef DEBUG - ErrorF("BELL : freq %d volume %d duration %d repeats %d\n", - freq, loudness, duration, repeats); -#endif - - AUDIO_INITINFO(&audioInfo); - audioInfo.play.encoding = AUDIO_ENCODING_LINEAR; - audioInfo.play.sample_rate = BELL_RATE; - audioInfo.play.channels = 2; - audioInfo.play.precision = 16; - audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100); - - if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){ - xf86Msg(X_ERROR, - "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n", - AUDIO_DEVICE, strerror(errno)); - close(audioFD); - return; - } - - iovcnt = 0; - - for (cnt = 0; cnt <= repeats; cnt++) { - iov[iovcnt].iov_base = (char *) samples; - iov[iovcnt++].iov_len = sizeof(samples); - if (cnt == repeats) { - /* Insert a bit of silence so that multiple beeps are distinct and - * not compressed into a single tone. - */ - iov[iovcnt].iov_base = (char *) silence; - iov[iovcnt++].iov_len = sizeof(silence); - } - if ((iovcnt >= IOV_MAX) || (cnt == repeats)) { - written = writev(audioFD, iov, iovcnt); - - if ((written < ((int)(sizeof(samples) * iovcnt)))) { - /* audio buffer was full! */ - - int naptime; - - if (written == -1) { - if (errno != EAGAIN) { - xf86Msg(X_ERROR, - "Bell: writev failed on audio device \"%s\": %s\n", - AUDIO_DEVICE, strerror(errno)); - close(audioFD); - return; - } - i = iovcnt; - } else { - i = ((sizeof(samples) * iovcnt) - written) - / sizeof(samples); - } - cnt -= i; - - /* sleep a little to allow audio buffer to drain */ - naptime = BELL_MS * i; - poll(NULL, 0, naptime); - - i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples); - iovcnt = 0; - if ((written != -1) && (i > 0)) { - iov[iovcnt].iov_base = ((char *) samples) + i; - iov[iovcnt++].iov_len = sizeof(samples) - i; - } - } else { - iovcnt = 0; - } - } - } - - close(audioFD); - return; -} diff --git a/hw/xfree86/os-support/solaris/sun_bios.c b/hw/xfree86/os-support/solaris/sun_bios.c deleted file mode 100644 index a27a5a5a7..000000000 --- a/hw/xfree86/os-support/solaris/sun_bios.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * Copyright 1999 by David Holland <davidh@iquest.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 names of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The 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 COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT - * SHALL THE 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. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#if defined(__i386__) || defined(__i386) -#define _NEED_SYSI86 -#endif -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -extern char *apertureDevName; - -/* - * Read BIOS via mmap()ing physical memory. - */ -_X_EXPORT int -xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, - int Len) -{ - int fd; - unsigned char *ptr; - char solx86_vtname[20]; - int psize; - int mlen; - - /* - * Solaris 2.1 x86 SVR4 (10/27/93) - * The server must treat the virtual terminal device file - * as the standard SVR4 /dev/pmem. By default, then used VT - * is considered the "default" file to open. - * - * Solaris 2.8 x86 (7/26/99) - DWH - * - * Use /dev/xsvc for everything. - */ - psize = getpagesize(); - Offset += Base & (psize - 1); - Base &= ~(psize - 1); - mlen = (Offset + Len + psize - 1) & ~(psize - 1); -#if (defined(__i386__) || defined(__i386)) && !defined(__SOL8__) - if (Base >= 0xA0000 && Base + mlen < 0xFFFFF && xf86Info.vtno >= 0) - sprintf(solx86_vtname, "/dev/vt%02d", xf86Info.vtno); - else -#endif - { - if (!xf86LinearVidMem()) - FatalError("xf86ReadBIOS: Could not mmap BIOS" - " [a=%lx]\n", Base); - sprintf(solx86_vtname, apertureDevName); - } - - if ((fd = open(solx86_vtname, O_RDONLY)) < 0) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", - solx86_vtname, strerror(errno)); - return(-1); - } - ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, - MAP_SHARED, fd, (off_t)Base); - if (ptr == MAP_FAILED) - { - xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed " - "[0x%08lx, 0x%04x]\n", - solx86_vtname, Base, mlen); - close(fd); - return -1; - } - - (void)memcpy(Buf, (void *)(ptr + Offset), Len); - (void)munmap((caddr_t)ptr, mlen); - (void)close(fd); - - return Len; -} diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c deleted file mode 100644 index 1f389cb40..000000000 --- a/hw/xfree86/os-support/solaris/sun_init.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * Copyright 1999 by David Holland <davidh@iquest.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 names of the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The 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 COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND IN NO - * EVENT SHALL THE 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. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#if defined(__i386__) || defined(__i386) || defined(__x86) -# include <sys/kd.h> -#endif - -static Bool KeepTty = FALSE; -static Bool Protect0 = FALSE; -#ifdef HAS_USL_VTS -static int VTnum = -1; -static int xf86StartVT = -1; -#endif - -#if defined(__SOL8__) || (!defined(__i386__) && !defined(__i386)) -static char fb_dev[PATH_MAX] = "/dev/fb"; -#else -static char fb_dev[PATH_MAX] = "/dev/console"; -#endif - -void -xf86OpenConsole(void) -{ -#ifdef HAS_USL_VTS - int fd, i; - struct vt_mode VT; - struct vt_stat vtinfo; - int FreeVTslot; - MessageType from = X_PROBED; -#endif - - if (serverGeneration == 1) - { - /* Check if we're run with euid==0 */ - if (geteuid() != 0) - FatalError("xf86OpenConsole: Server must be suid root\n"); - - /* 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) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: cannot open /dev/zero (%s)\n", - strerror(errno)); - } - else - { - if ((int)mmap(0, 0x1000, PROT_NONE, - MAP_FIXED | MAP_SHARED, fd, 0) == -1) - xf86Msg(X_WARNING, - "xf86OpenConsole: failed to protect page 0 (%s)\n", - strerror(errno)); - - close(fd); - } - } - -#ifdef HAS_USL_VTS - - /* - * Setup the virtual terminal manager - */ - if (VTnum != -1) - { - xf86Info.vtno = VTnum; - from = X_CMDLINE; - } - else - { - if ((fd = open("/dev/vt00",O_RDWR,0)) < 0) - FatalError("xf86OpenConsole: Cannot open /dev/vt00 (%s)\n", - strerror(errno)); - - if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0) - FatalError("xf86OpenConsole: Cannot determine current VT\n"); - - xf86StartVT = vtinfo.v_active; - - /* - * There is a SEVERE problem with x86's VT's. The VT_OPENQRY - * ioctl() will panic the entire system if all 8 (7 VT's+Console) - * terminals are used. The only other way I've found to determine - * if there is a free VT is to try activating all the the available - * VT's and see if they all succeed - if they do, there there is no - * free VT, and the Xserver cannot continue without panic'ing the - * system. (It's ugly, but it seems to work.) Note there is a - * possible race condition here. - * - * David Holland 2/23/94 - */ - - FreeVTslot = 0; - for (i = 7; (i >= 0) && !FreeVTslot; i--) - if (ioctl(fd, VT_ACTIVATE, i) != 0) - FreeVTslot = 1; - - if (!FreeVTslot || - (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || - (xf86Info.vtno == -1)) - FatalError("xf86OpenConsole: Cannot find a free VT\n"); - - close(fd); - } - - xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); - - sprintf(fb_dev, "/dev/vt%02d", xf86Info.vtno); /* Solaris 2.1 x86 */ - -#endif /* HAS_USL_VTS */ - - if (!KeepTty) - setpgrp(); - - if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0)) - FatalError("xf86OpenConsole: Cannot open %s (%s)\n", - fb_dev, strerror(errno)); - -#ifdef HAS_USL_VTS - - /* Change ownership of the vt */ - chown(fb_dev, getuid(), getgid()); - - /* - * Now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) - xf86Msg(X_WARNING, "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"); -#endif -#ifdef KDSETMODE - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) - FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); -#endif - } - else /* serverGeneration != 1 */ - { -#ifdef HAS_USL_VTS - /* - * Now re-get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) - xf86Msg(X_WARNING, "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 (!xf86Screens[0]->vtSema) - sleep(5); - -#endif /* HAS_USL_VTS */ - - } -} - -void -xf86CloseConsole(void) -{ -#ifdef HAS_USL_VTS - struct vt_mode VT; -#endif - -#if !defined(__i386__) && !defined(__i386) && !defined(__x86) - - if (!xf86DoProbe && !xf86DoConfigure) { - int fd; - - /* - * Wipe out framebuffer just like the non-SI Xsun server does. This - * could be improved by saving framebuffer contents in - * xf86OpenConsole() above and restoring them here. Also, it's unclear - * at this point whether this should be done for all framebuffers in - * the system, rather than only the console. - */ - if ((fd = open("/dev/fb", O_RDWR, 0)) < 0) { - xf86Msg(X_WARNING, - "xf86CloseConsole(): unable to open framebuffer (%s)\n", - strerror(errno)); - } else { - struct fbgattr fbattr; - - if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) && - (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) { - xf86Msg(X_WARNING, - "xf86CloseConsole(): unable to retrieve framebuffer" - " attributes (%s)\n", strerror(errno)); - } else { - pointer fbdata; - - fbdata = mmap(NULL, fbattr.fbtype.fb_size, - PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (fbdata == MAP_FAILED) { - xf86Msg(X_WARNING, - "xf86CloseConsole(): unable to mmap framebuffer" - " (%s)\n", strerror(errno)); - } else { - (void)memset(fbdata, 0, fbattr.fbtype.fb_size); - (void)munmap(fbdata, fbattr.fbtype.fb_size); - } - } - - close(fd); - } - } - -#endif - -#ifdef KDSETMODE - /* Reset the display back to text mode */ - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); -#endif - -#ifdef HAS_USL_VTS - - /* - * Solaris 2.1 x86 doesn't seem to "switch" back to the console when the VT - * is relinquished and its mode is reset to auto. Also, Solaris 2.1 seems - * to associate vt00 with the console so I've opened the "console" back up - * and made it the active vt again in text mode and then closed it. There - * must be a better hack for this but I'm not aware of one at this time. - * - * Doug Anson 11/6/93 - * danson@lgc.com - * - * Fixed - 12/5/93 - David Holland - davidh@dorite.use.com - * Did the whole thing similarly to the way linux does it - */ - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) - { - VT.mode = VT_AUTO; /* Set default vt handling */ - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); - } - - /* Activate the VT that X was started on */ - ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT); - -#endif /* HAS_USL_VTS */ - - close(xf86Info.consoleFd); -} - -int -xf86ProcessArgument(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; - } - - /* - * 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; - } - -#ifdef HAS_USL_VTS - - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) - { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) - { - UseMsg(); - VTnum = -1; - return 0; - } - - return 1; - } - -#endif /* HAS_USL_VTS */ - -#if defined(__SOL8__) || (!defined(__i386__) && !defined(__i386)) - - if ((i + 1) < argc) { - if (!strcmp(argv[i], "-dev")) { - strncpy(fb_dev, argv[i+1], PATH_MAX); - fb_dev[PATH_MAX - 1] = '\0'; - return 2; - } - } - -#endif - - return 0; -} - -void xf86UseMsg() -{ -#ifdef HAS_USL_VTS - ErrorF("vtXX Use the specified VT number\n"); -#endif -#if defined(__SOL8__) || !defined(__i386__) - ErrorF("-dev <fb> Framebuffer device\n"); -#endif - ErrorF("-keeptty Don't detach controlling tty\n"); - ErrorF(" (for debugging only)\n"); -} diff --git a/hw/xfree86/os-support/solaris/sun_inout.s b/hw/xfree86/os-support/solaris/sun_inout.s deleted file mode 100644 index e8f03d0e8..000000000 --- a/hw/xfree86/os-support/solaris/sun_inout.s +++ /dev/null @@ -1,124 +0,0 @@ -/ $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s,v 1.1 2001/05/28 02:42:31 tsi Exp $ -/ -/ Copyright 1994-2001 The XFree86 Project, Inc. All Rights Reserved. -/ -/ Permission is hereby granted, free of charge, to any person obtaining a copy -/ of this software and associated documentation files (the "Software"), to deal -/ in the Software without restriction, including without limitation the rights -/ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -/ copies of the Software, and to permit persons to whom the Software is -/ furnished to do so, subject to the following conditions: -/ -/ The above copyright notice and this permission notice shall be included in -/ all copies or substantial portions of the Software. -/ -/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -/ XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -/ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -/ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -/ -/ Except as contained in this notice, the name of the XFree86 Project shall not -/ be used in advertising or otherwise to promote the sale, use or other -/ dealings in this Software without prior written authorization from the -/ XFree86 Project. -/ -/ -/ File: sun_inout.s -/ -/ Purpose: Provide inb(), inw(), inl(), outb(), outw(), outl() functions -/ for Solaris x86 using the ProWorks compiler by SunPro -/ -/ Author: Installed into XFree86 SuperProbe by Doug Anson (danson@lgc.com) -/ Portions donated to XFree86 by Steve Dever (Steve.Dever@Eng.Sun.Com) -/ -/ Synopsis: (c callable external declarations) -/ extern unsigned char inb(int port); -/ extern unsigned short inw(int port); -/ extern unsigned long inl(int port); -/ extern void outb(int port, unsigned char value); -/ extern void outw(int port, unsigned short value); -/ extern void outl(int port, unsigned long value); -/ - -.file "sunos_inout.s" -.text - -.globl inb -.globl inw -.globl inl -.globl outb -.globl outw -.globl outl - -/ -/ unsigned char inb(int port); -/ -.align 4 -inb: - movl 4(%esp),%edx - subl %eax,%eax - inb (%dx) - ret -.type inb,@function -.size inb,.-inb - -/ -/ unsigned short inw(int port); -/ -.align 4 -inw: - movl 4(%esp),%edx - subl %eax,%eax - inw (%dx) - ret -.type inw,@function -.size inw,.-inw - -/ -/ unsigned long inl(int port); -/ -.align 4 -inl: - movl 4(%esp),%edx - inl (%dx) - ret -.type inl,@function -.size inl,.-inl - -/ -/ void outb(int port, unsigned char value); -/ -.align 4 -outb: - movl 4(%esp),%edx - movl 8(%esp),%eax - outb (%dx) - ret -.type outb,@function -.size outb,.-outb - -/ -/ void outw(int port, unsigned short value); -/ -.align 4 -outw: - movl 4(%esp),%edx - movl 8(%esp),%eax - outw (%dx) - ret -.type outw,@function -.size outw,.-outw - -/ -/ void outl(int port, unsigned long value); -/ -.align 4 -outl: - movl 4(%esp),%edx - movl 8(%esp),%eax - outl (%dx) - ret -.type outl,@function -.size outl,.-outl diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c deleted file mode 100644 index a5955ef2c..000000000 --- a/hw/xfree86/os-support/solaris/sun_mouse.c +++ /dev/null @@ -1,717 +0,0 @@ -/* - * Copyright 1999-2001 The XFree86 Project, Inc. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the XFree86 Project shall - * not be used in advertising or otherwise to promote the sale, use or other - * dealings in this Software without prior written authorization from the - * XFree86 Project. - */ -/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons - * to whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT - * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. - * - * Except as contained in this notice, the name of a copyright holder - * shall not be used in advertising or otherwise to promote the sale, use - * or other dealings in this Software without prior written authorization - * of the copyright holder. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include "xf86.h" -#include "xf86_OSlib.h" -#include "xf86OSmouse.h" - -#if defined(__SOL8__) || !defined(__i386) - -#include "xisb.h" -#include "mipointer.h" -#include <sys/stropts.h> -#include <sys/vuid_event.h> -#include <sys/msio.h> - -/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */ -#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */ -# define HAVE_VUID_WHEEL -#endif -#ifdef HAVE_VUID_WHEEL -# include <sys/vuid_wheel.h> -#endif - -/* Support for scaling absolute coordinates to screen size in - * Solaris 10 updates and beyond */ -#if !defined(HAVE_ABSOLUTE_MOUSE_SCALING) -# ifdef MSIOSRESOLUTION /* Defined in msio.h if scaling support present */ -# define HAVE_ABSOLUTE_MOUSE_SCALING -# endif -#endif - -/* Names of protocols that are handled internally here. */ - -static const char *internalNames[] = { - "VUID", - NULL -}; - -static const char *solarisMouseDevs[] = { - /* Device file: Protocol: */ - "/dev/mouse", "VUID", /* USB or SPARC */ -#if defined(__i386) || defined(__x86) - "/dev/kdmouse", "PS/2", /* PS/2 */ -#endif - NULL -}; - -typedef struct _VuidMseRec { - struct _VuidMseRec *next; - InputInfoPtr pInfo; - Firm_event event; - unsigned char * buffer; - char * strmod; - Bool(*wrapped_device_control)(DeviceIntPtr device, int what); -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING - Ms_screen_resolution absres; -#endif -} VuidMseRec, *VuidMsePtr; - -static VuidMsePtr vuidMouseList = NULL; - -static int vuidMouseProc(DeviceIntPtr pPointer, int what); -static void vuidReadInput(InputInfoPtr pInfo); - -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING -static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse); -static void vuidMouseAdjustFrame(int index, int x, int y, int flags); - -static int vuidMouseGeneration = 0; -static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey; -#define vuidMouseGetScreenPrivate(s) ( \ - dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey)) -#define vuidMouseSetScreenPrivate(s,p) \ - dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, (void *) p) -#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */ - -static inline -VuidMsePtr getVuidMsePriv(InputInfoPtr pInfo) -{ - VuidMsePtr m = vuidMouseList; - - while ((m != NULL) && (m->pInfo != pInfo)) { - m = m->next; - } - - return m; -} - - -/* - * Initialize and enable the mouse wheel, if present. - * - * Returns 1 if mouse wheel was successfully enabled. - * Returns 0 if an error occurred or if there is no mouse wheel. - */ -static int -vuidMouseWheelInit(InputInfoPtr pInfo) -{ -#ifdef HAVE_VUID_WHEEL - wheel_state wstate; - int nwheel = -1; - int i; - - wstate.vers = VUID_WHEEL_STATE_VERS; - wstate.id = 0; - wstate.stateflags = -1; - - SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel)); - if (i != 0) - return (0); - - SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate)); - if (i != 0) { - xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name); - return (0); - } - - wstate.stateflags |= VUID_WHEEL_STATE_ENABLED; - - SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate)); - if (i != 0) { - xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name); - return (0); - } - - return (1); -#else - return (0); -#endif -} - - -/* This function is called when the protocol is "VUID". */ -static Bool -vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - MouseDevPtr pMse = pInfo->private; - VuidMsePtr pVuidMse; - int buttons, i; - - pVuidMse = xcalloc(sizeof(VuidMseRec), 1); - if (pVuidMse == NULL) { - xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name); - xfree(pMse); - return FALSE; - } - - pMse->protocol = protocol; - xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); - - /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); - xf86ProcessCommonOptions(pInfo, pInfo->options); - - /* Check if the device can be opened. */ - pInfo->fd = xf86OpenSerial(pInfo->options); - if (pInfo->fd == -1) { - if (xf86GetAllowMouseOpenFail()) - xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); - else { - xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); - xfree(pVuidMse); - xfree(pMse); - return FALSE; - } - } - - pVuidMse->buffer = (unsigned char *)&pVuidMse->event; - - pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL); - if (pVuidMse->strmod) { - SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod)); - if (i < 0) { - xf86Msg(X_ERROR, - "%s: cannot push module '%s' onto mouse device: %s\n", - pInfo->name, pVuidMse->strmod, strerror(errno)); - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - xfree(pVuidMse->strmod); - xfree(pVuidMse); - xfree(pMse); - return FALSE; - } - } - - buttons = xf86SetIntOption(pInfo->options, "Buttons", 0); - if (buttons == 0) { - SYSCALL(i = ioctl(pInfo->fd, MSIOBUTTONS, &buttons)); - if (i == 0) { - pInfo->conf_idev->commonOptions = - xf86ReplaceIntOption(pInfo->conf_idev->commonOptions, - "Buttons", buttons); - xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n", - pInfo->name, buttons); - } - } - - if (pVuidMse->strmod) { - SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod)); - if (i == -1) { - xf86Msg(X_WARNING, - "%s: cannot pop module '%s' off mouse device: %s\n", - pInfo->name, pVuidMse->strmod, strerror(errno)); - } - } - - xf86CloseSerial(pInfo->fd); - pInfo->fd = -1; - - /* Process common mouse options (like Emulate3Buttons, etc). */ - pMse->CommonOptions(pInfo); - - /* Setup the local procs. */ - pVuidMse->wrapped_device_control = pInfo->device_control; - pInfo->device_control = vuidMouseProc; - pInfo->read_input = vuidReadInput; - - pMse->xisbscale = sizeof(Firm_event); - -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING - pVuidMse->absres.height = pVuidMse->absres.width = 0; -#endif - pVuidMse->pInfo = pInfo; - pVuidMse->next = vuidMouseList; - vuidMouseList = pVuidMse; - - pInfo->flags |= XI86_CONFIGURED; - return TRUE; -} - -static void -vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY, - Bool *absXset, Bool *absYset) -{ -#ifdef DEBUG - ErrorF("vuidFlushAbsEvents: %d,%d (set: %d, %d)\n", absX, absY, - *absXset, *absYset); -#endif - if ((*absXset) && (*absYset)) { - xf86PostMotionEvent(pInfo->dev, - /* is_absolute: */ TRUE, - /* first_valuator: */ 0, - /* num_valuators: */ 2, - absX, absY); - } else if (*absXset) { - xf86PostMotionEvent(pInfo->dev, - /* is_absolute: */ TRUE, - /* first_valuator: */ 0, - /* num_valuators: */ 1, - absX); - } else if (*absYset) { - xf86PostMotionEvent(pInfo->dev, - /* is_absolute: */ TRUE, - /* first_valuator: */ 1, - /* num_valuators: */ 1, - absY); - } - - *absXset = FALSE; - *absYset = FALSE; -} - -static void -vuidReadInput(InputInfoPtr pInfo) -{ - MouseDevPtr pMse; - VuidMsePtr pVuidMse; - int buttons; - int dx = 0, dy = 0, dz = 0, dw = 0; - unsigned int n; - int c; - unsigned char *pBuf; - int wmask; - int absX, absY; - Bool absXset = FALSE, absYset = FALSE; - - pMse = pInfo->private; - pVuidMse = getVuidMsePriv(pInfo); - buttons = pMse->lastButtons; - XisbBlockDuration(pMse->buffer, -1); - pBuf = pVuidMse->buffer; - n = 0; - - do { - while (n < sizeof(Firm_event) && (c = XisbRead(pMse->buffer)) >= 0) { - pBuf[n++] = (unsigned char)c; - } - - if (n == 0) - return; - - if (n != sizeof(Firm_event)) { - xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", - pInfo->name, n); - } - -#ifdef DEBUG - ErrorF("vuidReadInput: event type: %3d value: %5d\n", - pVuidMse->event.id, pVuidMse->event.value); -#endif - - if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) { - /* button */ - int butnum = pVuidMse->event.id - BUT_FIRST; - - if (butnum < 3) - butnum = 2 - butnum; - if (!pVuidMse->event.value) - buttons &= ~(1 << butnum); - else - buttons |= (1 << butnum); - } else if (pVuidMse->event.id >= VLOC_FIRST && - pVuidMse->event.id <= VLOC_LAST) { - /* axis */ - int delta = pVuidMse->event.value; - switch(pVuidMse->event.id) { - case LOC_X_DELTA: - dx += delta; - break; - case LOC_Y_DELTA: - dy -= delta; - break; - case LOC_X_ABSOLUTE: - if (absXset) { - vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset); - } - absX = delta; - absXset = TRUE; - break; - case LOC_Y_ABSOLUTE: - if (absYset) { - vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset); - } - absY = delta; - absYset = TRUE; - break; - } - } -#ifdef HAVE_VUID_WHEEL - else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) { - if (vuid_id_offset(pVuidMse->event.id) == 0) - dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value); - else - dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value); - } -#endif -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING - else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) { - /* force sending absolute resolution scaling ioctl */ - pVuidMse->absres.height = pVuidMse->absres.width = 0; - vuidMouseSendScreenSize(miPointerCurrentScreen(), pVuidMse); - } -#endif - - n = 0; - if ((c = XisbRead(pMse->buffer)) >= 0) { - /* Another packet. Handle it right away. */ - pBuf[n++] = c; - } - } while (n != 0); - - if (absXset || absYset) { - vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset); - } - - pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); - return; -} - -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING -static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse) -{ - InputInfoPtr pInfo = pVuidMse->pInfo; - ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); - int result; - - if ((pVuidMse->absres.width != pScr->currentMode->HDisplay) || - (pVuidMse->absres.height != pScr->currentMode->VDisplay)) - { - pVuidMse->absres.width = pScr->currentMode->HDisplay; - pVuidMse->absres.height = pScr->currentMode->VDisplay; - - do { - result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres)); - } while ( (result != 0) && (errno == EINTR) ); - - if (result != 0) { - xf86Msg(X_WARNING, - "%s: couldn't set absolute mouse scaling resolution: %s\n", - pInfo->name, strerror(errno)); -#ifdef DEBUG - } else { - xf86Msg(X_INFO, - "%s: absolute mouse scaling resolution set to %d x %d\n", - pInfo->name, - pVuidMse->absres.width, pVuidMse->absres.height); -#endif - } - } -} - -static void vuidMouseAdjustFrame(int index, int x, int y, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[index]; - ScreenPtr pScreen = pScrn->pScreen; - xf86AdjustFrameProc *wrappedAdjustFrame - = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen); - VuidMsePtr m; - - if(wrappedAdjustFrame) { - pScrn->AdjustFrame = wrappedAdjustFrame; - (*pScrn->AdjustFrame)(index, x, y, flags); - pScrn->AdjustFrame = vuidMouseAdjustFrame; - } - - if (miPointerCurrentScreen() == pScreen) { - for (m = vuidMouseList; m != NULL ; m = m->next) { - vuidMouseSendScreenSize(pScreen, m); - } - } -} -#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */ - - -static int -vuidMouseProc(DeviceIntPtr pPointer, int what) -{ - InputInfoPtr pInfo; - MouseDevPtr pMse; - VuidMsePtr pVuidMse; - int ret = Success; - int i; - - pInfo = pPointer->public.devicePrivate; - pMse = pInfo->private; - pMse->device = pPointer; - - pVuidMse = getVuidMsePriv(pInfo); - if (pVuidMse == NULL) { - return BadImplementation; - } - - switch (what) { - - case DEVICE_INIT: -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING - if (vuidMouseGeneration != serverGeneration) { - for (i = 0; i < screenInfo.numScreens; i++) { - ScreenPtr pScreen = screenInfo.screens[i]; - ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); - vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame); - pScrn->AdjustFrame = vuidMouseAdjustFrame; - } - vuidMouseGeneration = serverGeneration; - } -#endif - ret = pVuidMse->wrapped_device_control(pPointer, what); - break; - - case DEVICE_ON: - ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON); - - if ((ret == Success) && (pInfo->fd != -1)) { - int fmt = VUID_FIRM_EVENT; - - if (pVuidMse->strmod) { - SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod)); - if (i < 0) { - xf86Msg(X_WARNING, - "%s: cannot push module '%s' onto mouse device: %s\n", - pInfo->name, pVuidMse->strmod, strerror(errno)); - xfree(pVuidMse->strmod); - pVuidMse->strmod = NULL; - } - } - SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt)); - if (i < 0) { - xf86Msg(X_WARNING, - "%s: cannot set mouse device to VUID mode: %s\n", - pInfo->name, strerror(errno)); - } - vuidMouseWheelInit(pInfo); -#ifdef HAVE_ABSOLUTE_MOUSE_SCALING - vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse); -#endif - xf86FlushInput(pInfo->fd); - } - break; - - case DEVICE_OFF: - case DEVICE_CLOSE: - if (pInfo->fd != -1) { - if (pVuidMse->strmod) { - SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod)); - if (i == -1) { - xf86Msg(X_WARNING, - "%s: cannot pop module '%s' off mouse device: %s\n", - pInfo->name, pVuidMse->strmod, strerror(errno)); - } - } - } - ret = pVuidMse->wrapped_device_control(pPointer, what); - break; - - default: /* Should never be called, but just in case */ - ret = pVuidMse->wrapped_device_control(pPointer, what); - break; - } - return ret; -} - -static Bool -sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - /* The protocol is guaranteed to be one of the internalNames[] */ - if (xf86NameCmp(protocol, "VUID") == 0) { - return vuidPreInit(pInfo, protocol, flags); - } - return TRUE; -} - -static const char ** -BuiltinNames(void) -{ - return internalNames; -} - -static Bool -CheckProtocol(const char *protocol) -{ - int i; - - for (i = 0; internalNames[i]; i++) - if (xf86NameCmp(protocol, internalNames[i]) == 0) - return TRUE; - - return FALSE; -} - -static const char * -DefaultProtocol(void) -{ - return "Auto"; -} - -static Bool -solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol, - const char **device) -{ - const char **pdev, **pproto, *dev = NULL; - int fd = -1; - Bool found; - - for (pdev = solarisMouseDevs; *pdev; pdev += 2) { - pproto = pdev + 1; - if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) && - (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) { - continue; - } - if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) { - continue; - } - SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); - if (fd == -1) { -#ifdef DEBUG - ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno)); -#endif - } else { - found = TRUE; - if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) { - int i, r; - SYSCALL(r = ioctl(fd, VUIDGFORMAT, &i)); - if (r < 0) { - found = FALSE; - } - } - close(fd); - if (found == TRUE) { - if (*pproto != NULL) { - *protocol = *pproto; - } - *device = *pdev; - return TRUE; - } - } - } - return FALSE; -} - -static const char * -SetupAuto(InputInfoPtr pInfo, int *protoPara) -{ - const char *pdev = NULL; - const char *pproto = NULL; - MouseDevPtr pMse = pInfo->private; - - if (pInfo->fd == -1) { - /* probe to find device/protocol to use */ - if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) { - /* Set the Device option. */ - pInfo->conf_idev->commonOptions = - xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev); - xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", - pInfo->name, pdev); - } - } else if (pMse->protocolID == PROT_AUTO) { - pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions, - "Device", NULL); - solarisMouseAutoProbe(pInfo, &pproto, &pdev); - } - return pproto; -} - -static const char * -FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) -{ - const char *pdev = NULL; - const char *pproto = protocol; - - if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) { - /* Set the Device option. */ - pInfo->conf_idev->commonOptions = - xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev); - xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", - pInfo->name, pdev); - } - return pdev; -} - -#else /* __SOL8__ || !__i386 */ - -#undef MSE_MISC -#define MSE_MISC 0 - -#endif /* !__SOL8__ && __i386 */ - -static int -SupportedInterfaces(void) -{ - /* XXX This needs to be checked. */ - return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_XPS2 | MSE_MISC; -} - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - p->SupportedInterfaces = SupportedInterfaces; -#if defined(__SOL8__) || !defined(__i386) - p->BuiltinNames = BuiltinNames; - p->CheckProtocol = CheckProtocol; - p->PreInit = sunMousePreInit; - p->DefaultProtocol = DefaultProtocol; - p->SetupAuto = SetupAuto; - p->FindDevice = FindDevice; -#endif - return p; -} - diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c deleted file mode 100644 index e7b529ccb..000000000 --- a/hw/xfree86/os-support/solaris/sun_vid.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * 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 the copyright holders not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. The 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 COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT - * SHALL THE 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. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <sys/types.h> /* get __x86 definition if not set by compiler */ - -#if defined(__i386__) || defined(__i386) || defined(__x86) -#define _NEED_SYSI86 -#endif -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -char *apertureDevName = NULL; - -_X_EXPORT Bool -xf86LinearVidMem(void) -{ - int mmapFd; - - if (apertureDevName) - return TRUE; - - apertureDevName = "/dev/xsvc"; - if ((mmapFd = open(apertureDevName, O_RDWR)) < 0) - { - apertureDevName = "/dev/fbs/aperture"; - if((mmapFd = open(apertureDevName, O_RDWR)) < 0) - { - xf86MsgVerb(X_WARNING, 0, - "xf86LinearVidMem: failed to open %s (%s)\n", - apertureDevName, strerror(errno)); - xf86MsgVerb(X_WARNING, 0, - "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc" - " device driver required\n"); - xf86MsgVerb(X_WARNING, 0, - "xf86LinearVidMem: linear memory access disabled\n"); - apertureDevName = NULL; - return FALSE; - } - } - close(mmapFd); - return TRUE; -} - -_X_EXPORT pointer -xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) -{ - pointer base; - int fd; - char vtname[20]; - - /* - * Solaris 2.1 x86 SVR4 (10/27/93) - * The server must treat the virtual terminal device file as the - * standard SVR4 /dev/pmem. - * - * Using the /dev/vtXX device as /dev/pmem only works for the - * A0000-FFFFF region - If we wish you mmap the linear aperture - * it requires a device driver. - * - * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and - * try to use the /dev/fbs/aperture or /dev/xsvc driver if the server - * tries to mmap anything > FFFFF. Its very very unlikely that the - * server will try to mmap anything below FFFFF that can't be handled - * by /dev/vtXX. - * - * DWH - 2/23/94 - * DWH - 1/31/99 (Gee has it really been 5 years?) - * - * Solaris 2.8 7/26/99 - * Use /dev/xsvc for everything - * - * DWH - 7/26/99 - Solaris8/dev/xsvc changes - * - * TSI - 2001.09 - SPARC changes - */ - -#if defined(__i386__) && !defined(__SOL8__) - if(Base < 0xFFFFF) - sprintf(vtname, "/dev/vt%02d", xf86Info.vtno); - else -#endif - { - if (!xf86LinearVidMem()) - FatalError("xf86MapVidMem: no aperture device\n"); - - strcpy(vtname, apertureDevName); - } - - fd = open(vtname, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - vtname, strerror(errno)); - - base = mmap(NULL, Size, - (Flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, (off_t)Base); - close(fd); - if (base == MAP_FAILED) - FatalError("xf86MapVidMem: mmap failure: %s\n", - strerror(errno)); - - return(base); -} - -/* ARGSUSED */ -_X_EXPORT void -xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap(Base, Size); -} - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -#if defined(__i386__) || defined(__i386) || defined(__x86) -static Bool ExtendedEnabled = FALSE; -#endif - -_X_EXPORT Bool -xf86EnableIO(void) -{ -#if defined(__i386__) || defined(__i386) || defined(__x86) - if (ExtendedEnabled) - return TRUE; - - if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) { - xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n"); - return FALSE; - } - ExtendedEnabled = TRUE; -#endif /* i386 */ - return TRUE; -} - -_X_EXPORT void -xf86DisableIO(void) -{ -#if defined(__i386__) || defined(__i386) || defined(__x86) - if(!ExtendedEnabled) - return; - - sysi86(SI86V86, V86SC_IOPL, 0); - - ExtendedEnabled = FALSE; -#endif /* i386 */ -} - - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool xf86DisableInterrupts(void) -{ -#if defined(__i386__) || defined(__i386) || defined(__x86) - if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)) - return FALSE; - -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - asm("cli"); -#endif /* __GNUC__ */ - - if (!ExtendedEnabled) - sysi86(SI86V86, V86SC_IOPL, 0); -#endif /* i386 */ - - return TRUE; -} - -_X_EXPORT void xf86EnableInterrupts(void) -{ -#if defined(__i386__) || defined(__i386) || defined(__x86) - if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)) - return; - -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - asm("sti"); -#endif /* __GNUC__ */ - - if (!ExtendedEnabled) - sysi86(SI86V86, V86SC_IOPL, 0); -#endif /* i386 */ -} - -_X_EXPORT void -xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, - unsigned long Size) -{ -} - -_X_EXPORT Bool -xf86CheckMTRR(int ScreenNum) -{ - return FALSE; -} - diff --git a/hw/xfree86/os-support/sysv/Makefile.am b/hw/xfree86/os-support/sysv/Makefile.am deleted file mode 100644 index f9d2f237a..000000000 --- a/hw/xfree86/os-support/sysv/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -EXTRA_DIST = sysv_init.c sysv_mouse.c sysv_video.c diff --git a/hw/xfree86/os-support/sysv/sysv_init.c b/hw/xfree86/os-support/sysv/sysv_init.c deleted file mode 100644 index 170bb8914..000000000 --- a/hw/xfree86/os-support/sysv/sysv_init.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Thomas Roell and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Thomas Roell and - * David Wexelblat makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include <X11/Xmd.h> - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -static Bool KeepTty = FALSE; -#ifdef SVR4 -static Bool Protect0 = FALSE; -#endif -static int VTnum = -1; - - -void -xf86OpenConsole() -{ - int fd; - struct vt_mode VT; - char vtname1[10],vtname2[10]; - MessageType from = X_PROBED; - - if (serverGeneration == 1) - { - /* check if we're run with euid==0 */ - if (geteuid() != 0) - { - FatalError("xf86OpenConsole: Server must be 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) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: cannot open /dev/zero (%s)\n", - strerror(errno)); - } - else - { - if ((int)mmap(0, 0x1000, PROT_NONE, - MAP_FIXED | MAP_SHARED, fd, 0) == -1) - { - xf86Msg(X_WARNING, - "xf86OpenConsole: failed to protect page 0 (%s)\n", - strerror(errno)); - } - close(fd); - } - } -#endif - /* - * setup the virtual terminal manager - */ - if (VTnum != -1) - { - xf86Info.vtno = VTnum; - from = X_CMDLINE; - } - 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); - } - xf86Msg(from, "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 */ - - 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) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "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) - { - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); - } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) - { - xf86Msg(X_WARNING, "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 (!xf86Screens[0]->vtSema) - 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(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; -} diff --git a/hw/xfree86/os-support/sysv/sysv_mouse.c b/hw/xfree86/os-support/sysv/sysv_mouse.c deleted file mode 100644 index e62010515..000000000 --- a/hw/xfree86/os-support/sysv/sysv_mouse.c +++ /dev/null @@ -1,60 +0,0 @@ - -/* - * Copyright 1999 by The XFree86 Project, Inc. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "xf86.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" - -static int -SupportedInterfaces(void) -{ - /* XXX Need to check this. */ - return MSE_SERIAL | MSE_AUTO; -} - -#ifndef ISC -static const char *internalNames[] = { - NULL -}; - -static const char ** -BuiltinNames(void) -{ - return internalNames; -} - -static Bool -CheckProtocol(const char *protocol) -{ - int i; - - for (i = 0; internalNames[i]; i++) - if (xf86NameCmp(protocol, internalNames[i]) == 0) - return TRUE; - return FALSE; -} -#endif - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - p->SupportedInterfaces = SupportedInterfaces; -#ifndef ISC - p->BuiltinNames = BuiltinNames; - p->CheckProtocol = CheckProtocol; -#endif - return p; -} - diff --git a/hw/xfree86/os-support/sysv/sysv_video.c b/hw/xfree86/os-support/sysv/sysv_video.c deleted file mode 100644 index 9972bcaa4..000000000 --- a/hw/xfree86/os-support/sysv/sysv_video.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany - * Copyright 1993 by David Wexelblat <dwex@goblin.org> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of Thomas Roell and David Wexelblat - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. Thomas Roell and - * David Wexelblat makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR - * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF - * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -#ifndef SI86IOPL -#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL) -#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0) -#else -#define SET_IOPL() sysi86(SI86IOPL,3) -#define RESET_IOPL() sysi86(SI86IOPL,0) -#endif - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -/* - * XXX Support for SVR3 will need to be reworked if needed. In particular - * the Region parameter is no longer passed, and will need to be dealt - * with internally if required. - * OK, i'll rework that thing ... (clean it up a lot) - * SVR3 Support only with SVR3_MMAPDRV (mr) - * - */ - -#ifdef HAS_SVR3_MMAPDRV -#ifndef MMAP_DEBUG -#define MMAP_DEBUG 3 -#endif - -struct kd_memloc MapDSC; -int mmapFd = -2; - -static int -mmapStat(pointer Base, unsigned long Size) { - - int nmmreg,i=0,region=-1; - mmapinfo_t *ibuf; - - nmmreg = ioctl(mmapFd, GETNMMREG); - - if(nmmreg <= 0) - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "\nNo physical memory mapped currently.\n\n"); - else { - if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL) - xf86Msg(X_WARNING, - "Couldn't allocate memory 4 mmapinfo_t\n"); - else { - if(ioctl(mmapFd, GETMMREG, ibuf) != -1) - { - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# mmapStat: [Size=%x,Base=%x]\n", Size, Base); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# Physical Address Size Reference Count\n"); - for(i = 0; i < nmmreg; i++) { - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "%-4d 0x%08X %5dk %5d ", - i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt); - if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) { - xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!"); - if (region==-1) region=i; - } - xf86ErrorFVerb(MMAP_DEBUG, "\n"); - } - xf86ErrorFVerb(MMAP_DEBUG, "\n"); - } - free(ibuf); - } - } - if (region == -1 && nmmreg > 0) region=region * i; - return(region); -} -#endif - - -static Bool -linearVidMem() -{ -#ifdef SVR4 - return TRUE; -#elif defined(HAS_SVR3_MMAPDRV) - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# xf86LinearVidMem: MMAP 2.2.2 called\n"); - - if(mmapFd >= 0) return TRUE; - - if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) - { - if(ioctl(mmapFd, GETVERSION) < 0x0222) { - xf86Msg(X_WARNING, - "xf86LinearVidMem: MMAP 2.2.2 or above required\n"); - xf86ErrorF("\tlinear memory access disabled\n"); - return FALSE; - } - return TRUE; - } - xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n", - strerror(errno)); - xf86ErrorF("\tlinear memory access disabled\n"); - return FALSE; -#endif -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - int fd; - -#if defined(SVR4) - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) - { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, - (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, (off_t)Base); - close(fd); - if (base == MAP_FAILED) - { - FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", Size, Base, strerror(errno)); - } -#else /* SVR4 */ -#ifdef HAS_SVR3_MMAPDRV - - xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n"); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); - if (ioctl(mmapFd, GETVERSION) == -1) - { - xf86LinearVidMem(); - } - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION)); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: Screen: %d\n", ScreenNum); - mmapStat(Base,Size); - /* To force the MMAP driver to provide the address */ - base = (pointer)0; - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base); - MapDSC.vaddr = (char *)base; - MapDSC.physaddr = (char *)Base; - MapDSC.length = Size; - MapDSC.ioflg = 1; - if(mmapFd >= 0) - { - if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1) - { - FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", Size, Base, strerror(errno)); - /* NOTREACHED */ - } - - /* Next time we want the same address! */ - MapDSC.vaddr = (char *)base; - } - - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "MapDSC.length : %d\n", MapDSC.length); - mmapStat(Base,Size); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n"); -#endif /* HAS_SVR3_MMAPDRV */ -#endif /* SVR4 */ - return(base); -} - -/* ARGSUSED */ -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ -#if defined (SVR4) - munmap(Base, Size); -#else /* SVR4 */ -#ifdef HAS_SVR3_MMAPDRV - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# xf86UnMapVidMem: UNMapping FrameBuffer\n"); - mmapStat(Base,Size); - ioctl(mmapFd, UNMAPRM , Base); - mmapStat(Base,Size); - xf86MsgVerb(X_INFO, MMAP_DEBUG, - "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base); -#endif /* HAS_SVR3_MMAPDRV */ -#endif /* SVR4 */ - return; -} - -#if defined(SVR4) && defined(__i386__) && !defined(sun) -/* - * For some SVR4 versions, a 32-bit read is done for the first location - * in each page when the page is first mapped. If this is done while - * memory access is enabled for regions that have read side-effects, - * this can cause unexpected results, including lockups on some hardware. - * This function is called to make sure each page is mapped while it is - * safe to do so. - */ - -/* - * XXX Should get this the correct way (see os/xalloc.c), but since this is - * for one platform I'll be lazy. - */ -#define X_PAGE_SIZE 4096 - -static void -readSideEffects(int ScreenNum, pointer Base, unsigned long Size) -{ - unsigned long base, end, addr; - CARD32 val; - - base = (unsigned long)Base; - end = base + Size; - - for (addr = base; addr < end; addr += X_PAGE_SIZE) - val = *(volatile CARD32 *)addr; -} -#endif - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = linearVidMem(); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; -#if defined(SVR4) && defined(__i386__) && !defined(sun) - pVidMem->readSideEffects = readSideEffects; -#endif - pVidMem->initialised = TRUE; -} - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -static Bool ExtendedEnabled = FALSE; -static Bool InitDone = FALSE; - -_X_EXPORT Bool -xf86EnableIO() -{ - int i; - - if (ExtendedEnabled) - return TRUE; - - if (SET_IOPL() < 0) - { - xf86Msg(X_WARNING, - "xf86EnableIO: Failed to set IOPL for extended I/O\n"); - return FALSE; - } - ExtendedEnabled = TRUE; - - return TRUE; -} - -_X_EXPORT void -xf86DisableIO() -{ - if (!ExtendedEnabled) - return; - - RESET_IOPL(); - ExtendedEnabled = FALSE; - - return; -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts() -{ - if (!ExtendedEnabled) - { - if (SET_IOPL() < 0) - { - return(FALSE); - } - } - -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - asm("cli"); -#endif /* __GNUC__ */ - - if (!ExtendedEnabled) - { - RESET_IOPL(); - } - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts() -{ - if (!ExtendedEnabled) - { - if (SET_IOPL() < 0) - { - return; - } - } - -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - asm("sti"); -#endif /* __GNUC__ */ - - if (!ExtendedEnabled) - { - RESET_IOPL(); - } - return; -} diff --git a/hw/xfree86/os-support/usl/Makefile.am b/hw/xfree86/os-support/usl/Makefile.am deleted file mode 100644 index db08f5d85..000000000 --- a/hw/xfree86/os-support/usl/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -EXTRA_DIST = \ - usl_init.c \ - usl_iop.c \ - usl_mouse.c \ - usl_video.c \ - usl_vtsw.c diff --git a/hw/xfree86/os-support/usl/usl_init.c b/hw/xfree86/os-support/usl/usl_init.c deleted file mode 100644 index d27b206c8..000000000 --- a/hw/xfree86/os-support/usl/usl_init.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright 2001-2005 by Kean Johnston <jkj@sco.com> - * 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, David Wexelblat - * and Kean Johnston not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * Thomas Roell, David Wexelblat and Kean Johnston make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THOMAS ROELL, DAVID WEXELBLAT AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT - * OR KEAN JOHNSTON 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. - * - */ - -#include "X.h" -#include "Xmd.h" - -#include "compiler.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -#include <sys/utsname.h> - -static Bool KeepTty = FALSE; -static Bool Protect0 = FALSE; -static Bool CRTSpecified = FALSE; -static int VTnum = -1; -static char vtdevice[48]; - -int usl_is_osr6 = -1; - -static Bool -IsConsoleDevice(const char *dev) -{ - if ((!strcmp (dev, "/dev/console")) || - (!strcmp (dev, "/dev/syscon")) || - (!strcmp (dev, "/dev/systty"))) - return TRUE; - - return FALSE; -} - -static int -is_osr6 (void) -{ - struct utsname uts; - - if (usl_is_osr6 == -1) { - if (uname (&uts) < 0) { - FatalError ("get_usl_ver: Failed to determine UNIX name (%s)\n", - strerror (errno)); - } - - if (uts.version[0] == '6') - usl_is_osr6 = 1; - else - usl_is_osr6 = 0; - } - - return usl_is_osr6; -} - - -void -xf86OpenConsole(void) -{ - int fd, i, ioctl_ret; - struct vt_mode VT; - struct vt_stat vts; - MessageType from = X_PROBED; - struct sigaction sigvtsw; - char *ttn; - - if (serverGeneration == 1) { - int isconsole = 0, consdev = 0; - - /* check if we're run with euid==0 */ - if (geteuid() != 0) { - FatalError("xf86OpenConsole: Server must be suid root\n"); - } - - /* If we are run in the background we will get SIGTTOU. Ignore it. */ - OsSignal (SIGTTOU, SIG_IGN); - - /* 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) { - xf86Msg(X_WARNING, "xf86OpenConsole: cannot open /dev/zero (%s)\n", - strerror(errno)); - } else { - if ((int)mmap(0, 0x1000, PROT_NONE, - MAP_FIXED | MAP_SHARED, fd, 0) == -1) { - xf86Msg(X_WARNING, "xf86OpenConsole: failed to protect page 0 (%s)\n", - strerror(errno)); - } - close(fd); - } - } - - /* - * setup the virtual terminal manager - */ - if (VTnum == -1) { - /* - * No device was specified. We need to query the kernel to see which - * console device we are on (and in fact if we are on a console at all). - */ - if (ioctl (0, VT_GETSTATE, &vts) < 0) { - FatalError("xf86OpenConsole: Could not query active VT: %s\n", - strerror(errno)); - } - VTnum = vts.v_active; - if (is_osr6()) - snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1); - else - snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum); - } else { - from = X_CMDLINE; - if (is_osr6()) - snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1); - else - snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum); - } - - if (IsConsoleDevice(vtdevice)) { - isconsole = 1; - CRTSpecified = FALSE; /* Dont honour -crt /dev/console */ - } - - if (ioctl (0, KIOCINFO, 0) >= 0) - consdev = 1 + isconsole; - - if ((!CRTSpecified) && (isconsole || (!consdev))) { - /* - * Need to find a free VT - */ - if ((fd = open ("/dev/console", O_WRONLY | O_NOCTTY)) < 0) { - FatalError ("xf86OpenConsole: Could not open /dev/console: %s\n", - strerror (errno)); - } - - if (ioctl (fd, VT_OPENQRY, &VTnum) < 0) { - FatalError ("xf86OpenConsole: Cannot find a free VT: %s\n", - strerror(errno)); - } - close (fd); - if (usl_is_osr6) - snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum + 1); - else - snprintf (vtdevice, sizeof(vtdevice), "/dev/vt%02d", VTnum); - } - - /* - * Now we can dispose of stdin/stdout - */ - fclose (stdin); - fclose (stdout); - - if (CRTSpecified || isconsole || consdev != 1) { - if (!KeepTty) { - setpgrp(); - } - } - - if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NONBLOCK, 0)) < 0) { - FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice, - strerror(errno)); - } - - xf86Msg (from, "using VT number %d (%s)\n\n", VTnum, vtdevice); - xf86Info.vtno = VTnum; - - /* change ownership of the vt */ - chown(vtdevice, getuid(), getgid()); - - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { - FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) { - FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",strerror(errno)); - } - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) { - FatalError("xf86OpenConsole: VT_GETMODE failed: %s\n", strerror(errno)); - } - - sigvtsw.sa_handler = xf86VTRequest; - sigfillset(&sigvtsw.sa_mask); - sigvtsw.sa_flags = 0; - sigaction(SIGUSR1, &sigvtsw, NULL); - - VT.mode = VT_PROCESS; - VT.relsig = SIGUSR1; - VT.acqsig = SIGUSR1; - - ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); - if (ioctl_ret < 0) { - FatalError("xf86OpenConsole: VT_SETMODE failed: %s\n", strerror(errno)); - } - - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { - FatalError("xf86OpenConsole: KD_GRAPHICS failed: %s\n", strerror(errno)); - } - } else { /* serverGeneration != 1 */ - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) { - FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", strerror(errno)); - } - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) { - FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",strerror(errno)); - } - /* - * 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 (!xf86Screens[0]->vtSema) - sleep(5); - } - return; -} - -void -xf86CloseConsole(void) -{ - struct vt_mode VT; - struct sigaction sigvtsw; - - ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ - - sigvtsw.sa_handler = SIG_DFL; - sigfillset(&sigvtsw.sa_mask); - sigvtsw.sa_flags = 0; - sigaction(SIGUSR1, &sigvtsw, NULL); - - if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) { - VT.mode = VT_AUTO; - VT.waitv = 0; - ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ - } - close(xf86Info.consoleFd); /* make the vt-manager happy */ - return; -} - -int -xf86ProcessArgument(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); - } - - /* - * 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); - } - - if ((argv[i][0] == 'v') && (argv[i][1] == 't')) { - if (sscanf(argv[i], "vt%2d", &VTnum) == 0) { - UseMsg(); - VTnum = -1; - return(0); - } - VTnum -= is_osr6(); - CRTSpecified = TRUE; - return(1); - } - - /* - * Use a device the user specifies. - */ - if (!strcmp(argv[i], "-crt")) { - if (++i > argc) { - UseMsg(); - VTnum = -1; - return(0); - } else { - char *mytty = ttyname(0); - char *arg = argv[i]; - - if (!mytty) - mytty = "\1"; - if (!arg[0]) - arg = "\2"; /* Prevent idiots from using -crt "" */ - - if (strcmp (mytty, arg) != 0) { - char *fmt; - - if (is_osr6()) - fmt = "/dev/tty%02d"; - else - fmt = "/dev/vt%02d"; - - if (sscanf(arg, fmt, &VTnum) == 0) { - UseMsg(); - VTnum = -1; - return(0); - } - - /* OSR6 devices start names at 1, UW7 starts at 0 */ - VTnum -= is_osr6(); - CRTSpecified = TRUE; - } - return(2); - } - } - return(0); -} - -void -xf86UseMsg(void) -{ - if (is_osr6()) { - ErrorF("-crt /dev/ttyXX use the specified VT device\n"); - ErrorF("vtXX use the specified VT number (01-16)\n"); - } else { - ErrorF("-crt /dev/vtXX use the specified VT device\n"); - ErrorF("vtXX use the specified VT number (00-15)\n"); - } - - ErrorF("-keeptty "); - ErrorF("don't detach controlling tty (for debugging only)\n"); - return; -} diff --git a/hw/xfree86/os-support/usl/usl_iop.c b/hw/xfree86/os-support/usl/usl_iop.c deleted file mode 100644 index c6382fc7e..000000000 --- a/hw/xfree86/os-support/usl/usl_iop.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2001,2005 by Kean Johnston <jkj@sco.com> - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEAN JOHNSTON 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. - */ - - -#include "X.h" - -#include "compiler.h" - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86OSpriv.h" -#include "xf86_OSlib.h" - - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -static Bool IOEnabled = FALSE; - -_X_EXPORT Bool -xf86EnableIO(void) -{ - if (IOEnabled) - return TRUE; - - if (sysi86(SI86IOPL, 3) < 0) - FatalError("Failed to set IOPL for extended I/O\n"); - IOEnabled = TRUE; - return TRUE; -} - -_X_EXPORT void -xf86DisableIO(void) -{ - if (!IOEnabled) - return; - - sysi86(SI86IOPL, 0); - IOEnabled = FALSE; -} - -/***************************************************************************/ -/* Interrupt Handling section */ -/***************************************************************************/ - -_X_EXPORT Bool -xf86DisableInterrupts(void) -{ - if (!IOEnabled) { - if (sysi86(SI86IOPL, 3) < 0) - return FALSE; - } - -#ifdef __GNUC__ - __asm__ __volatile__("cli"); -#else - asm("cli"); -#endif /* __GNUC__ */ - - if (!IOEnabled) { - sysi86(SI86IOPL, 0); - } - - return(TRUE); -} - -_X_EXPORT void -xf86EnableInterrupts(void) -{ - if (!IOEnabled) { - if (sysi86(SI86IOPL, 3) < 0) - return; - } - -#ifdef __GNUC__ - __asm__ __volatile__("sti"); -#else - asm("sti"); -#endif /* __GNUC__ */ - - if (!IOEnabled) { - sysi86(SI86IOPL, 0); - } -} - diff --git a/hw/xfree86/os-support/usl/usl_mouse.c b/hw/xfree86/os-support/usl/usl_mouse.c deleted file mode 100644 index aa4600f79..000000000 --- a/hw/xfree86/os-support/usl/usl_mouse.c +++ /dev/null @@ -1,177 +0,0 @@ - -/* - * Copyright 2005 Kean Johnston - * Copyright 1999 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 XFree86 Project, Inc - * and Kean Johnston not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * The XFree86 Project, Inc and Kean Johnston make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THE XFREE86 PROJECT, INC AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT - * OR KEAN JOHNSTON 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. - * - */ - -#include "X.h" -#include "compiler.h" -#include "xf86.h" -#include "xf86Xinput.h" -#include "xf86OSmouse.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "mipointer.h" - -static int -SupportedInterfaces(void) -{ - return MSE_MISC; -} - -static const char *internalNames[] = { - NULL -}; - -static const char ** -BuiltinNames(void) -{ - return internalNames; -} - -static const char * -DefaultProtocol (void) -{ - return "OSMouse"; -} - -static Bool -CheckProtocol(const char *protocol) -{ - int i; - - for (i = 0; internalNames[i]; i++) - if (xf86NameCmp(protocol, internalNames[i]) == 0) - return TRUE; - return FALSE; -} - -static int -OsMouseProc(DeviceIntPtr pPointer, int what) -{ - InputInfoPtr pInfo; - MouseDevPtr pMse; - unsigned char map[9]; - int ret; - - pInfo = pPointer->public.devicePrivate; - pMse = pInfo->private; - pMse->device = pPointer; - - switch (what) { - case DEVICE_INIT: - pPointer->public.on = FALSE; - - for (ret = 0; ret <= 8; ret++) - map[ret] = ret; - - InitPointerDeviceStruct((DevicePtr)pPointer, map, 8, - miPointerGetMotionEvents, pMse->Ctrl, - miPointerGetMotionBufferSize()); - /* X valuator */ - xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); - xf86InitValuatorDefaults(pPointer, 0); - - /* Y valuator */ - xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); - xf86InitValuatorDefaults(pPointer, 1); - - xf86MotionHistoryAllocate(pInfo); - break; - - case DEVICE_ON: - pMse->lastButtons = 0; - pMse->emulateState = 0; - pPointer->public.on = TRUE; - XqMseOnOff (pInfo, 1); - break; - - case DEVICE_CLOSE: - case DEVICE_OFF: - pPointer->public.on = FALSE; - XqMseOnOff (pInfo, 0); - break; - } - return Success; -} - -static Bool -OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) -{ - MouseDevPtr pMse; - - pMse = pInfo->private; - pMse->protocol = protocol; - xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); - - /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); - xf86ProcessCommonOptions(pInfo, pInfo->options); - - pInfo->fd = -1; -#if 0 - /* Make sure we can open the mouse */ - pInfo->fd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK); - - if (pInfo->fd < 0) { - if (xf86GetAllowMouseOpenFail()) { - xf86Msg(X_WARNING, "%s: cannot open /dev/mouse (%s)\n", - pInfo->name, strerror(errno)); - } else { - xf86Msg(X_ERROR, "%s: cannot open /dev/mouse (%s)\n", - pInfo->name, strerror(errno)); - xfree(pMse); - return FALSE; - } - } -#endif - - /* Process common mouse options (like Emulate3Buttons, etc). */ - pMse->CommonOptions(pInfo); - - /* Setup the local procs. */ - pInfo->device_control = OsMouseProc; - pInfo->read_input = NULL; - - pInfo->flags |= XI86_CONFIGURED; - return TRUE; -} - -_X_EXPORT OSMouseInfoPtr -xf86OSMouseInit(int flags) -{ - OSMouseInfoPtr p; - - p = xcalloc(sizeof(OSMouseInfoRec), 1); - if (!p) - return NULL; - - p->SupportedInterfaces = SupportedInterfaces; - p->BuiltinNames = BuiltinNames; - p->DefaultProtocol = DefaultProtocol; - p->CheckProtocol = CheckProtocol; - p->PreInit = OsMousePreInit; - return p; -} - diff --git a/hw/xfree86/os-support/usl/usl_video.c b/hw/xfree86/os-support/usl/usl_video.c deleted file mode 100644 index 41abd2259..000000000 --- a/hw/xfree86/os-support/usl/usl_video.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyrught 2005 Kean Johnston <jkj@sco.com> - * 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, David Dawes - * and Kean Johnston not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior permission. - * Thomas Roell, David Dawes and Kean Johnston make no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * THOMAS ROELL, DAVID DAWES AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT - * OR KEAN JOHNSTON 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. - * - */ - -#include "X.h" - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" -#include "xf86OSpriv.h" - -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) -#endif - -static Bool -linearVidMem(void) -{ - return TRUE; -} - -static pointer -mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - pointer base; - int fd; - - fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", - DEV_MEM, strerror(errno)); - } - base = mmap((caddr_t)0, Size, (flags & VIDMEM_READONLY) ? - PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, (off_t)Base); - close(fd); - - if (base == MAP_FAILED) { - FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", - "xf86MapVidMem", Size, Base, strerror(errno)); - } - return(base); -} - -/* ARGSUSED */ -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ - munmap(Base, Size); -} - -/* - * For some SVR4 versions, a 32-bit read is done for the first location - * in each page when the page is first mapped. If this is done while - * memory access is enabled for regions that have read side-effects, - * this can cause unexpected results, including lockups on some hardware. - * This function is called to make sure each page is mapped while it is - * safe to do so. - */ - -#define X_PAGE_SIZE 4096 - -static void -readSideEffects(int ScreenNum, pointer Base, unsigned long Size) -{ - unsigned long base, end, addr; - CARD32 val; - - base = (unsigned long)Base; - end = base + Size; - - for (addr = base; addr < end; addr += X_PAGE_SIZE) - val = *(volatile CARD32 *)addr; -} - -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - pVidMem->linearSupported = linearVidMem(); - pVidMem->mapMem = mapVidMem; - pVidMem->unmapMem = unmapVidMem; - pVidMem->readSideEffects = readSideEffects; - pVidMem->initialised = TRUE; -} - diff --git a/hw/xfree86/os-support/usl/usl_vtsw.c b/hw/xfree86/os-support/usl/usl_vtsw.c deleted file mode 100644 index 812e5bddb..000000000 --- a/hw/xfree86/os-support/usl/usl_vtsw.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2005 by Kean Johnston <jkj@sco.com> - * 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. - * - */ - -#include "X.h" - -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86_OSlib.h" - -/* - * Handle the VT-switching interface for SCO UnixWare / OpenServer 6 - */ - -/* - * This function is the signal handler for the VT-switching signal. It - * is only referenced inside the OS-support layer. NOTE: we do NOT need - * to re-arm the signal here, since we used sigaction() to set the signal - * disposition in usl_init.c. If we had used signal(), we would need to - * re-arm the signal here. All we need to do now is record the fact that - * we got the signal. XFree86 handles the rest. - */ -void -xf86VTRequest(int sig) -{ - xf86Info.vtRequestsPending = TRUE; - return; -} - -Bool -xf86VTSwitchPending(void) -{ - return(xf86Info.vtRequestsPending ? TRUE : FALSE); -} - -static int usl_ledstatus = -1; -static unsigned int usl_ledstate = 0; - -Bool -xf86VTSwitchAway(void) -{ - usl_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &usl_ledstate); - - xf86Info.vtRequestsPending = FALSE; - if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) { - return(FALSE); - } else { - return(TRUE); - } -} - -Bool -xf86VTSwitchTo(void) -{ - xf86Info.vtRequestsPending = FALSE; - if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) { - return(FALSE); - } else { - if (usl_ledstatus >= 0) { - ioctl (xf86Info.consoleFd, KDSETLED, usl_ledstate); - } - usl_ledstatus = -1; - - /* - * Convince the console driver this screen is in graphics mode, - * otherwise it assumes it can do more to the screen than it should. - */ - if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) { - ErrorF("Failed to set graphics mode (%s)\n", strerror(errno)); - } - - return TRUE; - } -} diff --git a/hw/xfree86/os-support/xf86OSmouse.h b/hw/xfree86/os-support/xf86OSmouse.h deleted file mode 100644 index 600683866..000000000 --- a/hw/xfree86/os-support/xf86OSmouse.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (c) 1999-2003 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* Public interface to OS-specific mouse support. */ - -#ifndef _XF86OSMOUSE_H_ -#define _XF86OSMOUSE_H_ - -#include "xf86Xinput.h" - -/* Mouse interface classes */ -#define MSE_NONE 0x00 -#define MSE_SERIAL 0x01 /* serial port */ -#define MSE_BUS 0x02 /* old bus mouse */ -#define MSE_PS2 0x04 /* standard read-only PS/2 */ -#define MSE_XPS2 0x08 /* extended PS/2 */ -#define MSE_AUTO 0x10 /* auto-detect (PnP) */ -#define MSE_MISC 0x20 /* The OS layer will identify the - * specific protocol names that are - * supported for this class. */ - -/* Mouse Protocol IDs. */ -typedef enum { - PROT_UNKNOWN = -2, - PROT_UNSUP = -1, /* protocol is not supported */ - PROT_MS = 0, - PROT_MSC, - PROT_MM, - PROT_LOGI, - PROT_LOGIMAN, - PROT_MMHIT, - PROT_GLIDE, - PROT_IMSERIAL, - PROT_THINKING, - PROT_ACECAD, - PROT_VALUMOUSESCROLL, - PROT_PS2, - PROT_GENPS2, - PROT_IMPS2, - PROT_EXPPS2, - PROT_THINKPS2, - PROT_MMPS2, - PROT_GLIDEPS2, - PROT_NETPS2, - PROT_NETSCPS2, - PROT_BM, - PROT_AUTO, - PROT_SYSMOUSE, - PROT_NUMPROTOS /* This must always be last. */ -} MouseProtocolID; - -struct _MouseDevRec; - -typedef int (*GetInterfaceTypesProc)(void); -typedef const char **(*BuiltinNamesProc)(void); -typedef Bool (*CheckProtocolProc)(const char *protocol); -typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol, - int flags); -typedef const char *(*DefaultProtocolProc)(void); -typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara); -typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate, - int res); -typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol, - int flags); -typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags); - -/* - * OSMouseInfoRec is used to pass information from the OSMouse layer to the - * OS-independent mouse driver. - */ -typedef struct { - GetInterfaceTypesProc SupportedInterfaces; - BuiltinNamesProc BuiltinNames; - CheckProtocolProc CheckProtocol; - BuiltinPreInitProc PreInit; - DefaultProtocolProc DefaultProtocol; - SetupAutoProc SetupAuto; - SetResProc SetPS2Res; - SetResProc SetBMRes; - SetResProc SetMiscRes; - FindDeviceProc FindDevice; - GuessProtocolProc GuessProtocol; -} OSMouseInfoRec, *OSMouseInfoPtr; - -/* - * SupportedInterfaces: Returns the mouse interface types that the OS support. - * If MSE_MISC is returned, then the BuiltinNames and - * CheckProtocol should be set. - * - * BuiltinNames: Returns the names of the protocols that are fully handled - * in the OS-specific code. These are names that don't appear - * directly in the main "mouse" driver. - * - * CheckProtocol: Checks if the protocol name given is supported by the - * OS. It should return TRUE for both "builtin" protocols and - * protocols of type MSE_MISC that are supported by the OS. - * - * PreInit: The PreInit function for protocols that are builtin. This - * function is passed the protocol name. - * - * DefaultProtocol: Returns the name of a default protocol that should be used - * for the OS when none has been supplied in the config file. - * This should only be set when there is a reasonable default. - * - * SetupAuto: This function can be used to do OS-specific protocol - * auto-detection. It returns the name of the detected protocol, - * or NULL when detection fails. It may also adjust one or more - * of the "protoPara" values for the detected protocol by setting - * then to something other than -1. SetupAuto gets called in two - * ways. The first is before any devices have been opened. This - * can be used when the protocol "Auto" always maps to a single - * protocol type. The second is with the device open, allowing - * OS-specific probing to be done. - * - * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2 - * protocol types. - * - * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types. - * - * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types. - * - * FindDevice: This function gets called when no Device has been specified - * in the config file. OS-specific methods may be used to guess - * which input device to use. This function is called after the - * pre-open attempts at protocol discovery are done, but before - * the device is open. I.e., after the first SetupAuto() call, - * after the DefaultProtocol() call, but before the PreInit() - * call. Available protocol information may be used in locating - * the default input device. - * - * GuessProtocol: A last resort attempt at guessing the mouse protocol by - * whatever OS-specific means might be available. OS-independent - * things should be in the mouse driver. This function gets - * called after the mouse driver's OS-independent methods have - * failed. - */ - -extern OSMouseInfoPtr xf86OSMouseInit(int flags); - -/* Adjust this when the mouse interface changes. */ - -/* - * History: - * - * 1.0.0 - Everything up to when versioning was started. - * 1.1.0 - FindDevice and GuessProtocol added to OSMouseInfoRec - * 1.2.0 - xisbscale added to MouseDevRec - * - */ - -#define OS_MOUSE_VERSION_MAJOR 1 -#define OS_MOUSE_VERSION_MINOR 2 -#define OS_MOUSE_VERSION_PATCH 0 - -#define OS_MOUSE_VERSION_CURRENT \ - BUILTIN_INTERFACE_VERSION_NUMERIC(OS_MOUSE_VERSION_MAJOR, \ - OS_MOUSE_VERSION_MINOR, \ - OS_MOUSE_VERSION_PATCH) - -#define HAVE_GUESS_PROTOCOL \ - (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \ - BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0)) - -#define HAVE_FIND_DEVICE \ - (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \ - BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0)) - -/* Z axis mapping */ -#define MSE_NOZMAP 0 -#define MSE_MAPTOX -1 -#define MSE_MAPTOY -2 -#define MSE_MAPTOZ -3 -#define MSE_MAPTOW -4 - -/* Generalize for other axes. */ -#define MSE_NOAXISMAP MSE_NOZMAP - -#define MSE_MAXBUTTONS 24 -#define MSE_DFLTBUTTONS 3 - -/* - * Mouse device record. This is shared by the mouse driver and the OSMouse - * layer. - */ - -typedef void (*checkMovementsProc)(InputInfoPtr,int, int); -typedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool); -typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char); -typedef Bool (*dataGoodProc)(struct _MouseDevRec *); - -typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons, - int dx, int dy, int dz, int dw); -typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo); - -typedef struct _MouseDevRec { - PtrCtrlProcPtr Ctrl; - PostMseEventProc PostEvent; - MouseCommonOptProc CommonOptions; - DeviceIntPtr device; - const char * mseDevice; - const char * protocol; - MouseProtocolID protocolID; - MouseProtocolID oldProtocolID; /* hack */ - int class; - int mseModel; - int baudRate; - int oldBaudRate; - int sampleRate; - int lastButtons; - int threshold; /* acceleration */ - int num; - int den; - int buttons; /* # of buttons */ - int emulateState; /* automata state for 2 button mode */ - Bool emulate3Buttons; - Bool emulate3ButtonsSoft; - int emulate3Timeout;/* Timeout for 3 button emulation */ - Bool chordMiddle; - Bool flipXY; - int invX; - int invY; - int mouseFlags; /* Flags to Clear after opening - * mouse dev */ - int truebuttons; /* (not used) - * Arg to maintain before - * emulate3buttons timer callback */ - int resolution; - int negativeZ; /* button mask */ - int positiveZ; /* button mask */ - int negativeW; /* button mask */ - int positiveW; /* button mask */ - pointer buffer; /* usually an XISBuffer* */ - int protoBufTail; - unsigned char protoBuf[8]; - unsigned char protoPara[8]; - unsigned char inSync; /* driver in sync with datastream */ - pointer mousePriv; /* private area */ - InputInfoPtr pInfo; - int origProtocolID; - const char * origProtocol; - Bool emulate3Pending;/* timer waiting */ - CARD32 emulate3Expires;/* time to fire emulation code */ - Bool emulateWheel; - int wheelInertia; - int wheelButton; - int negativeX; /* Button values. Unlike the Z and */ - int positiveX; /* W equivalents, these are button */ - int negativeY; /* values rather than button masks. */ - int positiveY; - int wheelYDistance; - int wheelXDistance; - Bool autoProbe; - checkMovementsProc checkMovements; - autoProbeProc autoProbeMouse; - collectDataProc collectData; - dataGoodProc dataGood; - int angleOffset; - pointer pDragLock; /* drag lock area */ - int xisbscale; /* buffer size for 1 event */ - int wheelButtonTimeout;/* Timeout for the wheel button emulation */ - CARD32 wheelButtonExpires; - int doubleClickSourceButtonMask; - int doubleClickTargetButton; - int doubleClickTargetButtonMask; - int doubleClickOldSourceState; - int lastMappedButtons; - int buttonMap[MSE_MAXBUTTONS]; -} MouseDevRec, *MouseDevPtr; - -#endif /* _XF86OSMOUSE_H_ */ diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h deleted file mode 100644 index 754128de9..000000000 --- a/hw/xfree86/os-support/xf86OSpriv.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 1999-2000 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#ifndef _XF86OSPRIV_H -#define _XF86OSPRIV_H - -typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int); -typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long); -typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool, - MessageType); -typedef void (*ProtectMemProcPtr)(int, pointer, unsigned long, Bool); -typedef void (*UndoWCProcPtr)(int, pointer); -typedef void (*ReadSideEffectsProcPtr)(int, pointer, unsigned long); - -typedef struct { - Bool initialised; - MapMemProcPtr mapMem; - UnmapMemProcPtr unmapMem; - ProtectMemProcPtr protectMem; - SetWCProcPtr setWC; - UndoWCProcPtr undoWC; - ReadSideEffectsProcPtr readSideEffects; - Bool linearSupported; -} VidMemInfo, *VidMemInfoPtr; - -void xf86OSInitVidMem(VidMemInfoPtr); - -#endif /* _XF86OSPRIV_H */ diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h deleted file mode 100644 index aba47581f..000000000 --- a/hw/xfree86/os-support/xf86_OSlib.h +++ /dev/null @@ -1,683 +0,0 @@ -/* - * 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 1997 by Takis Psarogiannakopoulos <takis@dpmms.cam.ac.uk> - * Copyright 1994-2003 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. - * - */ - -/* - * The ARM32 code here carries the following copyright: - * - * Copyright 1997 - * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is - * transferred hereby. - * - * 1) Any source code used, modified or distributed must reproduce and retain - * this copyright notice and list of conditions as they appear in the - * source file. - * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" - * name nor any trademark or logo of Digital Equipment Corporation may be - * used to endorse or promote products derived from this software without - * the prior written permission of Digital Equipment Corporation. - * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. - * In no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for lost profits, loss - * of revenue or loss of use, whether such damages arise in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even - * if advised of the possibility of such damage. - * - */ - -/* - * This is private, and should not be included by any drivers. Drivers - * may include xf86_OSproc.h to get prototypes for public interfaces. - */ - -#ifndef _XF86_OSLIB_H -#define _XF86_OSLIB_H - -#include <X11/Xos.h> -#include <X11/Xfuncproto.h> - -#include <stdio.h> -#include <ctype.h> -#include <stddef.h> - -/**************************************************************************/ -/* SYSV386 (SVR3, SVR4), including Solaris */ -/**************************************************************************/ -#if (defined(SYSV) || defined(SVR4)) && \ - !defined(DGUX) && !defined(sgi) && \ - (defined(sun) || defined(__i386__)) -# ifdef SCO325 -# ifndef _SVID3 -# define _SVID3 -# endif -# ifndef _NO_STATIC -# define _NO_STATIC -# endif -# 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 - -# ifdef ISC -# define TIOCMSET (TIOC|26) /* set all modem bits */ -# define TIOCMBIS (TIOC|27) /* bis modem bits */ -# define TIOCMBIC (TIOC|28) /* bic modem bits */ -# define TIOCMGET (TIOC|29) /* get all modem bits */ -# endif - -# include <errno.h> - -# if defined(_NEED_SYSI86) -# if !(defined (sun) && defined (SVR4)) -# include <sys/immu.h> -# 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 */ -/* V86SC_IOPL was moved to <sys/sysi86.h> on Solaris 7 and later */ -# if defined(sun) && defined (SVR4) /* Solaris? */ -# if defined(__i386__) || defined(__i386) || defined(__x86) /* on x86 or x64? */ -# if !defined(V86SC_IOPL) /* Solaris 7 or later? */ -# include <sys/v86.h> /* Nope */ -# endif -# endif /* V86SC_IOPL */ -# else -# include <sys/v86.h> /* Not solaris */ -# endif /* sun && i386 && SVR4 */ -# if defined(sun) && (defined (__i386__) || defined(__i386) || defined(__x86)) && 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 - -# if !defined(sun) || (!defined(sparc) && !defined(__SOL8__)) -# define HAS_USL_VTS -# endif -# if !defined(sun) -# include <sys/emap.h> -# endif -# if defined(SCO325) -# include <sys/vtkd.h> -# include <sys/console.h> -# include <sys/scankbd.h> -# include <sys/vid.h> -# define LED_CAP CLKED -# define LED_NUM NLKED -# define LED_SCR SLKED -# elif defined(HAS_USL_VTS) -# include <sys/at_ansi.h> -# include <sys/kd.h> -# include <sys/vt.h> -# elif defined(sun) -# include <sys/fbio.h> -# include <sys/kbd.h> -# include <sys/kbio.h> - -/* undefine symbols from <sys/kbd.h> we don't need that conflict with enum - definitions in parser/xf86tokens.h */ -# undef STRING -# undef LEFTALT -# undef RIGHTALT - -# define LED_CAP LED_CAPS_LOCK -# define LED_NUM LED_NUM_LOCK -# define LED_SCR LED_SCROLL_LOCK -# define LED_COMP LED_COMPOSE -# endif /* sun */ - -# 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 (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(__i386)) && defined (SVR4) && !defined(__SOL8__) -# define USE_VT_SYSREQ -# define VT_SYSREQ_DEFAULT TRUE -# endif - -# ifdef SYSV -# if !defined(ISC) || defined(ISC202) || defined(ISC22) -# define NEED_STRERROR -# endif -# endif - -#endif /* (SYSV || SVR4) && !DGUX */ - - - -/**************************************************************************/ -/* DG/ux R4.20MU03 Intel AViion Machines */ -/**************************************************************************/ -#if defined(DGUX) && defined(SVR4) -#include <sys/ioctl.h> -#include <signal.h> -#include <ctype.h> -#include <termios.h> /* Use termios for BSD Flavor ttys */ -#include <sys/termios.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/param.h> -#include <errno.h> -#include <sys/sysi86.h> -#include <unistd.h> -#include <sys/proc.h> -#include <sys/map.h> -#include <sys/sysmacros.h> -#include <sys/mman.h> /* Memory handling */ -#include <sys/kd.h> /* definitios for KDENABIO KDDISABIO needed for IOPL s */ -#include <sys/kbd.h> -#include <fcntl.h> -#include <time.h> -#include <sys/stream.h> -#include <sys/ptms.h> - -#include <sys/socket.h> -#include <sys/utsname.h> -#include <sys/stropts.h> -#include <sys/sockio.h> - - -#define POSIX_TTY - -#undef HAS_USL_VTS -#undef USE_VT_SYSREQ -#undef VT_ACKACQ - -#define LED_CAP KBD_LED_CAPS_LOCK -#define LED_NUM KBD_LED_NUM_LOCK -#define LED_SCR KBD_LED_SCROLL_LOCK - -#define KDGKBTYPE KBD_GET_LANGUAGE - - -/* General keyboard types */ -# define KB_84 2 -# define KB_101 1 /* Because ioctl(dgkeybdFd,KBD_GET_LANGUAGE,&type) gives 1=US keyboard */ -# define KB_OTHER 3 - -#define KDSETLED KBD_SET_LED -#define KDGETLED KBD_GET_STATE -#undef KDMKTONE -#define KDMKTONE KBD_TONE_HIGH - - -#undef DEV_MEM -#define DEV_MEM "/dev/mem" -#define CLEARDTR_SUPPORT - -#undef VT_SYSREQ_DEFAULT -#define VT_SYSREQ_DEFAULT FALSE /* Make sure that we dont define any VTs since DG/ux has none */ - -#endif /* DGUX && SVR4 */ - -/**************************************************************************/ -/* Linux or Glibc-based system */ -/**************************************************************************/ -#if defined(__linux__) || defined(__GLIBC__) -# include <sys/ioctl.h> -# include <signal.h> -# include <stdlib.h> -# include <sys/types.h> -# include <assert.h> - -#ifdef __GNU__ /* GNU/Hurd */ -# define USE_OSMOUSE -#endif - -# ifdef __linux__ -# include <termio.h> -# else /* __GLIBC__ */ -# include <termios.h> -# endif -# ifdef __sparc__ -# include <sys/param.h> -# endif - -# include <errno.h> - -# include <sys/stat.h> - -# include <sys/mman.h> -# ifdef __linux__ -# define HAS_USL_VTS -# 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 -# endif - -# define POSIX_TTY - -#endif /* __linux__ || __GLIBC__ */ - -/**************************************************************************/ -/* 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 -# define CLEARDTR_SUPPORT - -/* LynxOS 2.5.1 has these */ -# ifdef LED_NUMLOCK -# define LED_CAP LED_CAPSLOCK -# define LED_NUM LED_NUMLOCK -# define LED_SCR LED_SCROLLOCK -# endif - -#endif /* Lynx */ - -/**************************************************************************/ -/* 386BSD and derivatives, BSD/386 */ -/**************************************************************************/ - -#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__)) -# undef __386BSD__ -#endif - -#ifdef CSRG_BASED -# include <sys/ioctl.h> -# include <signal.h> - -# include <termios.h> -# define termio termios -# define POSIX_TTY - -# include <errno.h> - -# 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__ */ - -#endif /* CSRG_BASED */ - -/**************************************************************************/ -/* Kernel of *BSD */ -/**************************************************************************/ -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) - -# include <sys/param.h> -# if defined(__FreeBSD_version) && !defined(__FreeBSD_kernel_version) -# define __FreeBSD_kernel_version __FreeBSD_version -# endif - -# 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 SYSCONS_SUPPORT -# define COMPAT_SYSCONS -# if defined(__NetBSD__) || defined(__OpenBSD__) -# include <machine/console.h> -# else -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -# if defined(__DragonFly__) || (__FreeBSD_kernel_version >= 410000) -# include <sys/consio.h> -# include <sys/kbio.h> -# else -# include <machine/console.h> -# endif /* FreeBSD 4.1 RELEASE or lator */ -# else -# include <sys/console.h> -# endif -# endif -# endif /* SYSCONS_SUPPORT */ -# if defined(PCVT_SUPPORT) -# if !defined(SYSCONS_SUPPORT) - /* no syscons, so include pcvt specific header file */ -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -# include <machine/pcvt_ioctl.h> -# else -# if defined(__NetBSD__) || defined(__OpenBSD__) -# if !defined(WSCONS_SUPPORT) -# include <machine/pcvt_ioctl.h> -# endif /* WSCONS_SUPPORT */ -# else -# include <sys/pcvt_ioctl.h> -# endif /* __NetBSD__ */ -# endif /* __FreeBSD_kernel__ || __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 */ -# ifdef WSCONS_SUPPORT -# include <dev/wscons/wsconsio.h> -# include <dev/wscons/wsdisplay_usl_io.h> -# endif /* WSCONS_SUPPORT */ -# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -# if defined(__FreeBSD_kernel_version) && (__FreeBSD_kernel_version >= 500013) -# include <sys/mouse.h> -# else -# undef MOUSE_GETINFO -# include <machine/mouse.h> -# endif -# 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 -# ifndef CONSOLE_X_TV_ON -# define CONSOLE_X_TV_ON _IOW('t',155,int) -# define XMODE_RGB 0 -# define XMODE_NTSC 1 -# define XMODE_PAL 2 -# define XMODE_SECAM 3 -# endif -# ifndef CONSOLE_X_TV_OFF -# define CONSOLE_X_TV_OFF _IO('t',156) -# endif -#ifndef CONSOLE_GET_LINEAR_INFO -# define CONSOLE_GET_LINEAR_INFO _IOR('t',157,struct map_info) -#endif -#ifndef CONSOLE_GET_IO_INFO -# define CONSOLE_GET_IO_INFO _IOR('t',158,struct map_info) -#endif -#ifndef CONSOLE_GET_MEM_INFO -# define CONSOLE_GET_MEM_INFO _IOR('t',159,struct map_info) -#endif -# endif /* __bsdi__ */ -# endif /* !LINKKIT */ - -#if defined(USE_I386_IOPL) || defined(USE_AMD64_IOPL) -#include <machine/sysarch.h> -#endif - -# define CLEARDTR_SUPPORT - -# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) -# define USE_VT_SYSREQ -# endif - -#endif -/* __FreeBSD_kernel__ || __NetBSD__ || __OpenBSD__ || __bsdi__ */ - -/**************************************************************************/ -/* QNX4 */ -/**************************************************************************/ -/* This is the QNX code for Watcom 10.6 and QNX 4.x */ -#if defined(QNX4) -#include <signal.h> -#include <errno.h> -#include <sys/stat.h> -#include <termios.h> -#include <ioctl.h> -#include <sys/param.h> - -/* Warning: by default, the fd_set size is 32 in QNX! */ -#define FD_SETSIZE 256 -#include <sys/select.h> - - /* keyboard types */ -# define KB_84 1 -# define KB_101 2 -# define KB_OTHER 3 - - /* LEDs */ -# define LED_CAP 0x04 -# define LED_NUM 0x02 -# define LED_SCR 0x01 - -# define POSIX_TTY -# define OSMOUSE_ONLY -# define MOUSE_PROTOCOL_IN_KERNEL - -#define TIOCM_DTR 0x0001 /* data terminal ready */ -#define TIOCM_RTS 0x0002 /* request to send */ -#define TIOCM_CTS 0x1000 /* clear to send */ -#define TIOCM_DSR 0x2000 /* data set ready */ -#define TIOCM_RI 0x4000 /* ring */ -#define TIOCM_RNG TIOCM_RI -#define TIOCM_CD 0x8000 /* carrier detect */ -#define TIOCM_CAR TIOCM_CD -#define TIOCM_LE 0x0100 /* line enable */ -#define TIOCM_ST 0x0200 /* secondary transmit */ -#define TIOCM_SR 0x0400 /* secondary receive */ - -#endif - -/**************************************************************************/ -/* QNX/Neutrino */ -/**************************************************************************/ -/* This is the Neutrino code for for NTO2.0 and GCC */ -#if defined(__QNXNTO__) -#include <signal.h> -#include <errno.h> -#include <sys/stat.h> -#include <termios.h> -#include <ioctl.h> -#include <sys/param.h> - -/* Warning: by default, the fd_set size is 32 in NTO! */ -#define FD_SETSIZE 256 -#include <sys/select.h> - - /* keyboard types */ -# define KB_84 1 -# define KB_101 2 -# define KB_OTHER 3 - -# define POSIX_TTY - -#endif - -/**************************************************************************/ -/* IRIX */ -/**************************************************************************/ -#if defined(sgi) - -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> - -#endif - -/**************************************************************************/ -/* Generic */ -/**************************************************************************/ - -#include <sys/wait.h> /* May need to adjust this for other OSs */ - -/* - * 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( - double x -); -#endif - -#ifndef DEV_MEM -#define DEV_MEM "/dev/mem" -#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 - -#define SYSCALL(call) while(((call) == -1) && (errno == EINTR)) - -#define XF86_OS_PRIVS -#include "xf86_OSproc.h" - -#ifndef NO_COMPILER_H -#include "compiler.h" -#endif - -#endif /* _XF86_OSLIB_H */ diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h deleted file mode 100644 index abf5a47c2..000000000 --- a/hw/xfree86/os-support/xf86_OSproc.h +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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-2003 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. - * - */ - -/* - * The ARM32 code here carries the following copyright: - * - * Copyright 1997 - * Digital Equipment Corporation. All rights reserved. - * This software is furnished under license and may be used and copied only in - * accordance with the following terms and conditions. Subject to these - * conditions, you may download, copy, install, use, modify and distribute - * this software in source and/or binary form. No title or ownership is - * transferred hereby. - * - * 1) Any source code used, modified or distributed must reproduce and retain - * this copyright notice and list of conditions as they appear in the - * source file. - * - * 2) No right is granted to use any trade name, trademark, or logo of Digital - * Equipment Corporation. Neither the "Digital Equipment Corporation" - * name nor any trademark or logo of Digital Equipment Corporation may be - * used to endorse or promote products derived from this software without - * the prior written permission of Digital Equipment Corporation. - * - * 3) This software is provided "AS-IS" and any express or implied warranties, - * including but not limited to, any implied warranties of merchantability, - * fitness for a particular purpose, or non-infringement are disclaimed. - * In no event shall DIGITAL be liable for any damages whatsoever, and in - * particular, DIGITAL shall not be liable for special, indirect, - * consequential, or incidental damages or damages for lost profits, loss - * of revenue or loss of use, whether such damages arise in contract, - * negligence, tort, under statute, in equity, at law or otherwise, even - * if advised of the possibility of such damage. - * - */ - - -#ifndef _XF86_OSPROC_H -#define _XF86_OSPROC_H - -#ifdef XF86_OS_PRIVS -#include "xf86Pci.h" -#endif - -/* - * 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. - */ - -/* - * Flags for xf86MapVidMem(). Multiple flags can be or'd together. The - * flags may be used as hints. For example it would be permissible to - * enable write combining for memory marked only for framebuffer use. - */ - -#define VIDMEM_FRAMEBUFFER 0x01 /* memory for framebuffer use */ -#define VIDMEM_MMIO 0x02 /* memory for I/O use */ -#define VIDMEM_MMIO_32BIT 0x04 /* memory accesses >= 32bit */ -#define VIDMEM_READSIDEEFFECT 0x08 /* reads can have side-effects */ -#define VIDMEM_SPARSE 0x10 /* sparse mapping required - * assumed when VIDMEM_MMIO is - * set. May be used with - * VIDMEM_FRAMEBUFFER) */ -#define VIDMEM_READONLY 0x20 /* read-only mapping - * used when reading BIOS images - * through xf86MapVidMem() */ - -/* - * OS-independent modem state flags for xf86SetSerialModemState() and - * xf86GetSerialModemState(). - */ -#define XF86_M_LE 0x001 /* line enable */ -#define XF86_M_DTR 0x002 /* data terminal ready */ -#define XF86_M_RTS 0x004 /* request to send */ -#define XF86_M_ST 0x008 /* secondary transmit */ -#define XF86_M_SR 0x010 /* secondary receive */ -#define XF86_M_CTS 0x020 /* clear to send */ -#define XF86_M_CAR 0x040 /* carrier detect */ -#define XF86_M_RNG 0x080 /* ring */ -#define XF86_M_DSR 0x100 /* data set ready */ - -#ifdef XF86_OS_PRIVS -extern void xf86WrapperInit(void); -#endif - -#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(). - */ - -#define xf86FatalError(a, b) \ - if (dispatchException & DE_TERMINATE) { \ - ErrorF(a, b); \ - ErrorF("\n"); \ - return; \ - } else FatalError(a, b) - -/***************************************************************************/ -/* Prototypes */ -/***************************************************************************/ - -#include <X11/Xfuncproto.h> -#include "opaque.h" - -_XFUNCPROTOBEGIN - -/* public functions */ -extern Bool xf86LinearVidMem(void); -extern Bool xf86CheckMTRR(int); -extern pointer xf86MapVidMem(int, int, unsigned long, unsigned long); -extern void xf86UnMapVidMem(int, pointer, unsigned long); -extern void xf86MapReadSideEffects(int, int, pointer, unsigned long); -extern int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int); -extern Bool xf86EnableIO(void); -extern void xf86DisableIO(void); -extern Bool xf86DisableInterrupts(void); -extern void xf86EnableInterrupts(void); -extern void xf86SetTVOut(int); -extern void xf86SetRGBOut(void); -extern void xf86OSRingBell(int, int, int); -#if defined(QNX4) -#pragma aux xf86BusToMem modify [eax ebx ecx edx esi edi]; -#pragma aux xf86MemToBus modify [eax ebx ecx edx esi edi]; -#endif -extern void xf86BusToMem(unsigned char *, unsigned char *, int); -extern void xf86MemToBus(unsigned char *, unsigned char *, int); -extern void xf86IODelay(void); -extern void xf86UDelay(long usec); -extern void xf86SetReallySlowBcopy(void); -extern void xf86SlowBcopy(unsigned char *, unsigned char *, int); -extern int xf86OpenSerial(pointer options); -extern int xf86SetSerial(int fd, pointer options); -extern int xf86SetSerialSpeed(int fd, int speed); -extern int xf86ReadSerial(int fd, void *buf, int count); -extern int xf86WriteSerial(int fd, const void *buf, int count); -extern int xf86CloseSerial(int fd); -extern int xf86FlushInput(int fd); -extern int xf86WaitForInput(int fd, int timeout); -extern int xf86SerialSendBreak(int fd, int duration); -extern int xf86SetSerialModemState(int fd, int state); -extern int xf86GetSerialModemState(int fd); -extern int xf86SerialModemSetBits(int fd, int bits); -extern int xf86SerialModemClearBits(int fd, int bits); -extern int xf86LoadKernelModule(const char *pathname); -extern void xf86RingBell(int volume, int pitch, int duration); - -/* AGP GART interface */ - -typedef struct _AgpInfo { - CARD32 bridgeId; - CARD32 agpMode; - unsigned long base; - unsigned long size; - unsigned long totalPages; - unsigned long systemPages; - unsigned long usedPages; -} AgpInfo, *AgpInfoPtr; - -extern Bool xf86AgpGARTSupported(void); -extern AgpInfoPtr xf86GetAGPInfo(int screenNum); -extern Bool xf86AcquireGART(int screenNum); -extern Bool xf86ReleaseGART(int screenNum); -extern int xf86AllocateGARTMemory(int screenNum, unsigned long size, int type, - unsigned long *physical); -extern Bool xf86DeallocateGARTMemory(int screenNum, int key); -extern Bool xf86BindGARTMemory(int screenNum, int key, unsigned long offset); -extern Bool xf86UnbindGARTMemory(int screenNum, int key); -extern Bool xf86EnableAGP(int screenNum, CARD32 mode); -extern Bool xf86GARTCloseScreen(int screenNum); - -/* These routines are in shared/sigio.c and are not loaded as part of the - module. These routines are small, and the code if very POSIX-signal (or - OS-signal) specific, so it seemed better to provide more complex - wrappers than to wrap each individual function called. */ -extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); -extern int xf86RemoveSIGIOHandler(int fd); -extern int xf86BlockSIGIO (void); -extern void xf86UnblockSIGIO (int); -extern void xf86AssertBlockedSIGIO (char *); -extern Bool xf86SIGIOSupported (void); - -#ifdef XF86_OS_PRIVS -typedef void (*PMClose)(void); -extern void xf86OpenConsole(void); -extern void xf86CloseConsole(void); -extern Bool xf86VTSwitchPending(void); -extern Bool xf86VTSwitchAway(void); -extern Bool xf86VTSwitchTo(void); -extern void xf86VTRequest(int sig); -extern int xf86ProcessArgument(int, char **, int); -extern void xf86UseMsg(void); -extern void xf86ReloadInputDevs(int sig); -extern PMClose xf86OSPMOpen(void); - -#ifdef NEED_OS_RAC_PROTOS -/* RAC-related privs */ -/* internal to os-support layer */ -resPtr xf86StdAccResFromOS(resPtr ret); - -/* available to the common layer */ -resPtr xf86AccResFromOS(resPtr ret); -#endif /* NEED_OS_RAC_PROTOS */ - -extern unsigned long xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base); - -extern void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer); -extern void xf86InitVidMem(void); - -#endif /* XF86_OS_PRIVS */ - - -_XFUNCPROTOEND -#endif /* NO_OSLIB_PROTOTYPES */ - -#endif /* _XF86_OSPROC_H */ |