Index: configure.ac =================================================================== RCS file: /cvs/xserver/xserver/configure.ac,v retrieving revision 3.50 diff -u -r3.50 configure.ac --- configure.ac 13 Jan 2004 03:53:21 -0000 3.50 +++ configure.ac 16 Jan 2004 01:16:51 -0000 @@ -76,6 +76,9 @@ # tslib touchscreen driver AC_CHECK_HEADERS([tslib.h]) +# linux keyboard driver +AC_CHECK_HEADERS([sys/kbio.h]) + REQUIRED_MODULES="randr render fixesext damageext xextensions xfont xproto xtrans xau" DEFAULT_FONT_PATH="/usr/lib/X11/fonts/misc,/usr/lib/X11/fonts/100dpi,/usr/lib/X11/fonts/75dpi" Index: hw/kdrive/ati/ati.h =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati.h,v retrieving revision 1.6 diff -u -r1.6 ati.h --- hw/kdrive/ati/ati.h 9 Jan 2004 08:43:48 -0000 1.6 +++ hw/kdrive/ati/ati.h 16 Jan 2004 01:16:53 -0000 @@ -28,6 +28,9 @@ #include "config.h" +#include +#include + #ifdef KDRIVEFBDEV #include #endif Index: hw/kdrive/linux/agp.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/linux/agp.c,v retrieving revision 1.7 diff -u -r1.7 agp.c --- hw/kdrive/linux/agp.c 2 Nov 2003 19:56:10 -0000 1.7 +++ hw/kdrive/linux/agp.c 16 Jan 2004 01:16:57 -0000 @@ -69,6 +69,13 @@ #include #endif +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + #ifndef AGP_DEVICE #define AGP_DEVICE "/dev/agpgart" #endif Index: hw/kdrive/linux/keyboard.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/linux/keyboard.c,v retrieving revision 1.16 diff -u -r1.16 keyboard.c --- hw/kdrive/linux/keyboard.c 13 Nov 2003 09:14:29 -0000 1.16 +++ hw/kdrive/linux/keyboard.c 16 Jan 2004 01:17:00 -0000 @@ -27,8 +27,13 @@ #endif #include "kdrive.h" #include "kkeymap.h" +#ifdef linux #include #include +#endif +#ifdef HAVE_SYS_KBIO_H +#include +#endif #define XK_PUBLISHING #include #include @@ -105,15 +110,18 @@ static unsigned char tbl[KD_MAX_WIDTH] = { +#ifdef linux 0, 1 << KG_SHIFT, (1 << KG_ALTGR), (1 << KG_ALTGR) | (1 << KG_SHIFT) +#endif }; static void readKernelMapping(void) { +#ifdef linux KeySym *k; int i, j; struct kbentry kbe; @@ -372,6 +380,7 @@ } kdMinScanCode = minKeyCode; kdMaxScanCode = maxKeyCode; +#endif } static void @@ -404,13 +413,16 @@ static int LinuxKeyboardEnable (int fd, void *closure) { +#ifdef linux struct termios nTty; unsigned char buf[256]; int n; ioctl (fd, KDGKBMODE, &LinuxKbdTrans); tcgetattr (fd, &LinuxTermios); - + + /* Does K_MEDIUMRAW make the keyboard return keycodes? + If it does then use K_CODE on BSD */ ioctl(fd, KDSKBMODE, K_MEDIUMRAW); nTty = LinuxTermios; nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); @@ -428,6 +440,9 @@ while ((n = read (fd, buf, sizeof (buf))) > 0) ; return fd; +#else + return 0; +#endif } static void Index: hw/kdrive/linux/linux.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/linux/linux.c,v retrieving revision 1.17 diff -u -r1.17 linux.c --- hw/kdrive/linux/linux.c 19 Nov 2003 08:32:36 -0000 1.17 +++ hw/kdrive/linux/linux.c 16 Jan 2004 01:17:04 -0000 @@ -29,12 +29,26 @@ #include "klinux.h" #include #include +#ifdef linux #include #include +#endif #include #include #include +#ifdef linux #include +#endif +#ifdef __FreeBSD__ +#include +#include +#endif + +#ifdef linux +#define TTY_DEVICE "/dev/tty0" +#else +#define TTY_DEVICE "/dev/ttyv0" +#endif static int vtno; int LinuxConsoleFd; @@ -69,7 +83,11 @@ { int fd = -1; char vtname[11]; +#ifdef linux struct vt_stat vts; +#else + int vts; +#endif LinuxConsoleFd = -1; /* check if we're run with euid==0 */ @@ -82,11 +100,11 @@ vtno = kdVirtualTerminal; else { - if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) + if ((fd = open(TTY_DEVICE,O_WRONLY,0)) < 0) { FatalError( - "LinuxInit: Cannot open /dev/tty0 (%s)\n", - strerror(errno)); + "LinuxInit: Cannot open %s (%s)\n", + TTY_DEVICE, strerror(errno)); } if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || (vtno == -1)) @@ -96,7 +114,11 @@ } close(fd); +#ifdef linux sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */ +#else + sprintf(vtname,"/dev/ttyv%d",vtno); /* /dev/ttyv1-64 */ +#endif if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0) { @@ -113,20 +135,29 @@ * * Why is this needed? */ - LinuxCheckChown ("/dev/tty0"); + LinuxCheckChown (TTY_DEVICE); /* * 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. */ +#ifdef linux memset (&vts, '\0', sizeof (vts)); /* valgrind */ if (ioctl(LinuxConsoleFd, VT_GETSTATE, &vts) == 0) { activeVT = vts.v_active; } +#endif +#ifdef __FreeBSD__ + if (ioctl(LinuxConsoleFd, VT_GETACTIVE, &vts) == 0) + { + activeVT = vts; + } +#endif return 1; } +/* This will most likely be broken on FreeBSD */ Bool LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr) { @@ -280,6 +311,7 @@ static void LinuxApmWakeup (pointer blockData, int result, pointer pReadmask) { +#ifdef linux fd_set *readmask = (fd_set *) pReadmask; if (result > 0 && LinuxApmFd >= 0 && FD_ISSET (LinuxApmFd, readmask)) @@ -321,6 +353,7 @@ ioctl (LinuxApmFd, cmd, 0); } } +#endif } #ifdef FNONBLOCK @@ -342,9 +375,13 @@ /* * Open the APM driver */ +#ifdef linux LinuxApmFd = open ("/dev/apm_bios", 2); if (LinuxApmFd < 0 && errno == ENOENT) LinuxApmFd = open ("/dev/misc/apm_bios", 2); +#else + LinuxApmFd = open ("/dev/apm", 2); +#endif if (LinuxApmFd >= 0) { LinuxApmRunning = TRUE; @@ -376,15 +413,24 @@ static Bool LinuxSpecialKey (KeySym sym) { +#ifdef linux struct vt_stat vts; +#else + int vts; +#endif int con; if (XK_F1 <= sym && sym <= XK_F12) { con = sym - XK_F1 + 1; +#ifdef linux memset (&vts, '\0', sizeof (vts)); /* valgrind */ ioctl (LinuxConsoleFd, VT_GETSTATE, &vts); if (con != vts.v_active && (vts.v_state & (1 << con))) +#else + ioctl (LinuxConsoleFd, VT_GETACTIVE, &vts); + if (con != vts) +#endif { ioctl (LinuxConsoleFd, VT_ACTIVATE, con); return TRUE; @@ -416,7 +462,11 @@ LinuxFini (void) { struct vt_mode VT; +#ifdef linux struct vt_stat vts; +#else + int vts; +#endif int fd; if (LinuxConsoleFd < 0) @@ -427,19 +477,32 @@ VT.mode = VT_AUTO; ioctl(LinuxConsoleFd, VT_SETMODE, &VT); /* set dflt vt handling */ } +#ifdef linux memset (&vts, '\0', sizeof (vts)); /* valgrind */ ioctl (LinuxConsoleFd, VT_GETSTATE, &vts); +#else + ioctl (LinuxConsoleFd, VT_GETACTIVE, &vts); +#endif /* * Find a legal VT to switch to, either the one we started from * or the lowest active one that isn't ours */ if (activeVT < 0 || +#ifdef linux activeVT == vts.v_active || !(vts.v_state & (1 << activeVT))) +#else + activeVT == vts) +#endif { for (activeVT = 1; activeVT < 16; activeVT++) +#ifdef linux if (activeVT != vtno && (vts.v_state & (1 << activeVT))) break; +#else + if (activeVT != vtno) + break; +#endif if (activeVT == 16) activeVT = -1; } @@ -453,13 +516,17 @@ activeVT = -1; } close(LinuxConsoleFd); /* make the vt-manager happy */ - fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0); + fd = open (TTY_DEVICE, O_RDWR|O_NDELAY, 0); if (fd >= 0) { +#ifdef linux memset (&vts, '\0', sizeof (vts)); /* valgrind */ ioctl (fd, VT_GETSTATE, &vts); if (ioctl (fd, VT_DISALLOCATE, vtno) < 0) fprintf (stderr, "Can't deallocate console %d errno %d\n", vtno, errno); +#else + ioctl (fd, VT_GETACTIVE, &vts); +#endif close (fd); } return; Index: hw/kdrive/src/vga.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/src/vga.c,v retrieving revision 1.9 diff -u -r1.9 vga.c --- hw/kdrive/src/vga.c 1 Dec 2003 01:46:42 -0000 1.9 +++ hw/kdrive/src/vga.c 16 Jan 2004 01:17:08 -0000 @@ -58,6 +58,38 @@ #endif +#ifdef __FreeBSD__ +#include +#include +#if _MACHINE == i386 + +#define _VgaInb(r) inb(r) +#define _VgaOutb(v,r) outb(v,r) +#else +#define _VgaInb(r) 0 +#define _VgaOutb(v,r) +#endif + +#define _VgaByteAddr(a) ((VGAVOL8 *) (a)) +#define _VgaBytePort(a) (a) +#endif + +#ifdef __FreeBSD__ +#include +#include +#if _MACHINE == i386 + +#define _VgaInb(r) inb(r) +#define _VgaOutb(v,r) outb(v,r) +#else +#define _VgaInb(r) 0 +#define _VgaOutb(v,r) +#endif + +#define _VgaByteAddr(a) ((VGAVOL8 *) (a)) +#define _VgaBytePort(a) (a) +#endif + #undef VGA_DEBUG_REGISTERS #ifdef VGA_DEBUG_REGISTERS #define VGA_DEBUG(a) fprintf a