diff options
Diffstat (limited to 'hw/xfree86')
62 files changed, 28445 insertions, 0 deletions
diff --git a/hw/xfree86/common/atKeynames.h b/hw/xfree86/common/atKeynames.h new file mode 100644 index 000000000..24ae59a30 --- /dev/null +++ b/hw/xfree86/common/atKeynames.h @@ -0,0 +1,335 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.9 1996/12/23 06:43:13 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: atKeynames.h,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */ + +#ifndef _ATKEYNAMES_H +#define _ATKEYNAMES_H + +#define XK_TECHNICAL +#define XK_KATAKANA +#include "keysym.h" + +#define GLYPHS_PER_KEY 4 +#define NUM_KEYCODES 150 +#define NUM_STD_KEYCODES 127 +#define MIN_KEYCODE 8 +#define MAX_KEYCODE (NUM_KEYCODES + MIN_KEYCODE - 1) +#define MAX_STD_KEYCODE (NUM_STD_KEYCODES + MIN_KEYCODE - 1) + +#define AltMask Mod1Mask +#define NumLockMask Mod2Mask +#define AltLangMask Mod3Mask +#define KanaMask Mod4Mask +#define ScrollLockMask Mod5Mask + +#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7))) +#define ModifierDown(k) ((keyc->state & (k)) == (k)) + +#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */ + +/* + * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three) + * sets of scancodes. Set3 can only be generated by a MF keyboard. + * Set2 sends a makecode for keypress, and the same code prefixed by a + * F0 for keyrelease. This is a little bit ugly to handle. Thus we use + * here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes. + * Bit 7 ist set if the key is released. The code E0 switches to a + * different meaning to add the new MF cursorkeys, while not breaking old + * applications. E1 is another special prefix. Since I assume that there + * will be further versions of PC/XT scancode compatible keyboards, we + * may be in trouble one day. + * + * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3. + * 2) Use the keyboards native set and translate it to common keysyms. + */ + +/* + * definition of the AT84/MF101/MF102 Keyboard: + * ============================================================ + * Defined Key Cap Glyphs Pressed value + * Key Name Main Also (hex) (dec) + * ---------------- ---------- ------- ------ ------ + */ + +#ifndef PC98 + +#define KEY_Escape /* Escape 0x01 */ 1 +#define KEY_1 /* 1 ! 0x02 */ 2 +#define KEY_2 /* 2 @ 0x03 */ 3 +#define KEY_3 /* 3 # 0x04 */ 4 +#define KEY_4 /* 4 $ 0x05 */ 5 +#define KEY_5 /* 5 % 0x06 */ 6 +#define KEY_6 /* 6 ^ 0x07 */ 7 +#define KEY_7 /* 7 & 0x08 */ 8 +#define KEY_8 /* 8 * 0x09 */ 9 +#define KEY_9 /* 9 ( 0x0a */ 10 +#define KEY_0 /* 0 ) 0x0b */ 11 +#define KEY_Minus /* - (Minus) _ (Under) 0x0c */ 12 +#define KEY_Equal /* = (Equal) + 0x0d */ 13 +#define KEY_BackSpace /* Back Space 0x0e */ 14 +#define KEY_Tab /* Tab 0x0f */ 15 +#define KEY_Q /* Q 0x10 */ 16 +#define KEY_W /* W 0x11 */ 17 +#define KEY_E /* E 0x12 */ 18 +#define KEY_R /* R 0x13 */ 19 +#define KEY_T /* T 0x14 */ 20 +#define KEY_Y /* Y 0x15 */ 21 +#define KEY_U /* U 0x16 */ 22 +#define KEY_I /* I 0x17 */ 23 +#define KEY_O /* O 0x18 */ 24 +#define KEY_P /* P 0x19 */ 25 +#define KEY_LBrace /* [ { 0x1a */ 26 +#define KEY_RBrace /* ] } 0x1b */ 27 +#define KEY_Enter /* Enter 0x1c */ 28 +#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29 +#define KEY_A /* A 0x1e */ 30 +#define KEY_S /* S 0x1f */ 31 +#define KEY_D /* D 0x20 */ 32 +#define KEY_F /* F 0x21 */ 33 +#define KEY_G /* G 0x22 */ 34 +#define KEY_H /* H 0x23 */ 35 +#define KEY_J /* J 0x24 */ 36 +#define KEY_K /* K 0x25 */ 37 +#define KEY_L /* L 0x26 */ 38 +#define KEY_SemiColon /* ;(SemiColon) :(Colon) 0x27 */ 39 +#define KEY_Quote /* ' (Apostr) " (Quote) 0x28 */ 40 +#define KEY_Tilde /* ` (Accent) ~ (Tilde) 0x29 */ 41 +#define KEY_ShiftL /* Shift(left) 0x2a */ 42 +#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 43 +#define KEY_Z /* Z 0x2c */ 44 +#define KEY_X /* X 0x2d */ 45 +#define KEY_C /* C 0x2e */ 46 +#define KEY_V /* V 0x2f */ 47 +#define KEY_B /* B 0x30 */ 48 +#define KEY_N /* N 0x31 */ 49 +#define KEY_M /* M 0x32 */ 50 +#define KEY_Comma /* , (Comma) < (Less) 0x33 */ 51 +#define KEY_Period /* . (Period) >(Greater)0x34 */ 52 +#define KEY_Slash /* / (Slash) ? 0x35 */ 53 +#define KEY_ShiftR /* Shift(right) 0x36 */ 54 +#define KEY_KP_Multiply /* * 0x37 */ 55 +#define KEY_Alt /* Alt(left) 0x38 */ 56 +#define KEY_Space /* (SpaceBar) 0x39 */ 57 +#define KEY_CapsLock /* CapsLock 0x3a */ 58 +#define KEY_F1 /* F1 0x3b */ 59 +#define KEY_F2 /* F2 0x3c */ 60 +#define KEY_F3 /* F3 0x3d */ 61 +#define KEY_F4 /* F4 0x3e */ 62 +#define KEY_F5 /* F5 0x3f */ 63 +#define KEY_F6 /* F6 0x40 */ 64 +#define KEY_F7 /* F7 0x41 */ 65 +#define KEY_F8 /* F8 0x42 */ 66 +#define KEY_F9 /* F9 0x43 */ 67 +#define KEY_F10 /* F10 0x44 */ 68 +#define KEY_NumLock /* NumLock 0x45 */ 69 +#define KEY_ScrollLock /* ScrollLock 0x46 */ 70 +#define KEY_KP_7 /* 7 Home 0x47 */ 71 +#define KEY_KP_8 /* 8 Up 0x48 */ 72 +#define KEY_KP_9 /* 9 PgUp 0x49 */ 73 +#define KEY_KP_Minus /* - (Minus) 0x4a */ 74 +#define KEY_KP_4 /* 4 Left 0x4b */ 75 +#define KEY_KP_5 /* 5 0x4c */ 76 +#define KEY_KP_6 /* 6 Right 0x4d */ 77 +#define KEY_KP_Plus /* + (Plus) 0x4e */ 78 +#define KEY_KP_1 /* 1 End 0x4f */ 79 +#define KEY_KP_2 /* 2 Down 0x50 */ 80 +#define KEY_KP_3 /* 3 PgDown 0x51 */ 81 +#define KEY_KP_0 /* 0 Insert 0x52 */ 82 +#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83 +#define KEY_SysReqest /* SysReqest 0x54 */ 84 + /* NOTUSED 0x55 */ +#define KEY_Less /* < (Less) >(Greater) 0x56 */ 86 +#define KEY_F11 /* F11 0x57 */ 87 +#define KEY_F12 /* F12 0x58 */ 88 + +#define KEY_Prefix0 /* special 0x60 */ 96 +#define KEY_Prefix1 /* specail 0x61 */ 97 + +/* + * The 'scancodes' below are generated by the server, because the MF101/102 + * keyboard sends them as sequence of other scancodes + */ +#define KEY_Home /* Home 0x59 */ 89 +#define KEY_Up /* Up 0x5a */ 90 +#define KEY_PgUp /* PgUp 0x5b */ 91 +#define KEY_Left /* Left 0x5c */ 92 +#define KEY_Begin /* Begin 0x5d */ 93 +#define KEY_Right /* Right 0x5e */ 94 +#define KEY_End /* End 0x5f */ 95 +#define KEY_Down /* Down 0x60 */ 96 +#define KEY_PgDown /* PgDown 0x61 */ 97 +#define KEY_Insert /* Insert 0x62 */ 98 +#define KEY_Delete /* Delete 0x63 */ 99 +#define KEY_KP_Enter /* Enter 0x64 */ 100 +#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101 +#define KEY_Pause /* Pause 0x66 */ 102 +#define KEY_Print /* Print 0x67 */ 103 +#define KEY_KP_Divide /* Didive 0x68 */ 104 +#define KEY_AltLang /* AtlLang(right) 0x69 */ 105 +#define KEY_Break /* Break 0x6a */ 106 +#define KEY_LMeta /* Left Meta 0x6b */ 107 +#define KEY_RMeta /* Right Meta 0x6c */ 108 +#define KEY_Menu /* Menu 0x6d */ 109 +#define KEY_F13 /* F13 0x6e */ 110 +#define KEY_F14 /* F14 0x6f */ 111 +#define KEY_F15 /* F15 0x70 */ 112 +#define KEY_F16 /* F16 0x71 */ 113 +#define KEY_F17 /* F17 0x72 */ 114 +#define KEY_KP_DEC /* KP_DEC 0x73 */ 115 +#define KEY_SN_KP_7 /* ServerNumLock 7 0x80 */ 128 +#define KEY_SN_KP_8 /* ServerNumLock 8 0x81 */ 129 +#define KEY_SN_KP_9 /* ServerNumLock 9 0x82 */ 130 +#define KEY_SN_KP_4 /* ServerNumLock 4 0x83 */ 131 +#define KEY_SN_KP_5 /* ServerNumLock 5 0x84 */ 132 +#define KEY_SN_KP_6 /* ServerNumLock 6 0x85 */ 133 +#define KEY_SN_KP_1 /* ServerNumLock 1 0x86 */ 134 +#define KEY_SN_KP_2 /* ServerNumLock 2 0x87 */ 135 +#define KEY_SN_KP_3 /* ServerNumLock 4 0x88 */ 136 +#define KEY_SN_KP_0 /* ServerNumLock 0 0x89 */ 137 +#define KEY_SN_KP_Dec /* ServerNumLock Decimal 0x8a */ 138 +#define KEY_SN_KP_Home /* ServerNumLock Home 0x8b */ 139 +#define KEY_SN_KP_Up /* ServerNumLock Up 0x8c */ 140 +#define KEY_SN_KP_Prior /* ServerNumLock Prior 0x8d */ 141 +#define KEY_SN_KP_Left /* ServerNumLock Left 0x8e */ 142 +#define KEY_SN_KP_Begin /* ServerNumLock Begin 0x8f */ 143 +#define KEY_SN_KP_Right /* ServerNumLock Right 0x90 */ 144 +#define KEY_SN_KP_End /* ServerNumLock End 0x91 */ 145 +#define KEY_SN_KP_Down /* ServerNumLock Down 0x92 */ 146 +#define KEY_SN_KP_Next /* ServerNumLock Next 0x93 */ 147 +#define KEY_SN_KP_Ins /* ServerNumLock Ins 0x94 */ 148 +#define KEY_SN_KP_Del /* ServerNumLock Del 0x95 */ 149 + +#else + +#define KEY_Escape /* Escape 0x01 */ 0 +#define KEY_1 /* 1 ! 0x02 */ 1 +#define KEY_2 /* 2 " 0x03 */ 2 +#define KEY_3 /* 3 # 0x04 */ 3 +#define KEY_4 /* 4 $ 0x05 */ 4 +#define KEY_5 /* 5 % 0x06 */ 5 +#define KEY_6 /* 6 & 0x07 */ 6 +#define KEY_7 /* 7 ' 0x08 */ 7 +#define KEY_8 /* 8 ( 0x09 */ 8 +#define KEY_9 /* 9 ) 0x0a */ 9 +#define KEY_0 /* 0 0x0b */ 10 +#define KEY_Minus /* - (Minus) = (Equal) 0x0c */ 11 +#define KEY_Hat /* ^ (Hat) ` 0x0d */ 12 +#define KEY_BSlash /* \(BckSlash) |(VertBar)0x2b */ 13 +#define KEY_BackSpace /* Back Space 0x0e */ 14 +#define KEY_Tab /* Tab 0x0f */ 15 +#define KEY_Q /* Q 0x10 */ 16 +#define KEY_W /* W 0x11 */ 17 +#define KEY_E /* E 0x12 */ 18 +#define KEY_R /* R 0x13 */ 19 +#define KEY_T /* T 0x14 */ 20 +#define KEY_Y /* Y 0x15 */ 21 +#define KEY_U /* U 0x16 */ 22 +#define KEY_I /* I 0x17 */ 23 +#define KEY_O /* O 0x18 */ 24 +#define KEY_P /* P 0x19 */ 25 +#define KEY_At /* @ ~ 0x1a */ 26 +#define KEY_LBrace /* [ { 0x1b */ 27 +#define KEY_Enter /* Enter 0x1c */ 28 +#define KEY_A /* A 0x1d */ 29 +#define KEY_S /* S 0x1e */ 30 +#define KEY_D /* D 0x1f */ 31 +#define KEY_F /* F 0x20 */ 32 +#define KEY_G /* G 0x21 */ 33 +#define KEY_H /* H 0x22 */ 34 +#define KEY_J /* J 0x23 */ 35 +#define KEY_K /* K 0x24 */ 36 +#define KEY_L /* L 0x25 */ 37 +#define KEY_SemiColon /* ;(SemiColon) +(Plus) 0x26 */ 38 +#define KEY_Colon /* :(Colon) *(Quote) 0x27 */ 39 +#define KEY_RBrace /* ] } 0x28 */ 40 +#define KEY_Z /* Z 0x29 */ 41 +#define KEY_X /* X 0x2a */ 42 +#define KEY_C /* C 0x2b */ 43 +#define KEY_V /* V 0x2c */ 44 +#define KEY_B /* B 0x2d */ 45 +#define KEY_N /* N 0x2e */ 46 +#define KEY_M /* M 0x2f */ 47 +#define KEY_Comma /* , (Comma) < (Less) 0x30 */ 48 +#define KEY_Period /* . (Period) >(Greater)0x31 */ 49 +#define KEY_Slash /* / (Slash) ? 0x32 */ 50 +#define KEY_Under /* _ 0x33 */ 51 +#define KEY_Space /* (SpaceBar) 0x34 */ 52 +#define KEY_Xfer /* (XFER) 0x35 */ 53 +#define KEY_PgUp /* PgUp 0x36 */ 54 +#define KEY_Pgdown /* (Roll Down) 0x37 */ 55 +#define KEY_Insert /* Insert 0x38 */ 56 +#define KEY_Delete /* Delete 0x39 */ 57 +#define KEY_Up /* Up 0x3a */ 58 +#define KEY_Left /* Left 0x3b */ 59 +#define KEY_Right /* Right 0x3c */ 60 +#define KEY_Down /* Down 0x3d */ 61 +#define KEY_Home /* Home 0x3e */ 62 +#define KEY_Help /* Help 0x3f */ 63 +#define KEY_KP_Subtract /* - (Minus) 0x40 */ 64 +#define KEY_KP_Minus /* - */ 64 +#define KEY_KP_Divide /* / (Slash) 0x41 */ 65 +#define KEY_KP_7 /* 7 0x42 */ 66 +#define KEY_KP_8 /* 8 0x43 */ 67 +#define KEY_KP_9 /* 9 0x44 */ 68 +#define KEY_KP_Multiply /* * 0x45 */ 69 +#define KEY_KP_4 /* 4 0x46 */ 70 +#define KEY_KP_5 /* 5 0x47 */ 71 +#define KEY_KP_6 /* 6 0x48 */ 72 +#define KEY_KP_Add /* + (Plus) 0x49 */ 73 +#define KEY_KP_Plus /* + */ 73 +#define KEY_KP_1 /* 1 0x4a */ 74 +#define KEY_KP_2 /* 2 0x4b */ 75 +#define KEY_KP_3 /* 3 0x4c */ 76 +#define KEY_KP_Equal /* = 0x4d */ 77 +#define KEY_KP_0 /* 0 0x4e */ 78 +#define KEY_KP_Separator /* , 0x4f */ 79 +#define KEY_KP_Decimal /* . (Decimal) 0x50 */ 80 +#define KEY_Nfer /* (NFER) 0x51 */ 81 +#define KEY_F11 /* F11 0x52 */ 82 +#define KEY_F12 /* F12 0x53 */ 83 +#define KEY_F13 /* F13 0x54 */ 84 +#define KEY_F14 /* F14 0x55 */ 85 +#define KEY_F15 /* F15 0x56 */ 86 +#define KEY_Break /* (Stop) 0x60 */ 96 +#define KEY_Copy /* (Copy) 0x61 */ 97 +#define KEY_Begin /* Begin ?? */ 97 +#define KEY_F1 /* F1 0x62 */ 98 +#define KEY_F2 /* F2 0x63 */ 99 +#define KEY_F3 /* F3 0x64 */ 100 +#define KEY_F4 /* F4 0x65 */ 101 +#define KEY_F5 /* F5 0x66 */ 102 +#define KEY_F6 /* F6 0x67 */ 103 +#define KEY_F7 /* F7 0x68 */ 104 +#define KEY_F8 /* F8 0x69 */ 105 +#define KEY_F9 /* F9 0x6a */ 106 +#define KEY_F10 /* F10 0x6b */ 107 +#define KEY_ShiftL /* Shift(left) 0x70 */ 112 +#define KEY_CapsLock /* CapsLock 0x71 */ 113 +#define KEY_KanaLock /* Kana 0x72 */ 114 +#define KEY_Alt /* Alt(left) 0x73 */ 115 +#define KEY_LCtrl /* Ctrl(left) 0x74 */ 116 + +#endif /* PC98 */ + +#endif /* _ATKEYNAMES_H */ diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h new file mode 100644 index 000000000..f85ecd132 --- /dev/null +++ b/hw/xfree86/common/compiler.h @@ -0,0 +1,1460 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.2 1998/02/07 00:44:37 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: compiler.h,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */ + +#ifndef _COMPILER_H +#define _COMPILER_H + +#ifndef __STDC__ +# ifdef signed +# undef signed +# endif +# ifdef volatile +# undef volatile +# endif +# ifdef const +# undef const +# endif +# define signed /**/ +# ifdef __GNUC__ +# define volatile __volatile__ +# define const __const__ +# ifdef PC98 +# undef NO_INLINE +# endif +# else +# define const /**/ +# ifdef PC98 +# define __inline__ /**/ +# endif +# endif /* __GNUC__ */ +#endif /* !__STDC__ */ + +#if defined(IODEBUG) && defined(__GNUC__) +#define outb RealOutb +#define outw RealOutw +#define outl RealOutl +#define inb RealInb +#define inw RealInw +#define inl RealInl +#endif + +#ifdef NO_INLINE + +extern void outb(); +extern void outw(); +extern void outl(); +extern unsigned int inb(); +extern unsigned int inw(); +extern unsigned int inl(); +#if NeedFunctionPrototypes +extern unsigned char rdinx(unsigned short int, unsigned char); +extern void wrinx(unsigned short int, unsigned char, unsigned char); +extern void modinx(unsigned short int, unsigned char, unsigned char, unsigned char); +extern int testrg(unsigned short int, unsigned char); +extern int testinx2(unsigned short int, unsigned char, unsigned char); +extern int testinx(unsigned short int, unsigned char); +#else /* NeedFunctionProtoypes */ +extern unsigned char rdinx(); +extern void wrinx(); +extern void modinx(); +extern int testrg(); +extern int testinx2(); +extern int testinx(); +#endif /* NeedFunctionProtoypes */ + +#else /* NO_INLINE */ + +#ifdef __GNUC__ + +#if defined(linux) && defined(__alpha__) +/* for Linux on Alpha, we use the LIBC _inx/_outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +static __inline__ void +outb(port, val) + unsigned short port; + char val; +{ + extern void _outb(char val, unsigned short port); + _outb(val, port); +} + +static __inline__ void +outw(port, val) + unsigned short port; + short val; +{ + extern void _outw(short val, unsigned short port); + _outw(val, port); +} + +static __inline__ void +outl(port, val) + unsigned short port; + int val; +{ + extern void _outl(int val, unsigned short port); + _outl(val, port); +} + +static __inline__ unsigned int +inb(port) + unsigned short port; +{ + extern unsigned int _inb(unsigned short port); + return _inb(port); +} + +static __inline__ unsigned int +inw(port) + unsigned short port; +{ + extern unsigned int _inw(unsigned short port); + return _inw(port); +} + +static __inline__ unsigned int +inl(port) + unsigned short port; +{ + extern unsigned int _inl(unsigned short port); + return _inl(port); +} + + +/* + * inline functions to do unaligned accesses + * from linux/include/asm-alpha/unaligned.h + */ + +static __inline__ unsigned long ldq_u(unsigned long * r11) +{ + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extql %0,%2,%0\n\t" + "extqh %1,%2,%1\n\t" + "bis %1,%0,%0" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(7+(char *) r11))); + return r1; +} + +static __inline__ unsigned long ldl_u(unsigned int * r11) +{ + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extll %0,%2,%0\n\t" + "extlh %1,%2,%1\n\t" + "bis %1,%0,%0" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(3+(char *) r11))); + return r1; +} + +static __inline__ unsigned long ldw_u(unsigned short * r11) +{ + unsigned long r1,r2; + __asm__("ldq_u %0,%3\n\t" + "ldq_u %1,%4\n\t" + "extwl %0,%2,%0\n\t" + "extwh %1,%2,%1\n\t" + "bis %1,%0,%0" + :"=&r" (r1), "=&r" (r2) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(1+(char *) r11))); + return r1; +} + +static __inline__ void stq_u(unsigned long r5, unsigned long * r11) +{ + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "insqh %6,%7,%5\n\t" + "insql %6,%7,%4\n\t" + "mskqh %3,%7,%3\n\t" + "mskql %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(7+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +} + +static __inline__ void stl_u(unsigned long r5, unsigned int * r11) +{ + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inslh %6,%7,%5\n\t" + "insll %6,%7,%4\n\t" + "msklh %3,%7,%3\n\t" + "mskll %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(3+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +} + +static __inline__ void stw_u(unsigned long r5, unsigned short * r11) +{ + unsigned long r1,r2,r3,r4; + + __asm__("ldq_u %3,%1\n\t" + "ldq_u %2,%0\n\t" + "inswh %6,%7,%5\n\t" + "inswl %6,%7,%4\n\t" + "mskwh %3,%7,%3\n\t" + "mskwl %2,%7,%2\n\t" + "bis %3,%5,%3\n\t" + "bis %2,%4,%2\n\t" + "stq_u %3,%1\n\t" + "stq_u %2,%0" + :"=m" (*r11), + "=m" (*(unsigned long *)(1+(char *) r11)), + "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4) + :"r" (r5), "r" (r11)); +} + +#define mem_barrier() __asm__ __volatile__("mb" : : : "memory") +#ifdef __ELF__ +#define write_mem_barrier() __asm__ __volatile__("wmb" : : : "memory") +#else /* ECOFF gas 2.6 doesn't know "wmb" :-( */ +#define write_mem_barrier() mem_barrier() +#endif + +#else /* defined(linux) && defined(__alpha__) */ +#if defined(__mips__) + +unsigned int IOPortBase; /* Memory mapped I/O port area */ + +static __inline__ void +outb(port, val) + short port; + char val; +{ + *(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val; +} + +static __inline__ void +outw(port, val) + short port; + short val; +{ + *(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val; +} + +static __inline__ void +outl(port, val) + short port; + int val; +{ + *(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val; +} + +static __inline__ unsigned int +inb(port) + short port; +{ + return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase)); +} + +static __inline__ unsigned int +inw(port) + short port; +{ + return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase)); +} + +static __inline__ unsigned int +inl(port) + short port; +{ + return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase)); +} + + +static __inline__ unsigned long ldq_u(unsigned long * r11) +{ + unsigned long r1; + __asm__("lwr %0,%2\n\t" + "lwl %0,%3\n\t" + :"=&r" (r1) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(3+(char *) r11))); + return r1; +} + +static __inline__ unsigned long ldl_u(unsigned int * r11) +{ + unsigned long r1; + __asm__("lwr %0,%2\n\t" + "lwl %0,%3\n\t" + :"=&r" (r1) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(3+(char *) r11))); + return r1; +} + +static __inline__ unsigned long ldw_u(unsigned short * r11) +{ + unsigned long r1; + __asm__("lwr %0,%2\n\t" + "lwl %0,%3\n\t" + :"=&r" (r1) + :"r" (r11), + "m" (*r11), + "m" (*(unsigned long *)(1+(char *) r11))); + return r1; +} + +#define stq_u(v,p) stl_u(v,p) +#define stl_u(v,p) ((unsigned char *)(p)) = (v); \ + ((unsigned char *)(p)+1) = ((v) >> 8); \ + ((unsigned char *)(p)+2) = ((v) >> 16); \ + ((unsigned char *)(p)+3) = ((v) >> 24) + +#define stw_u(v,p) ((unsigned char *)(p)) = (v); \ + ((unsigned char *)(p)+1) = ((v) >> 8) + +#define mem_barrier() /* NOP */ + +#else /* defined(mips) */ + +#define ldq_u(p) (*((unsigned long *)(p))) +#define ldl_u(p) (*((unsigned int *)(p))) +#define ldw_u(p) (*((unsigned short *)(p))) +#define stq_u(v,p) ((unsigned long *)(p)) = (v) +#define stl_u(v,p) ((unsigned int *)(p)) = (v) +#define stw_u(v,p) ((unsigned short *)(p)) = (v) +#define mem_barrier() /* NOP */ +#define write_mem_barrier() /* NOP */ + +#if !defined(FAKEIT) && !defined(__mc68000__) +#ifdef GCCUSESGAS + +/* + * If gcc uses gas rather than the native assembler, the syntax of these + * inlines has to be different. DHD + */ +#ifndef PC98 + +static __inline__ void +#if NeedFunctionPrototypes +outb( +unsigned short int port, +unsigned char val) +#else +outb(port, val) +unsigned short int port; +unsigned char val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +} + + +static __inline__ void +#if NeedFunctionPrototypes +outw( +unsigned short int port, +unsigned short int val) +#else +outw(port, val) +unsigned short int port; +unsigned short int val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ void +#if NeedFunctionPrototypes +outl( +unsigned short int port, +unsigned int val) +#else +outl(port, val) +unsigned short int port; +unsigned int val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inb( +unsigned short int port) +#else +inb(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inw( +unsigned short int port) +#else +inw(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned short int ret; + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inl( +unsigned short int port) +#else +inl(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +#else /* PC98 */ + +static __inline__ void +#if NeedFunctionPrototypes +_outb( +unsigned short int port, +unsigned char val) +#else +_outb(port, val) +unsigned short int port; +unsigned char val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port)); +} + +static __inline__ void +#if NeedFunctionPrototypes +_outw( +unsigned short int port, +unsigned short int val) +#else +_outw(port, val) +unsigned short int port; +unsigned short int val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port)); +} + +static __inline__ void +#if NeedFunctionPrototypes +_outl( +unsigned short int port, +unsigned int val) +#else +_outl(port, val) +unsigned short int port; +unsigned int val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +} + + +static __inline__ unsigned int +#if NeedFunctionPrototypes +_inb( +unsigned short int port) +#else +_inb(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +_inw( +unsigned short int port) +#else +_inw(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned short ret; + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +_inl( +unsigned short int port) +#else +_inl(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + + +#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968) +#define PW_PORT 0x600 +extern short chipID; +#if NeedFunctionPrototypes +extern void *mmioBase; +#else +extern unsigned char *mmioBase; +#endif +extern unsigned short _port_tbl[]; +#define port_convert(x) _port_tbl[(unsigned short)x] +#endif + +#if defined(PC98_WAB) || defined(PC98_GANB_WAP) +static __inline__ unsigned short +port_convert(unsigned short port) +{ + port <<= 8; + port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ + port |= 0xE0; + return port; +} +#endif /* PC98_WAB || PC98_GANB_WAP */ + +#if defined(PC98_WABEP) +static __inline__ unsigned short +port_convert(unsigned short port) +{ + port &= 0x7f; /* Mask 0000 0000 0111 1111 */ + port |= 0x0f00; + return port; +} +#endif /* PC98_WABEP */ + +#ifdef PC98_WSNA +static __inline__ unsigned short +port_convert(unsigned short port) +{ + port <<= 8; + port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ + port |= 0xE2; + return port; +} +#endif /* PC98_WSNA */ + +#ifdef PC98_NKVNEC +#ifdef PC98_NEC_CIRRUS2 +static __inline__ unsigned short +port_convert(unsigned short port) +{ + port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050; + return port; +} +#else +static __inline__ unsigned short +port_convert(unsigned short port) +{ + port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0; + return port; +} +#endif /* PC98_NEC_CIRRUS2 */ +#endif /* PC98_NKVNEC */ + +#if defined(PC98_TGUI) || defined(PC98_MGA) +#if NeedFunctionPrototypes +extern void *mmioBase; +#else +extern unsigned char *mmioBase; +#endif +#endif + +static __inline__ void +#if NeedFunctionPrototypes +outb( +unsigned short port, +unsigned char val) +#else +outb(port, val) +unsigned short port; +unsigned char val; +#endif /* NeedFunctionPrototypes */ +{ +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val); +#else + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +#endif +} + +static __inline__ void +#if NeedFunctionPrototypes +outw( +unsigned short port, +unsigned short val) +#else +outw(port, val) +unsigned short port; +unsigned short val; +#endif /* NeedFunctionPrototypes */ +{ +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val); +#else + __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); +#endif +} + +static __inline__ void +#if NeedFunctionPrototypes +outl( +unsigned short port, +unsigned int val) +#else +outl(port, val) +unsigned short port; +unsigned int val; +#endif /* NeedFunctionPrototypes */ +{ +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val); +#else + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +#endif +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inb( +unsigned short port) +#else +inb(port) +unsigned short port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned char ret; + +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + ret =*(volatile unsigned char *)((char *)mmioBase+(port)); +#else + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); +#endif + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inw( +unsigned short port) +#else +inw(port) +unsigned short port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned short ret; + +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + ret =*(volatile unsigned short *)((char *)mmioBase+(port)); +#else + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); +#endif + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inl( +unsigned short port) +#else +inl(port) +unsigned short port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned int ret; + +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + ret =*(volatile unsigned int *)((char *)mmioBase+(port)); +#else + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); +#endif + return ret; +} + +#endif /* PC98 */ + +#else /* GCCUSESGAS */ + +static __inline__ void +#if NeedFunctionPrototypes +outb( +unsigned short int port, +unsigned char val) +#else +outb(port, val) +unsigned short int port; +unsigned char val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ void +#if NeedFunctionPrototypes +outw( +unsigned short int port, +unsigned short int val) +#else +outw(port, val) +unsigned short int port; +unsigned short int val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ void +#if NeedFunctionPrototypes +outl( +unsigned short int port, +unsigned int val) +#else +outl(port, val) +unsigned short int port; +unsigned int val; +#endif /* NeedFunctionPrototypes */ +{ + __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inb( +unsigned short int port) +#else +inb(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned char ret; + __asm__ __volatile__("in%B0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inw( +unsigned short int port) +#else +inw(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned short int ret; + __asm__ __volatile__("in%W0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inl( +unsigned short int port) +#else +inl(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + unsigned int ret; + __asm__ __volatile__("in%L0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +#endif /* GCCUSESGAS */ + +#else /* !defined(FAKEIT) && !defined(__mc68000__) */ + +static __inline__ void +#if NeedFunctionPrototypes +outb( +unsigned short int port, +unsigned char val) +#else +outb(port, val) +unsigned short int port; +unsigned char val; +#endif /* NeedFunctionPrototypes */ +{ +} + +static __inline__ void +#if NeedFunctionPrototypes +outw( +unsigned short int port, +unsigned short int val) +#else +outw(port, val) +unsigned short int port; +unsigned short int val; +#endif /* NeedFunctionPrototypes */ +{ +} + +static __inline__ void +#if NeedFunctionPrototypes +outl( +unsigned short int port, +unsigned int val) +#else +outl(port, val) +unsigned short int port; +unsigned int val; +#endif /* NeedFunctionPrototypes */ +{ +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inb( +unsigned short int port) +#else +inb(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + return 0; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inw( +unsigned short int port) +#else +inw(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + return 0; +} + +static __inline__ unsigned int +#if NeedFunctionPrototypes +inl( +unsigned short int port) +#else +inl(port) +unsigned short int port; +#endif /* NeedFunctionPrototypes */ +{ + return 0; +} + +#endif /* FAKEIT */ + +#endif /* defined(mips) */ +#endif /* defined(AlphaArchitecture) && defined(LinuxArchitecture) */ + +#else /* __GNUC__ */ +#if !defined(AMOEBA) && !defined(MINIX) +# if defined(__STDC__) && (__STDC__ == 1) +# ifndef asm +# define asm __asm +# endif +# endif +# ifdef SVR4 +# include <sys/types.h> +# ifndef __HIGHC__ +# ifndef __USLC__ +# define __USLC__ +# endif +# endif +# endif +# ifndef PC98 +# ifndef SCO325 +# include <sys/inline.h> +# else +# include "scoasm.h" +# endif +# else +#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968) +#define PW_PORT 0x600 +extern short chipID; +#if NeedFunctionPrototypes +extern void *mmioBase; +#else +extern unsigned char *mmioBase; +#endif +extern unsigned short _port_tbl[]; +#define port_convert(x) _port_tbl[(unsigned short)x] +#endif + +#if defined(PC98_TGUI) || defined(PC98_MGA) +#if NeedFunctionPrototypes +extern void *mmioBase; +#else +extern unsigned char *mmioBase; +#endif +#endif + +asm void _outl(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + outl (%dx) +%reg port; mem val; + movl port, %edx + movl val, %eax + outl (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + outl (%dx) +%mem port,val; + movw port, %dx + movl val, %eax + outl (%dx) +} + +asm void _outw(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + data16 + outl (%dx) +%reg port; mem val; + movl port, %edx + movw val, %ax + data16 + outl (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + data16 + outl (%dx) +%mem port,val; + movw port, %dx + movw val, %ax + data16 + outl (%dx) +} + +asm void _outb(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + outb (%dx) +%reg port; mem val; + movl port, %edx + movb val, %al + outb (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + outb (%dx) +%mem port,val; + movw port, %dx + movb val, %al + outb (%dx) +} + +asm int _inl(port) +{ +%reg port; + movl port, %edx + inl (%dx) +%mem port; + movw port, %dx + inl (%dx) +} + +asm int _inw(port) +{ +%reg port; + subl %eax, %eax + movl port, %edx + data16 + inl (%dx) +%mem port; + subl %eax, %eax + movw port, %dx + data16 + inl (%dx) +} + +asm int _inb(port) +{ +%reg port; + subl %eax, %eax + movl port, %edx + inb (%dx) +%mem port; + subl %eax, %eax + movw port, %dx + inb (%dx) +} + +#if defined(PC98_WAB) || defined(PC98_GANB_WAP) +static unsigned short +port_convert(unsigned short port) +{ + port <<= 8; + port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ + port |= 0xE0; + return port; +} +#endif /* PC98_WAB || PC98_GANB_WAP */ + +#if defined(PC98_WABEP) +static unsigned short +port_convert(unsigned short port) +{ + port &= 0x7f; /* Mask 0000 0000 0111 1111 */ + port |= 0x0f00; + return port; +} +#endif /* PC98_WABEP */ + +#ifdef PC98_WSNA +static unsigned short +port_convert(unsigned short port) +{ + port <<= 8; + port &= 0x7f00; /* Mask 0111 1111 0000 0000 */ + port |= 0xE2; + return port; +} +#endif /* PC98_WSNA */ + +#ifdef PC98_NKVNEC +#ifdef PC98_NEC_CIRRUS2 +static unsigned short +port_convert(unsigned short port) +{ + port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050; + return port; +} +#else +static unsigned short +port_convert(unsigned short port) +{ + port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0; + return port; +} +#endif /* PC98_NEC_CIRRUS2 */ +#endif /* PC98_NKVNEC */ + +static void outl(port,val) +{ +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val); +#else + _outl(port,val); +#endif +} + +static void outw(port,val) +{ +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val); +#else + _outw(port,val); +#endif +} + +static void outb(port,val) +{ +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val); +#else + _outb(port,val); +#endif +} + +static int inl(port) +{ + unsigned int ret; + +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + ret =*(volatile unsigned int *)((char *)mmioBase+(port)); +#else + ret = _inl(port); +#endif + return ret; +} + +static int inw(port) +{ + unsigned short ret; + +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + ret =*(volatile unsigned short *)((char *)mmioBase+(port)); +#else + ret = _inw(port); +#endif + return ret; +} + +static int inb(port) +{ + unsigned char ret; + +#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \ + defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \ + defined(PC98_XKB) || defined(PC98_NEC) + unsigned short tmp; + tmp=port_convert(port); + port=tmp; +#endif + +#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA) + ret =*(volatile unsigned char *)((char *)mmioBase+(port)); +#else + ret = _inb(port); +#endif + return ret; +} + + +# endif /* PC98 */ +# if !defined(__HIGHC__) && !defined(SCO325) +# pragma asm partial_optimization outl +# pragma asm partial_optimization outw +# pragma asm partial_optimization outb +# pragma asm partial_optimization inl +# pragma asm partial_optimization inw +# pragma asm partial_optimization inb +# endif +#endif +#define ldq_u(p) (*((unsigned long *)(p))) +#define ldl_u(p) (*((unsigned int *)(p))) +#define ldw_u(p) (*((unsigned short *)(p))) +#define stq_u(v,p) ((unsigned long *)(p)) = (v) +#define stl_u(v,p) ((unsigned int *)(p)) = (v) +#define stw_u(v,p) ((unsigned short *)(p)) = (v) +#define mem_barrier() /* NOP */ +#define write_mem_barrier() /* NOP */ +#endif /* __GNUC__ */ + +#if defined(IODEBUG) && defined(__GNUC__) +#undef inb +#undef inw +#undef inl +#undef outb +#undef outw +#undef outl +#define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +#define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) +#define inl(a) __extension__ ({unsigned long __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;}) + +#define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b)) +#define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b)) +#define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b)) +#endif + +/* + * This header sometimes gets included where is isn't needed, and on some + * OSs this causes problems because the following functions generate + * references to inb() and outb() which can't be resolved. Defining + * NO_COMPILER_H_EXTRAS avoids this problem. + */ + +#ifndef NO_COMPILER_H_EXTRAS +/* + *----------------------------------------------------------------------- + * Port manipulation convenience functions + *----------------------------------------------------------------------- + */ + +#ifndef __GNUC__ +#define __inline__ /**/ +#endif + +/* + * rdinx - read the indexed byte port 'port', index 'ind', and return its value + */ +static __inline__ unsigned char +#ifdef __STDC__ +rdinx(unsigned short int port, unsigned char ind) +#else +rdinx(port, ind) +unsigned short int port; +unsigned char ind; +#endif +{ + if (port == 0x3C0) /* reset attribute flip-flop */ + (void) inb(0x3DA); + outb(port, ind); + return(inb(port+1)); +} + +/* + * wrinx - write 'val' to port 'port', index 'ind' + */ +static __inline__ void +#ifdef __STDC__ +wrinx(unsigned short int port, unsigned char ind, unsigned char val) +#else +wrinx(port, ind, val) +unsigned short int port; +unsigned char ind, val; +#endif +{ + outb(port, ind); + outb(port+1, val); +} + +/* + * modinx - in register 'port', index 'ind', set the bits in 'mask' as in 'new'; + * the other bits are unchanged. + */ +static __inline__ void +#ifdef __STDC__ +modinx(unsigned short int port, unsigned char ind, + unsigned char mask, unsigned char new) +#else +modinx(port, ind, mask, new) +unsigned short int port; +unsigned char ind, mask, new; +#endif +{ + unsigned char tmp; + + tmp = (rdinx(port, ind) & ~mask) | (new & mask); + wrinx(port, ind, tmp); +} + +/* + * tstrg - returns true iff the bits in 'mask' of register 'port' are + * readable & writable. + */ + +static __inline__ int +#ifdef __STDC__ +testrg(unsigned short int port, unsigned char mask) +#else +tstrg(port, mask) +unsigned short int port; +unsigned char mask; +#endif +{ + unsigned char old, new1, new2; + + old = inb(port); + outb(port, old & ~mask); + new1 = inb(port) & mask; + outb(port, old | mask); + new2 = inb(port) & mask; + outb(port, old); + return((new1 == 0) && (new2 == mask)); +} + +/* + * testinx2 - returns true iff the bits in 'mask' of register 'port', index + * 'ind' are readable & writable. + */ +static __inline__ int +#ifdef __STDC__ +testinx2(unsigned short int port, unsigned char ind, unsigned char mask) +#else +testinx2(port, ind, mask) +unsigned short int port; +unsigned char ind, mask; +#endif +{ + unsigned char old, new1, new2; + + old = rdinx(port, ind); + wrinx(port, ind, old & ~mask); + new1 = rdinx(port, ind) & mask; + wrinx(port, ind, old | mask); + new2 = rdinx(port, ind) & mask; + wrinx(port, ind, old); + return((new1 == 0) && (new2 == mask)); +} + +/* + * testinx - returns true iff all bits of register 'port', index 'ind' are + * readable & writable. + */ +static __inline__ int +#ifdef __STDC__ +testinx(unsigned short int port, unsigned char ind) +#else +testinx(port, ind, mask) +unsigned short int port; +unsigned char ind; +#endif +{ + return(testinx2(port, ind, 0xFF)); +} +#endif /* NO_COMPILER_H_EXTRAS */ + +#endif /* NO_INLINE */ +#endif /* _COMPILER_H */ diff --git a/hw/xfree86/common/scoasm.h b/hw/xfree86/common/scoasm.h new file mode 100644 index 000000000..12fe46693 --- /dev/null +++ b/hw/xfree86/common/scoasm.h @@ -0,0 +1,112 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/scoasm.h,v 3.0 1996/10/03 08:34:06 dawes Exp $ */ + +/* + * scoasm.h - used to define inline versions of certain functions which + * do NOT appear in sys/inline.h. + */ +#ifdef SCO325 +#ifndef _SCOASM_HDR_INC +#define _SCOASM_HDR_INC + +asm void outl(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + outl (%dx) +%reg port; mem val; + movl port, %edx + movl val, %eax + outl (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + outl (%dx) +%mem port,val; + movw port, %dx + movl val, %eax + outl (%dx) +} + +asm void outw(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + data16 + outl (%dx) +%reg port; mem val; + movl port, %edx + movw val, %ax + data16 + outl (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + data16 + outl (%dx) +%mem port,val; + movw port, %dx + movw val, %ax + data16 + outl (%dx) +} + +asm void outb(port,val) +{ +%reg port,val; + movl port, %edx + movl val, %eax + outb (%dx) +%reg port; mem val; + movl port, %edx + movb val, %al + outb (%dx) +%mem port; reg val; + movw port, %dx + movl val, %eax + outb (%dx) +%mem port,val; + movw port, %dx + movb val, %al + outb (%dx) +} + +asm int inl(port) +{ +%reg port; + movl port, %edx + inl (%dx) +%mem port; + movw port, %dx + inl (%dx) +} + +asm int inw(port) +{ +%reg port; + subl %eax, %eax + movl port, %edx + data16 + inl (%dx) +%mem port; + subl %eax, %eax + movw port, %dx + data16 + inl (%dx) +} + +asm int inb(port) +{ +%reg port; + subl %eax, %eax + movl port, %edx + inb (%dx) +%mem port; + subl %eax, %eax + movw port, %dx + inb (%dx) +} + +#endif /* _SCOASM_HDR_INC */ +#endif /* SCO325 */ diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h new file mode 100644 index 000000000..ba00913d8 --- /dev/null +++ b/hw/xfree86/common/xf86.h @@ -0,0 +1,743 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.47.2.8 1998/02/24 19:05:53 hohndel Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86.h,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */ + +#ifndef _XF86_H +#define _XF86_H + +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86_Option.h" + +/* + * structure common for all modes + */ +typedef struct _DispM { + struct _DispM *prev,*next; + char *name; /* identifier of this mode */ + /* These are the values that the user sees/provides */ + int Clock; /* pixel clock */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int Flags; + /* These are the values the hardware uses */ + int SynthClock; /* Actual clock freq to be programmed */ + int CrtcHDisplay; + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHTotal; + int CrtcHSkew; + int CrtcVDisplay; + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVTotal; + Bool CrtcHAdjusted; + Bool CrtcVAdjusted; + int PrivSize; + INT32 *Private; +} DisplayModeRec, *DisplayModePtr; + +#define V_PHSYNC 0x0001 +#define V_NHSYNC 0x0002 +#define V_PVSYNC 0x0004 +#define V_NVSYNC 0x0008 +#define V_INTERLACE 0x0010 +#define V_DBLSCAN 0x0020 +#define V_CSYNC 0x0040 +#define V_PCSYNC 0x0080 +#define V_NCSYNC 0x0100 +#define V_HSKEW 0x0200 /* hskew provided */ +#define V_PIXMUX 0x1000 +#define V_DBLCLK 0x2000 +#define V_CLKDIV2 0x4000 + +/* The monitor description */ + +#define MAX_HSYNC 8 +#define MAX_VREFRESH 8 + +typedef struct { float hi, lo; } range; + +typedef struct { + char *id; + char *vendor; + char *model; + float EMPTY; + int n_hsync; + range hsync[MAX_HSYNC]; + int n_vrefresh; + range vrefresh[MAX_VREFRESH]; + DisplayModePtr Modes, Last; /* Start and end of monitor's mode list */ +} MonRec, *MonPtr; + +#define MAXCLOCKS 128 +#define MAXDACSPEEDS 4 /* for <= 8, 16, 24, 32bpp */ + +/* Set default max allowed clock to 90MHz */ +#define DEFAULT_MAX_CLOCK 90000 + +/* + * the graphic device + */ +typedef struct { + Bool configured; + int tmpIndex; + int scrnIndex; + Bool (* Probe)( +#if NeedNestedPrototypes + void +#endif +); + Bool (* Init)( +#if NeedNestedPrototypes + int scr_index, + ScreenPtr pScreen, + int argc, + char **argv +#endif +); + int (* ValidMode)( +#if NeedNestedPrototypes + DisplayModePtr target, + Bool verbose, + int flag +#endif +); + void (* EnterLeaveVT)( +#if NeedNestedPrototypes + int, + int +#endif +); + void (* EnterLeaveMonitor)( +#if NeedNestedPrototypes + int +#endif +); + void (* EnterLeaveCursor)( +#if NeedNestedPrototypes + int +#endif +); + void (* AdjustFrame)( +#if NeedNestedPrototypes + int x, + int y +#endif +); + Bool (* SwitchMode)( +#if NeedNestedPrototypes + DisplayModePtr modes +#endif +); + void (* DPMSSet)( +#if NeedNestedPrototypes + int level +#endif +); + void (* PrintIdent)( +#if NeedNestedPrototypes + void +#endif +); + int depth; + xrgb weight; + int bitsPerPixel; + int defaultVisual; + int virtualX,virtualY; + int displayWidth; + int frameX0, frameY0, frameX1, frameY1; + OFlagSet options; + OFlagSet clockOptions; + OFlagSet xconfigFlag; + char *chipset; + char *ramdac; + int dacSpeeds[MAXDACSPEEDS]; + int dacSpeedBpp; + int clocks; + int clock[MAXCLOCKS]; + int maxClock; + int videoRam; + int BIOSbase; /* Base address of video BIOS */ + unsigned long MemBase; /* Frame buffer base address */ + int width, height; /* real display dimensions */ + unsigned long speedup; /* Use SpeedUp code */ + DisplayModePtr modes; + MonPtr monitor; + char *clockprog; + int textclock; + Bool bankedMono; /* display supports banking for mono server */ + char *name; + xrgb blackColour; + xrgb whiteColour; + int *validTokens; + char *patchLevel; + unsigned int IObase; /* AGX - video card I/O reg base */ + unsigned int DACbase; /* AGX - dac I/O reg base */ + unsigned long COPbase; /* AGX - coprocessor memory base */ + unsigned int POSbase; /* AGX - I/O address of POS regs */ + int instance; /* AGX - XGA video card instance number */ + int s3Madjust; + int s3Nadjust; + int s3MClk; + int chipID; + int chipRev; + unsigned long VGAbase; /* AGX - 64K aperture memory address */ + int s3RefClk; + int s3BlankDelay; + int textClockFreq; + char *DCConfig; + char *DCOptions; + int MemClk; /* General flag used for memory clocking */ + int LCDClk; +#ifdef XFreeXDGA + int directMode; + void (*setBank)( +#if NeedNestedPrototypes + int +#endif + ); + unsigned long physBase; + int physSize; +#endif +#ifdef XF86SETUP + void *device; /* This should be GDevPtr, but it causes + problems with include file order */ +#endif +} ScrnInfoRec, *ScrnInfoPtr; + +typedef struct { + int token; /* id of the token */ + char *name; /* pointer to the LOWERCASED name */ +} SymTabRec, *SymTabPtr; + +#define VGA_DRIVER 1 +#define V256_DRIVER 2 +#define WGA_DRIVER 3 +#define XGA_DRIVER 4 + +#define ENTER 1 +#define LEAVE 0 + +/* These are possible return values for xf86CheckMode() and ValidMode() */ +#define MODE_OK 0 +#define MODE_HSYNC 1 /* hsync out of range */ +#define MODE_VSYNC 2 /* vsync out of range */ +#define MODE_BAD 255 /* unspecified reason */ + +/* These are the possible flags for ValidMode */ +#define MODE_USED 1 /* this mode is really being used in the */ + /* modes line of the Display Subsection */ +#define MODE_SUGGESTED 2 /* this mode is included in the available*/ + /* modes in the Monitor Section */ +#define MODE_VID 3 /* this is called from the VidMode extension */ + +/* Indicates the level of DPMS support */ +typedef enum { + DPMSSupportUnknown, + DPMSNotSupported, + DPMSFullSupport +} DPMSSupportStatus; + +/* flags for xf86LookupMode */ +#define LOOKUP_DEFAULT 0 /* Use default mode lookup method */ +#define LOOKUP_BEST_REFRESH 1 /* Pick modes with best refresh */ +#define LOOKUP_NO_INTERLACED 2 /* Ignore interlaced modes */ +#define LOOKUP_FORCE_DEFAULT 4 /* Force default lookup method */ + +#define INTERLACE_REFRESH_WEIGHT 1.5 + +/* SpeedUp options */ + +#define SPEEDUP_FILLBOX 1 +#define SPEEDUP_FILLRECT 2 +#define SPEEDUP_BITBLT 4 +#define SPEEDUP_LINE 8 +#define SPEEDUP_TEGBLT8 0x10 +#define SPEEDUP_RECTSTIP 0x20 + +/* + * This is the routines where SpeedUp is quicker than fXF86. The problem is + * that the SpeedUp fillbox is better for drawing vertical and horizontal + * line segments, and the fXF86 version is significantly better for + * more general lines + */ +#define SPEEDUP_BEST (SPEEDUP_FILLRECT | SPEEDUP_BITBLT | \ + SPEEDUP_LINE | SPEEDUP_TEGBLT8 | \ + SPEEDUP_RECTSTIP) +/* +#define SPEEDUP_BEST (SPEEDUP_FILLBOX | SPEEDUP_FILLRECT | \ + SPEEDUP_BITBLT | SPEEDUP_LINE | \ + SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP) +*/ + +/* + * SpeedUp routines which are not dependent on the screen virtual resolution + */ +#ifndef SPEEDUP_ANYWIDTH +#define SPEEDUP_ANYWIDTH (SPEEDUP_FILLRECT | SPEEDUP_BITBLT | \ + SPEEDUP_LINE | SPEEDUP_FILLBOX) +#endif + +/* + * SpeedUp routines which are not dependent on ET4000 + */ +#ifndef SPEEDUP_ANYCHIPSET +#define SPEEDUP_ANYCHIPSET (SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP) +#endif + +/* All SpeedUps */ +#define SPEEDUP_ALL (SPEEDUP_FILLBOX | SPEEDUP_FILLRECT | \ + SPEEDUP_BITBLT | SPEEDUP_LINE | \ + SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP) + +/* SpeedUp flags used if SpeedUp is not in XF86Config */ +#define SPEEDUP_DEFAULT SPEEDUP_ALL + +extern Bool xf86VTSema; + +/* Mouse device private record */ + +#define MSE_MAPTOX (-1) +#define MSE_MAPTOY (-2) +#define MSE_MAXBUTTONS 12 +#define MSE_DFLTBUTTONS 3 + +typedef struct _MouseDevRec { + DeviceProc mseProc; /* procedure for initializing */ + void (* mseEvents)( +#if NeedNestedPrototypes + struct _MouseDevRec * +#endif + ); /* proc for processing events */ + DeviceIntPtr device; + int mseFd; + char *mseDevice; + int mseType; + int mseModel; + int baudRate; + int oldBaudRate; + int sampleRate; + int lastButtons; + int threshold, num, den; /* acceleration */ + int buttons; /* # of buttons */ + int emulateState; /* automata state for 2 button mode */ + Bool emulate3Buttons; + int emulate3Timeout; /* Timeout for 3 button emulation */ + Bool chordMiddle; + int mouseFlags; /* Flags to Clear after opening mouse dev */ + int truebuttons; /* Arg to maintain before emulate3buttons timer callback */ + + int resolution; + int negativeZ; + int positiveZ; +#ifndef MOUSE_PROTOCOL_IN_KERNEL + unsigned char protoPara[7]; +#endif + +#ifndef CSRG_BASED + /* xque part */ + int xquePending; /* was xqueFd, but nothing uses that */ + int xqueSema; +#endif +#ifdef XINPUT + struct _LocalDeviceRec *local; +#endif +} MouseDevRec, *MouseDevPtr; + +#ifdef XINPUT +#define MOUSE_DEV(dev) (MouseDevPtr) PRIVATE(dev) +#else +#define MOUSE_DEV(dev) (MouseDevPtr) (dev)->public.devicePrivate +#endif + +/* Global data */ +/* xf86Init.c */ +extern double xf86rGamma, xf86gGamma, xf86bGamma; + +#ifdef XF86VIDMODE +extern Bool xf86VidModeEnabled; +extern Bool xf86VidModeAllowNonLocal; +#endif +#ifdef XF86MISC +extern Bool xf86MiscModInDevEnabled; +extern Bool xf86MiscModInDevAllowNonLocal; +#endif + +/* PCI probe flags */ + + +typedef enum { + PCIProbe1 = 0, + PCIProbe2, + PCIForceConfig1, + PCIForceConfig2 +} PciProbeType; + +extern PciProbeType xf86PCIFlags; + +/* Function Prototypes */ +#ifndef _NO_XF86_PROTOTYPES + +/* xf86Init.c */ +void InitOutput( +#if NeedFunctionPrototypes + ScreenInfo *pScreenInfo, + int argc, + char **argv +#endif +); + +void InitInput( +#if NeedFunctionPrototypes + int argc, + char **argv +#endif +); + +void ddxGiveUp( +#if NeedFunctionPrototypes + void +#endif +); + +void AbortDDX( +#if NeedFunctionPrototypes + void +#endif +); + +int ddxProcessArgument( +#if NeedFunctionPrototypes + int argc, + char *argv[], + int i +#endif +); + +void ddxUseMsg( +#if NeedFunctionPrototypes + void +#endif +); + +/* xf86Config.c */ +unsigned int StrToUL( +#if NeedFunctionPrototypes + char *str +#endif +); + +#ifndef CONFIG_RETURN_TYPE +#ifdef XF86SETUP +#define CONFIG_RETURN_TYPE int +#else +#define CONFIG_RETURN_TYPE void +#endif +#endif + +CONFIG_RETURN_TYPE xf86Config( +#if NeedFunctionPrototypes + int vtopen +#endif +); + +CONFIG_RETURN_TYPE configPointerSection( +#if NeedFunctionPrototypes + MouseDevPtr /*mouse_dev*/, + int /*end_tag*/, + char** /*devicename*/ +#endif +); + +Bool xf86LookupMode( +#if NeedFunctionPrototypes + DisplayModePtr target, + ScrnInfoPtr driver, + int flags +#endif +); + +void xf86VerifyOptions( +#if NeedFunctionPrototypes + OFlagSet *allowedOptions, + ScrnInfoPtr driver +#endif +); + +int xf86CheckMode( +#if NeedFunctionPrototypes + ScrnInfoPtr scrp, + DisplayModePtr dispmp, + MonPtr monp, + int verbose +#endif +); + +int xf86GetNearestClock( +#if NeedFunctionPrototypes + ScrnInfoPtr Screen, + int Frequency +#endif +); + +/* xf86Cursor.c */ +void xf86InitViewport( +#if NeedFunctionPrototypes + ScrnInfoPtr pScr +#endif +); + +void xf86SetViewport( +#if NeedFunctionPrototypes + ScreenPtr pScreen, + int x, + int y +#endif +); + +void xf86LockZoom( +#if NeedFunctionPrototypes + ScreenPtr pScreen, + int lock +#endif +); + +void xf86ZoomViewport( +#if NeedFunctionPrototypes + ScreenPtr pScreen, + int zoom +#endif +); + +/* xf86Dl.c */ +void* +xf86LoadModule( +#if NeedFunctionPrototypes + const char * file, + const char * path +#endif +); + +/* xf86Events.c */ +int TimeSinceLastInputEvent( +#if NeedFunctionPrototypes + void +#endif +); + +void SetTimeSinceLastInputEvent( +#if NeedFunctionPrototypes + void +#endif +); + +void ProcessInputEvents( +#if NeedFunctionPrototypes + void +#endif +); + +void xf86PostKbdEvent( +#if NeedFunctionPrototypes + unsigned key +#endif +); + +void xf86PostMseEvent( +#if NeedFunctionPrototypes + DeviceIntPtr device, + int buttons, + int dx, + int dy +#endif +); + +void xf86Block( +#if NeedFunctionPrototypes + pointer blockData, + OSTimePtr pTimeout, + pointer pReadmask +#endif +); + +void xf86Wakeup( +#if NeedFunctionPrototypes + pointer blockData, + int err, + pointer pReadmask +#endif +); + +void xf86SigHandler( +#if NeedFunctionPrototypes + int signo +#endif +); + +/* xf86Io.c */ +void xf86KbdBell( +#if NeedFunctionPrototypes + int percent, + DeviceIntPtr pKeyboard, + pointer ctrl, + int unused +#endif +); + +void xf86KbdLeds( +#if NeedFunctionPrototypes + void +#endif +); + +void xf86KbdCtrl( +#if NeedFunctionPrototypes + DevicePtr pKeyboard, + KeybdCtrl *ctrl +#endif +); + +void xf86InitKBD( +#if NeedFunctionPrototypes + Bool init +#endif +); + +int xf86KbdProc( +#if NeedFunctionPrototypes + DeviceIntPtr pKeyboard, + int what +#endif +); + +void xf86MseCtrl( +#if NeedFunctionPrototypes + DevicePtr pPointer, + PtrCtrl *ctrl +#endif +); + +int GetMotionEvents( +#if NeedFunctionPrototypes + DeviceIntPtr, + xTimecoord *, + unsigned long, + unsigned long, + ScreenPtr +#endif +); + +int xf86MseProc( +#if NeedFunctionPrototypes + DeviceIntPtr pPointer, + int what +#endif +); + +void xf86MseEvents( +#if NeedFunctionPrototypes + MouseDevPtr mouse +#endif +); + +CARD32 GetTimeInMillis( +#if NeedFunctionPrototypes + void +#endif +); + +void OsVendorInit( +#if NeedFunctionPrototypes + void +#endif +); + +/* xf86_Mouse.c */ +Bool xf86MouseSupported( +#if NeedFunctionPrototypes + int mousetype +#endif +); + +void xf86SetupMouse( +#if NeedFunctionPrototypes + MouseDevPtr mouse +#endif +); + +void xf86MouseProtocol( +#if NeedFunctionPrototypes + DeviceIntPtr device, + unsigned char *rBuf, + int nBytes +#endif +); + +#ifdef XINPUT +void xf86MouseCtrl( +#if NeedFunctionPrototypes + DeviceIntPtr device, + PtrCtrl *ctrl +#endif +); +#endif + +/* xf86_PnPMouse.c */ +int xf86GetPnPMouseProtocol( +#if NeedFunctionPrototypes + MouseDevPtr mouse +#endif +); + +/* xf86Kbd.c */ +Bool LegalModifier( +#if NeedFunctionPrototypes + unsigned int key, + DevicePtr pDev +#endif +); + +void xf86KbdGetMapping( +#if NeedFunctionPrototypes + KeySymsPtr pKeySyms, + CARD8 *pModMap +#endif +); +#endif /* _NO_XF86_PROTOTYPES */ + +/* End of Prototypes */ + +#endif /* _XF86_H */ + + diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c new file mode 100644 index 000000000..e523dd0fc --- /dev/null +++ b/hw/xfree86/common/xf86Config.c @@ -0,0 +1,3934 @@ +/* + * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.113.2.17 1998/02/24 19:05:54 hohndel Exp $ + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* $Xorg: xf86Config.c,v 1.3 2000/08/17 19:50:28 cpqbld Exp $ */ + +#ifndef X_NOT_STDC_ENV +#include <stdlib.h> +#else +extern double atof(); +extern char *getenv(); +#endif + +#define NEED_EVENTS 1 +#include "X.h" +#include "Xproto.h" +#include "Xmd.h" +#include "input.h" +#include "servermd.h" +#include "scrnintstr.h" + +#ifdef DPMSExtension +#include "opaque.h" +extern CARD32 DPMSStandbyTime; +extern CARD32 DPMSSuspendTime; +extern CARD32 DPMSOffTime; +#endif + +#define NO_COMPILER_H_EXTRAS +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +#define INIT_CONFIG +#include "xf86_Config.h" + +#ifdef XKB +#include "inputstr.h" +#include "XKBsrv.h" +#endif + +#ifdef XF86SETUP +#include "xfsconf.h" +#endif + +#ifdef XINPUT +#include "xf86Xinput.h" + +#ifndef XF86SETUP +extern DeviceAssocRec mouse_assoc; +#endif +#endif + +#ifdef NEED_RETURN_VALUE +#define HANDLE_RETURN(xx) if (xx == RET_ERROR) return RET_ERROR +#else +#define HANDLE_RETURN(xx) xx +#endif + +#define CONFIG_BUF_LEN 1024 + +static FILE * configFile = NULL; +static int configStart = 0; /* start of the current token */ +static int configPos = 0; /* current readers position */ +static int configLineNo = 0; /* linenumber */ +static char *configBuf,*configRBuf; /* buffer for lines */ +static char *configPath; /* path to config file */ +static char *fontPath = NULL; /* font path */ +static char *modulePath = NULL; /* module path */ +static int pushToken = LOCK_TOKEN; +static LexRec val; /* global return value */ +static char DCerr; +static int scr_index = 0; + +#ifdef XF86SETUP +#define STATIC_OR_NOT +#else +#define STATIC_OR_NOT static +#endif +STATIC_OR_NOT int n_monitors = 0; +STATIC_OR_NOT MonPtr monitor_list = NULL; +STATIC_OR_NOT int n_devices = 0; +STATIC_OR_NOT GDevPtr device_list = NULL; + +static int screenno = -100; /* some little number ... */ + +extern char *defaultFontPath; +extern char *rgbPath; + +extern Bool xf86fpFlag, xf86coFlag, xf86sFlag; +extern Bool xf86ScreensOpen; + +extern int defaultColorVisualClass; +extern CARD32 defaultScreenSaverTime, ScreenSaverTime; + +char *xf86VisualNames[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; + +static CONFIG_RETURN_TYPE configFilesSection( +#if NeedFunctionPrototypes + void +#endif +); +static CONFIG_RETURN_TYPE configServerFlagsSection( +#if NeedFunctionPrototypes + void +#endif +); +static CONFIG_RETURN_TYPE configKeyboardSection( +#if NeedFunctionPrototypes + void +#endif +); +static CONFIG_RETURN_TYPE configDeviceSection( +#if NeedFunctionPrototypes + void +#endif +); +static CONFIG_RETURN_TYPE configScreenSection( +#if NeedFunctionPrototypes + void +#endif +); +static CONFIG_RETURN_TYPE configDisplaySubsection( +#if NeedFunctionPrototypes + DispPtr disp +#endif +); +static CONFIG_RETURN_TYPE configMonitorSection( +#if NeedFunctionPrototypes + void +#endif +); +static CONFIG_RETURN_TYPE configDynamicModuleSection( +#if NeedFunctionPrototypes + void +#endif +); +static char *xf86DCSaveLine( +#if NeedFunctionPrototypes +char *, +int +#endif +); +static char *xf86DCOption( +#if NeedFunctionPrototypes +char *, +LexRec +#endif +); +static char * xf86DCConcatOption( +#if NeedFunctionPrototypes +char *, +char * +#endif +); +#ifndef XF86SETUP +static +#endif +CONFIG_RETURN_TYPE findConfigFile( +#if NeedFunctionPrototypes + char *filename, + FILE **fp +#endif +); +static int getScreenIndex( +#if NeedFunctionPrototypes + int token +#endif +); +static int getStringToken( +#if NeedFunctionPrototypes + SymTabRec tab[] +#endif +); +static CONFIG_RETURN_TYPE readVerboseMode( +#if NeedFunctionPrototypes + MonPtr monp +#endif +); +static Bool validateGraphicsToken( +#if NeedFunctionPrototypes + int *validTokens, + int token +#endif +); +extern char * xf86GetPathElem( +#if NeedFunctionPrototypes + char **pnt +#endif +); +static DisplayModePtr xf86PruneModes( +#if NeedFunctionPrototypes + MonPtr monp, + DisplayModePtr allmodes, + ScrnInfoPtr scrp, + Bool card +#endif +); +static char * xf86ValidateFontPath( +#if NeedFunctionPrototypes + char * /* path */ +#endif +); +#ifdef XINPUT +extern CONFIG_RETURN_TYPE xf86ConfigExtendedInputSection( +#if NeedFunctionPrototypes + LexPtr pval +#endif +); +#endif + +#ifdef XKB +extern char *XkbInitialMap; +#endif + +#define DIR_FILE "/fonts.dir" + +/* + * xf86GetPathElem -- + * Extract a single element from the font path string starting at + * pnt. The font path element will be returned, and pnt will be + * updated to point to the start of the next element, or set to + * NULL if there are no more. + */ +char * +xf86GetPathElem(pnt) + char **pnt; +{ + char *p1; + + p1 = *pnt; + *pnt = index(*pnt, ','); + if (*pnt != NULL) { + **pnt = '\0'; + *pnt += 1; + } + return(p1); +} + +/* + * StrToUL -- + * + * A portable, but restricted, version of strtoul(). It only understands + * hex, octal, and decimal. But it's good enough for our needs. + */ +unsigned int StrToUL(str) +char *str; +{ + int base = 10; + char *p = str; + unsigned int tot = 0; + + if (*p == '0') { + p++; + if (*p == 'x') { + p++; + base = 16; + } + else + base = 8; + } + while (*p) { + if ((*p >= '0') && (*p <= ((base == 8)?'7':'9'))) { + tot = tot * base + (*p - '0'); + } + else if ((base == 16) && (*p >= 'a') && (*p <= 'f')) { + tot = tot * base + 10 + (*p - 'a'); + } + else if ((base == 16) && (*p >= 'A') && (*p <= 'F')) { + tot = tot * base + 10 + (*p - 'A'); + } + else { + return(tot); + } + p++; + } + return(tot); +} + +/* + * xf86ValidateFontPath -- + * Validates the user-specified font path. Each element that + * begins with a '/' is checked to make sure the directory exists. + * If the directory exists, the existence of a file named 'fonts.dir' + * is checked. If either check fails, an error is printed and the + * element is removed from the font path. + */ +#define CHECK_TYPE(mode, type) ((S_IFMT & (mode)) == (type)) +static char * +xf86ValidateFontPath(path) + char *path; +{ + char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem; + struct stat stat_buf; + int flag; + int dirlen; + + tmp_path = (char *)Xcalloc(strlen(path)+1); + out_pnt = tmp_path; + path_elem = NULL; + next = path; + while (next != NULL) { + path_elem = xf86GetPathElem(&next); +#ifndef __EMX__ + if (*path_elem == '/') { + dir_elem = (char *)Xcalloc(strlen(path_elem) + 1); + if ((p1 = strchr(path_elem, ':')) != 0) +#else + /* OS/2 must prepend X11ROOT */ + if (*path_elem == '/') { + path_elem = (char*)__XOS2RedirRoot(path_elem); + dir_elem = (char*)xcalloc(1, strlen(path_elem) + 1); + if (p1 = strchr(path_elem+2, ':')) +#endif + dirlen = p1 - path_elem; + else + dirlen = strlen(path_elem); + strncpy(dir_elem, path_elem, dirlen); + dir_elem[dirlen] = '\0'; + flag = stat(dir_elem, &stat_buf); + if (flag == 0) + if (!CHECK_TYPE(stat_buf.st_mode, S_IFDIR)) + flag = -1; + if (flag != 0) { + ErrorF("Warning: The directory \"%s\" does not exist.\n", dir_elem); + ErrorF(" Entry deleted from font path.\n"); + continue; + } + else { + p1 = (char *)xalloc(strlen(dir_elem)+strlen(DIR_FILE)+1); + strcpy(p1, dir_elem); + strcat(p1, DIR_FILE); + flag = stat(p1, &stat_buf); + if (flag == 0) + if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG)) + flag = -1; +#ifndef __EMX__ + xfree(p1); +#endif + if (flag != 0) { + ErrorF("Warning: 'fonts.dir' not found (or not valid) in \"%s\".\n", + dir_elem); + ErrorF(" Entry deleted from font path.\n"); + ErrorF(" (Run 'mkfontdir' on \"%s\").\n", dir_elem); + continue; + } + } + xfree(dir_elem); + } + + /* + * Either an OK directory, or a font server name. So add it to + * the path. + */ + if (out_pnt != tmp_path) + *out_pnt++ = ','; + strcat(out_pnt, path_elem); + out_pnt += strlen(path_elem); + } + return(tmp_path); +} + +/* + * xf86GetToken -- + * Read next Token form the config file. Handle the global variable + * pushToken. + */ +int +xf86GetToken(tab) + SymTabRec tab[]; +{ + int c, i; + + /* + * First check whether pushToken has a different value than LOCK_TOKEN. + * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the other + * case the next token must be read from the input. + */ + if (pushToken == EOF) return(EOF); + else if (pushToken == LOCK_TOKEN) + { + + c = configBuf[configPos]; + + /* + * Get start of next Token. EOF is handled, whitespaces & comments are + * skipped. + */ + do { + if (!c) { + if (fgets(configBuf,CONFIG_BUF_LEN-1,configFile) == NULL) + { + return( pushToken = EOF ); + } + configLineNo++; + configStart = configPos = 0; + } +#ifndef __EMX__ + while (((c=configBuf[configPos++])==' ') || ( c=='\t') || ( c=='\n')); +#else + while (((c=configBuf[configPos++])==' ') || ( c=='\t') || ( c=='\n') + || (c=='\r')); +#endif + if (c == '#') c = '\0'; + } while (!c); + + /* GJA -- handle '-' and ',' + * Be careful: "-hsync" is a keyword. + */ + if ( (c == ',') && !isalpha(configBuf[configPos]) ) { + configStart = configPos; return COMMA; + } else if ( (c == '-') && !isalpha(configBuf[configPos]) ) { + configStart = configPos; return DASH; + } + + configStart = configPos; + /* + * Numbers are returned immediately ... + */ + if (isdigit(c)) + { + int base; + + if (c == '0') + if ((configBuf[configPos] == 'x') || + (configBuf[configPos] == 'X')) + base = 16; + else + base = 8; + else + base = 10; + + configRBuf[0] = c; i = 1; + while (isdigit(c = configBuf[configPos++]) || + (c == '.') || (c == 'x') || + ((base == 16) && (((c >= 'a') && (c <= 'f')) || + ((c >= 'A') && (c <= 'F'))))) + configRBuf[i++] = c; + configPos--; /* GJA -- one too far */ + configRBuf[i] = '\0'; + val.num = StrToUL(configRBuf); + val.realnum = atof(configRBuf); + return(NUMBER); + } + + /* + * All Strings START with a \" ... + */ + else if (c == '\"') + { + i = -1; + do { + configRBuf[++i] = (c = configBuf[configPos++]); +#ifndef __EMX__ + } while ((c != '\"') && (c != '\n') && (c != '\0')); +#else + } while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0')); +#endif + configRBuf[i] = '\0'; + val.str = (char *)xalloc(strlen(configRBuf) + 1); + strcpy(val.str, configRBuf); /* private copy ! */ + return(STRING); + } + + /* + * ... and now we MUST have a valid token. The search is + * handled later along with the pushed tokens. + */ + else + { + configRBuf[0] = c; + i = 0; + do { + configRBuf[++i] = (c = configBuf[configPos++]);; +#ifndef __EMX__ + } while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\0')); +#else + } while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') ); +#endif + configRBuf[i] = '\0'; i=0; + } + + } + else + { + + /* + * Here we deal with pushed tokens. Reinitialize pushToken again. If + * the pushed token was NUMBER || STRING return them again ... + */ + int temp = pushToken; + pushToken = LOCK_TOKEN; + + if (temp == COMMA || temp == DASH) return(temp); + if (temp == NUMBER || temp == STRING) return(temp); + } + + /* + * Joop, at last we have to lookup the token ... + */ + if (tab) + { + i = 0; + while (tab[i].token != -1) + if (StrCaseCmp(configRBuf,tab[i].name) == 0) + return(tab[i].token); + else + i++; + } + + return(ERROR_TOKEN); /* Error catcher */ +} + +/* + * xf86GetToken -- + * Lookup a string if it is actually a token in disguise. + */ +static int +getStringToken(tab) + SymTabRec tab[]; +{ + int i; + + for ( i = 0 ; tab[i].token != -1 ; i++ ) { + if ( ! StrCaseCmp(tab[i].name,val.str) ) return tab[i].token; + } + return(ERROR_TOKEN); +} + +/* + * getScreenIndex -- + * Given the screen token, returns the index in xf86Screens, or -1 if + * the screen type is not applicable to this server. + */ +static int +getScreenIndex(token) + int token; +{ + int i; + + for (i = 0; xf86ScreenNames[i] >= 0 && xf86ScreenNames[i] != token; i++) + ; + if (xf86ScreenNames[i] < 0) + return(-1); + else + return(i); +} + +/* + * validateGraphicsToken -- + * If token is a graphics token, check it is in the list of validTokens + * XXXX This needs modifying to work as it did with the old format + */ +static Bool +validateGraphicsToken(validTokens, token) + int *validTokens; + int token; +{ + int i; + + for (i = 0; ScreenTab[i].token >= 0 && ScreenTab[i].token != token; i++) + ; + if (ScreenTab[i].token < 0) + return(FALSE); /* Not a graphics token */ + + for (i = 0; validTokens[i] >= 0 && validTokens[i] != token; i++) + ; + return(validTokens[i] >= 0); +} + +/* + * xf86TokenToString -- + * returns the string corresponding to token + */ +char * +xf86TokenToString(table, token) + SymTabPtr table; + int token; +{ + int i; + + for (i = 0; table[i].token >= 0 && table[i].token != token; i++) + ; + if (table[i].token < 0) + return("unknown"); + else + return(table[i].name); +} + +/* + * xf86StringToToken -- + * returns the string corresponding to token + */ +int +xf86StringToToken(table, string) + SymTabPtr table; + char *string; +{ + int i; + + for (i = 0; table[i].token >= 0 && StrCaseCmp(string, table[i].name); i++) + ; + return(table[i].token); +} + +/* + * xf86ConfigError -- + * Print a READABLE ErrorMessage!!! All information that is + * interesting is printed. Even a pointer to the erroneous place is + * printed. Maybe our e-mail will be less :-) + */ +#ifdef XF86SETUP +int +XF86SetupXF86ConfigError(msg) +#else +void +xf86ConfigError(msg) +#endif + char *msg; +{ + int i,j; + + ErrorF( "\nConfig Error: %s:%d\n\n%s", configPath, configLineNo, configBuf); + for (i = 1, j = 1; i < configStart; i++, j++) + if (configBuf[i-1] != '\t') + ErrorF(" "); + else + do + ErrorF(" "); + while (((j++)%8) != 0); + for (i = configStart; i <= configPos; i++) ErrorF("^"); + ErrorF("\n%s\n", msg); +#ifdef NEED_RETURN_VALUE + return RET_ERROR; +#else + exit(-1); /* simple exit ... */ +#endif +} + +#ifndef XF86SETUP +void +xf86DeleteMode(infoptr, dispmp) +ScrnInfoPtr infoptr; +DisplayModePtr dispmp; +{ + if(infoptr->modes == dispmp) + infoptr->modes = dispmp->next; + + if(dispmp->next == dispmp) + FatalError("No valid modes found.\n"); + + ErrorF("%s %s: Removing mode \"%s\" from list of valid modes.\n", + XCONFIG_PROBED, infoptr->name, dispmp->name); + dispmp->prev->next = dispmp->next; + dispmp->next->prev = dispmp->prev; + + xfree(dispmp->name); + xfree(dispmp); +} +#endif + +/* + * findConfigFile -- + * Locate the XF86Config file. Abort if not found. + */ +#ifndef XF86SETUP +static +#endif +CONFIG_RETURN_TYPE +findConfigFile(filename, fp) + char *filename; + FILE **fp; +{ +#define configFile (*fp) +#define MAXPTRIES 6 + char *home = NULL; + char *xconfig = NULL; + char *xwinhome = NULL; + char *configPaths[MAXPTRIES]; + int pcount = 0, idx; + + /* + * First open if necessary the config file. + * If the -xf86config flag was used, use the name supplied there (root only). + * If $XF86CONFIG is a pathname, use it as the name of the config file (root) + * If $XF86CONFIG is set but doesn't contain a '/', append it to 'XF86Config' + * and search the standard places (root only). + * If $XF86CONFIG is not set, just search the standard places. + */ + while (!configFile) { + + /* + * configPaths[0] is used as a buffer for -xf86config + * and $XF86CONFIG if it contains a path + * configPaths[1...MAXPTRIES-1] is used to store the paths of each of + * the other attempts + */ + for (pcount = idx = 0; idx < MAXPTRIES; idx++) + configPaths[idx] = NULL; + + /* + * First check if the -xf86config option was used. + */ + configPaths[pcount] = (char *)xalloc(PATH_MAX); +#ifndef __EMX__ + if (getuid() == 0 && xf86ConfigFile[0]) +#else + if (xf86ConfigFile[0]) +#endif + { + strcpy(configPaths[pcount], xf86ConfigFile); + if ((configFile = fopen(configPaths[pcount], "r")) != 0) + break; + else + FatalError( + "Cannot read file \"%s\" specified by the -xf86config flag\n", + configPaths[pcount]); + } + /* + * Check if XF86CONFIG is set. + */ +#ifndef __EMX__ + if (getuid() == 0 + && (xconfig = getenv("XF86CONFIG")) != 0 + && index(xconfig, '/')) +#else + /* no root available, and filenames start with drive letter */ + if ((xconfig = getenv("XF86CONFIG")) != 0 + && isalpha(xconfig[0]) + && xconfig[1]==':') +#endif + { + strcpy(configPaths[pcount], xconfig); + if ((configFile = fopen(configPaths[pcount], "r")) != 0) + break; + else + FatalError( + "Cannot read file \"%s\" specified by XF86CONFIG variable\n", + configPaths[pcount]); + } + +#ifndef __EMX__ + /* + * ~/XF86Config ... + */ + if (getuid() == 0 && (home = getenv("HOME"))) { + configPaths[++pcount] = (char *)xalloc(PATH_MAX); + strcpy(configPaths[pcount],home); + strcat(configPaths[pcount],"/XF86Config"); + if (xconfig) strcat(configPaths[pcount],xconfig); + if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break; + } + + /* + * /etc/XF86Config + */ + configPaths[++pcount] = (char *)xalloc(PATH_MAX); + strcpy(configPaths[pcount], "/etc/XF86Config"); + if (xconfig) strcat(configPaths[pcount],xconfig); + if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break; + + /* + * $(LIBDIR)/XF86Config.<hostname> + */ + + configPaths[++pcount] = (char *)xalloc(PATH_MAX); + if (getuid() == 0 && (xwinhome = getenv("XWINHOME")) != NULL) + sprintf(configPaths[pcount], "%s/lib/X11/XF86Config", xwinhome); + else + strcpy(configPaths[pcount], SERVER_CONFIG_FILE); + if (getuid() == 0 && xconfig) strcat(configPaths[pcount],xconfig); + strcat(configPaths[pcount], "."); +#ifdef AMOEBA + { + extern char *XServerHostName; + + strcat(configPaths[pcount], XServerHostName); + } +#else + gethostname(configPaths[pcount]+strlen(configPaths[pcount]), + MAXHOSTNAMELEN); +#endif + if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break; +#endif /* !__EMX__ */ + + /* + * $(LIBDIR)/XF86Config + */ + configPaths[++pcount] = (char *)xalloc(PATH_MAX); +#ifndef __EMX__ + if (getuid() == 0 && xwinhome) + sprintf(configPaths[pcount], "%s/lib/X11/XF86Config", xwinhome); + else + strcpy(configPaths[pcount], SERVER_CONFIG_FILE); + if (getuid() == 0 && xconfig) strcat(configPaths[pcount],xconfig); +#else + /* we explicitly forbid numerous config files everywhere for OS/2; + * users should consider them lucky to have one in a standard place + * and another one with the -xf86config option + */ + xwinhome = getenv("X11ROOT"); /* get drive letter */ + if (!xwinhome) FatalError("X11ROOT environment variable not set\n"); + strcpy(configPaths[pcount], __XOS2RedirRoot("/XFree86/lib/X11/XConfig")); +#endif + + if ((configFile = fopen( configPaths[pcount], "r" )) != 0) break; + + ErrorF("\nCould not find config file!\n"); + ErrorF("- Tried:\n"); + for (idx = 1; idx <= pcount; idx++) + if (configPaths[idx] != NULL) + ErrorF(" %s\n", configPaths[idx]); + FatalError("No config file found!\n%s", getuid() == 0 ? "" : + "Note, the X server no longer looks for XF86Config in $HOME"); + } + strcpy(filename, configPaths[pcount]); + if (xf86Verbose) { + ErrorF("XF86Config: %s\n", filename); + ErrorF("%s stands for supplied, %s stands for probed/default values\n", + XCONFIG_GIVEN, XCONFIG_PROBED); + } + for (idx = 0; idx <= pcount; idx++) + if (configPaths[idx] != NULL) + xfree(configPaths[idx]); +#undef configFile +#undef MAXPTRIES +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static DisplayModePtr pNew, pLast; +static Bool graphFound = FALSE; + +/* + * xf86GetNearestClock -- + * Find closest clock to given frequency (in kHz). This assumes the + * number of clocks is greater than zero. + */ +int +xf86GetNearestClock(Screen, Frequency) + ScrnInfoPtr Screen; + int Frequency; +{ + int NearestClock = 0; + int MinimumGap = abs(Frequency - Screen->clock[0]); + int i; + for (i = 1; i < Screen->clocks; i++) + { + int Gap = abs(Frequency - Screen->clock[i]); + if (Gap < MinimumGap) + { + MinimumGap = Gap; + NearestClock = i; + } + } + return NearestClock; +} + +/* + * xf86Config -- + * Fill some internal structure with userdefined setups. Many internal + * Structs are initialized. The drivers are selected and initialized. + * if (! vtopen), XF86Config is read, but devices are not probed. + * if (vtopen), devices are probed (and modes resolved). + * The vtopen argument was added so that XF86Config information could be + * made available before the VT is opened. + */ +CONFIG_RETURN_TYPE +xf86Config (vtopen) + int vtopen; +{ + int token; + int i, j; +#if defined(SYSV) || defined(linux) + int xcpipe[2]; +#endif +#ifdef XINPUT + LocalDevicePtr local; +#endif + + if (!vtopen) + { + + OFLG_ZERO(&GenericXF86ConfigFlag); + configBuf = (char*)xalloc(CONFIG_BUF_LEN); + configRBuf = (char*)xalloc(CONFIG_BUF_LEN); + configPath = (char*)xalloc(PATH_MAX); + + configBuf[0] = '\0'; /* sanity ... */ + + /* + * Read the XF86Config file with the real uid to avoid security problems + * + * For SYSV we fork, and send the data back to the parent through a pipe + */ +#if defined(SYSV) || defined(linux) + if (getuid() != 0) { + if (pipe(xcpipe)) + FatalError("Pipe failed (%s)\n", strerror(errno)); + switch (fork()) { + case -1: + FatalError("Fork failed (%s)\n", strerror(errno)); + break; + case 0: /* child */ + close(xcpipe[0]); + setuid(getuid()); + HANDLE_RETURN(findConfigFile(configPath, &configFile)); + { + unsigned char pbuf[CONFIG_BUF_LEN]; + int nbytes; + + /* Pass the filename back as the first line */ + strcat(configPath, "\n"); + if (write(xcpipe[1], configPath, strlen(configPath)) < 0) + FatalError("Child error writing to pipe (%s)\n", strerror(errno)); + while ((nbytes = fread(pbuf, 1, CONFIG_BUF_LEN, configFile)) > 0) + if (write(xcpipe[1], pbuf, nbytes) < 0) + FatalError("Child error writing to pipe (%s)\n", strerror(errno)); + } + close(xcpipe[1]); + fclose(configFile); + exit(0); + break; + default: /* parent */ + close(xcpipe[1]); + configFile = (FILE *)fdopen(xcpipe[0], "r"); + if (fgets(configPath, PATH_MAX, configFile) == NULL) + FatalError("Error reading config file\n"); + configPath[strlen(configPath) - 1] = '\0'; + } + } + else { + HANDLE_RETURN(findConfigFile(configPath, &configFile)); + } +#else /* ! (SYSV || linux) */ + { +#ifndef __EMX__ /* in OS/2 we don't care about uids */ + int real_uid = getuid(); + + if (real_uid) { +#ifdef MINIX + setuid(getuid()); +#else +#if !defined(SVR4) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) + setruid(0); +#endif + seteuid(real_uid); +#endif /* MINIX */ + } +#endif /* __EMX__ */ + + HANDLE_RETURN(findConfigFile(configPath, &configFile)); +#if defined(MINIX) || defined(__EMX__) + /* no need to restore the uid to root */ +#else + if (real_uid) { + seteuid(0); +#if !defined(SVR4) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) + setruid(real_uid); +#endif + } +#endif /* MINIX */ + } +#endif /* SYSV || linux */ + xf86Info.sharedMonitor = FALSE; + xf86Info.kbdProc = NULL; + xf86Info.notrapSignals = FALSE; + xf86Info.caughtSignal = FALSE; + + /* Allocate mouse device */ +#if defined(XINPUT) && !defined(XF86SETUP) + local = mouse_assoc.device_allocate(); + xf86Info.mouseLocal = (pointer) local; + xf86Info.mouseDev = (MouseDevPtr) local->private; + xf86Info.mouseDev->mseProc = NULL; +#else + xf86Info.mouseDev = (MouseDevPtr) Xcalloc(sizeof(MouseDevRec)); +#endif + + while ((token = xf86GetToken(TopLevelTab)) != EOF) { + switch(token) { + case SECTION: + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("section name string expected"); + if ( StrCaseCmp(val.str, "files") == 0 ) { + HANDLE_RETURN(configFilesSection()); + } else if ( StrCaseCmp(val.str, "serverflags") == 0 ) { + HANDLE_RETURN(configServerFlagsSection()); + } else if ( StrCaseCmp(val.str, "keyboard") == 0 ) { + HANDLE_RETURN(configKeyboardSection()); + } else if ( StrCaseCmp(val.str, "pointer") == 0 ) { + HANDLE_RETURN(configPointerSection(xf86Info.mouseDev, ENDSECTION, NULL)); + } else if ( StrCaseCmp(val.str, "device") == 0 ) { + HANDLE_RETURN(configDeviceSection()); + } else if ( StrCaseCmp(val.str, "monitor") == 0 ) { + HANDLE_RETURN(configMonitorSection()); + } else if ( StrCaseCmp(val.str, "screen") == 0 ) { + HANDLE_RETURN(configScreenSection()); +#ifdef XINPUT + } else if ( StrCaseCmp(val.str, "xinput") == 0 ) { + HANDLE_RETURN(xf86ConfigExtendedInputSection(&val)); +#endif + } else if ( StrCaseCmp(val.str, "module") == 0 ) { + HANDLE_RETURN(configDynamicModuleSection()); + } else { + xf86ConfigError("not a recognized section name"); + } + break; + } + } + + fclose(configFile); + xfree(configBuf); + xfree(configRBuf); + xfree(configPath); + + /* These aren't needed after the XF86Config file has been read */ +#ifndef XF86SETUP + if (monitor_list) + xfree(monitor_list); + if (device_list) + xfree(device_list); +#endif + if (modulePath) + xfree(modulePath); + +#if defined(SYSV) || defined(linux) + if (getuid() != 0) { + /* Wait for the child */ + wait(NULL); + } +#endif + + /* Try XF86Config FontPath first */ + if (!xf86fpFlag) + if (fontPath) { + char *f = xf86ValidateFontPath(fontPath); + if (*f) + defaultFontPath = f; + else + ErrorF( + "Warning: FontPath is completely invalid. Using compiled-in default.\n" + ); + xfree(fontPath); + fontPath = (char *)NULL; + } + else + ErrorF("Warning: No FontPath specified, using compiled-in default.\n"); + else /* Use fontpath specified with '-fp' */ + { + OFLG_CLR (XCONFIG_FONTPATH, &GenericXF86ConfigFlag); + if (fontPath) + { + xfree(fontPath); + fontPath = (char *)NULL; + } + } + if (!fontPath) { + /* xf86ValidateFontPath will write into it's arg, but defaultFontPath + could be static, so we make a copy. */ + char *f = (char *)xalloc(strlen(defaultFontPath) + 1); + f[0] = '\0'; + strcpy (f, defaultFontPath); + defaultFontPath = xf86ValidateFontPath(f); + xfree(f); + } + else + xfree(fontPath); + + /* If defaultFontPath is still empty, exit here */ + + if (! *defaultFontPath) + FatalError("No valid FontPath could be found\n"); + if (xf86Verbose) + ErrorF("%s FontPath set to \"%s\"\n", + OFLG_ISSET(XCONFIG_FONTPATH, &GenericXF86ConfigFlag) ? XCONFIG_GIVEN : + XCONFIG_PROBED, defaultFontPath); + + if (!xf86Info.kbdProc) + FatalError("You must specify a keyboard in XF86Config"); + if (!xf86Info.mouseDev->mseProc) + FatalError("You must specify a mouse in XF86Config"); + + if (!graphFound) + { + Bool needcomma = FALSE; + + ErrorF("\nYou must provide a \"Screen\" section in XF86Config for at\n"); + ErrorF("least one of the following graphics drivers: "); + for (i = 0; i < xf86MaxScreens; i++) + { + if (xf86Screens[i]) + { + ErrorF("%s%s", needcomma ? ", " : "", + xf86TokenToString(DriverTab, xf86ScreenNames[i])); + needcomma = TRUE; + } + } + ErrorF("\n"); + FatalError("No configured graphics devices"); + } + } +#ifndef XF86SETUP + else /* if (vtopen) */ + { + /* + * Probe all configured screens for letting them resolve their modes + */ + xf86ScreensOpen = TRUE; + for ( i=0; i < xf86MaxScreens; i++ ) + if (xf86Screens[i] && xf86Screens[i]->configured && + (xf86Screens[i]->configured = (xf86Screens[i]->Probe)())){ + /* if driver doesn't report error do it here */ + if(xf86DCGetToken(xf86Screens[i]->DCConfig,NULL,DeviceTab) != EOF){ + xf86DCConfigError("Unknown device section keyword"); + FatalError("\n"); + } + if(xf86Screens[i]->DCOptions){ + xf86DCGetOption(xf86Screens[i]->DCOptions,NULL); + FatalError("\n"); + } + xf86InitViewport(xf86Screens[i]); + } + + /* + * Now sort the drivers to match the order of the ScreenNumbers + * requested by the user. (sorry, slow bubble-sort here) + * Note, that after this sorting the first driver that is not configured + * can be used as last-mark for all configured ones. + */ + for ( j = 0; j < xf86MaxScreens-1; j++) + for ( i=0; i < xf86MaxScreens-j-1; i++ ) + if (!xf86Screens[i] || !xf86Screens[i]->configured || + (xf86Screens[i+1] && xf86Screens[i+1]->configured && + (xf86Screens[i+1]->tmpIndex < xf86Screens[i]->tmpIndex))) + { + ScrnInfoPtr temp = xf86Screens[i+1]; + xf86Screens[i+1] = xf86Screens[i]; + xf86Screens[i] = temp; + } + + } +#endif /* XF86SETUP */ + +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static char* prependRoot(char *pathname) +{ +#ifndef __EMX__ + return pathname; +#else + /* XXXX caveat: multiple path components in line */ + return (char*)__XOS2RedirRoot(pathname); +#endif +} + +static CONFIG_RETURN_TYPE +configFilesSection() +{ + int token; + int i, j; + int k, l; + char *str; + + while ((token = xf86GetToken(FilesTab)) != ENDSECTION) { + switch (token) { + case FONTPATH: + OFLG_SET(XCONFIG_FONTPATH,&GenericXF86ConfigFlag); + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Font path component expected"); + j = FALSE; + str = prependRoot(val.str); + if (fontPath == NULL) + { + fontPath = (char *)xalloc(1); + fontPath[0] = '\0'; + i = strlen(str) + 1; + } + else + { + i = strlen(fontPath) + strlen(str) + 1; + if (fontPath[strlen(fontPath)-1] != ',') + { + i++; + j = TRUE; + } + } + fontPath = (char *)xrealloc(fontPath, i); + if (j) + strcat(fontPath, ","); + + strcat(fontPath, str); + xfree(val.str); + break; + + case RGBPATH: + OFLG_SET(XCONFIG_RGBPATH, &GenericXF86ConfigFlag); + if (xf86GetToken(NULL) != STRING) xf86ConfigError("RGB path expected"); + if (!xf86coFlag) + rgbPath = val.str; + break; + + case MODULEPATH: + OFLG_SET(XCONFIG_MODULEPATH, &GenericXF86ConfigFlag); + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Module path expected"); + l = FALSE; + str = prependRoot(val.str); + if (modulePath == NULL) { + modulePath = (char *)xalloc(1); + modulePath[0] = '\0'; + k = strlen(str) + 1; + } + else + { + k = strlen(modulePath) + strlen(str) + 1; + if (modulePath[strlen(modulePath)-1] != ',') + { + k++; + l = TRUE; + } + } + modulePath = (char *)xrealloc(modulePath, k); + if (l) + strcat(modulePath, ","); + + strcat(modulePath, str); + xfree(val.str); + break; + + case EOF: + FatalError("Unexpected EOF (missing EndSection?)"); + break; /* :-) */ + default: + xf86ConfigError("File section keyword expected"); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +configServerFlagsSection() +{ + int token; + + xf86Info.dontZap = FALSE; + xf86Info.dontZoom = FALSE; + + while ((token = xf86GetToken(ServerFlagsTab)) != ENDSECTION) { + switch (token) { + case NOTRAPSIGNALS: + xf86Info.notrapSignals=TRUE; + break; + case DONTZAP: + xf86Info.dontZap = TRUE; + break; + case DONTZOOM: + xf86Info.dontZoom = TRUE; + break; +#ifdef XF86VIDMODE + case DISABLEVIDMODE: + xf86VidModeEnabled = FALSE; + break; + case ALLOWNONLOCAL: + xf86VidModeAllowNonLocal = TRUE; + break; +#endif +#ifdef XF86MISC + case DISABLEMODINDEV: + xf86MiscModInDevEnabled = FALSE; + break; + case MODINDEVALLOWNONLOCAL: + xf86MiscModInDevAllowNonLocal = TRUE; + break; +#endif + case ALLOWMOUSEOPENFAIL: + xf86AllowMouseOpenFail = TRUE; + break; + case PCIPROBE1: + xf86PCIFlags = PCIProbe1; + break; + case PCIPROBE2: + xf86PCIFlags = PCIProbe2; + break; + case PCIFORCECONFIG1: + xf86PCIFlags = PCIForceConfig1; + break; + case PCIFORCECONFIG2: + xf86PCIFlags = PCIForceConfig2; + break; + case EOF: + FatalError("Unexpected EOF (missing EndSection?)"); + break; /* :-) */ + default: + xf86ConfigError("Server flags section keyword expected"); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +configKeyboardSection() +{ + int token, ntoken; + + /* Initialize defaults */ + xf86Info.serverNumLock = FALSE; + xf86Info.xleds = 0L; + xf86Info.kbdDelay = 500; + xf86Info.kbdRate = 30; + xf86Info.kbdProc = (DeviceProc)0; + xf86Info.vtinit = NULL; + xf86Info.vtSysreq = VT_SYSREQ_DEFAULT; + xf86Info.specialKeyMap = (int *)xalloc((RIGHTCTL - LEFTALT + 1) * + sizeof(int)); + xf86Info.specialKeyMap[LEFTALT - LEFTALT] = KM_META; + xf86Info.specialKeyMap[RIGHTALT - LEFTALT] = KM_META; + xf86Info.specialKeyMap[SCROLLLOCK - LEFTALT] = KM_COMPOSE; + xf86Info.specialKeyMap[RIGHTCTL - LEFTALT] = KM_CONTROL; +#if defined(SVR4) && defined(i386) && !defined(PC98) + xf86Info.panix106 = FALSE; +#endif +#ifdef XKB + xf86Info.xkbkeymap = NULL; + xf86Info.xkbtypes = "default"; +#ifndef PC98 + xf86Info.xkbcompat = "default"; + xf86Info.xkbkeycodes = "xfree86"; + xf86Info.xkbsymbols = "us(pc101)"; + xf86Info.xkbgeometry = "pc"; +#else + xf86Info.xkbcompat = "pc98"; + xf86Info.xkbkeycodes = "xfree98"; + xf86Info.xkbsymbols = "nec/jp(pc98)"; + xf86Info.xkbgeometry = "nec(pc98)"; +#endif + xf86Info.xkbcomponents_specified = False; + xf86Info.xkbrules = "xfree86"; + xf86Info.xkbmodel = NULL; + xf86Info.xkblayout = NULL; + xf86Info.xkbvariant = NULL; + xf86Info.xkboptions = NULL; +#endif + + while ((token = xf86GetToken(KeyboardTab)) != ENDSECTION) { + switch (token) { + case KPROTOCOL: + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Keyboard protocol name expected"); + if ( StrCaseCmp(val.str,"standard") == 0 ) { + xf86Info.kbdProc = xf86KbdProc; +#ifdef AMOEBA + xf86Info.kbdEvents = NULL; +#else + xf86Info.kbdEvents = xf86KbdEvents; +#endif + } else if ( StrCaseCmp(val.str,"xqueue") == 0 ) { +#ifdef XQUEUE + xf86Info.kbdProc = xf86XqueKbdProc; + xf86Info.kbdEvents = xf86XqueEvents; + xf86Info.mouseDev->xqueSema = 0; + if (xf86Verbose) + ErrorF("%s Xqueue selected for keyboard input\n", + XCONFIG_GIVEN); +#endif + } else { + xf86ConfigError("Not a valid keyboard protocol name"); + } + break; + case AUTOREPEAT: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Autorepeat delay expected"); + xf86Info.kbdDelay = val.num; + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Autorepeat rate expected"); + xf86Info.kbdRate = val.num; + break; + case SERVERNUM: + xf86Info.serverNumLock = TRUE; + break; + + case XLEDS: + while ((token= xf86GetToken(NULL)) == NUMBER) + xf86Info.xleds |= 1L << (val.num-1); + pushToken = token; + break; + case LEFTALT: + case RIGHTALT: + case SCROLLLOCK: + case RIGHTCTL: + ntoken = xf86GetToken(KeyMapTab); + if ((ntoken == EOF) || (ntoken == STRING) || (ntoken == NUMBER)) + xf86ConfigError("KeyMap type token expected"); + else { + switch(ntoken) { + case KM_META: + case KM_COMPOSE: + case KM_MODESHIFT: + case KM_MODELOCK: + case KM_SCROLLLOCK: + case KM_CONTROL: + xf86Info.specialKeyMap[token - LEFTALT] = ntoken; + break; + default: + xf86ConfigError("Illegal KeyMap type"); + break; + } + } + break; + case VTINIT: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("VTInit string expected"); + xf86Info.vtinit = val.str; + if (xf86Verbose) + ErrorF("%s VTInit: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case VTSYSREQ: +#ifdef USE_VT_SYSREQ + xf86Info.vtSysreq = TRUE; + if (xf86Verbose && !VT_SYSREQ_DEFAULT) + ErrorF("%s VTSysReq enabled\n", XCONFIG_GIVEN); +#else + xf86ConfigError("VTSysReq not supported on this OS"); +#endif + break; + +#ifdef XKB + case XKBDISABLE: + noXkbExtension = TRUE; + if (xf86Verbose) + ErrorF("%s XKB: disabled\n", XCONFIG_GIVEN); + break; + + case XKBKEYMAP: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBKeymap string expected"); + xf86Info.xkbkeymap = val.str; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: keymap: \"%s\" (overrides other XKB settings)\n", + XCONFIG_GIVEN, val.str); + break; + + case XKBCOMPAT: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBCompat string expected"); + xf86Info.xkbcompat = val.str; + xf86Info.xkbcomponents_specified = True; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: compat: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBTYPES: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBTypes string expected"); + xf86Info.xkbtypes = val.str; + xf86Info.xkbcomponents_specified = True; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: types: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBKEYCODES: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBKeycodes string expected"); + xf86Info.xkbkeycodes = val.str; + xf86Info.xkbcomponents_specified = True; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: keycodes: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBGEOMETRY: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBGeometry string expected"); + xf86Info.xkbgeometry = val.str; + xf86Info.xkbcomponents_specified = True; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: geometry: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBSYMBOLS: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBSymbols string expected"); + xf86Info.xkbsymbols = val.str; + xf86Info.xkbcomponents_specified = True; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: symbols: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBRULES: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBRules string expected"); + xf86Info.xkbrules = val.str; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: rules: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBMODEL: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBModel string expected"); + xf86Info.xkbmodel = val.str; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: model: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBLAYOUT: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBLayout string expected"); + xf86Info.xkblayout = val.str; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: layout: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBVARIANT: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBVariant string expected"); + xf86Info.xkbvariant = val.str; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: variant: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; + + case XKBOPTIONS: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("XKBOptions string expected"); + xf86Info.xkboptions = val.str; + if (xf86Verbose && !XkbInitialMap) + ErrorF("%s XKB: options: \"%s\"\n", XCONFIG_GIVEN, val.str); + break; +#endif +#if defined(SVR4) && defined(i386) && !defined(PC98) + case PANIX106: + xf86Info.panix106 = TRUE; + if (xf86Verbose) + ErrorF("%s PANIX106: enabled\n", XCONFIG_GIVEN); + break; +#endif + + case EOF: + FatalError("Unexpected EOF (missing EndSection?)"); + break; /* :-) */ + + default: + xf86ConfigError("Keyboard section keyword expected"); + break; + } + } + if (xf86Info.kbdProc == (DeviceProc)0) + { + xf86ConfigError("No keyboard device given"); + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +CONFIG_RETURN_TYPE +configPointerSection(MouseDevPtr mouse_dev, + int end_tag, + char **devicename) /* used by extended device */ +{ + int token; + int mtoken; + int i; + char *mouseType = "unknown"; + + /* Set defaults */ + mouse_dev->baudRate = 1200; + mouse_dev->oldBaudRate = -1; + mouse_dev->sampleRate = 0; + mouse_dev->resolution = 0; + mouse_dev->buttons = MSE_DFLTBUTTONS; + mouse_dev->emulate3Buttons = FALSE; + mouse_dev->emulate3Timeout = 50; + mouse_dev->chordMiddle = FALSE; + mouse_dev->mouseFlags = 0; + mouse_dev->mseProc = (DeviceProc)0; + mouse_dev->mseDevice = NULL; + mouse_dev->mseType = -1; + mouse_dev->mseModel = 0; + mouse_dev->negativeZ = 0; + mouse_dev->positiveZ = 0; + + while ((token = xf86GetToken(PointerTab)) != end_tag) { + switch (token) { + + case PROTOCOL: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Mouse name expected"); +#if defined(USE_OSMOUSE) || defined(OSMOUSE_ONLY) + if ( StrCaseCmp(val.str,"osmouse") == 0 ) { + if (xf86Verbose) + ErrorF("%s OsMouse selected for mouse input\n", XCONFIG_GIVEN); + /* + * allow an option to be passed to the OsMouse routines + */ + if ((i = xf86GetToken(NULL)) != ERROR_TOKEN) + xf86OsMouseOption(i, (pointer) &val); + else + pushToken = i; + mouse_dev->mseProc = xf86OsMouseProc; + mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86OsMouseEvents; + break; + } +#endif +#ifdef XQUEUE + if ( StrCaseCmp(val.str,"xqueue") == 0 ) { + mouse_dev->mseProc = xf86XqueMseProc; + mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86XqueEvents; + mouse_dev->xqueSema = 0; + if (xf86Verbose) + ErrorF("%s Xqueue selected for mouse input\n", + XCONFIG_GIVEN); + break; + } +#endif + +#ifndef OSMOUSE_ONLY +#if defined(MACH) || defined(AMOEBA) + mouseType = (char *) xalloc (strlen (val.str) + 1); + strcpy (mouseType, val.str); +#else + mouseType = (char *)strdup(val.str); /* GJA -- should we free this? */ +#endif + mtoken = getStringToken(MouseTab); /* Which mouse? */ +#ifdef AMOEBA + mouse_dev->mseProc = xf86MseProc; + mouse_dev->mseEvents = NULL; +#else + mouse_dev->mseProc = xf86MseProc; + mouse_dev->mseEvents = xf86MseEvents; +#endif + mouse_dev->mseType = mtoken - MICROSOFT; + if (!xf86MouseSupported(mouse_dev->mseType)) + { + xf86ConfigError("Mouse type not supported by this OS"); + } +#else /* OSMOUSE_ONLY */ + xf86ConfigError("Mouse type not supported by this OS"); +#endif /* OSMOUSE_ONLY */ + +#ifdef MACH386 + /* Don't need to specify the device for MACH -- should always be this */ + mouse_dev->mseDevice = "/dev/mouse"; +#endif + break; +#ifndef OSMOUSE_ONLY + case PDEVICE: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Mouse device expected"); + mouse_dev->mseDevice = val.str; + break; + case BAUDRATE: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Baudrate expected"); + if (mouse_dev->mseType + MICROSOFT == LOGIMAN) + { + /* + * XXXX This should be extended to other mouse types -- most + * support only 1200. Should also disallow baudrate for bus mice + */ + /* Moan if illegal baud rate! [CHRIS-211092] */ + if ((val.num != 1200) && (val.num != 9600)) + xf86ConfigError("Only 1200 or 9600 Baud are supported by MouseMan"); + } + else if (val.num%1200 != 0 || val.num < 1200 || val.num > 9600) + xf86ConfigError("Baud rate must be one of 1200, 2400, 4800, or 9600"); + mouse_dev->baudRate = val.num; + break; + + case SAMPLERATE: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Sample rate expected"); +#if 0 + if (mouse_dev->mseType + MICROSOFT == LOGIMAN) + { + /* XXXX Most mice don't allow this */ + /* Moan about illegal sample rate! [CHRIS-211092] */ + xf86ConfigError("Selection of sample rate is not supported by MouseMan"); + } +#endif + mouse_dev->sampleRate = val.num; + break; + + case PRESOLUTION: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Resolution expected"); + if (val.num <= 0) + xf86ConfigError("Resolution must be a positive value"); + mouse_dev->resolution = val.num; + break; +#endif /* OSMOUSE_ONLY */ + case EMULATE3: + if (mouse_dev->chordMiddle) + xf86ConfigError("Can't use Emulate3Buttons with ChordMiddle"); + mouse_dev->emulate3Buttons = TRUE; + break; + + case EM3TIMEOUT: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("3 button emulation timeout expected"); + mouse_dev->emulate3Timeout = val.num; + break; + +#ifndef OSMOUSE_ONLY + case CHORDMIDDLE: + if (mouse_dev->mseType + MICROSOFT == MICROSOFT || + mouse_dev->mseType + MICROSOFT == LOGIMAN) + { + if (mouse_dev->emulate3Buttons) + xf86ConfigError("Can't use ChordMiddle with Emulate3Buttons"); + mouse_dev->chordMiddle = TRUE; + } + else + xf86ConfigError("ChordMiddle is only supported for Microsoft and MouseMan"); + break; + + case CLEARDTR: +#ifdef CLEARDTR_SUPPORT + if (mouse_dev->mseType + MICROSOFT == MOUSESYS) + mouse_dev->mouseFlags |= MF_CLEAR_DTR; + else + xf86ConfigError("ClearDTR only supported for MouseSystems mouse"); +#else + xf86ConfigError("ClearDTR not supported on this OS"); +#endif + break; + case CLEARRTS: +#ifdef CLEARDTR_SUPPORT + if (mouse_dev->mseType + MICROSOFT == MOUSESYS) + mouse_dev->mouseFlags |= MF_CLEAR_RTS; + else + xf86ConfigError("ClearRTS only supported for MouseSystems mouse"); +#else + xf86ConfigError("ClearRTS not supported on this OS"); +#endif + break; +#endif /* OSMOUSE_ONLY */ + + case DEVICE_NAME: + if (!devicename) /* not called for an extended device */ + xf86ConfigError("Pointer section keyword expected"); + + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Option string expected"); + *devicename = strdup(val.str); + break; + +#ifndef XF86SETUP +#ifdef XINPUT + case ALWAYSCORE: + xf86AlwaysCore(mouse_dev->local, TRUE); + break; +#endif +#endif + + case ZAXISMAPPING: + switch (xf86GetToken(ZMapTab)) { + case NUMBER: + if (val.num <= 0 || val.num > MSE_MAXBUTTONS) + xf86ConfigError("Button number (1..12) expected"); + mouse_dev->negativeZ = 1 << (val.num - 1); + if (xf86GetToken(NULL) != NUMBER || + val.num <= 0 || val.num > MSE_MAXBUTTONS) + xf86ConfigError("Button number (1..12) expected"); + mouse_dev->positiveZ = 1 << (val.num - 1); + break; + case XAXIS: + mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOX; + break; + case YAXIS: + mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOY; + break; + default: + xf86ConfigError("Button number (1..12), X or Y expected"); + } + break; + + case PBUTTONS: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Number of buttons (1..12) expected"); + if (val.num <= 0 || val.num > MSE_MAXBUTTONS) + xf86ConfigError("Number of buttons must be a positive value (1..12)"); + mouse_dev->buttons = val.num; + break; + + case EOF: + FatalError("Unexpected EOF (missing EndSection?)"); + break; /* :-) */ + + default: + xf86ConfigError("Pointer section keyword expected"); + break; + } + + } + /* Print log and make sanity checks */ + + if (mouse_dev->mseProc == (DeviceProc)0) + { + xf86ConfigError("No mouse protocol given"); + } + + /* + * if mseProc is set and mseType isn't, then using Xqueue or OSmouse. + * Otherwise, a mouse device is required. + */ + if (mouse_dev->mseType >= 0 && !mouse_dev->mseDevice) + { + xf86ConfigError("No mouse device given"); + } + + switch (mouse_dev->negativeZ) { + case 0: /* none */ + case MSE_MAPTOX: + case MSE_MAPTOY: + break; + default: /* buttons */ + for (i = 0; mouse_dev->negativeZ != (1 << i); ++i) + ; + if (i + 1 > mouse_dev->buttons) + mouse_dev->buttons = i + 1; + for (i = 0; mouse_dev->positiveZ != (1 << i); ++i) + ; + if (i + 1 > mouse_dev->buttons) + mouse_dev->buttons = i + 1; + break; + } + + if (xf86Verbose && mouse_dev->mseType >= 0) + { + Bool formatFlag = FALSE; + ErrorF("%s Mouse: type: %s, device: %s", + XCONFIG_GIVEN, mouseType, mouse_dev->mseDevice); + if (mouse_dev->mseType != P_BM + && mouse_dev->mseType != P_PS2 + && mouse_dev->mseType != P_IMPS2 + && mouse_dev->mseType != P_THINKINGPS2 + && mouse_dev->mseType != P_MMANPLUSPS2 + && mouse_dev->mseType != P_GLIDEPOINTPS2 + && mouse_dev->mseType != P_NETPS2 + && mouse_dev->mseType != P_NETSCROLLPS2 + && mouse_dev->mseType != P_SYSMOUSE) + { + formatFlag = TRUE; + ErrorF(", baudrate: %d", mouse_dev->baudRate); + } + if (mouse_dev->sampleRate) + { + ErrorF(formatFlag ? "\n%s Mouse: samplerate: %d" : "%ssamplerate: %d", + formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->sampleRate); + formatFlag = !formatFlag; + } + if (mouse_dev->resolution) + { + ErrorF(formatFlag ? "\n%s Mouse: resolution: %d" : "%sresolution: %d", + formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->resolution); + formatFlag = !formatFlag; + } + ErrorF(formatFlag ? "\n%s Mouse: buttons: %d" : "%sbuttons: %d", + formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->buttons); + formatFlag = !formatFlag; + if (mouse_dev->emulate3Buttons) + { + ErrorF(formatFlag ? "\n%s Mouse: 3 button emulation (timeout: %dms)" : + "%s3 button emulation (timeout: %dms)", + formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->emulate3Timeout); + formatFlag = !formatFlag; + } + if (mouse_dev->chordMiddle) + ErrorF(formatFlag ? "\n%s Mouse: Chorded middle button" : + "%sChorded middle button", + formatFlag ? XCONFIG_GIVEN : ", "); + ErrorF("\n"); + + switch (mouse_dev->negativeZ) { + case 0: /* none */ + break; + case MSE_MAPTOX: + ErrorF("%s Mouse: zaxismapping: X\n", XCONFIG_GIVEN); + break; + case MSE_MAPTOY: + ErrorF("%s Mouse: zaxismapping: Y\n", XCONFIG_GIVEN); + break; + default: /* buttons */ + for (i = 0; mouse_dev->negativeZ != (1 << i); ++i) + ; + ErrorF("%s Mouse: zaxismapping: (-)%d", XCONFIG_GIVEN, i + 1); + for (i = 0; mouse_dev->positiveZ != (1 << i); ++i) + ; + ErrorF(" (+)%d\n", i + 1); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +configDeviceSection() +{ + int token; + int i; + GDevPtr devp; + + /* Allocate one more device */ + if ( device_list == NULL ) { + device_list = (GDevPtr) xalloc(sizeof(GDevRec)); + } else { + device_list = (GDevPtr) xrealloc(device_list, + (n_devices+1) * sizeof(GDevRec)); + } + devp = &(device_list[n_devices]); /* Point to the last device */ + n_devices++; + + /* Pre-init the newly created device */ + devp->identifier = NULL; + devp->board = NULL; + devp->vendor = NULL; + devp->chipset = NULL; + devp->ramdac = NULL; + for (i=0; i<MAXDACSPEEDS; i++) + devp->dacSpeeds[i] = 0; + OFLG_ZERO(&(devp->options)); + OFLG_ZERO(&(devp->xconfigFlag)); + devp->videoRam = 0; + devp->speedup = SPEEDUP_DEFAULT; + OFLG_ZERO(&(devp->clockOptions)); + devp->clocks = 0; + devp->clockprog = NULL; + devp->textClockValue = -1; + /* GJA -- We initialize the following fields to known values. + * If later on we find they contain different values, + * they might be interesting to print. + */ + devp->IObase = 0; + devp->DACbase = 0; + devp->COPbase = 0; + devp->POSbase = 0; + devp->instance = 0; + devp->BIOSbase = 0; + devp->VGAbase = 0; + devp->MemBase = 0; + devp->s3Madjust = 0; + devp->s3Nadjust = 0; + devp->s3MClk = 0; + devp->chipID = 0; + devp->chipRev = 0; + devp->s3RefClk = 0; + devp->s3BlankDelay = -1; + devp->DCConfig = NULL; + devp->DCOptions = NULL; + devp->MemClk = 0; + devp->LCDClk = 0; + + while ((token = xf86GetToken(DeviceTab)) != ENDSECTION) { + devp->DCConfig = xf86DCSaveLine(devp->DCConfig, token); + switch (token) { + + case IDENTIFIER: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("identifier name expected"); + devp->identifier = val.str; + break; + + case VENDOR: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("vendor name expected"); + devp->vendor = val.str; + break; + + case BOARD: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("board name expected"); + devp->board = val.str; + break; + + case CHIPSET: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Chipset string expected"); + devp->chipset = val.str; + OFLG_SET(XCONFIG_CHIPSET,&(devp->xconfigFlag)); + break; + + case RAMDAC: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("RAMDAC string expected"); + devp->ramdac = val.str; + OFLG_SET(XCONFIG_RAMDAC,&(devp->xconfigFlag)); + break; + + case DACSPEED: + for (i=0; i<MAXDACSPEEDS; i++) + devp->dacSpeeds[i] = 0; + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("DAC speed(s) expected"); + else { + devp->dacSpeeds[0] = (int)(val.realnum * 1000.0 + 0.5); + for(i=1; i<MAXDACSPEEDS; i++) { + if (xf86GetToken(NULL) == NUMBER) + devp->dacSpeeds[i] = (int)(val.realnum * 1000.0 + 0.5); + else { + pushToken = token; + break; + } + } + } + OFLG_SET(XCONFIG_DACSPEED,&(devp->xconfigFlag)); + break; + + case CLOCKCHIP: + /* Only allow one Clock string */ + if (OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(devp->clockOptions))) + { + xf86ConfigError("Only one Clock chip may be specified."); + break; + } + if (devp->clocks == 0) + { + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Option string expected"); + i = 0; + while (xf86_ClockOptionTab[i].token != -1) + { + if (StrCaseCmp(val.str, xf86_ClockOptionTab[i].name) == 0) + { + OFLG_SET(CLOCK_OPTION_PROGRAMABLE, &(devp->clockOptions)); + OFLG_SET(xf86_ClockOptionTab[i].token, + &(devp->clockOptions)); + break; + } + i++; + } + if (xf86_ClockOptionTab[i].token == -1) { + xf86ConfigError("Unknown clock chip"); + break; + } + } + else + { + xf86ConfigError("Clocks previously specified by value"); + } + break; + + case CLOCKS: + OFLG_SET(XCONFIG_CLOCKS,&(devp->xconfigFlag)); + if ((token = xf86GetToken(NULL)) == STRING) + { + xf86ConfigError("Use ClockChip to specify a programmable clock"); + break; + } + if (OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(devp->clockOptions))) + { + xf86ConfigError("Clock previously specified as programmable"); + break; + } + for (i = devp->clocks; token == NUMBER && i < MAXCLOCKS; i++) { + devp->clock[i] = (int)(val.realnum * 1000.0 + 0.5); + token = xf86GetToken(NULL); + } + + devp->clocks = i; + pushToken = token; + break; + + case OPTION: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Option string expected"); + i = 0; + while (xf86_OptionTab[i].token != -1) + { + if (StrCaseCmp(val.str, xf86_OptionTab[i].name) == 0) + { + OFLG_SET(xf86_OptionTab[i].token, &(devp->options)); + break; + } + i++; + } + if (xf86_OptionTab[i].token == -1) + /*xf86ConfigError("Unknown option string");*/ + devp->DCOptions = xf86DCOption(devp->DCOptions,val); + break; + + case VIDEORAM: + OFLG_SET(XCONFIG_VIDEORAM,&(devp->xconfigFlag)); + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Video RAM size expected"); + devp->videoRam = val.num; + break; + + case SPEEDUP: + OFLG_SET(XCONFIG_SPEEDUP,&(devp->xconfigFlag)); + if ((token = xf86GetToken(NULL)) == STRING) + if (!strcmp(val.str,"all")) + devp->speedup = SPEEDUP_ALL; + else + if (!strcmp(val.str,"best")) + devp->speedup = SPEEDUP_BEST; + else + if (!strcmp(val.str,"none")) + devp->speedup = 0; + else + xf86ConfigError("Unrecognised SpeedUp option"); + else + { + pushToken = token; + if ((token = xf86GetToken(NULL)) == NUMBER) + devp->speedup = val.num; + else + { + pushToken = token; + devp->speedup = SPEEDUP_ALL; + } + } + break; + + case NOSPEEDUP: + OFLG_SET(XCONFIG_SPEEDUP,&(devp->xconfigFlag)); + devp->speedup = 0; + break; + + case CLOCKPROG: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("ClockProg string expected"); + if (val.str[0] != '/') + FatalError("Full pathname must be given for ClockProg \"%s\"\n", + val.str); + if (access(val.str, X_OK) < 0) + { + if (access(val.str, F_OK) < 0) + FatalError("ClockProg \"%s\" does not exist\n", val.str); + else + FatalError("ClockProg \"%s\" is not executable\n", val.str); + } + { + struct stat stat_buf; + stat(val.str, &stat_buf); + if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG)) + FatalError("ClockProg \"%s\" is not a regular file\n", val.str); + } + devp->clockprog = val.str; + if (xf86GetToken(NULL) == NUMBER) + { + devp->textClockValue = (int)(val.realnum * 1000.0 + 0.5); + } + else + { + pushToken = token; + } + break; + + case BIOSBASE: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("BIOS base address expected"); + devp->BIOSbase = val.num; + OFLG_SET(XCONFIG_BIOSBASE, &(devp->xconfigFlag)); + break; + + case MEMBASE: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Memory base address expected"); + devp->MemBase = val.num; + OFLG_SET(XCONFIG_MEMBASE, &(devp->xconfigFlag)); + break; + + case IOBASE: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Direct access register I/O base address expected"); + devp->IObase = val.num; + OFLG_SET(XCONFIG_IOBASE, &(devp->xconfigFlag)); + break; + + case DACBASE: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("DAC base I/O address expected"); + devp->DACbase = val.num; + OFLG_SET(XCONFIG_DACBASE, &(devp->xconfigFlag)); + break; + + case COPBASE: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Coprocessor base memory address expected"); + devp->COPbase = val.num; + OFLG_SET(XCONFIG_COPBASE, &(devp->xconfigFlag)); + break; + + case POSBASE: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("POS base address expected"); + devp->POSbase = val.num; + OFLG_SET(XCONFIG_POSBASE, &(devp->xconfigFlag)); + break; + + case INSTANCE: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Video adapter instance number expected"); + devp->instance = val.num; + OFLG_SET(XCONFIG_INSTANCE, &(devp->xconfigFlag)); + break; + + case S3MNADJUST: + if ((token = xf86GetToken(NULL)) == DASH) { /* negative number */ + token = xf86GetToken(NULL); + val.num = -val.num; + } + if (token != NUMBER || val.num<-31 || val.num>31) + xf86ConfigError("M adjust (max. 31) expected"); + devp->s3Madjust = val.num; + + if ((token = xf86GetToken(NULL)) == DASH) { /* negative number */ + token = xf86GetToken(NULL); + val.num = -val.num; + } + if (token == NUMBER) { + if (val.num<-255 || val.num>255) + xf86ConfigError("N adjust (max. 255) expected"); + else + devp->s3Nadjust = val.num; + } + else pushToken = token; + break; + + case S3MCLK: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("MCLK value in MHz expected"); + devp->s3MClk = (int)(val.realnum * 1000.0 + 0.5); + break; + + case MEMCLOCK: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Memory Clock value in MHz expected"); + devp->MemClk = (int)(val.realnum * 1000.0 + 0.5); + OFLG_SET(XCONFIG_MEMCLOCK,&(devp->xconfigFlag)); + break; + + case LCDCLOCK: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("LCD Clock value in MHz expected"); + devp->LCDClk = (int)(val.realnum * 1000.0 + 0.5); + OFLG_SET(XCONFIG_LCDCLOCK,&(devp->xconfigFlag)); + break; + + case CHIPID: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("ChipID expected"); + devp->chipID = val.num; + break; + + case CHIPREV: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("ChipRev expected"); + devp->chipRev = val.num; + break; + + case VGABASEADDR: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("VGA aperature base address expected"); + devp->VGAbase = val.num; + OFLG_SET(XCONFIG_VGABASE, &(devp->xconfigFlag)); + break; + + case S3REFCLK: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("RefCLK value in MHz expected"); + devp->s3RefClk = (int)(val.realnum * 1000.0 + 0.5); + break; + + case S3BLANKDELAY: + if (xf86GetToken(NULL) != NUMBER || val.num>7) + xf86ConfigError("number(s) 0..7 expected"); + devp->s3BlankDelay = val.num; + if ((token=xf86GetToken(NULL)) == NUMBER) { + if (val.num>7) xf86ConfigError("number2 0..7 expected"); + devp->s3BlankDelay |= val.num<<4; + } + else pushToken = token; + break; + + case TEXTCLOCKFRQ: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Text clock expected"); + devp->textClockValue = (int)(val.realnum * 1000.0 + 0.5); + break; + + case EOF: + FatalError("Unexpected EOF (missing EndSection?)"); + break; /* :-) */ + default: + if(DCerr) + xf86ConfigError("Device section keyword expected"); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +configMonitorSection() +{ + int token; + int i; + MonPtr monp; + float multiplier; + + /* Allocate one more monitor */ + if ( monitor_list == NULL ) { + monitor_list = (MonPtr) xalloc(sizeof(MonRec)); + } else { + monitor_list = (MonPtr) xrealloc(monitor_list, + (n_monitors+1) * sizeof(MonRec)); + } + monp = &(monitor_list[n_monitors]); /* Point to the new monitor */ + monp->Modes = 0; + monp->Last = 0; + monp->n_hsync = 0; + monp->n_vrefresh = 0; + n_monitors++; + + while ((token = xf86GetToken(MonitorTab)) != ENDSECTION) { + switch (token) { + case IDENTIFIER: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("identifier name expected"); + monp->id = val.str; + break; + case VENDOR: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("vendor name expected"); + monp->vendor = val.str; + break; + case MODEL: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("model name expected"); + monp->model = val.str; + break; + case MODE: + readVerboseMode(monp); + break; + case MODELINE: + token = xf86GetToken(NULL); + pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec)); + + if (monp->Last) + monp->Last->next = pNew; + else + monp->Modes = pNew; + + if (token == STRING) + { + pNew->name = val.str; + if ((token = xf86GetToken(NULL)) != NUMBER) + FatalError("Dotclock expected"); + } + else if (monp->Last) + { +#if defined(MACH) || defined(AMOEBA) + pNew->name = (char *) xalloc (strlen (monp->Last->name) + 1); + strcpy (pNew->name, monp->Last->name); +#else + pNew->name = (char *)strdup(monp->Last->name); +#endif + } + else + xf86ConfigError("Mode name expected"); + + pNew->next = NULL; + pNew->prev = NULL; + pNew->Flags = 0; + pNew->Clock = (int)(val.realnum * 1000.0 + 0.5); + pNew->CrtcHAdjusted = FALSE; + pNew->CrtcVAdjusted = FALSE; + pNew->CrtcHSkew = pNew->HSkew = 0; + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHDisplay = pNew->HDisplay = val.num; + else xf86ConfigError("Horizontal display expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHSyncStart = pNew->HSyncStart = val.num; + else xf86ConfigError("Horizontal sync start expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHSyncEnd = pNew->HSyncEnd = val.num; + else xf86ConfigError("Horizontal sync end expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHTotal = pNew->HTotal = val.num; + else xf86ConfigError("Horizontal total expected"); + + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVDisplay = pNew->VDisplay = val.num; + else xf86ConfigError("Vertical display expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVSyncStart = pNew->VSyncStart = val.num; + else xf86ConfigError("Vertical sync start expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVSyncEnd = pNew->VSyncEnd = val.num; + else xf86ConfigError("Vertical sync end expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVTotal = pNew->VTotal = val.num; + else xf86ConfigError("Vertical total expected"); + + token = xf86GetToken(TimingTab); + while ( (token == TT_INTERLACE) || (token == TT_PHSYNC) || + (token == TT_NHSYNC) || (token == TT_PVSYNC) || + (token == TT_NVSYNC) || (token == TT_CSYNC) || + (token == TT_PCSYNC) || (token == TT_NCSYNC) || + (token == TT_DBLSCAN) || (token == TT_HSKEW) ) + { + switch(token) { + + case TT_INTERLACE: pNew->Flags |= V_INTERLACE; break; + case TT_PHSYNC: pNew->Flags |= V_PHSYNC; break; + case TT_NHSYNC: pNew->Flags |= V_NHSYNC; break; + case TT_PVSYNC: pNew->Flags |= V_PVSYNC; break; + case TT_NVSYNC: pNew->Flags |= V_NVSYNC; break; + case TT_CSYNC: pNew->Flags |= V_CSYNC; break; + case TT_PCSYNC: pNew->Flags |= V_PCSYNC; break; + case TT_NCSYNC: pNew->Flags |= V_NCSYNC; break; + case TT_DBLSCAN: pNew->Flags |= V_DBLSCAN; break; + case TT_HSKEW: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Horizontal skew expected"); + pNew->CrtcHSkew = pNew->HSkew = val.num; + pNew->Flags |= V_HSKEW; + break; + default: + xf86ConfigError("bug found in config reader"); break; + } + token = xf86GetToken(TimingTab); + } + pushToken = token; + monp->Last = pNew; /* GJA */ + break; + case BANDWIDTH: + /* This should be completely removed at some point */ + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Bandwidth number expected"); +#if 0 + monp->bandwidth = val.realnum; + /* Handle optional scaler */ + token = xf86GetToken(UnitTab); + switch ( token ) { + case HRZ: multiplier = 1.0e-6; break; + case KHZ: multiplier = 1.0e-3; break; + case MHZ: multiplier = 1.0; break; + default: multiplier = 1.0; pushToken = token; + } + monp->bandwidth *= multiplier; +#endif + break; + case HORIZSYNC: + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Horizontal sync value expected"); + monp->hsync[monp->n_hsync].lo = val.realnum; + if ((token = xf86GetToken(NULL)) == DASH) { + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Upperbound for horizontal sync value expected"); + monp->hsync[monp->n_hsync].hi = val.realnum; + } else { + pushToken = token; + monp->hsync[monp->n_hsync].hi = monp->hsync[monp->n_hsync].lo; + } + monp->n_hsync++; + while ( (token = xf86GetToken(NULL)) == COMMA ) { + if ( monp->n_hsync == MAX_HSYNC ) + xf86ConfigError("Sorry. Too many horizontal sync intervals."); + + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Horizontal sync value expected"); + monp->hsync[monp->n_hsync].lo = val.realnum; + if ((token = xf86GetToken(NULL)) == DASH) { + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Upperbound for horizontal sync value expected"); + monp->hsync[monp->n_hsync].hi = val.realnum; + } else { + pushToken = token; + monp->hsync[monp->n_hsync].hi = monp->hsync[monp->n_hsync].lo; + } + monp->n_hsync++; + } + pushToken = token; + /* Handle optional scaler */ + token = xf86GetToken(UnitTab); + switch ( token ) { + case HRZ: multiplier = 1.0e-3; break; + case KHZ: multiplier = 1.0; break; + case MHZ: multiplier = 1.0e3; break; + default: multiplier = 1.0; pushToken = token; + } + for ( i = 0 ; i < monp->n_hsync ; i++ ) { + monp->hsync[i].hi *= multiplier; + monp->hsync[i].lo *= multiplier; + } + break; + case VERTREFRESH: + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Vertical refresh value expected"); + monp->vrefresh[monp->n_vrefresh].lo = val.realnum; + if ((token = xf86GetToken(NULL)) == DASH) { + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Upperbound for vertical refresh value expected"); + monp->vrefresh[monp->n_vrefresh].hi = val.realnum; + } else { + monp->vrefresh[monp->n_vrefresh].hi = + monp->vrefresh[monp->n_vrefresh].lo; + pushToken = token; + } + monp->n_vrefresh++; + while ( (token = xf86GetToken(NULL)) == COMMA ) { + if ( monp->n_vrefresh == MAX_HSYNC ) + xf86ConfigError("Sorry. Too many vertical refresh intervals."); + + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Vertical refresh value expected"); + monp->vrefresh[monp->n_vrefresh].lo = val.realnum; + if ((token = xf86GetToken(NULL)) == DASH) { + if ((token = xf86GetToken(NULL)) != NUMBER) + xf86ConfigError("Upperbound for vertical refresh value expected"); + monp->vrefresh[monp->n_vrefresh].hi = val.realnum; + } else { + monp->vrefresh[monp->n_vrefresh].hi = + monp->vrefresh[monp->n_vrefresh].lo; + pushToken = token; + } + monp->n_vrefresh++; + } + pushToken = token; + /* Handle optional scaler */ + token = xf86GetToken(UnitTab); + switch ( token ) { + case HRZ: multiplier = 1.0; break; + case KHZ: multiplier = 1.0e3; break; + case MHZ: multiplier = 1.0e6; break; + default: multiplier = 1.0; pushToken = token; + } + for ( i = 0 ; i < monp->n_vrefresh ; i++ ) { + monp->vrefresh[i].hi *= multiplier; + monp->vrefresh[i].lo *= multiplier; + } + break; + case GAMMA: { + char *msg = "gamma correction value(s) expected\n either one value or three r/g/b values with 0.1 <= gamma <= 10"; + if ((token = xf86GetToken(NULL)) != NUMBER || val.realnum<0.1 || val.realnum>10) + xf86ConfigError(msg); + else { + xf86rGamma = xf86gGamma = xf86bGamma = 1.0 / val.realnum; + if ((token = xf86GetToken(NULL)) == NUMBER) { + if (val.realnum<0.1 || val.realnum>10) xf86ConfigError(msg); + else { + xf86gGamma = 1.0 / val.realnum; + if ((token = xf86GetToken(NULL)) != NUMBER || val.realnum<0.1 || val.realnum>10) + xf86ConfigError(msg); + else { + xf86bGamma = 1.0 / val.realnum; + } + } + } + else pushToken = token; + } + break; + } + case EOF: + FatalError("Unexpected EOF. Missing EndSection?"); + break; /* :-) */ + + default: + xf86ConfigError("Monitor section keyword expected"); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +configDynamicModuleSection() +{ + int token; + + while ((token = xf86GetToken(ModuleTab)) != ENDSECTION) { + switch (token) { + case LOAD: + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("Dynamic module expected"); + else { +#ifdef DYNAMIC_MODULE + if (!modulePath) { + static Bool firstTime = TRUE; + + modulePath = (char*)Xcalloc(strlen(DEFAULT_MODULE_PATH)+1); + strcpy(modulePath, DEFAULT_MODULE_PATH); + + if (xf86Verbose && firstTime) { + ErrorF("%s no ModulePath specified using default: %s\n", + XCONFIG_PROBED, DEFAULT_MODULE_PATH); + firstTime = FALSE; + } + } + xf86LoadModule(val.str, modulePath); +#else + ErrorF("Dynamic modules not supported. \"%s\" not loaded\n", + val.str); +#endif + } + break; + + case EOF: + FatalError("Unexpected EOF. Missing EndSection?"); + break; /* :-) */ + + default: + xf86ConfigError("Module section keyword expected"); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +readVerboseMode(monp) +MonPtr monp; +{ + int token, token2; + int had_dotclock = 0, had_htimings = 0, had_vtimings = 0; + + pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec)); + pNew->next = NULL; + pNew->prev = NULL; + pNew->Flags = 0; + pNew->HDisplay = pNew->VDisplay = 0; /* Uninitialized */ + pNew->CrtcHAdjusted = pNew->CrtcVAdjusted = FALSE; + pNew->CrtcHSkew = pNew->HSkew = 0; + + if (monp->Last) + monp->Last->next = pNew; + else + monp->Modes = pNew; + monp->Last = pNew; + + if ( xf86GetToken(NULL) != STRING ) { + FatalError("Mode name expected"); + } + pNew->name = val.str; + while ((token = xf86GetToken(ModeTab)) != ENDMODE) { + switch (token) { + case DOTCLOCK: + if ((token = xf86GetToken(NULL)) != NUMBER) { + FatalError("Dotclock expected"); + } + pNew->Clock = (int)(val.realnum * 1000.0 + 0.5); + had_dotclock = 1; + break; + case HTIMINGS: + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHDisplay = pNew->HDisplay = val.num; + else xf86ConfigError("Horizontal display expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHSyncStart = pNew->HSyncStart = val.num; + else xf86ConfigError("Horizontal sync start expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHSyncEnd = pNew->HSyncEnd = val.num; + else xf86ConfigError("Horizontal sync end expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcHTotal = pNew->HTotal = val.num; + else xf86ConfigError("Horizontal total expected"); + had_htimings = 1; + break; + case VTIMINGS: + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVDisplay = pNew->VDisplay = val.num; + else xf86ConfigError("Vertical display expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVSyncStart = pNew->VSyncStart = val.num; + else xf86ConfigError("Vertical sync start expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVSyncEnd = pNew->VSyncEnd = val.num; + else xf86ConfigError("Vertical sync end expected"); + + if (xf86GetToken(NULL) == NUMBER) + pNew->CrtcVTotal = pNew->VTotal = val.num; + else xf86ConfigError("Vertical total expected"); + had_vtimings = 1; + break; + case FLAGS: + token = xf86GetToken(NULL); + if (token != STRING) + xf86ConfigError("Flag string expected. Note: flags must be in \"\""); + while ( token == STRING ) { + token2 = getStringToken(TimingTab); + switch(token2) { + case TT_INTERLACE: pNew->Flags |= V_INTERLACE; break; + case TT_PHSYNC: pNew->Flags |= V_PHSYNC; break; + case TT_NHSYNC: pNew->Flags |= V_NHSYNC; break; + case TT_PVSYNC: pNew->Flags |= V_PVSYNC; break; + case TT_NVSYNC: pNew->Flags |= V_NVSYNC; break; + case TT_CSYNC: pNew->Flags |= V_CSYNC; break; + case TT_PCSYNC: pNew->Flags |= V_PCSYNC; break; + case TT_NCSYNC: pNew->Flags |= V_NCSYNC; break; + case TT_DBLSCAN: pNew->Flags |= V_DBLSCAN; break; + default: + xf86ConfigError("Unknown flag string"); break; + } + token = xf86GetToken(NULL); + } + pushToken = token; + break; + case HSKEW: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Horizontal skew expected"); + pNew->Flags |= V_HSKEW; + pNew->CrtcHSkew = pNew->HSkew = val.num; + break; + } + } + if ( !had_dotclock ) xf86ConfigError("the dotclock is missing"); + if ( !had_htimings ) xf86ConfigError("the horizontal timings are missing"); + if ( !had_vtimings ) xf86ConfigError("the vertical timings are missing"); +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static Bool dummy; + +#ifdef XF86SETUP +int xf86setup_scrn_ndisps[8]; +DispPtr xf86setup_scrn_displays[8]; +#endif + +static CONFIG_RETURN_TYPE +configScreenSection() +{ + int i, j; + int driverno; + int had_monitor = 0, had_device = 0; + int dispIndex = 0; + int numDisps = 0; + DispPtr dispList = NULL; + DispPtr dispp; + + int token; + ScrnInfoPtr screen = NULL; + int textClockValue = -1; + + token = xf86GetToken(ScreenTab); + if ( token != DRIVER ) + xf86ConfigError("The screen section must begin with the 'driver' line"); + + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Driver name expected"); + driverno = getStringToken(DriverTab); + switch ( driverno ) { + case SVGA: + case VGA2: + case MONO: + case VGA16: + case ACCEL: + case FBDEV: + break; + default: + xf86ConfigError("Not a recognized driver name"); + } + scr_index = getScreenIndex(driverno); + + dummy = scr_index < 0 || !xf86Screens[scr_index]; + if (dummy) + screen = (ScrnInfoPtr)xalloc(sizeof(ScrnInfoRec)); + else + { + screen = xf86Screens[scr_index]; + screen->configured = TRUE; + screen->tmpIndex = screenno++; + screen->scrnIndex = scr_index; /* scrnIndex must not be changed */ + screen->frameX0 = -1; + screen->frameY0 = -1; + screen->virtualX = -1; + screen->virtualY = -1; + screen->defaultVisual = -1; + screen->modes = NULL; + screen->width = 240; + screen->height = 180; + screen->bankedMono = FALSE; + screen->textclock = -1; + screen->blackColour.red = 0; + screen->blackColour.green = 0; + screen->blackColour.blue = 0; + screen->whiteColour.red = 0x3F; + screen->whiteColour.green = 0x3F; + screen->whiteColour.blue = 0x3F; + } + screen->clocks = 0; + + while ((token = xf86GetToken(ScreenTab)) != ENDSECTION) { + switch (token) { + + case DEFBPP: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Default color depth expected"); + screen->depth = val.num; + break; + + case SCREENNO: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Screen number expected"); + screen->tmpIndex = val.num; + break; + + case SUBSECTION: + if ((xf86GetToken(NULL) != STRING) || (StrCaseCmp(val.str, "display") != 0)) { + xf86ConfigError("You must say \"Display\" here"); + } + if (dispList == NULL) { + dispList = (DispPtr)xalloc(sizeof(DispRec)); + } else { + dispList = (DispPtr)xrealloc(dispList, + (numDisps + 1) * sizeof(DispRec)); + } + dispp = dispList + numDisps; + numDisps++; + dispp->depth = -1; + dispp->weight.red = dispp->weight.green = dispp->weight.blue = 0; + dispp->frameX0 = -1; + dispp->frameY0 = -1; + dispp->virtualX = -1; + dispp->virtualY = -1; + dispp->modes = NULL; + dispp->whiteColour.red = dispp->whiteColour.green = + dispp->whiteColour.blue = 0x3F; + dispp->blackColour.red = dispp->blackColour.green = + dispp->blackColour.blue = 0; + dispp->defaultVisual = -1; + OFLG_ZERO(&(dispp->options)); + OFLG_ZERO(&(dispp->xconfigFlag)); + dispp->DCOptions = NULL; + + configDisplaySubsection(dispp); + break; + + case EOF: + FatalError("Unexpected EOF (missing EndSection?)"); + break; /* :-) */ + + case MDEVICE: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Device name expected"); + for ( i = 0 ; i < n_devices ; i++ ) { + if ( strcmp(device_list[i].identifier,val.str) == 0 ) { + /* Copy back */ + if (!dummy && xf86Verbose) { + ErrorF("%s %s: Graphics device ID: \"%s\"\n", + XCONFIG_GIVEN, screen->name, device_list[i].identifier); + } + screen->clocks = device_list[i].clocks; + for ( j = 0 ; j < MAXCLOCKS ; j++ ) { + screen->clock[j] = device_list[i].clock[j]; + } + screen->chipset = device_list[i].chipset; + screen->ramdac = device_list[i].ramdac; + for (j=0; j<MAXDACSPEEDS; j++) + screen->dacSpeeds[j] = device_list[i].dacSpeeds[j]; + screen->dacSpeedBpp = 0; + screen->options = device_list[i].options; + screen->clockOptions = device_list[i].clockOptions; + screen->xconfigFlag = device_list[i].xconfigFlag; + screen->videoRam = device_list[i].videoRam; + screen->speedup = device_list[i].speedup; + screen->clockprog = device_list[i].clockprog; + textClockValue = device_list[i].textClockValue; + if (OFLG_ISSET(XCONFIG_BIOSBASE, &screen->xconfigFlag)) + screen->BIOSbase = device_list[i].BIOSbase; + if (OFLG_ISSET(XCONFIG_MEMBASE, &screen->xconfigFlag)) + screen->MemBase = device_list[i].MemBase; + if (OFLG_ISSET(XCONFIG_IOBASE, &screen->xconfigFlag)) + screen->IObase = device_list[i].IObase; + if (OFLG_ISSET(XCONFIG_DACBASE, &screen->xconfigFlag)) + screen->DACbase = device_list[i].DACbase; + if (OFLG_ISSET(XCONFIG_COPBASE, &screen->xconfigFlag)) + screen->COPbase = device_list[i].COPbase; + if (OFLG_ISSET(XCONFIG_POSBASE, &screen->xconfigFlag)) + screen->POSbase = device_list[i].POSbase; + if (OFLG_ISSET(XCONFIG_INSTANCE, &screen->xconfigFlag)) + screen->instance = device_list[i].instance; + screen->s3Madjust = device_list[i].s3Madjust; + screen->s3Nadjust = device_list[i].s3Nadjust; + screen->s3MClk = device_list[i].s3MClk; + screen->MemClk = device_list[i].MemClk; + screen->LCDClk = device_list[i].LCDClk; + screen->chipID = device_list[i].chipID; + screen->chipRev = device_list[i].chipRev; + screen->s3RefClk = device_list[i].s3RefClk; + screen->s3BlankDelay = device_list[i].s3BlankDelay; + screen->textClockFreq = device_list[i].textClockValue; + if (OFLG_ISSET(XCONFIG_VGABASE, &screen->xconfigFlag)) + screen->VGAbase = device_list[i].VGAbase; + screen->DCConfig = device_list[i].DCConfig; + screen->DCOptions = device_list[i].DCOptions; +#ifdef XF86SETUP + screen->device = (void *) &device_list[i]; +#endif + break; + } + } + if ( i == n_devices ) { /* Exhausted the device list */ + xf86ConfigError("Not a declared device"); + } + had_device = 1; + break; + + case MONITOR: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Monitor name expected"); + for ( i = 0 ; i < n_monitors ; i++ ) { + if ( strcmp(monitor_list[i].id,val.str) == 0 ) { + if (!dummy && xf86Verbose) { + ErrorF("%s %s: Monitor ID: \"%s\"\n", + XCONFIG_GIVEN, screen->name, monitor_list[i].id); + } + if (!dummy) { + monitor_list[i].Modes = xf86PruneModes(&monitor_list[i], + monitor_list[i].Modes, + screen, FALSE); + screen->monitor = (MonPtr)xalloc(sizeof(MonRec)); + memcpy(screen->monitor, &monitor_list[i], sizeof(MonRec)); + } + break; + } + } + if ( i == n_monitors ) { /* Exhausted the monitor list */ + xf86ConfigError("Not a declared monitor"); + } + had_monitor = 1; + break; + + case BLANKTIME: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Screensaver blank time expected"); + if (!dummy && !xf86sFlag) + defaultScreenSaverTime = ScreenSaverTime = val.num * MILLI_PER_MIN; + break; + + case STANDBYTIME: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Screensaver standby time expected"); +#ifdef DPMSExtension + if (!dummy) + DPMSStandbyTime = val.num * MILLI_PER_MIN; +#endif + break; + + case SUSPENDTIME: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Screensaver suspend time expected"); +#ifdef DPMSExtension + if (!dummy) + DPMSSuspendTime = val.num * MILLI_PER_MIN; +#endif + break; + + case OFFTIME: + if (xf86GetToken(NULL) != NUMBER) + xf86ConfigError("Screensaver off time expected"); +#ifdef DPMSExtension + if (!dummy) + DPMSOffTime = val.num * MILLI_PER_MIN; +#endif + break; + + default: + if (!dummy && !validateGraphicsToken(screen->validTokens, token)) + { + xf86ConfigError("Screen section keyword expected"); + } + break; + } + } + + if (!dummy) { + if (dispList == NULL) { + FatalError( + "A \"Display\" subsection is required in each \"Screen\" section\n"); + } else { + /* Work out which if any Display subsection to use based on depth */ + if (xf86bpp < 0) { + /* + * no -bpp option given, so take depth if only one Display subsection + * Don't do this for VGA2 and VGA16 where it makes no sense, and only + * causes problems + */ + if (numDisps == 1) { +#ifndef XF86SETUP + if (dispList[0].depth > 0 + && !(driverno >= VGA2 && driverno <= VGA16)) { + xf86bpp = dispList[0].depth; + } +#endif + dispIndex = 0; + } else { + xf86bpp = screen->depth; + /* Look for a section which matches the driver's default depth */ + for (dispIndex = 0; dispIndex < numDisps; dispIndex++) { + if (dispList[dispIndex].depth == screen->depth) + break; + } + if (dispIndex == numDisps) { + /* No match. This time, allow 15/16 and 24/32 to match */ + for (dispIndex = 0; dispIndex < numDisps; dispIndex++) { + if ((screen->depth == 15 && dispList[dispIndex].depth == 16) || + (screen->depth == 16 && dispList[dispIndex].depth == 15) || + (screen->depth == 24 && dispList[dispIndex].depth == 32) || + (screen->depth == 32 && dispList[dispIndex].depth == 24)) + break; + } + } + if (dispIndex == numDisps) { + /* Still no match, so exit */ + FatalError("No \"Display\" subsection for default depth %d\n", + screen->depth); + } + } + } else { + /* xf86bpp is set */ + if (numDisps == 1 && dispList[0].depth < 0) { + /* one Display subsection, no depth set, so use it */ + /* XXXX Maybe should only do this when xf86bpp == default depth?? */ + dispIndex = 0; + } else { + /* find Display subsection matching xf86bpp */ + for (dispIndex = 0; dispIndex < numDisps; dispIndex++) { + if (dispList[dispIndex].depth == xf86bpp) + break; + } + if (dispIndex == numDisps) { +#if 0 + /* No match. This time, allow 15/16 and 24/32 to match */ + for (dispIndex = 0; dispIndex < numDisps; dispIndex++) { + if ((xf86bpp == 15 && dispList[dispIndex].depth == 16) || + (xf86bpp == 16 && dispList[dispIndex].depth == 15) || + (xf86bpp == 24 && dispList[dispIndex].depth == 32) || + (xf86bpp == 32 && dispList[dispIndex].depth == 24)) + break; +#else + /* No match. This time, allow 15/16 to match */ + for (dispIndex = 0; dispIndex < numDisps; dispIndex++) { + if ((xf86bpp == 15 && dispList[dispIndex].depth == 16) || + (xf86bpp == 16 && dispList[dispIndex].depth == 15)) + break; +#endif + } + } + if (dispIndex == numDisps) { + if (!(driverno >= VGA2 && driverno <= VGA16)) { + /* Still no match, so exit */ + FatalError("No \"Display\" subsection for -bpp depth %d\n", + xf86bpp); + } + else + dispIndex = 0; + } + } + } + /* Now copy the info across to the screen rec */ + dispp = dispList + dispIndex; + if (xf86bpp > 0) screen->depth = xf86bpp; + else if (dispp->depth > 0) screen->depth = dispp->depth; + if (xf86weight.red || xf86weight.green || xf86weight.blue) + screen->weight = xf86weight; + else if (dispp->weight.red > 0) { + screen->weight = dispp->weight; + xf86weight = dispp->weight; + } + screen->frameX0 = dispp->frameX0; + screen->frameY0 = dispp->frameY0; + screen->virtualX = dispp->virtualX; + screen->virtualY = dispp->virtualY; + screen->modes = dispp->modes; + screen->whiteColour = dispp->whiteColour; + screen->blackColour = dispp->blackColour; + screen->defaultVisual = dispp->defaultVisual; + /* Add any new options that might be set */ + for (i = 0; i < MAX_OFLAGS; i++) { + if (OFLG_ISSET(i, &(dispp->options))) + OFLG_SET(i, &(screen->options)); + if (OFLG_ISSET(i, &(dispp->xconfigFlag))) + OFLG_SET(i, &(screen->xconfigFlag)); + } + screen->DCOptions = xf86DCConcatOption(screen->DCOptions,dispp->DCOptions); +#ifdef XF86SETUP + xf86setup_scrn_ndisps[driverno-SVGA] = numDisps; + xf86setup_scrn_displays[driverno-SVGA] = dispList; +#else + /* Don't need them any more */ + xfree(dispList); +#endif + } + + /* Maybe these should be FatalError() instead? */ + if ( !had_monitor ) { + xf86ConfigError("A screen must specify a monitor"); + } + if ( !had_device ) { + xf86ConfigError("A screen must specify a device"); + } + } + + /* Check for information that must be specified in XF86Config */ + if (scr_index >= 0 && xf86Screens[scr_index]) + { + ScrnInfoPtr driver = xf86Screens[scr_index]; + + graphFound = TRUE; + + if (driver->clockprog && !driver->clocks) + { + if (!OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(screen->clockOptions))){ + ErrorF("%s: No clock line specified: assuming programmable clocks\n"); + OFLG_SET(CLOCK_OPTION_PROGRAMABLE, &(screen->clockOptions));} + driver->textclock = textClockValue; + } + + /* Find the Index of the Text Clock for the ClockProg */ + if (driver->clockprog && textClockValue > 0 + && !OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(screen->clockOptions))) + { + driver->textclock = xf86GetNearestClock(driver, textClockValue); + if (abs(textClockValue - driver->clock[driver->textclock]) > + CLOCK_TOLERANCE) + FatalError( + "There is no defined dot-clock matching the text clock\n"); + if (xf86Verbose) + ErrorF("%s %s: text clock = %7.3f, clock used = %7.3f\n", + XCONFIG_GIVEN, + driver->name, textClockValue / 1000.0, + driver->clock[driver->textclock] / 1000.0); + } + if (xf86Verbose && driver->defaultVisual > 0) { + char *visualname; + switch (driver->defaultVisual) { + case StaticGray: + case GrayScale: + case StaticColor: + case PseudoColor: + case TrueColor: + case DirectColor: + visualname = xf86VisualNames[driver->defaultVisual]; + break; + default: + xf86ConfigError("unknown visual type"); + } + ErrorF("%s %s: Default visual: %s\n", XCONFIG_GIVEN, driver->name, + visualname); + } + if (defaultColorVisualClass < 0) + defaultColorVisualClass = driver->defaultVisual; + + /* GJA --Moved these from the device code. Had to reorganize it + * a bit. + */ + if (xf86Verbose) { + if (OFLG_ISSET(XCONFIG_IOBASE, &driver->xconfigFlag)) + ErrorF("%s %s: Direct Access Register I/O Base Address: %x\n", + XCONFIG_GIVEN, driver->name, driver->IObase); + + if (OFLG_ISSET(XCONFIG_DACBASE, &driver->xconfigFlag)) + ErrorF("%s %s: DAC Base I/O Address: %x\n", + XCONFIG_GIVEN, driver->name, driver->DACbase); + + if (OFLG_ISSET(XCONFIG_COPBASE, &driver->xconfigFlag)) + ErrorF("%s %s: Coprocessor Base Memory Address: %x\n", + XCONFIG_GIVEN, driver->name, driver->COPbase); + + if (OFLG_ISSET(XCONFIG_POSBASE, &driver->xconfigFlag)) + ErrorF("%s %s: POS Base Address: %x\n", XCONFIG_GIVEN, driver->name, + driver->POSbase); + + if (OFLG_ISSET(XCONFIG_BIOSBASE, &driver->xconfigFlag)) + ErrorF("%s %s: BIOS Base Address: %x\n", XCONFIG_GIVEN, driver->name, + driver->BIOSbase); + + if (OFLG_ISSET(XCONFIG_MEMBASE, &driver->xconfigFlag)) + ErrorF("%s %s: Memory Base Address: %x\n", XCONFIG_GIVEN, + driver->name, driver->MemBase); + + if (OFLG_ISSET(XCONFIG_VGABASE, &driver->xconfigFlag)) + ErrorF("%s %s: VGA Aperture Base Address: %x\n", XCONFIG_GIVEN, + driver->name, driver->VGAbase); + + /* Print clock program */ + if ( driver->clockprog ) { + ErrorF("%s %s: ClockProg: \"%s\"", XCONFIG_GIVEN, driver->name, + driver->clockprog); + if ( textClockValue ) + ErrorF(", Text Clock: %7.3f\n", textClockValue / 1000.0); + ErrorF("\n"); + } + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +static CONFIG_RETURN_TYPE +configDisplaySubsection(disp) +DispPtr disp; +{ + int token; + int i; + + while ((token = xf86GetToken(DisplayTab)) != ENDSUBSECTION) { + switch (token) { + case DEPTH: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display depth expected"); + disp->depth = val.num; + break; + + case WEIGHT: + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display weight expected"); + if (val.num > 9) { + disp->weight.red = (val.num / 100) % 10; + disp->weight.green = (val.num / 10) % 10; + disp->weight.blue = val.num % 10; + } else { + disp->weight.red = val.num; + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display weight expected"); + disp->weight.green = val.num; + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display weight expected"); + disp->weight.blue = val.num; + } + break; + + case VIEWPORT: + OFLG_SET(XCONFIG_VIEWPORT,&(disp->xconfigFlag)); + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Viewport X expected"); + disp->frameX0 = val.num; + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Viewport Y expected"); + disp->frameY0 = val.num; + break; + + case VIRTUAL: + OFLG_SET(XCONFIG_VIRTUAL,&(disp->xconfigFlag)); + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Virtual X expected"); + disp->virtualX = val.num; + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Virtual Y expected"); + disp->virtualY = val.num; + break; + + case MODES: + for (pLast=NULL; (token = xf86GetToken(NULL)) == STRING; pLast = pNew) + { + pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec)); + pNew->name = val.str; + pNew->PrivSize = 0; + pNew->Private = NULL; + + if (pLast) + { + pLast->next = pNew; + pNew->prev = pLast; + } + else + disp->modes = pNew; + } + /* Make sure at least one mode was present */ + if (!pLast) + xf86ConfigError("Mode name expected"); + pNew->next = disp->modes; + disp->modes->prev = pLast; + pushToken = token; + break; + + case BLACK: + case WHITE: + { + unsigned char rgb[3]; + int ii; + + for (ii = 0; ii < 3; ii++) + { + if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("RGB value expected"); + rgb[ii] = val.num & 0x3F; + } + if (token == BLACK) + { + disp->blackColour.red = rgb[0]; + disp->blackColour.green = rgb[1]; + disp->blackColour.blue = rgb[2]; + } + else + { + disp->whiteColour.red = rgb[0]; + disp->whiteColour.green = rgb[1]; + disp->whiteColour.blue = rgb[2]; + } + } + break; + + case VISUAL: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Visual name expected"); + token = getStringToken(VisualTab); + if (!dummy && disp->defaultVisual >= 0) + xf86ConfigError("Only one default visual may be specified"); + disp->defaultVisual = token - STATICGRAY; + break; + + case OPTION: + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Option string expected"); + i = 0; + while (xf86_OptionTab[i].token != -1) + { + if (StrCaseCmp(val.str, xf86_OptionTab[i].name) == 0) + { + OFLG_SET(xf86_OptionTab[i].token, &(disp->options)); + break; + } + i++; + } + if (xf86_OptionTab[i].token == -1) + disp->DCOptions = xf86DCOption(disp->DCOptions,val); + break; + + /* The following should really go in the S3 server */ + case INVERTVCLK: + case BLANKDELAY: + case EARLYSC: + { + DisplayModePtr p = disp->modes; + if (xf86GetToken(NULL) != STRING) xf86ConfigError("Mode name expected"); + if (disp->modes == NULL) + xf86ConfigError("This must be after the Modes line"); + { + Bool found = FALSE; + int opt; + INT32 value; + char *mode_string = (char *)xalloc(strlen(val.str)+1); + strcpy(mode_string,val.str); + + switch (token) { + default: /* pacify compiler (uninitialized opt, value) */ + case INVERTVCLK: + if (xf86GetToken(NULL) != NUMBER || val.num < 0 || val.num > 1) + xf86ConfigError("0 or 1 expected"); + opt = S3_INVERT_VCLK; + value = val.num; + break; + + case BLANKDELAY: + if (xf86GetToken(NULL) != NUMBER || val.num < 0 || val.num > 7) + xf86ConfigError("number(s) 0..7 expected"); + opt = S3_BLANK_DELAY; + value = val.num; + if ((token=xf86GetToken(NULL)) == NUMBER) { + if (val.num < 0 || val.num > 7) + xf86ConfigError("number2 0..7 expected"); + value |= val.num << 4; + } + else pushToken = token; + break; + + case EARLYSC: + if (xf86GetToken(NULL) != NUMBER || val.num < 0 || val.num > 1) + xf86ConfigError("0 or 1 expected"); + opt = S3_EARLY_SC; + value = val.num; + break; + } + + do { + if (strcmp(p->name, mode_string) == 0 + || strcmp("*", mode_string) == 0) { + found = TRUE; + if (!p->PrivSize || !p->Private) { + p->PrivSize = S3_MODEPRIV_SIZE; + p->Private = (INT32 *)Xcalloc(sizeof(INT32) * S3_MODEPRIV_SIZE); + p->Private[0] = 0; + } + p->Private[0] |= (1 << opt); + p->Private[opt] = value; + } + p = p->next; + } while (p != disp->modes); + if (!found) xf86ConfigError("No mode of that name in the Modes line"); + xfree(mode_string); + } + } + break; + + + case EOF: + FatalError("Unexpected EOF (missing EndSubSection)"); + break; /* :-) */ + + default: + xf86ConfigError("Display subsection keyword expected"); + break; + } + } +#ifdef NEED_RETURN_VALUE + return RET_OKAY; +#endif +} + +Bool +xf86LookupMode(target, driver, flags) + DisplayModePtr target; + ScrnInfoPtr driver; + int flags; +{ + DisplayModePtr p; + DisplayModePtr best_mode = NULL; + int i, j, k, Gap; + int Minimum_Gap = CLOCK_TOLERANCE + 1; + Bool found_mode = FALSE; + Bool clock_too_high = FALSE; + static Bool first_time = TRUE; + double refresh, bestRefresh = 0.0; + + if (first_time) + { + ErrorF("%s %s: Maximum allowed dot-clock: %1.3f MHz\n", XCONFIG_PROBED, + driver->name, driver->maxClock / 1000.0); + first_time = FALSE; + /* + * First time through, cull modes which are not valid for the + * card/driver. + */ + driver->monitor->Modes = xf86PruneModes(NULL, driver->monitor->Modes, + driver, TRUE); + } + + if (xf86BestRefresh && !(flags & LOOKUP_FORCE_DEFAULT)) + flags |= LOOKUP_BEST_REFRESH; + + for (p = driver->monitor->Modes; p != NULL; p = p->next) /* scan list */ + { + if (!strcmp(p->name, target->name)) /* names equal ? */ + { + /* First check if the driver objects to the mode */ + if ((driver->ValidMode)(p, xf86Verbose, MODE_USED) != MODE_OK) + { + ErrorF("%s %s: Mode \"%s\" rejected by driver. Deleted.\n", + XCONFIG_PROBED,driver->name, target->name ); + break; + } + + if ((flags & LOOKUP_NO_INTERLACED) && (p->Flags & V_INTERLACE)) + { + continue; + } + + if ((OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(driver->clockOptions))) && + !OFLG_ISSET(OPTION_NO_PROGRAM_CLOCKS, &(driver->options))) + { + if (driver->clocks == 0) + { + /* this we know */ + driver->clock[0] = 25175; /* 25.175Mhz */ + driver->clock[1] = 28322; /* 28.322MHz */ + driver->clocks = 2; + } + + if ((p->Clock / 1000) > (driver->maxClock / 1000)) + clock_too_high = TRUE; + else + { + /* We fill in the the programmable clocks as we go */ + for (i=0; i < driver->clocks; i++) + if (driver->clock[i] == p->Clock) + break; + + if (i >= MAXCLOCKS) + { + ErrorF("%s %s: Too many programmable clocks used (limit %d)!\n", + XCONFIG_PROBED, driver->name, MAXCLOCKS); + return FALSE; + } + + if (i == driver->clocks) + { + driver->clock[i] = p->Clock; + driver->clocks++; + } + + + if (flags & LOOKUP_BEST_REFRESH) + { + refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal; + if (p->Flags & V_INTERLACE) + { + refresh *= 2; + refresh /= INTERLACE_REFRESH_WEIGHT; + } + else if (p->Flags & V_DBLSCAN) + { + refresh /= 2; + } + if (refresh > bestRefresh) + { + best_mode = p; + bestRefresh = refresh; + target->Clock = i; + } + } + else + { + target->Clock = i; + best_mode = p; + } + } + } + else + { + /* + * go look if any of the clocks in the list matches the one in + * the mode (j=1), or if a better match exists when the clocks + * in the list are divided by 2 (j=2) + */ + if (OFLG_ISSET(OPTION_CLKDIV2, &(driver->options))) + k=2; + else + k=1; + for (j=1 ; j<=k ; j++) + { + i = xf86GetNearestClock(driver, p->Clock*j); + if (flags & LOOKUP_BEST_REFRESH) + { + if ( ((driver->clock[i]/j) / 1000) > (driver->maxClock / 1000) ) + clock_too_high = TRUE; + else + { + refresh = p->Clock * 1000.0 / p->HTotal / p->VTotal; + if (p->Flags & V_INTERLACE) + { + refresh *= 2; + refresh /= INTERLACE_REFRESH_WEIGHT; + } + else if (p->Flags & V_DBLSCAN) + { + refresh /= 2; + } + if (refresh > bestRefresh) + { + target->Clock = i; + if (j==2) p->Flags |= V_CLKDIV2; + best_mode = p; + bestRefresh = refresh; + } + } + } + else + { + Gap = abs( p->Clock - (driver->clock[i]/j) ); + if (Gap < Minimum_Gap) + { + if ( ((driver->clock[i]/j) / 1000) > (driver->maxClock / 1000) ) + clock_too_high = TRUE; + else + { + target->Clock = i; + if (j==2) p->Flags |= V_CLKDIV2; + best_mode = p; + Minimum_Gap = Gap; + } + } + } + } + } + found_mode = TRUE; + } + } + + if (best_mode != NULL) + { + target->HDisplay = best_mode->HDisplay; + target->HSyncStart = best_mode->HSyncStart; + target->HSyncEnd = best_mode->HSyncEnd; + target->HTotal = best_mode->HTotal; + target->HSkew = best_mode->HSkew; + target->VDisplay = best_mode->VDisplay; + target->VSyncStart = best_mode->VSyncStart; + target->VSyncEnd = best_mode->VSyncEnd; + target->VTotal = best_mode->VTotal; + target->Flags = best_mode->Flags; + target->CrtcHDisplay = best_mode->CrtcHDisplay; + target->CrtcHSyncStart = best_mode->CrtcHSyncStart; + target->CrtcHSyncEnd = best_mode->CrtcHSyncEnd; + target->CrtcHTotal = best_mode->CrtcHTotal; + target->CrtcHSkew = best_mode->CrtcHSkew; + target->CrtcVDisplay = best_mode->CrtcVDisplay; + target->CrtcVSyncStart = best_mode->CrtcVSyncStart; + target->CrtcVSyncEnd = best_mode->CrtcVSyncEnd; + target->CrtcVTotal = best_mode->CrtcVTotal; + target->CrtcHAdjusted = best_mode->CrtcHAdjusted; + target->CrtcVAdjusted = best_mode->CrtcVAdjusted; + if (target->Flags & V_DBLSCAN) + { + target->CrtcVDisplay *= 2; + target->CrtcVSyncStart *= 2; + target->CrtcVSyncEnd *= 2; + target->CrtcVTotal *= 2; + target->CrtcVAdjusted = TRUE; + } + +#if 0 + /* I'm not sure if this is the best place for this in the + * new XF86Config organization. - SRA + */ + if (found_mode) + if ((driver->ValidMode)(target, xf86Verbose, MODE_USED) != MODE_OK) + { + ErrorF("%s %s: Unable to support mode \"%s\"\n", + XCONFIG_GIVEN,driver->name, target->name ); + return(FALSE); + } +#endif + + if (xf86Verbose) + { + ErrorF("%s %s: Mode \"%s\": mode clock = %7.3f", + XCONFIG_GIVEN, driver->name, target->name, + best_mode->Clock / 1000.0); + if (!OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &(driver->clockOptions)) || + OFLG_ISSET(OPTION_NO_PROGRAM_CLOCKS, &(driver->options))) { + ErrorF(", clock used = %7.3f", driver->clock[target->Clock] / 1000.0); + if (target->Flags & V_CLKDIV2) + ErrorF("/2"); + } + ErrorF("\n"); + } + } + else if (!found_mode) + ErrorF("%s %s: There is no mode definition named \"%s\"\n", + XCONFIG_PROBED, driver->name, target->name); + else if (clock_too_high) + ErrorF("%s %s: Clock for mode \"%s\" %s\n\tLimit is %7.3f MHz\n", + XCONFIG_PROBED, driver->name, target->name, + "is too high for the configured hardware.", + driver->maxClock / 1000.0); + else + ErrorF("%s %s: There is no defined dot-clock matching mode \"%s\"\n", + XCONFIG_PROBED, driver->name, target->name); + + return (best_mode != NULL); +} + +void +xf86VerifyOptions(allowedOptions, driver) + OFlagSet *allowedOptions; + ScrnInfoPtr driver; +{ + int j; + + for (j=0; xf86_OptionTab[j].token >= 0; j++) + if ((OFLG_ISSET(xf86_OptionTab[j].token, &driver->options))) + if (OFLG_ISSET(xf86_OptionTab[j].token, allowedOptions)) + { + if (xf86Verbose) + ErrorF("%s %s: Option \"%s\"\n", XCONFIG_GIVEN, + driver->name, xf86_OptionTab[j].name); + } + else + ErrorF("%s %s: Option flag \"%s\" is not defined for this driver\n", + XCONFIG_GIVEN, driver->name, xf86_OptionTab[j].name); +} + +/* Note: (To keep me [GJA] from getting confused) + * We have two mode-related datastructures: + * 1. A doubly linked mode name list, with ends marked by self-pointers. + * 2. A doubly linked mode structure list. + * We are operating here on the second structure. + * Initially this is just singly linked. + */ +static DisplayModePtr +xf86PruneModes(monp, allmodes, scrp, card) + MonPtr monp; /* Monitor specification */ + DisplayModePtr allmodes; /* List to be pruned */ + ScrnInfoPtr scrp; + Bool card; /* TRUE => do driver validity check */ +{ + DisplayModePtr dispmp; /* To walk the list */ + DisplayModePtr olddispmp; /* The one being freed. */ + DisplayModePtr remainder; /* The first one retained. */ + + dispmp = allmodes; + + /* The first modes to be deleted require that the pointer to the + * mode list is updated. Also, they have no predecessor in the list. + */ + while (dispmp && + (card ? + ((scrp->ValidMode)(dispmp, xf86Verbose, MODE_SUGGESTED) + != MODE_OK) : + (xf86CheckMode(scrp, dispmp, monp, xf86Verbose) != MODE_OK))) { + olddispmp = dispmp; + dispmp = dispmp->next; + xfree(olddispmp->name); + xfree(olddispmp); + } + /* Now we either have a mode that fits, or no mode at all */ + if ( ! dispmp ) { /* No mode at all */ + return NULL; + } + remainder = dispmp; + while ( dispmp->next ) { + if (card ? + ((scrp->ValidMode)(dispmp->next,xf86Verbose,MODE_SUGGESTED) + != MODE_OK) : + (xf86CheckMode(scrp, dispmp->next, monp, xf86Verbose) != + MODE_OK)) { + olddispmp = dispmp->next; + dispmp->next = dispmp->next->next; + xfree(olddispmp->name); + xfree(olddispmp); + } else { + dispmp = dispmp->next; + } + } + return remainder; /* Return pointer to {the first / the list } */ +} + +/* + * Return MODE_OK if the mode pointed to by dispmp agrees with all constraints + * we can make up for the monitor pointed to by monp. + */ +int +xf86CheckMode(scrp, dispmp, monp, verbose) + ScrnInfoPtr scrp; + DisplayModePtr dispmp; + MonPtr monp; + Bool verbose; +{ + int i; + float dotclock, hsyncfreq, vrefreshrate; + char *scrname = scrp->name; + + /* Sanity checks */ + if ((0 >= dispmp->HDisplay) || + (dispmp->HDisplay > dispmp->HSyncStart) || + (dispmp->HSyncStart >= dispmp->HSyncEnd) || + (dispmp->HSyncEnd >= dispmp->HTotal)) + { + ErrorF( + "%s %s: Invalid horizontal timing for mode \"%s\". Deleted.\n", + XCONFIG_PROBED, scrname, dispmp->name); + return MODE_HSYNC; + } + + if ((0 >= dispmp->VDisplay) || + (dispmp->VDisplay > dispmp->VSyncStart) || + (dispmp->VSyncStart >= dispmp->VSyncEnd) || + (dispmp->VSyncEnd >= dispmp->VTotal)) + { + ErrorF( + "%s %s: Invalid vertical timing for mode \"%s\". Deleted.\n", + XCONFIG_PROBED, scrname, dispmp->name); + return MODE_VSYNC; + } + + /* Deal with the dispmp->Clock being a frequency or index */ + if (dispmp->Clock > MAXCLOCKS) { + dotclock = (float)dispmp->Clock; + } else { + dotclock = (float)scrp->clock[dispmp->Clock]; + } + hsyncfreq = dotclock / (float)(dispmp->HTotal); + for ( i = 0 ; i < monp->n_hsync ; i++ ) + if ( (hsyncfreq > 0.999 * monp->hsync[i].lo) && + (hsyncfreq < 1.001 * monp->hsync[i].hi) ) + break; /* In range. */ + + /* Now see whether we ran out of sync frequencies */ + if ( i == monp->n_hsync ) { + if (verbose) { + ErrorF( + "%s %s: Mode \"%s\" needs hsync freq of %.2f kHz. Deleted.\n", + XCONFIG_PROBED, scrname, dispmp->name, hsyncfreq); + } + return MODE_HSYNC; + } + + vrefreshrate = dotclock * 1000.0 / + ((float)(dispmp->HTotal) * (float)(dispmp->VTotal)) ; + if ( dispmp->Flags & V_INTERLACE ) vrefreshrate *= 2.0; + if ( dispmp->Flags & V_DBLSCAN ) vrefreshrate /= 2.0; + for ( i = 0 ; i < monp->n_vrefresh ; i++ ) + if ( (vrefreshrate > 0.999 * monp->vrefresh[i].lo) && + (vrefreshrate < 1.001 * monp->vrefresh[i].hi) ) + break; /* In range. */ + + /* Now see whether we ran out of refresh rates */ + if ( i == monp->n_vrefresh ) { + if (verbose) { + ErrorF( + "%s %s: Mode \"%s\" needs vert refresh rate of %.2f Hz. Deleted.\n", + XCONFIG_PROBED, scrname, dispmp->name, vrefreshrate); + } + return MODE_VSYNC; + } + + /* Interlaced modes should have an odd VTotal */ + if (dispmp->Flags & V_INTERLACE) + dispmp->CrtcVTotal = dispmp->VTotal |= 1; + + /* Passed every test. */ + return MODE_OK; +} + +/* + * Save entire line from config file in memory area, if memory area + * does not exist allocate it. Set DCerr according to value of token. + * Return address of memory area. + */ +static char *xf86DCSaveLine(DCPointer,token) + char *DCPointer; + int token; +{ + static int len = 0; /* length of memory area where to store strings */ + static int pos = 0; /* current position */ + char *currpointer; /* pointer to current position in memory area */ + static int currline; /* lineno of line currently interpreted */ + int addlen; /* len to add to pos */ + + if(DCPointer == NULL){ /* initialize */ + DCPointer = (char *)xalloc(4096); /* initial size 4kB */ + len = 4096; + strcpy(DCPointer,configPath); + pos = strlen(DCPointer) + 1; + currline = -1; /* no line yet */ + } + + if(configLineNo != currline) /* new line */ + { + currline = configLineNo; + addlen = strlen(configBuf) + 1 + sizeof(int); /* string + lineno */ + while ( (pos + addlen) >= len ){ /* not enough space? */ + DCPointer = (char *)xrealloc(DCPointer, (len + 4096)); + len += 4096; + } + currpointer = DCPointer + pos; /* find current position */ + memcpy(currpointer, &currline, sizeof(int)); /* Grrr unaligned ints.. */ + strcpy((currpointer + sizeof(int)),configBuf); /* store complete line*/ + pos += addlen; /* goto end */ + currpointer += addlen; + *(currpointer) = EOF; /* mark end */ + } + switch(token){ + case STRING: + case DASH: + case NUMBER: + case COMMA: + break; + case ERROR_TOKEN: /* if unknown token unset DCerr to ignore it */ + DCerr = 0; /* and subsequent STRING, DASH, NUMBER, COMMA */ + break; + default: /* set to complain if a valid token is */ + DCerr = 1; /* followed by an unwanted STRING etc. */ + } + return(DCPointer); +} + +/* + * Store any unknown Option strings (contained in val.str) + * in a memory are pointed to by pointer. If it doesn't + * exist allocate it and return a pointer pointing to it + */ + +static char * +xf86DCOption(DCPointer, val) + char *DCPointer; + LexRec val; +{ + static int len = 0; + static int pos = 0; + int addlen; + char *currpointer; /* current position */ + + if (DCPointer == NULL){ /* First time: initialize */ + DCPointer = (char *)xalloc(4096); /* allocate enough space */ + strcpy(DCPointer,configPath); + pos = strlen(DCPointer) + 1; + len = 4096; /* and total length */ + } + + addlen = sizeof(int) + strlen(val.str) + 1; /* token, lineno */ + while( (pos + addlen) >= len ){ /* reallocate if not enough */ + DCPointer = (char *)xrealloc(DCPointer, (len + 4096)); + len += 4096; + } + currpointer = DCPointer + pos; + *(int *)currpointer=configLineNo; + strcpy(currpointer + sizeof(int),val.str); /* store string */ + pos += addlen; + *(currpointer + addlen) = EOF; /* mark end */ + return(DCPointer); +} + +static char +* xf86DCConcatOption(Pointer1, Pointer2) +char *Pointer1; +char *Pointer2; +{ + int s1 = 0; + int s2 = 0; + int s3; + char *ptmp; + + if(Pointer1) + while(*(Pointer1 + s1) != EOF){s1++;} + else if (Pointer2) + return Pointer2; + else return NULL; + if(Pointer2) + while(*(Pointer2 + s2) != EOF){s2++;} + else if (Pointer1) + return Pointer1; + else return NULL; + s3 = strlen(Pointer2) + 1; + s2 -= s3; + + Pointer1 = (char *)xrealloc(Pointer1,s1+s2+1); + ptmp = Pointer1 + s1; + Pointer2 += s3; + do{ + *ptmp = *Pointer2; + *ptmp++; + *Pointer2++; + } while(s2--); + return Pointer1; +} + diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c new file mode 100644 index 000000000..6c0943b41 --- /dev/null +++ b/hw/xfree86/common/xf86Cursor.c @@ -0,0 +1,326 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.13 1996/12/23 06:43:22 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86Cursor.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "cursor.h" +#include "mipointer.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#ifdef XFreeXDGA +#include "Xproto.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "servermd.h" + +#define _XF86DGA_SERVER_ +#include "extensions/xf86dgastr.h" +#endif + +#ifdef XINPUT +#include "xf86_Config.h" +#include "XIproto.h" +#include "xf86Xinput.h" +#endif + +/* #include "atKeynames.h" -hv- dont need that include here */ + + +static Bool xf86CursorOffScreen( +#if NeedFunctionPrototypes + ScreenPtr *pScreen, + int *x, + int *y +#endif +); +static void xf86CrossScreen( +#if NeedFunctionPrototypes + ScreenPtr pScreen, + Bool entering +#endif +); +static void xf86WrapCursor( +#if NeedFunctionPrototypes + ScreenPtr pScreen, + int x, + int y +#endif +); + +miPointerScreenFuncRec xf86PointerScreenFuncs = { + xf86CursorOffScreen, + xf86CrossScreen, + xf86WrapCursor, +#ifdef XINPUT + xf86eqEnqueue, +#endif +}; + + + +/* + * xf86InitViewport -- + * Initialize paning & zooming parameters, so that a driver must only + * check what resolutions are possible and whether the virtual area + * is valid if specifyed. + */ + +void +xf86InitViewport(pScr) + ScrnInfoPtr pScr; +{ + /* + * Compute the initial Viewport if necessary + */ + if (pScr->frameX0 < 0) + { + pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2; + pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2; + } + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + + /* + * Now adjust the initial Viewport, so it lies within the virtual area + */ + if (pScr->frameX1 >= pScr->virtualX) + { + pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay; + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + } + + if (pScr->frameY1 >= pScr->virtualY) + { + pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + } +} + + +/* + * xf86SetViewport -- + * Scroll the visual part of the screen so the pointer is visible. + */ + +void +xf86SetViewport(pScreen, x, y) + ScreenPtr pScreen; + int x, y; +{ + Bool frameChanged = FALSE; + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + + /* + * check wether (x,y) belongs to the visual part of the screen + * if not, change the base of the displayed frame accoring + */ + if ( pScr->frameX0 > x) { + pScr->frameX0 = x; + pScr->frameX1 = x + pScr->modes->HDisplay - 1; + frameChanged = TRUE ; + } + + if ( pScr->frameX1 < x) { + pScr->frameX1 = x + 1; + pScr->frameX0 = x - pScr->modes->HDisplay + 1; + frameChanged = TRUE ; + } + + if ( pScr->frameY0 > y) { + pScr->frameY0 = y; + pScr->frameY1 = y + pScr->modes->VDisplay - 1; + frameChanged = TRUE; + } + + if ( pScr->frameY1 < y) { + pScr->frameY1 = y; + pScr->frameY0 = y - pScr->modes->VDisplay + 1; + frameChanged = TRUE; + } + + if (frameChanged) (pScr->AdjustFrame)(pScr->frameX0, pScr->frameY0); +} + + +static Bool xf86ZoomLocked = FALSE; + +/* + * xf86LockZoom -- + * Enable/disable ZoomViewport + */ + +void +xf86LockZoom (pScreen, lock) + ScreenPtr pScreen; + Bool lock; +{ + /* + * pScreen is currently ignored, but may be used later to enable locking + * of individual screens. + */ + + xf86ZoomLocked = lock; +} + +/* + * xf86ZoomViewport -- + * Reinitialize the visual part of the screen for another modes-> + */ + +void +xf86ZoomViewport (pScreen, zoom) + ScreenPtr pScreen; + int zoom; +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + + if (xf86ZoomLocked) + return; + +#ifdef XFreeXDGA + /* + * We should really send the mode change request to the DGA client and let + * it decide what to do. For now just bin the request + */ + if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics) + return; +#endif + + if (pScr->modes != pScr->modes->next) + { + pScr->modes = zoom > 0 ? pScr->modes->next : pScr->modes->prev; + + if ((pScr->SwitchMode)(pScr->modes)) + { + /* + * adjust new frame for the displaysize + */ + pScr->frameX0 = (pScr->frameX1 + pScr->frameX0 -pScr->modes->HDisplay)/2; + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + + if (pScr->frameX0 < 0) + { + pScr->frameX0 = 0; + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + } + else if (pScr->frameX1 >= pScr->virtualX) + { + pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay; + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + } + + pScr->frameY0 = (pScr->frameY1 + pScr->frameY0 - pScr->modes->VDisplay)/2; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + + if (pScr->frameY0 < 0) + { + pScr->frameY0 = 0; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + } + else if (pScr->frameY1 >= pScr->virtualY) + { + pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + } + } + else /* switch failed, so go back to old mode */ + pScr->modes = zoom > 0 ? pScr->modes->prev : pScr->modes->next; + } + + (pScr->AdjustFrame)(pScr->frameX0, pScr->frameY0); +} + + + +/* + * xf86CursorOffScreen -- + * Check whether it is necessary to switch to another screen + */ + +/* ARGSUSED */ +static Bool +xf86CursorOffScreen (pScreen, x, y) + ScreenPtr *pScreen; + int *x, *y; +{ + int i; + + if ((screenInfo.numScreens > 1) && ((*x < 0) || ((*pScreen)->width <= *x))) { + i = (*pScreen)->myNum; + if (*x < 0) { + i = (i ? i : screenInfo.numScreens) -1; + *pScreen = screenInfo.screens[i]; + *x += (*pScreen)->width; + } + else { + *x -= (*pScreen)->width; + i = (i+1) % screenInfo.numScreens; + *pScreen = screenInfo.screens[i]; + } + return(TRUE); + } + return(FALSE); +} + + + +/* + * xf86CrossScreen -- + * Switch to another screen + */ + +/* ARGSUSED */ +static void +xf86CrossScreen (pScreen, entering) + ScreenPtr pScreen; + Bool entering; +{ + if (xf86Info.sharedMonitor) + (XF86SCRNINFO(pScreen)->EnterLeaveMonitor)(entering); + (XF86SCRNINFO(pScreen)->EnterLeaveCursor)(entering); +} + + +/* + * xf86WrapCursor -- + * Wrap possible to another screen + */ + +/* ARGSUSED */ +static void +xf86WrapCursor (pScreen, x, y) + ScreenPtr pScreen; + int x,y; +{ + miPointerWarpCursor(pScreen,x,y); + + xf86Info.currentScreen = pScreen; +} diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c new file mode 100644 index 000000000..aa0983111 --- /dev/null +++ b/hw/xfree86/common/xf86Events.c @@ -0,0 +1,1575 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.42.2.4 1998/02/07 09:23:28 hohndel Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86Events.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */ + +/* [JCH-96/01/21] Extended std reverse map to four buttons. */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "Xpoll.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86_Config.h" +#include "atKeynames.h" + + +#ifdef XFreeXDGA +#include "XIproto.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "servermd.h" + +#include "exevents.h" + +#define _XF86DGA_SERVER_ +#include "extensions/xf86dgastr.h" +#endif + +#ifdef XINPUT +#include "XI.h" +#include "XIproto.h" +#include "xf86Xinput.h" +#endif + +#include "mipointer.h" +#include "opaque.h" +#ifdef DPMSExtension +#include "extensions/dpms.h" +#endif + +#ifdef XKB +extern Bool noXkbExtension; +#endif + +#define XE_POINTER 1 +#define XE_KEYBOARD 2 + +#ifdef XTESTEXT1 + +#define XTestSERVER_SIDE +#include "xtestext1.h" +extern short xtest_mousex; +extern short xtest_mousey; +extern int on_steal_input; +extern Bool XTestStealKeyData(); +extern void XTestStealMotionData(); + +#ifdef XINPUT +#define ENQUEUE(ev, code, direction, dev_type) \ + (ev)->u.u.detail = (code); \ + (ev)->u.u.type = (direction); \ + if (!on_steal_input || \ + XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \ + xtest_mousex, xtest_mousey)) \ + xf86eqEnqueue((ev)) +#else +#define ENQUEUE(ev, code, direction, dev_type) \ + (ev)->u.u.detail = (code); \ + (ev)->u.u.type = (direction); \ + if (!on_steal_input || \ + XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \ + xtest_mousex, xtest_mousey)) \ + mieqEnqueue((ev)) +#endif + +#define MOVEPOINTER(dx, dy, time) \ + if (on_steal_input) \ + XTestStealMotionData(dx, dy, XE_POINTER, xtest_mousex, xtest_mousey); \ + miPointerDeltaCursor (dx, dy, time) + +#else /* ! XTESTEXT1 */ + +#ifdef XINPUT +#define ENQUEUE(ev, code, direction, dev_type) \ + (ev)->u.u.detail = (code); \ + (ev)->u.u.type = (direction); \ + xf86eqEnqueue((ev)) +#else +#define ENQUEUE(ev, code, direction, dev_type) \ + (ev)->u.u.detail = (code); \ + (ev)->u.u.type = (direction); \ + mieqEnqueue((ev)) +#endif +#define MOVEPOINTER(dx, dy, time) \ + miPointerDeltaCursor (dx, dy, time) + +#endif + +Bool xf86VTSema = TRUE; + +#ifdef XINPUT +extern InputInfo inputInfo; +#endif /* XINPUT */ + +/* + * The first of many hack's to get VT switching to work under + * Solaris 2.1 for x86. The basic problem is that Solaris is supposed + * to be SVR4. It is for the most part, except where the video interface + * is concerned. These hacks work around those problems. + * See the comments for Linux, and SCO. + * + * This is a toggleling variable: + * FALSE = No VT switching keys have been pressed last time around + * TRUE = Possible VT switch Pending + * (DWH - 12/2/93) + * + * This has been generalised to work with Linux and *BSD+syscons (DHD) + */ + +#ifdef USE_VT_SYSREQ +static Bool VTSysreqToggle = FALSE; +#endif /* !USE_VT_SYSREQ */ +static Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for *BSD */ + +extern fd_set EnabledDevices; + +#if defined(CODRV_SUPPORT) +extern unsigned char xf86CodrvMap[]; +#endif + +#if defined(XQUEUE) && !defined(XQUEUE_ASYNC) +extern void xf86XqueRequest( +#if NeedFunctionPrototypes + void +#endif + ); +#endif + +#ifdef DPMSExtension +extern BOOL DPMSEnabled; +extern void DPMSSet(CARD16); +#endif + +static void xf86VTSwitch( +#if NeedFunctionPrototypes + void +#endif + ); +#ifdef XFreeXDGA +static void XF86DirectVideoMoveMouse( +#if NeedFunctionPrototypes + int x, + int y, + CARD32 mtime +#endif + ); +static void XF86DirectVideoKeyEvent( +#if NeedFunctionPrototypes + xEvent *xE, + int keycode, + int etype +#endif + ); +#endif +static CARD32 buttonTimer( +#if NeedFunctionPrototypes + OsTimerPtr timer, + CARD32 now, + pointer arg +#endif + ); + +/* + * Lets create a simple finite-state machine: + * + * state[?][0]: action1 + * state[?][1]: action2 + * state[?][2]: next state + * + * action > 0: ButtonPress + * action = 0: nothing + * action < 0: ButtonRelease + * + * Why this stuff ??? Normally you cannot press both mousebuttons together, so + * the mouse reports both pressed at the same time ... + */ + +static char stateTab[48][3] = { + +/* nothing pressed */ + { 0, 0, 0 }, + { 0, 0, 8 }, /* 1 right -> delayed right */ + { 0, 0, 0 }, /* 2 nothing */ + { 0, 0, 8 }, /* 3 right -> delayed right */ + { 0, 0, 16 }, /* 4 left -> delayed left */ + { 2, 0, 24 }, /* 5 left & right (middle press) -> middle pressed */ + { 0, 0, 16 }, /* 6 left -> delayed left */ + { 2, 0, 24 }, /* 7 left & right (middle press) -> middle pressed */ + +/* delayed right */ + { 1, -1, 0 }, /* 8 nothing (right event) -> init */ + { 1, 0, 32 }, /* 9 right (right press) -> right pressed */ + { 1, -1, 0 }, /* 10 nothing (right event) -> init */ + { 1, 0, 32 }, /* 11 right (right press) -> right pressed */ + { 1, -1, 16 }, /* 12 left (right event) -> delayed left */ + { 2, 0, 24 }, /* 13 left & right (middle press) -> middle pressed */ + { 1, -1, 16 }, /* 14 left (right event) -> delayed left */ + { 2, 0, 24 }, /* 15 left & right (middle press) -> middle pressed */ + +/* delayed left */ + { 3, -3, 0 }, /* 16 nothing (left event) -> init */ + { 3, -3, 8 }, /* 17 right (left event) -> delayed right */ + { 3, -3, 0 }, /* 18 nothing (left event) -> init */ + { 3, -3, 8 }, /* 19 right (left event) -> delayed right */ + { 3, 0, 40 }, /* 20 left (left press) -> pressed left */ + { 2, 0, 24 }, /* 21 left & right (middle press) -> pressed middle */ + { 3, 0, 40 }, /* 22 left (left press) -> pressed left */ + { 2, 0, 24 }, /* 23 left & right (middle press) -> pressed middle */ + +/* pressed middle */ + { -2, 0, 0 }, /* 24 nothing (middle release) -> init */ + { -2, 0, 0 }, /* 25 right (middle release) -> init */ + { -2, 0, 0 }, /* 26 nothing (middle release) -> init */ + { -2, 0, 0 }, /* 27 right (middle release) -> init */ + { -2, 0, 0 }, /* 28 left (middle release) -> init */ + { 0, 0, 24 }, /* 29 left & right -> pressed middle */ + { -2, 0, 0 }, /* 30 left (middle release) -> init */ + { 0, 0, 24 }, /* 31 left & right -> pressed middle */ + +/* pressed right */ + { -1, 0, 0 }, /* 32 nothing (right release) -> init */ + { 0, 0, 32 }, /* 33 right -> pressed right */ + { -1, 0, 0 }, /* 34 nothing (right release) -> init */ + { 0, 0, 32 }, /* 35 right -> pressed right */ + { -1, 0, 16 }, /* 36 left (right release) -> delayed left */ + { -1, 2, 24 }, /* 37 left & right (r rel, m prs) -> middle pressed */ + { -1, 0, 16 }, /* 38 left (right release) -> delayed left */ + { -1, 2, 24 }, /* 39 left & right (r rel, m prs) -> middle pressed */ + +/* pressed left */ + { -3, 0, 0 }, /* 40 nothing (left release) -> init */ + { -3, 0, 8 }, /* 41 right (left release) -> delayed right */ + { -3, 0, 0 }, /* 42 nothing (left release) -> init */ + { -3, 0, 8 }, /* 43 right (left release) -> delayed right */ + { 0, 0, 40 }, /* 44 left -> left pressed */ + { -3, 2, 24 }, /* 45 left & right (l rel, mprs) -> middle pressed */ + { 0, 0, 40 }, /* 46 left -> left pressed */ + { -3, 2, 24 }, /* 47 left & right (l rel, mprs) -> middle pressed */ +}; + + +/* + * Table to allow quick reversal of natural button mapping to correct mapping + */ + +/* + * [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol + * with a fourth button activated by tapping the PAD. + * The 2nd line corresponds to 4th button on; the drv sends + * the buttons in the following map (MSBit described first) : + * 0 | 4th | 1st | 2nd | 3rd + * And we remap them (MSBit described first) : + * 0 | 4th | 3rd | 2nd | 1st + */ +static char reverseMap[32] = { 0, 4, 2, 6, 1, 5, 3, 7, + 8, 12, 10, 14, 9, 13, 11, 15, + 16, 20, 18, 22, 17, 21, 19, 23, + 24, 28, 26, 30, 25, 29, 27, 31}; + + +static char hitachMap[16] = { 0, 2, 1, 3, + 8, 10, 9, 11, + 4, 6, 5, 7, + 12, 14, 13, 15 }; + +#define reverseBits(map, b) (((b) & ~0x0f) | map[(b) & 0x0f]) + + +/* + * TimeSinceLastInputEvent -- + * Function used for screensaver purposes by the os module. Retruns the + * time in milliseconds since there last was any input. + */ + +int +TimeSinceLastInputEvent() +{ + if (xf86Info.lastEventTime == 0) { + xf86Info.lastEventTime = GetTimeInMillis(); + } + return GetTimeInMillis() - xf86Info.lastEventTime; +} + + + +/* + * SetTimeSinceLastInputEvent -- + * Set the lastEventTime to now. + */ + +void +SetTimeSinceLastInputEvent() +{ + xf86Info.lastEventTime = GetTimeInMillis(); +} + + + +/* + * ProcessInputEvents -- + * Retrieve all waiting input events and pass them to DIX in their + * correct chronological order. Only reads from the system pointer + * and keyboard. + */ + +void +ProcessInputEvents () +{ + int x, y; +#ifdef INHERIT_LOCK_STATE + static int generation = 0; +#endif + +#ifdef AMOEBA +#define MAXEVENTS 32 +#define BUTTON_PRESS 0x1000 +#define MAP_BUTTON(ev,but) (((ev) == EV_ButtonPress) ? \ + ((but) | BUTTON_PRESS) : ((but) & ~BUTTON_PRESS)) +#define KEY_RELEASE 0x80 +#define MAP_KEY(ev, key) (((ev) == EV_KeyReleaseEvent) ? \ + ((key) | KEY_RELEASE) : ((key) & ~KEY_RELEASE)) + + register IOPEvent *e, *elast; + IOPEvent events[MAXEVENTS]; + int dx, dy, nevents; +#endif + + /* + * With INHERIT_LOCK_STATE defined, the initial state of CapsLock, NumLock + * and ScrollLock will be set to match that of the VT the server is + * running on. + */ +#ifdef INHERIT_LOCK_STATE + if (generation != serverGeneration) { + xEvent kevent; + DevicePtr pKeyboard = xf86Info.pKeyboard; + extern unsigned int xf86InitialCaps, xf86InitialNum, xf86InitialScroll; + + generation = serverGeneration; + kevent.u.keyButtonPointer.time = GetTimeInMillis(); + kevent.u.keyButtonPointer.rootX = 0; + kevent.u.keyButtonPointer.rootY = 0; + kevent.u.u.type = KeyPress; + + + if (xf86InitialCaps) { + kevent.u.u.detail = xf86InitialCaps; + (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1); + xf86InitialCaps = 0; + } + if (xf86InitialNum) { + kevent.u.u.detail = xf86InitialNum; + (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1); + xf86InitialNum = 0; + } + if (xf86InitialScroll) { + kevent.u.u.detail = xf86InitialScroll; + (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1); + xf86InitialScroll = 0; + } + } +#endif + +#ifdef AMOEBA + /* + * Get all events from the IOP server + */ + while ((nevents = AmoebaGetEvents(events, MAXEVENTS)) > 0) { + for (e = &events[0], elast = &events[nevents]; e < elast; e++) { + xf86Info.lastEventTime = e->time; + switch (e->type) { + case EV_PointerDelta: + if (e->x != 0 || e->y != 0) { + xf86PostMseEvent(&xf86Info.pMouse, 0, e->x, e->y); + } + break; + case EV_ButtonPress: + case EV_ButtonRelease: + xf86PostMseEvent(&xf86Info.pMouse, MAP_BUTTON(e->type, e->keyorbut), 0, 0); + break; + case EV_KeyPressEvent: + case EV_KeyReleaseEvent: + xf86PostKbdEvent(MAP_KEY(e->type, e->keyorbut)); + break; + default: + /* this shouldn't happen */ + ErrorF("stray event %d (%d,%d) %x\n", + e->type, e->x, e->y, e->keyorbut); + break; + } + } + } +#endif + + xf86Info.inputPending = FALSE; + +#ifdef XINPUT + xf86eqProcessInputEvents(); +#else + mieqProcessInputEvents(); +#endif + miPointerUpdate(); + + miPointerPosition(&x, &y); + xf86SetViewport(xf86Info.currentScreen, x, y); +} + + + +/* + * xf86PostKbdEvent -- + * Translate the raw hardware KbdEvent into an XEvent, and tell DIX + * about it. Scancode preprocessing and so on is done ... + * + * OS/2 specific xf86PostKbdEvent(key) has been moved to os-support/os2/os2_kbd.c + * as some things differ, and I did not want to scatter this routine with + * ifdefs further (hv). + */ + +#ifdef ASSUME_CUSTOM_KEYCODES +extern u_char SpecialServerMap[]; +#endif /* ASSUME_CUSTOM_KEYCODES */ + +#if !defined(__EMX__) +void +xf86PostKbdEvent(key) + unsigned key; +{ + int scanCode = (key & 0x7f); + int specialkey; + Bool down = (key & 0x80 ? FALSE : TRUE); + KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key; + Bool updateLeds = FALSE; + Bool UsePrefix = FALSE; + Bool Direction = FALSE; + xEvent kevent; + KeySym *keysym; + int keycode; + static int lockkeys = 0; +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + static Bool first_time = TRUE; +#endif + +#if defined(CODRV_SUPPORT) + if (xf86Info.consType == CODRV011 || xf86Info.consType == CODRV01X) + scanCode = xf86CodrvMap[scanCode]; +#endif + +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + if (first_time) + { + first_time = FALSE; + VTSwitchEnabled = (xf86Info.consType == SYSCONS) + || (xf86Info.consType == PCVT); + } +#endif + +#if defined (i386) && defined (SVR4) && !defined (PC98) + /* + * PANIX returns DICOP standards based keycodes in using 106jp + * keyboard. We need to remap some keys. + */ +#define KEY_P_UP 0x5A +#define KEY_P_PGUP 0x5B +#define KEY_P_LEFT 0x5C +#define KEY_P_BKSL 0x73 +#define KEY_P_YEN 0x7D +#define KEY_P_NFER 0x7B +#define KEY_P_XFER 0x79 + + if(xf86Info.panix106 == TRUE){ + switch (scanCode) { + /* case 0x78: scanCode = KEY_P_UP; break; not needed*/ + case 0x56: scanCode = KEY_P_BKSL; break; /* Backslash */ + case 0x5A: scanCode = KEY_P_NFER; break; /* No Kanji Transfer*/ + case 0x5B: scanCode = KEY_P_XFER; break; /* Kanji Tranfer */ + case 0x5C: scanCode = KEY_P_YEN; break; /* Yen curs pgup */ + case 0x6B: scanCode = KEY_P_LEFT; break; /* Cur Left */ + case 0x6F: scanCode = KEY_P_PGUP; break; /* Cur PageUp */ + case 0x72: scanCode = KEY_AltLang; break; /* AltLang(right) */ + case 0x73: scanCode = KEY_RCtrl; break; /* not needed */ + } + } +#endif /* i386 && SVR4 */ + +#ifndef ASSUME_CUSTOM_KEYCODES + /* + * First do some special scancode remapping ... + */ + if (xf86Info.scanPrefix == 0) { + + switch (scanCode) { + +#ifndef PC98 + case KEY_Prefix0: + case KEY_Prefix1: +#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + if (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS + || xf86Info.consType == PCVT) { +#endif + xf86Info.scanPrefix = scanCode; /* special prefixes */ + return; +#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + } + break; +#endif +#endif /* not PC98 */ + } +#ifndef PC98 + if (xf86Info.serverNumLock) { + if ((!xf86Info.numLock && ModifierDown(ShiftMask)) || + (xf86Info.numLock && !ModifierDown(ShiftMask))) { + /* + * Hardwired numlock handling ... (Some applications break if they have + * these keys double defined, like twm) + */ + switch (scanCode) { + case KEY_KP_7: scanCode = KEY_SN_KP_7; break; /* curs 7 */ + case KEY_KP_8: scanCode = KEY_SN_KP_8; break; /* curs 8 */ + case KEY_KP_9: scanCode = KEY_SN_KP_9; break; /* curs 9 */ + case KEY_KP_4: scanCode = KEY_SN_KP_4; break; /* curs 4 */ + case KEY_KP_5: scanCode = KEY_SN_KP_5; break; /* curs 5 */ + case KEY_KP_6: scanCode = KEY_SN_KP_6; break; /* curs 6 */ + case KEY_KP_1: scanCode = KEY_SN_KP_1; break; /* curs 1 */ + case KEY_KP_2: scanCode = KEY_SN_KP_2; break; /* curs 2 */ + case KEY_KP_3: scanCode = KEY_SN_KP_3; break; /* curs 3 */ + case KEY_KP_0: scanCode = KEY_SN_KP_0; break; /* curs 0 */ + case KEY_KP_Decimal: scanCode = KEY_SN_KP_Dec; break; /* curs decimal */ + } + } else { + switch (scanCode) { + case KEY_KP_7: scanCode = KEY_SN_KP_Home; break; /* curs home */ + case KEY_KP_8: scanCode = KEY_SN_KP_Up ; break; /* curs up */ + case KEY_KP_9: scanCode = KEY_SN_KP_Prior; break; /* curs pgup */ + case KEY_KP_4: scanCode = KEY_SN_KP_Left; break; /* curs left */ + case KEY_KP_5: scanCode = KEY_SN_KP_Begin; break; /* curs begin */ + case KEY_KP_6: scanCode = KEY_SN_KP_Right; break; /* curs right */ + case KEY_KP_1: scanCode = KEY_SN_KP_End; break; /* curs end */ + case KEY_KP_2: scanCode = KEY_SN_KP_Down; break; /* curs down */ + case KEY_KP_3: scanCode = KEY_SN_KP_Next; break; /* curs pgdn */ + case KEY_KP_0: scanCode = KEY_SN_KP_Ins; break; /* curs ins */ + case KEY_KP_Decimal: scanCode = KEY_SN_KP_Del; break; /* curs del */ + } + } + } +#endif /* not PC98 */ + } + +#ifndef PC98 + else if ( +#ifdef CSRG_BASED + (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS + || xf86Info.consType == PCVT) && +#endif + (xf86Info.scanPrefix == KEY_Prefix0)) { + xf86Info.scanPrefix = 0; + + switch (scanCode) { + case KEY_KP_7: scanCode = KEY_Home; break; /* curs home */ + case KEY_KP_8: scanCode = KEY_Up; break; /* curs up */ + case KEY_KP_9: scanCode = KEY_PgUp; break; /* curs pgup */ + case KEY_KP_4: scanCode = KEY_Left; break; /* curs left */ + case KEY_KP_5: scanCode = KEY_Begin; break; /* curs begin */ + case KEY_KP_6: scanCode = KEY_Right; break; /* curs right */ + case KEY_KP_1: scanCode = KEY_End; break; /* curs end */ + case KEY_KP_2: scanCode = KEY_Down; break; /* curs down */ + case KEY_KP_3: scanCode = KEY_PgDown; break; /* curs pgdown */ + case KEY_KP_0: scanCode = KEY_Insert; break; /* curs insert */ + case KEY_KP_Decimal: scanCode = KEY_Delete; break; /* curs delete */ + case KEY_Enter: scanCode = KEY_KP_Enter; break; /* keypad enter */ + case KEY_LCtrl: scanCode = KEY_RCtrl; break; /* right ctrl */ + case KEY_KP_Multiply: scanCode = KEY_Print; break; /* print */ + case KEY_Slash: scanCode = KEY_KP_Divide; break; /* keyp divide */ + case KEY_Alt: scanCode = KEY_AltLang; break; /* right alt */ + case KEY_ScrollLock: scanCode = KEY_Break; break; /* curs break */ + case 0x5b: scanCode = KEY_LMeta; break; + case 0x5c: scanCode = KEY_RMeta; break; + case 0x5d: scanCode = KEY_Menu; break; + case KEY_F3: scanCode = KEY_F13; break; + case KEY_F4: scanCode = KEY_F14; break; + case KEY_F5: scanCode = KEY_F15; break; + case KEY_F6: scanCode = KEY_F16; break; + case KEY_F7: scanCode = KEY_F17; break; + case KEY_KP_Plus: scanCode = KEY_KP_DEC; break; + /* + * Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6) + */ + default: + return; /* skip illegal */ + } + } + + else if (xf86Info.scanPrefix == KEY_Prefix1) + { + xf86Info.scanPrefix = (scanCode == KEY_LCtrl) ? KEY_LCtrl : 0; + return; + } + + else if (xf86Info.scanPrefix == KEY_LCtrl) + { + xf86Info.scanPrefix = 0; + if (scanCode != KEY_NumLock) return; + scanCode = KEY_Pause; /* pause */ + } +#endif /* not PC98 */ +#endif /* !ASSUME_CUSTOM_KEYCODES */ + + /* + * and now get some special keysequences + */ + +#ifdef ASSUME_CUSTOM_KEYCODES + specialkey = SpecialServerMap[scanCode]; +#else /* ASSUME_CUSTOM_KEYCODES */ + specialkey = scanCode; +#endif /* ASSUME_CUSTOM_KEYCODES */ + + if ((ModifierDown(ControlMask | AltMask)) || + (ModifierDown(ControlMask | AltLangMask))) + { + + switch (specialkey) { + + case KEY_BackSpace: + if (!xf86Info.dontZap) { +#ifdef XFreeXDGA + if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics) + break; +#endif + GiveUp(0); + } + break; + + /* + * The idea here is to pass the scancode down to a list of + * registered routines. There should be some standard conventions + * for processing certain keys. + */ + case KEY_KP_Minus: /* Keypad - */ + if (!xf86Info.dontZoom) { + if (down) xf86ZoomViewport(xf86Info.currentScreen, -1); + return; + } + break; + + case KEY_KP_Plus: /* Keypad + */ + if (!xf86Info.dontZoom) { + if (down) xf86ZoomViewport(xf86Info.currentScreen, 1); + return; + } + break; + +#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) || defined(SCO) + /* + * Under Linux, the raw keycodes are consumed before the kernel + * does any processing on them, so we must emulate the vt switching + * we want ourselves. + */ + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + if (VTSwitchEnabled && !xf86Info.vtSysreq +#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) + && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) +#endif + ) + { + if (down) +#ifdef SCO325 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F1); +#else + ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F1 + 1); +#endif + return; + } + break; + case KEY_F11: + case KEY_F12: + if (VTSwitchEnabled && !xf86Info.vtSysreq +#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) + && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) +#endif + ) + { + if (down) +#ifdef SCO325 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F11 + 10); +#else + ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F11 + 11); +#endif + return; + } + break; +#endif /* linux || BSD with VTs */ + + /* just worth mentioning here: any 386bsd keyboard driver + * (pccons.c or co_kbd.c) catches CTRL-ALT-DEL and CTRL-ALT-ESC + * before any application (e.g. XF86) will see it + * OBS: syscons does not, nor does pcvt ! + */ + } + } + + /* + * Start of actual Solaris VT switching code. + * This should pretty much emulate standard SVR4 switching keys. + * + * DWH 12/2/93 + */ + +#ifdef USE_VT_SYSREQ + if (VTSwitchEnabled && xf86Info.vtSysreq) + { + switch (specialkey) + { + /* + * syscons on *BSD doesn't have a VT #0 -- don't think Linux does + * either + */ +#if defined (sun) && defined (i386) && defined (SVR4) + case KEY_H: + if (VTSysreqToggle && down) + { + ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0); + VTSysreqToggle = 0; + return; + } + break; + + /* + * Yah, I know the N, and P keys seem backwards, however that's + * how they work under Solaris + * XXXX N means go to next active VT not necessarily vtno+1 (or vtno-1) + */ + + case KEY_N: + if (VTSysreqToggle && down) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno - 1 ) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + VTSysreqToggle = FALSE; + return; + } + break; + + case KEY_P: + if (VTSysreqToggle && down) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1 ) < 0) + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + VTSysreqToggle = FALSE; + return; + } + break; +#endif + + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + if (VTSysreqToggle && down) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey-KEY_F1 + 1) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + VTSysreqToggle = FALSE; + return; + } + break; + + case KEY_F11: + case KEY_F12: + if (VTSysreqToggle && down) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey-KEY_F11 + 11) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + VTSysreqToggle = FALSE; + return; + } + break; + + /* Ignore these keys -- ie don't let them cancel an alt-sysreq */ + case KEY_Alt: +#ifndef PC98 + case KEY_AltLang: +#endif /* not PC98 */ + break; + +#ifndef PC98 + case KEY_SysReqest: + if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask))) + VTSysreqToggle = TRUE; + break; +#endif /* not PC98 */ + + default: + if (VTSysreqToggle) + { + /* + * We only land here when Alt-SysReq is followed by a + * non-switching key. + */ + VTSysreqToggle = FALSE; + + } + } + } + +#endif /* USE_VT_SYSREQ */ + +#ifdef SCO + /* + * With the console in raw mode, SCO will not switch consoles, + * you get around this by activating the next console along, if + * this fails then go back to console 0, if there is only one + * then it doesn't matter, switching to yourself is a nop as far + * as the console driver is concerned. + * We could do something similar to linux here but SCO ODT uses + * Ctrl-PrintScrn, so why change? + */ + if (specialkey == KEY_Print && ModifierDown(ControlMask)) { + if (down) + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno + 1) < 0) + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 0) < 0) + ErrorF("Failed to switch consoles (%s)\n", strerror(errno)); + return; + } +#endif /* SCO */ + + /* + * Now map the scancodes to real X-keycodes ... + */ + keycode = scanCode + MIN_KEYCODE; + keysym = (keyc->curKeySyms.map + + keyc->curKeySyms.mapWidth * + (keycode - keyc->curKeySyms.minKeyCode)); +#ifdef XKB + if (noXkbExtension) { +#endif + /* + * Filter autorepeated caps/num/scroll lock keycodes. + */ +#define CAPSFLAG 0x01 +#define NUMFLAG 0x02 +#define SCROLLFLAG 0x04 +#define MODEFLAG 0x08 + if( down ) { + switch( keysym[0] ) { + case XK_Caps_Lock : + if (lockkeys & CAPSFLAG) + return; + else + lockkeys |= CAPSFLAG; + break; + + case XK_Num_Lock : + if (lockkeys & NUMFLAG) + return; + else + lockkeys |= NUMFLAG; + break; + + case XK_Scroll_Lock : + if (lockkeys & SCROLLFLAG) + return; + else + lockkeys |= SCROLLFLAG; + break; + } + if (keysym[1] == XF86XK_ModeLock) + { + if (lockkeys & MODEFLAG) + return; + else + lockkeys |= MODEFLAG; + } + + } + else { + switch( keysym[0] ) { + case XK_Caps_Lock : + lockkeys &= ~CAPSFLAG; + break; + + case XK_Num_Lock : + lockkeys &= ~NUMFLAG; + break; + + case XK_Scroll_Lock : + lockkeys &= ~SCROLLFLAG; + break; + } + if (keysym[1] == XF86XK_ModeLock) + lockkeys &= ~MODEFLAG; + } + + /* + * LockKey special handling: + * ignore releases, toggle on & off on presses. + * Don't deal with the Caps_Lock keysym directly, but check the lock modifier + */ +#ifndef PC98 + if (keyc->modifierMap[keycode] & LockMask || + keysym[0] == XK_Scroll_Lock || + keysym[1] == XF86XK_ModeLock || + keysym[0] == XK_Num_Lock) + { + Bool flag; + + if (!down) return; + if (KeyPressed(keycode)) { + down = !down; + flag = FALSE; + } + else + flag = TRUE; + + if (keyc->modifierMap[keycode] & LockMask) xf86Info.capsLock = flag; + if (keysym[0] == XK_Num_Lock) xf86Info.numLock = flag; + if (keysym[0] == XK_Scroll_Lock) xf86Info.scrollLock = flag; + if (keysym[1] == XF86XK_ModeLock) xf86Info.modeSwitchLock = flag; + updateLeds = TRUE; + } +#endif /* not PC98 */ + +#ifndef ASSUME_CUSTOM_KEYCODES + /* + * normal, non-keypad keys + */ + if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) { +#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__) + /* + * magic ALT_L key on AT84 keyboards for multilingual support + */ + if (xf86Info.kbdType == KB_84 && + ModifierDown(AltMask) && + keysym[2] != NoSymbol) + { + UsePrefix = TRUE; + Direction = TRUE; + } +#endif /* !CSRG_BASED && !MACH386 && !MINIX && !__OSF__ */ + } +#endif /* !ASSUME_CUSTOM_KEYCODES */ + if (updateLeds) xf86KbdLeds(); +#ifdef XKB + } +#endif + + /* + * check for an autorepeat-event + */ + if ((down && KeyPressed(keycode)) && + (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode])) + return; + + xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis(); + /* + * And now send these prefixes ... + * NOTE: There cannot be multiple Mode_Switch keys !!!! + */ + if (UsePrefix) + { + ENQUEUE(&kevent, + keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], + (Direction ? KeyPress : KeyRelease), + XE_KEYBOARD); + ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); + ENQUEUE(&kevent, + keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], + (Direction ? KeyRelease : KeyPress), + XE_KEYBOARD); + } + else + { +#ifdef XFreeXDGA + if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectKeyb) { + XF86DirectVideoKeyEvent(&kevent, keycode, (down ? KeyPress : KeyRelease)); + } else +#endif + { + ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); + + } + } +} +#endif /* !__EMX__ */ + + +static CARD32 +buttonTimer(timer, now, arg) + OsTimerPtr timer; + CARD32 now; + pointer arg; +{ + MouseDevPtr priv = MOUSE_DEV((DeviceIntPtr) arg); + + xf86PostMseEvent(((DeviceIntPtr) arg), priv->truebuttons, 0, 0); + return(0); +} + + +/* + * xf86PostMseEvent -- + * Translate the raw hardware MseEvent into an XEvent(s), and tell DIX + * about it. Perform a 3Button emulation if required. + */ + +void +xf86PostMseEvent(device, buttons, dx, dy) + DeviceIntPtr device; + int buttons, dx, dy; +{ + static OsTimerPtr timer = NULL; + MouseDevPtr private = MOUSE_DEV(device); + int id, change; + int truebuttons; + xEvent mevent[2]; +#ifdef XINPUT + deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) mevent; + deviceValuator *xv = (deviceValuator *) (xev+1); + int is_pointer; /* the mouse is the pointer ? */ +#endif + +#ifdef AMOEBA + int pressed; + + pressed = ((buttons & BUTTON_PRESS) != 0); + buttons &= ~BUTTON_PRESS; +#endif + +#ifdef XINPUT + is_pointer = xf86IsCorePointer(device); + + if (!is_pointer) { + xev->time = xf86Info.lastEventTime = GetTimeInMillis(); + } + else +#endif + xf86Info.lastEventTime = mevent->u.keyButtonPointer.time = GetTimeInMillis(); + + truebuttons = buttons; + if (private->mseType == P_MMHIT) + buttons = reverseBits(hitachMap, buttons); + else + buttons = reverseBits(reverseMap, buttons); + + if (dx || dy) { + + /* + * accelerate the baby now if sqrt(dx*dx + dy*dy) > threshold ! + * but do some simpler arithmetic here... + */ + if ((abs(dx) + abs(dy)) >= private->threshold) { + dx = (dx * private->num) / private->den; + dy = (dy * private->num)/ private->den; + } + +#ifdef XINPUT + if (is_pointer) { +#endif +#ifdef XFreeXDGA + if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectMouse) { + XF86DirectVideoMoveMouse(dx, dy, mevent->u.keyButtonPointer.time); + } else +#endif + { + MOVEPOINTER(dx, dy, mevent->u.keyButtonPointer.time); + } +#ifdef XINPUT + } + else { + xev->type = DeviceMotionNotify; + xev->deviceid = device->id | MORE_EVENTS; + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->num_valuators = 2; + xv->first_valuator = 0; + xv->device_state = 0; + xv->valuator0 = dx; + xv->valuator1 = dy; + xf86eqEnqueue(mevent); + } +#endif + } + + if (private->emulate3Buttons) + { + + /* + * Hack to operate the middle button even with Emulate3Buttons set. + * Modifying the state table to keep track of the middle button state + * would nearly double its size, so I'll stick with this fix. - TJW + */ + if (private->mseType == P_MMHIT) + change = buttons ^ reverseBits(hitachMap, private->lastButtons); + else + change = buttons ^ reverseBits(reverseMap, private->lastButtons); + if (change & 02) + { +#ifdef XINPUT + if (xf86CheckButton(2, (buttons & 02))) { +#endif + ENQUEUE(mevent, + 2, (buttons & 02) ? ButtonPress : ButtonRelease, + XE_POINTER); +#ifdef XINPUT + } +#endif + } + + /* + * emulate the third button by the other two + */ + if ((id = stateTab[buttons + private->emulateState][0]) != 0) + { +#ifdef XINPUT + if (is_pointer) { + if (xf86CheckButton(abs(id), (id >= 0))) { +#endif + ENQUEUE(mevent, + abs(id), (id < 0 ? ButtonRelease : ButtonPress), + XE_POINTER); +#ifdef XINPUT + } + } + else { + xev->type = (id < 0 ? DeviceButtonRelease : DeviceButtonPress); + xev->deviceid = device->id | MORE_EVENTS; + xev->detail = abs(id); + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->num_valuators = 0; + xv->device_state = 0; + xf86eqEnqueue(mevent); + } +#endif + } + + if ((id = stateTab[buttons + private->emulateState][1]) != 0) + { +#ifdef XINPUT + if (is_pointer) { + if (xf86CheckButton(abs(id), (id >= 0))) { +#endif + ENQUEUE(mevent, + abs(id), (id < 0 ? ButtonRelease : ButtonPress), + XE_POINTER); +#ifdef XINPUT + } + } + else { + xev->type = (id < 0 ? DeviceButtonRelease : DeviceButtonPress); + xev->deviceid = device->id | MORE_EVENTS; + xev->detail = abs(id); + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->num_valuators = 0; + xv->device_state = 0; + xf86eqEnqueue(mevent); + } +#endif + } + + private->emulateState = stateTab[buttons + private->emulateState][2]; + if (stateTab[buttons + private->emulateState][0] || + stateTab[buttons + private->emulateState][1]) + { + private->truebuttons = truebuttons; + timer = TimerSet(timer, 0, private->emulate3Timeout, buttonTimer, + (pointer)device); + } + else + { + if (timer) + { + TimerFree(timer); + timer = NULL; + } + } + } + else + { +#ifdef AMOEBA + if (truebuttons != 0) { +#ifdef XINPUT + if (is_pointer) { + if (xf86CheckButton(truebuttons)) { +#endif + ENQUEUE(mevent, + truebuttons, (pressed ? ButtonPress : ButtonRelease), + XE_POINTER); +#ifdef XINPUT + } + } + else { + xev->type = pressed ? DeviceButtonPress : DeviceButtonRelease; + xev->deviceid = device->id | MORE_EVENTS; + xev->detail = truebuttons; + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->num_valuators = 0; + xv->device_state = 0; + xf86eqEnqueue(mevent); + } +#endif + } +#else + /* + * real three button event + * Note that xf86Info.lastButtons has the hardware button mapping which + * is the reverse of the button mapping reported to the server. + */ + if (private->mseType == P_MMHIT) + change = buttons ^ reverseBits(hitachMap, private->lastButtons); + else + change = buttons ^ reverseBits(reverseMap, private->lastButtons); + while (change) + { + id = ffs(change); + change &= ~(1 << (id-1)); +#ifdef XINPUT + if (is_pointer) { + if (xf86CheckButton(id, (buttons&(1<<(id-1))))) { +#endif + ENQUEUE(mevent, + id, (buttons&(1<<(id-1)))? ButtonPress : ButtonRelease, + XE_POINTER); +#ifdef XINPUT + } + } + else { + xev->type = (buttons&(1<<(id-1)))? DeviceButtonPress : DeviceButtonRelease; + xev->deviceid = device->id | MORE_EVENTS; + xev->detail = id; + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->num_valuators = 0; + xv->device_state = 0; + xf86eqEnqueue(mevent); + } +#endif + } +#endif + } + private->lastButtons = truebuttons; +} + + + +/* + * xf86Block -- + * Os block handler. + */ + +/* ARGSUSED */ +void +xf86Block(blockData, pTimeout, pReadmask) + pointer blockData; + OSTimePtr pTimeout; + pointer pReadmask; +{ +} + + +#ifndef AMOEBA + +/* + * xf86Wakeup -- + * Os wakeup handler. + */ + +/* ARGSUSED */ +void +xf86Wakeup(blockData, err, pReadmask) + pointer blockData; + int err; + pointer pReadmask; +{ + +#ifndef __EMX__ +#ifdef __OSF__ + fd_set kbdDevices; + fd_set mseDevices; +#endif /* __OSF__ */ + fd_set* LastSelectMask = (fd_set*)pReadmask; + fd_set devicesWithInput; + + if ((int)err >= 0) { + XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices); +#ifdef __OSF__ + /* + * Until the two devices are made nonblock on read, we have to do this. + */ + + MASKANDSETBITS(devicesWithInput, pReadmask, EnabledDevices); + + CLEARBITS(kbdDevices); + BITSET(kbdDevices, xf86Info.consoleFd); + MASKANDSETBITS(kbdDevices, kbdDevices, devicesWithInput); + + CLEARBITS(mseDevices); + BITSET(mseDevices, xf86Info.mouseDev->mseFd); + MASKANDSETBITS(mseDevices, mseDevices, devicesWithInput); + + if (ANYSET(kbdDevices) || xf86Info.kbdRate) + (xf86Info.kbdEvents)(ANYSET(kbdDevices)); + if (ANYSET(mseDevices)) + (xf86Info.mouseDev->mseEvents)(1); + +#else + if (XFD_ANYSET(&devicesWithInput)) + { + (xf86Info.kbdEvents)(); + (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev); + } +#endif /* __OSF__ */ + } +#else /* __EMX__ */ + + (xf86Info.kbdEvents)(); /* Under OS/2, always call */ + (xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev); + +#endif /* __EMX__ */ + +#if defined(XQUEUE) && !defined(XQUEUE_ASYNC) + /* This could be done more cleanly */ + if (xf86Info.mouseDev->xqueSema && xf86Info.mouseDev->xquePending) + xf86XqueRequest(); +#endif + + if (xf86VTSwitchPending()) xf86VTSwitch(); + + if (xf86Info.inputPending) ProcessInputEvents(); +} + +#endif /* AMOEBA */ + + +/* + * xf86SigHandler -- + * Catch unexpected signals and exit cleanly. + */ +void +xf86SigHandler(signo) + int signo; +{ + signal(signo,SIG_IGN); + xf86Info.caughtSignal = TRUE; + FatalError("Caught signal %d. Server aborting\n", signo); +} + +/* + * xf86VTSwitch -- + * Handle requests for switching the vt. + */ +static void +xf86VTSwitch() +{ + int j; + +#ifdef XFreeXDGA + /* + * Not ideal, but until someone adds DGA events to the DGA client we + * should protect the machine + */ + if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics) { + xf86Info.vtRequestsPending = FALSE; + return; + } +#endif + if (xf86VTSema) { + for (j = 0; j < screenInfo.numScreens; j++) + (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(LEAVE, j); + +#ifndef __EMX__ + DisableDevice((DeviceIntPtr)xf86Info.pKeyboard); + DisableDevice((DeviceIntPtr)xf86Info.pMouse); +#endif + + if (!xf86VTSwitchAway()) { + /* + * switch failed + */ + + for (j = 0; j < screenInfo.numScreens; j++) + (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(ENTER, j); + SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset); +#ifdef DPMSExtension + if (DPMSEnabled) + DPMSSet(DPMSModeOn); +#endif + +#ifndef __EMX__ + EnableDevice((DeviceIntPtr)xf86Info.pKeyboard); + EnableDevice((DeviceIntPtr)xf86Info.pMouse); +#endif + + } else { + xf86VTSema = FALSE; + } + } else { + if (!xf86VTSwitchTo()) return; + + xf86VTSema = TRUE; + for (j = 0; j < screenInfo.numScreens; j++) + (XF86SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(ENTER, j); + + /* Turn screen saver off when switching back */ + SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset); +#ifdef DPMSExtension + if (DPMSEnabled) + DPMSSet(DPMSModeOn); +#endif + +#ifndef __EMX__ + EnableDevice((DeviceIntPtr)xf86Info.pKeyboard); + EnableDevice((DeviceIntPtr)xf86Info.pMouse); +#endif + + } +} + +#ifdef XTESTEXT1 + +void +XTestGetPointerPos(fmousex, fmousey) + short *fmousex; + short *fmousey; +{ + int x,y; + + miPointerPosition(&x, &y); + *fmousex = x; + *fmousey = y; +} + + + +void +XTestJumpPointer(jx, jy, dev_type) + int jx; + int jy; + int dev_type; +{ + miPointerAbsoluteCursor(jx, jy, GetTimeInMillis() ); +} + + + +void +XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey) + int dev_type; + int keycode; + int keystate; + int mousex; + int mousey; +{ + xEvent tevent; + + tevent.u.u.type = (dev_type == XE_POINTER) ? + (keystate == XTestKEY_UP) ? ButtonRelease : ButtonPress : + (keystate == XTestKEY_UP) ? KeyRelease : KeyPress; + tevent.u.u.detail = keycode; + tevent.u.keyButtonPointer.rootX = mousex; + tevent.u.keyButtonPointer.rootY = mousey; + tevent.u.keyButtonPointer.time = xf86Info.lastEventTime = GetTimeInMillis(); +#ifdef XINPUT + xf86eqEnqueue(&tevent); +#else + mieqEnqueue(&tevent); +#endif + xf86Info.inputPending = TRUE; /* virtual event */ +} + +#endif /* XTESTEXT1 */ + + +#ifdef XFreeXDGA +static void +XF86DirectVideoMoveMouse(x, y, mtime) + int x; + int y; + CARD32 mtime; +{ + xEvent xE; + + xE.u.u.type = MotionNotify; + xE.u.keyButtonPointer.time = xf86Info.lastEventTime = mtime; + xf86Info.lastEventTime = mtime; + + + xE.u.keyButtonPointer.eventY = x; + xE.u.keyButtonPointer.eventY = y; + xE.u.keyButtonPointer.rootX = x; + xE.u.keyButtonPointer.rootY = y; + + if (((DeviceIntPtr)(xf86Info.pMouse))->grab) + DeliverGrabbedEvent(&xE, (xf86Info.pMouse), FALSE, 1); + else + DeliverDeviceEvents(GetSpriteWindow(), &xE, NullGrab, NullWindow, + (xf86Info.pMouse), 1); +} + +static void +XF86DirectVideoKeyEvent(xE, keycode, etype) +xEvent *xE; +int keycode; +int etype; +{ + DeviceIntPtr keybd = (DeviceIntPtr)xf86Info.pKeyboard; + KeyClassPtr keyc = keybd->key; + BYTE *kptr; + + kptr = &keyc->down[keycode >> 3]; + xE->u.u.type = etype; + xE->u.u.detail = keycode; + + /* clear the keypress state */ + if (etype == KeyPress) { + *kptr &= ~(1 << (keycode & 7)); + } + keybd->public.processInputProc(xE, keybd, 1); +} +#endif diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c new file mode 100644 index 000000000..864933a84 --- /dev/null +++ b/hw/xfree86/common/xf86Init.c @@ -0,0 +1,834 @@ +/* + * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.66.2.2 1997/06/29 08:43:36 dawes Exp $ + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* $Xorg: xf86Init.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */ + +#ifndef X_NOT_STDC_ENV +#include <stdlib.h> +#else +extern int atoi(); +#endif + +#define NEED_EVENTS +#include "X.h" +#include "Xmd.h" +#include "Xproto.h" +#include "input.h" +#include "servermd.h" +#include "scrnintstr.h" +#include "site.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86Version.h" +#include "mipointer.h" + +#ifdef XINPUT +#include "XI.h" +#include "XIproto.h" +#include "xf86_Config.h" +#include "xf86Xinput.h" +#else +#include "inputstr.h" +#endif + +#include "opaque.h" + +#ifdef XTESTEXT1 +#include "atKeynames.h" +extern int xtest_command_key; +#endif /* XTESTEXT1 */ + +#ifdef __EMX__ +#define seteuid(x) /*nothing*/ +#define setruid(x) /*nothing*/ +#endif + +/* xf86Exiting is set while the screen is shutting down (even on a reset) */ +Bool xf86Exiting = FALSE; +Bool xf86Resetting = FALSE; +Bool xf86ProbeFailed = TRUE; +Bool xf86FlipPixels = FALSE; +#ifdef XF86VIDMODE +Bool xf86VidModeEnabled = TRUE; +Bool xf86VidModeAllowNonLocal = FALSE; +#endif +#ifdef XF86MISC +Bool xf86MiscModInDevEnabled = TRUE; +Bool xf86MiscModInDevAllowNonLocal = FALSE; +#endif +Bool xf86AllowMouseOpenFail = FALSE; +PciProbeType xf86PCIFlags = PCIProbe1; +Bool xf86ScreensOpen = FALSE; +int xf86Verbose = 1; +Bool xf86fpFlag = FALSE; +Bool xf86coFlag = FALSE; +Bool xf86sFlag = FALSE; +Bool xf86ProbeOnly = FALSE; +char xf86ConfigFile[PATH_MAX] = ""; +int xf86bpp = -1; +xrgb xf86weight = { 0, 0, 0 } ; /* RGB weighting at 16 bpp */ +double xf86rGamma=1.0, xf86gGamma=1.0, xf86bGamma=1.0; +unsigned char xf86rGammaMap[256], xf86gGammaMap[256], xf86bGammaMap[256]; +char *xf86ServerName = NULL; +Bool xf86BestRefresh = FALSE; + +int vgaIOBase = 0x3d0; +int vgaCRIndex = 0x3d4; +int vgaCRReg = 0x3d5; + +static void xf86PrintBanner( +#if NeedFunctionPrototypes + void +#endif + ); +static void xf86PrintConfig( +#if NeedFunctionPrototypes + void +#endif + ); +#ifdef DO_CHECK_BETA +void xf86CheckBeta( +#if NeedFunctionPrototypes + int, + char * +#endif + ); +static int extraDays = 0; +static char *expKey = NULL; +#endif + +extern ScrnInfoPtr xf86Screens[]; +extern int xf86MaxScreens; +extern double pow(); +#ifdef USE_XF86_SERVERLOCK +extern void xf86UnlockServer(); +#endif +#ifdef __EMX__ +extern void os2ServerVideoAccess(); +#endif + +xf86InfoRec xf86Info; +int xf86ScreenIndex; + +/* + * InitOutput -- + * Initialize screenInfo for all actually accessible framebuffers. + * That includes vt-manager setup, querying all possible devices and + * collecting the pixmap formats. + */ + +void +InitOutput(pScreenInfo, argc, argv) + ScreenInfo *pScreenInfo; + int argc; + char **argv; +{ + int i, j, scr_index; + static int numFormats = 0; + static PixmapFormatRec formats[MAXFORMATS]; + static unsigned long generation = 0; + int any_screens = 0; + +#ifdef __EMX__ + os2ServerVideoAccess(); /* See if we have access to the screen before doing anything */ +#endif + + if (serverGeneration == 1) { + + if ((xf86ServerName = strrchr(argv[0], '/')) != 0) + xf86ServerName++; + else + xf86ServerName = argv[0]; + +#ifdef DO_CHECK_BETA + xf86CheckBeta(extraDays, expKey); +#endif + + xf86PrintBanner(); + + xf86PrintConfig(); + + xf86OpenConsole(); + +#if !defined(AMOEBA) && !defined(MINIX) + /* + * If VTInit was set, run that program with consoleFd as stdin and stdout + */ + + if (xf86Info.vtinit) { + switch(fork()) { + case -1: + FatalError("Fork failed for VTInit (%s)\n", strerror(errno)); + break; + case 0: /* child */ + setuid(getuid()); + /* set stdin, stdout to the consoleFd */ + for (i = 0; i < 2; i++) { + if (xf86Info.consoleFd != i) { + close(i); + dup(xf86Info.consoleFd); + } + } + execl("/bin/sh", "sh", "-c", xf86Info.vtinit, NULL); + ErrorF("Warning: exec of /bin/sh failed for VTInit (%s)\n", + strerror(errno)); + exit(255); + break; + default: /* parent */ + wait(NULL); + } + } +#endif /* !AMOEBA && !MINIX */ + + /* Do this after XF86Config is read (it's normally in OsInit()) */ + OsInitColors(); + + for (i=0; i<256; i++) { + xf86rGammaMap[i] = (int)(pow(i/255.0,xf86rGamma)*255.0+0.5); + xf86gGammaMap[i] = (int)(pow(i/255.0,xf86gGamma)*255.0+0.5); + xf86bGammaMap[i] = (int)(pow(i/255.0,xf86bGamma)*255.0+0.5); + } + + xf86Config(TRUE); /* Probe displays, and resolve modes */ + +#ifdef XKB + xf86InitXkb(); +#endif + + /* + * collect all possible formats + */ + formats[0].depth = 1; + formats[0].bitsPerPixel = 1; + formats[0].scanlinePad = BITMAP_SCANLINE_PAD; + numFormats++; + + for ( i=0; + i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured; + i++ ) + { + /* + * At least one probe function succeeded. + */ + any_screens = 1; + + /* + * add new pixmap format + */ + for ( j=0; j < numFormats; j++ ) { + + if (formats[j].depth == xf86Screens[i]->depth && + formats[j].bitsPerPixel == xf86Screens[i]->bitsPerPixel) + break; /* found */ + } + + if (j == numFormats) { /* not already there */ + formats[j].depth = xf86Screens[i]->depth; + formats[j].bitsPerPixel = xf86Screens[i]->bitsPerPixel; + formats[j].scanlinePad = BITMAP_SCANLINE_PAD; + numFormats++; + if ( numFormats > MAXFORMATS ) + FatalError( "Too many pixmap formats! Exiting\n" ); + } + } + if (!any_screens) + if (xf86ProbeFailed) + ErrorF("\n *** None of the configured devices were detected.***\n\n"); + else + ErrorF( + "\n *** A configured device found, but display modes could not be resolved.***\n\n"); + if (xf86ProbeOnly) + { + xf86VTSema = FALSE; + AbortDDX(); + fflush(stderr); + exit(0); + } + } + else { + /* + * serverGeneration != 1; some OSs have to do things here, too. + */ + xf86OpenConsole(); + } + + /* + * Install signal handler for unexpected signals + */ + if (!xf86Info.notrapSignals) + { + xf86Info.caughtSignal=FALSE; + signal(SIGSEGV,xf86SigHandler); + signal(SIGILL,xf86SigHandler); +#ifdef SIGEMT + signal(SIGEMT,xf86SigHandler); +#endif + signal(SIGFPE,xf86SigHandler); +#ifdef SIGBUS + signal(SIGBUS,xf86SigHandler); +#endif +#ifdef SIGSYS + signal(SIGSYS,xf86SigHandler); +#endif +#ifdef SIGXCPU + signal(SIGXCPU,xf86SigHandler); +#endif +#ifdef SIGXFSZ + signal(SIGXFSZ,xf86SigHandler); +#endif + } + + + /* + * Use the previous collected parts to setup pScreenInfo + */ + pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; + pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; + pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD; + pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER; + pScreenInfo->numPixmapFormats = numFormats; + for ( i=0; i < numFormats; i++ ) pScreenInfo->formats[i] = formats[i]; + + if (generation != serverGeneration) + { + xf86ScreenIndex = AllocateScreenPrivateIndex(); + generation = serverGeneration; + } + + + for ( i=0; + i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured; + i++ ) + { + /* + * On a server-reset, we have explicitely to remap all stuff ... + * (At startuptime this is implicitely done by probing the device + */ + if (serverGeneration != 1) + { + xf86Resetting = TRUE; + xf86Exiting = FALSE; +#ifdef HAS_USL_VTS + if (!xf86VTSema) + ioctl(xf86Info.consoleFd,VT_RELDISP,VT_ACKACQ); +#endif + xf86VTSema = TRUE; + (xf86Screens[i]->EnterLeaveVT)(ENTER, i); + xf86Resetting = FALSE; + } +#ifdef SCO + else { + /* + * Under SCO we must ack that we got the console at startup, + * I think this is the safest way to assure it + */ + static int once = 1; + if (once) { + once = 0; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + ErrorF("VT_ACKACQ failed"); + } + } +#endif /* SCO */ + scr_index = AddScreen(xf86Screens[i]->Init, argc, argv); + if (scr_index > -1) + { + screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr + = (pointer)xf86Screens[i]; + } + + /* + * Here we have to let the driver getting access of the VT. Note that + * this doesn't mean that the graphics board may access automatically + * the monitor. If the monitor is shared this is done in xf86CrossScreen! + */ + if (!xf86Info.sharedMonitor) (xf86Screens[i]->EnterLeaveMonitor)(ENTER); + } + +#ifndef AMOEBA + RegisterBlockAndWakeupHandlers(xf86Block, xf86Wakeup, (void *)0); +#endif +} + + +/* + * InitInput -- + * Initialize all supported input devices...what else is there + * besides pointer and keyboard? Two DeviceRec's are allocated and + * registered as the system pointer and keyboard devices. + */ + +void +InitInput(argc, argv) + int argc; + char **argv; +{ + xf86Info.vtRequestsPending = FALSE; + xf86Info.inputPending = FALSE; +#ifdef XTESTEXT1 + xtest_command_key = KEY_Begin + MIN_KEYCODE; +#endif /* XTESTEXT1 */ + + xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE); + xf86Info.pMouse = AddInputDevice(xf86Info.mouseDev->mseProc, TRUE); + RegisterKeyboardDevice((DevicePtr)xf86Info.pKeyboard); + RegisterPointerDevice((DevicePtr)xf86Info.pMouse); + +#ifdef XINPUT + (xf86Info.pMouse)->public.devicePrivate = xf86Info.mouseLocal; +#if 0 /* Is this needed?? */ + ((LocalDevicePtr) xf86Info.mouseLocal)->dev = xf86Info.pMouse; +#endif +#else + (xf86Info.pMouse)->public.devicePrivate = (pointer) xf86Info.mouseDev; +#endif + +#ifdef XINPUT + InitExtInput(); +#endif + + miRegisterPointerDevice(screenInfo.screens[0], (DevicePtr) xf86Info.pMouse); +#ifdef XINPUT + xf86XinputFinalizeInit(xf86Info.pMouse); + xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse); +#else + mieqInit (xf86Info.pKeyboard, xf86Info.pMouse); +#endif +} + +/* + * OsVendorInit -- + * OS/Vendor-specific initialisations. Called from OsInit(), which + * is called by dix before establishing the well known sockets. + */ + +extern Bool OsDelayInitColors; + +void +OsVendorInit() +{ +#ifdef SIGCHLD + signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */ +#endif +#ifdef USE_XF86_SERVERLOCK + extern void xf86LockServer(); + static Bool been_here = FALSE; + + if (!been_here) { + xf86LockServer(); + been_here = TRUE; + } +#endif + OsDelayInitColors = TRUE; +} + +#ifdef DPMSExtension +extern CARD16 DPMSPowerLevel; + +/* + * DPMSSet -- + * Device dependent DPMS mode setting hook. This is called whenever + * the DPMS mode is to be changed. + */ +void +DPMSSet(CARD16 level) +{ + int i; + + /* For each screen, set the power saver level */ + for (i = 0; i < screenInfo.numScreens; i++) { + (XF86SCRNINFO(screenInfo.screens[i])->DPMSSet)(level); + } + + DPMSPowerLevel = level; +} + +#if 0 +/* + * DPMSGet -- + * Device dependent DPMS mode getting hook. This returns the current + * DPMS mode, or -1 if DPMS is not supported. + * + * This should hook in to the appropriate driver-level function, which + * will be added to the ScrnInfoRec. + * + * NOTES: + * 1. the calling interface should be changed to specify which + * screen to check. + * 2. It isn't clear that this function is ever used. + */ +CARD16 +DPMSGet(CARD16 *level) +{ + int i; + + /* For each screen, set the power saver level */ + for (i = 0; i < screenInfo.numScreens; i++) { + ; + } +} +#endif + +/* + * DPMSSupported -- + * Return TRUE if any screen supports DPMS. + */ +Bool +DPMSSupported(void) +{ + int i; + + /* For each screen, check if DPMS is supported */ + for (i = 0; i < screenInfo.numScreens; i++) { + if (XF86SCRNINFO(screenInfo.screens[i])->DPMSSet != (void (*)())NoopDDA) + return TRUE; + } + return FALSE; +} +#endif /* DPMSExtension */ + +/* + * ddxGiveUp -- + * Device dependent cleanup. Called by by dix before normal server death. + * For SYSV386 we must switch the terminal back to normal mode. No error- + * checking here, since there should be restored as much as possible. + */ + +void +ddxGiveUp() +{ +#ifdef USE_XF86_SERVERLOCK + xf86UnlockServer(); +#endif + + xf86CloseConsole(); + + /* If an unexpected signal was caught, dump a core for debugging */ + if (xf86Info.caughtSignal) + abort(); +} + + + +/* + * AbortDDX -- + * DDX - specific abort routine. Called by AbortServer(). The attempt is + * made to restore all original setting of the displays. Also all devices + * are closed. + */ + +void +AbortDDX() +{ + int i; + +#if 0 + if (xf86Exiting) + return; +#endif + + xf86Exiting = TRUE; + + /* + * try to deinitialize all input devices + */ + if (xf86Info.pMouse) (xf86Info.mouseDev->mseProc)(xf86Info.pMouse, DEVICE_CLOSE); + if (xf86Info.pKeyboard) (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE); + + /* + * try to restore the original video state + */ +#ifdef HAS_USL_VTS + /* Need the sleep when starting X from within another X session */ + sleep(1); +#endif + if (xf86VTSema && xf86ScreensOpen) + for ( i=0; + i < xf86MaxScreens && xf86Screens[i] && xf86Screens[i]->configured; + i++ ) + (xf86Screens[i]->EnterLeaveVT)(LEAVE, i); + + /* + * This is needed for a abnormal server exit, since the normal exit stuff + * MUST also be performed (i.e. the vt must be left in a defined state) + */ + ddxGiveUp(); +} + +void +OsVendorFatalError() +{ + ErrorF("\nWhen reporting a problem related to a server crash, please send\n" + "the full server output, not just the last messages\n\n"); +} + +/* + * ddxProcessArgument -- + * Process device-dependent command line args. Returns 0 if argument is + * not device dependent, otherwise Count of number of elements of argv + * that are part of a device dependent commandline option. + */ + +/* ARGSUSED */ +int +ddxProcessArgument (argc, argv, i) + int argc; + char *argv[]; + int i; +{ + if (getuid() == 0 && !strcmp(argv[i], "-xf86config")) + { + if (!argv[i+1]) + return 0; + if (strlen(argv[i+1]) >= PATH_MAX) + FatalError("XF86Config path name too long\n"); + strcpy(xf86ConfigFile, argv[i+1]); + return 2; + } + if (!strcmp(argv[i],"-probeonly")) + { + xf86ProbeOnly = TRUE; + return 1; + } + if (!strcmp(argv[i],"-flipPixels")) + { + xf86FlipPixels = TRUE; + return 1; + } +#ifdef XF86VIDMODE + if (!strcmp(argv[i],"-disableVidMode")) + { + xf86VidModeEnabled = FALSE; + return 1; + } + if (!strcmp(argv[i],"-allowNonLocalXvidtune")) + { + xf86VidModeAllowNonLocal = TRUE; + return 1; + } +#endif +#ifdef XF86MISC + if (!strcmp(argv[i],"-disableModInDev")) + { + xf86MiscModInDevEnabled = FALSE; + return 1; + } + if (!strcmp(argv[i],"-allowNonLocalModInDev")) + { + xf86MiscModInDevAllowNonLocal = TRUE; + return 1; + } + if (!strcmp(argv[i],"-allowMouseOpenFail")) + { + xf86AllowMouseOpenFail = TRUE; + return 1; + } +#endif + if (!strcmp(argv[i],"-bestRefresh")) + { + xf86BestRefresh = TRUE; + return 1; + } +#ifdef DO_CHECK_BETA + if (!strcmp(argv[i],"-extendExpiry")) + { + extraDays = atoi(argv[i + 1]); + expKey = argv[i + 2]; + return 3; + } +#endif + if (!strcmp(argv[i],"-verbose")) + { + if (!xf86Verbose++) + xf86Verbose = 2; + return 1; + } + if (!strcmp(argv[i],"-quiet")) + { + xf86Verbose = 0; + return 1; + } + if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version")) + { + xf86PrintBanner(); + xf86PrintConfig(); + exit(0); + } + /* Notice the -fp flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-fp")) + { + xf86fpFlag = TRUE; + return 0; + } + /* Notice the -co flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-co")) + { + xf86coFlag = TRUE; + return 0; + } + /* Notice the -s flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-s")) + { + xf86sFlag = TRUE; + return 0; + } +#ifndef XF86MONOVGA + if (!strcmp(argv[i], "-bpp")) + { + int bpp; + if (++i >= argc) + return 0; + if (sscanf(argv[i], "%d", &bpp) == 1) + { + xf86bpp = bpp; + return 2; + } + else + { + ErrorF("Invalid bpp\n"); + return 0; + } + } + if (!strcmp(argv[i], "-weight")) + { + int red, green, blue; + if (++i >= argc) + return 0; + if (sscanf(argv[i], "%1d%1d%1d", &red, &green, &blue) == 3) + { + xf86weight.red = red; + xf86weight.green = green; + xf86weight.blue = blue; + return 2; + } + else + { + ErrorF("Invalid weighting\n"); + return 0; + } + } + if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") || + !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma")) + { + double gamma; + if (++i >= argc) + return 0; + if (sscanf(argv[i], "%lf", &gamma) == 1) { + if (gamma < 0.1 || gamma > 10) { + ErrorF("gamma out of range, only 0.1 < gamma_value < 10 is valid\n"); + return 0; + } + if (!strcmp(argv[i-1], "-gamma")) + xf86rGamma = xf86gGamma = xf86bGamma = 1.0 / gamma; + else if (!strcmp(argv[i-1], "-rgamma")) xf86rGamma = 1.0 / gamma; + else if (!strcmp(argv[i-1], "-ggamma")) xf86gGamma = 1.0 / gamma; + else if (!strcmp(argv[i-1], "-bgamma")) xf86bGamma = 1.0 / gamma; + return 2; + } + } +#endif /* XF86MONOVGA */ + return xf86ProcessArgument(argc, argv, i); +} + + +/* + * ddxUseMsg -- + * Print out correct use of device dependent commandline options. + * Maybe the user now knows what really to do ... + */ + +void +ddxUseMsg() +{ + ErrorF("\n"); + ErrorF("\n"); + ErrorF("Device Dependent Usage\n"); + if (getuid() == 0) + ErrorF("-xf86config file specify a configuration file\n"); + ErrorF("-probeonly probe for devices, then exit\n"); + ErrorF("-verbose verbose startup messages\n"); + ErrorF("-quiet minimal startup messages\n"); +#ifndef XF86MONOVGA + ErrorF("-bpp n set number of bits per pixel. Default: 8\n"); + ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n"); + ErrorF("-rgamma f set gamma value for red phase\n"); + ErrorF("-ggamma f set gamma value for green phase\n"); + ErrorF("-bgamma f set gamma value for blue phase\n"); + ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n"); +#endif /* XF86MONOVGA */ + ErrorF("-flipPixels swap default black/white Pixel values\n"); +#ifdef XF86VIDMODE + ErrorF("-disableVidMode disable mode adjustments with xvidtune\n"); + ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n"); +#endif +#ifdef XF86MISC + ErrorF("-disableModInDev disable dynamic modification of input device settings\n"); + ErrorF("-allowNonLocalModInDev allow changes to keyboard and mouse settings\n"); + ErrorF(" from non-local clients\n"); + ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); +#endif + ErrorF("-bestRefresh Chose modes with the best refresh rate\n"); + ErrorF( + "-showconfig show which drivers are included in the server\n"); + xf86UseMsg(); + ErrorF("\n"); +} + + +#ifndef OSNAME +#define OSNAME "unknown" +#endif +#ifndef OSVENDOR +#define OSVENDOR "" +#endif + +static void +xf86PrintBanner() +{ + ErrorF("\nXFree86 Version%s/ X Window System\n",XF86_VERSION); + ErrorF("(protocol Version %d, revision %d, vendor release %d)\n", + X_PROTOCOL, X_PROTOCOL_REVISION, VENDOR_RELEASE ); + ErrorF("Release Date: %s\n", XF86_DATE); + ErrorF("\tIf the server is older than 6-12 months, or if your card is " + "newer\n" + "\tthan the above date, look for a newer version before " + "reporting\n" + "\tproblems. (see http://www.XFree86.Org/FAQ)\n"); + ErrorF("Operating System: %s %s\n", OSNAME, OSVENDOR); +} + +static void +xf86PrintConfig() +{ + int i; + + ErrorF("Configured drivers:\n"); + for (i = 0; i < xf86MaxScreens; i++) + if (xf86Screens[i]) + (xf86Screens[i]->PrintIdent)(); +} + diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c new file mode 100644 index 000000000..6fddb5e89 --- /dev/null +++ b/hw/xfree86/common/xf86Io.c @@ -0,0 +1,542 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.28.2.5 1998/02/24 19:05:55 hohndel Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86Io.c,v 1.3 2000/08/17 19:50:29 cpqbld Exp $ */ +/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86_Config.h" + +#ifdef XINPUT +#include "xf86Xinput.h" +#endif + +#ifdef XKB +#include <X11/extensions/XKB.h> +#include <X11/extensions/XKBstr.h> +#include <X11/extensions/XKBsrv.h> +#endif + +extern KeybdCtrl defaultKeyboardControl; + +unsigned int xf86InitialCaps = 0; +unsigned int xf86InitialNum = 0; +unsigned int xf86InitialScroll = 0; + +#include "atKeynames.h" + +extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords, + unsigned long start, unsigned long stop, + ScreenPtr pScreen); + +/* + * xf86KbdBell -- + * Ring the terminal/keyboard bell for an amount of time proportional to + * "loudness". + */ + +void +xf86KbdBell(percent, pKeyboard, ctrl, unused) + int percent; /* Percentage of full volume */ + DeviceIntPtr pKeyboard; /* Keyboard to ring */ + pointer ctrl; + int unused; +{ + xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration); +} + +#ifdef AMOEBA +#define LED_CAP IOP_LED_CAP +#define LED_NUM IOP_LED_NUM +#define LED_SCR IOP_LED_SCROLL +#endif + +#ifdef MINIX +#define LED_CAP KBD_LEDS_CAPS +#define LED_NUM KBD_LEDS_NUM +#define LED_SCR KBD_LEDS_SCROLL +#endif + +void +xf86KbdLeds () +{ + int leds = 0; +#ifdef XKB + if (!noXkbExtension) { + XkbEventCauseRec cause; + XkbSetCauseUnknown(&cause); + XkbUpdateIndicators((DeviceIntPtr)xf86Info.pKeyboard, + XkbAllIndicatorsMask, False, NULL, &cause); + return; + } +#endif +#ifdef LED_CAP + if (xf86Info.capsLock && !(xf86Info.xleds & XLED1)) + leds |= LED_CAP; + + if (xf86Info.numLock && !(xf86Info.xleds & XLED2)) + leds |= LED_NUM; + + if ((xf86Info.scrollLock || + xf86Info.modeSwitchLock || + xf86Info.composeLock) && + !(xf86Info.xleds & XLED3)) + leds |= LED_SCR; + + if ((xf86Info.leds & xf86Info.xleds) & XLED1) leds |= LED_CAP; + if ((xf86Info.leds & xf86Info.xleds) & XLED2) leds |= LED_NUM; + if ((xf86Info.leds & xf86Info.xleds) & XLED3) leds |= LED_SCR; + + xf86SetKbdLeds(leds); +#endif /* LED_CAP */ +} + +/* + * xf86KbdCtrl -- + * Alter some of the keyboard control parameters. All special protocol + * values are handled by dix (ProgChangeKeyboardControl) + */ + +void +xf86KbdCtrl (pKeyboard, ctrl) + DevicePtr pKeyboard; /* Keyboard to alter */ + KeybdCtrl *ctrl; +{ + xf86Info.bell_pitch = ctrl->bell_pitch; + xf86Info.bell_duration = ctrl->bell_duration; + xf86Info.autoRepeat = ctrl->autoRepeat; + xf86Info.leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR)); + + xf86Info.composeLock = (ctrl->leds & XCOMP) ? TRUE : FALSE; + + xf86KbdLeds(); +} + +/* + * xf86InitKBD -- + * Reinitialize the keyboard. Only set Lockkeys accrding to ours leds. + * Depress all other keys. + */ + +void +xf86InitKBD(init) +Bool init; +{ + char leds = 0, rad; + unsigned int i; + xEvent kevent; + DeviceIntPtr pKeyboard = xf86Info.pKeyboard; + KeyClassRec *keyc = xf86Info.pKeyboard->key; + KeySym *map = keyc->curKeySyms.map; + +#ifndef MACH386 + kevent.u.keyButtonPointer.time = GetTimeInMillis(); + kevent.u.keyButtonPointer.rootX = 0; + kevent.u.keyButtonPointer.rootY = 0; + + /* + * Hmm... here is the biggest hack of every time ! + * It may be possible that a switch-vt procedure has finished BEFORE + * you released all keys neccessary to do this. That peculiar behavior + * can fool the X-server pretty much, cause it assumes that some keys + * were not released. TWM may stuck alsmost completly.... + * OK, what we are doing here is after returning from the vt-switch + * exeplicitely unrelease all keyboard keys before the input-devices + * are reenabled. + */ + for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; + i < keyc->curKeySyms.maxKeyCode; + i++, map += keyc->curKeySyms.mapWidth) + if (KeyPressed(i)) + { + switch (*map) { + /* Don't release the lock keys */ + case XK_Caps_Lock: + case XK_Shift_Lock: + case XK_Num_Lock: + case XK_Scroll_Lock: + case XK_Kana_Lock: + break; + default: + kevent.u.u.detail = i; + kevent.u.u.type = KeyRelease; + (* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1); + } + } +#endif /* MACH386 */ + + xf86Info.scanPrefix = 0; + + if (init) + { + /* + * we must deal here with the fact, that on some cases the numlock or + * capslock key are enabled BEFORE the server is started up. So look + * here at the state on the according LEDS to determine whether a + * lock-key is already set. + */ + + xf86Info.capsLock = FALSE; + xf86Info.numLock = FALSE; + xf86Info.scrollLock = FALSE; + xf86Info.modeSwitchLock = FALSE; + xf86Info.composeLock = FALSE; + +#ifdef LED_CAP +#ifdef INHERIT_LOCK_STATE + leds = xf86Info.leds; + + for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; + i < keyc->curKeySyms.maxKeyCode; + i++, map += keyc->curKeySyms.mapWidth) + + switch(*map) { + + case XK_Caps_Lock: + case XK_Shift_Lock: + if (leds & LED_CAP) + { + xf86InitialCaps = i; + xf86Info.capsLock = TRUE; + } + break; + + case XK_Num_Lock: + if (leds & LED_NUM) + { + xf86InitialNum = i; + xf86Info.numLock = TRUE; + } + break; + + case XK_Scroll_Lock: + case XK_Kana_Lock: + if (leds & LED_SCR) + { + xf86InitialScroll = i; + xf86Info.scrollLock = TRUE; + } + break; + } +#endif /* INHERIT_LOCK_STATE */ + xf86SetKbdLeds(leds); +#endif /* LED_CAP */ + + if (xf86Info.kbdDelay <= 375) rad = 0x00; + else if (xf86Info.kbdDelay <= 625) rad = 0x20; + else if (xf86Info.kbdDelay <= 875) rad = 0x40; + else rad = 0x60; + + if (xf86Info.kbdRate <= 2) rad |= 0x1F; + else if (xf86Info.kbdRate >= 30) rad |= 0x00; + else rad |= ((58 / xf86Info.kbdRate) - 2); + + xf86SetKbdRepeat(rad); + } +} + +/* + * xf86KbdProc -- + * Handle the initialization, etc. of a keyboard. + */ + +int +xf86KbdProc (pKeyboard, what) + DeviceIntPtr pKeyboard; /* Keyboard to manipulate */ + int what; /* What to do to it */ +{ + KeySymsRec keySyms; + CARD8 modMap[MAP_LENGTH]; + int kbdFd; + + switch (what) { + + case DEVICE_INIT: + /* + * First open and find the current state of the keyboard. + */ + + xf86KbdInit(); + + xf86KbdGetMapping(&keySyms, modMap); + + +#ifndef XKB + defaultKeyboardControl.leds = xf86GetKbdLeds(); +#else + defaultKeyboardControl.leds = 0; +#endif + + /* + * Perform final initialization of the system private keyboard + * structure and fill in various slots in the device record + * itself which couldn't be filled in before. + */ + + pKeyboard->public.on = FALSE; + +#ifdef XKB + if (noXkbExtension) { +#endif + InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard, + &keySyms, + modMap, + xf86KbdBell, + (KbdCtrlProcPtr)xf86KbdCtrl); +#ifdef XKB + } else { + XkbComponentNamesRec names; + if (XkbInitialMap) { + if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL) + xf86Info.xkbkeymap++; + else + xf86Info.xkbkeymap = XkbInitialMap; + } + if (xf86Info.xkbkeymap) { + names.keymap = xf86Info.xkbkeymap; + names.keycodes = NULL; + names.types = NULL; + names.compat = NULL; + names.symbols = NULL; + names.geometry = NULL; + } else { + names.keymap = NULL; + names.keycodes = xf86Info.xkbkeycodes; + names.types = xf86Info.xkbtypes; + names.compat = xf86Info.xkbcompat; + names.symbols = xf86Info.xkbsymbols; + names.geometry = xf86Info.xkbgeometry; + } + if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified) + && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) { + xf86Info.xkbrules = NULL; + } + XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel, + xf86Info.xkblayout, xf86Info.xkbvariant, + xf86Info.xkboptions); + XkbInitKeyboardDeviceStruct(pKeyboard, + &names, + &keySyms, + modMap, + xf86KbdBell, + (KbdCtrlProcPtr)xf86KbdCtrl); + } +#endif + + xf86InitKBD(TRUE); + break; + + case DEVICE_ON: + /* + * Set the keyboard into "direct" mode and turn on + * event translation. + */ + + kbdFd = xf86KbdOn(); + /* + * Discard any pending input after a VT switch to prevent the server + * passing on parts of the VT switch sequence. + */ + sleep(1); + if (kbdFd != -1) { + char buf[16]; + read(kbdFd, buf, 16); + } + +#ifndef __EMX__ /* Under EMX, keyboard cannot be select()'ed */ + if (kbdFd != -1) + AddEnabledDevice(kbdFd); +#endif /* __EMX__ */ + + pKeyboard->public.on = TRUE; + xf86InitKBD(FALSE); + break; + + case DEVICE_CLOSE: + case DEVICE_OFF: + /* + * Restore original keyboard directness and translation. + */ + + kbdFd = xf86KbdOff(); + + if (kbdFd != -1) + RemoveEnabledDevice(kbdFd); + + pKeyboard->public.on = FALSE; + break; + + } + return (Success); +} + +/* + * xf86MseCtrl -- + * Alter the control parameters for the mouse. Note that all special + * protocol values are handled by dix. + */ + +void +xf86MseCtrl(pPointer, ctrl) + DevicePtr pPointer; + PtrCtrl *ctrl; +{ + MouseDevPtr mouse = MOUSE_DEV((DeviceIntPtr) pPointer); + + mouse->num = ctrl->num; + mouse->den = ctrl->den; + mouse->threshold = ctrl->threshold; +} + +/* + * xf86MseProc -- + * Handle the initialization, etc. of a mouse + */ + +int +xf86MseProc(pPointer, what) + DeviceIntPtr pPointer; + int what; +{ + MouseDevPtr mouse = MOUSE_DEV(pPointer); + + mouse->device = pPointer; + + return xf86MseProcAux(pPointer, what, mouse, NULL, + (PtrCtrlProcPtr)xf86MseCtrl); +} + +int +xf86MseProcAux(pPointer, what, mouse, fd, ctrl) + DeviceIntPtr pPointer; + int what; + MouseDevPtr mouse; + int *fd; + PtrCtrlProcPtr ctrl; +{ + unsigned char map[MSE_MAXBUTTONS + 1]; + int nbuttons; + int mousefd; + + switch (what) + { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + /* + * [KAZU-241097] We don't know exactly how many buttons the + * device has... + */ + for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons) + map[nbuttons + 1] = nbuttons + 1; + + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + min(mouse->buttons, MSE_MAXBUTTONS), + miPointerGetMotionEvents, + ctrl, + miPointerGetMotionBufferSize()); + + xf86MouseInit(mouse); + + break; + + case DEVICE_ON: + + mousefd = xf86MouseOn(mouse); + + if (fd) + *fd = mousefd; + + if (mousefd != -1) { + if (mousefd == -2) { + if (fd) + *fd = -1; + } else { + if (mouse->mseType == P_PS2) + write(mousefd, "\364", 1); + + AddEnabledDevice(mousefd); + } + mouse->lastButtons = 0; + mouse->emulateState = 0; + pPointer->public.on = TRUE; + } else { + return !Success; + } + + break; + + case DEVICE_OFF: + case DEVICE_CLOSE: + + mousefd = xf86MouseOff(mouse, what == DEVICE_CLOSE); + + if (mousefd != -1) + RemoveEnabledDevice(mousefd); + + pPointer->public.on = FALSE; + usleep(300000); + break; + } + return Success; +} + +/* + * xf86MseEvents -- + * Read the new events from the device, and pass them to the eventhandler. + * This should is not used if there is only an OS_MOUSE driver. + */ +#ifndef OSMOUSE_ONLY +void +xf86MseEvents(mouse) + MouseDevPtr mouse; +{ + xf86MouseEvents(mouse); +} +#endif + +#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__) +/* + * These are getting tossed in here until I can think of where + * they really belong + */ +CARD32 +GetTimeInMillis() +{ + struct timeval tp; + + gettimeofday(&tp, 0); + return(tp.tv_sec * 1000) + (tp.tv_usec / 1000); +} +#endif /* !AMOEBA && !(sun || SVR4) && !MINIX */ + diff --git a/hw/xfree86/common/xf86Kbd.c b/hw/xfree86/common/xf86Kbd.c new file mode 100644 index 000000000..f263937a2 --- /dev/null +++ b/hw/xfree86/common/xf86Kbd.c @@ -0,0 +1,407 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.14 1997/01/05 11:58:08 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86Kbd.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "atKeynames.h" +#include "xf86_Config.h" + +#include "xf86Keymap.h" + +#define KD_GET_ENTRY(i,n) \ + eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]] + +/* + * NOTE: Not all possible remappable symbols are remapped. There are two main + * reasons: + * a) The mapping between scancode and SYSV/386 - symboltable + * is inconsistent between different versions and has some + * BIG mistakes. + * b) In X-Windows there is a difference between numpad-keys + * and normal keys. SYSV/386 uses for both kinds of keys + * the same symbol. + * + * Thus only the alpha keypad and the function keys are translated. + * Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt. + */ + +static unsigned char remap[128] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */ + 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; + +static KeySym eascii_to_x[512] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex, + XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla, + XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis, + XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring, + XK_Eacute, XK_ae, XK_AE, XK_ocircumflex, + XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave, + XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent, + XK_sterling, XK_yen, XK_paragraph, XK_section, + XK_aacute, XK_iacute, XK_oacute, XK_uacute, + XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine, + XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf, + XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi, + XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau, + XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta, + XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection, + XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal, + XK_topintegral, XK_botintegral, XK_division, XK_similarequal, + XK_degree, NoSymbol, NoSymbol, XK_radical, + XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol, + + /* + * special marked entries (256 + x) + */ + + NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R, + XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L, + NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R, + XK_Control_L, XK_Control_R, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_F1, + XK_F2, XK_F3, XK_F4, XK_F5, + XK_F6, XK_F7, XK_F8, XK_F9, + XK_F10, XK_F11, XK_F12, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + }; + + +/* + * LegalModifier -- + * determine whether a key is a legal modifier key, i.e send a + * press/release sequence. + */ + +/*ARGSUSED*/ +Bool +LegalModifier(key, pDev) + unsigned int key; + DevicePtr pDev; +{ + return (TRUE); +} + + + +/* + * xf86KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +void +xf86KbdGetMapping (pKeySyms, pModMap) + KeySymsPtr pKeySyms; + CARD8 *pModMap; +{ + KeySym *k; +#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) + keymap_t keymap; +#endif /* !Lynx && !AMOEBA && !MINIX && !__OSF__ && !__EMX__ */ + char type; + int i, j; + KeySym *pMap; + +#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) + xf86Info.kbdType = + ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101; + if (xf86Info.kbdType == KB_84) + pMap = map84; + else + pMap = map; +#else + xf86Info.kbdType = 0; + pMap = map; +#endif + +#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) + /* + * use the keymap, which can be gotten from our oringinal vt??. + * ( ttymap(1) !!!! ) + */ + if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) { + for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++) + + if (remap[i]) { + + k = pMap + (remap[i] << 2); + + k[0] = KD_GET_ENTRY(i,0); /* non-shifed */ + k[1] = KD_GET_ENTRY(i,1); /* shifted */ + k[2] = KD_GET_ENTRY(i,4); /* alt */ + k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */ + + if (k[3] == k[2]) k[3] = NoSymbol; + if (k[2] == k[1]) k[2] = NoSymbol; + if (k[1] == k[0]) k[1] = NoSymbol; + if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol; + } + } +#endif /* !Lynx && !AMOEBA && !MINIX && !__OSF__ && !__EMX__ */ + + /* + * Apply the special key mapping specified in XF86Config + */ + for (k = pMap, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) { + switch (k[0]) { + case XK_Alt_L: + j = K_INDEX_LEFTALT; + break; + case XK_Alt_R: + j = K_INDEX_RIGHTALT; + break; + case XK_Scroll_Lock: + j = K_INDEX_SCROLLLOCK; + break; + case XK_Control_R: + j = K_INDEX_RIGHTCTL; + break; + default: + j = -1; + } + if (j >= 0) + switch (xf86Info.specialKeyMap[j]) { + case KM_META: + if (k[0] == XK_Alt_R) + k[1] = XK_Meta_R; + else { + k[0] = XK_Alt_L; + k[1] = XK_Meta_L; + } + break; + case KM_COMPOSE: + k[0] = XK_Multi_key; + break; + case KM_MODESHIFT: + k[0] = XK_Mode_switch; + k[1] = NoSymbol; + break; + case KM_MODELOCK: + k[0] = XK_Mode_switch; + k[1] = XF86XK_ModeLock; + break; + case KM_SCROLLLOCK: + k[0] = XK_Scroll_Lock; + break; + case KM_CONTROL: + k[0] = XK_Control_R; + break; + } + } + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = pMap, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + +#if !defined(Lynx) && !defined(AMOEBA) && !defined(MINIX) && !defined(__OSF__) && !defined(__EMX__) && !defined(__mips__) + xf86Info.kbdType = + ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101; +#else +/* OS/2 sets the keyboard type during xf86OpenKbd */ +#ifndef __EMX__ + xf86Info.kbdType = 0; +#endif +#endif + + + pKeySyms->map = pMap; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + if (xf86Info.serverNumLock) + pKeySyms->maxKeyCode = MAX_KEYCODE; + else + pKeySyms->maxKeyCode = MAX_STD_KEYCODE; +} diff --git a/hw/xfree86/common/xf86KbdBSD.c b/hw/xfree86/common/xf86KbdBSD.c new file mode 100644 index 000000000..bf880dd68 --- /dev/null +++ b/hw/xfree86/common/xf86KbdBSD.c @@ -0,0 +1,687 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.10 1996/12/23 06:43:30 dawes Exp $ */ +/* + * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk) + * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * and from xf86KbdCODrv.c by Holger Veit + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* $Xorg: xf86KbdBSD.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "atKeynames.h" +#include "xf86_Config.h" +#include "coKeynames.h" +#include "xf86Keymap.h" + +#define KD_GET_ENTRY(i,n) \ + eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]] + +#ifndef __bsdi__ +static KeySym coGetKeysym(); +#endif + +#ifndef PC98 +static unsigned char remap[128] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */ + 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; +#else /* PC98 */ +static unsigned char remap[128] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0, 0, 0, /* 0x30 - 0x37 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x38 - 0x3f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0x52, 0x53, 0x54, 0x55, 0x56, 0, /* 0x50 - 0x57 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60 - 0x67 */ + 0x68, 0x69, 0x6a, 0x6b, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0x70, 0x71, 0x72, 0x73, 0x74, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; +#endif /* PC98 */ + + +/* This table assumes the ibm code page 437 coding for characters + * > 0x80. They are returned in this form by PCVT */ +static KeySym eascii_to_x[512] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex, + XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla, + XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis, + XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring, + XK_Eacute, XK_ae, XK_AE, XK_ocircumflex, + XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave, + XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent, + XK_sterling, XK_yen, XK_paragraph, XK_section, + XK_aacute, XK_iacute, XK_oacute, XK_uacute, + XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine, + XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf, + XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi, + XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau, + XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta, + XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection, + XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal, + XK_topintegral, XK_botintegral, XK_division, XK_similarequal, + XK_degree, NoSymbol, NoSymbol, XK_radical, + XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol, + + /* + * special marked entries (256 + x) + */ + + NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R, + XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L, + NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R, + XK_Control_L, XK_Control_R, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_F1, + XK_F2, XK_F3, XK_F4, XK_F5, + XK_F6, XK_F7, XK_F8, XK_F9, + XK_F10, XK_F11, XK_F12, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + }; + +#ifdef __OpenBSD__ +/* don't mark AltR and CtrlR for remapping, since they + * cannot be remapped by pccons */ +static unsigned char pccons_remap[128] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */ + 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; + +/* This table assumes an iso8859_1 encoding for the characters + * > 80, as returned by pccons */ +static KeySym latin1_to_x[256] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling, + XK_currency, XK_yen, XK_brokenbar, XK_section, + XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft, + XK_notsign, XK_hyphen, XK_registered, XK_macron, + XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior, + XK_acute, XK_mu, XK_paragraph, XK_periodcentered, + XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright, + XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown, + XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde, + XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla, + XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis, + XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis, + XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute, + XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply, + XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex, + XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp, + XK_agrave, XK_aacute, XK_acircumflex, XK_atilde, + XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla, + XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis, + XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis, + XK_eth, XK_ntilde, XK_ograve, XK_oacute, + XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division, + XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex, + XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis + }; +#endif +/* + * LegalModifier -- + * determine whether a key is a legal modifier key, i.e send a + * press/release sequence. + */ + +/*ARGSUSED*/ +Bool +LegalModifier(key, pDev) + unsigned int key; + DevicePtr pDev; +{ + return (TRUE); +} + +/* + * xf86KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +void +xf86KbdGetMapping (pKeySyms, pModMap) + KeySymsPtr pKeySyms; + CARD8 *pModMap; +{ + KeySym *k; + char type; + int i, j; + +#ifndef __bsdi__ + switch (xf86Info.consType) { + +#ifdef PCCONS_SUPPORT + case PCCONS: +#if defined(__OpenBSD__) + /* + * on OpenBSD, the pccons keymap is programmable, too + */ + { + pccons_keymap_t keymap[KB_NUM_KEYS]; + if (ioctl(xf86Info.consoleFd, CONSOLE_GET_KEYMAP, &keymap) != -1) { + for (i = 0; i < KB_NUM_KEYS; i++) + if (pccons_remap[i]) { + k = map + (pccons_remap[i] << 2); + switch (keymap[i].type) { + case KB_ASCII: + /* For ASCII keys, there is only one char in the keymap */ + k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]]; + k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]]; + k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]]; + k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]]; + break; + case KB_SCROLL: + k[0] = XK_Scroll_Lock; + goto special; + case KB_NUM: + k[0] = XK_Num_Lock; + goto special; + case KB_CAPS: + k[0] = XK_Caps_Lock; + goto special; + case KB_SHIFT: + switch (keymap[i].unshift[0]) { + case 1: + /* left shift */ + k[0] = XK_Shift_L; + break; + case 2: + /* right shift */ + k[0] = XK_Shift_R; + break; + default: + k[0] = NoSymbol; + } + goto special; + case KB_CTL: + k[0] = XK_Control_L; + goto special; + case KB_ALT: + k[0] = XK_Alt_L; + goto special; + case KB_FUNC: + switch (keymap[i].unshift[2]) { + case 'M': + k[0] = XK_F1; + break; + case 'N': + k[0] = XK_F2; + break; + case 'O': + k[0] = XK_F3; + break; + case 'P': + k[0] = XK_F4; + break; + case 'Q': + k[0] = XK_F5; + break; + case 'R': + k[0] = XK_F6; + break; + case 'S': + k[0] = XK_F7; + break; + case 'T': + k[0] = XK_F8; + break; + case 'U': + k[0] = XK_F9; + break; + case 'V': + k[0] = XK_F10; + break; + case 'W': + k[0] = XK_F11; + break; + case 'X': + k[0] = XK_F12; + break; + default: + k[0] = NoSymbol; + break; + } + goto special; + default: + k[0] = NoSymbol; + special: + k[1] = k[2] = k[3] = NoSymbol; + } + } + } else { + ErrorF("Can't read pccons keymap\n"); + } + } +#endif /* __OpenBSD__ */ + break; +#endif + +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + { + keymap_t keymap; + + if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) { + for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++) +#ifdef PC98 + if (remap[i] || i == 0) { +#else + if (remap[i]) { +#endif + k = map + (remap[i] << 2); + k[0] = KD_GET_ENTRY(i,0); /* non-shifed */ + k[1] = KD_GET_ENTRY(i,1); /* shifted */ + k[2] = KD_GET_ENTRY(i,4); /* alt */ + k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */ + if (k[3] == k[2]) k[3] = NoSymbol; + if (k[2] == k[1]) k[2] = NoSymbol; + if (k[1] == k[0]) k[1] = NoSymbol; + if (k[0] == k[2] && k[1] == k[3]) + k[2] = k[3] = NoSymbol; + } + } + } + break; +#endif /* SYSCONS || PCVT */ + +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + for (i=1; i<= 128; i++) { + struct kbd_ovlkey cokeymap; + struct oldkbd_ovlkey ocokeymap; + KeySym coGetKeysym(); + + if (xf86Info.consType == CODRV011) { + ocokeymap.keynum = i; + if (ioctl(xf86Info.consoleFd, OLDKBDGCKEY, &ocokeymap) < 0) + break; /* Don't try again if it fails once */ + if ((ocokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */ + k = map + (xf86CodrvMap[i] << 2); + k[0] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.unshift,k[0]); + k[1] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.shift,k[1]); + k[2] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.altgr,k[2]); + k[3] = NoSymbol; + } + } else { + cokeymap.keynum = i; + if (ioctl(xf86Info.consoleFd, KBDGCKEY, &cokeymap) < 0) + break; /* Don't try again if it fails once */ + if ((cokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */ + k = map + (xf86CodrvMap[i] << 2); + k[0] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.unshift,k[0]); + k[1] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.shift,k[1]); + k[2] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.altgr,k[2]); + k[3] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.shiftaltgr,k[3]); + } + } + if ((cokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */ + if (k[3] == k[2]) k[3] = NoSymbol; + if (k[2] == k[1]) k[2] = NoSymbol; + if (k[1] == k[0]) k[1] = NoSymbol; + if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol; + } + } + break; +#endif /* CODRV */ + } +#endif /* !bsdi */ + + /* + * Apply the special key mapping specified in XF86Config + */ + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) { + switch (k[0]) { + case XK_Alt_L: + j = K_INDEX_LEFTALT; + break; + case XK_Alt_R: + j = K_INDEX_RIGHTALT; + break; + case XK_Scroll_Lock: + j = K_INDEX_SCROLLLOCK; + break; + case XK_Control_R: + j = K_INDEX_RIGHTCTL; + break; + default: + j = -1; + } + if (j >= 0) + switch (xf86Info.specialKeyMap[j]) { + case KM_META: + if (k[0] == XK_Alt_R) + k[1] = XK_Meta_R; + else { + k[0] = XK_Alt_L; + k[1] = XK_Meta_L; + } + break; + case KM_COMPOSE: + k[0] = XK_Multi_key; + break; + case KM_MODESHIFT: + k[0] = XK_Mode_switch; + k[1] = NoSymbol; + break; + case KM_MODELOCK: + k[0] = XK_Mode_switch; + k[1] = XF86XK_ModeLock; + break; + case KM_SCROLLLOCK: + k[0] = XK_Scroll_Lock; + break; + case KM_CONTROL: + k[0] = XK_Control_R; + break; + } + } + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + + xf86Info.kbdType = 0; + + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + if (xf86Info.serverNumLock) + pKeySyms->maxKeyCode = MAX_KEYCODE; + else + pKeySyms->maxKeyCode = MAX_STD_KEYCODE; + +} + +#ifdef CODRV_SUPPORT +/* Converts a CoDriver ASCII+Special combination into a KeySym + */ +static KeySym +coGetKeysym(typ,str,old) + int typ; + CARD8 *str; + KeySym old; +{ + if (strlen((char *)str) > 1) return old; + switch (typ & KBD_MASK) { + case KBD_NONE: + return NoSymbol; + case KBD_SHIFT: + if (old==XK_Shift_L || old==XK_Shift_R) return old; + else return XK_Shift_L; + case KBD_NUM: + return XK_Num_Lock; + case KBD_CTL: + if (old==XK_Control_L || old==XK_Control_R) return old; + else return XK_Control_L; + case KBD_ALTGR: + return XK_Mode_switch; + case KBD_META: + if (old==XK_Alt_L || old==XK_Alt_R) return old; + else return XK_Alt_L; + case KBD_SHFTLOCK: + case KBD_CAPS: + return XK_Caps_Lock; + case KBD_SCROLL: + return XK_Scroll_Lock; + case KBD_BREAK: + return XK_Break; + default: + case KBD_KP: /* there are few good reasons to overload + * F Keys and KP Keys, so we ignore any attempt + * at all + */ + return old; + case KBD_ASCII: + return *str; + } +} +#endif diff --git a/hw/xfree86/common/xf86KbdLnx.c b/hw/xfree86/common/xf86KbdLnx.c new file mode 100644 index 000000000..094044b30 --- /dev/null +++ b/hw/xfree86/common/xf86KbdLnx.c @@ -0,0 +1,697 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.12 1996/12/23 06:43:31 dawes Exp $ */ +/* + * Linux version of keymapping setup. The kernel (since 0.99.14) has support + * for fully remapping the keyboard, but there are some differences between + * the Linux map and the SVR4 map (esp. in the extended keycodes). We also + * remove the restriction on what keycodes can be remapped. + * Orest Zborowski. + */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86KbdLnx.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "atKeynames.h" +#include "xf86_Config.h" + +#include "xf86Keymap.h" +#include "DECkeysym.h" + +/* + * LegalModifier -- + * determine whether a key is a legal modifier key, i.e send a + * press/release sequence. + */ + +/*ARGSUSED*/ +Bool +LegalModifier(unsigned int key, DevicePtr pDev) +{ + return (TRUE); +} + +/* + * xf86KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +static void readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap); + +void +xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KeySym *k; + char type; + int i, j; + + readKernelMapping(pKeySyms, pModMap); + + /* + * Apply the special key mapping specified in XF86Config + */ + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) { + switch (k[0]) { + case XK_Alt_L: + j = K_INDEX_LEFTALT; + break; + case XK_Alt_R: + j = K_INDEX_RIGHTALT; + break; + case XK_Scroll_Lock: + j = K_INDEX_SCROLLLOCK; + break; + case XK_Control_R: + j = K_INDEX_RIGHTCTL; + break; + default: + j = -1; + } + if (j >= 0) + switch (xf86Info.specialKeyMap[j]) { + case KM_META: + if (k[0] == XK_Alt_R) + k[1] = XK_Meta_R; + else { + k[0] = XK_Alt_L; + k[1] = XK_Meta_L; + } + break; + case KM_COMPOSE: + k[0] = XK_Multi_key; + break; + case KM_MODESHIFT: + k[0] = XK_Mode_switch; + k[1] = NoSymbol; + break; + case KM_MODELOCK: + k[0] = XK_Mode_switch; + k[1] = XF86XK_ModeLock; + break; + case KM_SCROLLLOCK: + k[0] = XK_Scroll_Lock; + break; + case KM_CONTROL: + k[0] = XK_Control_R; + break; + } + } + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + + xf86Info.kbdType = + ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101; + + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + if (xf86Info.serverNumLock) + pKeySyms->maxKeyCode = MAX_KEYCODE; + else + pKeySyms->maxKeyCode = MAX_STD_KEYCODE; + +} + +#include <linux/keyboard.h> + +static KeySym linux_to_x[256] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling, + XK_currency, XK_yen, XK_brokenbar, XK_section, + XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft, + XK_notsign, XK_hyphen, XK_registered, XK_macron, + XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior, + XK_acute, XK_mu, XK_paragraph, XK_periodcentered, + XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright, + XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown, + XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde, + XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla, + XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis, + XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis, + XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute, + XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply, + XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex, + XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp, + XK_agrave, XK_aacute, XK_acircumflex, XK_atilde, + XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla, + XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis, + XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis, + XK_eth, XK_ntilde, XK_ograve, XK_oacute, + XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division, + XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex, + XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis +}; + +#ifndef ASSUME_CUSTOM_KEYCODES + +/* + * Maps the AT keycodes to Linux keycodes + */ +static unsigned char at2lnx[] = +{ + 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */ + 0x03, /* KEY_2 */ 0x04, /* KEY_3 */ + 0x05, /* KEY_4 */ 0x06, /* KEY_5 */ + 0x07, /* KEY_6 */ 0x08, /* KEY_7 */ + 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */ + 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */ + 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */ + 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */ + 0x11, /* KEY_W */ 0x12, /* KEY_E */ + 0x13, /* KEY_R */ 0x14, /* KEY_T */ + 0x15, /* KEY_Y */ 0x16, /* KEY_U */ + 0x17, /* KEY_I */ 0x18, /* KEY_O */ + 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */ + 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */ + 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */ + 0x1f, /* KEY_S */ 0x20, /* KEY_D */ + 0x21, /* KEY_F */ 0x22, /* KEY_G */ + 0x23, /* KEY_H */ 0x24, /* KEY_J */ + 0x25, /* KEY_K */ 0x26, /* KEY_L */ + 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */ + 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */ + 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */ + 0x2d, /* KEY_X */ 0x2e, /* KEY_C */ + 0x2f, /* KEY_V */ 0x30, /* KEY_B */ + 0x31, /* KEY_N */ 0x32, /* KEY_M */ + 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */ + 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */ + 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */ + 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */ + 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */ + 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */ + 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */ + 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */ + 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */ + 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */ + 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */ + 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */ + 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */ + 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */ + 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */ + 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */ + 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */ + 0x00, /* 0x55 */ 0x56, /* KEY_Less */ + 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */ + 0x66, /* KEY_Home */ 0x67, /* KEY_Up */ + 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */ + 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */ + 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */ + 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */ + 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */ + 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */ + 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */ + 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */ + 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */ + 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */ + 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */ + 0x00, /* 0x71 */ 0x00, /* 0x72 */ + 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */ + 0x00, /* 0x75 */ 0x00, /* 0x76 */ + 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */ + 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */ + 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */ + 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */ + 0x00, /* 0x7f */ + /* the following are for ServerNumLock handling */ + 0x47, /* KEY_SN_KP_7 */ 0x48, /* KEY_SN_KP_8 */ + 0x49, /* KEY_SN_KP_9 */ 0x4b, /* KEY_SN_KP_4 */ + 0x4c, /* KEY_SN_KP_5 */ 0x4d, /* KEY_SN_KP_6 */ + 0x4f, /* KEY_SN_KP_1 */ 0x50, /* KEY_SN_KP_2 */ + 0x51, /* KEY_SN_KP_3 */ 0x52, /* KEY_SN_KP_0 */ + 0x53, /* KEY_SN_KP_Decimal */ 0x66, /* KEY_SN_Home */ + 0x67, /* KEY_SN_Up */ 0x68, /* KEY_SN_Prior */ + 0x69, /* KEY_SN_Left */ 0x5d, /* KEY_SN_Begin */ + 0x6a, /* KEY_SN_Right */ 0x6b, /* KEY_SN_End */ + 0x6c, /* KEY_SN_Down */ 0x6d, /* KEY_SN_Next */ + 0x6e, /* KEY_SN_Ins */ 0x6f /* KEY_SN_Del */ +}; +#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0])) + +#else /* !ASSUME_CUSTOM_KEYCODES */ + +#define NUM_AT2LNX NR_KEYS + +u_char SpecialServerMap[NR_KEYS]; + +#endif /* !ASSUME_CUSTOM_KEYCODES */ + +static void +readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KeySym *k; + int i; + static unsigned char tbl[GLYPHS_PER_KEY] = + { + 0, /* unshifted */ + 1, /* shifted */ + 0, /* modeswitch unshifted */ + 0 /* modeswitch shifted */ + }; + + /* + * Read the mapping from the kernel. + * Since we're still using the XFree86 scancode->AT keycode mapping + * routines, we need to convert the AT keycodes to Linux keycodes, + * then translate the Linux keysyms into X keysyms. + * + * First, figure out which tables to use for the modeswitch columns + * above, from the XF86Config fields. + */ + if (xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODESHIFT || + xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODELOCK) + tbl[2] = 4; /* control */ + else if (xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODESHIFT || + xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODELOCK) + tbl[2] = 2; /* AltGr */ + else + tbl[2] = 8; /* alt */ + tbl[3] = tbl[2] | 1; + +#ifndef ASSUME_CUSTOM_KEYCODES + for (i = 0, k = map+GLYPHS_PER_KEY; i < NUM_AT2LNX; ++i) +#else /* !ASSUME_CUSTOM_KEYCODES */ + for (i = 0, k = map; i < NUM_AT2LNX; ++i) +#endif /* !ASSUME_CUSTOM_KEYCODES */ + { + struct kbentry kbe; + int j; + +#ifndef ASSUME_CUSTOM_KEYCODES + kbe.kb_index = at2lnx[i]; +#else /* !ASSUME_CUSTOM_KEYCODES */ + kbe.kb_index = i; +#endif /* !ASSUME_CUSTOM_KEYCODES */ + + for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k) + { + unsigned short kval; + + *k = NoSymbol; + + kbe.kb_table = tbl[j]; + if ( +#ifndef ASSUME_CUSTOM_KEYCODES + kbe.kb_index == 0 || +#endif /* !ASSUME_CUSTOM_KEYCODES */ + ioctl(xf86Info.consoleFd, KDGKBENT, &kbe)) + continue; + + kval = KVAL(kbe.kb_value); + switch (KTYP(kbe.kb_value)) + { + case KT_LATIN: + case KT_LETTER: + *k = linux_to_x[kval]; + break; + + case KT_FN: + if (kval <= 19) + *k = XK_F1 + kval; + else switch (kbe.kb_value) + { + case K_FIND: + *k = XK_Home; /* or XK_Find */ + break; + case K_INSERT: + *k = XK_Insert; + break; + case K_REMOVE: + *k = XK_Delete; + break; + case K_SELECT: + *k = XK_End; /* or XK_Select */ + break; + case K_PGUP: + *k = XK_Prior; + break; + case K_PGDN: + *k = XK_Next; + break; + case K_HELP: + *k = XK_Help; + break; + case K_DO: + *k = XK_Execute; + break; + case K_PAUSE: + *k = XK_Pause; + break; + case K_MACRO: + *k = XK_Menu; + break; + default: + break; + } + break; + + case KT_SPEC: + switch (kbe.kb_value) + { + case K_ENTER: + *k = XK_Return; + break; + case K_BREAK: + *k = XK_Break; + break; + case K_CAPS: + *k = XK_Caps_Lock; + break; + case K_NUM: + *k = XK_Num_Lock; + break; + case K_HOLD: + *k = XK_Scroll_Lock; + break; + case K_COMPOSE: + *k = XK_Multi_key; + break; + default: + break; + } + break; + + case KT_PAD: + switch (kbe.kb_value) + { + case K_PPLUS: + *k = XK_KP_Add; + break; + case K_PMINUS: + *k = XK_KP_Subtract; + break; + case K_PSTAR: + *k = XK_KP_Multiply; + break; + case K_PSLASH: + *k = XK_KP_Divide; + break; + case K_PENTER: + *k = XK_KP_Enter; + break; + case K_PCOMMA: + *k = XK_KP_Separator; + break; + case K_PDOT: + *k = XK_KP_Decimal; + break; + case K_PPLUSMINUS: + *k = XK_KP_Subtract; + break; + default: + if (kval <= 9) + *k = XK_KP_0 + kval; + break; + } + break; + + /* + * KT_DEAD keys are for accelerated diacritical creation. + */ + case KT_DEAD: + switch (kbe.kb_value) + { + case K_DGRAVE: + *k = XK_dead_grave; + break; + case K_DACUTE: + *k = XK_dead_acute; + break; + case K_DCIRCM: + *k = XK_dead_circumflex; + break; + case K_DTILDE: + *k = XK_dead_tilde; + break; + case K_DDIERE: + *k = XK_dead_diaeresis; + break; + } + break; + + case KT_CUR: + switch (kbe.kb_value) + { + case K_DOWN: + *k = XK_Down; + break; + case K_LEFT: + *k = XK_Left; + break; + case K_RIGHT: + *k = XK_Right; + break; + case K_UP: + *k = XK_Up; + break; + } + break; + + case KT_SHIFT: + switch (kbe.kb_value) + { + case K_ALTGR: + *k = XK_Alt_R; + break; + case K_ALT: + *k = (kbe.kb_index == 0x64 ? + XK_Alt_R : XK_Alt_L); + break; + case K_CTRL: + *k = (kbe.kb_index == 0x61 ? + XK_Control_R : XK_Control_L); + break; + case K_CTRLL: + *k = XK_Control_L; + break; + case K_CTRLR: + *k = XK_Control_R; + break; + case K_SHIFT: + *k = (kbe.kb_index == 0x36 ? + XK_Shift_R : XK_Shift_L); + break; + case K_SHIFTL: + *k = XK_Shift_L; + break; + case K_SHIFTR: + *k = XK_Shift_R; + break; + default: + break; + } + break; + + /* + * KT_ASCII keys accumulate a 3 digit decimal number that gets + * emitted when the shift state changes. We can't emulate that. + */ + case KT_ASCII: + break; + + case KT_LOCK: + if (kbe.kb_value == K_SHIFTLOCK) + *k = XK_Shift_Lock; + break; + + default: + break; + } + } + + if (k[-1] == k[-2]) k[-1] = NoSymbol; + if (k[-2] == k[-3]) k[-2] = NoSymbol; + if (k[-3] == k[-4]) k[-3] = NoSymbol; + if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol; + if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol; + } +#ifdef ASSUME_CUSTOM_KEYCODES + /* + * Find the Mapping for the special server functions + */ + for (i = 0; i < NR_KEYS; ++i) { + struct kbentry kbe; + int special = 0; + + kbe.kb_index = i; + kbe.kb_table = 0; /* Plain map */ + if (!ioctl(xf86Info.consoleFd, KDGKBENT, &kbe)) + switch (kbe.kb_value) { + case K(KT_LATIN,0x7f): /* This catches DEL too... But who cares? */ + special = KEY_BackSpace; + break; + case K_PMINUS: + special = KEY_KP_Minus; + break; + case K_PPLUS: + special = KEY_KP_Plus; + break; + case K_F1: + special = KEY_F1; + break; + case K_F2: + special = KEY_F2; + break; + case K_F3: + special = KEY_F3; + break; + case K_F4: + special = KEY_F4; + break; + case K_F5: + special = KEY_F5; + break; + case K_F6: + special = KEY_F6; + break; + case K_F7: + special = KEY_F7; + break; + case K_F8: + special = KEY_F8; + break; + case K_F9: + special = KEY_F9; + break; + case K_F10: + special = KEY_F10; + break; + case K_F11: + special = KEY_F11; + break; + case K_F12: + special = KEY_F12; + break; + case K_ALT: + special = KEY_Alt; + break; + case K_ALTGR: + special = KEY_AltLang; + break; + case K_CONS: + special = KEY_SysReqest; + break; + } + SpecialServerMap[i] = special; + } +#endif /* ASSUME_CUSTOM_KEYCODES */ +} diff --git a/hw/xfree86/common/xf86KbdMach.c b/hw/xfree86/common/xf86KbdMach.c new file mode 100644 index 000000000..cc23ee8e0 --- /dev/null +++ b/hw/xfree86/common/xf86KbdMach.c @@ -0,0 +1,312 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdMach.c,v 3.7 1996/12/23 06:43:32 dawes Exp $ */ +/* + ***************************************************************************** + * HISTORY + * Log: xf86KbdMach.c,v + * Revision 2.1.2.1 92/06/25 10:32:08 moore + * Incorporate the Elliot Dresselhaus's, Ernest Hua's and local changes + * to run Thomas Roell's I386 color X11R5. Original code only worked + * with SCO Unix. New code works with 2.5 and 3.0 Mach + * [92/06/24 rvb] + * + * EndLog + * + ***************************************************************************** + */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86KbdMach.c,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "atKeynames.h" +#include "xf86_Config.h" + +#include "xf86Keymap.h" + +static KeySym ascii_to_x[256] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex, + XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla, + XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis, + XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring, + XK_Eacute, XK_ae, XK_AE, XK_ocircumflex, + XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave, + XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent, + XK_sterling, XK_yen, XK_paragraph, XK_section, + XK_aacute, XK_iacute, XK_oacute, XK_uacute, + XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine, + XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf, + XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi, + XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau, + XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta, + XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection, + XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal, + XK_topintegral, XK_botintegral, XK_division, XK_similarequal, + XK_degree, NoSymbol, NoSymbol, XK_radical, + XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol, + }; + +/* + * LegalModifier -- + * determine whether a key is a legal modifier key, i.e send a + * press/release sequence. + */ + +/*ARGSUSED*/ +Bool +LegalModifier(key, pDev) + unsigned int key; + DevicePtr pDev; +{ + return (TRUE); +} + + + +/* + * xf86KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +void +xf86KbdGetMapping (pKeySyms, pModMap) + KeySymsPtr pKeySyms; + CARD8 *pModMap; +{ + KeySym *k; + struct kbentry kbe; + char type; + int i, j; + + for (i = 0; i < NUMKEYS; i++) + { + static int states[] = { NORM_STATE, SHIFT_STATE, ALT_STATE, SHIFT_ALT }; + int j; + + k = &map[i*4]; + kbe.kb_index = i; + + for (j = 0; j < 4; j++) + { + kbe.kb_state = states[j]; + + if (ioctl (xf86Info.consoleFd, KDGKBENT, &kbe) != -1) + continue; + + if (kbe.kb_value [0] == K_SCAN) + { + int keycode = -1; + switch (kbe.kb_value [1]) + { + case K_CTLSC: keycode = XK_Control_L; break; + case K_LSHSC: keycode = XK_Shift_L; break; + case K_RSHSC: keycode = XK_Shift_R; break; + case K_ALTSC: keycode = XK_Alt_L; break; + case K_CLCKSC: keycode = XK_Caps_Lock; break; + case K_NLCKSC: keycode = XK_Num_Lock; break; + default: break; + } + if (keycode > 0) + k[j] = keycode; + } + else if (kbe.kb_value[1] != NC) + { + /* How to handle multiple characters? + Ignore them for now. */ + } + else + { + k[j] = ascii_to_x[kbe.kb_value[0]]; + } + } + } + + /* + * Apply the special key mapping specified in XF86Config + */ + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) { + switch (k[0]) { + case XK_Alt_L: + j = K_INDEX_LEFTALT; + break; + case XK_Alt_R: + j = K_INDEX_RIGHTALT; + break; + case XK_Scroll_Lock: + j = K_INDEX_SCROLLLOCK; + break; + case XK_Control_R: + j = K_INDEX_RIGHTCTL; + break; + default: + j = -1; + } + if (j >= 0) + switch (xf86Info.specialKeyMap[j]) { + case KM_META: + if (k[0] == XK_Alt_R) + k[1] = XK_Meta_R; + else { + k[0] = XK_Alt_L; + k[1] = XK_Meta_L; + } + break; + case KM_COMPOSE: + k[0] = XK_Multi_key; + break; + case KM_MODESHIFT: + k[0] = XK_Mode_switch; + k[1] = NoSymbol; + break; + case KM_MODELOCK: + k[0] = XK_Mode_switch; + k[1] = XF86XK_ModeLock; + break; + case KM_SCROLLLOCK: + k[0] = XK_Scroll_Lock; + break; + case KM_CONTROL: + k[0] = XK_Control_R; + break; + } + } + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + + xf86Info.kbdType = + ioctl(xf86Info.kbdFd, KDGKBDTYPE, &type) != -1 ? type : KB_VANILLAKB; + + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + if (xf86Info.serverNumLock) + pKeySyms->maxKeyCode = MAX_KEYCODE; + else + pKeySyms->maxKeyCode = MAX_STD_KEYCODE; + +} diff --git a/hw/xfree86/common/xf86Keymap.h b/hw/xfree86/common/xf86Keymap.h new file mode 100644 index 000000000..2b9debff4 --- /dev/null +++ b/hw/xfree86/common/xf86Keymap.h @@ -0,0 +1,449 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.9 1996/12/23 06:43:35 dawes Exp $ */ +/* + * + * For Scancodes see notes in atKeynames.h !!!! + * + */ +/* $Xorg: xf86Keymap.h,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */ + +static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = { +#ifndef PC98 + /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, + /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol, + /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol, + /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol, + /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol, + /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol, + /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol, + /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol, + /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol, + /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol, + /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol, + /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol, + /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol, + /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, + /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol, + /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol, + /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol, + /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol, + /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol, + /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol, + /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol, + /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol, + /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol, + /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol, + /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, + /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, + /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol, + /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol, + /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol, + /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol, + /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol, + /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol, + /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol, + /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol, + /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol, + /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol, + /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol, + /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol, + /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol, + /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol, + /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol, + /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol, + /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol, + /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol, + /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol, + /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol, + /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol, + /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol, + /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol, + /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, + /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol, + /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol, + /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol, + /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol, + /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol, + /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol, + /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol, + /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol, + /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol, + /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol, + /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol, + /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol, + /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, + /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, + /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, + /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, + /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, + /* 0x4c */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, + /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, + /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, + /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, + /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, + /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, + /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, + /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, + /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol, + /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol, + /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol, + /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol, + + /* 0x59 */ XK_Home, NoSymbol, NoSymbol, NoSymbol, + /* 0x5a */ XK_Up, NoSymbol, NoSymbol, NoSymbol, + /* 0x5b */ XK_Prior, NoSymbol, NoSymbol, NoSymbol, + /* 0x5c */ XK_Left, NoSymbol, NoSymbol, NoSymbol, + /* 0x5d */ XK_Begin, NoSymbol, NoSymbol, NoSymbol, + /* 0x5e */ XK_Right, NoSymbol, NoSymbol, NoSymbol, + /* 0x5f */ XK_End, NoSymbol, NoSymbol, NoSymbol, + /* 0x60 */ XK_Down, NoSymbol, NoSymbol, NoSymbol, + /* 0x61 */ XK_Next, NoSymbol, NoSymbol, NoSymbol, + /* 0x62 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol, + /* 0x63 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol, + /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, + /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol, + /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol, + /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, + /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol, + /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol, + /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol, + /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x70 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x71 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x72 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x73 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, +#else /* PC98 */ + /* 0x00 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, + /* 0x01 */ XK_1, XK_exclam, XK_kana_NU, NoSymbol, + /* 0x02 */ XK_2, XK_quotedbl, XK_kana_FU, NoSymbol, + /* 0x03 */ XK_3, XK_numbersign, XK_kana_A, XK_kana_a, + /* 0x04 */ XK_4, XK_dollar, XK_kana_U, XK_kana_u, + /* 0x05 */ XK_5, XK_percent, XK_kana_E, XK_kana_e, + /* 0x06 */ XK_6, XK_ampersand, XK_kana_O, XK_kana_o, + /* 0x07 */ XK_7, XK_quoteright, XK_kana_YA, XK_kana_ya, + /* 0x08 */ XK_8, XK_parenleft, XK_kana_YU, XK_kana_yu, + /* 0x09 */ XK_9, XK_parenright, XK_kana_YO, XK_kana_yo, + /* 0x0a */ XK_0, NoSymbol, XK_kana_WA, XK_kana_WO, + /* 0x0b */ XK_minus, XK_equal, XK_kana_HO, NoSymbol, + /* 0x0c */ XK_asciicircum, XK_quoteleft, XK_kana_HE, NoSymbol, + /* 0x0d */ XK_backslash, XK_bar, XK_prolongedsound, NoSymbol, + /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, + /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol, + /* 0x10 */ XK_Q, NoSymbol, XK_kana_TA, NoSymbol, + /* 0x11 */ XK_W, NoSymbol, XK_kana_TE, NoSymbol, + /* 0x12 */ XK_E, NoSymbol, XK_kana_I, XK_kana_i, + /* 0x13 */ XK_R, NoSymbol, XK_kana_SU, NoSymbol, + /* 0x14 */ XK_T, NoSymbol, XK_kana_KA, NoSymbol, + /* 0x15 */ XK_Y, NoSymbol, XK_kana_N, NoSymbol, + /* 0x16 */ XK_U, NoSymbol, XK_kana_NA, NoSymbol, + /* 0x17 */ XK_I, NoSymbol, XK_kana_NI, NoSymbol, + /* 0x18 */ XK_O, NoSymbol, XK_kana_RA, NoSymbol, + /* 0x19 */ XK_P, NoSymbol, XK_kana_SE, NoSymbol, + /* 0x1a */ XK_at, XK_asciitilde, XK_voicedsound, NoSymbol, + /* 0x1b */ XK_bracketleft, XK_braceleft, XK_semivoicedsound, XK_kana_openingbracket, + /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol, + /* 0x1d */ XK_A, NoSymbol, XK_kana_CHI, NoSymbol, + /* 0x1e */ XK_S, NoSymbol, XK_kana_TO, NoSymbol, + /* 0x1f */ XK_D, NoSymbol, XK_kana_SHI, NoSymbol, + /* 0x20 */ XK_F, NoSymbol, XK_kana_HA, NoSymbol, + /* 0x21 */ XK_G, NoSymbol, XK_kana_KI, NoSymbol, + /* 0x22 */ XK_H, NoSymbol, XK_kana_KU, NoSymbol, + /* 0x23 */ XK_J, NoSymbol, XK_kana_MA, NoSymbol, + /* 0x24 */ XK_K, NoSymbol, XK_kana_NO, NoSymbol, + /* 0x25 */ XK_L, NoSymbol, XK_kana_RI, NoSymbol, + /* 0x26 */ XK_semicolon, XK_plus, XK_kana_RE, NoSymbol, + /* 0x27 */ XK_colon, XK_asterisk, XK_kana_KE, NoSymbol, + /* 0x28 */ XK_bracketright,XK_braceright, XK_kana_MU, XK_kana_closingbracket, + /* 0x29 */ XK_Z, NoSymbol, XK_kana_TSU, NoSymbol, + /* 0x2a */ XK_X, NoSymbol, XK_kana_SA, NoSymbol, + /* 0x2b */ XK_C, NoSymbol, XK_kana_SO, NoSymbol, + /* 0x2c */ XK_V, NoSymbol, XK_kana_HI, NoSymbol, + /* 0x2d */ XK_B, NoSymbol, XK_kana_KO, NoSymbol, + /* 0x2e */ XK_N, NoSymbol, XK_kana_MI, NoSymbol, + /* 0x2f */ XK_M, NoSymbol, XK_kana_MO, NoSymbol, + /* 0x30 */ XK_comma, XK_less, XK_kana_NE, XK_kana_comma, + /* 0x31 */ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop, + /* 0x32 */ XK_slash, XK_question, XK_kana_ME, XK_kana_middledot, + /* 0x33 */ XK_underscore, XK_underscore, XK_kana_RO, NoSymbol, + /* 0x34 */ XK_space, NoSymbol, NoSymbol, NoSymbol, + /* 0x35 */ XK_Henkan, XK_Kanji, NoSymbol, NoSymbol, + /* 0x36 */ XK_Next, NoSymbol, NoSymbol, NoSymbol, + /* 0x37 */ XK_Prior, NoSymbol, NoSymbol, NoSymbol, + /* 0x38 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol, + /* 0x39 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol, + /* 0x3a */ XK_Up, NoSymbol, NoSymbol, NoSymbol, + /* 0x3b */ XK_Left, NoSymbol, NoSymbol, NoSymbol, + /* 0x3c */ XK_Right, NoSymbol, NoSymbol, NoSymbol, + /* 0x3d */ XK_Down, NoSymbol, NoSymbol, NoSymbol, + /* 0x3e */ XK_Clear, XK_Home, NoSymbol, NoSymbol, + /* 0x3f */ XK_Help, NoSymbol, NoSymbol, NoSymbol, + /* 0x40 */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, + /* 0x41 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, + /* 0x42 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol, + /* 0x43 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol, + /* 0x44 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol, + /* 0x45 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, + /* 0x46 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol, + /* 0x47 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol, + /* 0x48 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol, + /* 0x49 */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, + /* 0x4a */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol, + /* 0x4b */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol, + /* 0x4c */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol, + /* 0x4d */ XK_KP_Equal, NoSymbol, NoSymbol, NoSymbol, + /* 0x4e */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol, + /* 0x4f */ XK_KP_Separator,NoSymbol, NoSymbol, NoSymbol, + /* 0x50 */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol, + /* 0x51 */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol, + /* 0x52 */ XK_F11, NoSymbol, NoSymbol, NoSymbol, + /* 0x53 */ XK_F12, NoSymbol, NoSymbol, NoSymbol, + /* 0x54 */ XK_F13, NoSymbol, NoSymbol, NoSymbol, + /* 0x55 */ XK_F14, NoSymbol, NoSymbol, NoSymbol, + /* 0x56 */ XK_F15, NoSymbol, NoSymbol, NoSymbol, + /* 0x57 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x58 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x60 */ XK_Break, NoSymbol, NoSymbol, NoSymbol, + /* 0x61 */ XK_Print, NoSymbol, NoSymbol, NoSymbol, + /* 0x62 */ XK_F1, NoSymbol, NoSymbol, NoSymbol, + /* 0x63 */ XK_F2, NoSymbol, NoSymbol, NoSymbol, + /* 0x64 */ XK_F3, NoSymbol, NoSymbol, NoSymbol, + /* 0x65 */ XK_F4, NoSymbol, NoSymbol, NoSymbol, + /* 0x66 */ XK_F5, NoSymbol, NoSymbol, NoSymbol, + /* 0x67 */ XK_F6, NoSymbol, NoSymbol, NoSymbol, + /* 0x68 */ XK_F7, NoSymbol, NoSymbol, NoSymbol, + /* 0x69 */ XK_F8, NoSymbol, NoSymbol, NoSymbol, + /* 0x6a */ XK_F9, NoSymbol, NoSymbol, NoSymbol, + /* 0x6b */ XK_F10, NoSymbol, NoSymbol, NoSymbol, + /* 0x6c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x6d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x70 */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x71 */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x72 */ XK_kana_switch, NoSymbol, XK_kana_switch, NoSymbol, + /* 0x73 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol, + /* 0x74 */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, +#endif /* PC98 */ + /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + + /* These are for ServerNumLock handling */ + /* 0x80 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol, + /* 0x81 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol, + /* 0x82 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol, + /* 0x83 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol, + /* 0x84 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol, + /* 0x85 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol, + /* 0x86 */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol, + /* 0x87 */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol, + /* 0x88 */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol, + /* 0x89 */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol, + /* 0x8a */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol, + /* 0x8b */ XK_Home, NoSymbol, NoSymbol, NoSymbol, + /* 0x8c */ XK_Up, NoSymbol, NoSymbol, NoSymbol, + /* 0x8d */ XK_Prior, NoSymbol, NoSymbol, NoSymbol, + /* 0x8e */ XK_Left, NoSymbol, NoSymbol, NoSymbol, + /* 0x8f */ XK_Begin, NoSymbol, NoSymbol, NoSymbol, + /* 0x90 */ XK_Right, NoSymbol, NoSymbol, NoSymbol, + /* 0x91 */ XK_End, NoSymbol, NoSymbol, NoSymbol, + /* 0x92 */ XK_Down, NoSymbol, NoSymbol, NoSymbol, + /* 0x93 */ XK_Next, NoSymbol, NoSymbol, NoSymbol, + /* 0x94 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol, + /* 0x95 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol, +}; + +static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = { + /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, + /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol, + /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol, + /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol, + /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol, + /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol, + /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol, + /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol, + /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol, + /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol, + /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol, + /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol, + /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol, + /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, + /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol, + /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol, + /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol, + /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol, + /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol, + /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol, + /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol, + /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol, + /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol, + /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol, + /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, + /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, + /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol, + /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol, + /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol, + /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol, + /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol, + /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol, + /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol, + /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol, + /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol, + /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol, + /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol, + /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol, + /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol, + /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol, + /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol, + /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol, + /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol, + /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol, + /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol, + /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol, + /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol, + /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol, + /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol, + /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, + /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol, + /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol, + /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol, + /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol, + /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol, + /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol, + /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol, + /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol, + /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol, + /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol, + /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol, + /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol, + /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, + /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, + /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, + /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, + /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, + /* 0x4c */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, + /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, + /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, + /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, + /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, + /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, + /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, + /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, + /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol, + /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol, + /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol, + /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol, + + /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x60 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x61 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x62 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x63 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, + /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol, + /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol, + /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, + /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol, + /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol, + /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol, + /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x70 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x71 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x72 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x73 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + + /* These are for ServerNumLock handling */ + /* 0x80 */ XK_KP_7, NoSymbol, NoSymbol, NoSymbol, + /* 0x81 */ XK_KP_8, NoSymbol, NoSymbol, NoSymbol, + /* 0x82 */ XK_KP_9, NoSymbol, NoSymbol, NoSymbol, + /* 0x83 */ XK_KP_4, NoSymbol, NoSymbol, NoSymbol, + /* 0x84 */ XK_KP_5, NoSymbol, NoSymbol, NoSymbol, + /* 0x85 */ XK_KP_6, NoSymbol, NoSymbol, NoSymbol, + /* 0x86 */ XK_KP_1, NoSymbol, NoSymbol, NoSymbol, + /* 0x87 */ XK_KP_2, NoSymbol, NoSymbol, NoSymbol, + /* 0x88 */ XK_KP_3, NoSymbol, NoSymbol, NoSymbol, + /* 0x89 */ XK_KP_0, NoSymbol, NoSymbol, NoSymbol, + /* 0x8a */ XK_KP_Decimal, NoSymbol, NoSymbol, NoSymbol, + /* 0x8b */ XK_Home, NoSymbol, NoSymbol, NoSymbol, + /* 0x8c */ XK_Up, NoSymbol, NoSymbol, NoSymbol, + /* 0x8d */ XK_Prior, NoSymbol, NoSymbol, NoSymbol, + /* 0x8e */ XK_Left, NoSymbol, NoSymbol, NoSymbol, + /* 0x8f */ XK_Begin, NoSymbol, NoSymbol, NoSymbol, + /* 0x90 */ XK_Right, NoSymbol, NoSymbol, NoSymbol, + /* 0x91 */ XK_End, NoSymbol, NoSymbol, NoSymbol, + /* 0x92 */ XK_Down, NoSymbol, NoSymbol, NoSymbol, + /* 0x93 */ XK_Next, NoSymbol, NoSymbol, NoSymbol, + /* 0x94 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol, + /* 0x95 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol, +}; diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h new file mode 100644 index 000000000..3c73f6e56 --- /dev/null +++ b/hw/xfree86/common/xf86Priv.h @@ -0,0 +1,175 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.24.2.1 1998/02/01 16:04:47 robin Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86Priv.h,v 1.3 2000/08/17 19:50:30 cpqbld Exp $ */ + +#ifndef _XF86PRIV_H +#define _XF86PRIV_H + +#ifndef _XF86VIDMODE_SERVER_ +#include "Xproto.h" +#include "xf86_OSproc.h" +#endif + +typedef struct { + + /* keyboard part */ + DeviceIntPtr pKeyboard; + DeviceProc kbdProc; /* procedure for initializing */ + void (* kbdEvents)( /* proc for processing events */ +#if NeedNestedPrototypes && !defined(__OSF__) + void +#endif + ); +#ifndef MINIX + int consoleFd; +#else + int kbdFd; +#endif /* MINIX */ +#if defined(MACH386) || defined(__OSF__) + int kbdFd; +#endif /* MACH386 || __OSF__ */ + int vtno; + int kbdType; /* AT84 / AT101 */ + int kbdRate; + int kbdDelay; + int bell_pitch; + int bell_duration; + Bool autoRepeat; + unsigned long leds; + unsigned long xleds; + char *vtinit; + int *specialKeyMap; + int scanPrefix; /* scancode-state */ + Bool capsLock; + Bool numLock; + Bool scrollLock; + Bool modeSwitchLock; + Bool serverNumLock; + Bool composeLock; + Bool vtSysreq; +#if defined(SVR4) && defined(i386) + Bool panix106; +#endif /* SVR4 && i386 */ + + /* mouse part */ + DeviceIntPtr pMouse; +#ifdef XINPUT + pointer mouseLocal; +#endif + MouseDevPtr mouseDev; + + /* event handler part */ + int lastEventTime; + Bool vtRequestsPending; + Bool inputPending; + Bool dontZap; + Bool dontZoom; + Bool notrapSignals; /* don't exit cleanly - die at fault */ + Bool caughtSignal; + + /* graphics part */ + Bool sharedMonitor; + ScreenPtr currentScreen; +#ifdef CSRG_BASED + int screenFd; /* fd for memory mapped access to vga card */ + int consType; /* Which console driver? */ +#endif +#if defined(AMOEBA) + void *screenPtr; +#endif + +#ifdef XKB +/* + * would like to use an XkbComponentNamesRec here but can't without + * pulling in a bunch of header files. :-( + */ + char *xkbkeymap; + char *xkbkeycodes; + char *xkbtypes; + char *xkbcompat; + char *xkbsymbols; + char *xkbgeometry; + Bool xkbcomponents_specified; + char *xkbrules; + char *xkbmodel; + char *xkblayout; + char *xkbvariant; + char *xkboptions; +#endif + +} xf86InfoRec, *xf86InfoPtr; + +extern xf86InfoRec xf86Info; + +/* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */ +#define XLED1 ((unsigned long) 0x00000001) +#define XLED2 ((unsigned long) 0x00000002) +#define XLED3 ((unsigned long) 0x00000004) +#define XCAPS ((unsigned long) 0x20000000) +#define XNUM ((unsigned long) 0x40000000) +#define XSCR ((unsigned long) 0x80000000) +#define XCOMP ((unsigned long) 0x00008000) + +/* 386BSD console driver types (consType) */ +#ifdef CSRG_BASED +#define PCCONS 0 +#define CODRV011 1 +#define CODRV01X 2 +#define SYSCONS 8 +#define PCVT 16 +#endif + +/* Values of xf86Info.mouseFlags */ +#define MF_CLEAR_DTR 1 +#define MF_CLEAR_RTS 2 + +extern int xf86ScreenIndex; + +#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr)) + +extern int xf86MaxScreens; +extern ScrnInfoPtr xf86Screens[]; +extern int xf86ScreenNames[]; + +extern char xf86ConfigFile[]; +extern int xf86Verbose; +extern Bool xf86ProbeOnly, xf86ProbeFailed; +extern unsigned short xf86MouseCflags[]; +extern Bool xf86SupportedMouseTypes[]; +extern int xf86NumMouseTypes; +extern int xf86bpp; +extern xrgb xf86weight; +extern Bool xf86AllowMouseOpenFail; +extern Bool xf86BestRefresh; + +extern Bool xf86FlipPixels; +#define XF86FLIP_PIXELS() \ + if (xf86FlipPixels) { \ + pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \ + pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \ + } + +#endif /* _XF86PRIV_H */ + + diff --git a/hw/xfree86/common/xf86Version.h b/hw/xfree86/common/xf86Version.h new file mode 100644 index 000000000..f403c31f5 --- /dev/null +++ b/hw/xfree86/common/xf86Version.h @@ -0,0 +1,23 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.236.2.50 1998/03/02 09:58:21 dawes Exp $ */ + +#define XF86_VERSION " 3.3.2 " + +/* The finer points in versions... */ +#define XF86_VERSION_MAJOR 3 +#define XF86_VERSION_MINOR 3 +#define XF86_VERSION_SUBMINOR 2 +#define XF86_VERSION_BETA 0 /* 0="", 1="A", 2="B", etc... */ +#define XF86_VERSION_ALPHA 0 /* 0="", 1="a", 2="b", etc... */ + +#define XF86_VERSION_NUMERIC(major,minor,subminor,beta,alpha) \ + ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha) +#define XF86_VERSION_CURRENT \ + XF86_VERSION_NUMERIC(XF86_VERSION_MAJOR, \ + XF86_VERSION_MINOR, \ + XF86_VERSION_SUBMINOR, \ + XF86_VERSION_BETA, \ + XF86_VERSION_ALPHA) + +#define XF86_DATE "March 2 1998" + +/* $Xorg: xf86Version.h,v 1.3 2000/08/17 19:48:48 cpqbld Exp $ */ diff --git a/hw/xfree86/common/xf86XKB.c b/hw/xfree86/common/xf86XKB.c new file mode 100644 index 000000000..c5ac740fd --- /dev/null +++ b/hw/xfree86/common/xf86XKB.c @@ -0,0 +1,118 @@ +/* $Xorg: xf86XKB.c,v 1.3 2000/08/17 19:50:31 cpqbld Exp $ */ +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +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 Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.6 1996/12/28 11:14:43 dawes Exp $ */ + +#include <stdio.h> +#define NEED_EVENTS 1 +#include <X11/X.h> +#include <X11/Xproto.h> +#include <X11/keysym.h> +#include "inputstr.h" +#include "scrnintstr.h" +#include "windowstr.h" +#include "XI.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86_Config.h" + +#include "XKBsrv.h" + +#ifdef AMOEBA +#define LED_CAP IOP_LED_CAP +#define LED_NUM IOP_LED_NUM +#define LED_SCR IOP_LED_SCROLL +#endif + +#ifdef MINIX +#define LED_CAP KBD_LEDS_CAPS +#define LED_NUM KBD_LEDS_NUM +#define LED_SCR KBD_LEDS_SCROLL +#endif + +void +xf86InitXkb() +{ +} + +void +#if NeedFunctionPrototypes +XkbDDXUpdateIndicators(DeviceIntPtr pXDev,CARD32 new) +#else +XkbDDXUpdateIndicators(pXDev,new) + DeviceIntPtr pXDev; + CARD32 new; +#endif +{ + CARD32 old; +#ifdef DEBUG +/* if (xkbDebugFlags)*/ + ErrorF("XkbDDXUpdateIndicators(...,0x%x) -- XFree86 version\n",new); +#endif +#ifdef LED_CAP + old= new; + new= 0; + if (old&XLED1) new|= LED_CAP; + if (old&XLED2) new|= LED_NUM; + if (old&XLED3) new|= LED_SCR; +#endif + xf86SetKbdLeds(new); + return; +} + +void +#if NeedFunctionPrototypes +XkbDDXUpdateDeviceIndicators( DeviceIntPtr dev, + XkbSrvLedInfoPtr sli, + CARD32 new) +#else +XkbDDXUpdateDeviceIndicators(dev,sli,new) + DeviceIntPtr dev; + XkbSrvLedInfoPtr sli; + CARD32 new; +#endif +{ + if (sli->fb.kf==dev->kbdfeed) + XkbDDXUpdateIndicators(dev,new); + else if (sli->class==KbdFeedbackClass) { + KbdFeedbackPtr kf; + kf= sli->fb.kf; + if (kf && kf->CtrlProc) { + (*kf->CtrlProc)(dev,&kf->ctrl); + } + } + else if (sli->class==LedFeedbackClass) { + LedFeedbackPtr lf; + lf= sli->fb.lf; + if (lf && lf->CtrlProc) { + (*lf->CtrlProc)(dev,&lf->ctrl); + } + } + return; +} diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c new file mode 100644 index 000000000..7659deb3f --- /dev/null +++ b/hw/xfree86/common/xf86Xinput.c @@ -0,0 +1,1264 @@ +/* $Xorg: xf86Xinput.c,v 1.3 2000/08/17 19:50:31 cpqbld Exp $ */ +/* + * Copyright 1995,1996 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.22.2.7 1998/02/07 10:05:22 hohndel Exp $ */ + +#include "Xmd.h" +#include "XI.h" +#include "XIproto.h" +#include "xf86.h" +#include "Xpoll.h" +#include "xf86Priv.h" +#include "xf86_Config.h" +#include "xf86Xinput.h" +#include "xf86Procs.h" +#include "mipointer.h" + +#ifdef DPMSExtension +#include "extensions/dpms.h" +#endif + +#include "exevents.h" /* AddInputDevice */ + +#include "extnsionst.h" +#include "extinit.h" /* LookupDeviceIntRec */ + +#include "windowstr.h" /* screenIsSaved */ + +#include <stdarg.h> + +extern InputInfo inputInfo; + +#ifndef DYNAMIC_MODULE +#ifdef JOYSTICK_SUPPORT +extern DeviceAssocRec joystick_assoc; +#endif +#ifdef WACOM_SUPPORT +extern DeviceAssocRec wacom_stylus_assoc; +extern DeviceAssocRec wacom_cursor_assoc; +extern DeviceAssocRec wacom_eraser_assoc; +#endif +#ifdef ELOGRAPHICS_SUPPORT +extern DeviceAssocRec elographics_assoc; +#endif +#ifdef SUMMASKETCH_SUPPORT +extern DeviceAssocRec summasketch_assoc; +#endif +#endif + +extern DeviceAssocRec mouse_assoc; + +static int num_devices; +static LocalDevicePtr *localDevices; +static int max_devices; + +static DeviceAssocPtr *deviceAssoc = NULL; +static int numAssoc = 0; +static int maxAssoc = 0; + +static SymTabRec XinputTab[] = { + { ENDSECTION, "endsection"}, + { SUBSECTION, "subsection" }, + { -1, "" }, +}; + +/*********************************************************************** + * + * xf86AlwaysCoreControl -- + * + * Control proc for the integer feedback that controls the always + * core feature. + * + *********************************************************************** + */ +static void +xf86AlwaysCoreControl(DeviceIntPtr device, + IntegerCtrl *control) +{ +} + +/*********************************************************************** + * + * Core devices functions -- + * + * Test if device is the core device by checking the + * value of always core feedback and the inputInfo struct. + * + *********************************************************************** + */ +int +xf86IsCorePointer(DeviceIntPtr device) +{ + LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate; + + return((local->always_core_feedback && + local->always_core_feedback->ctrl.integer_displayed) || + (device == inputInfo.pointer)); +} + +static int +xf86IsAlwaysCore(DeviceIntPtr device) +{ + LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate; + + return(local->always_core_feedback && + local->always_core_feedback->ctrl.integer_displayed); +} + +int +xf86IsCoreKeyboard(DeviceIntPtr device) +{ + LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate; + + return((local->flags & XI86_ALWAYS_CORE) || + (device == inputInfo.keyboard)); +} + +void +xf86AlwaysCore(LocalDevicePtr local, + Bool always) +{ + if (always) { + local->flags |= XI86_ALWAYS_CORE; + } else { + local->flags &= ~XI86_ALWAYS_CORE; + } +} + +/*********************************************************************** + * + * xf86CheckButton -- + * + * Test if the core pointer button state is coherent with + * the button event to send. + * + *********************************************************************** + */ +Bool +xf86CheckButton(int button, + int down) +{ + /* The device may have up to MSE_MAXBUTTONS (12) buttons. */ + int state = (inputInfo.pointer->button->state & 0x0fff00) >> 8; + int check = (state & (1 << (button - 1))); + + if ((check && down) && (!check && !down)) { + return FALSE; + } + + return TRUE; +} + +/*********************************************************************** + * + * ReadInput -- + * Wakeup handler to catch input and dispatch it to our + * input routines if necessary. + * + *********************************************************************** + */ +static void +ReadInput(pointer block_data, + int select_status, + pointer read_mask) +{ + int i; + LocalDevicePtr local_dev; + fd_set* LastSelectMask = (fd_set*) read_mask; + fd_set devices_with_input; + extern fd_set EnabledDevices; + + if (select_status < 1) + return; + + XFD_ANDSET(&devices_with_input, LastSelectMask, &EnabledDevices); + if (!XFD_ANYSET(&devices_with_input)) + return; + + for (i = 0; i < num_devices; i++) { + local_dev = localDevices[i]; + if (local_dev->read_input && + (local_dev->fd >= 0) && + (FD_ISSET(local_dev->fd, ((fd_set *) read_mask)) != 0)) { + (*local_dev->read_input)(local_dev); + break; + } + } +} + +/*********************************************************************** + * + * configExtendedInputSection -- + * + *********************************************************************** + */ + +void +xf86ConfigExtendedInputSection(LexPtr val) +{ + int i; + int token; + +#ifndef DYNAMIC_MODULE +# ifdef JOYSTICK_SUPPORT + xf86AddDeviceAssoc(&joystick_assoc); +# endif +# ifdef WACOM_SUPPORT + xf86AddDeviceAssoc(&wacom_stylus_assoc); + xf86AddDeviceAssoc(&wacom_cursor_assoc); + xf86AddDeviceAssoc(&wacom_eraser_assoc); +# endif +# ifdef ELOGRAPHICS_SUPPORT + xf86AddDeviceAssoc(&elographics_assoc); +# endif +# ifdef SUMMASKETCH_SUPPORT + xf86AddDeviceAssoc(&summasketch_assoc); +# endif +#endif + + xf86AddDeviceAssoc(&mouse_assoc); + + num_devices = 0; + max_devices = 3; + localDevices = (LocalDevicePtr*) xalloc(sizeof(LocalDevicePtr)*max_devices); + + while ((token = xf86GetToken(XinputTab)) != ENDSECTION) + { + if (token == SUBSECTION) + { + int found = 0; + + if (xf86GetToken(NULL) != STRING) + xf86ConfigError("SubSection name expected"); + + for(i=0; !found && i<numAssoc; i++) + { + if (StrCaseCmp(val->str, deviceAssoc[i]->config_section_name) == 0) + { + if (num_devices == max_devices) { + max_devices *= 2; + localDevices = (LocalDevicePtr*) xrealloc(localDevices, + sizeof(LocalDevicePtr)*max_devices); + } + localDevices[num_devices] = deviceAssoc[i]->device_allocate(); + + if (localDevices[num_devices] && localDevices[num_devices]->device_config) + { + (*localDevices[num_devices]->device_config)(localDevices, + num_devices, + num_devices+1, + val); + localDevices[num_devices]->flags |= XI86_CONFIGURED; + num_devices++; + } + found = 1; + } + } + if (!found) + xf86ConfigError("Invalid SubSection name"); + } + else + xf86ConfigError("XInput keyword section expected"); + } +} + +/*********************************************************************** + * + * xf86AddDeviceAssoc -- + * + * Add an association to the array deviceAssoc. This is needed to + * allow dynamic loading of devices to register themself. + * + *********************************************************************** + */ +void +xf86AddDeviceAssoc(DeviceAssocPtr assoc) +{ + if (!deviceAssoc) { + maxAssoc = 10; + deviceAssoc = (DeviceAssocPtr*) xalloc(sizeof(DeviceAssocPtr)*maxAssoc); + } else { + if (maxAssoc == numAssoc) { + maxAssoc *= 2; + deviceAssoc = (DeviceAssocPtr*) xrealloc(deviceAssoc, sizeof(DeviceAssocPtr)*maxAssoc); + } + } + deviceAssoc[numAssoc] = assoc; + numAssoc++; +} + +/*********************************************************************** + * + * xf86XinputFinalizeInit -- + * + * Create and initialize an integer feedback to control the always + * core feature. + * + *********************************************************************** + */ +void +xf86XinputFinalizeInit(DeviceIntPtr dev) +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + + if (InitIntegerFeedbackClassDeviceStruct(dev, xf86AlwaysCoreControl) == FALSE) { + ErrorF("Unable to init integer feedback for always core feature\n"); + } else { + local->always_core_feedback = dev->intfeed; + dev->intfeed->ctrl.integer_displayed = (local->flags & XI86_ALWAYS_CORE) ? 1 : 0; + } +} + + +/*********************************************************************** + * + * InitExtInput -- + * + * Initialize any extended devices we might have. It is called from + * ddx InitInput. + * + *********************************************************************** + */ + +void +InitExtInput() +{ + DeviceIntPtr dev; + int i; + + /* Register a Wakeup handler to handle input when generated */ + RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr) NoopDDA, ReadInput, + NULL); + + /* Add each device */ + for (i = 0; i < num_devices; i++) { + if (localDevices[i]->flags & XI86_CONFIGURED) { + int open_on_init; + + open_on_init = !(localDevices[i]->flags & XI86_NO_OPEN_ON_INIT) || + (localDevices[i]->flags & XI86_ALWAYS_CORE); + + dev = AddInputDevice(localDevices[i]->device_control, + open_on_init); + if (dev == NULL) + FatalError("Too many input devices"); + + localDevices[i]->atom = MakeAtom(localDevices[i]->name, + strlen(localDevices[i]->name), + TRUE); + dev->public.devicePrivate = (pointer) localDevices[i]; + localDevices[i]->dev = dev; + + xf86XinputFinalizeInit(dev); + + RegisterOtherDevice(dev); + if (serverGeneration == 1) + ErrorF("%s Adding extended device \"%s\" (type: %s)\n", XCONFIG_GIVEN, + localDevices[i]->name, localDevices[i]->type_name); + } + } +} + + +/*********************************************************************** + * + * Caller: ProcXOpenDevice + * + * This is the implementation-dependent routine to open an input device. + * Some implementations open all input devices when the server is first + * initialized, and never close them. Other implementations open only + * the X pointer and keyboard devices during server initialization, + * and only open other input devices when some client makes an + * XOpenDevice request. This entry point is for the latter type of + * implementation. + * + * If the physical device is not already open, do it here. In this case, + * you need to keep track of the fact that one or more clients has the + * device open, and physically close it when the last client that has + * it open does an XCloseDevice. + * + * The default implementation is to do nothing (assume all input devices + * are opened during X server initialization and kept open). + * + *********************************************************************** + */ + +void +OpenInputDevice (dev, client, status) + DeviceIntPtr dev; + ClientPtr client; + int *status; +{ + extern int BadDevice; + + if (!dev->inited) { + *status = BadDevice; + } else { + if (!dev->public.on) { + if (!EnableDevice(dev)) { + *status = BadDevice; + } else { + /* to prevent ProcXOpenDevice to call EnableDevice again */ + dev->startup = FALSE; + } + } + } +} + + +/*********************************************************************** + * + * Caller: ProcXChangeKeyboardDevice + * + * This procedure does the implementation-dependent portion of the work + * needed to change the keyboard device. + * + * The X keyboard device has a FocusRec. If the device that has been + * made into the new X keyboard did not have a FocusRec, + * ProcXChangeKeyboardDevice will allocate one for it. + * + * If you do not want clients to be able to focus the old X keyboard + * device, call DeleteFocusClassDeviceStruct to free the FocusRec. + * + * If you support input devices with keys that you do not want to be + * used as the X keyboard, you need to check for them here and return + * a BadDevice error. + * + * The default implementation is to do nothing (assume you do want + * clients to be able to focus the old X keyboard). The commented-out + * sample code shows what you might do if you don't want the default. + * + *********************************************************************** + */ + +int +ChangeKeyboardDevice (old_dev, new_dev) + DeviceIntPtr old_dev; + DeviceIntPtr new_dev; +{ + /********************************************************************** + * DeleteFocusClassDeviceStruct(old_dev); * defined in xchgptr.c * + **********************************************************************/ + return !Success; +} + + +/*********************************************************************** + * + * Caller: ProcXChangePointerDevice + * + * This procedure does the implementation-dependent portion of the work + * needed to change the pointer device. + * + * The X pointer device does not have a FocusRec. If the device that + * has been made into the new X pointer had a FocusRec, + * ProcXChangePointerDevice will free it. + * + * If you want clients to be able to focus the old pointer device that + * has now become accessible through the input extension, you need to + * add a FocusRec to it here. + * + * The XChangePointerDevice protocol request also allows the client + * to choose which axes of the new pointer device are used to move + * the X cursor in the X- and Y- directions. If the axes are different + * than the default ones, you need to keep track of that here. + * + * If you support input devices with valuators that you do not want to be + * used as the X pointer, you need to check for them here and return a + * BadDevice error. + * + * The default implementation is to do nothing (assume you don't want + * clients to be able to focus the old X pointer). The commented-out + * sample code shows what you might do if you don't want the default. + * + *********************************************************************** + */ + +int +#ifdef NeedFunctionPrototypes +ChangePointerDevice ( + DeviceIntPtr old_dev, + DeviceIntPtr new_dev, + unsigned char x, + unsigned char y) +#else +ChangePointerDevice (old_dev, new_dev, x, y) + DeviceIntPtr old_dev, new_dev; + unsigned char x, y; +#endif /* NeedFunctionPrototypes */ +{ + /************************************************************************ + InitFocusClassDeviceStruct(old_dev); * allow focusing old ptr* + + x_axis = x; * keep track of new x-axis* + y_axis = y; * keep track of new y-axis* + if (x_axis != 0 || y_axis != 1) + axes_changed = TRUE; * remember axes have changed* + else + axes_changed = FALSE; + *************************************************************************/ + /* + * We don't allow axis swap or other exotic features. + */ + if (x == 0 && y == 1) { + LocalDevicePtr old_local = (LocalDevicePtr)old_dev->public.devicePrivate; + LocalDevicePtr new_local = (LocalDevicePtr)new_dev->public.devicePrivate; + + InitFocusClassDeviceStruct(old_dev); + + /* Restore Extended motion history information */ + old_dev->valuator->GetMotionProc = old_local->motion_history_proc; + old_dev->valuator->numMotionEvents = old_local->history_size; + + /* Save Extended motion history information */ + new_local->motion_history_proc = new_dev->valuator->GetMotionProc; + new_local->history_size = new_dev->valuator->numMotionEvents; + + /* Set Core motion history information */ + new_dev->valuator->GetMotionProc = miPointerGetMotionEvents; + new_dev->valuator->numMotionEvents = miPointerGetMotionBufferSize(); + + return Success; + } + else + return !Success; +} + + +/*********************************************************************** + * + * Caller: ProcXCloseDevice + * + * Take care of implementation-dependent details of closing a device. + * Some implementations may actually close the device, others may just + * remove this clients interest in that device. + * + * The default implementation is to do nothing (assume all input devices + * are initialized during X server initialization and kept open). + * + *********************************************************************** + */ + +void +CloseInputDevice (d, client) + DeviceIntPtr d; + ClientPtr client; +{ + ErrorF("ProcXCloseDevice to close or not ?\n"); +} + + +/*********************************************************************** + * + * Caller: ProcXListInputDevices + * + * This is the implementation-dependent routine to initialize an input + * device to the point that information about it can be listed. + * Some implementations open all input devices when the server is first + * initialized, and never close them. Other implementations open only + * the X pointer and keyboard devices during server initialization, + * and only open other input devices when some client makes an + * XOpenDevice request. If some other process has the device open, the + * server may not be able to get information about the device to list it. + * + * This procedure should be used by implementations that do not initialize + * all input devices at server startup. It should do device-dependent + * initialization for any devices not previously initialized, and call + * AddInputDevice for each of those devices so that a DeviceIntRec will be + * created for them. + * + * The default implementation is to do nothing (assume all input devices + * are initialized during X server initialization and kept open). + * The commented-out sample code shows what you might do if you don't want + * the default. + * + *********************************************************************** + */ + +void +AddOtherInputDevices () +{ +} + + +/**************************************************************************** + * + * Caller: ProcXSetDeviceMode + * + * Change the mode of an extension device. + * This function is used to change the mode of a device from reporting + * relative motion to reporting absolute positional information, and + * vice versa. + * The default implementation below is that no such devices are supported. + * + *********************************************************************** + */ + +int +SetDeviceMode (client, dev, mode) + register ClientPtr client; + DeviceIntPtr dev; + int mode; +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + + if (local->switch_mode) { + return (*local->switch_mode)(client, dev, mode); + } + else + return BadMatch; +} + + +/*********************************************************************** + * + * Caller: ProcXSetDeviceValuators + * + * Set the value of valuators on an extension input device. + * This function is used to set the initial value of valuators on + * those input devices that are capable of reporting either relative + * motion or an absolute position, and allow an initial position to be set. + * The default implementation below is that no such devices are supported. + * + *********************************************************************** + */ + +int +SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators) + register ClientPtr client; + DeviceIntPtr dev; + int *valuators; + int first_valuator; + int num_valuators; +{ + return BadMatch; +} + + +/*********************************************************************** + * + * Caller: ProcXChangeDeviceControl + * + * Change the specified device controls on an extension input device. + * + *********************************************************************** + */ + +int +ChangeDeviceControl (client, dev, control) + register ClientPtr client; + DeviceIntPtr dev; + xDeviceCtl *control; +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + + if (!local->control_proc) { + return (BadMatch); + } + else { + return (*local->control_proc)(local, control); + } +} + +/* + * adapted from mieq.c to support extended events + * + */ +extern InputInfo inputInfo; + +#define QUEUE_SIZE 256 + +typedef struct _Event { + xEvent event; +#ifdef XINPUT + deviceValuator val; +#endif + ScreenPtr pScreen; +} EventRec, *EventPtr; + +typedef struct _EventQueue { + HWEventQueueType head, tail; + CARD32 lastEventTime; /* to avoid time running backwards */ + Bool lastMotion; + EventRec events[QUEUE_SIZE]; /* static allocation for signals */ + DevicePtr pKbd, pPtr; /* device pointer, to get funcs */ + ScreenPtr pEnqueueScreen; /* screen events are being delivered to */ + ScreenPtr pDequeueScreen; /* screen events are being dispatched to */ +} EventQueueRec, *EventQueuePtr; + +static EventQueueRec xf86EventQueue; + +Bool +xf86eqInit (pKbd, pPtr) + DevicePtr pKbd, pPtr; +{ + xf86EventQueue.head = xf86EventQueue.tail = 0; + xf86EventQueue.lastEventTime = GetTimeInMillis (); + xf86EventQueue.pKbd = pKbd; + xf86EventQueue.pPtr = pPtr; + xf86EventQueue.lastMotion = FALSE; + xf86EventQueue.pEnqueueScreen = screenInfo.screens[0]; + xf86EventQueue.pDequeueScreen = xf86EventQueue.pEnqueueScreen; + SetInputCheck (&xf86EventQueue.head, &xf86EventQueue.tail); + return TRUE; +} + +/* + * Must be reentrant with ProcessInputEvents. Assumption: xf86eqEnqueue + * will never be interrupted. If this is called from both signal + * handlers and regular code, make sure the signal is suspended when + * called from regular code. + */ + +void +xf86eqEnqueue (e) + xEvent *e; +{ + int oldtail, newtail; + Bool isMotion; +#ifdef XINPUT + int count; + + switch (e->u.u.type) + { + case KeyPress: + case KeyRelease: + case ButtonPress: + case ButtonRelease: + case MotionNotify: + count = 1; + break; + default: + if (!((deviceKeyButtonPointer *) e)->deviceid & MORE_EVENTS) + { + count = 1; + } + else + { + count = 2; + } + break; + } +#endif + + oldtail = xf86EventQueue.tail; + isMotion = e->u.u.type == MotionNotify; + if (isMotion && xf86EventQueue.lastMotion && oldtail != xf86EventQueue.head) + { + if (oldtail == 0) + oldtail = QUEUE_SIZE; + oldtail = oldtail - 1; + } + else + { + newtail = oldtail + 1; + if (newtail == QUEUE_SIZE) + newtail = 0; + /* Toss events which come in late */ + if (newtail == xf86EventQueue.head) + return; + xf86EventQueue.tail = newtail; + } + + xf86EventQueue.lastMotion = isMotion; + xf86EventQueue.events[oldtail].event = *e; +#ifdef XINPUT + if (count == 2) + { + xf86EventQueue.events[oldtail].val = *((deviceValuator *) (((deviceKeyButtonPointer *) e)+1)); + } +#endif + /* + * Make sure that event times don't go backwards - this + * is "unnecessary", but very useful + */ + if (e->u.keyButtonPointer.time < xf86EventQueue.lastEventTime && + xf86EventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) + { + xf86EventQueue.events[oldtail].event.u.keyButtonPointer.time = + xf86EventQueue.lastEventTime; + } + xf86EventQueue.events[oldtail].pScreen = xf86EventQueue.pEnqueueScreen; +} + +/* + * Call this from ProcessInputEvents() + */ +void +xf86eqProcessInputEvents () +{ + EventRec *e; + int x, y; + xEvent xe; +#ifdef XINPUT + DeviceIntPtr dev; + int id, count; + deviceKeyButtonPointer *dev_xe; +#endif + + while (xf86EventQueue.head != xf86EventQueue.tail) + { + if (screenIsSaved == SCREEN_SAVER_ON) + SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset); +#ifdef DPMSExtension + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(DPMSModeOn); +#endif + + e = &xf86EventQueue.events[xf86EventQueue.head]; + /* + * Assumption - screen switching can only occur on motion events + */ + if (e->pScreen != xf86EventQueue.pDequeueScreen) + { + xf86EventQueue.pDequeueScreen = e->pScreen; + x = e->event.u.keyButtonPointer.rootX; + y = e->event.u.keyButtonPointer.rootY; + if (xf86EventQueue.head == QUEUE_SIZE - 1) + xf86EventQueue.head = 0; + else + ++xf86EventQueue.head; + NewCurrentScreen (xf86EventQueue.pDequeueScreen, x, y); + } + else + { + xe = e->event; + if (xf86EventQueue.head == QUEUE_SIZE - 1) + xf86EventQueue.head = 0; + else + ++xf86EventQueue.head; + switch (xe.u.u.type) + { + case KeyPress: + case KeyRelease: + (*xf86EventQueue.pKbd->processInputProc) + (&xe, (DeviceIntPtr)xf86EventQueue.pKbd, 1); + break; +#ifdef XINPUT + case ButtonPress: + case ButtonRelease: + case MotionNotify: + (*(inputInfo.pointer->public.processInputProc)) + (&xe, (DeviceIntPtr)inputInfo.pointer, 1); + break; + + default: + dev_xe = (deviceKeyButtonPointer *) e; + id = dev_xe->deviceid & DEVICE_BITS; + if (!(dev_xe->deviceid & MORE_EVENTS)) { + count = 1; + } else { + count = 2; + } + dev = LookupDeviceIntRec(id); + if (dev == NULL) + { + ErrorF("LookupDeviceIntRec id=0x%x not found\n", id); +/* FatalError("xf86eqProcessInputEvents : device not found.\n"); + */ + break; + } + if (!dev->public.processInputProc) + { + FatalError("xf86eqProcessInputEvents : device has no input proc.\n"); + break; + } + (*dev->public.processInputProc)(&e->event, dev, count); +#else + default: + (*xf86EventQueue.pPtr->processInputProc) + (&xe, (DeviceIntPtr)xf86EventQueue.pPtr, 1); +#endif + break; + } + } + } +} + +/* + * convenient functions to post events + */ + +void +xf86PostMotionEvent(DeviceIntPtr device, + int is_absolute, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int loop; + xEvent xE[2]; + deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE; + deviceValuator *xv = (deviceValuator*) xev+1; + LocalDevicePtr local = (LocalDevicePtr)device->public.devicePrivate; + char *buff; + Time current = GetTimeInMillis(); + + if (HAS_MOTION_HISTORY(local)) { + buff = ((char *)local->motion_history + + (sizeof(INT32) * local->dev->valuator->numAxes + sizeof(Time)) * local->last); + } else + buff = 0; + + va_start(var, num_valuators); + + for(loop=0; loop<num_valuators; loop++) { + switch (loop % 6) { + case 0: + xv->valuator0 = va_arg(var, int); + break; + case 1: + xv->valuator1 = va_arg(var, int); + break; + case 2: + xv->valuator2 = va_arg(var, int); + break; + case 3: + xv->valuator3 = va_arg(var, int); + break; + case 4: + xv->valuator4 = va_arg(var, int); + break; + case 5: + xv->valuator5 = va_arg(var, int); + break; + } + if ((loop % 6 == 5) || (loop == num_valuators - 1)) { + if (!xf86IsCorePointer(device)) { + xev->type = DeviceMotionNotify; + xev->detail = 0; + xf86Info.lastEventTime = xev->time = current; + xev->deviceid = device->id | MORE_EVENTS; + + xv->type = DeviceValuator; + xv->deviceid = device->id; + + xv->num_valuators = (loop % 6) + 1; + xv->first_valuator = first_valuator + (loop / 6) * 6; + xv->device_state = 0; + + if (HAS_MOTION_HISTORY(local)) { + *(Time*)buff = current; + memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator, &xv->valuator0, + sizeof(INT32)*xv->num_valuators); + } + + xf86eqEnqueue(xE); + } else { + xf86Info.lastEventTime = current; + + if (num_valuators >= 2) { + if (is_absolute) { + miPointerAbsoluteCursor(xv->valuator0, xv->valuator1, xf86Info.lastEventTime); + } else { + if (device->ptrfeed) { + /* modeled from xf86Events.c */ + if ((abs(xv->valuator0) + abs(xv->valuator1)) >= device->ptrfeed->ctrl.threshold) { + xv->valuator0 = (xv->valuator0 * device->ptrfeed->ctrl.num) / device->ptrfeed->ctrl.den; + xv->valuator1 = (xv->valuator1 * device->ptrfeed->ctrl.num) / device->ptrfeed->ctrl.den; + } + } + miPointerDeltaCursor(xv->valuator0, xv->valuator1, xf86Info.lastEventTime); + } + } + break; + } + } + va_end(var); + } + if (HAS_MOTION_HISTORY(local)) { + local->last = (local->last + 1) % device->valuator->numMotionEvents; + if (local->last == local->first) + local->first = (local->first + 1) % device->valuator->numMotionEvents; + } +} + +void +xf86PostProximityEvent(DeviceIntPtr device, + int is_in, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int loop; + xEvent xE[2]; + deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE; + deviceValuator *xv = (deviceValuator*) xev+1; + + va_start(var, num_valuators); + + for(loop=0; loop<num_valuators; loop++) { + switch (loop % 6) { + case 0: + xv->valuator0 = va_arg(var, int); + break; + case 1: + xv->valuator1 = va_arg(var, int); + break; + case 2: + xv->valuator2 = va_arg(var, int); + break; + case 3: + xv->valuator3 = va_arg(var, int); + break; + case 4: + xv->valuator4 = va_arg(var, int); + break; + case 5: + xv->valuator5 = va_arg(var, int); + break; + } + if ((loop % 6 == 5) || (loop == num_valuators - 1)) { + xev->type = is_in ? ProximityIn : ProximityOut; + xev->detail = 0; + xf86Info.lastEventTime = xev->time = GetTimeInMillis(); + xev->deviceid = device->id | MORE_EVENTS; + + xv->type = DeviceValuator; + xv->deviceid = device->id; + + xv->num_valuators = (loop % 6) + 1; + xv->first_valuator = first_valuator + (loop / 6) * 6; + xv->device_state = 0; + + xf86eqEnqueue(xE); + } + } + va_end(var); +} + +void +xf86PostButtonEvent(DeviceIntPtr device, + int is_absolute, + int button, + int is_down, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int loop; + xEvent xE[2]; + deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE; + deviceValuator *xv = (deviceValuator*) xev+1; + int is_core_pointer = xf86IsCorePointer(device); + + /* Check the core pointer button state not to send an inconsistent + * event. This can happen with the AlwaysCore feature. + */ + if (is_core_pointer && !xf86CheckButton(button, is_down)) { + return; + } + + va_start(var, num_valuators); + + + for(loop=0; loop<num_valuators; loop++) { + switch (loop % 6) { + case 0: + xv->valuator0 = va_arg(var, int); + break; + case 1: + xv->valuator1 = va_arg(var, int); + break; + case 2: + xv->valuator2 = va_arg(var, int); + break; + case 3: + xv->valuator3 = va_arg(var, int); + break; + case 4: + xv->valuator4 = va_arg(var, int); + break; + case 5: + xv->valuator5 = va_arg(var, int); + break; + } + if (((loop % 6 == 5) || (loop == num_valuators - 1)) && + !is_core_pointer) { + xev->type = is_down ? DeviceButtonPress : DeviceButtonRelease; + xev->detail = button; + + xf86Info.lastEventTime = xev->time = GetTimeInMillis(); + xev->deviceid = device->id | MORE_EVENTS; + + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->device_state = 0; + /* if the device is in the relative mode we don't have to send valuators */ + xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0; + xv->first_valuator = first_valuator + (loop / 6) * 6; + xf86eqEnqueue(xE); + /* if the device is in the relative mode only one event is needed */ + if (!is_absolute) break; + } + if (is_core_pointer && loop == 1) { + int cx, cy; + + GetSpritePosition(&cx, &cy); + + /* Try to find the index in the core buttons map + * which corresponds to the extended button for + * an AlwaysCore device. + */ + if (xf86IsAlwaysCore(device)) { + int loop; + + button = device->button->map[button]; + + for(loop=1; loop<=inputInfo.pointer->button->numButtons; loop++) { + if (inputInfo.pointer->button->map[loop] == button) { + button = loop; + break; + } + } + } + + xE->u.u.type = is_down ? ButtonPress : ButtonRelease; + xE->u.u.detail = button; + xE->u.keyButtonPointer.rootY = cx; + xE->u.keyButtonPointer.rootX = cy; + xf86Info.lastEventTime = xE->u.keyButtonPointer.time = GetTimeInMillis(); + xf86eqEnqueue(xE); + break; + } + } + va_end(var); +} + +void +xf86PostKeyEvent(DeviceIntPtr device, + unsigned int key_code, + int is_down, + int is_absolute, + int first_valuator, + int num_valuators, + ...) +{ + va_list var; + int loop; + xEvent xE[2]; + deviceKeyButtonPointer *xev = (deviceKeyButtonPointer*) xE; + deviceValuator *xv = (deviceValuator*) xev+1; + + va_start(var, num_valuators); + + + for(loop=0; loop<num_valuators; loop++) { + switch (loop % 6) { + case 0: + xv->valuator0 = va_arg(var, int); + break; + case 1: + xv->valuator1 = va_arg(var, int); + break; + case 2: + xv->valuator2 = va_arg(var, int); + break; + case 3: + xv->valuator3 = va_arg(var, int); + break; + case 4: + xv->valuator4 = va_arg(var, int); + break; + case 5: + xv->valuator5 = va_arg(var, int); + break; + } + if (((loop % 6 == 5) || (loop == num_valuators - 1))) { + xev->type = is_down ? DeviceKeyPress : DeviceKeyRelease; + xev->detail = key_code; + + xf86Info.lastEventTime = xev->time = GetTimeInMillis(); + xev->deviceid = device->id | MORE_EVENTS; + + xv->type = DeviceValuator; + xv->deviceid = device->id; + xv->device_state = 0; + /* if the device is in the relative mode we don't have to send valuators */ + xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0; + xv->first_valuator = first_valuator + (loop / 6) * 6; + + xf86eqEnqueue(xE); + /* if the device is in the relative mode only one event is needed */ + if (!is_absolute) break; + } + } + va_end(var); +} + +/* + * Motion history management. + */ + +void +xf86MotionHistoryAllocate(LocalDevicePtr local) +{ + ValuatorClassPtr valuator = local->dev->valuator; + + if (!HAS_MOTION_HISTORY(local)) + return; + + local->motion_history = xalloc((sizeof(INT32) * valuator->numAxes + sizeof(Time)) + * valuator->numMotionEvents); + local->first = 0; + local->last = 0; +} + +int +xf86GetMotionEvents(DeviceIntPtr dev, + xTimecoord *buff, + unsigned long start, + unsigned long stop, + ScreenPtr pScreen) +{ + LocalDevicePtr local = (LocalDevicePtr)dev->public.devicePrivate; + ValuatorClassPtr valuator = dev->valuator; + int num = 0; + int loop = local->first; + int size; + Time current; + + if (!HAS_MOTION_HISTORY(local)) + return 0; + + size = (sizeof(INT32) * valuator->numAxes + sizeof(Time)); + + while (loop != local->last) { + current = *(Time*)(((char *)local->motion_history)+loop*size); + if (current > stop) + return num; + if (current >= start) { + memcpy(((char *)buff)+size*num, + ((char *)local->motion_history)+loop*size, size); + num++; + } + loop = (loop + 1) % valuator->numMotionEvents; + } + return num; +} + +/* end of xf86Xinput.c */ diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h new file mode 100644 index 000000000..b2bb8832f --- /dev/null +++ b/hw/xfree86/common/xf86Xinput.h @@ -0,0 +1,280 @@ +/* $Xorg: xf86Xinput.h,v 1.3 2000/08/17 19:50:31 cpqbld Exp $ */ +/* + * Copyright 1995,1996 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.h,v 3.14.2.1 1997/05/12 12:52:29 hohndel Exp $ */ + +#ifndef _xf86Xinput_h +#define _xf86Xinput_h + +#ifndef NEED_EVENTS +#define NEED_EVENTS +#endif +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "XI.h" +#include "XIproto.h" +#include "XIstubs.h" + +#define XI86_NO_OPEN_ON_INIT 1 /* open the device only when needed */ +#define XI86_CONFIGURED 2 /* the device has been configured */ +#define XI86_ALWAYS_CORE 4 /* the device always controls the pointer */ + +#ifdef PRIVATE +#undef PRIVATE +#endif +#define PRIVATE(dev) (((LocalDevicePtr)((dev)->public.devicePrivate))->private) + +#ifdef HAS_MOTION_HISTORY +#undef HAS_MOTION_HISTORY +#endif +#define HAS_MOTION_HISTORY(local) ((local)->dev->valuator && (local)->dev->valuator->numMotionEvents) + +typedef struct _LocalDeviceRec { + char *name; + int flags; + Bool (*device_config)( +#if NeedNestedPrototypes + struct _LocalDeviceRec** /*array*/, + int /*index*/, + int /*max*/, + LexPtr /*val*/ +#endif + ); + Bool (*device_control)( +#if NeedNestedPrototypes + DeviceIntPtr /*device*/, + int /*what*/ +#endif + ); + void (*read_input)( +#if NeedNestedPrototypes + struct _LocalDeviceRec* /*local*/ +#endif + ); + int (*control_proc)( +#if NeedNestedPrototypes + struct _LocalDeviceRec* /*local*/, + xDeviceCtl* /* control */ +#endif + ); + void (*close_proc)( +#if NeedNestedPrototypes + struct _LocalDeviceRec* /*local*/ +#endif + ); + int (*switch_mode)( +#if NeedNestedPrototypes + ClientPtr /*client*/, + DeviceIntPtr /*dev*/, + int /*mode*/ +#endif + ); + int fd; + Atom atom; + DeviceIntPtr dev; + pointer private; + int private_flags; + pointer motion_history; + ValuatorMotionProcPtr motion_history_proc; + unsigned int history_size; /* only for configuration purpose */ + unsigned int first; + unsigned int last; + char *type_name; + IntegerFeedbackPtr always_core_feedback; +} LocalDeviceRec, *LocalDevicePtr; + +typedef struct _DeviceAssocRec +{ + char *config_section_name; + LocalDevicePtr (*device_allocate)( +#if NeedNestedPrototypes + void +#endif +); +} DeviceAssocRec, *DeviceAssocPtr; + +extern int DeviceKeyPress; +extern int DeviceKeyRelease; +extern int DeviceButtonPress; +extern int DeviceButtonRelease; +extern int DeviceMotionNotify; +extern int DeviceValuator; +extern int ProximityIn; +extern int ProximityOut; + +extern int +xf86IsCorePointer( +#if NeedFunctionPrototypes + DeviceIntPtr /*dev*/ +#endif +); + +extern int +xf86IsCoreKeyboard( +#if NeedFunctionPrototypes + DeviceIntPtr /*dev*/ +#endif +); + +extern void +xf86AlwaysCore( +#if NeedFunctionPrototypes + LocalDevicePtr /*local*/, + Bool /*always*/ +#endif +); + +void +xf86configExtendedInputSection( +#ifdef NeedFunctionPrototypes + LexPtr /* val */ +#endif +); + +void +xf86AddDeviceAssoc( +#ifdef NeedFunctionPrototypes + DeviceAssocPtr /* assoc */ +#endif +); + +void +InitExtInput( +#ifdef NeedFunctionPrototypes + void +#endif +); + +Bool +xf86eqInit ( +#ifdef NeedFunctionPrototypes + DevicePtr /* pKbd */, + DevicePtr /* pPtr */ +#endif +); + +void +xf86eqEnqueue ( +#ifdef NeedFunctionPrototypes + struct _xEvent * /*event */ +#endif +); + +void +xf86eqProcessInputEvents ( +#ifdef NeedFunctionPrototypes + void +#endif +); + +void +xf86PostMotionEvent( +#if NeedVarargsPrototypes + DeviceIntPtr /*device*/, + int /*is_absolute*/, + int /*first_valuator*/, + int /*num_valuators*/, + ... +#endif +); + +void +xf86PostProximityEvent( +#if NeedVarargsPrototypes + DeviceIntPtr /*device*/, + int /*is_in*/, + int /*first_valuator*/, + int /*num_valuators*/, + ... +#endif +); + +void +xf86PostButtonEvent( +#if NeedVarargsPrototypes + DeviceIntPtr /*device*/, + int /*is_absolute*/, + int /*button*/, + int /*is_down*/, + int /*first_valuator*/, + int /*num_valuators*/, + ... +#endif +); + +void +xf86PostKeyEvent( +#if NeedVarargsPrototypes + DeviceIntPtr device, + unsigned int key_code, + int is_down, + int is_absolute, + int first_valuator, + int num_valuators, + ... +#endif +); + +void +xf86AddDeviceAssoc( +#if NeedFunctionPrototypes + DeviceAssocPtr /*assoc*/ +#endif +); + +void +xf86MotionHistoryAllocate( +#if NeedFunctionPrototypes + LocalDevicePtr local +#endif +); + +int +xf86GetMotionEvents( +#if NeedFunctionPrototypes + DeviceIntPtr dev, + xTimecoord *buff, + unsigned long start, + unsigned long stop, + ScreenPtr pScreen +#endif +); + +void +xf86XinputFinalizeInit( +#if NeedFunctionPrototypes + DeviceIntPtr dev +#endif +); + +Bool +xf86CheckButton( +#if NeedFunctionPrototypes + int button, + int down +#endif +); + +#endif /* _xf86Xinput_h */ diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c new file mode 100644 index 000000000..8abab86a5 --- /dev/null +++ b/hw/xfree86/dixmods/extmod/xf86vmode.c @@ -0,0 +1,1429 @@ +/* $XFree86: xc/programs/Xserver/Xext/xf86vmode.c,v 3.25 1996/10/16 14:37:58 dawes Exp $ */ + +/* + +Copyright 1995 Kaleb S. KEITHLEY + +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 Kaleb S. KEITHLEY 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 Kaleb S. KEITHLEY +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +from Kaleb S. KEITHLEY + +*/ +/* $Xorg: xf86vmode.c,v 1.3 2000/08/17 19:47:59 cpqbld Exp $ */ +/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ + +#define NEED_REPLIES +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "misc.h" +#include "dixstruct.h" +#include "extnsionst.h" +#include "scrnintstr.h" +#include "servermd.h" +#define _XF86VIDMODE_SERVER_ +#include "xf86vmstr.h" +#include "Xfuncproto.h" +#include "../hw/xfree86/common/xf86.h" +#include "../hw/xfree86/common/xf86Priv.h" + +extern int xf86ScreenIndex; +extern Bool xf86VidModeEnabled; +extern Bool xf86VidModeAllowNonLocal; + +static int vidmodeErrorBase; + +static int ProcXF86VidModeDispatch( +#if NeedFunctionPrototypes + ClientPtr /* client */ +#endif +); + +static int SProcXF86VidModeDispatch( +#if NeedFunctionPrototypes + ClientPtr /* client */ +#endif +); + +static void XF86VidModeResetProc( +#if NeedFunctionPrototypes + ExtensionEntry* /* extEntry */ +#endif +); + +extern void Swap32Write(); /* XXX should be in header file */ + +static unsigned char XF86VidModeReqCode = 0; + +/* The XF86VIDMODE_EVENTS code is far from complete */ + +#ifdef XF86VIDMODE_EVENTS +static int XF86VidModeEventBase = 0; + +static void SXF86VidModeNotifyEvent(); +#if NeedFunctionPrototypes + xXF86VidModeNotifyEvent * /* from */, + xXF86VidModeNotifyEvent * /* to */ +#endif +); + +extern WindowPtr *WindowTable; + +static RESTYPE EventType; /* resource type for event masks */ + +typedef struct _XF86VidModeEvent *XF86VidModeEventPtr; + +typedef struct _XF86VidModeEvent { + XF86VidModeEventPtr next; + ClientPtr client; + ScreenPtr screen; + XID resource; + CARD32 mask; +} XF86VidModeEventRec; + +static int XF86VidModeFreeEvents(); + +typedef struct _XF86VidModeScreenPrivate { + XF86VidModeEventPtr events; + Bool hasWindow; +} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr; + +static int ScreenPrivateIndex; + +#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr) +#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v); +#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s) + +#define New(t) ((t *) xalloc (sizeof (t))) +#endif + +void +XFree86VidModeExtensionInit() +{ + ExtensionEntry* extEntry; +#ifdef XF86VIDMODE_EVENTS + int i; + ScreenPtr pScreen; + + EventType = CreateNewResourceType(XF86VidModeFreeEvents); + ScreenPrivateIndex = AllocateScreenPrivateIndex (); + for (i = 0; i < screenInfo.numScreens; i++) + { + pScreen = screenInfo.screens[i]; + SetScreenPrivate (pScreen, NULL); + } +#endif + + if ( +#ifdef XF86VIDMODE_EVENTS + EventType && ScreenPrivateIndex != -1 && +#endif + (extEntry = AddExtension(XF86VIDMODENAME, + XF86VidModeNumberEvents, + XF86VidModeNumberErrors, + ProcXF86VidModeDispatch, + SProcXF86VidModeDispatch, + XF86VidModeResetProc, + StandardMinorOpcode))) { + XF86VidModeReqCode = (unsigned char)extEntry->base; + vidmodeErrorBase = extEntry->errorBase; +#ifdef XF86VIDMODE_EVENTS + XF86VidModeEventBase = extEntry->eventBase; + EventSwapVector[XF86VidModeEventBase] = SXF86VidModeNotifyEvent; +#endif + } +} + +/*ARGSUSED*/ +static void +XF86VidModeResetProc (extEntry) + ExtensionEntry* extEntry; +{ +} + +#ifdef XF86VIDMODE_EVENTS +static void +CheckScreenPrivate (pScreen) + ScreenPtr pScreen; +{ + SetupScreen (pScreen); + + if (!pPriv) + return; + if (!pPriv->events && !pPriv->hasWindow) { + xfree (pPriv); + SetScreenPrivate (pScreen, NULL); + } +} + +static XF86VidModeScreenPrivatePtr +MakeScreenPrivate (pScreen) + ScreenPtr pScreen; +{ + SetupScreen (pScreen); + + if (pPriv) + return pPriv; + pPriv = New (XF86VidModeScreenPrivateRec); + if (!pPriv) + return 0; + pPriv->events = 0; + pPriv->hasWindow = FALSE; + SetScreenPrivate (pScreen, pPriv); + return pPriv; +} + +static unsigned long +getEventMask (pScreen, client) + ScreenPtr pScreen; + ClientPtr client; +{ + SetupScreen(pScreen); + XF86VidModeEventPtr pEv; + + if (!pPriv) + return 0; + for (pEv = pPriv->events; pEv; pEv = pEv->next) + if (pEv->client == client) + return pEv->mask; + return 0; +} + +static Bool +setEventMask (pScreen, client, mask) + ScreenPtr pScreen; + ClientPtr client; + unsigned long mask; +{ + SetupScreen(pScreen); + XF86VidModeEventPtr pEv, *pPrev; + + if (getEventMask (pScreen, client) == mask) + return TRUE; + if (!pPriv) { + pPriv = MakeScreenPrivate (pScreen); + if (!pPriv) + return FALSE; + } + for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next) + if (pEv->client == client) + break; + if (mask == 0) { + *pPrev = pEv->next; + xfree (pEv); + CheckScreenPrivate (pScreen); + } else { + if (!pEv) { + pEv = New (ScreenSaverEventRec); + if (!pEv) { + CheckScreenPrivate (pScreen); + return FALSE; + } + *pPrev = pEv; + pEv->next = NULL; + pEv->client = client; + pEv->screen = pScreen; + pEv->resource = FakeClientID (client->index); + } + pEv->mask = mask; + } + return TRUE; +} + +static int +XF86VidModeFreeEvents (value, id) + pointer value; + XID id; +{ + XF86VidModeEventPtr pOld = (XF86VidModeEventPtr)value; + ScreenPtr pScreen = pOld->screen; + SetupScreen (pScreen); + XF86VidModeEventPtr pEv, *pPrev; + + if (!pPriv) + return TRUE; + for (pPrev = &pPriv->events; pEv = *pPrev; pPrev = &pEv->next) + if (pEv == pOld) + break; + if (!pEv) + return TRUE; + *pPrev = pEv->next; + xfree (pEv); + CheckScreenPrivate (pScreen); + return TRUE; +} + +static void +SendXF86VidModeNotify (pScreen, state, forced) + ScreenPtr pScreen; + int state; + Bool forced; +{ + XF86VidModeScreenPrivatePtr pPriv; + XF86VidModeEventPtr pEv; + unsigned long mask; + xXF86VidModeNotifyEvent ev; + ClientPtr client; + int kind; + + UpdateCurrentTimeIf (); + mask = XF86VidModeNotifyMask; + pScreen = screenInfo.screens[pScreen->myNum]; + pPriv = GetScreenPrivate(pScreen); + if (!pPriv) + return; + kind = XF86VidModeModeChange; + for (pEv = pPriv->events; pEv; pEv = pEv->next) + { + client = pEv->client; + if (client->clientGone) + continue; + if (!(pEv->mask & mask)) + continue; + ev.type = XF86VidModeNotify + XF86VidModeEventBase; + ev.state = state; + ev.sequenceNumber = client->sequence; + ev.timestamp = currentTime.milliseconds; + ev.root = WindowTable[pScreen->myNum]->drawable.id; + ev.kind = kind; + ev.forced = forced; + WriteEventsToClient (client, 1, (xEvent *) &ev); + } +} + +static void +SXF86VidModeNotifyEvent (from, to) + xXF86VidModeNotifyEvent *from, *to; +{ + to->type = from->type; + to->state = from->state; + cpswaps (from->sequenceNumber, to->sequenceNumber); + cpswapl (from->timestamp, to->timestamp); + cpswapl (from->root, to->root); + to->kind = from->kind; + to->forced = from->forced; +} +#endif + +static int +ProcXF86VidModeQueryVersion(client) + register ClientPtr client; +{ + xXF86VidModeQueryVersionReply rep; + register int n; + + REQUEST_SIZE_MATCH(xXF86VidModeQueryVersionReq); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.majorVersion = XF86VIDMODE_MAJOR_VERSION; + rep.minorVersion = XF86VIDMODE_MINOR_VERSION; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.majorVersion, n); + swaps(&rep.minorVersion, n); + } + WriteToClient(client, sizeof(xXF86VidModeQueryVersionReply), (char *)&rep); + return (client->noClientException); +} + +static int +ProcXF86VidModeGetModeLine(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeGetModeLineReq); + xXF86VidModeGetModeLineReply rep; + register int n; + ScrnInfoPtr vptr; + DisplayModePtr mptr; + int privsize; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + mptr = vptr->modes; + + if (!mptr->Private) + privsize = 0; + else + privsize = mptr->PrivSize; + + REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); + rep.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeGetModeLineReply) - SIZEOF(xGenericReply) + + privsize * sizeof(INT32)) >> 2; + rep.sequenceNumber = client->sequence; + rep.dotclock = vptr->clock[mptr->Clock]; + rep.hdisplay = mptr->HDisplay; + rep.hsyncstart = mptr->HSyncStart; + rep.hsyncend = mptr->HSyncEnd; + rep.htotal = mptr->HTotal; + rep.vdisplay = mptr->VDisplay; + rep.vsyncstart = mptr->VSyncStart; + rep.vsyncend = mptr->VSyncEnd; + rep.vtotal = mptr->VTotal; + rep.flags = mptr->Flags; + rep.privsize = privsize; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.dotclock, n); + swaps(&rep.hdisplay, n); + swaps(&rep.hsyncstart, n); + swaps(&rep.hsyncend, n); + swaps(&rep.htotal, n); + swaps(&rep.vdisplay, n); + swaps(&rep.vsyncstart, n); + swaps(&rep.vsyncend, n); + swaps(&rep.vtotal, n); + swapl(&rep.flags, n); + swapl(&rep.privsize, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetModeLineReply), (char *)&rep); + if (privsize) { + client->pSwapReplyFunc = Swap32Write; + WriteSwappedDataToClient(client, privsize * sizeof(INT32), + mptr->Private); + } + return (client->noClientException); +} + +static int +ProcXF86VidModeGetAllModeLines(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeGetAllModeLinesReq); + xXF86VidModeGetAllModeLinesReply rep; + xXF86VidModeModeInfo mdinf; + register int n; + ScrnInfoPtr vptr; + DisplayModePtr mptr, curmptr; + int privsize, modecount=1; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + curmptr = mptr = vptr->modes; + + while (mptr->next != curmptr) { + ++modecount; + mptr = mptr->next; + } + + REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq); + rep.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeGetAllModeLinesReply) - SIZEOF(xGenericReply) + + modecount * sizeof(xXF86VidModeModeInfo)) >> 2; + rep.sequenceNumber = client->sequence; + rep.modecount = modecount; + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.modecount, n); + } + WriteToClient(client, sizeof(xXF86VidModeGetAllModeLinesReply), (char *)&rep); + mptr = curmptr; + do { + if (!mptr->Private) + privsize = 0; + else + privsize = mptr->PrivSize; + + mdinf.dotclock = vptr->clock[mptr->Clock]; + mdinf.hdisplay = mptr->HDisplay; + mdinf.hsyncstart = mptr->HSyncStart; + mdinf.hsyncend = mptr->HSyncEnd; + mdinf.htotal = mptr->HTotal; + mdinf.vdisplay = mptr->VDisplay; + mdinf.vsyncstart = mptr->VSyncStart; + mdinf.vsyncend = mptr->VSyncEnd; + mdinf.vtotal = mptr->VTotal; + mdinf.flags = mptr->Flags; + mdinf.privsize = privsize; + if (client->swapped) { + swapl(&mdinf.dotclock, n); + swaps(&mdinf.hdisplay, n); + swaps(&mdinf.hsyncstart, n); + swaps(&mdinf.hsyncend, n); + swaps(&mdinf.htotal, n); + swaps(&mdinf.vdisplay, n); + swaps(&mdinf.vsyncstart, n); + swaps(&mdinf.vsyncend, n); + swaps(&mdinf.vtotal, n); + swapl(&mdinf.flags, n); + swapl(&mdinf.privsize, n); + } + WriteToClient(client, sizeof(xXF86VidModeModeInfo), (char *)&mdinf); + mptr = mptr->next; + } while (mptr != curmptr); + return (client->noClientException); +} + +#define CLOCKSPD(clk,scrp) ((clk>MAXCLOCKS)? clk: scrp->clock[clk]) +#define MODEMATCH(mptr,stuff,scrp) \ + (CLOCKSPD(mptr->Clock,scrp) == CLOCKSPD(stuff->dotclock,scrp) \ + && mptr->HDisplay == stuff->hdisplay \ + && mptr->HSyncStart== stuff->hsyncstart \ + && mptr->HSyncEnd == stuff->hsyncend \ + && mptr->HTotal == stuff->htotal \ + && mptr->VDisplay == stuff->vdisplay \ + && mptr->VSyncStart== stuff->vsyncstart \ + && mptr->VSyncEnd == stuff->vsyncend \ + && mptr->VTotal == stuff->vtotal \ + && mptr->Flags == stuff->flags ) + +static int +ProcXF86VidModeAddModeLine(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeAddModeLineReq); + ScrnInfoPtr vptr; + DisplayModePtr curmptr, mptr, newmptr; + DisplayModeRec modetmp; + int len; + + if (xf86Verbose) { + ErrorF("AddModeLine - scrn: %d clock: %d\n", + stuff->screen, stuff->dotclock); + ErrorF("AddModeLine - hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, stuff->flags); + ErrorF(" after - scrn: %d clock: %d\n", + stuff->screen, stuff->after_dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->after_hdisplay, stuff->after_hsyncstart, + stuff->after_hsyncend, stuff->after_htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + stuff->after_vdisplay, stuff->after_vsyncstart, + stuff->after_vsyncend, stuff->after_vtotal, stuff->after_flags); + } + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + curmptr = mptr = vptr->modes; + + REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeAddModeLineReq) >> 2); + if (len != stuff->privsize) + return BadLength; + + if (stuff->hsyncstart < stuff->hdisplay || + stuff->hsyncend < stuff->hsyncstart || + stuff->htotal < stuff->hsyncend || + stuff->vsyncstart < stuff->vdisplay || + stuff->vsyncend < stuff->vsyncstart || + stuff->vtotal < stuff->vsyncend) + return BadValue; + + if (stuff->after_hsyncstart < stuff->after_hdisplay || + stuff->after_hsyncend < stuff->after_hsyncstart || + stuff->after_htotal < stuff->after_hsyncend || + stuff->after_vsyncstart < stuff->after_vdisplay || + stuff->after_vsyncend < stuff->after_vsyncstart || + stuff->after_vtotal < stuff->after_vsyncend) + return BadValue; + + if (stuff->after_htotal != 0 || stuff->after_vtotal != 0) { + Bool found = FALSE; + do { + if (MODEMATCH(mptr, stuff, vptr)) { + found = TRUE; + break; + } + } while ((mptr = mptr->next) != curmptr); + if (!found) + return BadValue; + } + + newmptr = (DisplayModePtr) xalloc(sizeof(DisplayModeRec)); + + newmptr->Clock = stuff->dotclock; + newmptr->CrtcHDisplay = newmptr->HDisplay = stuff->hdisplay; + newmptr->CrtcHSyncStart= newmptr->HSyncStart = stuff->hsyncstart; + newmptr->CrtcHSyncEnd = newmptr->HSyncEnd = stuff->hsyncend; + newmptr->CrtcHTotal = newmptr->HTotal = stuff->htotal; + newmptr->CrtcVDisplay = newmptr->VDisplay = stuff->vdisplay; + newmptr->CrtcVSyncStart= newmptr->VSyncStart = stuff->vsyncstart; + newmptr->CrtcVSyncEnd = newmptr->VSyncEnd = stuff->vsyncend; + newmptr->CrtcVTotal = newmptr->VTotal = stuff->vtotal; + newmptr->Flags = stuff->flags; +#if 0 + newmptr->CrtcHSkew = newmptr->HSkew = stuff->hskew; +#endif + newmptr->CrtcHAdjusted = FALSE; + newmptr->CrtcVAdjusted = FALSE; + newmptr->name = ""; + newmptr->Private = NULL; + if (stuff->privsize) { + if (xf86Verbose) + ErrorF("AddModeLine - Request includes privates\n"); + newmptr->Private = + (INT32 *) ALLOCATE_LOCAL(stuff->privsize * sizeof(INT32)); + memcpy(newmptr->Private, &stuff[1], stuff->privsize*sizeof(INT32)); + } + + /* Check that the mode is consistent with the monitor specs */ + switch (xf86CheckMode(vptr, newmptr, vptr->monitor, FALSE)) { + case MODE_HSYNC: + xfree(newmptr->Private); + xfree(newmptr); + return vidmodeErrorBase + XF86VidModeBadHTimings; + case MODE_VSYNC: + xfree(newmptr->Private); + xfree(newmptr); + return vidmodeErrorBase + XF86VidModeBadVTimings; + } + + /* Check that the driver is happy with the mode */ + if (vptr->ValidMode(newmptr, xf86Verbose, MODE_VID) != MODE_OK) { + xfree(newmptr->Private); + xfree(newmptr); + return vidmodeErrorBase + XF86VidModeModeUnsuitable; + } + + if (newmptr->Flags & V_DBLSCAN) + { + newmptr->CrtcVDisplay *= 2; + newmptr->CrtcVSyncStart *= 2; + newmptr->CrtcVSyncEnd *= 2; + newmptr->CrtcVTotal *= 2; + newmptr->CrtcVAdjusted = TRUE; + } + + newmptr->next = mptr->next; + newmptr->prev = mptr; + mptr->next = newmptr; + newmptr->next->prev = newmptr; + +#if 0 /* Do we want this? */ + (vptr->SwitchMode)(newmptr); +#endif + + if (xf86Verbose) + ErrorF("AddModeLine - Succeeded\n"); + return(client->noClientException); +} + +static int +ProcXF86VidModeDeleteModeLine(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeDeleteModeLineReq); + ScrnInfoPtr vptr; + DisplayModePtr curmptr, mptr; + DisplayModeRec modetmp; + int len; + + if (xf86Verbose) { + ErrorF("DeleteModeLine - scrn: %d clock: %d\n", + stuff->screen, stuff->dotclock, stuff->dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, stuff->flags); + } + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + curmptr = mptr = vptr->modes; + + REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeDeleteModeLineReq) >> 2); + if (len != stuff->privsize) { + ErrorF("req_len = %d, sizeof(Req) = %d, privsize = %d, len = %d, length = %d\n", + client->req_len, sizeof(xXF86VidModeDeleteModeLineReq)>>2, stuff->privsize, len, stuff->length); + return BadLength; + } + + ErrorF("Checking against clock: %d (%d)\n", + mptr->Clock, CLOCKSPD(mptr->Clock, vptr)); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + mptr->HDisplay, mptr->HSyncStart, + mptr->HSyncEnd, mptr->HTotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + mptr->VDisplay, mptr->VSyncStart, mptr->VSyncEnd, + mptr->VTotal, mptr->Flags); + if (MODEMATCH(mptr, stuff, vptr)) + return BadValue; + + while ((mptr = mptr->next) != curmptr) { + ErrorF("Checking against clock: %d (%d)\n", + mptr->Clock, CLOCKSPD(mptr->Clock, vptr)); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + mptr->HDisplay, mptr->HSyncStart, + mptr->HSyncEnd, mptr->HTotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + mptr->VDisplay, mptr->VSyncStart, mptr->VSyncEnd, + mptr->VTotal, mptr->Flags); + if (MODEMATCH(mptr, stuff, vptr)) { + mptr->prev->next = mptr->next; + mptr->next->prev = mptr->prev; + xfree(mptr->name); + xfree(mptr->Private); + xfree(mptr); + if (xf86Verbose) + ErrorF("DeleteModeLine - Succeeded\n"); + return(client->noClientException); + } + } + return BadValue; +} + +static int +ProcXF86VidModeModModeLine(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeModModeLineReq); + ScrnInfoPtr vptr; + DisplayModePtr mptr; + DisplayModeRec modetmp; + int len; + + if (xf86Verbose) { + ErrorF("ModModeLine - scrn: %d hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->screen, stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, stuff->flags); + } + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + mptr = vptr->modes; + + REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeModModeLineReq) >> 2); + if (len != stuff->privsize) + return BadLength; + + if (stuff->hsyncstart < stuff->hdisplay || + stuff->hsyncend < stuff->hsyncstart || + stuff->htotal < stuff->hsyncend || + stuff->vsyncstart < stuff->vdisplay || + stuff->vsyncend < stuff->vsyncstart || + stuff->vtotal < stuff->vsyncend) + return BadValue; + + memcpy(&modetmp, mptr, sizeof(DisplayModeRec)); + + modetmp.HDisplay = stuff->hdisplay; + modetmp.HSyncStart = stuff->hsyncstart; + modetmp.HSyncEnd = stuff->hsyncend; + modetmp.HTotal = stuff->htotal; + modetmp.VDisplay = stuff->vdisplay; + modetmp.VSyncStart = stuff->vsyncstart; + modetmp.VSyncEnd = stuff->vsyncend; + modetmp.VTotal = stuff->vtotal; + modetmp.Flags = stuff->flags; + if (mptr->PrivSize && stuff->privsize) { + if (mptr->PrivSize != stuff->privsize) + return BadValue; + } + if (mptr->PrivSize && mptr->Private) { + modetmp.Private = + (INT32 *)ALLOCATE_LOCAL(mptr->PrivSize * sizeof(INT32)); + if (stuff->privsize) { + if (xf86Verbose) + ErrorF("ModModeLine - Request includes privates\n"); + memcpy(modetmp.Private, &stuff[1], mptr->PrivSize * sizeof(INT32)); + } else + memcpy(modetmp.Private, mptr->Private, + mptr->PrivSize * sizeof(INT32)); + } + + /* Check that the mode is consistent with the monitor specs */ + switch (xf86CheckMode(vptr, &modetmp, vptr->monitor, FALSE)) { + case MODE_HSYNC: + DEALLOCATE_LOCAL(modetmp.Private); + return vidmodeErrorBase + XF86VidModeBadHTimings; + case MODE_VSYNC: + DEALLOCATE_LOCAL(modetmp.Private); + return vidmodeErrorBase + XF86VidModeBadVTimings; + } + + /* Check that the driver is happy with the mode */ + if (vptr->ValidMode(&modetmp, xf86Verbose, MODE_VID) != MODE_OK) { + DEALLOCATE_LOCAL(modetmp.Private); + return vidmodeErrorBase + XF86VidModeModeUnsuitable; + } + + DEALLOCATE_LOCAL(modetmp.Private); + + mptr->HDisplay = stuff->hdisplay; + mptr->HSyncStart = stuff->hsyncstart; + mptr->HSyncEnd = stuff->hsyncend; + mptr->HTotal = stuff->htotal; + mptr->VDisplay = stuff->vdisplay; + mptr->VSyncStart = stuff->vsyncstart; + mptr->VSyncEnd = stuff->vsyncend; + mptr->VTotal = stuff->vtotal; + mptr->Flags = stuff->flags; + mptr->CrtcHDisplay = stuff->hdisplay; + mptr->CrtcHSyncStart = stuff->hsyncstart; + mptr->CrtcHSyncEnd = stuff->hsyncend; + mptr->CrtcHTotal = stuff->htotal; + mptr->CrtcVDisplay = stuff->vdisplay; + mptr->CrtcVSyncStart = stuff->vsyncstart; + mptr->CrtcVSyncEnd = stuff->vsyncend; + mptr->CrtcVTotal = stuff->vtotal; + mptr->CrtcVAdjusted = FALSE; + mptr->CrtcHAdjusted = FALSE; + if (mptr->Flags & V_DBLSCAN) + { + mptr->CrtcVDisplay *= 2; + mptr->CrtcVSyncStart *= 2; + mptr->CrtcVSyncEnd *= 2; + mptr->CrtcVTotal *= 2; + mptr->CrtcVAdjusted = TRUE; + } + if (mptr->PrivSize && stuff->privsize) { + memcpy(mptr->Private, &stuff[1], mptr->PrivSize * sizeof(INT32)); + } + + (vptr->SwitchMode)(mptr); + (vptr->AdjustFrame)(vptr->frameX0, vptr->frameY0); + + if (xf86Verbose) + ErrorF("ModModeLine - Succeeded\n"); + return(client->noClientException); +} + +static int +ProcXF86VidModeValidateModeLine(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeValidateModeLineReq); + xXF86VidModeValidateModeLineReply rep; + ScrnInfoPtr vptr; + DisplayModePtr mptr; + DisplayModeRec modetmp; + int len, status; + + if (xf86Verbose) { + ErrorF("ValidateModeLine - scrn: %d clock: %d\n", + stuff->screen, stuff->dotclock, stuff->dotclock); + ErrorF(" hdsp: %d hbeg: %d hend: %d httl: %d\n", + stuff->hdisplay, stuff->hsyncstart, + stuff->hsyncend, stuff->htotal); + ErrorF(" vdsp: %d vbeg: %d vend: %d vttl: %d flags: %d\n", + stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, + stuff->vtotal, stuff->flags); + } + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + mptr = vptr->modes; + + REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); + len = client->req_len - (sizeof(xXF86VidModeValidateModeLineReq) >> 2); + if (len != stuff->privsize) + return BadLength; + + status = MODE_OK; + modetmp.Private = NULL; + + if (stuff->hsyncstart < stuff->hdisplay || + stuff->hsyncend < stuff->hsyncstart || + stuff->htotal < stuff->hsyncend || + stuff->vsyncstart < stuff->vdisplay || + stuff->vsyncend < stuff->vsyncstart || + stuff->vtotal < stuff->vsyncend) + { + status = MODE_BAD; + goto status_reply; + } + + memcpy(&modetmp, mptr, sizeof(DisplayModeRec)); + + modetmp.HDisplay = stuff->hdisplay; + modetmp.HSyncStart = stuff->hsyncstart; + modetmp.HSyncEnd = stuff->hsyncend; + modetmp.HTotal = stuff->htotal; + modetmp.VDisplay = stuff->vdisplay; + modetmp.VSyncStart = stuff->vsyncstart; + modetmp.VSyncEnd = stuff->vsyncend; + modetmp.VTotal = stuff->vtotal; + modetmp.Flags = stuff->flags; + modetmp.Private = NULL; + if (mptr->PrivSize && stuff->privsize) { + if (mptr->PrivSize != stuff->privsize) { + status = MODE_BAD; + goto status_reply; + } + } + if (mptr->PrivSize && mptr->Private) { + modetmp.Private = + (INT32 *)ALLOCATE_LOCAL(mptr->PrivSize * sizeof(INT32)); + if (stuff->privsize) { + if (xf86Verbose) + ErrorF("ValidateModeLine - Request includes privates\n"); + memcpy(modetmp.Private, &stuff[1], mptr->PrivSize * sizeof(INT32)); + } else + memcpy(modetmp.Private, mptr->Private, + mptr->PrivSize * sizeof(INT32)); + } + + /* Check that the mode is consistent with the monitor specs */ + if ((status = xf86CheckMode(vptr, &modetmp, vptr->monitor, FALSE)) != MODE_OK) + goto status_reply; + + /* Check that the driver is happy with the mode */ + status = vptr->ValidMode(&modetmp, xf86Verbose, MODE_VID); + +status_reply: + if (modetmp.Private) + DEALLOCATE_LOCAL(modetmp.Private); + rep.type = X_Reply; + rep.length = (SIZEOF(xXF86VidModeValidateModeLineReply) + - SIZEOF(xGenericReply)) >> 2; + rep.sequenceNumber = client->sequence; + rep.status = status; + if (client->swapped) { + register int n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.status, n); + } + WriteToClient(client, sizeof(xXF86VidModeValidateModeLineReply), (char *)&rep); + if (xf86Verbose) + ErrorF("ValidateModeLine - Succeeded\n"); + return(client->noClientException); +} + +static int +ProcXF86VidModeSwitchMode(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeSwitchModeReq); + ScreenPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = screenInfo.screens[stuff->screen]; + if (xf86Info.dontZoom) + return vidmodeErrorBase + XF86VidModeZoomLocked; + + REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq); + + xf86ZoomViewport(vptr, (short)stuff->zoom); + return (client->noClientException); +} + +static int +ProcXF86VidModeSwitchToMode(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeSwitchToModeReq); + ScrnInfoPtr vptr; + DisplayModePtr curmptr, mptr; + DisplayModeRec modetmp; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + if (xf86Info.dontZoom) + return vidmodeErrorBase + XF86VidModeZoomLocked; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + curmptr = mptr = vptr->modes; + + REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq); + + if (MODEMATCH(mptr, stuff, vptr)) + return (client->noClientException); + + while ((mptr = mptr->next) != curmptr) { + if (MODEMATCH(mptr, stuff, vptr)) { + if ((vptr->SwitchMode)(mptr)) { + vptr->modes = mptr; + vptr->frameX0 = (vptr->frameX1 +vptr->frameX0 -mptr->HDisplay)/2; + vptr->frameX1 = vptr->frameX0 + mptr->HDisplay -1; + if (vptr->frameX0 < 0) { + vptr->frameX0 = 0; + vptr->frameX1 = mptr->HDisplay -1; + } else if (vptr->frameX1 >= vptr->virtualX) { + vptr->frameX0 = vptr->virtualX - mptr->HDisplay; + vptr->frameX1 = vptr->frameX0 + mptr->HDisplay -1; + } + vptr->frameY0 = (vptr->frameY1 +vptr->frameY0 -mptr->VDisplay)/2; + vptr->frameY1 = vptr->frameY0 + mptr->VDisplay -1; + if (vptr->frameY0 < 0) { + vptr->frameY0 = 0; + vptr->frameY1 = mptr->VDisplay -1; + } else if (vptr->frameY1 >= vptr->virtualY) { + vptr->frameY0 = vptr->virtualY - mptr->VDisplay; + vptr->frameY1 = vptr->frameY0 + mptr->VDisplay -1; + } + } + (vptr->AdjustFrame)(vptr->frameX0, vptr->frameY0); + return(client->noClientException); + } + } + return BadValue; +} + +static int +ProcXF86VidModeLockModeSwitch(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeLockModeSwitchReq); + ScreenPtr vptr; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = screenInfo.screens[stuff->screen]; + if (xf86Info.dontZoom) + return vidmodeErrorBase + XF86VidModeZoomLocked; + + REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq); + + xf86LockZoom(vptr, (short)stuff->lock); + return (client->noClientException); +} + +static int +ProcXF86VidModeGetMonitor(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeGetMonitorReq); + xXF86VidModeGetMonitorReply rep; + register int n; + ScrnInfoPtr vptr; + MonPtr mptr; + CARD32 *hsyncdata, *vsyncdata; + int i; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + mptr = vptr->monitor; + + REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq); + rep.type = X_Reply; + if (mptr->vendor) + rep.vendorLength = strlen(mptr->vendor); + else + rep.vendorLength = 0; + if (mptr->model) + rep.modelLength = strlen(mptr->model); + else + rep.modelLength = 0; + rep.length = (SIZEOF(xXF86VidModeGetMonitorReply) - SIZEOF(xGenericReply) + + (mptr->n_hsync + mptr->n_vrefresh) * sizeof(CARD32) + + ((rep.vendorLength + 3) & ~3) + + ((rep.modelLength + 3) & ~3)) >> 2; + rep.sequenceNumber = client->sequence; + rep.nhsync = mptr->n_hsync; + rep.nvsync = mptr->n_vrefresh; +#if 0 + rep.bandwidth = (unsigned long)(mptr->bandwidth * 1e6); +#endif + hsyncdata = ALLOCATE_LOCAL(mptr->n_hsync * sizeof(CARD32)); + if (!hsyncdata) { + return BadAlloc; + } + vsyncdata = ALLOCATE_LOCAL(mptr->n_vrefresh * sizeof(CARD32)); + if (!vsyncdata) { + DEALLOCATE_LOCAL(hsyncdata); + return BadAlloc; + } + for (i = 0; i < mptr->n_hsync; i++) { + hsyncdata[i] = (unsigned short)(mptr->hsync[i].lo * 100.0) | + (unsigned short)(mptr->hsync[i].hi * 100.0) << 16; + } + for (i = 0; i < mptr->n_vrefresh; i++) { + vsyncdata[i] = (unsigned short)(mptr->vrefresh[i].lo * 100.0) | + (unsigned short)(mptr->vrefresh[i].hi * 100.0) << 16; + } + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.bandwidth, n); + } + WriteToClient(client, SIZEOF(xXF86VidModeGetMonitorReply), (char *)&rep); + client->pSwapReplyFunc = Swap32Write; + WriteSwappedDataToClient(client, mptr->n_hsync * sizeof(CARD32), + hsyncdata); + WriteSwappedDataToClient(client, mptr->n_vrefresh * sizeof(CARD32), + vsyncdata); + if (rep.vendorLength) + WriteToClient(client, rep.vendorLength, mptr->vendor); + if (rep.modelLength) + WriteToClient(client, rep.modelLength, mptr->model); + DEALLOCATE_LOCAL(hsyncdata); + DEALLOCATE_LOCAL(vsyncdata); + return (client->noClientException); +} + +static int +ProcXF86VidModeGetViewPort(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeGetViewPortReq); + xXF86VidModeGetViewPortReply rep; + register int n; + ScrnInfoPtr vptr; + MonPtr mptr; + CARD32 *hsyncdata, *vsyncdata; + int i; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + mptr = vptr->monitor; + + REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); + rep.type = X_Reply; + return (client->noClientException); +} + +static int +ProcXF86VidModeSetViewPort(client) + register ClientPtr client; +{ + REQUEST(xXF86VidModeSetViewPortReq); + register int n; + ScrnInfoPtr vptr; + MonPtr mptr; + CARD32 *hsyncdata, *vsyncdata; + int i; + + if (stuff->screen > screenInfo.numScreens) + return BadValue; + + vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr; + mptr = vptr->monitor; + + REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq); + return (client->noClientException); +} + +static int +ProcXF86VidModeDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86VidModeQueryVersion: + return ProcXF86VidModeQueryVersion(client); + case X_XF86VidModeGetModeLine: + return ProcXF86VidModeGetModeLine(client); + case X_XF86VidModeGetAllModeLines: + return ProcXF86VidModeGetAllModeLines(client); + case X_XF86VidModeGetMonitor: + return ProcXF86VidModeGetMonitor(client); + case X_XF86VidModeValidateModeLine: + return ProcXF86VidModeValidateModeLine(client); + case X_XF86VidModeGetViewPort: + return ProcXF86VidModeGetViewPort(client); + default: + if (!xf86VidModeEnabled) + return vidmodeErrorBase + XF86VidModeExtensionDisabled; + if (xf86VidModeAllowNonLocal || LocalClient (client)) { + switch (stuff->data) { + case X_XF86VidModeAddModeLine: + return ProcXF86VidModeAddModeLine(client); + case X_XF86VidModeDeleteModeLine: + return ProcXF86VidModeDeleteModeLine(client); + case X_XF86VidModeModModeLine: + return ProcXF86VidModeModModeLine(client); + case X_XF86VidModeSwitchMode: + return ProcXF86VidModeSwitchMode(client); + case X_XF86VidModeSwitchToMode: + return ProcXF86VidModeSwitchToMode(client); + case X_XF86VidModeLockModeSwitch: + return ProcXF86VidModeLockModeSwitch(client); + case X_XF86VidModeSetViewPort: + return ProcXF86VidModeSetViewPort(client); + default: + return BadRequest; + } + } else + return vidmodeErrorBase + XF86VidModeClientNotLocal; + } +} + +static int +SProcXF86VidModeQueryVersion(client) + register ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeQueryVersionReq); + swaps(&stuff->length, n); + return ProcXF86VidModeQueryVersion(client); +} + +static int +SProcXF86VidModeGetModeLine(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeGetModeLineReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetModeLineReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetModeLine(client); +} + +static int +SProcXF86VidModeGetAllModeLines(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeGetAllModeLinesReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetAllModeLinesReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetAllModeLines(client); +} + +static int +SProcXF86VidModeAddModeLine(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeAddModeLineReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + return ProcXF86VidModeAddModeLine(client); +} + +static int +SProcXF86VidModeDeleteModeLine(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeDeleteModeLineReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + return ProcXF86VidModeDeleteModeLine(client); +} + +static int +SProcXF86VidModeModModeLine(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeModModeLineReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + return ProcXF86VidModeModModeLine(client); +} + +static int +SProcXF86VidModeValidateModeLine(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeValidateModeLineReq); + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq); + swapl(&stuff->screen, n); + swaps(&stuff->hdisplay, n); + swaps(&stuff->hsyncstart, n); + swaps(&stuff->hsyncend, n); + swaps(&stuff->htotal, n); + swaps(&stuff->vdisplay, n); + swaps(&stuff->vsyncstart, n); + swaps(&stuff->vsyncend, n); + swaps(&stuff->vtotal, n); + swapl(&stuff->flags, n); + swapl(&stuff->privsize, n); + SwapRestL(stuff); + return ProcXF86VidModeValidateModeLine(client); +} + +static int +SProcXF86VidModeSwitchMode(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeSwitchModeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSwitchModeReq); + swaps(&stuff->screen, n); + swaps(&stuff->zoom, n); + return ProcXF86VidModeSwitchMode(client); +} + +static int +SProcXF86VidModeSwitchToMode(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeSwitchToModeReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSwitchToModeReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeSwitchToMode(client); +} + +static int +SProcXF86VidModeLockModeSwitch(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeLockModeSwitchReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeLockModeSwitchReq); + swaps(&stuff->screen, n); + swaps(&stuff->lock, n); + return ProcXF86VidModeLockModeSwitch(client); +} + +static int +SProcXF86VidModeGetMonitor(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeGetMonitorReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetMonitorReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetMonitor(client); +} + +static int +SProcXF86VidModeGetViewPort(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeGetViewPortReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeGetViewPortReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeGetViewPort(client); +} + +static int +SProcXF86VidModeSetViewPort(client) + ClientPtr client; +{ + register int n; + REQUEST(xXF86VidModeSetViewPortReq); + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH(xXF86VidModeSetViewPortReq); + swaps(&stuff->screen, n); + return ProcXF86VidModeSetViewPort(client); +} + +static int +SProcXF86VidModeDispatch (client) + register ClientPtr client; +{ + REQUEST(xReq); + switch (stuff->data) + { + case X_XF86VidModeQueryVersion: + return SProcXF86VidModeQueryVersion(client); + case X_XF86VidModeGetModeLine: + return SProcXF86VidModeGetModeLine(client); + case X_XF86VidModeGetAllModeLines: + return SProcXF86VidModeGetAllModeLines(client); + case X_XF86VidModeGetMonitor: + return SProcXF86VidModeGetMonitor(client); + case X_XF86VidModeGetViewPort: + return SProcXF86VidModeGetViewPort(client); + case X_XF86VidModeValidateModeLine: + return SProcXF86VidModeValidateModeLine(client); + default: + if (!xf86VidModeEnabled) + return vidmodeErrorBase + XF86VidModeExtensionDisabled; + if (xf86VidModeAllowNonLocal || LocalClient(client)) { + switch (stuff->data) { + case X_XF86VidModeAddModeLine: + return SProcXF86VidModeAddModeLine(client); + case X_XF86VidModeDeleteModeLine: + return SProcXF86VidModeDeleteModeLine(client); + case X_XF86VidModeModModeLine: + return SProcXF86VidModeModModeLine(client); + case X_XF86VidModeSwitchMode: + return SProcXF86VidModeSwitchMode(client); + case X_XF86VidModeSwitchToMode: + return SProcXF86VidModeSwitchToMode(client); + case X_XF86VidModeLockModeSwitch: + return SProcXF86VidModeLockModeSwitch(client); + case X_XF86VidModeSetViewPort: + return SProcXF86VidModeSetViewPort(client); + default: + return BadRequest; + } + } else + return vidmodeErrorBase + XF86VidModeClientNotLocal; + } +} diff --git a/hw/xfree86/os-support/README.OS-lib b/hw/xfree86/os-support/README.OS-lib new file mode 100644 index 000000000..cf3a0cc7e --- /dev/null +++ b/hw/xfree86/os-support/README.OS-lib @@ -0,0 +1,437 @@ + + README for XFree86 OS-support Layer + ----------------------------------- + +Contents +-------- + 1) Overview + 2) Directory Layout + 3) Adding a new OS + 4) OS Support API + +1 - Overview +------------ + This directory contains the OS support layer functions for the XFree86 +servers. In addition, some miscellaneous server support functions (not +OS-dependent) are included here, to take advantage of the fact that this +library comes last in the linking order. + +Most of the functionality required to support a new OS is encapsulated in +this library. It is hoped that all OS-specific details can be encapsulated, +but that is not likely ever to be completely possible. Hence some minor +changes will wind up being made in other parts of the server. The major +design principles for this library are maintainability, readability, and +portability. Sometimes these goals conflict; some somewhat arbitrary choices +have been made in implementation. + +2 - Directory Layout +-------------------- + os-support/ Contains headers and documentation; no code + misc/ Non-OS-specific miscellaneous functions that + fit best into the link architecture this way. + shared/ Contains files with functions used by more than one + OS. These are symlinked into the OS subdirectories + at build time via Imakefile rules. This is alway + preferable to reproducing functions in more than one + OS library. + amoeba/ OS support for the Amoeba operating system. + bsd/ OS support for the 386BSD/NetBSD/FreeBSD operating + systems. + bsdi/ OS support for the BSD/386 operating system. + linux/ OS support for the Linux operating system. + mach/ OS support for the Mach and OSF/1 operating systems. + minix/ OS support for the Minix operating system. + os2/ OS support for OS/2 2.11 and OS/2 Warp + sco/ OS support for the SCO SVR3.x operating system. + solx86/ OS support for the Solaris x86 operating system. + sysv/ OS support for all SVR4.0 and SVR4.2, and for + ISC and AT&T SVR3.2 operating systems. + +3 - Adding A New OS +------------------- + Adding a support for a new operating system entails implementing all of +the functions described in the API below. Many of these functions are no-ops +for many operating systems, and appropriate files with dummy declarations are +available in the 'shared' subdirectory. + +If your OS is sufficiently similar to an existing OS, you can make use of +the existing subdirectory. One of the reasons for implementing this OS +library was the unmaintainability of the spagetti-#ifdef code that existed +before. You should try to avoid cluttering the code with #ifdef's. If +you find that the subdirectory is getting cluttered, split off into a +seperate subdirectory (e.g. as was done for SCO, rather than cluttering +the 'sysv' subdirectory). You can split functions out of an existing +subdirectory into the 'shared' subdirectory, if that is appropriate. Just +remember to update the Imakefile for the old subdirectory. + +You will still likely have to make some small changes to other parts of +the server. You should not put OS-specific #define's or #include's anywhere +else in the server. These should all go in the "xf86_OSlib.h" header file +in this directory. + +4 - OS Support API +----------------- +void xf86OpenConsole(void) +{ + /* + * Open console device, activate VTs, etc, etc. Fill in requisite + * pieces of x386Info. Most of this code comes from x386Init.c + */ +} + +void xf86CloseConsole(void) +{ + /* + * Close console at server exit. + */ +} + +Bool xf86VTSwitchPending(void) +{ + /* + * Returns TRUE iff there is a VT switch operation pending for + * the server. In the USL VT model, this is indicated via a + * signal handler. Should return FALSE always for OSs without + * VTs. + */ +} + +Bool xf86VTSwitchAway(void) +{ + /* + * Handles the OS-specific action for switching away from the active + * VT. Returns FALSE if the switch away fails. Should return + * FALSE always for OSs without VTs (then again, this function + * should never be called in that case). + */ +} + +Bool xf86VTSwitchTo(void) +{ + /* + * Handles the OS-specific action for switching to the active VT. + * Returns FALSE if the switch to fails. Should return TRUE + * always for OSs without VTs (then again, this function should + * never be called in that case). + */ +} + +Bool xf86LinearVidMem(void) +{ + /* + * Returns TRUE if the OS supports mapping linear frame buffers + * (ie memory at addresses above physical memory). + */ +} + +pointer xf86MapVidMem(int ScreenNum, int Region, pointer Base, + unsigned long Size) +{ + /* + * Handle mapping the video memory. Returns (pointer *)0 for + * failure; causes server exit. It is allowable to call FatalError() + * from inside this function and exit directly. + */ +} + +void xf86UnMapVidMem(int ScreenNum, int Region, pointer Base, + unsigned long Size) +{ + /* + * Handle unmapping the video memory. This should undo what + * xf86MapVidMem() does. Base is a pointer obtained from + * a previous call to xf86MapVidMem(). + */ +} + +void xf86MapDisplay(int ScreenNum, int Region) +{ + /* + * For OSs that require the screen be mapped when entering a VT. + * A dummy function will be defined for OSs that don't require + * this (or don't have VTs at all). + */ +} + +void xf86UnMapDisplay(int ScreenNum, int Region) +{ + /* + * For Os that require that the screen be unmapped when leaving a + * VT. A dummy function will be defined for OSs that don't require + * this (or don't have VTs at all). + */ +} + +int xf86ReadBIOS(unsigned long Base, unsigned long Offset, + unsigned char *Buf, int Len) +{ + /* + * Read Len bytes from the BIOS at address Base, offset Offset, + * into buffer Buf. Returns -1 for failure or if the OS does + * not support reading the BIOS. This causes a driver probe + * to fail, but does not cause the server to abort. + */ +} + +void xf86ClearIOPortList(int ScreenNum) +{ + /* + * Clears any list of I/O ports that the OS-layer may be maintaining. + * Note: the value used for ScreenNum must be the scrnIndex field + * of the screenInfoRec, because this is the only index that is + * guaranteed to be valid and never change during the life of the + * server. It is not the same as the index of pScreen in ScreenInfo. + */ +} + +void xf86AddIOPorts(int ScreenNum, int NumPorts, unsigned *Ports) +{ + /* + * Adds NumPorts I/O ports listed in array Ports to a list that + * the OS-layer may be maintaining. Successive calls to this + * function are cumulative. + */ +} + +void xf86EnableIOPorts(int ScreenNum) +{ + /* + * Enables I/O permissions. The OS layer can either use a + * previously created list of I/O ports to be used, or can + * enable all I/O port access. + */ +} + +void xf86DisableIOPorts(int ScreenNum) +{ + /* + * Disables I/O permissions. Does not clear the list of I/O + * ports, if any exists. + */ +} + +void xf86DisableIOPrivs(void) +{ + /* + * Do whatever is necessary to disable I/O permissions after forking + * a child process. + */ +} + +Bool xf86DisableInterrupts(void) +{ + /* + * Disable interrupts if allowed for this OS. Returns FALSE if + * this is not allowed or if the attempt fails for some reason. + */ +} + +void xf86EnableInterrupts(void) +{ + /* + * Reenable interrupts + */ +} + +int xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Process OS-specific command-line arguments. See + * ddxProcessArgument() for more info. + */ +} + +void xf86UseMsg(void) +{ + /* + * Print list of OS-specific command-line arguments. See + * ddxUseMsg() for more info. + */ +} + +void xf86SoundKbdBell(int loudness, int pitch, int duration) +{ + /* + * Sound the keyboard bell. pitch is in Hz, duration in ms, + * loudness is in the range 0-100 (0 -> off). For systems + * where the loudness can't be controlled, scale the duration + * by loudness/50. + */ +} + +void xf86SetKbdLeds(int leds) +{ + /* + * Set the keyboard LEDs to the state indicated in leds + */ +} + +int xf86GetKbdLeds(void) +{ + /* + * Return the state of the keyboard LEDs. If the OS doesn't + * support this, return 0. + */ +} + +void xf86SetKbdRepeat(char rad) +{ + /* + * Set the keyboard repeat rate and delay according the + * the rad value. The lower 5 bits determine the repeat + * rate (lower value -> higher rate). The next 2 bits + * determine the delay. + * This should possibly be changed to take separate rate and + * delay parameters. + */ +} + +void xf86KbdInit(void) +{ + /* + * Save initial keyboard state. This is called at the start of + * each server generation. + */ +} + +int xf86KbdOn(void) +{ + /* + * Set the keyboard up for use with X. This is called whenever + * the server becomes active (ie at the start of each generation and + * whenever its VT becomes active). Return the file descriptor + * for keyboard input. Return -1 if there is no file descriptor + * to add as an input device. If there are errors encountered, + * call FatalError(). A return value of -1 is not considered an + * error condition. + */ +} + +int xf86KbdOff(void) +{ + /* + * Return the keyboard to the state saved by xf86KbdInit(). This is + * called at the end of a server generation, and also when the + * server's VT ceases being active. Returns the keyboard file + * descriptor. Returns -1 if there is no file descriptor to be + * removed as an input device. Errors should be handled the same + * way as in xf86KbdOn(). + */ +} + +void xf86KbdEvents(void) +{ + /* + * Read characters from the keyboard device, and post the events + * by calling x386PostKbdEvent(). Read as much as is available + * without waiting. + */ +} + +void xf86SetMouseSpeed(int old, int new, unsigned cflag) +{ + /* + * Set the speed of the mouse port. old is the previous speed, + * new is the new speed, and cflag is the value of the termio[s] + * c_cflag field. For mice that have programmable speed operation, + * this should send the appropriate commands to the mouse. + */ +} + +void xf86MouseInit(void) +{ + /* + * This is called at the start of each server generation. In most + * cases this is a noop. If the mouse must not be opened/closed + * when VT switching, the open should be done here. + */ +} + +int xf86MousedOn(void) +{ + /* + * Set the mouse up for use with X. This is called whenever + * the server becomes active (ie at the start of each generation and + * whenever its VT becomes active). This function normally opens + * the mouse device, and may call xf86SetupMouse() to initialise + * the mouse parameters. Return the file descriptor for mouse input. + * Return -1 if there is no file descriptor to add as an input + * device. If there are errors encountered, call FatalError(). + * A return value of -1 is not considered an error condition. + */ +} + +int xf86MouseOff(Bool doclose) +{ + /* + * Release the mouse from use with X. This is called at the end + * of a server generation (with doclose==TRUE), and also when the + * server's VT ceases being active (with doclose==FALSE). If the + * mouse should not be opened/closed when VT switching, the close + * should be done here when doclose==TRUE. For other systems, the + * mouse device should be closed regardless of the doclose value. + * Returns the mouse file descriptor. Returns -1 if there is no + * file descriptor to be removed as an input device. Errors + * should be handled the same way as in xf86MouseOn(). + */ +} + +void xf86MouseEvents(void) +{ + /* + * Read characters from the mouse device, and post the events + * by calling x386PostMseEvent(). Read as much as is available + * without waiting. If the OS doesn't handle the mouse protocol + * translation, xf86MouseProtocol() may be called to do the + * translation and event posting. If the OS does handle the protocol + * translation, MOUSE_PROTOCOL_IN_KERNEL should be #define'd in + * xf86_OSlib.h. + */ +} + +int xf86OsMouseProc(DevicePtr pPointer, int what) +{ + /* + * Implements the device-proc for the pointer device when an + * OS-based mouse driver is being used (as opposed to the + * server's internal mouse driver). Implemented as any other + * device-proc in the server. + * + * This function only needs to be implemented if USE_OSMOUSE is + * defined for the OS. + */ +} + +int xf86OsMouseEvents(void) +{ + /* + * When supporting an OS-based mouse driver (as opposed to the + * server's internal mouse driver), read some events from the device + * and post them to the DIX layer through x386PostMseEvent(). + * + * This function only needs to be implemented if USE_OSMOUSE is + * defined for the OS. + */ +} + +void xf86OsMouseOption(int token, pointer lex_ptr) +{ + /* + * Used in parsing an OsMouse keyword from the Xconfig file. + * Passed the token type and a pointer to the token value. + * The function should do whatever is appropriate for the OS's + * mouse driver. + * + * This function only needs to be implemented if USE_OSMOUSE is + * defined for the OS. + */ +} + + +$XFree86: xc/programs/Xserver/hw/xfree86/os-support/README.OS-lib,v 3.2 1996/12/23 06:48:59 dawes Exp $ + + + + + +$Xorg: README.OS-lib,v 1.3 2000/08/17 19:51:19 cpqbld Exp $ diff --git a/hw/xfree86/os-support/assyntax.h b/hw/xfree86/os-support/assyntax.h new file mode 100644 index 000000000..ee2c23fa4 --- /dev/null +++ b/hw/xfree86/os-support/assyntax.h @@ -0,0 +1,725 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/assyntax.h,v 3.7.2.2 1997/05/11 02:56:22 dawes Exp $ */ +#ifndef __ASSYNTAX_H__ +#define __ASSYNTAX_H__ + +/* + * Copyright 1992 Vrije Universiteit, The Netherlands + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose and without fee is hereby granted, provided + * that the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the Vrije Universiteit not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The Vrije Universiteit makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL The Vrije Universiteit BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* $Xorg: assyntax.h,v 1.3 2000/08/17 19:51:19 cpqbld Exp $ */ + + /* + * assyntax.h + * + * Select the syntax appropriate to the 386 assembler being used + * To add support for more assemblers add more columns to the CHOICE + * macro. Note that register names must also have uppercase names + * to avoid macro recursion. e.g., #define ah %ah recurses! + * + * NB 1. Some of the macros for certain assemblers imply that the code is to + * run in protected mode!! Caveat emptor. + * + * NB 2. 486 specific instructions are not included. This is to discourage + * their accidental use in code that is intended to run on 386 and 486 + * systems. + * + * Supported assemblers: + * + * (a) AT&T SysVr4 as(1): default + * (b) GNU Assembler gas: define USE_GAS or GNU_ASSEMBLER + * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER + * + * The following naming conventions have been used to identify the various + * data types: + * _SR = segment register version + * Integer: + * _Q = quadword = 64 bits + * _L = long = 32 bits + * _W = short = 16 bits + * _B = byte = 8 bits + * Floating-point: + * _X = m80real = 80 bits + * _D = double = 64 bits + * _S = single = 32 bits + * + * Author: Gregory J. Sharp, Sept 1992 + * Vrije Universiteit, Amsterdam, The Netherlands + */ + +#if defined(USE_GAS) && !defined(GNU_ASSEMBLER) +#define GNU_ASSEMBLER +#endif + +#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__)) +#define CONCAT(x, y) x ## y +#else +#define CONCAT(x, y) x/**/y +#endif + +#ifdef ACK_ASSEMBLER + +/* Assume we write code for 32-bit protected mode! */ + +/* Redefine register names for GAS & AT&T assemblers */ +#define AL al +#define AH ah +#define AX ax +#define EAX ax +#define BL bl +#define BH bh +#define BX bx +#define EBX bx +#define CL cl +#define CH ch +#define CX cx +#define ECX cx +#define DL dl +#define DH dh +#define DX dx +#define EDX dx +#define BP bp +#define EBP bp +#define SI si +#define ESI si +#define DI di +#define EDI di +#define SP sp +#define ESP sp +#define CS cs +#define SS ss +#define DS ds +#define ES es +#define FS fs +#define GS gs +/* Control Registers */ +#define CR0 cr0 +#define CR1 cr1 +#define CR2 cr2 +#define CR3 cr3 +/* Debug Registers */ +#define DR0 dr0 +#define DR1 dr1 +#define DR2 dr2 +#define DR3 dr3 +#define DR4 dr4 +#define DR5 dr5 +#define DR6 dr6 +#define DR7 dr7 +/* Floating-point Stack */ +#define ST st + +#define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text + + +#define _WTOG o16 /* word toggle for _W instructions */ +#define _LTOG /* long toggle for _L instructions */ +#define ADDR_TOGGLE a16 +#define OPSZ_TOGGLE o16 +#define USE16 .use16 +#define USE32 .use32 + +#define CHOICE(a,b,c) c + +#else /* AT&T or GAS */ + +/* Redefine register names for GAS & AT&T assemblers */ +#define AL %al +#define AH %ah +#define AX %ax +#define EAX %eax +#define BL %bl +#define BH %bh +#define BX %bx +#define EBX %ebx +#define CL %cl +#define CH %ch +#define CX %cx +#define ECX %ecx +#define DL %dl +#define DH %dh +#define DX %dx +#define EDX %edx +#define BP %bp +#define EBP %ebp +#define SI %si +#define ESI %esi +#define DI %di +#define EDI %edi +#define SP %sp +#define ESP %esp +#define CS %cs +#define SS %ss +#define DS %ds +#define ES %es +#define FS %fs +#define GS %gs +/* Control Registers */ +#define CR0 %cr0 +#define CR1 %cr1 +#define CR2 %cr2 +#define CR3 %cr3 +/* Debug Registers */ +#define DR0 %db0 +#define DR1 %db1 +#define DR2 %db2 +#define DR3 %db3 +#define DR4 %db4 +#define DR5 %db5 +#define DR6 %db6 +#define DR7 %db7 +/* Floating-point Stack */ +#define ST %st + +#define AS_BEGIN +#define USE16 +#define USE32 + +#ifdef GNU_ASSEMBLER + +#define ADDR_TOGGLE aword +#define OPSZ_TOGGLE word + +#define CHOICE(a,b,c) b + +#else +/* + * AT&T ASSEMBLER SYNTAX + * ********************* + */ +#define CHOICE(a,b,c) a + +#define ADDR_TOGGLE addr16 +#define OPSZ_TOGGLE data16 + +#endif /* GNU_ASSEMBLER */ +#endif /* ACK_ASSEMBLER */ + + +#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || (defined(linux) || defined(__OS2ELF__)) && defined(__ELF__) +#define GLNAME(a) a +#else +#define GLNAME(a) CONCAT(_,a) +#endif + + + /****************************************/ + /* */ + /* Select the various choices */ + /* */ + /****************************************/ + + +/* Redefine assembler directives */ +/*********************************/ +#define GLOBL CHOICE(.globl, .globl, .extern) +#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4) +#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2) +/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is + * guaranteed to be filled with NOPs. Otherwise it does nothing. + */ +#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/) +#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4) +#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2) +#define FILE(s) CHOICE(.file s, .file s, .file s) +#define STRING(s) CHOICE(.string s, .asciz s, .asciz s) +#define D_LONG CHOICE(.long, .long, .data4) +#define D_WORD CHOICE(.value, .short, .data2) +#define D_BYTE CHOICE(.byte, .byte, .data1) +#define SPACE CHOICE(.comm, .space, .space) +#define COMM CHOICE(.comm, .comm, .comm) +#define SEG_DATA CHOICE(.data, .data, .sect .data) +#define SEG_TEXT CHOICE(.text, .text, .sect .text) +#define SEG_BSS CHOICE(.bss, .bss, .sect .bss) + +#ifdef GNU_ASSEMBLER +#define D_SPACE(n) . = . + n +#else +#define D_SPACE(n) .space n +#endif + +/* Addressing Modes */ +/* Immediate Mode */ +#define ADDR(a) CHOICE(CONCAT($,a), CONCAT($,a), a) +#define CONST(a) CHOICE(CONCAT($,a), CONCAT($,a), a) + +/* Indirect Mode */ +#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */ +#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */ +/* Register b indirect plus displacement a */ +#define REGOFF(a, b) CHOICE(a(b), a(b), a(b)) +/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode + * which has no scaling + */ +#define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i)) +/* Reg indirect Base + (Index * Scale) + Displacement */ +#define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s)) +/* Displaced Scaled Index: */ +#define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s)) +/* Indexed Base: */ +#define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i)) +/* Displaced Base: */ +#define REGDB(d,b) CHOICE(d(b), d(b), d(b)) +/* Variable indirect: */ +#define VARINDIRECT(var) CHOICE(*var, *var, (var)) +/* Use register contents as jump/call target: */ +#define CODEPTR(reg) CHOICE(*reg, *reg, reg) + +/* For expressions requiring bracketing + * eg. (CRT0_PM | CRT_EM) + */ + +#define EXPR(a) CHOICE([a], (a), [a]) +#define ENOT(a) CHOICE(0!a, ~a, ~a) +#define EMUL(a,b) CHOICE(a\*b, a*b, a*b) +#define EDIV(a,b) CHOICE(a\/b, a/b, a/b) + +/* + * We have to beat the problem of commas within arguments to choice. + * eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI + * and other known cpp definitions evaluate arguments before substitution + * so the following works. + */ +#define ARG2(a, b) a,b +#define ARG3(a,b,c) a,b,c + +/* Redefine assembler commands */ +#define AAA CHOICE(aaa, aaa, aaa) +#define AAD CHOICE(aad, aad, aad) +#define AAM CHOICE(aam, aam, aam) +#define AAS CHOICE(aas, aas, aas) +#define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a)) +#define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a)) +#define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a)) +#define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a)) +#define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a)) +#define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a)) +#define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a)) +#define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a)) +#define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a)) +#define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a)) +#define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a)) +#define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a)) +#define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a)) +#define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a)) +#define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a)) +#define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a)) +#define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a)) +#define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a)) +#define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a)) +#define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a)) +#define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a)) +#define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a)) +#define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a)) +#define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a)) +#define CALL(a) CHOICE(call a, call a, call a) +#define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a) +#define CBW CHOICE(cbtw, cbw, cbw) +#define CWDE CHOICE(cwtd, cwde, cwde) +#define CLC CHOICE(clc, clc, clc) +#define CLD CHOICE(cld, cld, cld) +#define CLI CHOICE(cli, cli, cli) +#define CLTS CHOICE(clts, clts, clts) +#define CMC CHOICE(cmc, cmc, cmc) +#define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a)) +#define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a)) +#define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a)) +#define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps) +#define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps) +#define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb) +#define CWD CHOICE(cwtl, cwd, cwd) +#define CDQ CHOICE(cltd, cdq, cdq) +#define DAA CHOICE(daa, daa, daa) +#define DAS CHOICE(das, das, das) +#define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a) +#define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a) +#define DEC_B(a) CHOICE(decb a, decb a, decb a) +#define DIV_L(a) CHOICE(divl a, divl a, div a) +#define DIV_W(a) CHOICE(divw a, divw a, div a) +#define DIV_B(a) CHOICE(divb a, divb a, divb a) +#define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a)) +#define HLT CHOICE(hlt, hlt, hlt) +#define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a) +#define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a) +#define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a) +/* More forms than this for imul!! */ +#define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a)) +#define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a)) +#define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a) +#define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX) +#define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX) +#define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX) +/* Please AS code writer: use the following ONLY, if you refer to ports<256 + * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer + */ +#if defined (sun) +#define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a) +#define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a) +#define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a) +#else +#define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a) +#define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a) +#define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a) +#endif +#define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a) +#define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a) +#define INC_B(a) CHOICE(incb a, incb a, incb a) +#define INS_L CHOICE(insl, insl, _LTOG ins) +#define INS_W CHOICE(insw, insw, _WTOG ins) +#define INS_B CHOICE(insb, insb, insb) +#define INT(a) CHOICE(int a, int a, int a) +#define INT3 CHOICE(int CONST(3), int3, int CONST(3)) +#define INTO CHOICE(into, into, into) +#define IRET CHOICE(iret, iret, iret) +#define IRETD CHOICE(iret, iret, iretd) +#define JA(a) CHOICE(ja a, ja a, ja a) +#define JAE(a) CHOICE(jae a, jae a, jae a) +#define JB(a) CHOICE(jb a, jb a, jb a) +#define JBE(a) CHOICE(jbe a, jbe a, jbe a) +#define JC(a) CHOICE(jc a, jc a, jc a) +#define JE(a) CHOICE(je a, je a, je a) +#define JG(a) CHOICE(jg a, jg a, jg a) +#define JGE(a) CHOICE(jge a, jge a, jge a) +#define JL(a) CHOICE(jl a, jl a, jl a) +#define JLE(a) CHOICE(jle a, jle a, jle a) +#define JNA(a) CHOICE(jna a, jna a, jna a) +#define JNAE(a) CHOICE(jnae a, jnae a, jnae a) +#define JNB(a) CHOICE(jnb a, jnb a, jnb a) +#define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a) +#define JNC(a) CHOICE(jnc a, jnc a, jnc a) +#define JNE(a) CHOICE(jne a, jne a, jne a) +#define JNG(a) CHOICE(jng a, jng a, jng a) +#define JNGE(a) CHOICE(jnge a, jnge a, jnge a) +#define JNL(a) CHOICE(jnl a, jnl a, jnl a) +#define JNLE(a) CHOICE(jnle a, jnle a, jnle a) +#define JNO(a) CHOICE(jno a, jno a, jno a) +#define JNP(a) CHOICE(jnp a, jnp a, jnp a) +#define JNS(a) CHOICE(jns a, jns a, jns a) +#define JNZ(a) CHOICE(jnz a, jnz a, jnz a) +#define JO(a) CHOICE(jo a, jo a, jo a) +#define JP(a) CHOICE(jp a, jp a, jp a) +#define JPE(a) CHOICE(jpe a, jpe a, jpe a) +#define JPO(a) CHOICE(jpo a, jpo a, jpo a) +#define JS(a) CHOICE(js a, js a, js a) +#define JZ(a) CHOICE(jz a, jz a, jz a) +#define JMP(a) CHOICE(jmp a, jmp a, jmp a) +#define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a) +#define LAHF CHOICE(lahf, lahf, lahf) +#if !defined(_REAL_MODE) && !defined(_V86_MODE) +#define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a)) +#endif +#define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a)) +#define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a)) +#define LEAVE CHOICE(leave, leave, leave) +#define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a) +#define LIDT(a) CHOICE(lidt a, lidt a, lidt a) +#define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a)) +#define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a)) +#define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a)) +#define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a)) +#define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a)) +#define LLDT(a) CHOICE(lldt a, lldt a, lldt a) +#define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a) +#define LOCK CHOICE(lock, lock, lock) +#define LODS_L CHOICE(lodsl, lodsl, _LTOG lods) +#define LODS_W CHOICE(lodsw, lodsw, _WTOG lods) +#define LODS_B CHOICE(lodsb, lodsb, lodsb) +#define LOOP(a) CHOICE(loop a, loop a, loop a) +#define LOOPE(a) CHOICE(loope a, loope a, loope a) +#define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a) +#define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a) +#define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a) +#if !defined(_REAL_MODE) && !defined(_V86_MODE) +#define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a)) +#endif +#define LTR(a) CHOICE(ltr a, ltr a, ltr a) +#define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a)) +#define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a)) +#define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a)) +#define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a)) +#define MOVS_L CHOICE(movsl, movsl, _LTOG movs) +#define MOVS_W CHOICE(movsw, movsw, _WTOG movs) +#define MOVS_B CHOICE(movsb, movsb, movsb) +#define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a)) +#define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a)) +#define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a)) +#define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a)) +#define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a)) +#define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a)) +#define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a) +#define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a) +#define MUL_B(a) CHOICE(mulb a, mulb a, mulb a) +#define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a) +#define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a) +#define NEG_B(a) CHOICE(negb a, negb a, negb a) +#define NOP CHOICE(nop, nop, nop) +#define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a) +#define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a) +#define NOT_B(a) CHOICE(notb a, notb a, notb a) +#define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a)) +#define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a)) +#define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a)) +#define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX) +#define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX) +#define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX) +/* Please AS code writer: use the following ONLY, if you refer to ports<256 + * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer + */ +#define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a) +#define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a) +#define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a) +#define OUTS_L CHOICE(outsl, outsl, _LTOG outs) +#define OUTS_W CHOICE(outsw, outsw, _WTOG outs) +#define OUTS_B CHOICE(outsb, outsb, outsb) +#define POP_SR(a) CHOICE(pop a, pop a, pop a) +#define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a) +#define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a) +#define POPA_L CHOICE(popal, popal, _LTOG popa) +#define POPA_W CHOICE(popaw, popaw, _WTOG popa) +#define POPF_L CHOICE(popfl, popfl, _LTOG popf) +#define POPF_W CHOICE(popfw, popfw, _WTOG popf) +#define PUSH_SR(a) CHOICE(push a, push a, push a) +#define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a) +#define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a) +#define PUSH_B(a) CHOICE(push a, pushb a, push a) +#define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha) +#define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha) +#define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf) +#define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf) +#define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a)) +#define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a)) +#define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a)) +#define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a)) +#define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a)) +#define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a)) +#define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a)) +#define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a)) +#define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a)) +#define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a)) +#define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a)) +#define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a)) +#define REP CHOICE(rep ;, rep ;, repe) +#define REPE CHOICE(repz ;, repe ;, repe) +#define REPNE CHOICE(repnz ;, repne ;, repne) +#define REPNZ REPNE +#define REPZ REPE +#define RET CHOICE(ret, ret, ret) +#define SAHF CHOICE(sahf, sahf, sahf) +#define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a)) +#define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a)) +#define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a)) +#define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a)) +#define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a)) +#define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a)) +#define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a)) +#define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a)) +#define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a)) +#define SCAS_L CHOICE(scasl, scasl, _LTOG scas) +#define SCAS_W CHOICE(scasw, scasw, _WTOG scas) +#define SCAS_B CHOICE(scasb, scasb, scasb) +#define SETA(a) CHOICE(seta a, seta a, seta a) +#define SETAE(a) CHOICE(setae a, setae a, setae a) +#define SETB(a) CHOICE(setb a, setb a, setb a) +#define SETBE(a) CHOICE(setbe a, setbe a, setbe a) +#define SETC(a) CHOICE(setc a, setb a, setb a) +#define SETE(a) CHOICE(sete a, sete a, sete a) +#define SETG(a) CHOICE(setg a, setg a, setg a) +#define SETGE(a) CHOICE(setge a, setge a, setge a) +#define SETL(a) CHOICE(setl a, setl a, setl a) +#define SETLE(a) CHOICE(setle a, setle a, setle a) +#define SETNA(a) CHOICE(setna a, setna a, setna a) +#define SETNAE(a) CHOICE(setnae a, setnae a, setnae a) +#define SETNB(a) CHOICE(setnb a, setnb a, setnb a) +#define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a) +#define SETNC(a) CHOICE(setnc a, setnb a, setnb a) +#define SETNE(a) CHOICE(setne a, setne a, setne a) +#define SETNG(a) CHOICE(setng a, setng a, setng a) +#define SETNGE(a) CHOICE(setnge a, setnge a, setnge a) +#define SETNL(a) CHOICE(setnl a, setnl a, setnl a) +#define SETNLE(a) CHOICE(setnle a, setnle a, setnle a) +#define SETNO(a) CHOICE(setno a, setno a, setno a) +#define SETNP(a) CHOICE(setnp a, setnp a, setnp a) +#define SETNS(a) CHOICE(setns a, setns a, setna a) +#define SETNZ(a) CHOICE(setnz a, setnz a, setnz a) +#define SETO(a) CHOICE(seto a, seto a, seto a) +#define SETP(a) CHOICE(setp a, setp a, setp a) +#define SETPE(a) CHOICE(setpe a, setpe a, setpe a) +#define SETPO(a) CHOICE(setpo a, setpo a, setpo a) +#define SETS(a) CHOICE(sets a, sets a, seta a) +#define SETZ(a) CHOICE(setz a, setz a, setz a) +#define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a) +#define SIDT(a) CHOICE(sidt a, sidt a, sidt a) +#define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a)) +#define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a)) +#define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a)) +#define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a)) +#define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL)) +#define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a)) +#define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL)) +#define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a)) +#define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a)) +#define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a)) +#define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a)) +#define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL)) +#define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a)) +#define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL)) +#define SLDT(a) CHOICE(sldt a, sldt a, sldt a) +#define SMSW(a) CHOICE(smsw a, smsw a, smsw a) +#define STC CHOICE(stc, stc, stc) +#define STD CHOICE(std, std, std) +#define STI CHOICE(sti, sti, sti) +#define STOS_L CHOICE(stosl, stosl, _LTOG stos) +#define STOS_W CHOICE(stosw, stosw, _WTOG stos) +#define STOS_B CHOICE(stosb, stosb, stosb) +#define STR(a) CHOICE(str a, str a, str a) +#define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a)) +#define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a)) +#define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a)) +#define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a)) +#define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a)) +#define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a)) +#define VERR(a) CHOICE(verr a, verr a, verr a) +#define VERW(a) CHOICE(verw a, verw a, verw a) +#define WAIT CHOICE(wait, wait, wait) +#define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a)) +#define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a)) +#define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a)) +#define XLAT CHOICE(xlat, xlat, xlat) +#define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a)) +#define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a)) +#define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a)) + + +/* Floating Point Instructions */ +#define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1) +#define FABS CHOICE(fabs, fabs, fabs) +#define FADD_D(a) CHOICE(faddl a, faddl a, faddd a) +#define FADD_S(a) CHOICE(fadds a, fadds a, fadds a) +#define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a)) +#define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a)) +#define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a) +#define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a) +#define FBLD(a) CHOICE(fbld a, fbld a, fbld a) +#define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a) +#define FCHS CHOICE(fchs, fchs, fchs) +#define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex) +#define FNCLEX CHOICE(fnclex, fnclex, fclex) +#define FCOM(a) CHOICE(fcom a, fcom a, fcom a) +#define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a) +#define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a) +#define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a) +#define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a) +#define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a) +#define FCOMPP CHOICE(fcompp, fcompp, fcompp) +#define FCOS CHOICE(fcos, fcos, fcos) +#define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp) +#define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a) +#define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a) +#define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a)) +#define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a)) +#define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a) +#define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a) +#define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a) +#define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a) +#define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a)) +#define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a)) +#define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a) +#define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a) +#define FFREE(a) CHOICE(ffree a, ffree a, ffree a) +#define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a) +#define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a) +#define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a) +#define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a) +#define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a) +#define FILD_L(a) CHOICE(fildl a, fildl a, fildl a) +#define FILD_W(a) CHOICE(fild a, filds a, filds a) +#define FINCSTP CHOICE(fincstp, fincstp, fincstp) +#define FINIT CHOICE(finit, wait; fninit, wait; finit) +#define FNINIT CHOICE(fninit, fninit, finit) +#define FIST_L(a) CHOICE(fistl a, fistl a, fistl a) +#define FIST_W(a) CHOICE(fist a, fists a, fists a) +#define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a) +#define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a) +#define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a) +#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */ +#define FLD_D(a) CHOICE(fldl a, fldl a, fldd a) +#define FLD_S(a) CHOICE(flds a, flds a, flds a) +#define FLD1 CHOICE(fld1, fld1, fld1) +#define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t) +#define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e) +#define FLDPI CHOICE(fldpi, fldpi, fldpi) +#define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2) +#define FLDLN2 CHOICE(fldln2, fldln2, fldln2) +#define FLDZ CHOICE(fldz, fldz, fldz) +#define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a) +#define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a) +#define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a) +#define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a) +#define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a)) +#define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a)) +#define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a) +#define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a) +#define FNOP CHOICE(fnop, fnop, fnop) +#define FPATAN CHOICE(fpatan, fpatan, fpatan) +#define FPREM CHOICE(fprem, fprem, fprem) +#define FPREM1 CHOICE(fprem1, fprem1, fprem1) +#define FPTAN CHOICE(fptan, fptan, fptan) +#define FRNDINT CHOICE(frndint, frndint, frndint) +#define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a) +#define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a) +#define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a) +#define FSCALE CHOICE(fscale, fscale, fscale) +#define FSIN CHOICE(fsin, fsin, fsin) +#define FSINCOS CHOICE(fsincos, fsincos, fsincos) +#define FSQRT CHOICE(fsqrt, fsqrt, fsqrt) +#define FST_D(a) CHOICE(fstl a, fstl a, fstd a) +#define FST_S(a) CHOICE(fsts a, fsts a, fsts a) +#define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a) +#define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a) +#define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a) +#define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a) +#define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a) +#define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a) +#define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a) +#define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a) +#define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a) +#define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a) +#define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a) +#define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a)) +#define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a)) +#define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a) +#define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a) +#define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a) +#define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a) +#define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a)) +#define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a)) +#define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a) +#define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a) +#define FTST CHOICE(ftst, ftst, ftst) +#define FUCOM(a) CHOICE(fucom a, fucom a, fucom a) +#define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a) +#define FUCOMPP CHOICE(fucompp, fucompp, fucompp) +#define FWAIT CHOICE(wait, wait, wait) +#define FXAM CHOICE(fxam, fxam, fxam) +#define FXCH(a) CHOICE(fxch a, fxch a, fxch a) +#define FXTRACT CHOICE(fxtract, fxtract, fxtract) +#define FYL2X CHOICE(fyl2x, fyl2x, fyl2x) +#define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1) + +#endif /* __ASSYNTAX_H__ */ diff --git a/hw/xfree86/os-support/bsd/bsd_VTsw.c b/hw/xfree86/os-support/bsd/bsd_VTsw.c new file mode 100644 index 000000000..13e78ad34 --- /dev/null +++ b/hw/xfree86/os-support/bsd/bsd_VTsw.c @@ -0,0 +1,92 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_VTsw.c,v 3.5 1996/12/23 06:49:35 dawes Exp $ */ +/* + * Derived from VTsw_usl.c which is + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * by S_ren Schmidt (sos@login.dkuug.dk) + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: bsd_VTsw.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Handle the VT-switching interface for OSs that use USL-style ioctl()s + * (the bsd, sysv, sco, and linux subdirs). + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void xf86VTRequest(sig) +int sig; +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = TRUE; + } +#endif + return; +} + +Bool xf86VTSwitchPending() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + return(xf86Info.vtRequestsPending ? TRUE : FALSE); + } +#endif + return FALSE; +} + +Bool xf86VTSwitchAway() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + return(FALSE); + else + return(TRUE); + } +#endif + return FALSE; +} + +Bool xf86VTSwitchTo() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + return(FALSE); + else + return(TRUE); + } +#endif + return(TRUE); +} diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c new file mode 100644 index 000000000..961fd0eac --- /dev/null +++ b/hw/xfree86/os-support/bsd/bsd_init.c @@ -0,0 +1,780 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_init.c,v 3.8.2.1 1998/02/06 22:36:49 hohndel Exp $ */ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: bsd_init.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +extern void xf86VTRequest( +#if NeedFunctionPrototypes + int +#endif +); + +static Bool KeepTty = FALSE; +static int devConsoleFd = -1; +static int VTnum = -1; +static int initialVT = -1; + +#ifdef PCCONS_SUPPORT +/* Stock 0.1 386bsd pccons console driver interface */ +#ifndef __OpenBSD__ +# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0" +#else +# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0" +#endif +#define PCCONS_CONSOLE_DEV2 "/dev/vga" +#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#ifdef CODRV_SUPPORT +/* Holger Veit's codrv console driver */ +#define CODRV_CONSOLE_DEV "/dev/kbd" +#define CODRV_CONSOLE_MODE O_RDONLY|O_NDELAY +#endif + +#ifdef SYSCONS_SUPPORT +/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */ +#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0" +#define SYSCONS_CONSOLE_DEV2 "/dev/vga" +#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#ifdef PCVT_SUPPORT +/* Hellmuth Michaelis' pcvt driver */ +#ifndef __OpenBSD__ +# define PCVT_CONSOLE_DEV "/dev/ttyv0" +#else +# define PCVT_CONSOLE_DEV "/dev/ttyC0" +#endif +#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#define CHECK_DRIVER_MSG \ + "Check your kernel's console driver configuration and /dev entries" + +static char *supported_drivers[] = { +#ifdef PCCONS_SUPPORT + "pccons (with X support)", +#endif +#ifdef CODRV_SUPPORT + "codrv", +#endif +#ifdef SYSCONS_SUPPORT + "syscons", +#endif +#ifdef PCVT_SUPPORT + "pcvt", +#endif +}; + + +/* + * Functions to probe for the existance of a supported console driver. + * Any function returns either a valid file descriptor (driver probed + * succesfully), -1 (driver not found), or uses FatalError() if the + * driver was found but proved to not support the required mode to run + * an X server. + */ + +typedef int (*xf86ConsOpen_t)( +#if NeedFunctionPrototypes + void +#endif +); + +#ifdef PCCONS_SUPPORT +static int xf86OpenPccons( +#if NeedFunctionPrototypes + void +#endif +); +#endif /* PCCONS_SUPPORT */ + +#ifdef CODRV_SUPPORT +static int xf86OpenCodrv( +#if NeedFunctionPrototypes + void +#endif +); +#endif /* CODRV_SUPPORT */ + +#ifdef SYSCONS_SUPPORT +static int xf86OpenSyscons( +#if NeedFunctionPrototypes + void +#endif +); +#endif /* SYSCONS_SUPPORT */ + +#ifdef PCVT_SUPPORT +static int xf86OpenPcvt( +#if NeedFunctionPrototypes + void +#endif +); +#endif /* PCVT_SUPPORT */ + +/* + * The sequence of the driver probes is important; start with the + * driver that is best distinguishable, and end with the most generic + * driver. (Otherwise, pcvt would also probe as syscons, and either + * pcvt or syscons might succesfully probe as pccons. Only codrv is + * at its own.) + */ +static xf86ConsOpen_t xf86ConsTab[] = { +#ifdef PCVT_SUPPORT + xf86OpenPcvt, +#endif +#ifdef CODRV_SUPPORT + xf86OpenCodrv, +#endif +#ifdef SYSCONS_SUPPORT + xf86OpenSyscons, +#endif +#ifdef PCCONS_SUPPORT + xf86OpenPccons, +#endif + (xf86ConsOpen_t)NULL +}; + + +void +xf86OpenConsole() +{ + int i, fd; +#ifdef CODRV_SUPPORT + int onoff; +#endif + xf86ConsOpen_t *driver; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + vtmode_t vtmode; +#endif + + if (serverGeneration == 1) + { + /* check if we are run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be running with root " + "permissions\n" + "You should be using Xwrapper to start the server or xdm.\n" + "We strongly advise against making the server SUID root!\n"); + } + + if (!KeepTty) + { + /* + * detaching the controlling tty solves problems of kbd character + * loss. This is not interesting for CO driver, because it is + * exclusive. + */ + setpgrp(0, getpid()); + if ((i = open("/dev/tty",O_RDWR)) >= 0) + { + ioctl(i,TIOCNOTTY,(char *)0); + close(i); + } + } + + /* detect which driver we are running on */ + for (driver = xf86ConsTab; *driver; driver++) + { + if((fd = (*driver)()) >= 0) + break; + } + + /* Check that a supported console driver was found */ + if (fd < 0) + { + char cons_drivers[80] = {0, }; + for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++) + { + if (i) + { + strcat(cons_drivers, ", "); + } + strcat(cons_drivers, supported_drivers[i]); + } + FatalError( + "%s: No console driver found\n\tSupported drivers: %s\n\t%s\n", + "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); + } + fclose(stdin); + xf86Info.consoleFd = fd; + xf86Info.screenFd = fd; + + xf86Config(FALSE); /* Read XF86Config */ + + switch (xf86Info.consType) + { +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + onoff = X_MODE_ON; + if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE, &onoff) < 0) + { + FatalError("%s: CONSOLE_X_MODE ON failed (%s)\n%s\n", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + if (xf86Info.consType == CODRV01X) + ioctl(xf86Info.consoleFd, VGATAKECTRL, 0); + break; +#endif +#ifdef PCCONS_SUPPORT + case PCCONS: + if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0) + { + FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s\n", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + /* + * Hack to prevent keyboard hanging when syslogd closes + * /dev/console + */ + if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0) + { + ErrorF("Warning: couldn't open /dev/console (%s)\n", + strerror(errno)); + } + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + /* + * First activate the #1 VT. This is a hack to allow a server + * to be started while another one is active. There should be + * a better way. + */ + if (initialVT != 1) { + + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + sleep(1); + } + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + + signal(SIGUSR1, xf86VTRequest); + + vtmode.mode = VT_PROCESS; + vtmode.relsig = SIGUSR1; + vtmode.acqsig = SIGUSR1; + vtmode.frsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) + { + FatalError("xf86OpenConsole: KDENABIO failed (%s)\n", + strerror(errno)); + } + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + { + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); + } + break; +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + } + } + else + { + /* serverGeneration != 1 */ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + } +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + } + return; +} + + +#ifdef PCCONS_SUPPORT + +static int +xf86OpenPccons() +{ + int fd = -1; + + if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0)) + >= 0 || + (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0)) + >= 0) + { + if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0) + { + FatalError( + "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s\n", + "xf86OpenPccons", + strerror(errno), + "Was expecting pccons driver with X support", + CHECK_DRIVER_MSG); + } + xf86Info.consType = PCCONS; + if (xf86Verbose) + { + ErrorF("Using pccons driver with X support\n"); + } + } + return fd; +} + +#endif /* PCCONS_SUPPORT */ + +#ifdef SYSCONS_SUPPORT + +static int +xf86OpenSyscons() +{ + int fd = -1; + vtmode_t vtmode; + char vtname[12]; + struct stat status; + long syscons_version; + + /* Check for syscons */ + if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0 + || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0) + { + if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) + { + /* Get syscons version */ + if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0) + { + syscons_version = 0; + } + + xf86Info.vtno = VTnum; + +#ifdef VT_GETACTIVE + if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) + initialVT = -1; +#endif + if (xf86Info.vtno == -1) + { + /* + * For old syscons versions (<0x100), VT_OPENQRY returns + * the current VT rather than the next free VT. In this + * case, the server gets started on the current VT instead + * of the next free VT. + */ + +#if 0 + /* check for the fixed VT_OPENQRY */ + if (syscons_version >= 0x100) + { +#endif + if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) + { + /* No free VTs */ + xf86Info.vtno = -1; + } +#if 0 + } +#endif + + if (xf86Info.vtno == -1) + { + /* + * All VTs are in use. If initialVT was found, use it. + * Otherwise, if stdin is a VT, use that one. + */ + if (initialVT != -1) + { + xf86Info.vtno = initialVT; + } + else if ((fstat(0, &status) >= 0) + && S_ISCHR(status.st_mode) + && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) + { + /* stdin is a VT */ + xf86Info.vtno = minor(status.st_rdev) + 1; + } + else + { + if (syscons_version >= 0x100) + { + FatalError("%s: Cannot find a free VT\n", + "xf86OpenSyscons"); + } + /* Should no longer reach here */ + FatalError("%s: %s %s\n\t%s %s\n", + "xf86OpenSyscons", + "syscons versions prior to 1.0 require", + "either the", + "server's stdin be a VT", + "or the use of the vtxx server option"); + } + } + } + + close(fd); +#ifndef __OpenBSD__ + sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); +#else + sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1); +#endif + if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) + { + FatalError("xf86OpenSyscons: Cannot open %s (%s)\n", + vtname, strerror(errno)); + } + if (ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("xf86OpenSyscons: VT_GETMODE failed\n"); + } + xf86Info.consType = SYSCONS; + if (xf86Verbose) + { + ErrorF("Using syscons driver with X support"); + if (syscons_version >= 0x100) + { + ErrorF(" (version %d.%d)\n", syscons_version >> 8, + syscons_version & 0xFF); + } + else + { + ErrorF(" (version 0.x)\n"); + } + ErrorF("(using VT number %d)\n\n", xf86Info.vtno); + } + } + else + { + /* VT_GETMODE failed, probably not syscons */ + close(fd); + fd = -1; + } + } + return fd; +} + +#endif /* SYSCONS_SUPPORT */ + + +#ifdef CODRV_SUPPORT + +static int +xf86OpenCodrv() +{ + int fd = -1, onoff = X_MODE_OFF; + struct oldconsinfo ci; + + if ((fd = open(CODRV_CONSOLE_DEV, CODRV_CONSOLE_MODE, 0)) >= 0) + { + if (ioctl(fd, CONSOLE_X_MODE, &onoff) < 0) + { + FatalError("%s: CONSOLE_X_MODE on %s failed (%s)\n%s\n%s\n", + "xf86OpenCodrv", + CODRV_CONSOLE_DEV, strerror(errno), + "Was expecting codrv driver", + CHECK_DRIVER_MSG); + } + xf86Info.consType = CODRV011; + } + else + { + if (errno == EBUSY) + { + FatalError("xf86OpenCodrv: %s is already in use (codrv)\n", + CODRV_CONSOLE_DEV); + } + } + else + { + fd = -1; + } + + if(fd >= 0) + { + /* + * analyse whether this kernel has sufficient capabilities for + * this xserver, if not don't proceed: it won't work. Also + * find out which codrv version. + */ +#define NECESSARY (CONS_HASKBD|CONS_HASKEYNUM|CONS_HASPX386) + if ((ioctl(fd, OLDCONSGINFO, &ci) < 0 || + (ci.info1 & NECESSARY) != NECESSARY)) + { + FatalError("xf86OpenCodrv: %s\n%s\n%s\n", + "This Xserver has detected the codrv driver, but your", + "kernel doesn't appear to have the required facilities", + CHECK_DRIVER_MSG); + } + /* Check for codrv 0.1.2 or later */ + if (ci.info1 & CONS_CODRV2) + { + xf86Info.consType = CODRV01X; + if (xf86Verbose) + { + ErrorF("Using codrv 0.1.2 (or later)\n"); + } + } + else + { + if (xf86Verbose) + { + ErrorF("Using codrv 0.1.1\n"); + } + } +#undef NECESSARY + } + + return fd; +} +#endif /* CODRV_SUPPORT */ + +#ifdef PCVT_SUPPORT + +static int +xf86OpenPcvt() +{ + /* This looks much like syscons, since pcvt is API compatible */ + int fd = -1; + vtmode_t vtmode; + char vtname[12]; + struct stat status; + struct pcvtid pcvt_version; + + if ((fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0)) >= 0) + { + if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0) + { + if(ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("%s: VT_GETMODE failed\n%s%s\n%s\n", + "xf86OpenPcvt", + "Found pcvt driver but X11 seems to be", + " not supported.", CHECK_DRIVER_MSG); + } + + xf86Info.vtno = VTnum; + + if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) + initialVT = -1; + + if (xf86Info.vtno == -1) + { + if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) + { + /* No free VTs */ + xf86Info.vtno = -1; + } + + if (xf86Info.vtno == -1) + { + /* + * All VTs are in use. If initialVT was found, use it. + * Otherwise, if stdin is a VT, use that one. + */ + if (initialVT != -1) + { + xf86Info.vtno = initialVT; + } + else if ((fstat(0, &status) >= 0) + && S_ISCHR(status.st_mode) + && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) + { + /* stdin is a VT */ + xf86Info.vtno = minor(status.st_rdev) + 1; + } + else + { + FatalError("%s: Cannot find a free VT\n", + "xf86OpenPcvt"); + } + } + } + + close(fd); +#ifndef __OpenBSD__ + sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); +#else + sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1); +#endif + if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) + { + FatalError("xf86OpenPcvt: Cannot open %s (%s)\n", + vtname, strerror(errno)); + } + if (ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("xf86OpenPcvt: VT_GETMODE failed\n"); + } + xf86Info.consType = PCVT; + if (xf86Verbose) + { + ErrorF("Using pcvt driver (version %d.%d)\n", + pcvt_version.rmajor, pcvt_version.rminor); + } + } + else + { + /* Not pcvt */ + close(fd); + fd = -1; + } + } + return fd; +} + +#endif /* PCVT_SUPPORT */ + + +void +xf86CloseConsole() +{ +#if defined(CODRV_SUPPORT) + int onoff; +#endif +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + struct vt_mode VT; +#endif + + switch (xf86Info.consType) + { +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + onoff = X_MODE_OFF; + if (xf86Info.consType == CODRV01X) + { + ioctl (xf86Info.consoleFd, VGAGIVECTRL, 0); + } + ioctl (xf86Info.consoleFd, CONSOLE_X_MODE, &onoff); + break; +#endif /* CODRV_SUPPORT */ +#ifdef PCCONS_SUPPORT + case PCCONS: + ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0); + break; +#endif /* PCCONS_SUPPORT */ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */ + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */ + } + if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) + { + xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)\n", + strerror(errno)); + } + if (initialVT != -1) + ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); + break; +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + } + + if (xf86Info.screenFd != xf86Info.consoleFd) + { + close(xf86Info.screenFd); + close(xf86Info.consoleFd); + if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0) + { + xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)\n", + strerror(errno)); + } + } + close(xf86Info.consoleFd); + if (devConsoleFd >= 0) + close(devConsoleFd); + return; +} + +int +xf86ProcessArgument (argc, argv, i) +int argc; +char *argv[]; +int i; +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || + VTnum < 1 || VTnum > 12) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + return(0); +} + +void +xf86UseMsg() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + ErrorF("vtXX use the specified VT number (1-12)\n"); +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/hw/xfree86/os-support/bsd/bsd_io.c b/hw/xfree86/os-support/bsd/bsd_io.c new file mode 100644 index 000000000..6741ba978 --- /dev/null +++ b/hw/xfree86/os-support/bsd/bsd_io.c @@ -0,0 +1,257 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_io.c,v 3.12 1996/12/23 06:49:37 dawes Exp $ */ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Dawes make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: bsd_io.c,v 1.3 2000/08/17 19:51:21 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + if (loudness && pitch) + { +#ifdef CODRV_SUPPORT + struct kbd_sound s; +#endif +#ifdef PCCONS_SUPPORT + int data[2]; +#endif + + switch (xf86Info.consType) { + +#ifdef PCCONS_SUPPORT + case PCCONS: + data[0] = pitch; + data[1] = (duration * loudness) / 50; + ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data); + break; +#endif +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + s.pitch = pitch; + s.duration = (duration * loudness) / 50; + ioctl(xf86Info.consoleFd, KBDSETBELL, &s); + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration*loudness/50)<<16)); + break; +#endif + } + } +} + +void xf86SetKbdLeds(leds) +int leds; +{ + switch (xf86Info.consType) { + + case PCCONS: + break; +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2; + ioctl(xf86Info.consoleFd, KBDSLEDS, &leds); + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDSETLED, leds); + break; +#endif + } +} + +int xf86GetKbdLeds() +{ + int leds = 0; + + switch (xf86Info.consType) { + + case PCCONS: + break; +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + ioctl(xf86Info.consoleFd, KBDGLEDS, &leds); + leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2; + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDGETLED, &leds); + break; +#endif + } + return(leds); +} + +#if NeedFunctionPrototypes +void xf86SetKbdRepeat(char rad) +#else +void xf86SetKbdRepeat(rad) +char rad; +#endif +{ + switch (xf86Info.consType) { + + case PCCONS: + break; +#ifdef CODRV_SUPPORT + case CODRV011: + case CODRV01X: + ioctl(xf86Info.consoleFd, KBDSTPMAT, &rad); + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDSETRAD, rad); + break; +#endif + } +} + +static struct termio kbdtty; + +void xf86KbdInit() +{ + switch (xf86Info.consType) { + + case CODRV011: + case CODRV01X: + break; +#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case PCCONS: + case SYSCONS: + case PCVT: + tcgetattr(xf86Info.consoleFd, &kbdtty); + break; +#endif + } +} + +int xf86KbdOn() +{ + struct termios nTty; + + switch (xf86Info.consType) { + + case CODRV011: + case CODRV01X: + break; + +#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) + case SYSCONS: + case PCCONS: + case PCVT: + nTty = kbdtty; + nTty.c_iflag = IGNPAR | IGNBRK; + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME] = 0; + nTty.c_cc[VMIN] = 1; + cfsetispeed(&nTty, 9600); + cfsetospeed(&nTty, 9600); + tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty); + +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW); +#endif + break; +#endif + } + return(xf86Info.consoleFd); +} + +int xf86KbdOff() +{ + switch (xf86Info.consType) { + + case CODRV011: + case CODRV01X: + break; + +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDSKBMODE, K_XLATE); + /* FALL THROUGH */ +#endif +#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) + case PCCONS: + tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty); + break; +#endif + } + return(xf86Info.consoleFd); +} + +void xf86MouseInit(mouse) +MouseDevPtr mouse; +{ + return; +} + +int xf86MouseOn(mouse) +MouseDevPtr mouse; +{ + if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open mouse (%s) - Continuing...\n", + strerror(errno)); + return(-2); + } + FatalError("Cannot open mouse (%s)\n", strerror(errno)); + } + + xf86SetupMouse(mouse); + + /* Flush any pending input */ + tcflush(mouse->mseFd, TCIFLUSH); + + return(mouse->mseFd); +} diff --git a/hw/xfree86/os-support/bsd/bsd_jstk.c b/hw/xfree86/os-support/bsd/bsd_jstk.c new file mode 100644 index 000000000..ab4a31420 --- /dev/null +++ b/hw/xfree86/os-support/bsd/bsd_jstk.c @@ -0,0 +1,180 @@ +/* + * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* Modified for FreeBSD by David Dawes <dawes@XFree86.org> */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_jstk.c,v 3.2 1996/01/12 14:34:41 dawes Exp $ */ + +#include <sys/types.h> +#include <unistd.h> +#include <string.h> +#include <machine/joystick.h> +#include <fcntl.h> + +#define JS_RETURN sizeof(struct joystick) + +extern int errno; +extern int xf86Verbose; + +/*********************************************************************** + * + * xf86JoystickOn -- + * + * open the device and init timeout according to the device value. + * + *********************************************************************** + */ + +int +xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY) +{ + int status; + int changed = 0; + int timeinmicros; + struct joystick js; + +#ifdef DEBUG + ErrorF("xf86JoystickOn: %s\n", name); +#endif + + if ((status = open(name, O_RDWR | O_NDELAY)) < 0) + { + ErrorF("xf86JoystickOn: Cannot open joystick '%s' (%s)\n", name, + strerror(errno)); + return -1; + } + + if (*timeout <= 0) { + /* Use the current setting */ + ioctl(status, JOY_GETTIMEOUT, &timeinmicros); + *timeout = timeinmicros / 1000; + if (*timeout == 0) + *timeout = 1; + changed = 1; + } + /* Maximum allowed timeout in the FreeBSD driver is 10ms */ + if (*timeout > 10) { + *timeout = 10; + changed = 1; + } + + if (changed && xf86Verbose) + ErrorF("(--) Joystick: timeout value = %d\n", *timeout); + + timeinmicros = *timeout * 1000; + + /* Assume the joystick is centred when this is called */ + read(status, &js, JS_RETURN); + if (*centerX < 0) { + *centerX = js.x; + if (xf86Verbose) { + ErrorF("(--) Joystick: CenterX set to %d\n", *centerX); + } + } + if (*centerY < 0) { + *centerY = js.y; + if (xf86Verbose) { + ErrorF("(--) Joystick: CenterY set to %d\n", *centerY); + } + } + + return status; +} + +/*********************************************************************** + * + * xf86JoystickInit -- + * + * called when X device is initialized. + * + *********************************************************************** + */ + +void +xf86JoystickInit() +{ + return; +} + +/*********************************************************************** + * + * xf86JoystickOff -- + * + * close the handle. + * + *********************************************************************** + */ + +int +xf86JoystickOff(fd, doclose) +int *fd; +int doclose; +{ + int oldfd; + + if (((oldfd = *fd) >= 0) && doclose) { + close(*fd); + *fd = -1; + } + return oldfd; +} + +/*********************************************************************** + * + * xf86JoystickGetState -- + * + * return the state of buttons and the position of the joystick. + * + *********************************************************************** + */ + +int +xf86JoystickGetState(fd, x, y, buttons) +int fd; +int *x; +int *y; +int *buttons; +{ + struct joystick js; + int status; + + status = read(fd, &js, JS_RETURN); + + if (status != JS_RETURN) + { + Error("Joystick read"); + return 0; + } + + *x = js.x; + *y = js.y; + *buttons = js.b1 | (js.b2 << 1); +#ifdef DEBUG + ErrorF("xf86JoystickGetState: x = %d, y = %d, buttons = %d\n", *x, *y, + *buttons); +#endif + + return 1; +} + +/* end of bsd_jstk.c */ diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c new file mode 100644 index 000000000..1c0791abb --- /dev/null +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -0,0 +1,274 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.7.2.3 1998/02/06 22:36:51 hohndel Exp $ */ +/* + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Orest Zborowski and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Orest Zborowski + * and David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: lnx_init.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +#ifdef USE_DEV_FB +extern char *getenv(const char *); +#include <linux/fb.h> +char *fb_dev_name; +#endif + +static Bool KeepTty = FALSE; +static int VTnum = -1; +static int activeVT = -1; + +extern void xf86VTRequest( +#if NeedFunctionPrototypes + int +#endif +); + +void xf86OpenConsole() +{ + int i, fd; + struct vt_mode VT; + char vtname[11]; + struct vt_stat vts; +#ifdef USE_DEV_FB + struct fb_var_screeninfo var; + int fbfd; +#endif + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be running with root " + "permissions\n" + "You should be using Xwrapper to start the server or xdm.\n" + "We strongly advise against making the server SUID root!\n"); + } + + /* + * setup the virtual terminal manager + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + } + else + { + if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n", + strerror(errno)); + } + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + { + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + } + close(fd); + } + +#ifdef USE_DEV_FB + fb_dev_name=getenv("FRAMEBUFFER"); + if (!fb_dev_name) + fb_dev_name="/dev/fb0current"; + if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0) + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + fb_dev_name, strerror(errno)); + if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var)) + FatalError("xf86OpenConsole: Unable to get screen info\n"); +#endif + ErrorF("(using VT number %d)\n\n", xf86Info.vtno); + + sprintf(vtname,"/dev/tty%d",xf86Info.vtno); /* /dev/tty1-64 */ + + xf86Config(FALSE); /* Read XF86Config */ + + if (!KeepTty) + { + setpgrp(); + } + + if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0) + { + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + vtname, strerror(errno)); + } + + /* change ownership of the vt */ + chown(vtname, getuid(), getgid()); + + /* + * the current VT device we're running on is not "console", we want + * to grab all consoles too + * + * Why is this needed? + */ + chown("/dev/tty0", getuid(), getgid()); + + /* + * Linux doesn't switch to an active vt after the last close of a vt, + * so we do this ourselves by remembering which is active now. + */ + if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) == 0) + { + activeVT = vts.v_active; + } + + if (!KeepTty) + { + /* + * Detach from the controlling tty to avoid char loss + */ + if ((i = open("/dev/tty",O_RDWR)) >= 0) + { + ioctl(i, TIOCNOTTY, 0); + close(i); + } + } + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError ("xf86OpenConsole: VT_GETMODE failed\n"); + } + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + { + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); + } +#ifdef USE_DEV_FB + /* copy info to new console */ + var.yoffset=0; + var.xoffset=0; + if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var)) + FatalError("Unable to set screen info\n"); + close(fbfd); +#endif + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + } + return; +} + +void xf86CloseConsole() +{ + struct vt_mode VT; + +#if 0 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); +#endif + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + /* + * Perform a switch back to the active VT when we were started + */ + if (activeVT >= 0) + { + ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT); + activeVT = -1; + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int xf86ProcessArgument (argc, argv, i) +int argc; +char *argv[]; +int i; +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/hw/xfree86/os-support/linux/lnx_io.c b/hw/xfree86/os-support/linux/lnx_io.c new file mode 100644 index 000000000..57a2979c5 --- /dev/null +++ b/hw/xfree86/os-support/linux/lnx_io.c @@ -0,0 +1,136 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.3 1996/12/23 06:50:01 dawes Exp $ */ +/* + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Orest Zborowski and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Orest Zborowski + * and David Dawes make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID DAWES BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: lnx_io.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + if (loudness && pitch) + { + ioctl(xf86Info.consoleFd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration * + loudness / 50) << 16)); + } +} + +void xf86SetKbdLeds(leds) +int leds; +{ + ioctl(xf86Info.consoleFd, KDSETLED, leds); +} + +int xf86GetKbdLeds() +{ + int leds; + + ioctl(xf86Info.consoleFd, KDGETLED, &leds); + return(leds); +} + +#if NeedFunctionPrototypes +void xf86SetKbdRepeat(char rad) +#else +void xf86SetKbdRepeat(rad) +char rad; +#endif +{ + return; +} + +static int kbdtrans; +static struct termios kbdtty; + +void xf86KbdInit() +{ + ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans); + tcgetattr (xf86Info.consoleFd, &kbdtty); +} + +int xf86KbdOn() +{ + struct termios nTty; + + ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW); + nTty = kbdtty; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME]=0; + nTty.c_cc[VMIN]=1; + cfsetispeed(&nTty, 9600); + cfsetospeed(&nTty, 9600); + tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty); + return(xf86Info.consoleFd); +} + +int xf86KbdOff() +{ + ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans); + tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty); + return(xf86Info.consoleFd); +} + +void xf86MouseInit(mouse) +MouseDevPtr mouse; +{ + return; +} + +int xf86MouseOn(mouse) +MouseDevPtr mouse; +{ + if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open mouse (%s) - Continuing...\n", + strerror(errno)); + return(-2); + } + FatalError("Cannot open mouse (%s)\n", strerror(errno)); + } + + xf86SetupMouse(mouse); + + /* Flush any pending input */ + tcflush(mouse->mseFd, TCIFLUSH); + + return(mouse->mseFd); +} diff --git a/hw/xfree86/os-support/linux/lnx_jstk.c b/hw/xfree86/os-support/linux/lnx_jstk.c new file mode 100644 index 000000000..ea308c159 --- /dev/null +++ b/hw/xfree86/os-support/linux/lnx_jstk.c @@ -0,0 +1,173 @@ +/* $Xorg: lnx_jstk.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */ +/* Id: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp */ +/* + * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_jstk.c,v 3.6 1996/12/23 06:50:02 dawes Exp $ */ + +static const char rcs_id[] = "$Xorg: lnx_jstk.c,v 1.1 1995/12/20 14:06:09 lepied Exp"; + +#include <sys/types.h> +#include <unistd.h> +#include <string.h> +#define inline __inline__ +#include <linux/joystick.h> +#include <fcntl.h> +#include <sys/ioctl.h> + +extern int errno; + +/*********************************************************************** + * + * xf86JoystickOn -- + * + * open the device and init timeout according to the device value. + * + *********************************************************************** + */ + +int +xf86JoystickOn(char *name, int *timeout, int *centerX, int *centerY) +{ + int fd; + struct JS_DATA_TYPE js; + extern int xf86Verbose; + +#ifdef DEBUG + ErrorF("xf86JoystickOn %s\n", name); +#endif + + if ((fd = open(name, O_RDWR | O_NDELAY)) < 0) + { + ErrorF("Cannot open joystick '%s' (%s)\n", name, + strerror(errno)); + return -1; + } + + if (*timeout == 0) { + if (ioctl (fd, JS_GET_TIMELIMIT, timeout) == -1) { + Error("joystick JS_GET_TIMELIMIT ioctl"); + } + else { + if (xf86Verbose) { + ErrorF("(--) Joystick: timeout value = %d\n", *timeout); + } + } + } + else { + if (ioctl(fd, JS_SET_TIMELIMIT, timeout) == -1) { + Error("joystick JS_SET_TIMELIMIT ioctl"); + } + } + + /* Assume the joystick is centred when this is called */ + read(fd, &js, JS_RETURN); + if (*centerX < 0) { + *centerX = js.x; + if (xf86Verbose) { + ErrorF("(--) Joystick: CenterX set to %d\n", *centerX); + } + } + if (*centerY < 0) { + *centerY = js.y; + if (xf86Verbose) { + ErrorF("(--) Joystick: CenterY set to %d\n", *centerY); + } + } + + return fd; +} + +/*********************************************************************** + * + * xf86JoystickInit -- + * + * called when X device is initialized. + * + *********************************************************************** + */ + +void +xf86JoystickInit() +{ + return; +} + +/*********************************************************************** + * + * xf86JoystickOff -- + * + * close the handle. + * + *********************************************************************** + */ + +int +xf86JoystickOff(fd, doclose) +int *fd; +int doclose; +{ + int oldfd; + + if (((oldfd = *fd) >= 0) && doclose) { + close(*fd); + *fd = -1; + } + return oldfd; +} + +/*********************************************************************** + * + * xf86JoystickGetState -- + * + * return the state of buttons and the position of the joystick. + * + *********************************************************************** + */ + +int +xf86JoystickGetState(fd, x, y, buttons) +int fd; +int *x; +int *y; +int *buttons; +{ + struct JS_DATA_TYPE js; + int status; + + status = read(fd, &js, JS_RETURN); + + if (status != JS_RETURN) + { + Error("Joystick read"); + return 0; + } + + *x = js.x; + *y = js.y; + *buttons = js.buttons; + + return 1; +} + +/* end of lnx_jstk.c */ diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c new file mode 100644 index 000000000..a29db8251 --- /dev/null +++ b/hw/xfree86/os-support/linux/lnx_video.c @@ -0,0 +1,634 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.13.2.1 1997/05/11 05:04:25 dawes Exp $ */ +/* + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Orest Zborowski and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Orest Zborowski + * and David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE + * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: lnx_video.c,v 1.3 2000/08/17 19:51:23 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef __alpha__ + +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ +#define SPARSE (5) +#define isJensen (1) +#else +#define isJensen (!_bus_base()) +#define SPARSE (7) +#endif + +#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base()) +#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x) +#else +#define BUS_BASE 0 +#define JENSEN_SHIFT(x) (x) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +/* + * Unfortunatly mmap without MAP_FIXED only works the first time :-( + * This is now fixed in pl13 ALPHA, but still seems to have problems. + */ +#undef ONLY_MMAP_FIXED_WORKS + +#ifdef ONLY_MMAP_FIXED_WORKS +static pointer AllocAddress[MAXSCREENS][NUM_REGIONS]; +#endif + +#if 0 +static struct xf86memMap { + int offset; + int memSize; +} xf86memMaps[MAXSCREENS]; +#endif + +pointer xf86MapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + pointer base; + int fd; + +#ifdef ONLY_MMAP_FIXED_WORKS +#ifdef __alpha__ + FatalError("xf86MapVidMem: Unexpected code for Alpha (pagesize=8k!)\n"); +#endif + AllocAddress[ScreenNum][Region] = (pointer)xalloc(Size + 0x1000); + if (AllocAddress[ScreenNum][Region] == NULL) + { + FatalError("xf86MapVidMem: can't alloc framebuffer space\n"); + } + base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region] + & ~0xFFF) + 0x1000); + if ((fd = open("/dev/mem", O_RDWR)) < 0) + { + FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n", + strerror(errno)); + } + base = (pointer)mmap((caddr_t)base, Size, PROT_READ|PROT_WRITE, + MAP_FIXED|MAP_SHARED, fd, (off_t)Base); +#else + if ((fd = open("/dev/mem", O_RDWR)) < 0) + { + FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n", + strerror(errno)); + } + /* This requirers linux-0.99.pl10 or above */ + base = (pointer)mmap((caddr_t)0, JENSEN_SHIFT(Size), + PROT_READ|PROT_WRITE, + MAP_SHARED, fd, + (off_t)(JENSEN_SHIFT((off_t)Base) + BUS_BASE)); +#endif + close(fd); + if ((long)base == -1) + { + FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", + strerror(errno)); + } +#if 0 + xf86memMaps[ScreenNum].offset = (int) Base; + xf86memMaps[ScreenNum].memSize = Size; +#endif + return base; +} + +#if 0 +void xf86GetVidMemData(ScreenNum, Base, Size) +int ScreenNum; +int *Base; +int *Size; +{ + *Base = xf86memMaps[ScreenNum].offset; + *Size = xf86memMaps[ScreenNum].memSize; +} +#endif + +void xf86UnMapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + munmap((caddr_t)JENSEN_SHIFT(Base), JENSEN_SHIFT(Size)); +#ifdef ONLY_MMAP_FIXED_WORKS + xfree(AllocAddress[ScreenNum][Region]); +#endif +} + +Bool xf86LinearVidMem() +{ + return(TRUE); +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +/* + * Linux handles regular (<= 0x3ff) ports with the TSS I/O bitmap, and + * extended ports with the iopl() system call. + * + * For testing, it's useful to enable only the ports we need, but for + * production purposes, it's faster to enable all ports. + */ +#define ALWAYS_USE_EXTENDED + +#ifdef ALWAYS_USE_EXTENDED + +static Bool ScreenEnabled[MAXSCREENS]; +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +void xf86ClearIOPortList(ScreenNum) +int ScreenNum; +{ + if (!InitDone) + { + int i; + + for (i = 0; i < MAXSCREENS; i++) + ScreenEnabled[i] = FALSE; + InitDone = TRUE; + } + + return; +} + +void xf86AddIOPorts(ScreenNum, NumPorts, Ports) +int ScreenNum; +int NumPorts; +unsigned *Ports; +{ + return; +} + +void xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + ScreenEnabled[ScreenNum] = TRUE; + + if (ExtendedEnabled) + return; + +#ifndef __mc68000__ + if (iopl(3)) + FatalError("%s: Failed to set IOPL for I/O\n", + "xf86EnableIOPorts"); +#endif + ExtendedEnabled = TRUE; + + return; +} + +void xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + ScreenEnabled[ScreenNum] = FALSE; + + if (!ExtendedEnabled) + return; + + for (i = 0; i < MAXSCREENS; i++) + if (ScreenEnabled[i]) + return; + +#ifndef __mc68000__ + iopl(0); +#endif + ExtendedEnabled = FALSE; + + return; +} + +#else /* !ALWAYS_USE_EXTENDED */ + +static unsigned *EnabledPorts[MAXSCREENS]; +static int NumEnabledPorts[MAXSCREENS]; +static Bool ScreenEnabled[MAXSCREENS]; +static Bool ExtendedPorts[MAXSCREENS]; +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +void xf86ClearIOPortList(ScreenNum) +int ScreenNum; +{ + if (!InitDone) + { + xf86InitPortLists(EnabledPorts, NumEnabledPorts, + ScreenEnabled, ExtendedPorts, MAXSCREENS); + InitDone = TRUE; + return; + } + ExtendedPorts[ScreenNum] = FALSE; + if (EnabledPorts[ScreenNum] != (unsigned *)NULL) + xfree(EnabledPorts[ScreenNum]); + EnabledPorts[ScreenNum] = (unsigned *)NULL; + NumEnabledPorts[ScreenNum] = 0; +} + +void xf86AddIOPorts(ScreenNum, NumPorts, Ports) +int ScreenNum; +int NumPorts; +unsigned *Ports; +{ + int i; + + if (!InitDone) + { + FatalError("xf86AddIOPorts: I/O control lists not initialised\n"); + } + EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum], + (NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned)); + for (i = 0; i < NumPorts; i++) + { + EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] = + Ports[i]; + if (Ports[i] > 0x3FF) + ExtendedPorts[ScreenNum] = TRUE; + } + NumEnabledPorts[ScreenNum] += NumPorts; +} + +void xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + if (ScreenEnabled[ScreenNum]) + return; + + for (i = 0; i < MAXSCREENS; i++) + { + if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum)) + { +#ifndef __mc68000__ + if (iopl(3)) + { + FatalError("%s: Failed to set IOPL for extended I/O\n", + "xf86EnableIOPorts"); + } +#endif + ExtendedEnabled = TRUE; + break; + } + } + /* Extended I/O was used, but not any more */ + if (ExtendedEnabled && i == MAXSCREENS) + { +#ifndef __mc68000__ + iopl(0); +#endif + ExtendedEnabled = FALSE; + } + /* + * Turn on non-extended ports even when using extended I/O + * so they are there if extended I/O gets turned off when it's no + * longer needed. + */ + for (i = 0; i < NumEnabledPorts[ScreenNum]; i++) + { + unsigned port = EnabledPorts[ScreenNum][i]; + + if (port > 0x3FF) + continue; + + if (xf86CheckPorts(port, EnabledPorts, NumEnabledPorts, + ScreenEnabled, MAXSCREENS)) + { + if (ioperm(port, 1, TRUE) < 0) + { + FatalError("%s: Failed to enable I/O port 0x%x (%s)\n", + "xf86EnableIOPorts", port, strerror(errno)); + } + } + } + ScreenEnabled[ScreenNum] = TRUE; + return; +} + +void xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + if (!ScreenEnabled[ScreenNum]) + return; + + ScreenEnabled[ScreenNum] = FALSE; + for (i = 0; i < MAXSCREENS; i++) + { + if (ScreenEnabled[i] && ExtendedPorts[i]) + break; + } + if (ExtendedEnabled && i == MAXSCREENS) + { +#ifndef __mc68000__ + iopl(0); +#endif + ExtendedEnabled = FALSE; + } + for (i = 0; i < NumEnabledPorts[ScreenNum]; i++) + { + unsigned port = EnabledPorts[ScreenNum][i]; + + if (port > 0x3FF) + continue; + + if (xf86CheckPorts(port, EnabledPorts, NumEnabledPorts, + ScreenEnabled, MAXSCREENS)) + { + ioperm(port, 1, FALSE); + } + } + return; +} + +#endif /* ALWAYS_USE_EXTENDED */ + +void xf86DisableIOPrivs() +{ +#ifndef __mc68000__ + if (ExtendedEnabled) + iopl(0); +#endif + return; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts() +{ + if (!ExtendedEnabled) +#ifndef __mc68000__ + if (iopl(3)) + return (FALSE); +#endif +#if defined(__alpha__) || defined(__mc68000__) +#else +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif +#endif +#ifndef __mc68000__ + if (!ExtendedEnabled) + iopl(0); +#endif + return (TRUE); +} + +void xf86EnableInterrupts() +{ + if (!ExtendedEnabled) +#ifndef __mc68000__ + if (iopl(3)) + return; +#endif +#if defined(__alpha__) || defined(__mc68000__) +#else +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif +#endif +#ifndef __mc68000__ + if (!ExtendedEnabled) + iopl(0); +#endif + return; +} + +#if defined(__alpha__) + +static int xf86SparseShift = 5; /* default to all but JENSEN */ + +pointer xf86MapVidMemSparse(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + pointer base; + int fd; + + if (!_bus_base()) xf86SparseShift = 7; /* Uh, oh, JENSEN... */ + + Size <<= xf86SparseShift; + Base = (pointer)((unsigned long)Base << xf86SparseShift); + + if ((fd = open("/dev/mem", O_RDWR)) < 0) + { + FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n", + strerror(errno)); + } + /* This requirers linux-0.99.pl10 or above */ + base = (pointer)mmap((caddr_t)0, Size, + PROT_READ | PROT_WRITE, + MAP_SHARED, fd, + (off_t)Base + _bus_base_sparse()); + close(fd); + if ((long)base == -1) + { + FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", + strerror(errno)); + } + return base; +} + +void xf86UnMapVidMemSparse(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + Size <<= xf86SparseShift; + + munmap((caddr_t)Base, Size); +} + +#define vuip volatile unsigned int * + +extern void sethae(unsigned long hae); + +int xf86ReadSparse8(Base, Offset) +pointer Base; +unsigned long Offset; +{ + unsigned long result, shift; + unsigned long msb = 0; + + shift = (Offset & 0x3) * 8; + if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */ + if (Offset >= (1UL << 24)) { + msb = Offset & 0xf8000000UL; + Offset -= msb; + if (msb) { + sethae(msb); + } + } + } + result = *(vuip) ((unsigned long)Base + (Offset << xf86SparseShift)); + if (msb) + sethae(0); + result >>= shift; + return 0xffUL & result; +} + +int xf86ReadSparse16(Base, Offset) +pointer Base; +unsigned long Offset; +{ + unsigned long result, shift; + unsigned long msb = 0; + + shift = (Offset & 0x2) * 8; + if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */ + if (Offset >= (1UL << 24)) { + msb = Offset & 0xf8000000UL; + Offset -= msb; + if (msb) { + sethae(msb); + } + } + } + result = *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(1<<(xf86SparseShift-2))); + if (msb) + sethae(0); + result >>= shift; + return 0xffffUL & result; +} + +int xf86ReadSparse32(Base, Offset) +pointer Base; +unsigned long Offset; +{ + unsigned long result; + unsigned long msb = 0; + + if (xf86SparseShift != 7) { /* if not JENSEN, we may need HAE */ + if (Offset >= (1UL << 24)) { + msb = Offset & 0xf8000000UL; + Offset -= msb; + if (msb) { + sethae(msb); + } + } + } + result = *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(3<<(xf86SparseShift-2))); + if (msb) + sethae(0); + return result; +} + +void xf86WriteSparse8(Value, Base, Offset) +int Value; +pointer Base; +unsigned long Offset; +{ + unsigned long msb = 0; + unsigned int b = Value & 0xffU; + + if (xf86SparseShift != 7) { /* not JENSEN */ + if (Offset >= (1UL << 24)) { + msb = Offset & 0xf8000000; + Offset -= msb; + if (msb) { + sethae(msb); + } + } + } + *(vuip) ((unsigned long)Base + (Offset << xf86SparseShift)) = b * 0x01010101; + if (msb) + sethae(0); +} + +void xf86WriteSparse16(Value, Base, Offset) +int Value; +pointer Base; +unsigned long Offset; +{ + unsigned long msb = 0; + unsigned int w = Value & 0xffffU; + + if (xf86SparseShift != 7) { /* not JENSEN */ + if (Offset >= (1UL << 24)) { + msb = Offset & 0xf8000000; + Offset -= msb; + if (msb) { + sethae(msb); + } + } + } + *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(1<<(xf86SparseShift-2))) = + w * 0x00010001; + if (msb) + sethae(0); +} + +void xf86WriteSparse32(Value, Base, Offset) +int Value; +pointer Base; +unsigned long Offset; +{ + unsigned long msb = 0; + + if (xf86SparseShift != 7) { /* not JENSEN */ + if (Offset >= (1UL << 24)) { + msb = Offset & 0xf8000000; + Offset -= msb; + if (msb) { + sethae(msb); + } + } + } + *(vuip)((unsigned long)Base+(Offset<<xf86SparseShift)+(3<<(xf86SparseShift-2))) = Value; + if (msb) + sethae(0); +} +#endif /* __alpha__ */ diff --git a/hw/xfree86/os-support/lynxos/lynx_init.c b/hw/xfree86/os-support/lynxos/lynx_init.c new file mode 100644 index 000000000..6c0e00aa3 --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_init.c @@ -0,0 +1,198 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_init.c,v 3.1.6.1 1998/02/06 22:36:51 hohndel Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +static int VTnum = -1; + +void xf86OpenConsole() +{ + struct vt_mode VT; + char vtname1[11]; + int i, fd, pgrp; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be running with root " + "permissions\n" + "You should be using Xwrapper to start the server or xdm.\n" + "We strongly advise against making the server SUID root!\n"); + } + + /* + * setup the virtual terminal manager + * NOTE: + * We use the out-of-the-box atc terminal driver, + * not the GE contributed vdt driver. + * Also, we do setup signals for VT switching which + * is not really necessary because we don't feed the + * VT switch keystrokes to the kernel in xf86Events.c + * (it bombs occasionally...) + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + } + else + { + /* We could use /dev/con which is usually a symlink + * to /dev/atc0 but one could configure the system + * to use a serial line as console device, so to + * be sure we take /dev/atc0. + */ + if ((fd = open("/dev/atc0",O_WRONLY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open /dev/atc0 (%s)\n", + strerror(errno)); + } + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + { + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + } + close(fd); + } + ErrorF("(using VT number %d)\n\n", xf86Info.vtno); + + sprintf(vtname1,"/dev/atc%d",xf86Info.vtno); + + pgrp = getpgrp(); /* POSIX version ! */ + ioctl(xf86Info.consoleFd, TIOCSPGRP, &pgrp); + + if ((xf86Info.consoleFd = open(vtname1,O_RDWR|O_NDELAY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open %s (%s)\n", + vtname1, strerror(errno)); + } + /* change ownership of the vt */ + chown(vtname1, getuid(), getgid()); + + /* Reading Config after opening the VT get's rid of */ + /* problems with LynxOS VT handling (i.e. VT_OPENQUERY */ + /* without open() leaves the vtxx busy until next */ + /* open/close) */ + + xf86Config(FALSE); /* Read XF86Config */ + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + } + + /* for future use... */ + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86VTSema) + sleep(5); + } + return; +} + +void xf86CloseConsole() +{ + struct vt_mode VT; + +#if 0 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); +#endif + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int xf86ProcessArgument (argc, argv, i) +int argc; +char *argv[]; +int i; +{ + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + return; +} + diff --git a/hw/xfree86/os-support/lynxos/lynx_io.c b/hw/xfree86/os-support/lynxos/lynx_io.c new file mode 100644 index 000000000..e0134609e --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_io.c @@ -0,0 +1,172 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_io.c,v 3.3 1996/08/10 13:07:36 dawes Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +#if defined(KDMKTONE) || defined(KIOCSOUND) +/* Lynx 2.2.1 has sophisticated atc stuff.... */ +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + if (loudness && pitch) + { +#ifdef KDMKTONE + /* + * If we have KDMKTONE use it to avoid putting the server + * to sleep + */ + ioctl(xf86Info.consoleFd, KDMKTONE, + (pitch & 0xffff) | + (((unsigned long)duration * + loudness / 50) << 16)); +#else + ioctl(xf86Info.consoleFd, KIOCSOUND, pitch); + usleep(xf86Info.bell_duration * loudness * 20); + ioctl(xf86Info.consoleFd, KIOCSOUND, 0); +#endif + } +} + +#else + +/* this is pulled from /sys/drivers/vt100/atbeep.c */ + +#define SPEAKER_CONTROL 0x61 +#define TIMER_CONTROL 0x43 +#define TIMER_DATA 0x42 +#define TIMER_LOAD_CMD 0xb6 + +#define TIMER_CONSTANT 1193280 +#define FREQ_LO(f) ((TIMER_CONSTANT / (f)) % 256) +#define FREQ_HI(f) ((TIMER_CONSTANT / (f)) / 256) + +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + int flo = FREQ_LO(pitch); + int fhi = FREQ_HI(pitch); + + outb(TIMER_CONTROL, TIMER_LOAD_CMD); + outb(TIMER_DATA, flo); + outb(TIMER_DATA, fhi); + + /* speaker on */ + outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) | 3); + usleep(xf86Info.bell_duration * loudness * 20); + /* speaker off */ + outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) & ~3); +} +#endif + +void xf86SetKbdLeds(leds) +int leds; +{ +} + +int xf86GetKbdLeds() +{ + return 0; +} + +void xf86SetKbdRepeat(char rad) +{ +} + +static struct termio kbdtty; + +void xf86KbdInit() +{ + ioctl(xf86Info.consoleFd, TCGETA, &kbdtty); +} + +int xf86KbdOn() +{ + struct termio nTty; + + /* set CAPS_LOCK to behave as CAPS_LOCK not as CTRL */ + write(xf86Info.consoleFd, "\033<", 2); + + /* enable scan mode */ + ioctl(xf86Info.consoleFd, TIO_ENSCANMODE, NULL); + + nTty = kbdtty; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME]=0; + nTty.c_cc[VMIN]=1; + ioctl(xf86Info.consoleFd, TCSETA, &nTty); + + return(xf86Info.consoleFd); +} + +int xf86KbdOff() +{ + /* disable scan mode */ + ioctl(xf86Info.consoleFd, TIO_DISSCANMODE, NULL); + ioctl(xf86Info.consoleFd, TCSETA, &kbdtty); + return(xf86Info.consoleFd); +} + +void xf86MouseInit(mouse) +MouseDevPtr mouse; +{ + return; +} + +int xf86MouseOn(mouse) +MouseDevPtr mouse; +{ + if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open mouse (%s) - Continuing...\n", + strerror(errno)); + return(-2); + } + FatalError("Cannot open mouse (%s)\n", strerror(errno)); + } + + /* assert DTR */ + ioctl(mouse->mseFd, TIOCSDTR, NULL); + + xf86SetupMouse(mouse); + + return(mouse->mseFd); +} diff --git a/hw/xfree86/os-support/lynxos/lynx_mmap.c b/hw/xfree86/os-support/lynxos/lynx_mmap.c new file mode 100644 index 000000000..621f42c5d --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_mmap.c @@ -0,0 +1,66 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_mmap.c,v 3.2 1996/09/29 13:38:29 dawes Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Read BIOS using smem_create facility + */ + +int xf86ReadBIOS(Base, Offset, Buf, Len) +unsigned long Base; +unsigned long Offset; +unsigned char *Buf; +int Len; +{ + char *p; + int mlen; + + mlen = (Offset + Len + 4095) & ~4096; + p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); + if (p == NULL) + { + /* check if there is a stale segment around */ + if (smem_remove("BIOS-probe") == 0) { + ErrorF("xf86ReadBios: removed stale smem_ segment\n"); + p = smem_create("BIOS-probe", (char *)Base, mlen, SM_READ); + } + if (p == NULL) { + ErrorF("xf86ReadBios: Failed to smem_create Base %x len %x %s \n", + Base, mlen, strerror(errno)); + return(-1); + } + } + memcpy(Buf, p + Offset, Len); + smem_create(NULL, p, 0, SM_DETACH); + smem_remove("BIOS-probe"); + return(Len); +} diff --git a/hw/xfree86/os-support/lynxos/lynx_video.c b/hw/xfree86/os-support/lynxos/lynx_video.c new file mode 100644 index 000000000..94b2f0ecd --- /dev/null +++ b/hw/xfree86/os-support/lynxos/lynx_video.c @@ -0,0 +1,167 @@ +/* + * Copyright 1993 by Thomas Mueller + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Mueller not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Mueller makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.2.4.1 1997/05/09 07:15:24 hohndel Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +typedef struct +{ + char name[16]; + pointer Base; + long Size; + char *ptr; + int RefCnt; +} +_SMEMS; + +#define MAX_SMEMS 8 + +static _SMEMS smems[MAX_SMEMS]; + +static void +smemCleanup() +{ + int i; + + for (i = 0; i < MAX_SMEMS; i++) { + if (*smems[i].name && smems[i].ptr) { + (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); + (void)smem_remove(smems[i].name); + *smems[i].name = '\0'; + smems[i].ptr = NULL; + smems[i].Base = NULL; + smems[i].Size = 0; + smems[i].RefCnt = 0; + } + } +} + +pointer xf86MapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + static int once; + int free_slot = -1; + int i; + + if (!once) + { + atexit(smemCleanup); + once = 1; + } + for (i = 0; i < MAX_SMEMS; i++) + { + if (!*smems[i].name && free_slot == -1) + free_slot = i; + if (smems[i].Base == Base && smems[i].Size == Size && *smems[i].name) { + smems[i].RefCnt++; + return smems[i].ptr; + } + } + if (i == MAX_SMEMS && free_slot == -1) + { + FatalError("xf86MapVidMem: failed to smem_create Base %x Size %x (out of SMEMS entries)\n", + Base, Size); + } + + i = free_slot; + sprintf(smems[i].name, "Video-%d", i); + smems[i].Base = Base; + smems[i].Size = Size; + smems[i].ptr = smem_create(smems[i].name, Base, Size, SM_READ|SM_WRITE); + smems[i].RefCnt = 1; + if (smems[i].ptr == NULL) + { + /* check if there is a stale segment around */ + if (smem_remove(smems[i].name) == 0) { + ErrorF("xf86MapVidMem: removed stale smem_ segment %s\n", + smems[i].name); + smems[i].ptr = smem_create(smems[i].name, + Base, Size, SM_READ|SM_WRITE); + } + if (smems[i].ptr == NULL) { + *smems[i].name = '\0'; + FatalError("xf86MapVidMem: failed to smem_create Base %x Size %x (%s)\n", + Base, Size, strerror(errno)); + } + } + return smems[i].ptr; +} + +void xf86UnMapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + int i; + + for (i = 0; i < MAX_SMEMS; i++) + { + if (*smems[i].name && smems[i].ptr == Base && smems[i].Size == Size) + { + if (--smems[i].RefCnt > 0) + return; + (void)smem_create(NULL, smems[i].ptr, 0, SM_DETACH); + (void)smem_remove(smems[i].name); + *smems[i].name = '\0'; + smems[i].RefCnt = 0; + return; + } + } + ErrorF("xf86UnMapVidMem: no SMEM found for Base = %lx Size = %lx\n", Base, Size); +} + +Bool xf86LinearVidMem() +{ + return(TRUE); +} + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts() +{ + return(TRUE); +} + +void xf86EnableInterrupts() +{ + return; +} + diff --git a/hw/xfree86/os-support/misc/xf86_IlHack.c b/hw/xfree86/os-support/misc/xf86_IlHack.c new file mode 100644 index 000000000..204fe4717 --- /dev/null +++ b/hw/xfree86/os-support/misc/xf86_IlHack.c @@ -0,0 +1,14 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_IlHack.c,v 3.4 1996/12/23 06:50:24 dawes Exp $ */ +/* + * This file is an incredible crock to get the normally-inline functions + * built into the server so that things can be debugged properly. + * + * Note: this doesn't work when using a compiler other than GCC. + */ +/* $Xorg: xf86_IlHack.c,v 1.3 2000/08/17 19:51:25 cpqbld Exp $ */ + + +#define static /**/ +#define __inline__ /**/ +#undef NO_INLINE +#include "compiler.h" diff --git a/hw/xfree86/os-support/misc/xf86_Util.c b/hw/xfree86/os-support/misc/xf86_Util.c new file mode 100644 index 000000000..a68d2ca89 --- /dev/null +++ b/hw/xfree86/os-support/misc/xf86_Util.c @@ -0,0 +1,126 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/misc/xf86_Util.c,v 3.4 1996/12/23 06:50:25 dawes Exp $ */ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86_Util.c,v 1.3 2000/08/17 19:51:26 cpqbld Exp $ */ + +/* + * This file is for utility functions that will be shared by other pieces + * of the system. Putting things here ensure that all the linking order + * dependencies are dealt with, as this library will be linked in last. + */ + +#include <ctype.h> + +/* + * A portable hack at implementing strcasecmp() + * The characters '_', ' ', and '\t' are ignored in the comparison + */ +int StrCaseCmp(s1, s2) +const char *s1, *s2; +{ + char c1, c2; + + if (*s1 == 0) + if (*s2 == 0) + return(0); + else + return(1); + + while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') + s1++; + while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') + s2++; + c1 = (isupper(*s1) ? tolower(*s1) : *s1); + c2 = (isupper(*s2) ? tolower(*s2) : *s2); + while (c1 == c2) + { + if (c1 == '\0') + return(0); + s1++; s2++; + while (*s1 == '_' || *s1 == ' ' || *s1 == '\t') + s1++; + while (*s2 == '_' || *s2 == ' ' || *s2 == '\t') + s2++; + c1 = (isupper(*s1) ? tolower(*s1) : *s1); + c2 = (isupper(*s2) ? tolower(*s2) : *s2); + } + return(c1 - c2); +} + + +/* For use only with gcc */ +#ifdef __GNUC__ + +#include "os.h" + +char *debug_alloca(file, line, size) +char *file; +int line; +int size; +{ + char *ptr; + + ptr = (char *)Xalloc(size); + ErrorF("Alloc: %s line %d; ptr = 0x%x, length = %d\n", file, line, + ptr, size); + return ptr; +} + +void debug_dealloca(file, line, ptr) +char *file; +int line; +char *ptr; +{ + ErrorF("Dealloc: %s line %d; ptr = 0x%x\n", file, line, ptr); + Xfree(ptr); +} +#endif + +#if defined(ISC) || defined(Lynx) + +#include <math.h> + +/* Needed for apm_driver.c */ +/* These functions are modeled after the functions inside gnu's libc */ + +static double copysign(double x, double y) +{ + x = fabs(x); + return y < 0 ? - x : x; +} + +double RInt(double x) +{ + double s,t; + const double one = 1.0; + const static double L = 4503599627370496.0E0; + + if (x!=x) + return(x); + if (copysign(x,one) >= L) + return(x); + s = copysign(L,x); + t = x + s; + return (t - s); +} +#endif diff --git a/hw/xfree86/os-support/sco/VTsw_sco.c b/hw/xfree86/os-support/sco/VTsw_sco.c new file mode 100644 index 000000000..386cd21ff --- /dev/null +++ b/hw/xfree86/os-support/sco/VTsw_sco.c @@ -0,0 +1,94 @@ +/* XFree86: $ */ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1993 by David McCullough <davidm@stallion.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: VTsw_sco.c,v 1.3 2000/08/17 19:51:28 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Handle the VT-switching interface for SCO + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void xf86VTRequest(sig) +int sig; +{ + signal(sig, (void(*)())xf86VTRequest); + xf86Info.vtRequestsPending = TRUE; + return; +} + +Bool xf86VTSwitchPending() +{ + return(xf86Info.vtRequestsPending ? TRUE : FALSE); +} + +Bool xf86VTSwitchAway() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + { + return(FALSE); + } + else + { + return(TRUE); + } +} + +Bool xf86VTSwitchTo() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + { + return(FALSE); + } + else + { + /* + * make sure the console driver thinks the console is in + * graphics mode. Under mono we have to do the two as the + * console driver only allows valid modes for the current + * video card and Herc or vga are the only devices currently + * supported. + */ + if (ioctl(xf86Info.consoleFd, SW_VGA12, 0) < 0) + if (ioctl(xf86Info.consoleFd, SW_HGC_P0, 0) < 0) + { + ErrorF("Failed to set graphics mode : %s\n", + strerror(errno)); + } + + return(TRUE); + } +} diff --git a/hw/xfree86/os-support/sco/sco_init.c b/hw/xfree86/os-support/sco/sco_init.c new file mode 100644 index 000000000..a61dcdfce --- /dev/null +++ b/hw/xfree86/os-support/sco/sco_init.c @@ -0,0 +1,261 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_init.c,v 3.10.2.1 1998/02/06 22:36:53 hohndel Exp $ */ +/* + * Copyright 1993 by David McCullough <davidm@stallion.oz.au> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of David McCullough and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. David McCullough and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * DAVID MCCULLOUGH AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH OR DAVID WEXELBLAT BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sco_init.c,v 1.3 2000/08/17 19:51:28 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +static Bool KeepTty = FALSE; +static int VTnum = -1; +static int sco_console_mode = -1; + +extern void xf86VTRequest( +#if NeedFunctionPrototypes + int +#endif +); + +void xf86OpenConsole() +{ + int fd,wc; + struct vt_mode VT; + struct stat status; + char vtname[11]; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be running with root " + "permissions\n" + "You should be using Xwrapper to start the server or xdm.\n" + "We strongly advise against making the server SUID root!\n"); + } + + /* + * setup the virtual terminal manager + * + * SCO vts start at tty01 which is vt00, if you could call them VT's. + * We use the numbers 1..X as it fits nicer with the device naming + * scheme. + * + * In os/osinit.c we took the precuation of not closing stdin so that + * we can use the current vt if no vt was specified on the command line + * + * Under SCO VT_OPENQRY does nothing at all + * if nothing was specified we try to determine the VT from stdin + */ + if ((VTnum != -1) && (VTnum != 0)) + { + wc = VTnum - 1; + } + else + { + if ((fstat(0, &status) >= 0) && (status.st_mode & S_IFCHR)) + { + wc = minor(status.st_rdev); + } + else + { + ErrorF("%s: Failed to stat stdin, using tty02 (%s)\n", + "xf86OpenConsole", strerror(errno)); + wc = 1; /* tty02 */ + } + } + ErrorF("(using VT number %d)\n\n", wc + 1); + + sprintf(vtname,"/dev/tty%02d", wc+1); /* /dev/tty[01-12] */ + + if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) < 0) + { + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + vtname, strerror(errno)); + } + + /* now we can dispose of stdin */ + + if (freopen(vtname, "r+", stdin) == (FILE *) NULL) + { + FatalError("xf86OpenConsole: Cannot reopen stdin as %s (%s)\n", + vtname, strerror(errno)); + } + + /* now we can fixup stdout */ + + if (freopen(vtname, "r+", stdout) == (FILE *) NULL) + { + FatalError("xf86OpenConsole: Cannot reopen stdout as %s (%s)\n", + vtname, strerror(errno)); + } + + /* We activate the console just in case its not the one we are on */ + xf86Info.vtno = wc; + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, wc) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + + xf86Config(FALSE); /* Read XF86Config */ + + if (!KeepTty) + { + setpgrp(); + } + + /* + * now get the VT + */ + if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed on console (%s)\n", + strerror(errno)); + } + if (ioctl(xf86Info.consoleFd, VGA_IOPRIVL, 1) < 0) + { + FatalError("xf86OpenConsole: VGA_IOPRIVL failed for VGA acc (%s)\n", + strerror(errno)); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", + strerror(errno)); + } + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + VT.frsig = SIGUSR1; + VT.waitv = 0; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + /* + * make sure the console driver thinks the console is in graphics + * mode. Under mono we have to do the two as the console driver only + * allows valid modes for the current video card and Herc or vga are + * the only devices currently supported. + */ + if (ioctl(xf86Info.consoleFd, SW_VGA12, 0) < 0) + if (ioctl(xf86Info.consoleFd, SW_HGC_P0, 0) < 0) + { + ErrorF("Failed to set graphics mode (%s)\n", + strerror(errno)); + } + + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + } + return; +} + +void xf86CloseConsole() +{ + struct vt_mode VT; + + ioctl(xf86Info.consoleFd, VT_RELDISP, 1); + if (sco_console_mode != -1) + { + ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int xf86ProcessArgument(argc, argv, i) +int argc; +char *argv[]; +int i; +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + if (!strcmp(argv[i], "-crt")) + { + if ((++i > argc) || + (sscanf(argv[i], "/dev/tty%2d", &VTnum) == 0)) + { + UseMsg(); + VTnum = -1; + return(0); + } + else + { + return(2); + } + } + return(0); +} + +void xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + ErrorF("-crt /dev/ttyXX use the specified VT number\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/hw/xfree86/os-support/sco/sco_io.c b/hw/xfree86/os-support/sco/sco_io.c new file mode 100644 index 000000000..162d1b76b --- /dev/null +++ b/hw/xfree86/os-support/sco/sco_io.c @@ -0,0 +1,117 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_io.c,v 3.3 1996/12/23 06:50:49 dawes Exp $ */ +/* + * Copyright 1993 by David McCullough <davidm@stallion.oz.au> + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of David McCullough and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. David McCullough + * and David Dawes makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * DAVID MCCULLOUGH AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sco_io.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86_Config.h" + +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + if (loudness && pitch) + { + ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch); + usleep(duration * loudness * 20); + ioctl(xf86Info.consoleFd, KIOCSOUND, 0); + } +} + +void xf86SetKbdLeds(leds) +int leds; +{ + /* + * sleep the first time through under SCO. There appears to be a + * timing problem in the driver which causes the keyboard to be lost. + * This sleep stops it from occurring. The sleep could proably be + * a lot shorter as even trace can fix the problem. You may + * prefer a usleep(100). + */ + static int once = 1; + + if (once) + { + sleep(1); + once = 0; + } + ioctl(xf86Info.consoleFd, KDSETLED, leds ); +} + +void xf86MouseInit(mouse) +MouseDevPtr mouse; +{ + if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open mouse (%s) - Continuing...\n", + strerror(errno)); + return; + } + FatalError("Cannot open mouse (%s)\n", strerror(errno)); + } +} + +int xf86MouseOn(mouse) +MouseDevPtr mouse; +{ + xf86SetupMouse(mouse); + + /* Flush any pending input */ + ioctl(mouse->mseFd, TCFLSH, 0); + + return(mouse->mseFd); +} + +int xf86MouseOff(mouse, doclose) +MouseDevPtr mouse; +Bool doclose; +{ + if (mouse->mseFd >= 0) + { + if (mouse->mseType == P_LOGI) + { + write(mouse->mseFd, "U", 1); + xf86SetMouseSpeed(mouse, mouse->baudRate, + mouse->oldBaudRate, + xf86MouseCflags[P_LOGI]); + } + if (doclose) + { + close(mouse->mseFd); + } + } + return(mouse->mseFd); +} diff --git a/hw/xfree86/os-support/sco/sco_mouse.c b/hw/xfree86/os-support/sco/sco_mouse.c new file mode 100644 index 000000000..564852ae3 --- /dev/null +++ b/hw/xfree86/os-support/sco/sco_mouse.c @@ -0,0 +1,175 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_mouse.c,v 3.8 1996/12/23 06:50:50 dawes Exp $ */ + + + + + +/* $Xorg: sco_mouse.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */ + +/******************************************************************************/ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +/******************************************************************************/ +#ifdef USE_OSMOUSE +/******************************************************************************/ + +#include <sys/event.h> +#include <mouse.h> +#include "xf86_Config.h" + +static dmask_t real_mask = (dmask_t) (D_REL | D_BUTTON); +static int config_buttons = 0; + +extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords, + unsigned long start, unsigned long stop, + ScreenPtr pScreen); + +/******************************************************************************/ +/* + * Handle any XF86Config options for "OsMouse", How you treat errors + * is up to you, they may or may not be Fatal + */ + +void +xf86OsMouseOption(lt, lp) + int lt; /* type returned by gettoken */ + pointer lp; /* The lexical return symbol */ +{ + if (lt != NUMBER) { + ErrorF("%s: Invalid Argument to OsMouse, %s\n", + "xf86OsMouseOption", "Number of buttons expected"); + return; + } + config_buttons = ((LexPtr)lp)->num; +} + +/******************************************************************************/ +/* + * xf86OsMouseProc -- + * Handle the initialization, etc. of a mouse + */ + +int +xf86OsMouseProc(pPointer, what) + DeviceIntPtr pPointer; + int what; +{ + unchar *map; + int i, err, buttons; + struct devinfo *dip; + dmask_t dmask; + + switch (what) { + case DEVICE_INIT: + + pPointer->public.on = FALSE; + + if (ev_init() < 0) + ErrorF("ev_init: Failed to initialize event driver\n"); + + dmask = real_mask; + xf86Info.mouseDev->mseFd = ev_open(&dmask); + switch (xf86Info.mouseDev->mseFd) { + case -1: FatalError("ev_open: Error in Configuration files\n"); + case -2: FatalError("ev_open: No mouse devices to attach\n"); + case -3: FatalError("ev_open: Unable to open a found device\n"); + case -4: FatalError("ev_open: unable to open an event queue\n"); + default: + if (xf86Info.mouseDev->mseFd < 0) + FatalError("ev_open: Failed to open device, reason unkown\n"); + break; + } + if (dmask != real_mask) + FatalError("Could not attach the mouse device (0x%x)\n", dmask); + + dip = (struct devinfo *) NULL; + if ((dip = ev_getdev(D_REL, dip)) == (struct devinfo *) NULL) + FatalError("Could not find info on mouse device\n"); + + buttons = config_buttons > 0 ? config_buttons : ((int) dip->buttons); + buttons = buttons > 0 ? buttons : 3; /* just in case */ + + ErrorF("%s OsMouse has %d buttons\n", + buttons == config_buttons ? XCONFIG_GIVEN : XCONFIG_PROBED, + buttons); + + map = (unchar *) xalloc(buttons + 1); + if (map == (unchar *) NULL) + FatalError("Failed to allocate OsMouse map structure\n"); + + for (i = 1; i <= buttons; i++) + map[i] = i; + + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + buttons, + miPointerGetMotionEvents, + (PtrCtrlProcPtr)xf86MseCtrl, + 0); + xfree(map); + ev_suspend(); /* suspend device until its turned on */ + break; + + case DEVICE_ON: + ev_resume(); + AddEnabledDevice(xf86Info.mouseDev->mseFd); + xf86Info.mouseDev->lastButtons = 0; + xf86Info.mouseDev->emulateState = 0; + pPointer->public.on = TRUE; + break; + + case DEVICE_CLOSE: + case DEVICE_OFF: + pPointer->public.on = FALSE; + RemoveEnabledDevice(xf86Info.mouseDev->mseFd); + if (what == DEVICE_CLOSE) { + ev_close(); + xf86Info.mouseDev->mseFd = -1; + } else + ev_suspend(); + break; + } + + return Success; +} + +/******************************************************************************/ +/* + * xf86OsMouseEvents -- + * Get some events from our queue. Process all outstanding events now. + */ + +void +xf86OsMouseEvents() +{ + EVENT *evp; + static long time = -1; + + while ((evp = ev_read()) != (EVENT *) NULL ) { +#if DEBUG + if (time == -1) + time = EV_TIME(*evp); + ErrorF("sco_event time(%ld) tag(%d) butts(%d) x(%ld) y(%ld)\n", + EV_TIME(*evp) - time, EV_TAG(*evp), EV_BUTTONS(*evp), + EV_DX(*evp), EV_DY(*evp)); +#endif + xf86PostMseEvent(xf86Info.pMouse,EV_BUTTONS(*evp), EV_DX(*evp), -(EV_DY(*evp))); + ev_pop(); + } + + xf86Info.inputPending = TRUE; +} + +/******************************************************************************/ +#endif /* USE_OSMOUSE */ +/******************************************************************************/ diff --git a/hw/xfree86/os-support/sco/sco_video.c b/hw/xfree86/os-support/sco/sco_video.c new file mode 100644 index 000000000..14947fa85 --- /dev/null +++ b/hw/xfree86/os-support/sco/sco_video.c @@ -0,0 +1,284 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/sco_video.c,v 3.2.2.1 1997/07/19 04:59:31 dawes Exp $ */ +/* + * Copyright 1993 by David McCullough <davidm@stallion.oz.au> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of David McCullough and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of the + * software without specific, written prior permission. David McCullough and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * DAVID MCCULLOUGH AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL DAVID MCCULLOUGH OR DAVID WEXELBLAT BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sco_video.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS]; +static int ver_once = 1; + +/***************************************************************************/ +/* + * To map the video-memory, we use the MAP_CLASS ioctl. + * Different drivers may have to do another one of these + * for their own special registers (ie., ATI). To find + * out which strings are valid look in /etc/conf/pack.d/cn/class.h + * + * if we fail to find one of these we try for the dmmap driver + */ + +struct { + unsigned long base, size; + char *class; +} SCO_Mapping[] = { + {0xA0000, 0x10000, "VGA"}, + {0xA0000, 0x20000, "SVGA"}, + {0xB0000, 0x08000, "HGA"}, + {0x0, 0x0, ""}, +}; + +/* ARGSUSED */ +pointer xf86MapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + int i; + char *class = (char *)NULL; + pointer base; + + for (i=0; SCO_Mapping[i].base != 0; i++) + { + if (((pointer)SCO_Mapping[i].base == Base) && + (SCO_Mapping[i].size == Size)) + { + class = SCO_Mapping[i].class; + break; + } + } + if (class == (char *)NULL) + { + int fd; + +#if defined(SVR4) || defined(SCO325) + if ((fd = open(DEV_MEM, O_RDWR)) < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE, + MAP_SHARED, fd, (off_t)Base); + close(fd); + if ((long)base == -1) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + } + + return(base); +#else + MapDSC[ScreenNum][Region].vaddr = (char *) NULL; + MapDSC[ScreenNum][Region].physaddr = (char *) Base; + MapDSC[ScreenNum][Region].length = Size; + MapDSC[ScreenNum][Region].ioflg = 1; + if ((fd = open("/dev/dmmap", O_RDWR)) >= 0) { + if (ioctl(fd, KDMAPDISP, &MapDSC[ScreenNum][Region]) == -1) + ErrorF("xf86MapVidMem: dmmap KDMAPDISP failed (%s)\n", + strerror(errno)); + else { + if (ver_once) + ErrorF("Using dmmap version 0x%04x.\n", + ioctl(fd, -1)); + ver_once = 0; + close(fd); + return(MapDSC[ScreenNum][Region].vaddr); + } + close(fd); + } + FatalError("xf86MapVidMem:No class map defined for (%x,%x)\n", + Base, Size); + /* NOTREACHED */ +#endif + } + + base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class); + if ((int)base == -1) + { + FatalError("xf86MapVidMem:Failed to map video mem class %s\n", + class); + /* NOTREACHED */ + } + return(base); +} + +/* + * Nothing to do here if it wasn't mapped using the dmmap driver + */ +/* ARGSUSED */ +void xf86UnMapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + int fd; + +#if defined (SVR4) || defined(SCO325) + munmap(Base, Size); +#else /* SVR4 */ + if (MapDSC[ScreenNum][Region].vaddr) { + if ((fd = open("/dev/dmmap", O_RDWR)) < 0) { + if (ioctl(fd, KDUNMAPDISP, &MapDSC[ScreenNum][Region]) == -1) + ErrorF("xf86UnMapVidMem: dmmap KDUNMAPDISP failed (%s)\n", + strerror(errno)); + close(fd); + } + MapDSC[ScreenNum][Region].vaddr = (char *) NULL; + MapDSC[ScreenNum][Region].physaddr = (char *) NULL; + MapDSC[ScreenNum][Region].length = 0; + MapDSC[ScreenNum][Region].ioflg = 0; + } +#endif + return; +} + +/* ARGSUSED */ +Bool xf86LinearVidMem() +{ + int fd, ver; + +#if defined(SVR4) || defined(SCO325) + return TRUE; +#else + if ((fd = open("/dev/dmmap", O_RDWR)) >= 0) { + ver = ioctl(fd, -1); + close(fd); + if (ver >= 0) { + if (ver_once) + ErrorF("Using dmmap version 0x%04x.\n", ver); + ver_once = 0; + return(TRUE); + } + } + return(FALSE); +#endif +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ScreenEnabled[MAXSCREENS]; +static Bool IOEnabled = FALSE; +static Bool InitDone = FALSE; + +void xf86ClearIOPortList(ScreenNum) +int ScreenNum; +{ + int i; + + if (!InitDone) + { + for (i = 0; i < MAXSCREENS; i++) + ScreenEnabled[i] = FALSE; + InitDone = TRUE; + } +} + +/* ARGSUSED */ +void xf86AddIOPorts(ScreenNum, NumPorts, Ports) +int ScreenNum; +int NumPorts; +unsigned *Ports; +{ +} + +void xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + ScreenEnabled[ScreenNum] = TRUE; + + if (IOEnabled) + return; + + if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) + FatalError("Failed to set IOPL for extended I/O\n"); + IOEnabled = TRUE; + return; +} + +void xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + ScreenEnabled[ScreenNum] = FALSE; + + if (!IOEnabled) + return; + + for (i = 0; i < MAXSCREENS; i++) + if (ScreenEnabled[i]) + return; + sysi86(SI86V86, V86SC_IOPL, 0); + IOEnabled = FALSE; + return; +} + +void xf86DisableIOPrivs() +{ + if (IOEnabled) + sysi86(SI86V86, V86SC_IOPL, 0); + return; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts() +{ +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + return(TRUE); +} + +void xf86EnableInterrupts() +{ +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + return; +} diff --git a/hw/xfree86/os-support/shared/VTsw_noop.c b/hw/xfree86/os-support/shared/VTsw_noop.c new file mode 100644 index 000000000..960ca9935 --- /dev/null +++ b/hw/xfree86/os-support/shared/VTsw_noop.c @@ -0,0 +1,51 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_noop.c,v 3.1 1996/12/23 06:50:56 dawes Exp $ */ +/* + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: VTsw_noop.c,v 1.3 2000/08/17 19:51:29 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * No-op functions for OSs without VTs + */ + +Bool xf86VTSwitchPending() +{ + return(FALSE); +} + +Bool xf86VTSwitchAway() +{ + return(FALSE); +} + +Bool xf86VTSwitchTo() +{ + return(TRUE); +} diff --git a/hw/xfree86/os-support/shared/VTsw_usl.c b/hw/xfree86/os-support/shared/VTsw_usl.c new file mode 100644 index 000000000..47c4c5f9d --- /dev/null +++ b/hw/xfree86/os-support/shared/VTsw_usl.c @@ -0,0 +1,80 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c,v 3.1 1996/12/23 06:50:57 dawes Exp $ */ +/* + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: VTsw_usl.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Handle the VT-switching interface for OSs that use USL-style ioctl()s + * (the sysv, sco, and linux subdirs). + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void xf86VTRequest(sig) +int sig; +{ + signal(sig, (void(*)())xf86VTRequest); + xf86Info.vtRequestsPending = TRUE; + return; +} + +Bool xf86VTSwitchPending() +{ + return(xf86Info.vtRequestsPending ? TRUE : FALSE); +} + +Bool xf86VTSwitchAway() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + { + return(FALSE); + } + else + { + return(TRUE); + } +} + +Bool xf86VTSwitchTo() +{ + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + { + return(FALSE); + } + else + { + return(TRUE); + } +} diff --git a/hw/xfree86/os-support/shared/bios_devmem.c b/hw/xfree86/os-support/shared/bios_devmem.c new file mode 100644 index 000000000..f26d7a524 --- /dev/null +++ b/hw/xfree86/os-support/shared/bios_devmem.c @@ -0,0 +1,139 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/bios_devmem.c,v 3.3 1996/12/23 06:50:58 dawes Exp $ */ +/* + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: bios_devmem.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include <string.h> + +/* + * Read BIOS via /dev/mem. + */ + +#ifndef DEV_MEM +# define DEV_MEM "/dev/mem" +#endif + +int xf86ReadBIOS(Base, Offset, Buf, Len) +unsigned long Base; +unsigned long Offset; +unsigned char *Buf; +int Len; +{ +#ifdef __alpha__ + /* + * The Alpha version uses "mmap" instead of "lseek/read", + * because these (currently) don't work for BUS memory. + * We trick "mmap" into mapping BUS memory for us via BUS_BASE, + * which is the KSEG address of the start of the DENSE memory + * area. + */ + + /* + * NOTE: there prolly ought to be more validity checks and all + * re: boundaries and sizes and such... + */ + +/* + * The Jensen lacks dense memory, thus we have to address the bus via + * the sparse addressing scheme. + * + * Martin Ostermann (ost@comnets.rwth-aachen.de) - Apr.-Sep. 1996 + */ + +#ifdef TEST_JENSEN_CODE /* define to test the Sparse addressing on a non-Jensen */ +#define SPARSE (5) +#define isJensen (1) +#else +#define isJensen (!_bus_base()) +#define SPARSE (7) +#endif + +extern unsigned long _bus_base(void); +extern unsigned long _bus_base_sparse(void); +#define BUS_BASE (isJensen ? _bus_base_sparse() : _bus_base()) +#define JENSEN_SHIFT(x) (isJensen ? ((long)x<<SPARSE) : (long)x) + +#define SIZE (64*1024) + + caddr_t base; + int fd; + + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) + { + ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM, + strerror(errno)); + return(-1); + } + + base = mmap((caddr_t)0, JENSEN_SHIFT(SIZE), PROT_READ, + MAP_SHARED, fd, (off_t)(JENSEN_SHIFT(Base) + BUS_BASE)); + + if (base == (caddr_t)-1UL) + { + ErrorF("xf86ReadBios: Failed to mmap %s (%s)\n", DEV_MEM, + strerror(errno)); + return(-1); + } + + SlowBCopyFromBus(base+JENSEN_SHIFT(Offset), Buf, Len); + + munmap((caddr_t)JENSEN_SHIFT(base), JENSEN_SHIFT(SIZE)); + close(fd); + return(Len); + +#else /* __alpha__ */ + + int fd; + + if ((fd = open(DEV_MEM, O_RDONLY)) < 0) + { + ErrorF("xf86ReadBios: Failed to open %s (%s)\n", DEV_MEM, + strerror(errno)); + return(-1); + } + + if (lseek(fd, (Base+Offset), SEEK_SET) < 0) + { + ErrorF("xf86ReadBios: %s seek failed (%s)\n", DEV_MEM, + strerror(errno)); + close(fd); + return(-1); + } + if (read(fd, Buf, Len) != Len) + { + ErrorF("xf86ReadBios: %s read failed (%s)\n", DEV_MEM, + strerror(errno)); + close(fd); + return(-1); + } + close(fd); + return(Len); +#endif /* __alpha__ */ +} diff --git a/hw/xfree86/os-support/shared/ioperm_noop.c b/hw/xfree86/os-support/shared/ioperm_noop.c new file mode 100644 index 000000000..4451d6f38 --- /dev/null +++ b/hw/xfree86/os-support/shared/ioperm_noop.c @@ -0,0 +1,60 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/ioperm_noop.c,v 3.1 1996/12/23 06:50:59 dawes Exp $ */ +/* + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: ioperm_noop.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */ + +/* + * Amoeba, Minix and 386BSD don't bother with I/O permissions, + * or the permissions are implicit with opening/enabling the console. + */ +void xf86ClearIOPortList(ScreenNum) +int ScreenNum; +{ + return; +} + +/* ARGSUSED */ +void xf86AddIOPorts(ScreenNum, NumPorts, Ports) +int ScreenNum; +int NumPorts; +unsigned *Ports; +{ + return; +} + +void xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + return; +} + +void xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + return; +} + +void xf86DisableIOPrivs() +{ + return; +} diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c new file mode 100644 index 000000000..8e92511d3 --- /dev/null +++ b/hw/xfree86/os-support/shared/posix_tty.c @@ -0,0 +1,174 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.8.2.1 1998/02/07 14:27:25 dawes Exp $ */ +/* + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. + * David Dawes makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: posix_tty.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" +#include "xf86_Config.h" + +static Bool not_a_tty = FALSE; + +void xf86SetMouseSpeed(mouse, old, new, cflag) +MouseDevPtr mouse; +int old; +int new; +unsigned cflag; +{ + struct termios tty; + char *c; + + if (not_a_tty) + return; + + if (tcgetattr(mouse->mseFd, &tty) < 0) + { + not_a_tty = TRUE; + ErrorF("Warning: %s unable to get status of mouse fd (%s)\n", + mouse->mseDevice, strerror(errno)); + return; + } + + /* this will query the initial baudrate only once */ + if (mouse->oldBaudRate < 0) { + switch (cfgetispeed(&tty)) + { + case B9600: + mouse->oldBaudRate = 9600; + break; + case B4800: + mouse->oldBaudRate = 4800; + break; + case B2400: + mouse->oldBaudRate = 2400; + break; + case B1200: + default: + mouse->oldBaudRate = 1200; + break; + } + } + + tty.c_iflag = IGNBRK | IGNPAR; + tty.c_oflag = 0; + tty.c_lflag = 0; + tty.c_cflag = (tcflag_t)cflag; + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 1; + + switch (old) + { + case 9600: + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + break; + case 4800: + cfsetispeed(&tty, B4800); + cfsetospeed(&tty, B4800); + break; + case 2400: + cfsetispeed(&tty, B2400); + cfsetospeed(&tty, B2400); + break; + case 1200: + default: + cfsetispeed(&tty, B1200); + cfsetospeed(&tty, B1200); + } + + if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n", + strerror(errno)); + return; + } + xf86FatalError("Unable to set status of mouse fd (%s)\n", + strerror(errno)); + } + + switch (new) + { + case 9600: + c = "*q"; + cfsetispeed(&tty, B9600); + cfsetospeed(&tty, B9600); + break; + case 4800: + c = "*p"; + cfsetispeed(&tty, B4800); + cfsetospeed(&tty, B4800); + break; + case 2400: + c = "*o"; + cfsetispeed(&tty, B2400); + cfsetospeed(&tty, B2400); + break; + case 1200: + default: + c = "*n"; + cfsetispeed(&tty, B1200); + cfsetospeed(&tty, B1200); + } + + if (mouse->mseType == P_LOGIMAN || mouse->mseType == P_LOGI) + { + if (write(mouse->mseFd, c, 2) != 2) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Unable to write to mouse fd (%s) - Continuing...\n", + strerror(errno)); + return; + } + xf86FatalError("Unable to write to mouse fd (%s)\n", + strerror(errno)); + } + } + usleep(100000); + + if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n", + strerror(errno)); + return; + } + xf86FatalError("Unable to set status of mouse fd (%s)\n", + strerror(errno)); + } +} + +int +xf86FlushInput(fd) +int fd; +{ + return tcflush(fd, TCIFLUSH); +} + diff --git a/hw/xfree86/os-support/shared/std_kbdEv.c b/hw/xfree86/os-support/shared/std_kbdEv.c new file mode 100644 index 000000000..bca8061db --- /dev/null +++ b/hw/xfree86/os-support/shared/std_kbdEv.c @@ -0,0 +1,49 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c,v 3.1 1996/12/23 06:51:02 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Dawes makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: std_kbdEv.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +void xf86KbdEvents() +{ + unsigned char rBuf[64]; + int nBytes, i; + + if ((nBytes = read( xf86Info.consoleFd, (char *)rBuf, sizeof(rBuf))) + > 0) + { + for (i = 0; i < nBytes; i++) + xf86PostKbdEvent(rBuf[i]); + } +} + diff --git a/hw/xfree86/os-support/shared/sysv_kbd.c b/hw/xfree86/os-support/shared/sysv_kbd.c new file mode 100644 index 000000000..2270be9f1 --- /dev/null +++ b/hw/xfree86/os-support/shared/sysv_kbd.c @@ -0,0 +1,105 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sysv_kbd.c,v 3.2 1996/12/23 06:51:07 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Dawes <dawes@XFree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Dawes makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sysv_kbd.c,v 1.3 2000/08/17 19:51:30 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +int xf86GetKbdLeds() +{ + int leds; + + ioctl(xf86Info.consoleFd, KDGETLED, &leds); + return(leds); +} + +#if NeedFunctionPrototypes +void xf86SetKbdRepeat(char rad) +#else +void xf86SetKbdRepeat(rad) +char rad; +#endif +{ +#ifdef KDSETRAD + ioctl(xf86Info.consoleFd, KDSETRAD, rad); +#endif +} + +static int kbdtrans; +static struct termio kbdtty; +static char *kbdemap = NULL; + +void xf86KbdInit() +{ +#ifdef KDGKBMODE + ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans); +#endif + ioctl (xf86Info.consoleFd, TCGETA, &kbdtty); +#if defined(E_TABSZ) && !defined(SCO325) + kbdemap = (char *)xalloc(E_TABSZ); + if (ioctl(xf86Info.consoleFd, LDGMAP, kbdemap) < 0) + { + xfree(kbdemap); + kbdemap = NULL; + } +#endif +} + +int xf86KbdOn() +{ + struct termio nTty; + + ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW); + ioctl(xf86Info.consoleFd, LDNMAP, 0); /* disable mapping completely */ + nTty = kbdtty; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8 | B9600; + nTty.c_lflag = 0; + nTty.c_cc[VTIME]=0; + nTty.c_cc[VMIN]=1; + ioctl(xf86Info.consoleFd, TCSETA, &nTty); + return(xf86Info.consoleFd); +} + +int xf86KbdOff() +{ + if (kbdemap) + { + ioctl(xf86Info.consoleFd, LDSMAP, kbdemap); + } + ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans); + ioctl(xf86Info.consoleFd, TCSETA, &kbdtty); + return(xf86Info.consoleFd); +} diff --git a/hw/xfree86/os-support/sysv/sysv_init.c b/hw/xfree86/os-support/sysv/sysv_init.c new file mode 100644 index 000000000..a253ab0b0 --- /dev/null +++ b/hw/xfree86/os-support/sysv/sysv_init.c @@ -0,0 +1,257 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_init.c,v 3.4.2.1 1998/02/06 22:36:54 hohndel Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sysv_init.c,v 1.3 2000/08/17 19:51:32 cpqbld Exp $ */ + +#include "X.h" +#include "Xmd.h" +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +static Bool KeepTty = FALSE; +#ifdef SVR4 +static Bool Protect0 = FALSE; +#endif +static int VTnum = -1; + +extern void xf86VTRequest( +#if NeedFunctionPrototypes + int +#endif +); + +void xf86OpenConsole() +{ + int fd; + struct vt_mode VT; + char vtname1[10],vtname2[10]; + + if (serverGeneration == 1) + { + /* check if we're run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be running with root " + "permissions\n" + "You should be using Xwrapper to start the server or xdm.\n" + "We strongly advise against making the server SUID root!\n"); + } + +#ifdef SVR4 + /* Protect page 0 to help find NULL dereferencing */ + /* mprotect() doesn't seem to work */ + if (Protect0) + { + int fd = -1; + + if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) + { + ErrorF("xf86OpenConsole: cannot open /dev/zero (%s)\n", + strerror(errno)); + } + else + { + if ((int)mmap(0, 0x1000, PROT_NONE, + MAP_FIXED | MAP_SHARED, fd, 0) == -1) + { + ErrorF("xf86OpenConsole: failed to protect page 0 (%s)\n", + strerror(errno)); + } + close(fd); + } + } +#endif + /* + * setup the virtual terminal manager + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + } + else + { + if ((fd = open("/dev/console",O_WRONLY,0)) < 0) + { + FatalError( + "xf86OpenConsole: Cannot open /dev/console (%s)\n", + strerror(errno)); + } + if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + { + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + } + close(fd); + } + ErrorF("(using VT number %d)\n\n", xf86Info.vtno); + + sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */ + sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */ + + xf86Config(FALSE); /* Read XF86Config */ + + if (!KeepTty) + { + setpgrp(); + } + + if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) && + ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0)) + { + FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n", + vtname2, vtname1, strerror(errno)); + } + + /* change ownership of the vt */ + if (chown(vtname1, getuid(), getgid()) < 0) + { + chown(vtname2, getuid(), getgid()); + } + + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + } + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + } + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + { + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); + } + } + else + { + /* serverGeneration != 1 */ + /* + * now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n"); + } + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + { + ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86VTSema) + sleep(5); + } + return; +} + +void xf86CloseConsole() +{ + struct vt_mode VT; + +#if 0 + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno); + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0); +#endif + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */ + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ + } + close(xf86Info.consoleFd); /* make the vt-manager happy */ + return; +} + +int xf86ProcessArgument(argc, argv, i) +int argc; +char *argv[]; +int i; +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } +#ifdef SVR4 + /* + * Undocumented flag to protect page 0 from read/write to help + * catch NULL pointer dereferences. This is purely a debugging + * flag. + */ + if (!strcmp(argv[i], "-protect0")) + { + Protect0 = TRUE; + return(1); + } +#endif + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } + return(0); +} + +void xf86UseMsg() +{ + ErrorF("vtXX use the specified VT number\n"); + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/hw/xfree86/os-support/sysv/sysv_io.c b/hw/xfree86/os-support/sysv/sysv_io.c new file mode 100644 index 000000000..150290c40 --- /dev/null +++ b/hw/xfree86/os-support/sysv/sysv_io.c @@ -0,0 +1,98 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_io.c,v 3.4 1996/12/23 06:51:26 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Dawes <dawes@physics.su.oz.au> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Dawes makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sysv_io.c,v 1.3 2000/08/17 19:51:32 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +void xf86SoundKbdBell(loudness, pitch, duration) +int loudness; +int pitch; +int duration; +{ + if (loudness && pitch) + { +#ifdef KDMKTONE + /* + * If we have KDMKTONE use it to avoid putting the server + * to sleep + */ + ioctl(xf86Info.consoleFd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration * + loudness / 50) << 16)); +#else + ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch); + usleep(xf86Info.bell_duration * loudness * 20); + ioctl(xf86Info.consoleFd, KIOCSOUND, 0); +#endif + } +} + +void xf86SetKbdLeds(leds) +int leds; +{ +#ifdef KBIO_SETMODE + ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_AT); + ioctl(xf86Info.consoleFd, KDSETLED, leds); + ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_XT); +#endif +} + +void xf86MouseInit(mouse) +MouseDevPtr mouse; +{ + return; +} + +int xf86MouseOn(mouse) +MouseDevPtr mouse; +{ + if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open mouse (%s) - Continuing...\n", + strerror(errno)); + return(-2); + } + FatalError("Cannot open mouse (%s)\n", strerror(errno)); + } + + xf86SetupMouse(mouse); + + /* Flush any pending input */ + ioctl(mouse->mseFd, TCFLSH, 0); + + return(mouse->mseFd); +} diff --git a/hw/xfree86/os-support/sysv/sysv_video.c b/hw/xfree86/os-support/sysv/sysv_video.c new file mode 100644 index 000000000..7dd1575fc --- /dev/null +++ b/hw/xfree86/os-support/sysv/sysv_video.c @@ -0,0 +1,589 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/sysv_video.c,v 3.9 1996/12/23 06:51:27 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Thomas Roell and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Thomas Roell and + * David Wexelblat makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: sysv_video.c,v 1.3 2000/08/17 19:51:33 cpqbld Exp $ */ + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef SI86IOPL +#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL) +#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0) +#else +#define SET_IOPL() sysi86(SI86IOPL,3) +#define RESET_IOPL() sysi86(SI86IOPL,0) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS]; +pointer AllocAddress[MAXSCREENS][NUM_REGIONS]; +#ifndef SVR4 +static int mmapFd = -2; +#endif +#if 0 +/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */ +#if defined(SVR4) || defined(HAS_SVR3_MMAPDRV) +static struct xf86memMap { + int offset; + int memSize; +} xf86memMaps[MAXSCREENS]; +#endif +#endif + +Bool xf86LinearVidMem() +{ +#ifdef SVR4 + return TRUE; +#else +#ifdef HAS_SVR3_MMAPDRV + if(mmapFd >= 0) + { + return TRUE; + } + if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1) + { + if(ioctl(mmapFd, GETVERSION) < 0x0222) { + ErrorF("xf86LinearVidMem: MMAP 2.2.2 or above required\n"); + ErrorF(" linear memory access disabled\n"); + return FALSE; + } + return TRUE; + } + ErrorF("xf86LinearVidMem: failed to open /dev/mmap (%s)\n", + strerror(errno)); + ErrorF(" linear memory access disabled\n"); +#endif + return FALSE; +#endif +} + +pointer xf86MapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ + pointer base; + int fd; + +#if defined(SVR4) + if ((fd = open(DEV_MEM, O_RDWR)) < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE, + MAP_SHARED, fd, (off_t)Base); + close(fd); + if ((long)base == -1) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + } +#else /* SVR4 */ +#ifdef HAS_SVR3_MMAPDRV + if (mmapFd == -2) + { + mmapFd = open("/dev/mmap", O_RDWR); + } +#endif + if (mmapFd >= 0) + { + /* To force the MMAP driver to provide the address */ + base = (pointer)0; + } + else + { + AllocAddress[ScreenNum][Region] = (pointer)xalloc(Size + 0x1000); + if (AllocAddress[ScreenNum][Region] == (pointer)0) + { + FatalError("xf86MapVidMem: can't alloc framebuffer space\n"); + /* NOTREACHED */ + } + base = (pointer)(((unsigned int)AllocAddress[ScreenNum][Region] + & ~0xFFF) + 0x1000); + } + MapDSC[ScreenNum][Region].vaddr = (char *)base; + MapDSC[ScreenNum][Region].physaddr = (char *)Base; + MapDSC[ScreenNum][Region].length = Size; + MapDSC[ScreenNum][Region].ioflg = 1; + +#ifdef HAS_SVR3_MMAPDRV + if(mmapFd >= 0) + { + if((base = (pointer)ioctl(mmapFd, MAP, + &(MapDSC[ScreenNum][Region]))) == (pointer)-1) + { + FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", Size, Base, strerror(errno)); + /* NOTREACHED */ + } + + /* Next time we want the same address! */ + MapDSC[ScreenNum][Region].vaddr = (char *)base; +#if 0 +/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */ + xf86memMaps[ScreenNum].offset = (int) Base; + xf86memMaps[ScreenNum].memSize = Size; +#endif + return((pointer)base); + } +#endif + if (ioctl(xf86Info.consoleFd, KDMAPDISP, + &(MapDSC[ScreenNum][Region])) < 0) + { + FatalError("xf86MapVidMem: Failed to map video mem (%x,%x) (%s)\n", + Base, Size, strerror(errno)); + /* NOTREACHED */ + } +#endif /* SVR4 */ +#if 0 + xf86memMaps[ScreenNum].offset = (int) Base; + xf86memMaps[ScreenNum].memSize = Size; +#endif + return((pointer)base); +} + +#if 0 +/* inserted for DGA support Tue Dec 5 21:33:00 MET 1995 mr */ +#if defined(SVR4) || defined(HAS_SVR3_MMAPDRV) +void xf86GetVidMemData(ScreenNum, Base, Size) +int ScreenNum; +int *Base; +int *Size; +{ + *Base = xf86memMaps[ScreenNum].offset; + *Size = xf86memMaps[ScreenNum].memSize; +} + +#endif +#endif +/* ARGSUSED */ +void xf86UnMapVidMem(ScreenNum, Region, Base, Size) +int ScreenNum; +int Region; +pointer Base; +unsigned long Size; +{ +#if defined (SVR4) + munmap(Base, Size); +#else /* SVR4 */ +#ifdef HAS_SVR3_MMAPDRV + if(mmapFd >= 0) + { + ioctl(mmapFd, UNMAPRM, MapDSC[ScreenNum][Region].vaddr); + return; + } +#endif + /* XXXX This is a problem because it unmaps all regions */ + ioctl(xf86Info.consoleFd, KDUNMAPDISP, 0); + xfree(AllocAddress[ScreenNum][Region]); +#endif /* SVR4 */ +} + +/* ARGSUSED */ +void xf86MapDisplay(ScreenNum, Region) +int ScreenNum; +int Region; +{ +#if !defined(SVR4) +#ifdef HAS_SVR3_MMAPDRV + if(mmapFd >= 0) + { + ioctl(mmapFd, MAP, &(MapDSC[ScreenNum][Region])); + return; + } +#endif + ioctl(xf86Info.consoleFd, KDMAPDISP, &(MapDSC[ScreenNum][Region])); +#endif /* SVR4 */ + return; +} + +/* ARGSUSED */ +void xf86UnMapDisplay(ScreenNum, Region) +int ScreenNum; +int Region; +{ +#if !defined(SVR4) +#ifdef HAS_SVR3_MMAPDRV + if(mmapFd > 0) + { + ioctl(mmapFd, UNMAP, MapDSC[ScreenNum][Region].vaddr); + return; + } +#endif + ioctl(xf86Info.consoleFd, KDUNMAPDISP, 0); +#endif /* SVR4 */ + return; +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +#define ALWAYS_USE_EXTENDED +#ifdef ALWAYS_USE_EXTENDED + +static Bool ScreenEnabled[MAXSCREENS]; +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +void +xf86ClearIOPortList(ScreenNum) +int ScreenNum; +{ + if (!InitDone) + { + int i; + for (i = 0; i < MAXSCREENS; i++) + ScreenEnabled[i] = FALSE; + InitDone = TRUE; + } + return; +} + +void +xf86AddIOPorts(ScreenNum, NumPorts, Ports) +int ScreenNum; +int NumPorts; +unsigned *Ports; +{ + return; +} + +void +xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + ScreenEnabled[ScreenNum] = TRUE; + + if (ExtendedEnabled) + return; + + if (SET_IOPL() < 0) + { + FatalError("%s: Failed to set IOPL for extended I/O\n", + "xf86EnableIOPorts"); + } + ExtendedEnabled = TRUE; + + return; +} + +void +xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + + ScreenEnabled[ScreenNum] = FALSE; + + if (!ExtendedEnabled) + return; + + for (i = 0; i < MAXSCREENS; i++) + if (ScreenEnabled[i]) + return; + + RESET_IOPL(); + ExtendedEnabled = FALSE; + + return; +} + +#else /* !ALWAYS_USE_EXTENDED */ + +#define DISABLED 0 +#define NON_EXTENDED 1 +#define EXTENDED 2 + +static unsigned *EnabledPorts[MAXSCREENS]; +static int NumEnabledPorts[MAXSCREENS]; +static Bool ScreenEnabled[MAXSCREENS]; +static Bool ExtendedPorts[MAXSCREENS]; +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; +static struct kd_disparam OrigParams; + +void xf86ClearIOPortList(ScreenNum) +int ScreenNum; +{ + if (!InitDone) + { + xf86InitPortLists(EnabledPorts, NumEnabledPorts, ScreenEnabled, + ExtendedPorts, MAXSCREENS); + if (ioctl(xf86Info.consoleFd, KDDISPTYPE, &OrigParams) < 0) + { + FatalError("%s: Could not get display parameters\n", + "xf86ClearIOPortList"); + } + InitDone = TRUE; + return; + } + ExtendedPorts[ScreenNum] = FALSE; + if (EnabledPorts[ScreenNum] != (unsigned *)NULL) + xfree(EnabledPorts[ScreenNum]); + EnabledPorts[ScreenNum] = (unsigned *)NULL; + NumEnabledPorts[ScreenNum] = 0; +} + +void xf86AddIOPorts(ScreenNum, NumPorts, Ports) +int ScreenNum; +int NumPorts; +unsigned *Ports; +{ + int i; + + if (!InitDone) + { + FatalError("xf86AddIOPorts: I/O control lists not initialised\n"); + } + EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum], + (NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned)); + for (i = 0; i < NumPorts; i++) + { + EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] = + Ports[i]; + if (Ports[i] > 0x3FF) + ExtendedPorts[ScreenNum] = TRUE; + } + NumEnabledPorts[ScreenNum] += NumPorts; +} + +void xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + struct kd_disparam param; + int i, j; + + if (ScreenEnabled[ScreenNum]) + return; + + for (i = 0; i < MAXSCREENS; i++) + { + if (ExtendedPorts[i] && (ScreenEnabled[i] || i == ScreenNum)) + { + if (SET_IOPL() < 0) + { + FatalError("%s: Failed to set IOPL for extended I/O\n", + "xf86EnableIOPorts"); + } + ExtendedEnabled = TRUE; + break; + } + } + /* If extended I/O was used, but isn't any more */ + if (ExtendedEnabled && i == MAXSCREENS) + { + RESET_IOPL(); + ExtendedEnabled = FALSE; + } + /* + * Turn on non-extended ports even when using extended I/O + * so they are there if extended I/O gets turned off when it's no + * longer needed. + */ + if (ioctl(xf86Info.consoleFd, KDDISPTYPE, ¶m) < 0) + { + FatalError("%s: Could not get display parameters\n", + "xf86EnableIOPorts"); + } + for (i = 0; i < NumEnabledPorts[ScreenNum]; i++) + { + unsigned port = EnabledPorts[ScreenNum][i]; + + if (port > 0x3FF) + continue; + + if (!xf86CheckPorts(port, EnabledPorts, NumEnabledPorts, + ScreenEnabled, MAXSCREENS)) + { + continue; + } + for (j=0; j < MKDIOADDR; j++) + { + if (param.ioaddr[j] == port) + { + break; + } + } + if (j == MKDIOADDR) + { + if (ioctl(xf86Info.consoleFd, KDADDIO, port) < 0) + { + FatalError("%s: Failed to enable port 0x%x\n", + "xf86EnableIOPorts", port); + } + } + } + if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) + { + FatalError("xf86EnableIOPorts: I/O port enable failed (%s)\n", + strerror(errno)); + } + ScreenEnabled[ScreenNum] = TRUE; + return; +} + +void xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + struct kd_disparam param; + int i, j; + + if (!ScreenEnabled[ScreenNum]) + return; + + ScreenEnabled[ScreenNum] = FALSE; + for (i = 0; i < MAXSCREENS; i++) + { + if (ScreenEnabled[i] && ExtendedPorts[i]) + break; + } + if (ExtendedEnabled && i == MAXSCREENS) + { + RESET_IOPL(); + ExtendedEnabled = FALSE; + } + /* Turn off I/O before changing the access list */ + ioctl(xf86Info.consoleFd, KDDISABIO, 0); + if (ioctl(xf86Info.consoleFd, KDDISPTYPE, ¶m) < 0) + { + ErrorF("%s: Could not get display parameters\n", + "xf86DisableIOPorts"); + return; + } + + for (i=0; i < MKDIOADDR; i++) + { + /* 0 indicates end of list */ + if (param.ioaddr[i] == 0) + { + break; + } + if (!xf86CheckPorts(param.ioaddr[i], EnabledPorts, + NumEnabledPorts, ScreenEnabled, MAXSCREENS)) + { + continue; + } + for (j=0; j < MKDIOADDR; j++) + { + if (param.ioaddr[i] == OrigParams.ioaddr[j]) + { + /* + * Port was one of the original ones; don't + * touch it. + */ + break; + } + } + if (j == MKDIOADDR) + { + /* + * We added this port, so remove it. + */ + ioctl(xf86Info.consoleFd, KDDELIO, param.ioaddr[i]); + } + } + /* If any other screens are enabled, turn I/O back on */ + for (i = 0; i < MAXSCREENS; i++) + { + if (ScreenEnabled[i]) + { + ioctl(xf86Info.consoleFd, KDENABIO, 0); + break; + } + } + return; +} +#endif /* ALWAYS_USE_EXTENDED */ + +void xf86DisableIOPrivs() +{ + if (ExtendedEnabled) + RESET_IOPL(); + return; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts() +{ + if (!ExtendedEnabled) + { + if (SET_IOPL() < 0) + { + return(FALSE); + } + } + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + { + RESET_IOPL(); + } + return(TRUE); +} + +void xf86EnableInterrupts() +{ + if (!ExtendedEnabled) + { + if (SET_IOPL() < 0) + { + return; + } + } + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + { + RESET_IOPL(); + } + return; +} diff --git a/hw/xfree86/os-support/sysv/xqueue.c b/hw/xfree86/os-support/sysv/xqueue.c new file mode 100644 index 000000000..5e3c8e9fc --- /dev/null +++ b/hw/xfree86/os-support/sysv/xqueue.c @@ -0,0 +1,406 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/xqueue.c,v 3.8.2.1 1997/07/13 14:45:04 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xqueue.c,v 1.3 2000/08/17 19:51:33 cpqbld Exp $ */ + +#define NEED_EVENTS +#include "X.h" +#include "Xproto.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "compiler.h" + +#include "xf86.h" +#include "xf86Procs.h" +#include "xf86_OSlib.h" + +#ifdef XQUEUE + +static xqEventQueue *XqueQaddr; +static int xqueFd = -1; +#ifndef XQUEUE_ASYNC +static int xquePipe[2]; +#endif + +#ifdef XKB +#include <X11/extensions/XKB.h> +#include <X11/extensions/XKBstr.h> +#include <X11/extensions/XKBsrv.h> +extern Bool noXkbExtension; +#endif + +#ifdef XINPUT +#include "xf86_Config.h" +#include "xf86Xinput.h" +#endif +extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords, + unsigned long start, unsigned long stop, + ScreenPtr pScreen); + +#ifndef XQUEUE_ASYNC +/* + * xf86XqueSignal -- + * Trap the signal from xqueue and let it be known that events are + * ready for collection + */ + +static void +xf86XqueSignal(int signum) +{ + xf86Info.mouseDev->xquePending = 1; + /* + * This is a hack, but it is the only reliable way I can find of letting + * the main select() loop know that there is more input waiting. Receiving + * a signal will interrupt select(), but there is no way I can find of + * dealing with events that come in between the end of processing the + * last set and when select() gets called. + * + * Suggestions for better ways of dealing with this without going back to + * asynchronous event processing are welcome. + */ + write(xquePipe[1], "X", 1); + signal(SIGUSR2, xf86XqueSignal); +} +#endif + + +/* + * xf86XqueRequest -- + * Notice an i/o request from the xqueue. + */ + +void +xf86XqueRequest() +{ + xqEvent *XqueEvents = XqueQaddr->xq_events; + int XqueHead = XqueQaddr->xq_head; + char buf[100]; + + while (XqueHead != XqueQaddr->xq_tail) + { + + switch(XqueEvents[XqueHead].xq_type) { + + case XQ_BUTTON: + xf86PostMseEvent(xf86Info.pMouse, + ~(XqueEvents[XqueHead].xq_code) & 0x07, 0, 0); + break; + + case XQ_MOTION: + xf86PostMseEvent(xf86Info.pMouse, + ~(XqueEvents[XqueHead].xq_code) & 0x07, + XqueEvents[XqueHead].xq_x, + XqueEvents[XqueHead].xq_y); + break; + + case XQ_KEY: + xf86PostKbdEvent(XqueEvents[XqueHead].xq_code); + break; + + default: + ErrorF("Unknown Xque Event: 0x%02x\n", XqueEvents[XqueHead].xq_type); + } + + if ((++XqueHead) == XqueQaddr->xq_size) XqueHead = 0; + } + + /* reenable the signal-processing */ + xf86Info.inputPending = TRUE; +#ifdef XQUEUE_ASYNC + signal(SIGUSR2, (void (*)()) xf86XqueRequest); +#else +#if 0 + signal(SIGUSR2, (void (*)()) xf86XqueSignal); +#endif +#endif + +#ifndef XQUEUE_ASYNC + { + int rval; + + while ((rval = read(xquePipe[0], buf, sizeof(buf))) > 0) +#ifdef DEBUG + ErrorF("Read %d bytes from xquePipe[0]\n", rval); +#else + ; +#endif + } +#endif + + XqueQaddr->xq_head = XqueQaddr->xq_tail; + xf86Info.mouseDev->xquePending = 0; + XqueQaddr->xq_sigenable = 1; /* UNLOCK */ +} + + + +/* + * xf86XqueEnable -- + * Enable the handling of the Xque + */ + +static int +xf86XqueEnable() +{ + static struct kd_quemode xqueMode; + static Bool was_here = FALSE; + + if (!was_here) { + if ((xqueFd = open("/dev/mouse", O_RDONLY|O_NDELAY)) < 0) + { + if (xf86AllowMouseOpenFail) { + ErrorF("Cannot open /dev/mouse (%s) - Continuing...\n", + strerror(errno)); + return (Success); + } else { + Error ("Cannot open /dev/mouse"); + return (!Success); + } + } +#ifndef XQUEUE_ASYNC + pipe(xquePipe); + fcntl(xquePipe[0],F_SETFL,fcntl(xquePipe[0],F_GETFL,0)|O_NDELAY); + fcntl(xquePipe[1],F_SETFL,fcntl(xquePipe[1],F_GETFL,0)|O_NDELAY); +#endif + was_here = TRUE; + } + + if (xf86Info.mouseDev->xqueSema++ == 0) + { +#ifdef XQUEUE_ASYNC + (void) signal(SIGUSR2, (void (*)()) xf86XqueRequest); +#else + (void) signal(SIGUSR2, (void (*)()) xf86XqueSignal); +#endif + xqueMode.qsize = 64; /* max events */ + xqueMode.signo = SIGUSR2; + ioctl(xf86Info.consoleFd, KDQUEMODE, NULL); + + if (ioctl(xf86Info.consoleFd, KDQUEMODE, &xqueMode) < 0) { + Error ("Cannot set KDQUEMODE"); + /* CONSTCOND */ + return (!Success); + } + + XqueQaddr = (xqEventQueue *)xqueMode.qaddr; + XqueQaddr->xq_sigenable = 1; /* UNLOCK */ + } + + return(Success); +} + + + +/* + * xf86XqueDisable -- + * disable the handling of the Xque + */ + +static int +xf86XqueDisable() +{ + if (xf86Info.mouseDev->xqueSema-- == 1) + { + + XqueQaddr->xq_sigenable = 0; /* LOCK */ + + if (ioctl(xf86Info.consoleFd, KDQUEMODE, NULL) < 0) { + Error ("Cannot unset KDQUEMODE"); + /* CONSTCOND */ + return (!Success); + } + } + + return(Success); +} + + + +/* + * xf86XqueMseProc -- + * Handle the initialization, etc. of a mouse + */ + +int +xf86XqueMseProc(pPointer, what) + DeviceIntPtr pPointer; + int what; +{ + MouseDevPtr mouse = MOUSE_DEV(pPointer); + unchar map[4]; + int ret; + + mouse->device = pPointer; + + switch (what) + { + case DEVICE_INIT: + + pPointer->public.on = FALSE; + + map[1] = 1; + map[2] = 2; + map[3] = 3; + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + 3, + miPointerGetMotionEvents, + (PtrCtrlProcPtr)xf86MseCtrl, + miPointerGetMotionBufferSize()); + break; + + case DEVICE_ON: + mouse->lastButtons = 0; + mouse->emulateState = 0; + pPointer->public.on = TRUE; + ret = xf86XqueEnable(); +#ifndef XQUEUE_ASYNC + if (xquePipe[0] != -1) + AddEnabledDevice(xquePipe[0]); +#endif + return(ret); + + case DEVICE_CLOSE: + case DEVICE_OFF: + pPointer->public.on = FALSE; + ret = xf86XqueDisable(); +#ifndef XQUEUE_ASYNC + if (xquePipe[0] != -1) + RemoveEnabledDevice(xquePipe[0]); +#endif + return(ret); + } + + return Success; +} + + + +/* + * xf86XqueKbdProc -- + * Handle the initialization, etc. of a keyboard. + */ + +int +xf86XqueKbdProc (pKeyboard, what) + DeviceIntPtr pKeyboard; /* Keyboard to manipulate */ + int what; /* What to do to it */ +{ + KeySymsRec keySyms; + CARD8 modMap[MAP_LENGTH]; + + switch (what) { + + case DEVICE_INIT: + + xf86KbdGetMapping(&keySyms, modMap); + + /* + * Get also the initial led settings + */ + ioctl(xf86Info.consoleFd, KDGETLED, &xf86Info.leds); + + /* + * Perform final initialization of the system private keyboard + * structure and fill in various slots in the device record + * itself which couldn't be filled in before. + */ + pKeyboard->public.on = FALSE; + +#ifdef XKB + if (noXkbExtension) { +#endif + InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard, + &keySyms, + modMap, + xf86KbdBell, + (KbdCtrlProcPtr)xf86KbdCtrl); +#ifdef XKB + } else { + XkbComponentNamesRec names; + if (XkbInitialMap) { + if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL) + xf86Info.xkbkeymap++; + else + xf86Info.xkbkeymap = XkbInitialMap; + } + if (xf86Info.xkbkeymap) { + names.keymap = xf86Info.xkbkeymap; + names.keycodes = NULL; + names.types = NULL; + names.compat = NULL; + names.symbols = NULL; + names.geometry = NULL; + } else { + names.keymap = NULL; + names.keycodes = xf86Info.xkbkeycodes; + names.types = xf86Info.xkbtypes; + names.compat = xf86Info.xkbcompat; + names.symbols = xf86Info.xkbsymbols; + names.geometry = xf86Info.xkbgeometry; + } + if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified) + && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) { + xf86Info.xkbrules = NULL; + } + XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel, + xf86Info.xkblayout, xf86Info.xkbvariant, + xf86Info.xkboptions); + XkbInitKeyboardDeviceStruct(pKeyboard, + &names, + &keySyms, + modMap, + xf86KbdBell, + (KbdCtrlProcPtr)xf86KbdCtrl); + } +#endif + + xf86InitKBD(TRUE); + break; + + case DEVICE_ON: + pKeyboard->public.on = TRUE; + xf86InitKBD(FALSE); + return(xf86XqueEnable()); + + case DEVICE_CLOSE: + case DEVICE_OFF: + pKeyboard->public.on = FALSE; + return(xf86XqueDisable()); + } + + return (Success); +} + + +/* + * xf86XqueEvents -- + * Get some events from our queue. Nothing to do here ... + */ + +void +xf86XqueEvents() +{ +} + +#endif /* XQUEUE */ diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h new file mode 100644 index 000000000..72722a2c8 --- /dev/null +++ b/hw/xfree86/os-support/xf86_OSlib.h @@ -0,0 +1,533 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.36.2.5 1998/02/15 16:09:30 hohndel Exp $ */ +/* + * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1992 by David Dawes <dawes@XFree86.org> + * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu> + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> + * Copyright 1992 by Orest Zborowski <obz@eskimo.com> + * Copyright 1993 by Vrije Universiteit, The Netherlands + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de> + * Copyright 1994, 1995 by The XFree86 Project, Inc + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holders + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holders make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $Xorg: xf86_OSlib.h,v 1.3 2000/08/17 19:51:20 cpqbld Exp $ */ + +#ifndef _XF86_OSLIB_H +#define _XF86_OSLIB_H + +#include <X11/Xos.h> +#include <X11/Xfuncproto.h> + +#include "compiler.h" + +#if defined(MACH386) || defined(__OSF__) +# undef NULL +#endif /* MACH386 || __OSF__ */ + +#include <stdio.h> +#include <ctype.h> + +/**************************************************************************/ +/* SYSV386 (SVR3, SVR4) */ +/**************************************************************************/ +#if defined(SYSV) || defined(SVR4) +# ifdef SCO325 +# define _SVID3 +# endif +# include <sys/ioctl.h> +# include <signal.h> +# include <termio.h> +# include <sys/stat.h> +# include <sys/types.h> +# if defined(SCO) || defined(ISC) +# include <sys/param.h> +# endif + +# include <errno.h> + +# if defined(_NEED_SYSI86) +# include <sys/immu.h> +# if !(defined (sun) && defined (i386) && defined (SVR4)) +# include <sys/region.h> +# endif +# include <sys/proc.h> +# include <sys/tss.h> +# include <sys/sysi86.h> +# if defined(SVR4) && !defined(sun) +# include <sys/seg.h> +# endif /* SVR4 && !sun */ +# include <sys/v86.h> +# if defined(sun) && defined (i386) && defined (SVR4) +# include <sys/psw.h> +# endif +# endif /* _NEED_SYSI86 */ + +#if defined(HAS_SVR3_MMAPDRV) +# include <sys/sysmacros.h> +# if !defined(_NEED_SYSI86) +# include <sys/immu.h> +# include <sys/region.h> +# endif +# include <sys/mmap.h> /* MMAP driver header */ +#endif + +# define HAS_USL_VTS +# if !defined(sun) +# include <sys/emap.h> +# endif +# if defined(SCO) +# include <sys/vtkd.h> +# include <sys/console.h> +# include <sys/keyboard.h> +# include <sys/vid.h> +# define LED_CAP 0x01 +# define LED_NUM 0x02 +# define LED_SCR 0x04 +# else /* SCO */ +# include <sys/at_ansi.h> +# include <sys/kd.h> +# include <sys/vt.h> +# endif /* SCO */ + +# if !defined(VT_ACKACQ) +# define VT_ACKACQ 2 +# endif /* !VT_ACKACQ */ + +# if defined(SCO) +# include <sys/sysmacros.h> +# define POSIX_TTY +# endif /* SCO */ + +# if defined(SVR4) || defined(SCO325) +# include <sys/mman.h> +# if !(defined(sun) && defined (i386) && defined (SVR4)) +# define DEV_MEM "/dev/pmem" +# endif +# ifdef SCO325 +# undef DEV_MEM +# define DEV_MEM "/dev/mem" +# endif +# define CLEARDTR_SUPPORT +# define POSIX_TTY +# endif /* SVR4 */ + +# ifdef ISC +# include <termios.h> +# define POSIX_TTY +# endif + +# if defined(sun) && defined (i386) && defined (SVR4) +# define USE_VT_SYSREQ +# define VT_SYSREQ_DEFAULT TRUE +# endif + +# if defined(ATT) && !defined(i386) +# define i386 /* note defined in ANSI C mode */ +# endif /* ATT && !i386 */ + +# if (defined(ATT) || defined(SVR4)) && !(defined(sun) && defined (i386) && defined (SVR4)) && !defined(SCO325) +# define XQUEUE +# include <sys/xque.h> +# endif /* ATT || SVR4 */ + +/* Hack on SVR3 and SVR4 to avoid linking in Xenix or BSD support */ +#if defined (sun) && defined (i386) && defined (SVR4) +extern int xf86_solx86usleep(unsigned long); +# define usleep(usec) xf86_solx86usleep(usec) +#else +# define usleep(usec) syscall(3112, (usec) / 1000 + 1) +#endif /* sun && i386 && SVR4 */ + +# ifdef SYSV +# if !defined(ISC) || defined(ISC202) || defined(ISC22) +# define NEED_STRERROR +# endif +# endif + +#ifndef NULL +# define NULL 0 +#endif + +#endif /* SYSV || SVR4 */ + +/**************************************************************************/ +/* Linux */ +/**************************************************************************/ +#if defined(linux) +# include <sys/ioctl.h> +# include <signal.h> +# include <termio.h> + +# include <errno.h> +extern int errno; + +# include <sys/stat.h> + +# define HAS_USL_VTS +# include <sys/mman.h> +# include <sys/kd.h> +# include <sys/vt.h> +# define LDGMAP GIO_SCRNMAP +# define LDSMAP PIO_SCRNMAP +# define LDNMAP LDSMAP + +# define CLEARDTR_SUPPORT +# define USE_VT_SYSREQ + +# define POSIX_TTY + +#endif /* linux */ + +/**************************************************************************/ +/* LynxOS AT */ +/**************************************************************************/ +#if defined(Lynx) + +# include <termio.h> +# include <sys/ioctl.h> +# include <param.h> +# include <signal.h> +# include <kd.h> +# include <vt.h> +# include <sys/stat.h> + +# include <errno.h> +extern int errno; + +/* smem_create et.al. to access physical memory */ +# include <smem.h> + +/* keyboard types */ +# define KB_84 1 +# define KB_101 2 +# define KB_OTHER 3 + +/* atc drivers ignores argument to VT_RELDISP ioctl */ +# define VT_ACKACQ 2 + +# include <termios.h> +# define POSIX_TTY + +#endif /* Lynx */ + +/**************************************************************************/ +/* 386BSD and derivatives, BSD/386 */ +/**************************************************************************/ + +#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__)) +# undef __386BSD__ +#endif + +#ifdef CSRG_BASED +# include <sys/ioctl.h> +# if defined(__OpenBSD__) && defined(_status) +# undef _status +# endif +# include <signal.h> + +# include <termios.h> +# define termio termios +# define POSIX_TTY + +# include <errno.h> +extern int errno; + +# if !defined(LINKKIT) + /* Don't need this stuff for the Link Kit */ +# if defined(__bsdi__) +# include <i386/isa/pcconsioctl.h> +# define CONSOLE_X_MODE_ON PCCONIOCRAW +# define CONSOLE_X_MODE_OFF PCCONIOCCOOK +# define CONSOLE_X_BELL PCCONIOCBEEP +# else /* __bsdi__ */ +# if defined(__OpenBSD__) +# ifdef PCCONS_SUPPORT +# include <machine/pccons.h> +# undef CONSOLE_X_MODE_ON +# undef CONSOLE_X_MODE_OFF +# undef CONSOLE_X_BELL +# endif +# endif +# ifdef CODRV_SUPPORT +# define COMPAT_CO011 +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +# include <machine/ioctl_pc.h> +# else +# include <sys/ioctl_pc.h> +# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ +# endif /* CODRV_SUPPORT */ +# ifdef SYSCONS_SUPPORT +# define COMPAT_SYSCONS +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +# include <machine/console.h> +# else +# include <sys/console.h> +# endif /* __FreeBSD__ || __NetBSD__ || defined(__OpenBSD__) */ +# endif /* SYSCONS_SUPPORT */ +# if defined(PCVT_SUPPORT) +# if !defined(SYSCONS_SUPPORT) + /* no syscons, so include pcvt specific header file */ +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +# include <machine/pcvt_ioctl.h> +# else +# include <sys/pcvt_ioctl.h> +# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */ +# else /* pcvt and syscons: hard-code the ID magic */ +# define VGAPCVTID _IOWR('V',113, struct pcvtid) + struct pcvtid { + char name[16]; + int rmajor, rminor; + }; +# endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */ +# endif /* PCVT_SUPPORT */ +# if defined(__FreeBSD__) +# undef MOUSE_GETINFO +# include <machine/mouse.h> +# endif + /* Include these definitions in case ioctl_pc.h didn't get included */ +# ifndef CONSOLE_X_MODE_ON +# define CONSOLE_X_MODE_ON _IO('t',121) +# endif +# ifndef CONSOLE_X_MODE_OFF +# define CONSOLE_X_MODE_OFF _IO('t',122) +# endif +# ifndef CONSOLE_X_BELL +# define CONSOLE_X_BELL _IOW('t',123,int[2]) +# endif +# endif /* __bsdi__ */ +# endif /* !LINKKIT */ + +# include <sys/types.h> +# include <sys/mman.h> +# include <sys/stat.h> + +# if defined(__bsdi__) +# include <sys/param.h> +# if (_BSDI_VERSION < 199510) +# include <i386/isa/vgaioctl.h> +# endif +# endif /* __bsdi__ */ + +# define CLEARDTR_SUPPORT + +# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) +# define USE_VT_SYSREQ +# endif + +# ifndef NULL +# define NULL 0 +# endif + +#endif /* CSRG_BASED */ + +/**************************************************************************/ +/* Mach and OSF/1 */ +/**************************************************************************/ +#if defined(MACH386) || defined(__OSF__) +# include <sys/ioctl.h> + +# include <signal.h> + +# include <errno.h> +extern int errno; + +# if defined(__OSF__) +# include <sys/param.h> +# include <machine/kd.h> +# else /* __OSF__ */ +# if !defined(__STDC__) +# define __STDC__ 1 +# include <i386at/kd.h> +# include <i386at/kd_queue.h> +# undef __STDC__ +# else /* !__STDC__ */ +# include <i386at/kd.h> +# include <i386at/kd_queue.h> +# endif /* !__STDC__ */ +# include <sys/file.h> +# define SEEK_SET L_SET +# endif /* __OSF__ */ + +# ifdef MACH386 +# define NEED_STRERROR +# endif + +# include <sys/mman.h> +# include <sys/stat.h> +# define MOUSE_PROTOCOL_IN_KERNEL + +#endif /* MACH386 || __OSF__ */ + +/**************************************************************************/ +/* Minix */ +/**************************************************************************/ +#if defined(MINIX) +# include <sys/ioctl.h> +# include <signal.h> + +# include <termios.h> +# define termio termios +# define POSIX_TTY + +# include <errno.h> + +# include <assert.h> +# include <limits.h> +# include <sys/memio.h> +# include <sys/kbdio.h> + +# include <sys/stat.h> + +#endif /* MINIX */ + +/**************************************************************************/ +/* Amoeba */ +/**************************************************************************/ +#if defined(AMOEBA) +# define port am_port_t +# include <amoeba.h> +# include <cmdreg.h> +# include <stderr.h> +# include <ampolicy.h> +# include <proc.h> +# include <signal.h> +# include <server/iop/iop.h> +# include <errno.h> +# undef port + +# undef _POSIX_SOURCE /* to get the BSD-compatible symbols */ +# include <sys/stat.h> + + /* keyboard types */ +# define KB_84 1 +# define KB_101 2 +# define KB_OTHER 3 + +extern capability iopcap; +# define MOUSE_PROTOCOL_IN_KERNEL + +#endif /* AMOEBA */ + +/**************************************************************************/ +/* OS/2 */ +/**************************************************************************/ +/* currently OS/2 with EMX/GCC compiler only */ +#if defined(__EMX__) +# include <signal.h> +# include <errno.h> +# include <sys/stat.h> + +/* I would have liked to have this included here always, but + * it causes clashes for BYTE and BOOL with Xmd.h, which is too dangerous. + * So I'll include it in place where I know it does no harm. + */ +#if defined(I_NEED_OS2_H) +# undef BOOL +# undef BYTE +# include <os2.h> +#endif + + /* keyboard types */ +# define KB_84 1 +# define KB_101 2 +/* could detect more keyboards */ +# define KB_OTHER 3 + + /* LEDs */ +# define LED_CAP 0x40 +# define LED_NUM 0x20 +# define LED_SCR 0x10 + + /* mouse driver */ +# define OSMOUSE_ONLY +# define MOUSE_PROTOCOL_IN_KERNEL + +extern char* __XOS2RedirRoot(char*); + +#endif + +/**************************************************************************/ +/* Generic */ +/**************************************************************************/ + +/* + * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere, + * and it's safe, so just do it. + */ +#if !defined(O_NDELAY) && defined(O_NONBLOCK) +# define O_NDELAY O_NONBLOCK +#endif /* !O_NDELAY && O_NONBLOCK */ + +#if !defined(MAXHOSTNAMELEN) +# define MAXHOSTNAMELEN 32 +#endif /* !MAXHOSTNAMELEN */ + +#if !defined(X_NOT_POSIX) +# if defined(_POSIX_SOURCE) +# include <limits.h> +# else +# define _POSIX_SOURCE +# include <limits.h> +# undef _POSIX_SOURCE +# endif /* _POSIX_SOURCE */ +#endif /* !X_NOT_POSIX */ +#if !defined(PATH_MAX) +# if defined(MAXPATHLEN) +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 1024 +# endif /* MAXPATHLEN */ +#endif /* !PATH_MAX */ + +#ifdef NEED_STRERROR +# ifndef strerror +extern char *sys_errlist[]; +extern int sys_nerr; +# define strerror(n) \ + ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error" +# endif /* !strerror */ +#endif /* NEED_STRERROR */ + +#if defined(ISC) || defined(Lynx) +#define rint(x) RInt(x) +double RInt( +#if NeedFunctionPrototypes + double x +#endif +); +#endif + +#ifndef VT_SYSREQ_DEFAULT +#define VT_SYSREQ_DEFAULT FALSE +#endif + +#ifdef OSMOUSE_ONLY +# ifndef MOUSE_PROTOCOL_IN_KERNEL +# define MOUSE_PROTOCOL_IN_KERNEL +# endif +#endif + +#include "xf86_OSproc.h" + +#endif /* _XF86_OSLIB_H */ diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h new file mode 100644 index 000000000..9f5c49e27 --- /dev/null +++ b/hw/xfree86/os-support/xf86_OSproc.h @@ -0,0 +1,394 @@ +/* $Xorg: xf86_OSproc.h,v 1.3 2000/08/17 19:51:20 cpqbld Exp $ */ +/* + * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1992 by David Dawes <dawes@XFree86.org> + * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu> + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu> + * Copyright 1992 by Orest Zborowski <obz@eskimo.com> + * Copyright 1993 by Vrije Universiteit, The Netherlands + * Copyright 1993 by David Wexelblat <dwex@XFree86.org> + * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de> + * Copyright 1994, 1995 by The XFree86 Project, Inc + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of the above listed copyright holders + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The above listed + * copyright holders make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD + * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE + * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY + * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.0.2.1 1998/02/07 14:27:24 dawes Exp $ */ + +#ifndef _XF86_OSPROC_H +#define _XF86_OSPROC_H + +/* + * The actual prototypes have been pulled into this seperate file so + * that they can can be used without pulling in all of the OS specific + * stuff like sys/stat.h, etc. This casues problem for loadable modules. + */ + +/* The Region arg to xf86[Un]Map* */ +#define NUM_REGIONS 4 +#define VGA_REGION 0 +#define LINEAR_REGION 1 +#define EXTENDED_REGION 2 +#define MMIO_REGION 3 + +#ifndef NO_OSLIB_PROTOTYPES +/* + * This is to prevent re-entrancy to FatalError() when aborting. + * Anything that can be called as a result of AbortDDX() should use this + * instead of FatalError(). (xf86Exiting gets set to TRUE the first time + * AbortDDX() is called.) + */ + +extern Bool xf86Exiting; + +#define xf86FatalError(a, b) \ + if (xf86Exiting) { \ + ErrorF(a, b); \ + return; \ + } else FatalError(a, b) + +/***************************************************************************/ +/* Prototypes */ +/***************************************************************************/ + +#include <X11/Xfuncproto.h> + +_XFUNCPROTOBEGIN + +/* xf86_Util.c */ +extern int StrCaseCmp( +#if NeedFunctionPrototypes + const char *, + const char * +#endif +); + +/* OS-support layer */ +extern void xf86OpenConsole( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86CloseConsole( +#if NeedFunctionPrototypes + void +#endif +); +extern Bool xf86VTSwitchPending( +#if NeedFunctionPrototypes + void +#endif +); +extern Bool xf86VTSwitchAway( +#if NeedFunctionPrototypes + void +#endif +); +extern Bool xf86VTSwitchTo( +#if NeedFunctionPrototypes + void +#endif +); +extern Bool xf86LinearVidMem( +#if NeedFunctionPrototypes + void +#endif +); +extern pointer xf86MapVidMem( +#if NeedFunctionPrototypes + int, + int, + pointer, + unsigned long +#endif +); +extern void xf86UnMapVidMem( +#if NeedFunctionPrototypes + int, + int, + pointer, + unsigned long +#endif +); +#if defined(__alpha__) +/* entry points for SPARSE memory access routines */ +extern pointer xf86MapVidMemSparse( +#if NeedFunctionPrototypes + int, + int, + pointer, + unsigned long +#endif +); +extern void xf86UnMapVidMemSparse( +#if NeedFunctionPrototypes + int, + int, + pointer, + unsigned long +#endif +); +extern int xf86ReadSparse8( +#if NeedFunctionPrototypes + pointer, + unsigned long +#endif +); +extern int xf86ReadSparse16( +#if NeedFunctionPrototypes + pointer, + unsigned long +#endif +); +extern int xf86ReadSparse32( +#if NeedFunctionPrototypes + pointer, + unsigned long +#endif +); +extern void xf86WriteSparse8( +#if NeedFunctionPrototypes + int, + pointer, + unsigned long +#endif +); +extern void xf86WriteSparse16( +#if NeedFunctionPrototypes + int, + pointer, + unsigned long +#endif +); +extern void xf86WriteSparse32( +#if NeedFunctionPrototypes + int, + pointer, + unsigned long +#endif +); +#endif /* __alpha__ */ +extern void xf86MapDisplay( +#if NeedFunctionPrototypes + int, + int +#endif +); +extern void xf86UnMapDisplay( +#if NeedFunctionPrototypes + int, + int +#endif +); +extern int xf86ReadBIOS( +#if NeedFunctionPrototypes + unsigned long, + unsigned long, + unsigned char *, + int +#endif +); +extern void xf86ClearIOPortList( +#if NeedFunctionPrototypes + int +#endif +); +extern void xf86AddIOPorts( +#if NeedFunctionPrototypes + int, + int, + unsigned * +#endif +); +void xf86EnableIOPorts( +#if NeedFunctionPrototypes + int +#endif +); +void xf86DisableIOPorts( +#if NeedFunctionPrototypes + int +#endif +); +void xf86DisableIOPrivs( +#if NeedFunctionPrototypes + void +#endif +); +extern Bool xf86DisableInterrupts( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86EnableInterrupts( +#if NeedFunctionPrototypes + void +#endif +); +extern int xf86ProcessArgument( +#if NeedFunctionPrototypes + int, + char **, + int +#endif +); +extern void xf86UseMsg( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86SoundKbdBell( +#if NeedFunctionPrototypes + int, + int, + int +#endif +); +extern void xf86SetKbdLeds( +#if NeedFunctionPrototypes + int +#endif +); +extern int xf86GetKbdLeds( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86SetKbdRepeat( +#if NeedFunctionPrototypes + char +#endif +); +extern void xf86KbdInit( +#if NeedFunctionPrototypes + void +#endif +); +extern int xf86KbdOn( +#if NeedFunctionPrototypes + void +#endif +); +extern int xf86KbdOff( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86KbdEvents( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86SetMouseSpeed( +#if NeedFunctionPrototypes + MouseDevPtr, + int, + int, + unsigned +#endif +); +extern void xf86MouseInit( +#if NeedFunctionPrototypes + MouseDevPtr +#endif +); +extern int xf86MouseOn( +#if NeedFunctionPrototypes + MouseDevPtr +#endif +); +extern int xf86MouseOff( +#if NeedFunctionPrototypes + MouseDevPtr, + Bool +#endif +); +extern void xf86MouseEvents( +#if NeedFunctionPrototypes + MouseDevPtr +#endif +); +extern int xf86FlushInput( +#if NeedFunctionPrototypes + int +#endif +); +extern int xf86XqueKbdProc( +#if NeedFunctionPrototypes + DeviceIntPtr, + int +#endif +); +extern int xf86XqueMseProc( +#if NeedFunctionPrototypes + DeviceIntPtr, + int +#endif +); +extern void xf86XqueEvents( +#if NeedFunctionPrototypes + void +#endif +); + + +/* These are privates */ +extern void xf86InitPortLists( +#if NeedFunctionPrototypes + unsigned **, + int *, + Bool *, + Bool *, + int +#endif +); +extern Bool xf86CheckPorts( +#if NeedFunctionPrototypes + unsigned, + unsigned **, + int *, + Bool *, + int +#endif +); +extern int xf86OsMouseProc( +#if NeedFunctionPrototypes + DeviceIntPtr, + int +#endif +); +extern void xf86OsMouseEvents( +#if NeedFunctionPrototypes + void +#endif +); +extern void xf86OsMouseOption( +#if NeedFunctionPrototypes + int, + pointer /* gets cast to LexPtr later, saves include file hassles */ +#endif +); + +_XFUNCPROTOEND +#endif /* NO_OSLIB_PROTOTYPES */ + +#endif /* _XF86_OSPROC_H */ diff --git a/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c new file mode 100644 index 000000000..37c23cfea --- /dev/null +++ b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.c @@ -0,0 +1,96 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.c,v 3.5 1996/12/23 06:47:13 dawes Exp $ */ + + +/* Keyboard mode control program for 386BSD */ + + +/* $Xorg: kbd_mode.c,v 1.3 2000/08/17 19:51:09 cpqbld Exp $ */ + +#include <sys/types.h> +#include <fcntl.h> +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> + +#include "X.h" +#include "input.h" +#include "scrnintstr.h" + +#include "xf86.h" +#include "xf86_OSlib.h" + +static int fd; + +void +msg (char* s) +{ + perror (s); + close (fd); + exit (-1); +} + +int +main(int argc, char** argv) +{ +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + vtmode_t vtmode; +#endif + Bool syscons = FALSE; + + if ((fd = open("/dev/vga",O_RDONLY,0)) <0) + msg ("Cannot open /dev/vga"); + +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + /* Check if syscons */ + if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) + syscons = TRUE; +#endif + + if (0 == strcmp (argv[1], "-u")) + { + if (syscons) + { +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + ioctl (fd, KDSKBMODE, K_RAW); +#endif + } + else + { + if (ioctl (fd, CONSOLE_X_MODE_ON, 0) < 0) + { + close (fd); + exit (0); /* Assume codrv, so nothing to do */ + } + } + } + else if (0 == strcmp (argv[1], "-a")) + { + if (syscons) + { +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + ioctl (fd, KDSKBMODE, K_XLATE); +#endif + } + else + { + if (ioctl (fd, CONSOLE_X_MODE_OFF, 0) < 0) + { + close (fd); + exit (0); /* Assume codrv, so nothing to do */ + } + } + } + else + { + close (fd); + fprintf (stderr,"Usage: %s [-u|-a]\n",argv[0]); + fprintf (stderr,"-u for sending up down key events in x mode.\n"); + fprintf (stderr,"-a for sending ascii keys in normal use.\n"); + exit (-1); + } + close (fd); + exit (0); +} diff --git a/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre new file mode 100644 index 000000000..c959d2332 --- /dev/null +++ b/hw/xfree86/utils/kbd_mode/bsd-kbd_mode.man.pre @@ -0,0 +1,36 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/etc/kbd_mode.man,v 3.2 1996/12/23 06:47:14 dawes Exp $ +.TH KBD_MODE 1 "Release 6.3 (XFree86 3.2)" "X Version 11" +.SH NAME +kbd_mode \- recover the PC console keyboard +.SH SYNOPSIS +.B kbd_mode +[ -a -u ] +.SH DESCRIPTION +.I Kbd_mode +resets the PC console keyboard to a rational state. +.SH OPTIONS +The following options are supported: +.TP 8 +.B \-a +Set the keyboard so that ASCII characters are read from the console. +.TP 8 +.B \-u +Set the keyboard so that undecoded keyboard values are read from the +console. +.SH EXAMPLES +If the server crashes or otherwise fails to put the keyboard back in +ascii mode when it exits, it can leave your keyboard dead. If you are +able to login remotely, you can reset it typing: +.sp + kbd_mode -a +.sp +.PP +Conversely, changing the keyboard to ascii mode while the server is +running will make the keyboard appear to be dead while the the mouse +continues to work. Again, if you are able to login remotely, you can +reset it typing: +.sp + kbd_mode -u +.sp + +.\" $Xorg: kbd_mode.man,v 1.3 2000/08/17 19:51:10 cpqbld Exp $ diff --git a/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c new file mode 100644 index 000000000..294787354 --- /dev/null +++ b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.c @@ -0,0 +1,150 @@ +/* $Xorg: kbd_mode.c,v 1.3 2000/08/17 19:48:29 cpqbld Exp $ */ +/************************************************************ +Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA. + + 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 no- +tice appear in all copies and that both that copyright no- +tice and this permission notice appear in supporting docu- +mentation, and that the names of Sun or The Open Group +not be used in advertising or publicity pertaining to +distribution of the software without specific prior +written permission. Sun and The Open Group make no +representations about the suitability of this software for +any purpose. It is provided "as is" without any express or +implied warranty. + +SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- +NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI- +ABLE 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. + +********************************************************/ + +#ifndef lint +static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13"; +#endif + +/* + * Copyright 1986 by Sun Microsystems, Inc. + * + * kbd_mode: set keyboard encoding mode + */ + +#include <sys/types.h> +#include <sys/file.h> +#include <sys/ioctl.h> +#if defined(SVR4) || defined(__bsdi_) +#include <fcntl.h> +#ifndef __bsdi__ +#include <sys/kbio.h> +#include <sys/kbd.h> +#else +#include <unistd.h> +#include </sys/sparc/dev/kbio.h> +#include </sys/sparc/dev/kbd.h> +#endif +#else +#ifndef CSRG_BASED +#include <sundev/kbio.h> +#include <sundev/kbd.h> +#else +#include <machine/kbio.h> +#include <machine/kbd.h> +#endif +#endif +#include <stdio.h> + +static void die(), usage(); +static int kbd_fd; + +main(argc, argv) + int argc; + char** argv; +{ + int code, translate, direct = -1; + char led; + int click; + + if ((kbd_fd = open("/dev/kbd", O_RDONLY, 0)) < 0) { + die("Couldn't open /dev/kbd"); + } + argc--; argv++; + if (argc-- && **argv == '-') { + code = *(++*argv); + } else { + usage(); + } + switch (code) { + case 'a': + case 'A': + translate = TR_ASCII; + direct = 0; + break; + case 'e': + case 'E': + translate = TR_EVENT; + break; + case 'n': + case 'N': + translate = TR_NONE; + break; + case 'u': + case 'U': + translate = TR_UNTRANS_EVENT; + break; + default: + usage(); + } +#ifdef KIOCSLED + led = 0; + if (ioctl(kbd_fd, KIOCSLED, &led)) + die("Couldn't set LEDs"); +#endif +#ifdef KIOCCMD + click = KBD_CMD_NOCLICK; + if (ioctl(kbd_fd, KIOCCMD, &click)) + die("Couldn't set click"); +#endif + if (ioctl(kbd_fd, KIOCTRANS, (caddr_t) &translate)) + die("Couldn't set translation"); + if (direct != -1 && ioctl(kbd_fd, KIOCSDIRECT, (caddr_t) &direct)) + die("Couldn't set redirect"); + return 0; +} + +static void +die(msg) + char *msg; +{ + fprintf(stderr, "%s\n", msg); + exit(1); +} + +static void +usage() +{ + int translate; + + if (ioctl(kbd_fd, KIOCGTRANS, (caddr_t) &translate)) { + die("Couldn't inquire current translation"); + } + fprintf(stderr, "kbd_mode {-a | -e | -n | -u }\n"); + fprintf(stderr, "\tfor ascii, encoded (normal) SunView events,\n"); + fprintf(stderr, " \tnon-encoded, or unencoded SunView events, resp.\n"); + fprintf(stderr, "Current mode is %s.\n", + ( translate == 0 ? "n (non-translated bytes)" : + ( translate == 1 ? "a (ascii bytes)" : + ( translate == 2 ? "e (encoded events)" : + /* translate == 3 */ "u (unencoded events)")))); + exit(1); +} + + diff --git a/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre new file mode 100644 index 000000000..88c4a89b4 --- /dev/null +++ b/hw/xfree86/utils/kbd_mode/sun-kbd_mode.man.pre @@ -0,0 +1,50 @@ +.\" $Xorg: kbd_mode.man,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $ +.\" Copyright 1987 Sun Microsystems, Inc. +.\" Copyright 1993, 1998 The Open Group +.\" +.\" 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. +.\" +.\" 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 OPEN GROUP 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 Open Group 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 Open Group. +.TH KBD_MODE 1 "Release 6.4" "X Version 11" +.SH NAME +kbd_mode \- recover the Sun console keyboard +.SH SYNOPSIS +.B kbd_mode +[ -a -e -n -u ] +.SH DESCRIPTION +.I Kbd_mode +resets the Sun console keyboard to a rational state. +.SH OPTIONS +The following options are supported, see \fIkb(4S)\fP for details: +.TP 8 +.B \-a +Causes ASCII to be reported. +.TP 8 +.B \-e +Causes \fIFirm_events\fP to be reported. +.TP 8 +.B \-n +Causes up/down key codes to be reported. +.TP 8 +.B \-u +Causes undecoded keyboard values to be reported. +.SH SEE ALSO +kb(4S) diff --git a/hw/xfree86/utils/scanpci/scanpci.c b/hw/xfree86/utils/scanpci/scanpci.c new file mode 100644 index 000000000..f3a142fba --- /dev/null +++ b/hw/xfree86/utils/scanpci/scanpci.c @@ -0,0 +1,1790 @@ +/* $Xorg: scanpci.c,v 1.3 2000/08/17 19:51:10 cpqbld Exp $ */ +/* + * name: scanpci.c + * + * purpose: This program will scan for and print details of + * devices on the PCI bus. + + * author: Robin Cutshaw (robin@xfree86.org) + * + * supported O/S's: SVR4, UnixWare, SCO, Solaris, + * FreeBSD, NetBSD, 386BSD, BSDI BSD/386, + * Linux, Mach/386, ISC + * DOS (WATCOM 9.5 compiler) + * + * compiling: [g]cc scanpci.c -o scanpci + * for SVR4 (not Solaris), UnixWare use: + * [g]cc -DSVR4 scanpci.c -o scanpci + * for DOS, watcom 9.5: + * wcc386p -zq -omaxet -7 -4s -s -w3 -d2 name.c + * and link with PharLap or other dos extender for exe + * + */ + +/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.10 1998/02/27 17:13:22 robin Exp $ */ + +/* + * 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. + * + */ + +#if defined(__SVR4) +#if !defined(SVR4) +#define SVR4 +#endif +#endif + +#ifdef __EMX__ +#define INCL_DOSFILEMGR +#include <os2.h> +#endif + +#include <stdio.h> +#include <sys/types.h> +#if defined(SVR4) +#if defined(sun) +#define __EXTENSIONS__ +#endif +#include <sys/proc.h> +#include <sys/tss.h> +#if defined(NCR) +#define __STDC +#include <sys/sysi86.h> +#undef __STDC +#else +#include <sys/sysi86.h> +#endif +#if defined(__SUNPRO_C) || defined(sun) || defined(__sun) +#include <sys/psw.h> +#else +#include <sys/seg.h> +#endif +#include <sys/v86.h> +#endif +#if defined(__FreeBSD__) || defined(__386BSD__) +#include <sys/file.h> +#include <machine/console.h> +#ifndef GCCUSESGAS +#define GCCUSESGAS +#endif +#endif +#if defined(__NetBSD__) +#include <sys/param.h> +#include <sys/file.h> +#include <machine/sysarch.h> +#ifndef GCCUSESGAS +#define GCCUSESGAS +#endif +#endif +#if defined(__bsdi__) +#include <sys/file.h> +#include <sys/ioctl.h> +#include <i386/isa/pcconsioctl.h> +#ifndef GCCUSESGAS +#define GCCUSESGAS +#endif +#endif +#if defined(SCO) || defined(ISC) +#ifndef ISC +#include <sys/console.h> +#endif +#include <sys/param.h> +#include <sys/immu.h> +#include <sys/region.h> +#include <sys/proc.h> +#include <sys/tss.h> +#include <sys/sysi86.h> +#include <sys/v86.h> +#endif +#if defined(Lynx_22) +#ifndef GCCUSESGAS +#define GCCUSESGAS +#endif +#endif + + +#if defined(__WATCOMC__) + +#include <stdlib.h> +void outl(unsigned port, unsigned data); +#pragma aux outl = "out dx, eax" parm [dx] [eax]; +void outb(unsigned port, unsigned data); +#pragma aux outb = "out dx, al" parm [dx] [eax]; +unsigned inl(unsigned port); +#pragma aux inl = "in eax, dx" parm [dx]; +unsigned inb(unsigned port); +#pragma aux inb = "xor eax,eax" "in al, dx" parm [dx]; + +#else /* __WATCOMC__ */ + +#if defined(__GNUC__) + +#if !defined(__alpha__) && !defined(__powerpc__) +#if defined(GCCUSESGAS) +#define OUTB_GCC "outb %0,%1" +#define OUTL_GCC "outl %0,%1" +#define INB_GCC "inb %1,%0" +#define INL_GCC "inl %1,%0" +#else +#define OUTB_GCC "out%B0 (%1)" +#define OUTL_GCC "out%L0 (%1)" +#define INB_GCC "in%B0 (%1)" +#define INL_GCC "in%L0 (%1)" +#endif /* GCCUSESGAS */ + +static void outb(unsigned short port, unsigned char val) { + __asm__ __volatile__(OUTB_GCC : :"a" (val), "d" (port)); } +static void outl(unsigned short port, unsigned long val) { + __asm__ __volatile__(OUTL_GCC : :"a" (val), "d" (port)); } +static unsigned char inb(unsigned short port) { unsigned char ret; + __asm__ __volatile__(INB_GCC : "=a" (ret) : "d" (port)); return ret; } +static unsigned long inl(unsigned short port) { unsigned long ret; + __asm__ __volatile__(INL_GCC : "=a" (ret) : "d" (port)); return ret; } + +#endif /* !defined(__alpha__) && !defined(__powerpc__) */ +#else /* __GNUC__ */ + +#if defined(__STDC__) && (__STDC__ == 1) +# if !defined(NCR) +# define asm __asm +# endif +#endif + +#if defined(__SUNPRO_C) +/* + * This section is a gross hack in if you tell anyone that I wrote it, + * I'll deny it. :-) + * The leave/ret instructions are the big hack to leave %eax alone on return. + */ + unsigned char inb(int port) { + asm(" movl 8(%esp),%edx"); + asm(" subl %eax,%eax"); + asm(" inb (%dx)"); + asm(" leave"); + asm(" ret"); + } + + unsigned short inw(int port) { + asm(" movl 8(%esp),%edx"); + asm(" subl %eax,%eax"); + asm(" inw (%dx)"); + asm(" leave"); + asm(" ret"); + } + + unsigned long inl(int port) { + asm(" movl 8(%esp),%edx"); + asm(" inl (%dx)"); + asm(" leave"); + asm(" ret"); + } + + void outb(int port, unsigned char value) { + asm(" movl 8(%esp),%edx"); + asm(" movl 12(%esp),%eax"); + asm(" outb (%dx)"); + } + + void outw(int port, unsigned short value) { + asm(" movl 8(%esp),%edx"); + asm(" movl 12(%esp),%eax"); + asm(" outw (%dx)"); + } + + void outl(int port, unsigned long value) { + asm(" movl 8(%esp),%edx"); + asm(" movl 12(%esp),%eax"); + asm(" outl (%dx)"); + } +#else + +#if defined(SVR4) +# if !defined(__USLC__) +# define __USLC__ +# endif +#endif + +#ifndef SCO325 +# include <sys/inline.h> +#else +# include "scoasm.h" +#endif + +#endif /* SUNPRO_C */ + +#endif /* __GNUC__ */ +#endif /* __WATCOMC__ */ + + +#if defined(__alpha__) +#if defined(linux) +#include <asm/unistd.h> +#define BUS(tag) (((tag)>>16)&0xff) +#define DFN(tag) (((tag)>>8)&0xff) +int pciconfig_read( + unsigned char bus, + unsigned char dfn, + unsigned char off, + unsigned char len, + void * buf) +{ + return __syscall(__NR_pciconfig_read, bus, dfn, off, len, buf); +} +int pciconfig_write( + unsigned char bus, + unsigned char dfn, + unsigned char off, + unsigned char len, + void * buf) +{ + return __syscall(__NR_pciconfig_write, bus, dfn, off, len, buf); +} +#else +Generate compiler error - scanpci unsupported on non-linux alpha platforms +#endif /* linux */ +#endif /* __alpha__ */ +#if defined(Lynx) && defined(__powerpc__) +/* let's mimick the Linux Alpha stuff for LynxOS so we don't have + * to change too much code + */ +#include <smem.h> + +unsigned char *pciConfBase; + +static __inline__ unsigned long +swapl(unsigned long val) +{ + unsigned char *p = (unsigned char *)&val; + return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0)); +} + + +#define BUS(tag) (((tag)>>16)&0xff) +#define DFN(tag) (((tag)>>8)&0xff) + +#define PCIBIOS_DEVICE_NOT_FOUND 0x86 +#define PCIBIOS_SUCCESSFUL 0x00 + +int pciconfig_read( + unsigned char bus, + unsigned char dev, + unsigned char offset, + int len, /* unused, alway 4 */ + unsigned long *val) +{ + unsigned long _val; + unsigned long *ptr; + + dev >>= 3; + if (bus || dev >= 16) { + *val = 0xFFFFFFFF; + return PCIBIOS_DEVICE_NOT_FOUND; + } else { + ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset)); + _val = swapl(*ptr); + } + *val = _val; + return PCIBIOS_SUCCESSFUL; +} + +int pciconfig_write( + unsigned char bus, + unsigned char dev, + unsigned char offset, + int len, /* unused, alway 4 */ + unsigned long val) +{ + unsigned long _val; + unsigned long *ptr; + + dev >>= 3; + _val = swapl(val); + if (bus || dev >= 16) { + return PCIBIOS_DEVICE_NOT_FOUND; + } else { + ptr = (unsigned long *)(pciConfBase + ((1<<dev) | offset)); + *ptr = _val; + } + return PCIBIOS_SUCCESSFUL; +} +#endif + +#if !defined(__powerpc__) +struct pci_config_reg { + /* start of official PCI config space header */ + union { + unsigned long device_vendor; + struct { + unsigned short vendor; + unsigned short device; + } dv; + } dv_id; +#define _device_vendor dv_id.device_vendor +#define _vendor dv_id.dv.vendor +#define _device dv_id.dv.device + union { + unsigned long status_command; + struct { + unsigned short command; + unsigned short status; + } sc; + } stat_cmd; +#define _status_command stat_cmd.status_command +#define _command stat_cmd.sc.command +#define _status stat_cmd.sc.status + union { + unsigned long class_revision; + struct { + unsigned char rev_id; + unsigned char prog_if; + unsigned char sub_class; + unsigned char base_class; + } cr; + } class_rev; +#define _class_revision class_rev.class_revision +#define _rev_id class_rev.cr.rev_id +#define _prog_if class_rev.cr.prog_if +#define _sub_class class_rev.cr.sub_class +#define _base_class class_rev.cr.base_class + union { + unsigned long bist_header_latency_cache; + struct { + unsigned char cache_line_size; + unsigned char latency_timer; + unsigned char header_type; + unsigned char bist; + } bhlc; + } bhlc; +#define _bist_header_latency_cache bhlc.bist_header_latency_cache +#define _cache_line_size bhlc.bhlc.cache_line_size +#define _latency_timer bhlc.bhlc.latency_timer +#define _header_type bhlc.bhlc.header_type +#define _bist bhlc.bhlc.bist + union { + struct { + unsigned long dv_base0; + unsigned long dv_base1; + unsigned long dv_base2; + unsigned long dv_base3; + unsigned long dv_base4; + unsigned long dv_base5; + } dv; + struct { + unsigned long bg_rsrvd[2]; + unsigned char primary_bus_number; + unsigned char secondary_bus_number; + unsigned char subordinate_bus_number; + unsigned char secondary_latency_timer; + unsigned char io_base; + unsigned char io_limit; + unsigned short secondary_status; + unsigned short mem_base; + unsigned short mem_limit; + unsigned short prefetch_mem_base; + unsigned short prefetch_mem_limit; + } bg; + } bc; +#define _base0 bc.dv.dv_base0 +#define _base1 bc.dv.dv_base1 +#define _base2 bc.dv.dv_base2 +#define _base3 bc.dv.dv_base3 +#define _base4 bc.dv.dv_base4 +#define _base5 bc.dv.dv_base5 +#define _primary_bus_number bc.bg.primary_bus_number +#define _secondary_bus_number bc.bg.secondary_bus_number +#define _subordinate_bus_number bc.bg.subordinate_bus_number +#define _secondary_latency_timer bc.bg.secondary_latency_timer +#define _io_base bc.bg.io_base +#define _io_limit bc.bg.io_limit +#define _secondary_status bc.bg.secondary_status +#define _mem_base bc.bg.mem_base +#define _mem_limit bc.bg.mem_limit +#define _prefetch_mem_base bc.bg.prefetch_mem_base +#define _prefetch_mem_limit bc.bg.prefetch_mem_limit + unsigned long rsvd1; + unsigned long rsvd2; + unsigned long _baserom; + unsigned long rsvd3; + unsigned long rsvd4; + union { + unsigned long max_min_ipin_iline; + struct { + unsigned char int_line; + unsigned char int_pin; + unsigned char min_gnt; + unsigned char max_lat; + } mmii; + } mmii; +#define _max_min_ipin_iline mmii.max_min_ipin_iline +#define _int_line mmii.mmii.int_line +#define _int_pin mmii.mmii.int_pin +#define _min_gnt mmii.mmii.min_gnt +#define _max_lat mmii.mmii.max_lat + /* I don't know how accurate or standard this is (DHD) */ + union { + unsigned long user_config; + struct { + unsigned char user_config_0; + unsigned char user_config_1; + unsigned char user_config_2; + unsigned char user_config_3; + } uc; + } uc; +#define _user_config uc.user_config +#define _user_config_0 uc.uc.user_config_0 +#define _user_config_1 uc.uc.user_config_1 +#define _user_config_2 uc.uc.user_config_2 +#define _user_config_3 uc.uc.user_config_3 + /* end of official PCI config space header */ + unsigned long _pcibusidx; + unsigned long _pcinumbus; + unsigned long _pcibuses[16]; + unsigned short _configtype; /* config type found */ + unsigned short _ioaddr; /* config type 1 - private I/O addr */ + unsigned long _cardnum; /* config type 2 - private card number */ +}; +#else +/* ppc is big endian, swapping bytes is not quite enough + * to interpret the PCI config registers... + */ +struct pci_config_reg { + /* start of official PCI config space header */ + union { + unsigned long device_vendor; + struct { + unsigned short device; + unsigned short vendor; + } dv; + } dv_id; +#define _device_vendor dv_id.device_vendor +#define _vendor dv_id.dv.vendor +#define _device dv_id.dv.device + union { + unsigned long status_command; + struct { + unsigned short status; + unsigned short command; + } sc; + } stat_cmd; +#define _status_command stat_cmd.status_command +#define _command stat_cmd.sc.command +#define _status stat_cmd.sc.status + union { + unsigned long class_revision; + struct { + unsigned char base_class; + unsigned char sub_class; + unsigned char prog_if; + unsigned char rev_id; + } cr; + } class_rev; +#define _class_revision class_rev.class_revision +#define _rev_id class_rev.cr.rev_id +#define _prog_if class_rev.cr.prog_if +#define _sub_class class_rev.cr.sub_class +#define _base_class class_rev.cr.base_class + union { + unsigned long bist_header_latency_cache; + struct { + unsigned char bist; + unsigned char header_type; + unsigned char latency_timer; + unsigned char cache_line_size; + } bhlc; + } bhlc; +#define _bist_header_latency_cache bhlc.bist_header_latency_cache +#define _cache_line_size bhlc.bhlc.cache_line_size +#define _latency_timer bhlc.bhlc.latency_timer +#define _header_type bhlc.bhlc.header_type +#define _bist bhlc.bhlc.bist + union { + struct { + unsigned long dv_base0; + unsigned long dv_base1; + unsigned long dv_base2; + unsigned long dv_base3; + unsigned long dv_base4; + unsigned long dv_base5; + } dv; +/* ?? */ + struct { + unsigned long bg_rsrvd[2]; + + unsigned char secondary_latency_timer; + unsigned char subordinate_bus_number; + unsigned char secondary_bus_number; + unsigned char primary_bus_number; + + unsigned short secondary_status; + unsigned char io_limit; + unsigned char io_base; + + unsigned short mem_limit; + unsigned short mem_base; + + unsigned short prefetch_mem_limit; + unsigned short prefetch_mem_base; + } bg; + } bc; +#define _base0 bc.dv.dv_base0 +#define _base1 bc.dv.dv_base1 +#define _base2 bc.dv.dv_base2 +#define _base3 bc.dv.dv_base3 +#define _base4 bc.dv.dv_base4 +#define _base5 bc.dv.dv_base5 +#define _primary_bus_number bc.bg.primary_bus_number +#define _secondary_bus_number bc.bg.secondary_bus_number +#define _subordinate_bus_number bc.bg.subordinate_bus_number +#define _secondary_latency_timer bc.bg.secondary_latency_timer +#define _io_base bc.bg.io_base +#define _io_limit bc.bg.io_limit +#define _secondary_status bc.bg.secondary_status +#define _mem_base bc.bg.mem_base +#define _mem_limit bc.bg.mem_limit +#define _prefetch_mem_base bc.bg.prefetch_mem_base +#define _prefetch_mem_limit bc.bg.prefetch_mem_limit + unsigned long rsvd1; + unsigned long rsvd2; + unsigned long _baserom; + unsigned long rsvd3; + unsigned long rsvd4; + union { + unsigned long max_min_ipin_iline; + struct { + unsigned char max_lat; + unsigned char min_gnt; + unsigned char int_pin; + unsigned char int_line; + } mmii; + } mmii; +#define _max_min_ipin_iline mmii.max_min_ipin_iline +#define _int_line mmii.mmii.int_line +#define _int_pin mmii.mmii.int_pin +#define _min_gnt mmii.mmii.min_gnt +#define _max_lat mmii.mmii.max_lat + /* I don't know how accurate or standard this is (DHD) */ + union { + unsigned long user_config; + struct { + unsigned char user_config_3; + unsigned char user_config_2; + unsigned char user_config_1; + unsigned char user_config_0; + } uc; + } uc; +#define _user_config uc.user_config +#define _user_config_0 uc.uc.user_config_0 +#define _user_config_1 uc.uc.user_config_1 +#define _user_config_2 uc.uc.user_config_2 +#define _user_config_3 uc.uc.user_config_3 + /* end of official PCI config space header */ + unsigned long _pcibusidx; + unsigned long _pcinumbus; + unsigned long _pcibuses[16]; + unsigned short _ioaddr; /* config type 1 - private I/O addr */ + unsigned short _configtype; /* config type found */ + unsigned long _cardnum; /* config type 2 - private card number */ +}; +#endif + +extern void identify_card(struct pci_config_reg *, int); +extern void print_i128(struct pci_config_reg *); +extern void print_mach64(struct pci_config_reg *); +extern void print_pcibridge(struct pci_config_reg *); +extern void enable_os_io(); +extern void disable_os_io(); + +#define MAX_DEV_PER_VENDOR_CFG1 32 +#define MAX_DEV_PER_VENDOR_CFG2 16 +#define MAX_PCI_DEVICES 64 +#define NF ((void (*)())NULL) +#define PCI_MULTIFUNC_DEV 0x80 +#if defined(__alpha__) || defined(__powerpc__) +#define PCI_ID_REG 0x00 +#define PCI_CMD_STAT_REG 0x04 +#define PCI_CLASS_REG 0x08 +#define PCI_HEADER_MISC 0x0C +#define PCI_MAP_REG_START 0x10 +#define PCI_MAP_ROM_REG 0x30 +#define PCI_INTERRUPT_REG 0x3C +#define PCI_REG_USERCONFIG 0x40 +#endif + +struct pci_vendor_device { + unsigned short vendor_id; + char *vendorname; + struct pci_device { + unsigned short device_id; + char *devicename; + void (*print_func)(struct pci_config_reg *); + } device[MAX_DEV_PER_VENDOR_CFG1]; +} pvd[] = { + { 0x0e11, "Compaq", { + { 0x3033, "QVision 1280/p", NF }, + { 0xae10, "Smart-2/P RAID Controller", NF }, + { 0xae32, "Netellignet 10/100", NF }, + { 0xae34, "Netellignet 10", NF }, + { 0xae35, "NetFlex 3", NF }, + { 0xae40, "Netellignet 10/100 Dual", NF }, + { 0xae43, "Netellignet 10/100 ProLiant", NF }, + { 0xb011, "Netellignet 10/100 Integrated", NF }, + { 0xf130, "ThunderLAN", NF }, + { 0xf150, "NetFlex 3 BNC", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1000, "NCR", { + { 0x0001, "53C810", NF }, + { 0x0002, "53C820", NF }, + { 0x0003, "53C825", NF }, + { 0x0004, "53C815", NF }, + { 0x0005, "53C810AP", NF }, + { 0x0006, "53C860", NF }, + { 0x000B, "53C896", NF }, + { 0x000C, "53C895", NF }, + { 0x000D, "53C885", NF }, + { 0x000F, "53C875", NF }, + { 0x008F, "53C875J", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1002, "ATI", { + { 0x4158, "Mach32", NF }, + { 0x4354, "Mach64 CT", print_mach64 }, + { 0x4358, "Mach64 CX", print_mach64 }, + { 0x4554, "Mach64 ET", print_mach64 }, + { 0x4742, "Mach64 GB", print_mach64 }, + { 0x4744, "Mach64 GD", print_mach64 }, + { 0x4750, "Mach64 GP", print_mach64 }, + { 0x4754, "Mach64 GT", print_mach64 }, + { 0x4755, "Mach64 GT", print_mach64 }, + { 0x4758, "Mach64 GX", print_mach64 }, + { 0x4C47, "Mach64 LT", print_mach64 }, + { 0x5654, "Mach64 VT", print_mach64 }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1004, "VLSI", { + { 0x0005, "82C592-FC1", NF }, + { 0x0006, "82C593-FC1", NF }, + { 0x0007, "82C594-AFC2", NF }, + { 0x0009, "82C597-AFC2", NF }, + { 0x000C, "82C541 Lynx", NF }, + { 0x000D, "82C543 Lynx ISA", NF }, + { 0x0702, "VAS96011", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1005, "Avance Logic", { + { 0x2301, "ALG2301", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x100B, "NS", { + { 0x0002, "87415", NF }, + { 0xD001, "87410", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x100C, "Tseng Labs", { + { 0x3202, "ET4000w32p rev A", NF }, + { 0x3205, "ET4000w32p rev B", NF }, + { 0x3206, "ET4000w32p rev D", NF }, + { 0x3207, "ET4000w32p rev C", NF }, + { 0x3208, "ET6000/6100", NF }, + { 0x4702, "ET6300", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x100E, "Weitek", { + { 0x9001, "P9000", NF }, + { 0x9100, "P9100", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1011, "Digital Equipment Corporation", { + { 0x0001, "DC21050 PCI-PCI Bridge",print_pcibridge}, + { 0x0002, "DC21040 10Mb/s Ethernet", NF }, + { 0x0004, "TGA", NF }, + { 0x0009, "DC21140 10/100 Mb/s Ethernet", NF }, + { 0x000D, "TGA2", NF }, + { 0x000F, "DEFPA (FDDI PCI)", NF }, + { 0x0014, "DC21041 10Mb/s Ethernet Plus", NF }, + { 0x0019, "DC21142 10/100 Mb/s Ethernet", NF }, + { 0x0021, "DC21052", NF }, + { 0x0024, "DC21152", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1013, "Cirrus Logic", { + { 0x0038, "GD 7548", NF }, + { 0x00A0, "GD 5430", NF }, + { 0x00A4, "GD 5434-4", NF }, + { 0x00A8, "GD 5434-8", NF }, + { 0x00AC, "GD 5436", NF }, + { 0x00B8, "GD 5446", NF }, + { 0x00BC, "GD 5480", NF }, + { 0x00D0, "GD 5462", NF }, + { 0x00D4, "GD 5464", NF }, + { 0x1100, "CL 6729", NF }, + { 0x1110, "CL 6832", NF }, + { 0x1200, "GD 7542", NF }, + { 0x1202, "GD 7543", NF }, + { 0x1204, "GD 7541", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1014, "IBM", { + { 0x000A, "Fire Coral", NF }, + { 0x0018, "Token Ring", NF }, + { 0x001D, "82G2675", NF }, + { 0x0022, "82351 pci-pci bridge", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x101A, "NCR", { + { 0x0000, (char *)NULL, NF } } }, + { 0x101C, "WD*", { + { 0x3296, "WD 7197", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1022, "AMD", { + { 0x2000, "79C970 Lance", NF }, + { 0x2020, "53C974 SCSI", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1023, "Trident", { + { 0x9320, "TGUI 9320", NF }, + { 0x9420, "TGUI 9420", NF }, + { 0x9440, "TGUI 9440", NF }, + { 0x9660, "TGUI 9660/9680/9682", NF }, +#if 0 + { 0x9680, "TGUI 9680", NF }, + { 0x9682, "TGUI 9682", NF }, +#endif + { 0x9750, "TGUI 9750", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1025, "ALI", { + { 0x1435, "M1435", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x102B, "Matrox", { + { 0x0518, "MGA-2 Atlas PX2085", NF }, + { 0x0519, "MGA Millennium", NF }, + { 0x051a, "MGA Mystique", NF }, + { 0x051b, "MGA Millennium II", NF }, + { 0x0D10, "MGA Impression", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x102C, "CT", { + { 0x00D8, "65545", NF }, + { 0x00DC, "65548", NF }, + { 0x00E0, "65550", NF }, + { 0x00E4, "65554", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1031, "Miro", { + { 0x5601, "ZR36050", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1033, "NEC", { + { 0x0046, "PowerVR PCX2", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1036, "FD", { + { 0x0000, "TMC-18C30 (36C70)", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1039, "SIS", { + { 0x0001, "86C201", NF }, + { 0x0002, "86C202", NF }, + { 0x0008, "85C503", NF }, + { 0x0205, "86C205", NF }, + { 0x0406, "85C501", NF }, + { 0x0496, "85C496", NF }, + { 0x0601, "85C601", NF }, + { 0x5107, "5107", NF }, + { 0x5511, "85C5511", NF }, + { 0x5513, "85C5513", NF }, + { 0x5571, "5571", NF }, + { 0x5597, "5597", NF }, + { 0x7001, "7001", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x103C, "HP", { + { 0x1030, "J2585A", NF }, + { 0x1031, "J2585B", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1042, "SMC/PCTECH", { + { 0x1000, "FDC 37C665/RZ1000", NF }, + { 0x1001, "FDC /RZ1001", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1044, "DPT", { + { 0xA400, "SmartCache/Raid", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1045, "Opti", { + { 0xC178, "92C178", NF }, + { 0xC557, "82C557 Viper-M", NF }, + { 0xC558, "82C558 Viper-M ISA+IDE", NF }, + { 0xC621, "82C621", NF }, + { 0xC700, "82C700", NF }, + { 0xC701, "82C701 FireStar Plus", NF }, + { 0xC814, "82C814 Firebridge 1", NF }, + { 0xC822, "82C822", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x104A, "SGS Thomson", { + { 0x0008, "STG2000", NF }, + { 0x0009, "STG1764", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x104B, "BusLogic", { + { 0x0140, "946C 01", NF }, + { 0x1040, "946C 10", NF }, + { 0x8130, "FlashPoint", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x104C, "Texas Instruments", { + { 0x3d04, "3DLabs Permedia", NF }, + { 0x3d07, "3DLabs Permedia 2", NF }, + { 0xAC12, "PCI1130", NF }, + { 0xAC15, "PCI1131", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x104E, "Oak", { + { 0x0107, "OTI107", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1050, "Windbond", { + { 0x0940, "89C940 NE2000-PCI", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1057, "Motorola", { + { 0x0001, "MPC105 Eagle", NF }, + { 0x0002, "MPC105 Grackle", NF }, + { 0x4801, "Raven", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x105A, "Promise", { + { 0x4D33, "IDE UltraDMA/33", NF }, + { 0x5300, "DC5030", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x105D, "Number Nine", { + { 0x2309, "Imagine-128", print_i128 }, + { 0x2339, "Imagine-128-II", print_i128 }, + { 0x493D, "Imagine-128-T2R", print_i128 }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1060, "UMC", { + { 0x0101, "UM8673F", NF }, + { 0x673A, "UM8886BF", NF }, + { 0x886A, "UM8886A", NF }, + { 0x8881, "UM8881F", NF }, + { 0x8886, "UM8886F", NF }, + { 0x8891, "UM8891A", NF }, + { 0x9017, "UM9017F", NF }, + { 0xE886, "UM8886N", NF }, + { 0xE891, "UM8891N", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1061, "X", { + { 0x0001, "ITT AGX016", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1066, "PICOP", { + { 0x0001, "PT86C52x Vesuvius", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x106B, "Apple", { + { 0x0001, "Bandit", NF }, + { 0x0002, "Grand Central", NF }, + { 0x000E, "Hydra", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1074, "Nexgen", { + { 0x0000, (char *)NULL, NF } } }, + { 0x1077, "QLogic", { + { 0x1020, "ISP1020", NF }, + { 0x1022, "ISP1022", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1078, "Cyrix", { + { 0x0000, "5510", NF }, + { 0x0001, "PCI Master", NF }, + { 0x0002, "5520", NF }, + { 0x0100, "5530 Kahlua Legacy", NF }, + { 0x0101, "5530 Kahlua SMI", NF }, + { 0x0102, "5530 Kahlua IDE", NF }, + { 0x0103, "5530 Kahlua Audio", NF }, + { 0x0104, "5530 Kahlua Video", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x107D, "Leadtek", { + { 0x0000, "S3 805", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1080, "Contaq", { + { 0x0600, "82C599", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1083, "FOREX", { + { 0x0000, (char *)NULL, NF } } }, + { 0x108D, "Olicom", { + { 0x0001, "OC-3136", NF }, + { 0x0011, "OC-2315", NF }, + { 0x0012, "OC-2325", NF }, + { 0x0013, "OC-2183", NF }, + { 0x0014, "OC-2326", NF }, + { 0x0021, "OC-6151", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x108E, "Sun", { + { 0x1000, "EBUS", NF }, + { 0x1001, "Happy Meal", NF }, + { 0x8000, "PCI Bus Module", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1095, "CMD", { + { 0x0640, "640A", NF }, + { 0x0643, "643", NF }, + { 0x0646, "646", NF }, + { 0x0670, "670", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1098, "Vision", { + { 0x0001, "QD 8500", NF }, + { 0x0002, "QD 8580", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x109E, "Brooktree", { + { 0x0350, "Bt848", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10A8, "Sierra", { + { 0x0000, "STB Horizon 64", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10AA, "ACC", { + { 0x0000, "2056", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10AD, "Winbond", { + { 0x0001, "W83769F", NF }, + { 0x0105, "SL82C105", NF }, + { 0x0565, "W83C553", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10B3, "Databook", { + { 0xB106, "DB87144", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10B7, "3COM", { + { 0x5900, "3C590 10bT", NF }, + { 0x5950, "3C595 100bTX", NF }, + { 0x5951, "3C595 100bT4", NF }, + { 0x5952, "3C595 10b-MII", NF }, + { 0x9000, "3C900 10bTPO", NF }, + { 0x9001, "3C900 10b Combo", NF }, + { 0x9050, "3C905 100bTX", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10B8, "SMC", { + { 0x0005, "9432 TX", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10B9, "ALI", { + { 0x1445, "M1445", NF }, + { 0x1449, "M1449", NF }, + { 0x1451, "M1451", NF }, + { 0x1461, "M1461", NF }, + { 0x1489, "M1489", NF }, + { 0x1511, "M1511", NF }, + { 0x1513, "M1513", NF }, + { 0x1521, "M1521", NF }, + { 0x1523, "M1523", NF }, + { 0x1531, "M1531 Aladdin IV", NF }, + { 0x1533, "M1533 Aladdin IV", NF }, + { 0x5215, "M4803", NF }, + { 0x5219, "M5219", NF }, + { 0x5229, "M5229 TXpro", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10BA, "Mitsubishi", { + { 0x0000, (char *)NULL, NF } } }, + { 0x10BD, "Surecom", { + { 0x0E34, "NE-34PCI Lan", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10C8, "Neomagic", { + { 0x0001, "Magicgraph NM2070", NF }, + { 0x0002, "Magicgraph 128V", NF }, + { 0x0003, "Magicgraph 128ZV", NF }, + { 0x0004, "Magicgraph NM2160", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10CD, "Advanced System Products", { + { 0x1200, "ABP940", NF }, + { 0x1300, "ABP940U", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10DC, "CERN", { + { 0x0001, "STAR/RD24 SCI-PCI (PMC)", NF }, + { 0x0002, "STAR/RD24 SCI-PCI (PMC)", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10DE, "NVidia", { + { 0x0008, "NV1", NF }, + { 0x0009, "DAC64", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10E0, "IMS", { + { 0x8849, "8849", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10E1, "Tekram", { + { 0x690C, "DC690C", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10E3, "Tundra", { + { 0x0000, "CA91C042 Universe", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10E8, "AMCC", { + { 0x8043, "Myrinet PCI (M2-PCI-32)", NF }, + { 0x807D, "S5933 PCI44", NF }, + { 0x809C, "S5933 Traquair HEPC3", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10EA, "Intergraphics", { + { 0x1680, "IGA-1680", NF }, + { 0x1682, "IGA-1682", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10EC, "Realtek", { + { 0x8029, "8029", NF }, + { 0x8129, "8129", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x10FA, "Truevision", { + { 0x000C, "Targa 1000", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1101, "Initio Corp", { + { 0x9100, "320 P", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1106, "VIA", { + { 0x0505, "VT 82C505", NF }, + { 0x0561, "VT 82C505", NF }, + { 0x0576, "VT 82C576 3V", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1119, "Vortex", { + { 0x0001, "GDT 6000b", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x111A, "EF", { + { 0x0000, "155P-MF1", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1127, "Fore Systems", { + { 0x0000, (char *)NULL, NF } } }, + { 0x112F, "Imaging Technology", { + { 0x0000, (char *)NULL, NF } } }, + { 0x113C, "PLX", { + { 0x0000, (char *)NULL, NF } } }, + { 0x1142, "Alliance", { + { 0x3210, "ProMotion 6410", NF }, + { 0x6422, "ProMotion 6422", NF }, + { 0x6424, "ProMotion AT24", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x114A, "VMIC", { + { 0x0000, (char *)NULL, NF } } }, + { 0x114F, "DIGI*", { + { 0x0000, (char *)NULL, NF } } }, + { 0x1159, "Mutech", { + { 0x0001, "MV1000", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1163, "Rendition", { + { 0x0001, "V1000", NF }, + { 0x2000, "V2100", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1179, "Toshiba", { + { 0x0000, (char *)NULL, NF } } }, + { 0x1193, "Zeinet", { + { 0x0001, "1221", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x11CB, "Specialix", { + { 0x0000, (char *)NULL, NF } } }, + { 0x11FE, "Control", { + { 0x0000, (char *)NULL, NF } } }, + { 0x120E, "Cyclades", { + { 0x0000, (char *)NULL, NF } } }, + { 0x121A, "3Dfx Interactive", { + { 0x0001, "Voodoo Graphics", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1236, "Sigma Designs", { + { 0x6401, "REALmagic64/GX (SD 6425)", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1281, "YOKOGAWA", { + { 0x0000, (char *)NULL, NF } } }, + { 0x1292, "TriTech Microelectronics", { + { 0xfc02, "Pyramid3D TR25202", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x12D2, "NVidia/SGS-Thomson", { + { 0x0018, "Riva128", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1C1C, "Symphony", { + { 0x0001, "82C101", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x1DE1, "Tekram", { + { 0xDC29, "DC290", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x3D3D, "3Dlabs", { + { 0x0001, "GLINT 300SX", NF }, + { 0x0002, "GLINT 500TX", NF }, + { 0x0003, "GLINT Delta", NF }, + { 0x0004, "GLINT Permedia", NF }, + { 0x0006, "GLINT MX", NF }, + { 0x0007, "GLINT Permedia 2", NF }, + { 0x0000, (char *)NULL, NF } } } , + { 0x4005, "Avance", { + { 0x0000, (char *)NULL, NF } } }, + { 0x5333, "S3", { + { 0x0551, "Plato/PX", NF }, + { 0x5631, "ViRGE", NF }, + { 0x8811, "Trio32/64", NF }, + { 0x8812, "Aurora64V+", NF }, + { 0x8814, "Trio64UV+", NF }, + { 0x883D, "ViRGE/VX", NF }, + { 0x8880, "868", NF }, + { 0x88B0, "928", NF }, + { 0x88C0, "864-0", NF }, + { 0x88C1, "864-1", NF }, + { 0x88D0, "964-0", NF }, + { 0x88D1, "964-1", NF }, + { 0x88F0, "968", NF }, + { 0x8901, "Trio64V2/DX or /GX", NF }, + { 0x8902, "PLATO/PX", NF }, + { 0x8A01, "ViRGE/DX or /GX", NF }, + { 0x8A10, "ViRGE/GX2", NF }, + { 0x8C01, "ViRGE/MX", NF }, + { 0x8C02, "ViRGE/MX+", NF }, + { 0x8C03, "ViRGE/MX+MV", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x8086, "Intel", { + { 0x0482, "82375EB pci-eisa bridge", NF }, + { 0x0483, "82424ZX cache dram controller", NF }, + { 0x0484, "82378IB/ZB pci-isa bridge", NF }, + { 0x0486, "82430ZX Aries", NF }, + { 0x04A3, "82434LX/NX pci cache mem controller", NF }, + { 0x1230, "82371 bus-master IDE controller", NF }, + { 0x1223, "SAA7116", NF }, + { 0x1229, "82557 10/100MBit network controller",NF}, + { 0x122D, "82437 Triton", NF }, + { 0x122E, "82471 Triton", NF }, + { 0x1230, "82438", NF }, + { 0x1250, "82439", NF }, + { 0x7000, "82371 pci-isa bridge", NF }, + { 0x7010, "82371 bus-master IDE controller", NF }, + { 0x7100, "82439 TX", NF }, + { 0x7110, "82371AB PIIX4 ISA", NF }, + { 0x7111, "82371AB PIIX4 IDE", NF }, + { 0x7112, "82371AB PIIX4 USB", NF }, + { 0x7113, "82371AB PIIX4 ACPI", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x9004, "Adaptec", { + { 0x5078, "7850", NF }, + { 0x5578, "7855", NF }, + { 0x6078, "7860", NF }, + { 0x7078, "294x", NF }, + { 0x7178, "2940", NF }, + { 0x7278, "7872", NF }, + { 0x7478, "2944", NF }, + { 0x8178, "2940U", NF }, + { 0x8278, "3940U", NF }, + { 0x8478, "2944U", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x907F, "Atronics", { + { 0x2015, "IDE-2015PL", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0xEDD8, "ARK Logic", { + { 0xA091, "1000PV", NF }, + { 0xA099, "2000PV", NF }, + { 0xA0A1, "2000MT", NF }, + { 0xA0A9, "2000MI", NF }, + { 0x0000, (char *)NULL, NF } } }, + { 0x0000, (char *)NULL, { + { 0x0000, (char *)NULL, NF } } } +}; + +#if defined(__alpha__) +#define PCI_EN 0x00000000 +#else +#define PCI_EN 0x80000000 +#endif + +#define PCI_MODE1_ADDRESS_REG 0xCF8 +#define PCI_MODE1_DATA_REG 0xCFC + +#define PCI_MODE2_ENABLE_REG 0xCF8 +#ifdef PC98 +#define PCI_MODE2_FORWARD_REG 0xCF9 +#else +#define PCI_MODE2_FORWARD_REG 0xCFA +#endif + + +main(int argc, unsigned char *argv[]) +{ + unsigned long tmplong1, tmplong2, config_cmd; + unsigned char tmp1, tmp2; + unsigned int idx; + struct pci_config_reg pcr; + int ch, verbose = 0, do_mode1_scan = 0, do_mode2_scan = 0; + int func; + + while((ch = getopt(argc, argv, "v12")) != EOF) { + switch((char)ch) { + case '1': + do_mode1_scan = 1; + break; + case '2': + do_mode2_scan = 1; + break; + case 'v': + verbose = 1; + break; + default : + printf("Usage: %s [-v12] \n", argv[0]); + exit(1); + } + } +#if !defined(MSDOS) + if (getuid()) { + printf("This program must be run as root\n"); + exit(1); + } +#endif + + enable_os_io(); + +#if !defined(__alpha__) && !defined(__powerpc__) + pcr._configtype = 0; + + outb(PCI_MODE2_ENABLE_REG, 0x00); + outb(PCI_MODE2_FORWARD_REG, 0x00); + tmp1 = inb(PCI_MODE2_ENABLE_REG); + tmp2 = inb(PCI_MODE2_FORWARD_REG); + if ((tmp1 == 0x00) && (tmp2 == 0x00)) { + pcr._configtype = 2; + printf("PCI says configuration type 2\n"); + } else { + tmplong1 = inl(PCI_MODE1_ADDRESS_REG); + outl(PCI_MODE1_ADDRESS_REG, PCI_EN); + tmplong2 = inl(PCI_MODE1_ADDRESS_REG); + outl(PCI_MODE1_ADDRESS_REG, tmplong1); + if (tmplong2 == PCI_EN) { + pcr._configtype = 1; + printf("PCI says configuration type 1\n"); + } else { + printf("No PCI !\n"); + disable_os_io(); + exit(1); + } + } +#else + pcr._configtype = 1; +#endif + + /* Try pci config 1 probe first */ + + if ((pcr._configtype == 1) || do_mode1_scan) { + printf("\nPCI probing configuration type 1\n"); + + pcr._ioaddr = 0xFFFF; + + pcr._pcibuses[0] = 0; + pcr._pcinumbus = 1; + pcr._pcibusidx = 0; + idx = 0; + + do { + printf("Probing for devices on PCI bus %d:\n\n", pcr._pcibusidx); + + for (pcr._cardnum = 0x0; pcr._cardnum < MAX_DEV_PER_VENDOR_CFG1; + pcr._cardnum += 0x1) { + func = 0; + do { /* loop over the different functions, if present */ +#if !defined(__alpha__) && !defined(__powerpc__) + config_cmd = PCI_EN | (pcr._pcibuses[pcr._pcibusidx]<<16) | + (pcr._cardnum<<11) | (func<<8); + + outl(PCI_MODE1_ADDRESS_REG, config_cmd); /* ioreg 0 */ + pcr._device_vendor = inl(PCI_MODE1_DATA_REG); +#else + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_ID_REG, 4, &pcr._device_vendor); +#endif + + if ((pcr._vendor == 0xFFFF) || (pcr._device == 0xFFFF)) + break; /* nothing there */ + + printf("\npci bus 0x%x cardnum 0x%02x function 0x%04x: vendor 0x%04x device 0x%04x\n", + pcr._pcibuses[pcr._pcibusidx], pcr._cardnum, func, + pcr._vendor, pcr._device); + +#if !defined(__alpha__) && !defined(__powerpc__) + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x04); + pcr._status_command = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x08); + pcr._class_revision = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x0C); + pcr._bist_header_latency_cache = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x10); + pcr._base0 = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x14); + pcr._base1 = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x18); + pcr._base2 = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x1C); + pcr._base3 = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x20); + pcr._base4 = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x24); + pcr._base5 = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x30); + pcr._baserom = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x3C); + pcr._max_min_ipin_iline = inl(PCI_MODE1_DATA_REG); + outl(PCI_MODE1_ADDRESS_REG, config_cmd | 0x40); + pcr._user_config = inl(PCI_MODE1_DATA_REG); +#else + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_CMD_STAT_REG, 4, &pcr._status_command); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_CLASS_REG, 4, &pcr._class_revision); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_HEADER_MISC, 4, &pcr._bist_header_latency_cache); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_REG_START, 4, &pcr._base0); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_REG_START + 0x04, 4, &pcr._base1); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_REG_START + 0x08, 4, &pcr._base2); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_REG_START + 0x0C, 4, &pcr._base3); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_REG_START + 0x10, 4, &pcr._base4); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_REG_START + 0x14, 4, &pcr._base5); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_MAP_ROM_REG, 4, &pcr._baserom); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_INTERRUPT_REG, 4, &pcr._max_min_ipin_iline); + pciconfig_read(pcr._pcibuses[pcr._pcibusidx], pcr._cardnum<<3, + PCI_REG_USERCONFIG, 4, &pcr._user_config); +#endif + + /* check for pci-pci bridges */ +#define PCI_CLASS_MASK 0xff000000 +#define PCI_SUBCLASS_MASK 0x00ff0000 +#define PCI_CLASS_BRIDGE 0x06000000 +#define PCI_SUBCLASS_BRIDGE_PCI 0x00040000 + switch(pcr._class_revision & (PCI_CLASS_MASK|PCI_SUBCLASS_MASK)) { + case PCI_CLASS_BRIDGE|PCI_SUBCLASS_BRIDGE_PCI: + if (pcr._secondary_bus_number > 0) { + pcr._pcibuses[pcr._pcinumbus++] = pcr._secondary_bus_number; + } + break; + default: + break; + } + if((func==0) && ((pcr._header_type & PCI_MULTIFUNC_DEV) == 0)) { + /* not a multi function device */ + func = 8; + } else { + func++; + } + + if (idx++ >= MAX_PCI_DEVICES) + continue; + + identify_card(&pcr, verbose); + } while( func < 8 ); + } + } while (++pcr._pcibusidx < pcr._pcinumbus); + } + +#if !defined(__alpha__) && !defined(__powerpc__) + /* Now try pci config 2 probe (deprecated) */ + + if ((pcr._configtype == 2) || do_mode2_scan) { + outb(PCI_MODE2_ENABLE_REG, 0xF1); + outb(PCI_MODE2_FORWARD_REG, 0x00); /* bus 0 for now */ + + printf("\nPCI probing configuration type 2\n"); + + pcr._pcibuses[0] = 0; + pcr._pcinumbus = 1; + pcr._pcibusidx = 0; + idx = 0; + + do { + for (pcr._ioaddr = 0xC000; pcr._ioaddr < 0xD000; pcr._ioaddr += 0x0100){ + outb(PCI_MODE2_FORWARD_REG, pcr._pcibuses[pcr._pcibusidx]); /* bus 0 for now */ + pcr._device_vendor = inl(pcr._ioaddr); + outb(PCI_MODE2_FORWARD_REG, 0x00); /* bus 0 for now */ + + if ((pcr._vendor == 0xFFFF) || (pcr._device == 0xFFFF)) + continue; + if ((pcr._vendor == 0xF0F0) || (pcr._device == 0xF0F0)) + continue; /* catch ASUS P55TP4XE motherboards */ + + printf("\npci bus 0x%x slot at 0x%04x, vendor 0x%04x device 0x%04x\n", + pcr._pcibuses[pcr._pcibusidx], pcr._ioaddr, pcr._vendor, + pcr._device); + + outb(PCI_MODE2_FORWARD_REG, pcr._pcibuses[pcr._pcibusidx]); /* bus 0 for now */ + pcr._status_command = inl(pcr._ioaddr + 0x04); + pcr._class_revision = inl(pcr._ioaddr + 0x08); + pcr._bist_header_latency_cache = inl(pcr._ioaddr + 0x0C); + pcr._base0 = inl(pcr._ioaddr + 0x10); + pcr._base1 = inl(pcr._ioaddr + 0x14); + pcr._base2 = inl(pcr._ioaddr + 0x18); + pcr._base3 = inl(pcr._ioaddr + 0x1C); + pcr._base4 = inl(pcr._ioaddr + 0x20); + pcr._base5 = inl(pcr._ioaddr + 0x24); + pcr._baserom = inl(pcr._ioaddr + 0x30); + pcr._max_min_ipin_iline = inl(pcr._ioaddr + 0x3C); + pcr._user_config = inl(pcr._ioaddr + 0x40); + outb(PCI_MODE2_FORWARD_REG, 0x00); /* bus 0 for now */ + + /* check for pci-pci bridges (currently we only know Digital) */ + if ((pcr._vendor == 0x1011) && (pcr._device == 0x0001)) + if (pcr._secondary_bus_number > 0) + pcr._pcibuses[pcr._pcinumbus++] = pcr._secondary_bus_number; + + if (idx++ >= MAX_PCI_DEVICES) + continue; + + identify_card(&pcr, verbose); + } + } while (++pcr._pcibusidx < pcr._pcinumbus); + + outb(PCI_MODE2_ENABLE_REG, 0x00); + } + +#endif /* __alpha__ */ + + disable_os_io(); +} + + +void +identify_card(struct pci_config_reg *pcr, int verbose) +{ + + int i = 0, j, foundit = 0; + + while (pvd[i].vendorname != (char *)NULL) { + if (pvd[i].vendor_id == pcr->_vendor) { + j = 0; + printf(" %s ", pvd[i].vendorname); + while (pvd[i].device[j].devicename != (char *)NULL) { + if (pvd[i].device[j].device_id == pcr->_device) { + printf("%s", pvd[i].device[j].devicename); + foundit = 1; + break; + } + j++; + } + } + if (foundit) + break; + i++; + } + + if (!foundit) + printf(" Device unknown\n"); + else { + printf("\n"); + if (verbose) { + if (pvd[i].device[j].print_func != (void (*)())NULL) { + pvd[i].device[j].print_func(pcr); + return; + } + } + } + + if (verbose) { + if (pcr->_status_command) + printf(" STATUS 0x%04x COMMAND 0x%04x\n", + pcr->_status, pcr->_command); + if (pcr->_class_revision) + printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n", + pcr->_base_class, pcr->_sub_class, pcr->_prog_if, + pcr->_rev_id); + if (pcr->_bist_header_latency_cache) + printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n", + pcr->_bist, pcr->_header_type, pcr->_latency_timer, + pcr->_cache_line_size); + if (pcr->_base0) + printf(" BASE0 0x%08x addr 0x%08x %s\n", + pcr->_base0, pcr->_base0 & (pcr->_base0 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0), + pcr->_base0 & 0x1 ? "I/O" : "MEM"); + if (pcr->_base1) + printf(" BASE1 0x%08x addr 0x%08x %s\n", + pcr->_base1, pcr->_base1 & (pcr->_base1 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0), + pcr->_base1 & 0x1 ? "I/O" : "MEM"); + if (pcr->_base2) + printf(" BASE2 0x%08x addr 0x%08x %s\n", + pcr->_base2, pcr->_base2 & (pcr->_base2 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0), + pcr->_base2 & 0x1 ? "I/O" : "MEM"); + if (pcr->_base3) + printf(" BASE3 0x%08x addr 0x%08x %s\n", + pcr->_base3, pcr->_base3 & (pcr->_base3 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0), + pcr->_base3 & 0x1 ? "I/O" : "MEM"); + if (pcr->_base4) + printf(" BASE4 0x%08x addr 0x%08x %s\n", + pcr->_base4, pcr->_base4 & (pcr->_base4 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0), + pcr->_base4 & 0x1 ? "I/O" : "MEM"); + if (pcr->_base5) + printf(" BASE5 0x%08x addr 0x%08x %s\n", + pcr->_base5, pcr->_base5 & (pcr->_base5 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0), + pcr->_base5 & 0x1 ? "I/O" : "MEM"); + if (pcr->_baserom) + printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n", + pcr->_baserom, pcr->_baserom & 0xFFFF8000, + pcr->_baserom & 0x1 ? "" : "not-"); + if (pcr->_max_min_ipin_iline) + printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n", + pcr->_max_lat, pcr->_min_gnt, + pcr->_int_pin, pcr->_int_line); + if (pcr->_user_config) + printf(" BYTE_0 0x%02x BYTE_1 0x%02x BYTE_2 0x%02x BYTE_3 0x%02x\n", + pcr->_user_config_0, pcr->_user_config_1, + pcr->_user_config_2, pcr->_user_config_3); + } +} + + +void +print_mach64(struct pci_config_reg *pcr) +{ + unsigned long sparse_io = 0; + + if (pcr->_status_command) + printf(" STATUS 0x%04x COMMAND 0x%04x\n", + pcr->_status, pcr->_command); + if (pcr->_class_revision) + printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n", + pcr->_base_class, pcr->_sub_class, pcr->_prog_if, pcr->_rev_id); + if (pcr->_bist_header_latency_cache) + printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n", + pcr->_bist, pcr->_header_type, pcr->_latency_timer, + pcr->_cache_line_size); + if (pcr->_base0) + printf(" APBASE 0x%08x addr 0x%08x\n", + pcr->_base0, pcr->_base0 & (pcr->_base0 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0)); + if (pcr->_base1) + printf(" BLOCKIO 0x%08x addr 0x%08x\n", + pcr->_base1, pcr->_base1 & (pcr->_base1 & 0x1 ? + 0xFFFFFFFC : 0xFFFFFFF0)); + if (pcr->_baserom) + printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n", + pcr->_baserom, pcr->_baserom & 0xFFFF8000, + pcr->_baserom & 0x1 ? "" : "not-"); + if (pcr->_max_min_ipin_iline) + printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n", + pcr->_max_lat, pcr->_min_gnt, pcr->_int_pin, pcr->_int_line); + switch (pcr->_user_config_0 & 0x03) { + case 0: + sparse_io = 0x2ec; + break; + case 1: + sparse_io = 0x1cc; + break; + case 2: + sparse_io = 0x1c8; + break; + } + printf(" SPARSEIO 0x%03x %s %s\n", + sparse_io, pcr->_user_config_0 & 0x04 ? "Block IO enabled" : + "Sparse IO enabled", + pcr->_user_config_0 & 0x08 ? "Disable 0x46E8" : "Enable 0x46E8"); +} + +void +print_i128(struct pci_config_reg *pcr) +{ + if (pcr->_status_command) + printf(" STATUS 0x%04x COMMAND 0x%04x\n", + pcr->_status, pcr->_command); + if (pcr->_class_revision) + printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n", + pcr->_base_class, pcr->_sub_class, pcr->_prog_if, pcr->_rev_id); + if (pcr->_bist_header_latency_cache) + printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n", + pcr->_bist, pcr->_header_type, pcr->_latency_timer, + pcr->_cache_line_size); + printf(" MW0_AD 0x%08x addr 0x%08x %spre-fetchable\n", + pcr->_base0, pcr->_base0 & 0xFFC00000, + pcr->_base0 & 0x8 ? "" : "not-"); + printf(" MW1_AD 0x%08x addr 0x%08x %spre-fetchable\n", + pcr->_base1, pcr->_base1 & 0xFFC00000, + pcr->_base1 & 0x8 ? "" : "not-"); + printf(" XYW_AD(A) 0x%08x addr 0x%08x\n", + pcr->_base2, pcr->_base2 & 0xFFC00000); + printf(" XYW_AD(B) 0x%08x addr 0x%08x\n", + pcr->_base3, pcr->_base3 & 0xFFC00000); + printf(" RBASE_G 0x%08x addr 0x%08x\n", + pcr->_base4, pcr->_base4 & 0xFFFF0000); + printf(" IO 0x%08x addr 0x%08x\n", + pcr->_base5, pcr->_base5 & 0xFFFFFF00); + printf(" RBASE_E 0x%08x addr 0x%08x %sdecode-enabled\n", + pcr->_baserom, pcr->_baserom & 0xFFFF8000, + pcr->_baserom & 0x1 ? "" : "not-"); + if (pcr->_max_min_ipin_iline) + printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n", + pcr->_max_lat, pcr->_min_gnt, pcr->_int_pin, pcr->_int_line); +} + +void +print_pcibridge(struct pci_config_reg *pcr) +{ + if (pcr->_status_command) + printf(" STATUS 0x%04x COMMAND 0x%04x\n", + pcr->_status, pcr->_command); + if (pcr->_class_revision) + printf(" CLASS 0x%02x 0x%02x 0x%02x REVISION 0x%02x\n", + pcr->_base_class, pcr->_sub_class, pcr->_prog_if, pcr->_rev_id); + if (pcr->_bist_header_latency_cache) + printf(" BIST 0x%02x HEADER 0x%02x LATENCY 0x%02x CACHE 0x%02x\n", + pcr->_bist, pcr->_header_type, pcr->_latency_timer, + pcr->_cache_line_size); + printf(" PRIBUS 0x%02x SECBUS 0x%02x SUBBUS 0x%02x SECLT 0x%02x\n", + pcr->_primary_bus_number, pcr->_secondary_bus_number, + pcr->_subordinate_bus_number, pcr->_secondary_latency_timer); + printf(" IOBASE: 0x%02x00 IOLIM 0x%02x00 SECSTATUS 0x%04x\n", + pcr->_io_base, pcr->_io_limit, pcr->_secondary_status); + printf(" NOPREFETCH MEMBASE: 0x%08x MEMLIM 0x%08x\n", + pcr->_mem_base, pcr->_mem_limit); + printf(" PREFETCH MEMBASE: 0x%08x MEMLIM 0x%08x\n", + pcr->_prefetch_mem_base, pcr->_prefetch_mem_limit); + printf(" RBASE_E 0x%08x addr 0x%08x %sdecode-enabled\n", + pcr->_baserom, pcr->_baserom & 0xFFFF8000, + pcr->_baserom & 0x1 ? "" : "not-"); + if (pcr->_max_min_ipin_iline) + printf(" MAX_LAT 0x%02x MIN_GNT 0x%02x INT_PIN 0x%02x INT_LINE 0x%02x\n", + pcr->_max_lat, pcr->_min_gnt, pcr->_int_pin, pcr->_int_line); +} + +static int io_fd; +#ifdef __EMX__ +USHORT callgate[3] = {0,0,0}; +#endif + +void +enable_os_io() +{ +#if defined(SVR4) || defined(SCO) || defined(ISC) +#if defined(SI86IOPL) + sysi86(SI86IOPL, 3); +#else + sysi86(SI86V86, V86SC_IOPL, PS_IOPL); +#endif +#endif +#if defined(linux) + iopl(3); +#endif +#if defined(__FreeBSD__) || defined(__386BSD__) || defined(__bsdi__) + if ((io_fd = open("/dev/console", O_RDWR, 0)) < 0) { + perror("/dev/console"); + exit(1); + } +#if defined(__FreeBSD__) || defined(__386BSD__) + if (ioctl(io_fd, KDENABIO, 0) < 0) { + perror("ioctl(KDENABIO)"); + exit(1); + } +#endif +#if defined(__bsdi__) + if (ioctl(io_fd, PCCONENABIOPL, 0) < 0) { + perror("ioctl(PCCONENABIOPL)"); + exit(1); + } +#endif +#endif +#if defined(__NetBSD__) +#if !defined(USE_I386_IOPL) + if ((io_fd = open("/dev/io", O_RDWR, 0)) < 0) { + perror("/dev/io"); + exit(1); + } +#else + if (i386_iopl(1) < 0) { + perror("i386_iopl"); + exit(1); + } +#endif /* USE_I386_IOPL */ +#endif /* __NetBSD__ */ +#if defined(__OpenBSD__) + if (i386_iopl(1) < 0) { + perror("i386_iopl"); + exit(1); + } +#endif /* __OpenBSD__ */ +#if defined(MACH386) + if ((io_fd = open("/dev/iopl", O_RDWR, 0)) < 0) { + perror("/dev/iopl"); + exit(1); + } +#endif +#ifdef __EMX__ + { + HFILE hfd; + ULONG dlen,action; + APIRET rc; + static char *ioDrvPath = "/dev/fastio$"; + + if (DosOpen((PSZ)ioDrvPath, (PHFILE)&hfd, (PULONG)&action, + (ULONG)0, FILE_SYSTEM, FILE_OPEN, + OPEN_SHARE_DENYNONE|OPEN_FLAGS_NOINHERIT|OPEN_ACCESS_READONLY, + (ULONG)0) != 0) { + fprintf(stderr,"Error opening fastio$ driver...\n"); + fprintf(stderr,"Please install xf86sup.sys in config.sys!\n"); + exit(42); + } + callgate[0] = callgate[1] = 0; + +/* Get callgate from driver for fast io to ports and other stuff */ + + rc = DosDevIOCtl(hfd, (ULONG)0x76, (ULONG)0x64, + NULL, 0, NULL, + (ULONG*)&callgate[2], sizeof(USHORT), &dlen); + if (rc) { + fprintf(stderr,"xf86-OS/2: EnableIOPorts failed, rc=%d, dlen=%d; emergency exit\n", + rc,dlen); + DosClose(hfd); + exit(42); + } + +/* Calling callgate with function 13 sets IOPL for the program */ + + asm volatile ("movl $13,%%ebx;.byte 0xff,0x1d;.long _callgate" + : /*no outputs */ + : /*no inputs */ + : "eax","ebx","ecx","edx","cc"); + + DosClose(hfd); + } +#endif +#if defined(Lynx) && defined(__powerpc__) + pciConfBase = (unsigned char *) smem_create("PCI-CONF", + (char *)0x80800000, 64*1024, SM_READ|SM_WRITE); + if (pciConfBase == (void *) -1) + exit(1); +#endif +} + + +void +disable_os_io() +{ +#if defined(SVR4) || defined(SCO) || defined(ISC) +#if defined(SI86IOPL) + sysi86(SI86IOPL, 0); +#else + sysi86(SI86V86, V86SC_IOPL, 0); +#endif +#endif +#if defined(linux) + iopl(0); +#endif +#if defined(__FreeBSD__) || defined(__386BSD__) + if (ioctl(io_fd, KDDISABIO, 0) < 0) { + perror("ioctl(KDDISABIO)"); + close(io_fd); + exit(1); + } + close(io_fd); +#endif +#if defined(__NetBSD__) +#if !defined(USE_I386_IOPL) + close(io_fd); +#else + if (i386_iopl(0) < 0) { + perror("i386_iopl"); + exit(1); + } +#endif /* NetBSD1_1 */ +#endif /* __NetBSD__ */ +#if defined(__bsdi__) + if (ioctl(io_fd, PCCONDISABIOPL, 0) < 0) { + perror("ioctl(PCCONDISABIOPL)"); + close(io_fd); + exit(1); + } + close(io_fd); +#endif +#if defined(MACH386) + close(io_fd); +#endif +#if defined(Lynx) && defined(__powerpc__) + smem_create(NULL, (char *) pciConfBase, 0, SM_DETACH); + smem_remove("PCI-CONF"); + pciConfBase = NULL; +#endif +} diff --git a/hw/xfree86/utils/xorgconfig/Cards b/hw/xfree86/utils/xorgconfig/Cards new file mode 100644 index 000000000..0412fdd61 --- /dev/null +++ b/hw/xfree86/utils/xorgconfig/Cards @@ -0,0 +1,2003 @@ +# $Xorg: Cards,v 1.3 2000/08/17 19:53:04 cpqbld Exp $ +# This is the database of card definitions used by xf86config. +# Each definition should have a NAME entry, CHIPSET (descriptive) and +# SERVER (one of Mono, VGA16, SVGA, S3, 8514, Mach8, Mach32, Mach64, AGX, +# P9000, W32, I128). +# A reference to another definition is made with SEE (already defined +# entries are not overridden). +# Optional entries are RAMDAC (identifier), CLOCKCHIP (identifier), +# DACSPEED, NOCLOCKPROBE (advises never to probe clocks), UNSUPPORTED +# (indicates card that is not yet properly supported by a dedicated +# server). A LINE entry adds a line of text to be included in the +# Device section (can include options or comments). +# There's no CLOCKS option (although a Clocks line can be included +# with LINE), as it is very undesirable to have a Clocks line that +# is incorrect. The idea is that the Clocks are probed for to be +# sure (a commented suggested Clocks line can be included). +# +# The majority of entries are just a binding of a model name to a +# chipset/server and untested. +# +# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.51.2.15 1998/02/27 15:28:57 dawes Exp $ + +#Chips & Technologies + +#untested +NAME Chips & Technologies CT65520 +CHIPSET ct65520 +SERVER SVGA +LINE # Device section for C&T cards. +LINE # Option "suspend_hack" +LINE # Option "STN" +LINE # Option "no_stretch" +LINE # Option "no_center" +LINE # Option "use_modeline" +LINE # Option "fix_panel_size" +LINE # videoram 512 + +NAME Chips & Technologies CT65525 +CHIPSET ct65525 +LINE # Option "nolinear" +LINE # MemBase 0x03b00000 +SEE Chips & Technologies CT65520 + +NAME Chips & Technologies CT65530 +CHIPSET ct65530 +SEE Chips & Technologies CT65525 + +NAME Chips & Technologies CT65535 +CHIPSET ct65535 +NOCLOCKPROBE +LINE # Option "hw_clocks" +LINE # Textclockfreq 25.175 +SEE Chips & Technologies CT65530 + +NAME Chips & Technologies CT65540 +CHIPSET ct65540 +NOCLOCKPROBE +LINE # Option "use_18bit_bus" +SEE Chips & Technologies CT65535 + +NAME Chips & Technologies CT65545 +CHIPSET ct65545 +NOCLOCKPROBE +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "sw_cursor" +LINE # Option "mmio" +SEE Chips & Technologies CT65540 + +NAME Chips & Technologies CT65546 +CHIPSET ct65546 +SEE Chips & Technologies CT65545 + +NAME Chips & Technologies CT65548 +CHIPSET ct65548 +SEE Chips & Technologies CT65545 + +NAME Chips & Technologies CT65550 +CHIPSET ct65550 +NOCLOCKPROBE +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "sw_cursor" +LINE # Option "sync_on_green" +LINE # Option "fast_dram" +LINE # Option "use_vclk1" +LINE # Textclockfreq 25.175 +SEE Chips & Technologies CT65530 + +NAME Chips & Technologies CT65554 +CHIPSET ct65554 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT65555 +CHIPSET ct65555 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT68554 +CHIPSET ct68554 +SEE Chips & Technologies CT65550 + +NAME Chips & Technologies CT64200 +CHIPSET ct64200 +SERVER SVGA +LINE # Device section for C&T cards. +LINE # videoram 1024 + +NAME Chips & Technologies CT64300 +CHIPSET ct64300 +SERVER SVGA +LINE # Option "noaccel" +LINE # Option "no_bitblt" +LINE # Option "xaa_no_color_exp" +LINE # Option "xaa_benchmark" +LINE # Option "sw_cursor" +LINE # Option "nolinear" +LINE # MemBase 0x03b00000 +LINE # Option "hw_clocks" +LINE # Textclockfreq 25.175 +SEE Chips & Technologies CT64200 + +# Cirrus Logic + +#tested +NAME Cirrus Logic GD542x +CHIPSET CL-GD5420/2/4/6/8/9 +SERVER SVGA +NOCLOCKPROBE +LINE # Device section for Cirrus Logic GD5420/2/4/6/8/9-based cards. +LINE #MemBase 0x00e00000 +LINE #MemBase 0x04e00000 +LINE #Option "linear" + +#tested +NAME Cirrus Logic GD543x +CHIPSET CL-GD5430/5434 +SERVER SVGA +NOCLOCKPROBE +LINE # Device section for Cirrus Logic GD5430/34-based cards. +LINE #MemBase 0x00e00000 # ISA card that maps to 14Mb +LINE #MemBase 0x04000000 # VLB card that maps to 64Mb +LINE #MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE #MemBase 0x02000000 # VLB card that maps to 32Mb +LINE #Option "linear" + +NAME Cirrus Logic GD544x +CHIPSET CL-GD544x +SERVER SVGA +NOCLOCKPROBE + +NAME Creative Labs Graphics Blaster MA201 +SEE Cirrus Logic GD544x + +NAME Creative Labs Graphics Blaster MA202 +SEE Cirrus Logic GD544x + +#tested +NAME Cirrus Logic GD5462 +CHIPSET CL-GD5462 +SERVER SVGA +NOCLOCKPROBE + +#tested +NAME Cirrus Logic GD5464 +CHIPSET CL-GD5464 +SERVER SVGA +NOCLOCKPROBE + +NAME Creative Labs Graphics Blaster MA302 +CHIPSET CL-GD5462 +SEE Cirrus Logic GD5462 + +NAME Creative Labs Graphics Blaster MA334 +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME Creative Labs Graphics Blaster 3D +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +#tested +NAME Diamond SpeedStar 64 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Diamond SpeedStar64 Graphics 2000/2200 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Diamond SpeedStar Pro SE (CL-GD5430/5434) +SEE Cirrus Logic GD543x + +NAME Diamond SpeedStar Pro 1100 +SEE Cirrus Logic GD542x + +NAME Orchid Kelvin 64 VLB Rev A +CHIPSET CL-GD5434 +SERVER SVGA +NOCLOCKPROBE +LINE # Device section for Orchid Kelvin 64 VLB Rev A +LINE # Linear framebuffer maps at 2048Mb. Some motherboards make linear addressing +LINE # impossible. Some cards map at 32Mb. +LINE #MemBase 0x02000000 # VLB card that maps to 32Mb +LINE #MemBase 0x04000000 # VLB card that maps to 64Mb +LINE MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE #Option "linear" + +NAME Orchid Kelvin 64 VLB Rev B +CHIPSET CL-GD5434 +SERVER SVGA +NOCLOCKPROBE +LINE # Device section for Orchid Kelvin 64 VLB Rev B +LINE # Linear framebuffer maps at 32Mb. Some motherboards make linear addressing +LINE # impossible. Some cards map at 2048Mb. +LINE MemBase 0x02000000 # VLB card that maps to 32Mb +LINE #MemBase 0x04000000 # VLB card that maps to 64Mb +LINE #MemBase 0x80000000 # VLB card that maps to 2048Mb +LINE #Option "linear" + +NAME Orchid Kelvin 64 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Intel 5430 +CHIPSET CL-GD5430 +SEE Cirrus Logic GD543x + +NAME STB Nitro (64) +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME STB Nitro 64 Video +CHIPSET CL-GD5446 +SEE Cirrus Logic GD544x + +NAME STB Horizon +CHIPSET CL-GD5426/28 +SEE Cirrus Logic GD542x + +NAME STB Horizon Video +CHIPSET CL-GD5440 +SEE Cirrus Logic GD544x + +NAME Genoa 8500VL(-28) +CHIPSET CL-GD5426/28 +SEE Cirrus Logic GD542x + +NAME Diamond SpeedStar Pro (not SE) +CHIPSET CL-GD5426/28 +SEE Cirrus Logic GD542x + +NAME ALG-5434(E) +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Actix ProStar +CHIPSET CL-GD5426/5428 +SEE Cirrus Logic GD542x + +NAME Actix ProStar 64 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +#tested +NAME Acumos AVGA3 +SEE Cirrus Logic GD542x + +NAME DFI-WG1000 +SEE Cirrus Logic GD542x + +NAME Spider VLB Plus +CHIPSET CL-GD5428 +SEE Cirrus Logic GD542x + +NAME VI720 +CHIPSET CL-GD5434 +SEE Cirrus Logic GD543x + +NAME Cirrus Logic GD62xx (laptop) +CHIPSET CL-GD6205/15/25/35 +SERVER SVGA +NOCLOCKPROBE + +NAME Cirrus Logic GD64xx (laptop) +CHIPSET CL-GD6420/6440 +SERVER SVGA + +NAME Cirrus Logic GD754x (laptop) +CHIPSET CL-GD7541/42/43/48 +SERVER SVGA +NOCLOCKPROBE + +# S3 801/805 + +NAME S3 801/805 (generic) +CHIPSET S3 801/805 +SERVER S3 + +NAME S3 86C801 (generic) +SEE S3 801/805 (generic) + +NAME S3 86C805 (generic) +SEE S3 801/805 (generic) + +#tested +NAME S3 801/805 with ATT20c490 RAMDAC +CHIPSET S3 801/805 +SERVER S3 +RAMDAC att20c490 +LINE #Option "dac_8_bit" # Not supported by some 20c490 clones + +NAME S3 801/805 with SC1148{2,3,4} RAMDAC +CHIPSET S3 801/805 +SERVER S3 +RAMDAC sc11482 + +NAME S3 801/805 with SC1148{5,7,9} RAMDAC +CHIPSET S3 801/805 +SERVER S3 +RAMDAC sc11485 + +NAME S3 801/805 with S3 GenDAC +CHIPSET S3 801/805 +SERVER S3 +RAMDAC s3gendac +CLOCKCHIP s3gendac + +NAME S3 801/805 with ATT20c490 RAMDAC and ICD2061A +CHIPSET S3 801/805 +SERVER S3 +RAMDAC att20c490 +CLOCKCHIP icd2061a +LINE #Option "dac_8_bit" # Not supported by some 20c490 clones + +NAME S3 801/805 with Chrontel 8391 +CHIPSET S3 801/805 +SERVER S3 +RAMDAC att20c490 +CLOCKCHIP ch8391 +LINE Option "dac_8_bit" + +#tested +NAME Actix GE32+ 2MB +CHIPSET S3 801/805 +SERVER S3 +RAMDAC att20c490 +LINE #Option "dac_8_bit" + +NAME Actix GE32i +CHIPSET S3 805i +SERVER S3 + +NAME Orchid Fahrenheit VA +CHIPSET S3 801/805 +SERVER S3 +RAMDAC att20c490 + +NAME Orchid Fahrenheit 1280 +CHIPSET S3 801 +SERVER S3 +LINE #Probable clocks: +LINE #Clocks 25.20 28.32 32.50 0.00 40.00 44.90 50.40 65.00 +LINE #Clocks 78.00 56.70 63.10 75.10 80.00 89.90 100.90 31.50 + +NAME Orchid Fahrenheit-1280+ +CHIPSET S3 801/805 +SERVER S3 +RAMDAC att20C490 +LINE Dacspeed 110 +LINE Option "dac_8_bit" +LINE #Option "nolinear" # VLB card may require this +LINE #Probable clocks: +LINE #Clocks 25.20 28.32 40.0 0.0 50.10 77.0 36.10 45.0 +LINE #Clocks 130.0 120.20 80.0 31.50 110.30 65.0 75.0 94.60 + +NAME Diamond Stealth 24 +CHIPSET S3 801/805 +SERVER S3 +CLOCKCHIP icd2061a +LINE #Option "nolinear" +LINE #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp + +NAME Miro Crystal 8S +SEE S3 801/805 (generic) + +NAME Miro Crystal 10SD with GenDAC +SEE S3 801/805 with S3 GenDAC + +NAME Dell S3 805 +SEE S3 801/805 (generic) + +NAME STB Powergraph X-24 +SEE S3 801/805 with ATT20c490 RAMDAC and ICD2061A + +NAME JAX 8241 +SEE S3 801/805 with Chrontel 8391 + +NAME VL-41 +SEE S3 801/805 with Chrontel 8391 + +NAME SPEA Mirage +SEE S3 801/805 with Chrontel 8391 + +# S3 864/Trio64/Trio32/868 + +NAME S3 864 (generic) +CHIPSET S3 864 +SERVER S3 + +NAME S3 86C864 (generic) +SEE S3 864 (generic) + +NAME S3 Vision864 (generic) +SEE S3 864 (generic) + +NAME S3 864 with SDAC (86C716) +CHIPSET S3 864 +SERVER S3 +RAMDAC s3_sdac +CLOCKCHIP s3_sdac +NOCLOCKPROBE + +NAME S3 864 with ATT 20C498 or 21C498 +CHIPSET S3 864 +SERVER S3 +RAMDAC att20c498 + +NAME S3 864 with STG1703 +CHIPSET S3 864 +SERVER S3 +RAMDAC stg1703 +NOCLOCKPROBE + +NAME S3 868 (generic) +CHIPSET S3 868 +SERVER S3 + +NAME S3 86C868 (generic) +SEE S3 868 (generic) + +NAME S3 Vision868 (generic) +SEE S3 868 (generic) + +NAME S3 868 with SDAC (86C716) +CHIPSET S3 868 +SERVER S3 +NOCLOCKPROBE + +NAME S3 868 with ATT 20C498 or 21C498 +CHIPSET S3 868 +SERVER S3 +RAMDAC att20c498 + +NAME S3 868 with ATT 20C409 +CHIPSET S3 868 +SERVER S3 +RAMDAC att20c409 +NOCLOCKPROBE + +NAME Number Nine FX Motion 531 +CLOCKCHIP icd2061a +SEE S3 868 with ATT 20C498 or 21C498 + +NAME S3 Trio64 (generic) +CHIPSET S3 Trio64 +SERVER S3 +NOCLOCKPROBE + +NAME S3 86C764 (generic) +SEE S3 Trio64 (generic) + +NAME S3 Trio64V+ (generic) +CHIPSET S3 Trio64V+ +SERVER S3 +NOCLOCKPROBE + +NAME S3 86C765 (generic) +SEE S3 Trio64V+ (generic) + +NAME S3 Trio32 (generic) +CHIPSET S3 Trio32 +SERVER S3 +NOCLOCKPROBE + +NAME Genoa Phantom 64i with S3 SDAC +DACSPEED 135 +SEE S3 864 with SDAC (86C716) + +NAME Number Nine GXE64 +CHIPSET S3 864 +SERVER S3 +CLOCKCHIP icd2061a +LINE Option "number_nine" + +NAME Number Nine GXE64 with S3 Trio64 +SEE S3 Trio64 (generic) + +NAME Diamond Stealth 64 DRAM with S3 SDAC +DACSPEED 135 +SEE S3 864 with SDAC (86C716) + +NAME Diamond Stealth64 Graphics 2xx0 series (864 + SDAC) +DACSPEED 135 +SEE S3 864 with SDAC (86C716) + +NAME Diamond Stealth 64 DRAM with S3 Trio64 +SEE S3 Trio64 (generic) + +NAME Diamond Stealth64 Graphics 2xx0 series (Trio64) +SEE S3 Trio64 (generic) + +NAME Diamond Stealth 64 DRAM SE +SEE S3 Trio32 (generic) + +NAME Diamond Stealth64 Video 2001 series (2121/2201) +SEE S3 Trio64V+ (generic) + +NAME Actix GE64 +CLOCKCHIP icd2061a +SEE S3 864 (generic) + +NAME ELSA Winner 1000PRO with S3 SDAC +SEE S3 864 with SDAC (86C716) + +NAME ELSA Winner 1000PRO with STG1700 or AT&T RAMDAC +CHIPSET S3 864 +SERVER S3 +CLOCKCHIP icd2061a + +NAME ELSA Winner 1000PRO/X +SEE S3 868 with SDAC (86C716) + +NAME ELSA Winner 1000ISA +CHIPSET S3 805i +SERVER S3 +CLOCKCHIP icd2061a +LINE Option "dac_8_bit" +LINE # the following settings should be detected and set automatically by XF86_S3 +LINE # if the serial number of the ELSA card is printed correctly: +LINE #ClockChip "icd2061a" + +NAME Cardex Trio64 +SEE S3 Trio64 (generic) + +NAME Cardex Trio64Pro +SEE S3 Trio64 (generic) + +NAME Miro Crystal 12SD +SEE S3 Trio32 (generic) + +NAME Miro Crystal 22SD +SEE S3 Trio64 (generic) + +NAME Miro Crystal 20SD with ICS2494 (BIOS 1.xx) +SEE S3 864 with ATT 20C498 or 21C498 + +NAME Miro Crystal 20SD with ICD2061A (BIOS 2.xx) +CLOCKCHIP icd2061a +SEE S3 864 with ATT 20C498 or 21C498 + +NAME Miro Crystal 20SD VLB with S3 SDAC (BIOS 3.xx) +SEE S3 864 with SDAC (86C716) + +NAME Miro Crystal 20SD PCI with S3 SDAC +SEE S3 868 with SDAC (86C716) + +NAME ELSA Winner 1000AVI (SDAC version) +SEE S3 868 with SDAC (86C716) + +NAME ELSA Winner 1000AVI (AT&T 20C409 version) +SEE S3 868 with ATT 20C409 + +NAME Diamond Stealth Video DRAM +SEE S3 868 with SDAC (86C716) + +NAME Diamond Stealth64 Video 2120/2200 +SEE S3 868 with SDAC (86C716) + +NAME SPEA/V7 Mirage P64 +CLOCKCHIP ics2595 +SEE S3 864 (generic) + +NAME SPEA/V7 Mirage P64 with S3 Trio64 +SEE S3 Trio64 (generic) + +NAME Number Nine FX Vision 330 +SEE S3 Trio64 (generic) + +NAME Number Nine FX Motion 331 +SEE S3 Trio64V+ (generic) + +NAME ASUS Video Magic PCI V864 +SEE S3 864 (generic) + +NAME ASUS Video Magic PCI VT64 +SEE S3 Trio64 (generic) + +NAME VidTech FastMax P20 +SEE S3 864 (generic) + +NAME VideoLogic GrafixStar 500 +SEE S3 868 with SDAC (86C716) + +NAME VideoLogic GrafixStar 400 +SEE S3 Trio64V+ (generic) + +NAME VideoLogic GrafixStar 300 +SEE S3 Trio64 (generic) + +NAME 2 the Max MAXColor S3 Trio64V+ +SEE S3 Trio64V+ (generic) + +NAME DataExpert DSV3365 +SEE S3 Trio64V+ (generic) + +NAME ExpertColor DSV3365 +SEE S3 Trio64V+ (generic) + +NAME DSV3326 +SEE S3 Trio64V+ (generic) + +# S3 Trio64V2 + +NAME S3 Trio64V2 (generic) +CHIPSET S3 Trio64V2 +SERVER S3 +NOCLOCKPROBE + +NAME S3 Trio64V2/DX (generic) +SEE S3 Trio64V2 (generic) + +NAME S3 Trio64V2/GX (generic) +SEE S3 Trio64V2 (generic) + +NAME S3 86C775 (generic) +SEE S3 Trio64V2/DX (generic) + +NAME S3 86C785 (generic) +SEE S3 Trio64V2/GX (generic) + +NAME ELSA WINNER 1000/T2D +SEE S3 Trio64V2/DX (generic) + + +# S3 Aurora64V+ + +NAME S3 Aurora64V+ (generic) +CHIPSET S3 Aurora64V+ +SERVER S3 +NOCLOCKPROBE +LINE # Option "lcd_center" +LINE # Set_LCDClk <pixel_clock_for_LCD> + +NAME S3 86CM65 +SEE S3 Aurora64V+ (generic) + +NAME SHARP 9080 +SEE S3 Aurora64V+ (generic) + +NAME SHARP 9090 +SEE S3 Aurora64V+ (generic) + +NAME COMPAQ Armada 7730MT +SEE S3 Aurora64V+ (generic) + +NAME COMPAQ Armada 7380DMT +SEE S3 Aurora64V+ (generic) + + +# S3 964/968 + +NAME S3 964 (generic) +CHIPSET S3 964 +SERVER S3 +NOCLOCKPROBE + +NAME S3 86C964 (generic) +SEE S3 964 (generic) + +NAME S3 Vision964 (generic) +SEE S3 964 (generic) + +NAME S3 968 (generic) +CHIPSET S3 968 +SERVER S3 +NOCLOCKPROBE + +NAME S3 86C968 (generic) +SEE S3 968 (generic) + +NAME S3 Vision968 (generic) +SEE S3 968 (generic) + +NAME Number Nine GXE64 Pro +CHIPSET S3 964 +SERVER S3 +RAMDAC ti3025 +LINE Option "number_nine" + +NAME Diamond Stealth 64 VRAM +CLOCKCHIP icd2061a +LINE #Option "slow_vram" +SEE S3 964 (generic) + +NAME Diamond Stealth64 Video 3200 +CHIPSET S3 968 +LINE #Option "slow_vram" +SEE S3 968 (generic) + +NAME Diamond Stealth 64 Video VRAM (TI RAMDAC) +CHIPSET S3 968 +LINE #Option "slow_vram" +LINE #DacSpeed 220 +SEE S3 968 (generic) + +NAME Diamond Stealth64 Video 3240/3400 (TI RAMDAC) +CHIPSET S3 968 +LINE #Option "slow_vram" +LINE #DacSpeed 220 +SEE S3 968 (generic) + +NAME Diamond Stealth64 Video 3240/3400 (IBM RAMDAC) +CHIPSET S3 968 +LINE #Option "slow_vram" +RAMDAC ibm_rgb526 +LINE DacSpeed 220 +SEE S3 968 (generic) + +NAME Genoa VideoBlitz III AV +CHIPSET S3 968 +LINE #s3RefClk 50 +LINE #DACspeed 170 +SEE S3 968 (generic) + +NAME STB Velocity 64 Video +CHIPSET S3 968 +LINE #s3RefClk 24 +LINE #DACspeed 220 +SEE S3 968 (generic) + +NAME STB Powergraph 64 Video +SEE S3 Trio64V+ (generic) + +NAME STB Powergraph 64 +SEE S3 Trio64 (generic) + +NAME ELSA Winner 1000TRIO +SEE S3 Trio64 (generic) + +NAME ELSA Winner 1000TRIO/V +SEE S3 Trio64V+ (generic) + +NAME Hercules Graphite Terminator 64 +LINE Option "slow_vram" +LINE #s3RefClk 50 +LINE #DACspeed 170 +SEE S3 964 (generic) + +NAME Hercules Terminator 64/Video +SEE S3 Trio64V+ (generic) + +NAME Hercules Graphite Terminator 64/DRAM +SEE S3 Trio64 (generic) + +NAME Hercules Graphite Terminator Pro 64 +LINE #s3RefClk 16 +LINE #DACspeed 220 +SEE S3 968 (generic) + +NAME Number Nine FX Motion 771 +LINE #s3RefClk 16 +SEE S3 968 (generic) + +NAME Spider Tarantula 64 +SEE S3 964 (generic) + +NAME Miro Crystal 20SV +CHIPSET S3 964 +SERVER S3 +CLOCKCHIP icd2061a + +NAME Miro Crystal 40SV +CHIPSET S3 964 +SERVER S3 +CLOCKCHIP ti3025 + +NAME Miro Crystal 80SV +CHIPSET S3 968 +SERVER S3 +NOCLOCKPROBE + +NAME Miro Video 20SV +CHIPSET S3 968 +SERVER S3 +RAMDAC att20c505 +LINE #DacSpeed 150 +CLOCKCHIP ics9161a + +NAME SPEA Mercury 64 +CHIPSET S3 964 +SERVER S3 +CLOCKCHIP ics9161a +LINE #Option "spea_mercury" + +NAME ELSA Winner 2000PRO-2 +CHIPSET S3 964 +SERVER S3 +LINE #Option "ELSA_w2000pro" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO-4 +CHIPSET S3 964 +SERVER S3 +LINE #Option "ELSA_w2000pro" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO/X-2 +CHIPSET S3 968 +SERVER S3 +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO/X-4 +CHIPSET S3 968 +SERVER S3 +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Winner 2000PRO/X-8 +CHIPSET S3 968 +SERVER S3 +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Winner 2000AVI +CHIPSET S3 968 +SERVER S3 +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Gloria-4 +CHIPSET S3 968 +SERVER S3 +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME ELSA Gloria-8 +CHIPSET S3 968 +SERVER S3 +LINE #Option "sync_on_green" +NOCLOCKPROBE + +NAME VideoLogic GrafixStar 700 +CHIPSET S3 968 +SERVER S3 +NOCLOCKPROBE + +NAME LeadTek WinFast S430 +CHIPSET S3 968 +SERVER S3 +NOCLOCKPROBE + +NAME WinFast S430 +SEE LeadTek WinFast S430 + +NAME LeadTek WinFast S510 +CHIPSET S3 968 +SERVER S3 +NOCLOCKPROBE + +NAME WinFast S510 +SEE LeadTek WinFast S510 + +# S3 928 + +NAME S3 928 (generic) +CHIPSET S3 928 +SERVER S3 + +NAME S3 86C928 (generic) +SEE S3 928 (generic) + +NAME Actix Ultra +CHIPSET S3 928 +SERVER S3 +RAMDAC att20c490 +LINE #Option "dac_8_bit" + +NAME Diamond Stealth Pro +CHIPSET S3 928 +SERVER S3 +CLOCKCHIP icd2061a +LINE #Ramdac "att20c490" # The Diamond RAMDAC is reportedly compatible for 15bpp +LINE #Option "no_linear" # Some VLB machines may require this + +NAME ELSA Winner 1000VL +CHIPSET S3 928 +SERVER S3 +LINE # the following settings should be detected and set automatically by XF86_S3 +LINE # if the serial number of the ELSA card is printed correctly: +LINE #ClockChip "icd2061a" +LINE #Membase 0xf8000000 + +NAME ELSA Winner 1000TwinBus +SEE ELSA Winner 1000VL + +NAME ELSA Winner 2000 +SEE S3 928 (generic) + +NAME Miro Crystal 16S +SEE S3 928 (generic) + +NAME SPEA/V7 Mercury +CHIPSET S3 928 +SERVER S3 +CLOCKCHIP sc11412 +LINE Option "spea_mercury" + +NAME STB Pegasus +CHIPSET S3 928 +SERVER S3 +RAMDAC bt485 +CLOCKCHIP icd2061a +LINE Option "stb_pegasus" +LINE #Option "sync_on_green" + +NAME Number Nine GXE Level 14/16 +CHIPSET S3 928 +SERVER S3 +DACSPEED 200 +CLOCKCHIP icd2061a +LINE Option "number_nine" +LINE #Option "nolinear" +LINE #Option "nomemaccess" + +NAME Number Nine GXE Level 10/11/12 +CHIPSET S3 928 +SERVER S3 +CLOCKCHIP icd2061a +LINE Option "number_nine" + +NAME 928Movie +CHIPSET S3 928 +SERVER S3 +CLOCKCHIP icd2595 +RAMDAC bt485 +LINE # pixel multiplexing not supported + +# S3 911/924 + +NAME S3 911/924 (generic) +CHIPSET S3 911/924 +SERVER S3 + +NAME S3 86C911 (generic) +SEE S3 911/924 (generic) + +NAME S3 86C924 (generic) +SEE S3 911/924 (generic) + +NAME Diamond Stealth VRAM +CHIPSET S3 911/924 +SERVER S3 +CLOCKCHIP icd2061a + +#NAME Orchid Fahrenheit 1280 +#SEE S3 911/924 (generic) + +NAME S3 924 with SC1148 DAC +CHIPSET S3 924 +SERVER S3 +LINE #Probable clocks: +LINE #Clocks 25.2 28.3 39.7 1.7 49.9 76.7 35.7 44 +LINE #Clocks 130.2 119.5 79.4 31.2 110.0 65.2 74.9 71.3 + +# S3 ViRGE,/DX,/GX and ViRGE/VX + +NAME S3 ViRGE (old S3V server) +CHIPSET S3 ViRGE +SERVER S3V +NOCLOCKPROBE + +NAME S3 ViRGE (generic) +CHIPSET S3 ViRGE +SERVER SVGA +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/DX (generic) +CHIPSET S3 ViRGE/DX +SERVER SVGA +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/GX (generic) +CHIPSET S3 ViRGE/GX +SERVER SVGA +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + + +NAME S3 ViRGE/GX2 (generic) +CHIPSET S3 ViRGE/GX2 +SERVER SVGA +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + +NAME S3 ViRGE/MX (generic) +CHIPSET S3 ViRGE/MX +SERVER SVGA +NOCLOCKPROBE +LINE #Option "lcd_center" +LINE #Set_LCDClk <pixel_clock_for_LCD> +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + + + + +NAME S3 86C325 (generic) +SEE S3 ViRGE (generic) + +NAME S3 86C375 (generic) +SEE S3 ViRGE/DX (generic) + +NAME S3 86C385 (generic) +SEE S3 ViRGE/GX (generic) + +NAME S3 86C357 (generic) +SEE S3 ViRGE/GX2 (generic) + +NAME S3 86C260 (generic) +SEE S3 ViRGE/MX (generic) + + +NAME ELSA Victory 3D +SEE S3 ViRGE (generic) + +NAME ELSA Victory 3DX +SEE S3 ViRGE/DX (generic) + +NAME ELSA Winner 3000-S +SEE S3 ViRGE (generic) + +NAME Number Nine Visual 9FX Reality 332 +SEE S3 ViRGE (generic) + +NAME Number Nine FX Motion 332 +SEE S3 ViRGE (generic) + +NAME Diamond Stealth 3D 2000 +SEE S3 ViRGE (generic) + +NAME Diamond Stealth 3D 2000 PRO +SEE S3 ViRGE/DX (generic) + +NAME Diamond Multimedia Stealth 3D 2000 +SEE S3 ViRGE (generic) + +NAME Diamond Multimedia Stealth 3D 2000 PRO +SEE S3 ViRGE/DX (generic) + +NAME Canopus Co. Power Window 3DV +SEE S3 ViRGE (generic) + +NAME DataExpert DSV3325 +SEE S3 ViRGE (generic) + +NAME ExpertColor DSV3325 +SEE S3 ViRGE (generic) + +NAME DSV3325 +SEE S3 ViRGE (generic) + +NAME Hercules Terminator 64/3D +SEE S3 ViRGE (generic) + +NAME Hercules Terminator 3D/DX +SEE S3 ViRGE/DX (generic) + +NAME LeadTek WinFast 3D S600 +SEE S3 ViRGE (generic) + +NAME WinFast 3D S600 +SEE LeadTek WinFast 3D S600 + +NAME LeadTek WinFast 3D S680 +SEE S3 ViRGE/GX2 (generic) + +NAME WinFast 3D S600 +SEE LeadTek WinFast 3D S680 + +NAME miro miroMedia 3D +SEE S3 ViRGE (generic) + +NAME Orchid Technology Fahrenheit Video 3D +SEE S3 ViRGE (generic) + +NAME STB Systems Powergraph 3D +SEE S3 ViRGE (generic) + +NAME STB Nitro 3D +CHIPSET S3 ViRGE/GX +SEE S3 ViRGE/GX (generic) + +NAME MELCO WGP-VG4S +LINE #DACSpeed 191 162 111 83 +LINE #SetMClck 75 +SEE S3 ViRGE (generic) + + + +NAME S3 ViRGE/VX (generic) +CHIPSET S3 ViRGE/VX +SERVER SVGA +NOCLOCKPROBE +LINE #Option "xaa_benchmark" +LINE #Option "fifo_moderate" +LINE #Option "pci_burst_on" +LINE #Option "pci_retry" + + +NAME S3 86C988 (generic) +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 3000 +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 3000-M-22 +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 3000-L-42 +SEE S3 ViRGE/VX (generic) + +NAME ELSA Winner 2000AVI/3D +SEE S3 ViRGE/VX (generic) + +NAME Diamond Stealth 3D 3000 +SEE S3 ViRGE/VX (generic) + +NAME STB Systems Velocity 3D +SEE S3 ViRGE/VX (generic) + +NAME MELCO WGP-VX8 +SEE S3 ViRGE/VX (generic) + + +NAME Toshiba Tecra 750CDT +SEE S3 ViRGE/MX (generic) + +NAME Toshiba Tecra 750DVD +SEE S3 ViRGE/MX (generic) + +NAME Toshiba Tecra 540CDT +SEE S3 ViRGE/MX (generic) + +NAME Toshiba Tecra 550CDT +SEE S3 ViRGE/MX (generic) + + + + + +# ET4000/ET6000 + +NAME ET3000 (generic) +CHIPSET ET3000 +SERVER SVGA + +NAME Genoa 5400 +SEE ET3000 (generic) + +NAME ET4000 (generic) +CHIPSET ET4000 +SERVER SVGA + +NAME ET4000/W32 (generic) +CHIPSET ET4000/W32 +SERVER W32 + +NAME ET4000 W32i, W32p (generic) +CHIPSET ET4000/W32(i/p) +SERVER SVGA +LINE #Option "linear" # for linear mode at 8bpp +LINE #Option "noaccel" # when problems with accelerator +LINE #Option "power_saver" # enable VESA DPMS +LINE #Option "fast_dram" +LINE #Option "pci_retry" # faster, but problematic for ISA DMA +LINE #Option "hibit_high" # see README.tseng -- most cards need this +LINE #Option "hibit_low" # see README.tseng -- mostly for older ET4000 cards +LINE #MemBase 0x3C00000 # when automatic MemBase detection doesn't work +LINE # -- see README.tseng for more (important) information on MemBase + +NAME ET6000 (generic) +CHIPSET ET6000 +SERVER SVGA +NOCLOCKPROBE +LINE #videoram 2304 # 2.25 MB, when memory probe is incorrect +LINE #Option "linear" # for linear mode at 8bpp +LINE #Option "noaccel" # when problems with accelerator +LINE #Option "power_saver" # enable VESA DPMS +LINE #Option "pci_retry" # faster, but problematic for ISA DMA +LINE #Option "hw_cursor" # Use hardware cursor (see docs for limitations) +LINE #Option "xaa_no_color_exp" # When text (or bitmap) is not rendered correctly + +NAME ET6100 (generic) +CHIPSET ET6100 +SERVER XSuSE_Tseng +NOCLOCKPROBE + +NAME Diamond Stealth 32 +CLOCKCHIP icd2061a +NOCLOCKPROBE +SEE ET4000 W32i, W32p (generic) + +NAME Cardex Cobra +SEE ET4000 W32i, W32p (generic) + +NAME Cardex Challenger (Pro) +SEE ET4000 W32i, W32p (generic) + +NAME Colorgraphic Dual Lightning +SEE ET4000 W32i, W32p (generic) + +NAME Dell onboard ET4000 +SEE ET4000 (generic) + +NAME DFI-WG5000 +SEE ET4000 W32i, W32p (generic) + +NAME Diamond SpeedStar (Plus) +SEE ET4000 (generic) + +NAME Diamond SpeedStar 24 +SEE ET4000 (generic) + +NAME Diamond SpeedStar HiColor +SEE ET4000 (generic) + +NAME Genoa 8900 Phantom 32i +SEE ET4000 W32i, W32p (generic) + +NAME Hercules Dynamite +SEE ET4000/W32 (generic) + +NAME Hercules Dynamite Power +SEE ET4000 W32i, W32p (generic) + +NAME Hercules Dynamite Pro +SEE ET4000 W32i, W32p (generic) + +NAME Integral FlashPoint +SEE ET4000 W32i, W32p (generic) + +NAME LeadTek WinFast S200 +SEE ET4000 W32i, W32p (generic) + +NAME Matrox Comet +SEE ET4000 W32i, W32p (generic) + +NAME Matrox Marvel II +SEE ET4000 W32i, W32p (generic) + +NAME Miro MiroVideo 20TD +SEE ET4000 W32i, W32p (generic) + +NAME WinFast S200 +SEE LeadTek WinFast S200 + +NAME Sigma Concorde +SEE ET4000/W32 (generic) + +NAME Sigma Legend +SEE ET4000 (generic) + +NAME SPEA/V7 ShowTime Plus +SEE ET4000 W32i, W32p (generic) + +NAME STB LightSpeed +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-2 +SEE ET4000 (generic) + +NAME STB MVP-2 PCI +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-2X +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-4 PCI +SEE ET4000 W32i, W32p (generic) + +NAME STB MVP-4X +SEE ET4000 W32i, W32p (generic) + +NAME TechWorks Thunderbolt +SEE ET4000/W32 (generic) + +NAME ViewTop PCI +SEE ET4000 W32i, W32p (generic) + +NAME SNI PC5H W32 +CLOCKCHIP stg1703 +NOCLOCKPROBE +SEE ET4000 W32i, W32p (generic) + +NAME SNI Scenic W32 +CLOCKCHIP stg1703 +NOCLOCKPROBE +SEE ET4000 W32i, W32p (generic) + +NAME Hercules Dynamite 128/Video +SEE ET6000 (generic) + +NAME STB LightSpeed 128 +SEE ET6000 (generic) + +NAME VideoLogic GrafixStar 600 +SEE ET6000 (generic) + +NAME Jazz Multimedia G-Force 128 +SEE ET6000 (generic) + +NAME Mirage Z-128 +SEE ET6000 (generic) + +NAME California Graphics SunTracer 6000 +SEE ET6000 (generic) + +NAME Binar Graphics AnyView +SEE ET6000 (generic) + +NAME MediaVision Proaxcel 128 +SEE ET6000 (generic) + +NAME ATrend ATC-2165A +SEE ET6000 (generic) + +NAME Interay PMC Viper +SEE ET6000 (generic) + +2-the-Max MAXColor 6000 +SEE ET6000 (generic) + +Gainward Challenger EV +SEE ET6000 (generic) + +MachSpeed VGA ET6000 +SEE ET6000 (generic) + +KouTech KeyVision 128 EV +SEE ET6000 (generic) + + +# ATI + +NAME ATI 8514 Ultra (no VGA) +CHIPSET ATI-Mach8 +SERVER Mach8 + +NAME ATI Graphics Ultra +CHIPSET ATI-Mach8 +SERVER Mach8 +LINE #Probable clocks: +LINE #Clocks 43 49 80 36 50 56 0 45 30 32 110 79 40 45 75 65 +LINE #Clocks 22 25 46 18 25 28 0 22 15 16 55 40 20 22 38 32 + +NAME ATI Graphics Ultra Pro +CHIPSET ATI-Mach32 +SERVER Mach32 +LINE #Probable clocks: +LINE #Clocks 100 126 92 36 51 57 0 44 135 32 110 80 39 +LINE #Clocks 45 75 65 50 63 46 18 25 28 0 22 67 16 55 40 19 23 37 33 +LINE #Option "dac_8_bit" + +NAME ATI Wonder SVGA +CHIPSET ATI vgawonder +SERVER SVGA +LINE #probable clocks: +LINE #Clocks 30 32 11 80 42 48 92 36 40 45 75 65 50 56 0 0 +LINE #Clocks 15 16 55 0 21 24 46 18 20 22 37 32 25 28 0 0 + +NAME ATI Ultra Plus +CHIPSET ATI-Mach32 +SERVER Mach32 + +NAME ATI Mach32 +CHIPSET ATI-Mach32 +SERVER Mach32 + +NAME ATI Mach64 +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Mach64 with AT&T 20C408 RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +LINE #Ramdac "att20c408" +NOCLOCKPROBE + +NAME ATI Mach64 with CH8398 RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +LINE #Ramdac "ch8398" +NOCLOCKPROBE + +NAME ATI Mach64 with IBM RGB514 RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +LINE #Ramdac "ibm_rgb514" +NOCLOCKPROBE + +NAME ATI Mach64 CT (264CT), Internal RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Mach64 VT (264VT), Internal RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Mach64 GT (264GT), aka 3D RAGE, Internal RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Mach64 3D RAGE II, Internal RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Mach64 3D RAGE II+, Internal RAMDAC +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Xpert@Play PCI and AGP, 3D Rage Pro +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Xpert@Work, 3D Rage Pro +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Pro Turbo+PC2TV, 3D Rage II+DVD +CHIPSET ATI-Mach64 +SERVER Mach64 +NOCLOCKPROBE + +NAME ATI Graphics Xpression with STG1702 RAMDAC +SEE ATI Mach64 + +NAME ATI Graphics Xpression with 68875 RAMDAC +SEE ATI Mach64 + +NAME ATI Graphics Xpression with CH8398 RAMDAC +SEE ATI Mach64 with CH8398 RAMDAC + +NAME ATI Graphics Xpression with AT&T 20C408 RAMDAC +SEE ATI Mach64 with AT&T 20C408 RAMDAC + +NAME ATI Graphics Xpression with Mach64 CT (264CT) +SEE ATI Mach64 CT (264CT), Internal RAMDAC + +NAME ATI Video Xpression +SEE ATI Mach64 VT (264VT), Internal RAMDAC + +NAME ATI 3D Xpression +SEE ATI Mach64 GT (264GT), aka 3D RAGE, Internal RAMDAC + +NAME ATI 3D Xpression+ PC2TV +SEE ATI Mach64 3D RAGE II, Internal RAMDAC + +NAME ATI 3D Pro Turbo +SEE ATI Mach64 3D RAGE II, Internal RAMDAC + +NAME ATI All-in-Wonder +SEE ATI Mach64 3D RAGE II+, Internal RAMDAC + +NAME ATI Win Boost with STG1702 RAMDAC +SEE ATI Mach64 + +NAME ATI Win Boost with CH8398 RAMDAC +SEE ATI Mach64 with CH8398 RAMDAC + +NAME ATI Win Boost with AT&T 20C408 RAMDAC +SEE ATI Mach64 with AT&T 20C408 RAMDAC + +NAME ATI Win Boost with Mach64 CT (264CT) +SEE ATI Mach64 CT (264CT), Internal RAMDAC + +NAME ATI Graphics Pro Turbo +SEE ATI Mach64 + +NAME ATI Graphics Pro Turbo 1600 +SEE ATI Mach64 with IBM RGB514 RAMDAC + +NAME ATI Win Turbo +SEE ATI Mach64 + +NAME ASUS PCI-V264CT +SEE ATI Mach64 CT (264CT), Internal RAMDAC + +NAME ASUS PCI-AV264CT +SEE ATI Mach64 CT (264CT), Internal RAMDAC + +# AGX + +NAME AGX (generic) +CHIPSET AGX-014/15/16 +SERVER AGX + +NAME Boca Vortex (Sierra RAMDAC) +CHIPSET AGX-015 +SERVER AGX +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + +NAME EIZO (VRAM) +SEE AGX (generic) + +NAME Orchid Celsius (AT&T RAMDAC) +CHIPSET AGX-015 +SERVER AGX +RAMDAC att20c490 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + +NAME Orchid Celsius (Sierra RAMDAC) +CHIPSET AGX-015 +SERVER AGX +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + + +NAME Spider Black Widow +CHIPSET AGX-015 +SERVER AGX +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels + + +NAME Spider Black Widow Plus +CHIPSET AGX-016 +SERVER AGX +RAMDAC sc15025 +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels +LINE #Option "fifo_aggressive" # 3x bus bw - may result in random pixels +LINE #Probable clocks: +LINE #Clocks 25.2 28.3 39.9 72.2 50.0 76.9 36.1 44.8 +LINE #Clocks 89.0 119.8 79.9 31.5 110.0 64.9 74.9 94.9 + +NAME Hercules Graphite HG210 +CHIPSET AGX-014 +SERVER AGX +RAMDAC bt482 +DACSPEED 85 +LINE Chipset "AGX-014" +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Probable clocks: +LINE #Clocks 25.0 28.0 32.0 36.0 40.0 45.0 50.0 65.0 +LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0 + +NAME Hercules Graphite Pro +CHIPSET AGX-015 +SERVER AGX +# Card specific DAC, doesn't appear in ramdac menu +LINE Ramdac "herc_dual_dac" +LINE Chipset "AGX-015" +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels +LINE #Probable clocks: +LINE #Clocks 25.0 28.0 32.0 36.0 40.0 45.0 50.0 65.0 +LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0 + +NAME Hercules Graphite Power +CHIPSET AGX-016 +SERVER AGX +# Card specific DAC, doesn't appear in ramdac menu +# The glue logic state machine for RAMDAC switching doesn't work as +# documented, for now we're stuck with the small RAMDAC +LINE Ramdac "herc_small_dac" +LINE Chipset "AGX-016" +LINE Option "dac_8_bit" +LINE Option "no_wait_state" +LINE #Option "fifo_moderate" # 2x bus bw - may result in random pixels +LINE #Option "fifo_aggressive" # 3x bus bw - may result in random pixels +LINE #Probable clocks: +LINE #Clocks 25.0 28.0 32.0 36.0 40.0 45.0 50.0 65.0 +LINE #Clocks 70.0 75.0 80.0 85.0 90.0 95.0 100.0 110.0 + +NAME XGA-2 (ISA bus) +CHIPSET XGA-2 +SERVER AGX +NOCLOCKPROBE +LINE #Instance 7 # XGA instance 0-7 +LINE #COPbase 0xC8F00 # XGA memory-mapped register address +LINE #POSbase 0 # Disable probing if above are specified + +NAME XGA-1 (ISA bus) +CHIPSET XGA-1 +SERVER AGX +LINE #Instance 7 # XGA instance 0-7 +LINE #COPbase 0xC8F00 # XGA memory-mapped register address +LINE #POSbase 0 # Disable probing if above are specified + +# WD + +NAME Paradise/WD 90CXX +CHIPSET WD90CXX +SERVER SVGA + +NAME DFI-WG6000 +CHIPSET WD90C33 +SERVER SVGA + +NAME Diamond SpeedStar 24X (not fully supported) +CHIPSET WD90C31 +SERVER SVGA + +NAME WD 90C24 (laptop) +CHIPSET WD90C24 +SERVER SVGA +LINE #Chipset "wd90c24" +LINE #Option "noaccel" # Use this if acceleration is causing problems +LINE #Clocks 25.175 28.322 65 36 # These are not programmable +LINE #Clocks 29.979 77.408 62.195 59.957 # These are programmable +LINE #Clocks 31.5 35.501 75.166 50.114 # These are not programmable +LINE #Clocks 39.822 72.038 44.744 80.092 # These are programmable +LINE #Clocks 44.297 # Must match Mclk + + +NAME WD 90C24A or 90C24A2 (laptop) +CHIPSET WD90C24A +SERVER SVGA +LINE #Chipset "wd90c24" +LINE #Clocks 25.175 28.322 65 36 # These are not programmable +LINE #Clocks 29.979 77.408 62.195 59.957 # These are programmable +LINE #Clocks 31.5 35.501 75.166 50.114 # These are not programmable +LINE #Clocks 39.822 72.038 44.744 80.092 # These are programmable +LINE #Clocks 44.297 # Must match Mclk + +# Avance Logic + +NAME Avance Logic 2101 +CHIPSET Avance Logic +LINE #chipset "al2101" +SERVER SVGA + +NAME Avance Logic 2228 +CHIPSET Avance Logic +LINE #chipset "ali2228" +SERVER SVGA + +NAME Avance Logic 2301 +CHIPSET Avance Logic +LINE #chipset "ali2301" +SERVER SVGA + +NAME Avance Logic 2302 +CHIPSET Avance Logic +LINE #chipset "ali2302" +SERVER SVGA + +NAME Avance Logic 2308 +CHIPSET Avance Logic +LINE #chipset "ali2308" +SERVER SVGA + +NAME Avance Logic 2401 +CHIPSET Avance Logic +LINE #chipset "ali2401" +SERVER SVGA + +NAME Hercules Stingray +CHIPSET ALG-2228/2301/2302 +LINE #chipset "ali2228" +SERVER SVGA + +NAME SPEA/V7 Mirage VEGA Plus +CHIPSET ALG-2228 +LINE #chipset "ali2228" +SERVER SVGA + +# ARK Logic + +NAME Ark Logic ARK1000PV (generic) +CHIPSET ARK1000PV +SERVER SVGA + +# For now, treat the VL as a PV. This may be changed later +NAME Ark Logic ARK1000VL (generic) +CHIPSET ARK1000VL +LINE Chipset "ark1000pv" +SERVER SVGA + +NAME Ark Logic ARK2000PV (generic) +CHIPSET ARK1000PV +SERVER SVGA + +NAME Ark Logic ARK2000MT (generic) +CHIPSET ARK1000MT +SERVER SVGA + +NAME Hercules Stingray Pro +SEE Ark Logic ARK1000PV (generic) + +NAME Hercules Stingray Pro/V +SEE Ark Logic ARK1000PV (generic) + +NAME Ocean (octek) VL-VGA-1000 +RAMDAC att20c490 +SEE Ark Logic ARK1000VL (generic) + +NAME Hercules Stingray 64/V with ZoomDAC +SEE Ark Logic ARK2000PV (generic) + +NAME Hercules Stingray 64/V with ICS5342 +CHIPSET ARK2000MT +RAMDAC ics5342 +SERVER SVGA + +NAME Diamond Stealth64 Graphics 2001 series +CHIPSET ARK2000PV +RAMDAC ics5342 +SERVER SVGA + +# Oak + +NAME Oak (generic) +CHIPSET Oak-067/77/87 +SERVER SVGA + +NAME Paradise Accelerator Value +CHIPSET Oak OTI-087 +SERVER SVGA + +# P9000 + +NAME Diamond Viper VLB 2Mb +CHIPSET Weitek 9000 +SERVER P9000 +LINE #Clocks must match the mode clocks (XFree86 3.1 P9000 server) +LINE #Versions later than 3.1 do not require a clocks line +LINE Chipset "vipervlb" # Required for some cards which autodetect as PCI +LINE Videoram 2048 # Required +LINE Membase 0x80000000 # Optional (0x80000000 is default) +NOCLOCKPROBE + +NAME Diamond Viper PCI 2Mb +CHIPSET Weitek 9000 +SERVER P9000 +LINE #Clocks must match the mode clocks (XFree86 3.1 P9000 server) +LINE #Versions later than 3.1 do not require a clocks line +LINE Videoram 2048 # Required +LINE #Membase 0x80000000 # Use scanpci to get the correct Membase +NOCLOCKPROBE + +NAME Orchid P9000 VLB +CHIPSET Weitek 9000 +SERVER P9000 +LINE Chipset "orchid_p9000" +LINE Membase 0xE0000000 +NOCLOCKPROBE + +# Trident + +NAME Trident 8900/9000 (generic) +CHIPSET TVGA8900/9000 +SERVER SVGA + +NAME Trident 8900D (generic) +CHIPSET TVGA8900D +SERVER SVGA + +NAME Trident TVGA9200CXr (generic) +CHIPSET TVGA9200CXr +SERVER SVGA + +NAME Trident TGUI9400CXi (generic) +CHIPSET TGUI9400CXi +SERVER SVGA + +NAME Trident TGUI9420DGi (generic) +CHIPSET TGUI9420DGi +SERVER SVGA + +NAME Trident TGUI9430DGi (generic) +CHIPSET TGUI9430DGi +SERVER SVGA + +NAME Trident TGUI9440 (generic) +CHIPSET TGUI9440 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident TGUI9660 (generic) +CHIPSET TGUI9660 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident TGUI9680 (generic) +CHIPSET TGUI9680 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident TGUI9682 (generic) +CHIPSET TGUI9682 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident TGUI9685 (generic) +CHIPSET TGUI9685 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident Cyber 9382 (generic) +CHIPSET Cyber9382 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident Cyber 9385 (generic) +CHIPSET Cyber9385 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident Cyber 9388 (generic) +CHIPSET Cyber9388 +SERVER SVGA +NOCLOCKPROBE + +NAME Trident Cyber 9397 (generic) +CHIPSET Cyber9397 +SERVER SVGA +NOCLOCKPROBE + +# SiS + +NAME SiS SG86C201 +CHIPSET SIS86C201 +SERVER SVGA + +# Alliance ProMotion + +NAME Alliance ProMotion 6422 +CHIPSET AP6422 +SERVER SVGA + +# VGA + +NAME Generic VGA compatible +CHIPSET Generic VGA +SERVER VGA16 + +NAME Unsupported VGA compatible +CHIPSET Generic VGA +SERVER VGA16 +UNSUPPORTED + +# Number 9 I128 + +NAME Number Nine Imagine I-128 (2-8MB) +CHIPSET I128 +SERVER I128 + +NAME Number Nine Imagine I-128 Series 2 (2-4MB) +CHIPSET I128 +SERVER I128 + +# Matrox + +NAME Matrox Millennium (MGA) +CHIPSET mga2064w +SERVER SVGA +NOCLOCKPROBE + +NAME Matrox Millennium II +CHIPSET mga2164w +SERVER SVGA +NOCLOCKPROBE + +NAME Matrox Millennium II AGP +CHIPSET mga2164w AGP +SERVER SVGA +NOCLOCKPROBE + +NAME Matrox Mystique +CHIPSET mga1064sg +SERVER SVGA +NOCLOCKPROBE + +# NV1 + +NAME Diamond Edge 3D +CHIPSET nv1 +SERVER SVGA +NOCLOCKPROBE + +NAME RIVA128 +CHIPSET RIVA128 +SERVER SVGA +NOCLOCKPROBE + +NAME ELSA VICTORY ERAZOR +SEE RIVA128 + +NAME Diamond Viper 330 +SEE RIVA128 + +NAME STB Velocity 128 +SEE RIVA128 + +NAME ASUS 3Dexplorer +SEE RIVA128 + +# Alliance Semiconductor + +NAME Diamond Stealth Video 2500 +CHIPSET Alliance AT24 +SERVER SVGA +NOCLOCKPROBE + +NAME AT3D +CHIPSET Alliance AT3D +SERVER SVGA +NOCLOCKPROBE +LINE #Option "no_accel" + +NAME AT25 +SEE AT3D + +NAME Hercules Stingray 128 3D +SEE AT3D + +# Misc + +NAME Techworks Ultimate 3D +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME VideoLogic GrafixStar 550 +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME Jaton Video-70P +CHIPSET CL-GD5464 +SEE Cirrus Logic GD5464 + +NAME Jaton Video-58P +SEE ET6000 (generic) + +NAME Rendition Verite 1000 +CHIPSET Verite 1000 +SEE Unsupported VGA compatible + +NAME Creative Labs 3D Blaster PCI (Verite 1000) +SEE Rendition Verite 1000 + +NAME Canopus Total-3D +SEE Rendition Verite 1000 + +NAME Sierra Screaming 3D +SEE Rendition Verite 1000 + +NAME NeoMagic (laptop/notebook) +CHIPSET NeoMagic 128/V/ZV +SEE Unsupported VGA compatible + +END diff --git a/hw/xfree86/utils/xorgconfig/cards.c b/hw/xfree86/utils/xorgconfig/cards.c new file mode 100644 index 000000000..a714d04ca --- /dev/null +++ b/hw/xfree86/utils/xorgconfig/cards.c @@ -0,0 +1,285 @@ +/* $Xorg: cards.c,v 1.3 2000/08/17 19:53:05 cpqbld Exp $ */ + + + + + +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/cards.c,v 3.11.2.1 1998/01/18 10:35:45 hohndel Exp $ */ + +/* + * Functions to manipulate card database. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "cards.h" + +/* + * Database format: + * + * NAME <name of card> + * CHIPSET <chipset description> + * SERVER <server name> + * + * Optional keywords: + * RAMDAC <ramdac identifier> + * CLOCKCHIP <clockchip identifier> + * DACSPEED <dacspeed> + * NOCLOCKPROBE + * UNSUPPORTED + * + * SEE <name of card> refers to another card definition; parameters that + * are already defined are not overridden. + * + * <server name> is one of Mono, VGA16, SVGA, S3, Mach32, Mach8, 8514, + * P9000, AGX, W32. + * + * A useful additional keywords may be CLOCKS. + */ + + + +/* Database vars. */ + +int lastcard; + +Card card[MAX_CARDS]; + +void sort_database(); + + +static int getline(f, l) +FILE *f; +char *l; +{ + if (fgets(l, 128, f) == NULL) + return -1; +#ifdef __EMX__ + { + char *p = strchr(l,'\r'); + if (p) { + *p = '\n'; + *(p+1) = '\0'; + } + } +#endif + return 0; +} + +static void appendstring(destp, src) + char **destp; + char *src; +{ + char *newstr; + newstr = malloc(strlen(*destp) + strlen(src) + 1); + strcpy(newstr, *destp); + strcat(newstr, src); + if (strlen(*destp) > 0) + free(*destp); + *destp = newstr; +} + +int lookupcard( char *name ) { + int i; + for (i = 0; i <= lastcard; i++) + if (strcmp(name, card[i].name) == 0) + return i; + return -1; +} + +static char *s3_comment = +"# Use Option \"nolinear\" if the server doesn't start up correctly\n" +"# (this avoids the linear framebuffer probe). If that fails try\n" +"# option \"nomemaccess\".\n" +"#\n" +"# Refer to /usr/X11R6/lib/doc/README.S3, and the XF86_S3 man page.\n"; + +static char *cirrus_comment = +"# Use Option \"no_bitblt\" if you have graphics problems. If that fails\n" +"# try Option \"noaccel\".\n" +"# Refer to /usr/X11R6/lib/doc/README.cirrus.\n" +"# To allow linear addressing, uncomment the Option line and the\n" +"# address that the card maps the framebuffer to.\n"; + +int parse_database() { + FILE *f; + char buf[128]; + int i, lineno; + char filename[128]; + +#ifndef __EMX__ + strcpy(filename, CARD_DATABASE_FILE); +#else + strcpy(filename, (char*)__XOS2RedirRoot(CARD_DATABASE_FILE)); +#endif + f = fopen(filename, "r"); + if (f == NULL) + return -1; + + lastcard = -1; + lineno = 0; + + for (;;) { + if (getline(f, buf)) + break; + lineno++; + if (buf[0] == '#') + /* Comment. */ + continue; + if (strncmp(buf, "END", 3) == 0) + /* End of database. */ + break; + if (strncmp(buf, "LINE", 4) == 0 && lastcard>=0) { + /* Line of Device comment. */ + char *lines; + /* Append to existing lines. */ + appendstring(&card[lastcard].lines, buf + 5); + continue; + } + /* + * The following keywords require the trailing newline + * to be deleted. + */ + i = strlen(buf); + buf[--i] = '\0'; + + /* remove trailing spaces or tabs */ + for(--i; i>=0 && (buf[i] == ' ' || buf[i] == '\011'); i--) ; + if (i>=0) + buf[i+1] = '\0'; + else + continue; /* skip empty lines */ + + if (strncmp(buf, "NAME", 4) == 0) { + /* New entry. */ + lastcard++; + card[lastcard].name = malloc(strlen(buf + 5) + 1); + strcpy(card[lastcard].name, buf + 5); + card[lastcard].chipset = NULL; + card[lastcard].ramdac = NULL; + card[lastcard].clockchip = NULL; + card[lastcard].dacspeed = NULL; + card[lastcard].flags = 0; + card[lastcard].lines = ""; + continue; + } + if (lastcard < 0) /* no NAME line found yet */ + continue; + if (strncmp(buf, "SEE", 3) == 0) { + /* Reference to another entry. */ + int i; + i = lookupcard(buf + 4); + if (i == -1) { + printf("Error in database, invalid reference: %s.\n", + buf + 4); + free(card[lastcard].name); + lastcard--; + continue; + } + if (card[lastcard].chipset == NULL) + card[lastcard].chipset = card[i].chipset; + if (card[lastcard].server == NULL) + card[lastcard].server = card[i].server; + if (card[lastcard].ramdac == NULL) + card[lastcard].ramdac = card[i].ramdac; + if (card[lastcard].clockchip == NULL) + card[lastcard].clockchip = card[i].clockchip; + if (card[lastcard].dacspeed == NULL) + card[lastcard].dacspeed = card[i].dacspeed; + card[lastcard].flags |= card[i].flags; + appendstring(&card[lastcard].lines, card[i].lines); + continue; + } + if (strncmp(buf, "CHIPSET", 7) == 0) { + /* Chipset description. */ + card[lastcard].chipset = malloc(strlen(buf + 8) + 1); + strcpy(card[lastcard].chipset, buf + 8); + continue; + } + if (strncmp(buf, "SERVER", 6) == 0) { + /* Server identifier. */ + card[lastcard].server = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].server, buf + 7); + continue; + } + if (strncmp(buf, "RAMDAC", 6) == 0) { + /* Ramdac indentifier. */ + card[lastcard].ramdac = malloc(strlen(buf + 7) + 1); + strcpy(card[lastcard].ramdac, buf + 7); + continue; + } + if (strncmp(buf, "CLOCKCHIP", 9) == 0) { + /* Clockchip indentifier. */ + card[lastcard].clockchip = malloc(strlen(buf + 10) + 1); + strcpy(card[lastcard].clockchip, buf + 10); + card[lastcard].flags |= NOCLOCKPROBE; + continue; + } + if (strncmp(buf, "DACSPEED", 8) == 0) { + /* Clockchip indentifier. */ + card[lastcard].dacspeed = malloc(strlen(buf + 9) + 1); + strcpy(card[lastcard].dacspeed, buf + 9); + continue; + } + if (strncmp(buf, "NOCLOCKPROBE", 12) == 0) { + card[lastcard].flags |= NOCLOCKPROBE; + continue; + } + if (strncmp(buf, "UNSUPPORTED", 12) == 0) { + card[lastcard].flags |= UNSUPPORTED; + continue; + } + /* test for missing required fields */ + if (card[lastcard].server == NULL) { + fprintf(stderr, "Warning SERVER specification missing " + "in Card database entry %s (line %d).\n", + card[lastcard].name, lineno); + keypress(); + card[lastcard].server = "unknown"; + } + if (card[lastcard].chipset == NULL) { + fprintf(stderr, "Warning CHIPSET specification missing " + "in Card database entry %s (line %d).\n", + card[lastcard].name, lineno); + keypress(); + card[lastcard].chipset = "unknown"; + } + } + + fclose(f); + + /* + * Add general comments. + */ + for (i = 0; i <= lastcard; i++) { + if (card[i].server && strcmp(card[i].server, "S3") == 0) + appendstring(&card[i].lines, s3_comment); + if (card[i].chipset && + strncmp(card[i].chipset, "CL-GD", 5) == 0) + appendstring(&card[i].lines, cirrus_comment); + } + + sort_database(); + + return 0; +} + +#ifdef __STDC__ +#define CONST const +#else +#define CONST +#endif + +static int compare_card(e1, e2) + CONST void *e1; + CONST void *e2; +{ + return strcmp(((Card *)e1)->name, ((Card *)e2)->name); +} + +void sort_database() { + /* Each element is a bunch of words, but nothing too bad. */ + qsort(card, lastcard + 1, sizeof(Card), compare_card); +} diff --git a/hw/xfree86/utils/xorgconfig/cards.h b/hw/xfree86/utils/xorgconfig/cards.h new file mode 100644 index 000000000..11976d978 --- /dev/null +++ b/hw/xfree86/utils/xorgconfig/cards.h @@ -0,0 +1,36 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/cards.h,v 3.3 1996/12/23 07:04:44 dawes Exp $ */ + + + + + +/* $Xorg: cards.h,v 1.3 2000/08/17 19:53:05 cpqbld Exp $ */ + +#ifndef CARD_DATABASE_FILE +#define CARD_DATABASE_FILE "Cards" +#endif + +#define MAX_CARDS 1000 + +typedef struct { + char *name; /* Name of the card. */ + char *chipset; /* Chipset (decriptive). */ + char *server; /* Server identifier. */ + char *ramdac; /* Ramdac identifier. */ + char *clockchip; /* Clockchip identifier. */ + char *dacspeed; /* DAC speed rating. */ + int flags; + char *lines; /* Additional Device section lines. */ +} Card; + +/* Flags: */ +#define NOCLOCKPROBE 0x1 /* Never probe clocks of the card. */ +#define UNSUPPORTED 0x2 /* Card is not supported (only VGA). */ + +extern int lastcard; + +extern Card card[MAX_CARDS]; + + +int parse_database(); + |