diff options
Diffstat (limited to 'hw/xfree86/os-support/solaris')
-rw-r--r-- | hw/xfree86/os-support/solaris/apSolaris.shar | 768 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_bios.c | 100 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_init.c | 375 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_inout.s | 124 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_io.c | 64 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_kbd.c | 112 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_kbdEv.c | 672 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_mouse.c | 322 | ||||
-rw-r--r-- | hw/xfree86/os-support/solaris/sun_vid.c | 229 |
9 files changed, 2766 insertions, 0 deletions
diff --git a/hw/xfree86/os-support/solaris/apSolaris.shar b/hw/xfree86/os-support/solaris/apSolaris.shar new file mode 100644 index 000000000..33cecdc4d --- /dev/null +++ b/hw/xfree86/os-support/solaris/apSolaris.shar @@ -0,0 +1,768 @@ +#!/bin/sh +# $XFree86: xc/programs/Xserver/hw/xfree86/etc/apSolaris.shar,v 1.3 2002/10/04 19:45:33 tsi Exp $ +# This is a shell archive (produced by GNU sharutils 4.2c). +# To extract the files from this archive, save it to some FILE, remove +# everything before the `!/bin/sh' line above, then type `sh FILE'. +# +# Made on 2002-10-04 13:41 MDT by <root@abcyxhiz>. +# Source directory was `/archives'. +# +# Existing files will *not* be overwritten unless `-c' is specified. +# This format requires very little intelligence at unshar time. +# "if test", "echo", "mkdir", and "sed" may be needed. +# +# This shar contains: +# length mode name +# ------ ---------- ------------------------------------------ +# 1521 -rw-r--r-- aperture/Makefile +# 1659 -rw-r--r-- aperture/README +# 7557 -rw-r--r-- aperture/aperture.c +# 450 -rw-r--r-- aperture/aperture.conf +# 87 -rw-r--r-- aperture/devlink.tab +# 1062 -rw-r--r-- aperture/Makefile.sun4u +# +echo=echo +shar_tty= shar_n= shar_c=' +' +mkdir _sh09806 || ( echo 'failed to create locking directory' '_sh09806'; exit 1 ) +# ============= aperture/Makefile ============== +if test ! -d 'aperture'; then + $echo $echo_n 'x -' 'aperture: '$echo_c + if mkdir 'aperture'; then $echo 'created'; else $echo 'failed to create'; fi +fi +if test -f 'aperture/Makefile' && test "$first_param" != -c; then + $echo 'x -' SKIPPING 'aperture/Makefile' '(file already exists)' +else + $echo 'x -' extracting 'aperture/Makefile' '(text)' + sed 's/^X//' << 'SHAR_EOF' > 'aperture/Makefile' && +X# +X# File: makefile for aperture Framebuffer Driver +X# Author: Doug Anson (danson@lgc.com) +X# Date: 2/15/94 +X# Modified: David Holland (davidh@use.com) +X# Date: 2/23/94 +X# - Changed name, and debugging structure +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Date: 2001.06.08 +X# - SPARC support, cleanup and turf aptest. +X# +X# >>NOTE<< Have a look at Makefile.sun4u for sun4u specifics. +X# +X# GNU gcc compiler +XCC=gcc +XCFLGS=-fno-builtin -Wall -O3 +X +X# +X# Proworks compiler +X#CC=/opt/SUNWspro/bin/cc +X#CFLGS=-Xa -xnolib -xO3 +X +X# +X# Debug error reporting +X#DEBUG_FLG= +X#DEBUG_FLG=-DAPERTURE_DEBUG +X +X# +X# Files and object declarations +XKERNEL_FLGS=-D_KERNEL -DSUNDDI +XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) +XCFILES= aperture.c +XOBJS= aperture.o +XDRIVER= aperture +X +X# +X# Make rules +Xall: $(DRIVER) +X +X$(DRIVER): $(OBJS) +X @if [ -f "Makefile.`uname -m`" ]; then \ +X make -f Makefile.`uname -m` $(DRIVER); \ +X else \ +X rm -f $(DRIVER); \ +X ld -r -o $(DRIVER) $(OBJS); \ +X fi +X +Xinstall: $(DRIVER) +X @if [ -f "Makefile.`uname -m`" ]; then \ +X make -f Makefile.`uname -m` install; \ +X else \ +X cp aperture.conf /kernel/drv; \ +X cp $(DRIVER) /kernel/drv; \ +X fi +X +Xadd_drv: +X @if [ -f "Makefile.`uname -m`" ]; then \ +X make -f Makefile.`uname -m` add_drv; \ +X else \ +X add_drv /kernel/drv/aperture; \ +X fi +X +Xclean: +X rm -f *% *.BAK $(OBJS) $(DRIVER) core +X +X.SUFFIXES: .i +X +X.c.i: +X $(CC) -E $(CFLAGS) $*.c > $@ +X +X.c.o: +X @if [ -f "Makefile.`uname -m`" ]; then \ +X make -f Makefile.`uname -m` $@; \ +X else \ +X rm -f $@; \ +X $(CC) -c $(CFLAGS) $*.c -o $@; \ +X fi +SHAR_EOF + : || $echo 'restore of' 'aperture/Makefile' 'failed' +fi +# ============= aperture/README ============== +if test -f 'aperture/README' && test "$first_param" != -c; then + $echo 'x -' SKIPPING 'aperture/README' '(file already exists)' +else + $echo 'x -' extracting 'aperture/README' '(text)' + sed 's/^X//' << 'SHAR_EOF' > 'aperture/README' && +XFramebuffer apperture driver. +X +XThis driver was written to provide a device that, unlike /dev/mem, allows +Xmmap()'ing of ranges beyond installed memory. +X +XThe original x86-based version of this driver was the corroborative work of +XDoug Anson (danson@lgc.com), and David Holland (davidh@use.com). It has since +Xbeen rewritten to also work on sun4u machines. +X +X +XInstallation instructions: +X +X1) Check the Makefile, for appropriate CC, and CFLAGS definitions. Compiling +X with APERTURE_DEBUG defined means the driver will generate reams of +X debugging output. You'll probably want to leave this off... +X +X2) type 'make'. The driver and test program should compile with out any +X problems. There also should not be any warning messages. +X +X3) Become 'root'. +X +X4) type 'make install' and 'make add_drv'. The screen should look something +X like this: +X +X # make install +X cp aperture aperture.conf /kernel/drv +X # make add_drv +X add_drv /kernel/drv/aperture +X +X On a sun4u machine this will mention the /kernel/drv/sparcv9 directory +X instead of /kernel/drv. +X +X This installs the driver in the system. +X +X5) While as root modify the file /etc/devlink.tab, adding these lines: +X +X# The following entry is for the framebuffer driver +Xtype=ddi_pseudo;name=aperture fbs/\M0 +X +X Add that line exactly as shown. You may also simply add the +X contents of the devlink.tab file supplied to /etc/devlink.tab. +X It contains the lines as well. (Yes, that is a tab between +X aperture, and fbs, not spaces - very important) +X +X6) Perform a reconfiguration boot of the system. +X +X # touch /reconfigure +X # init 6 +X +XBug reports, questions, suggestions, etc can be sent to xfree86@xfree86.org. +SHAR_EOF + : || $echo 'restore of' 'aperture/README' 'failed' +fi +# ============= aperture/aperture.c ============== +if test -f 'aperture/aperture.c' && test "$first_param" != -c; then + $echo 'x -' SKIPPING 'aperture/aperture.c' '(file already exists)' +else + $echo 'x -' extracting 'aperture/aperture.c' '(text)' + sed 's/^X//' << 'SHAR_EOF' > 'aperture/aperture.c' && +X/* +X * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. +X * +X * Permission is hereby granted, free of charge, to any person obtaining a copy +X * of this software and associated documentation files (the "Software"), to +X * deal in the Software without restriction, including without limitation the +X * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +X * sell copies of the Software, and to permit persons to whom the Software is +X * furnished to do so, subject to the following conditions: +X * +X * The above copyright notice and this permission notice shall be included in +X * all copies or substantial portions of the Software. +X * +X * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +X * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +X * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +X * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +X * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +X * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +X * +X * Except as contained in this notice, the name of the XFree86 Project shall +X * not be used in advertising or otherwise to promote the sale, use or other +X * dealings in this Software without prior written authorization from the +X * XFree86 Project. +X */ +X +X/* +X * Aperture driver for Solaris. +X */ +X +X#include <sys/conf.h> +X#include <sys/ddi.h> +X#include <sys/modctl.h> +X#include <sys/open.h> +X#include <sys/stat.h> +X#include <sys/sunddi.h> +X +X#define DEV_IDENT "aperture" +X#define DEV_BANNER "XFree86 aperture driver" +X +X#ifndef D_64BIT +X#define D_64BIT 0 +X#endif +X +X#ifndef NULL +X#define NULL ((void *)0) +X#endif +X +X/* +X * open(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_open +X( +X#ifdef __STDC__ +X dev_t *devp, +X int flag, +X int typ, +X struct cred *cred +X#endif +X) +X#ifndef __STDC__ +X dev_t *devp; +X int flag; +X int typ; +X struct cred *cred; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering open()\n"); +X +X#endif +X +X if ((typ != OTYP_CHR) || (getminor(*devp))) +X error = EINVAL; +X else +X error = 0; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving open() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * mmap(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_mmap +X( +X#ifdef __STDC__ +X dev_t dev, +X off_t off, +X int prot +X#endif +X) +X#ifndef __STDC__ +X dev_t dev; +X off_t off; +X int prot; +X#endif +X{ +X pfn_t pf; +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering mmap(0x%016lx)\n", off); +X +X#endif +X +X pf = btop((unsigned long)off); +X +X /* Deal with mmap(9E) interface limits */ +X error = (int)pf; +X if ((error < 0) || (pf != (pfn_t)error)) +X error = -1; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving mmap() = 0x%08lx", error); +X +X#endif +X +X return error; +X} +X +Xstatic struct cb_ops aperture_cb_ops = +X{ +X aperture_open, /* open */ +X nulldev, /* close */ +X nodev, /* strategy */ +X nodev, /* print */ +X nodev, /* dump */ +X nodev, /* read */ +X nodev, /* write */ +X nodev, /* ioctl */ +X nodev, /* devmap */ +X aperture_mmap, /* mmap */ +X ddi_segmap, /* segmap */ +X nochpoll, /* poll */ +X ddi_prop_op, /* cb_prop_op */ +X 0, /* streamtab */ +X D_NEW | D_MP | D_64BIT /* Driver compatibility flag */ +X}; +X +X +Xstatic dev_info_t *aperture_dip; /* private copy of devinfo pointer */ +X +X/* +X * getinfo(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_getinfo +X( +X#ifdef __STDC__ +X dev_info_t *dip, +X ddi_info_cmd_t infocmd, +X void *arg, +X void **result +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X ddi_info_cmd_t infocmd; +X void *arg; +X void **result; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering getinfo()\n"); +X +X#endif +X +X switch (infocmd) { +X case DDI_INFO_DEVT2DEVINFO: +X *result = aperture_dip; +X error = DDI_SUCCESS; +X break; +X case DDI_INFO_DEVT2INSTANCE: +X *result = NULL; +X error = DDI_SUCCESS; +X break; +X default: +X error = DDI_FAILURE; +X } +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving getinfo() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * identify(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_identify +X( +X#ifdef __STDC__ +X dev_info_t *dip +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering identify()\n"); +X +X#endif +X +X if (strcmp(ddi_get_name(dip), DEV_IDENT)) +X error = DDI_NOT_IDENTIFIED; +X else +X error = DDI_IDENTIFIED; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving identify() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * attach(9E) +X */ +X/*ARGSUSED*/ +Xstatic int +Xaperture_attach +X( +X#ifdef __STDC__ +X dev_info_t *dip, +X ddi_attach_cmd_t cmd +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X ddi_attach_cmd_t cmd; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering attach()\n"); +X +X#endif +X +X if (cmd != DDI_ATTACH) +X { +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": not attach(, DDI_ATTACH)\n"); +X +X#endif +X +X error = DDI_FAILURE; +X } +X else +X { +X error = ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR, +X (minor_t)ddi_get_instance(dip), +X NULL, NODESPECIFIC_DEV); +X +X if (error == DDI_SUCCESS) +X { +X aperture_dip = dip; +X ddi_report_dev(dip); +X } +X } +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving attach() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * detach(9E) +X */ +Xstatic int +Xaperture_detach +X( +X#ifdef __STDC__ +X dev_info_t *dip, +X ddi_detach_cmd_t cmd +X#endif +X) +X#ifndef __STDC__ +X dev_info_t *dip; +X ddi_detach_cmd_t cmd; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering detach()\n"); +X +X#endif +X +X if (cmd != DDI_DETACH) +X { +X error = DDI_FAILURE; +X } +X else +X { +X ddi_remove_minor_node(dip, NULL); +X aperture_dip = NULL; +X error = DDI_SUCCESS; +X } +X +X#if APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving detach() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X +Xstatic struct dev_ops aperture_ops = +X{ +X DEVO_REV, /* revision */ +X 0, /* refcnt */ +X aperture_getinfo, /* getinfo */ +X aperture_identify, /* identify */ +X nulldev, /* probe */ +X aperture_attach, /* attach */ +X aperture_detach, /* detach */ +X nodev, /* reset */ +X &aperture_cb_ops, /* driver operations */ +X NULL /* bus operations */ +X}; +X +X +Xstatic struct modldrv modldrv = +X{ +X &mod_driverops, /* mod_ops structure pointer */ +X DEV_BANNER, /* driver banner string */ +X &aperture_ops, /* dev_ops structure pointer */ +X}; +X +X +Xstatic struct modlinkage modlinkage = +X{ +X MODREV_1, /* module API revision */ +X { +X &modldrv, /* module driver structure pointer */ +X NULL /* list termination */ +X } +X}; +X +X +X/* +X * _init(9E) +X */ +Xint +X_init +X( +X#ifdef __STDC__ +X void +X#endif +X) +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering _init()\n"); +X +X#endif +X +X error = mod_install(&modlinkage); +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving _init() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * _info(9E) +X */ +Xint +X_info +X( +X#ifdef __STDC__ +X struct modinfo *modinfop +X#endif +X) +X#ifndef __STDC__ +X struct modinfo *modinfop; +X#endif +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering _info()\n"); +X +X#endif +X +X error = mod_info(&modlinkage, modinfop); +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving _info() = %d\n", error); +X +X#endif +X +X return error; +X} +X +X/* +X * _fini(9E) +X */ +Xint +X_fini +X( +X#ifdef __STDC__ +X void +X#endif +X) +X{ +X int error; +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": entering _fini()\n"); +X +X#endif +X +X error = mod_remove(&modlinkage); +X +X#ifdef APERTURE_DEBUG +X +X cmn_err(CE_CONT, DEV_IDENT ": leaving _fini() = %d\n", error); +X +X#endif +X +X return error; +X} +SHAR_EOF + : || $echo 'restore of' 'aperture/aperture.c' 'failed' +fi +# ============= aperture/aperture.conf ============== +if test -f 'aperture/aperture.conf' && test "$first_param" != -c; then + $echo 'x -' SKIPPING 'aperture/aperture.conf' '(file already exists)' +else + $echo 'x -' extracting 'aperture/aperture.conf' '(text)' + sed 's/^X//' << 'SHAR_EOF' > 'aperture/aperture.conf' && +X# +X# Copyright 1994 Doug Anson, danson@lgc.com & David Holland, davidh@use.com +X# +X# File: aperture.conf +X# Author: Doug Anson (danson@lgc.com) +X# +X# Modified: David Holland (davidh@use.com) +X# Log: Change comments 02/23/94 +X# Change defaults/comments 09/25/94 +X# +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Log: SPARC changes 2001.09 +X# +X# Purpose: This conf file is used by the aperture driver. +X# +Xname="aperture" parent="pseudo"; +SHAR_EOF + : || $echo 'restore of' 'aperture/aperture.conf' 'failed' +fi +# ============= aperture/devlink.tab ============== +if test -f 'aperture/devlink.tab' && test "$first_param" != -c; then + $echo 'x -' SKIPPING 'aperture/devlink.tab' '(file already exists)' +else + $echo 'x -' extracting 'aperture/devlink.tab' '(text)' + sed 's/^X//' << 'SHAR_EOF' > 'aperture/devlink.tab' && +X# The following entry is for the aperture driver +Xtype=ddi_pseudo;name=aperture fbs/\M0 +SHAR_EOF + : || $echo 'restore of' 'aperture/devlink.tab' 'failed' +fi +# ============= aperture/Makefile.sun4u ============== +if test -f 'aperture/Makefile.sun4u' && test "$first_param" != -c; then + $echo 'x -' SKIPPING 'aperture/Makefile.sun4u' '(file already exists)' +else + $echo 'x -' extracting 'aperture/Makefile.sun4u' '(text)' + sed 's/^X//' << 'SHAR_EOF' > 'aperture/Makefile.sun4u' && +X# +X# File: makefile for aperture Framebuffer Driver +X# Author: Doug Anson (danson@lgc.com) +X# Date: 2/15/94 +X# Modified: David Holland (davidh@use.com) +X# Date: 2/23/94 +X# - Changed name, and debugging structure +X# Modified: Marc Aurele La France (tsi@xfree86.org) +X# Date: 2001.06.08 +X# - SPARC support, cleanup and turf aptest. +X# +X +X# +X# GNU gcc compiler, version 3.2 or later +X# +XCC=gcc +XCFLGS=-fno-builtin -Wall -O3 -m64 +X +X# +X# Proworks compiler +X#CC=/opt/SUNWspro/bin/cc +X#CFLGS=-Xa -xarch=v9 -xnolib -xO3 +X +X# +X# Debug error reporting +X#DEBUG_FLG= +X#DEBUG_FLG=-DAPERTURE_DEBUG +X +X# +X# Files and object declarations +XKERNEL_FLGS=-D_KERNEL -DSUNDDI +XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG) +XCFILES= aperture.c +XOBJS= aperture.o +XDRIVER= aperture +X +X# +X# Make rules +Xall: $(DRIVER) +X +X$(DRIVER): $(OBJS) +X rm -f $(DRIVER) +X ld -r -o $(DRIVER) $(OBJS) +X +Xinstall: $(DRIVER) +X cp aperture.conf /kernel/drv +X cp $(DRIVER) /kernel/drv/sparcv9 +X +Xadd_drv: +X add_drv /kernel/drv/sparcv9/aperture +X +Xclean: +X rm -f *% *.BAK $(OBJS) $(DRIVER) core +X +X.SUFFIXES: .i +X +X.c.i: +X $(CC) -E $(CFLAGS) $*.c > $@ +SHAR_EOF + : || $echo 'restore of' 'aperture/Makefile.sun4u' 'failed' +fi +$echo $shar_n 'x -' 'lock directory' "\`_sh09806': " $shar_c +if rm -fr _sh09806; then + $echo 'removed' +else + $echo 'failed to remove' +fi +exit 0 diff --git a/hw/xfree86/os-support/solaris/sun_bios.c b/hw/xfree86/os-support/solaris/sun_bios.c new file mode 100644 index 000000000..d1c79888b --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_bios.c @@ -0,0 +1,100 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c,v 1.2 2001/10/28 03:34:02 tsi Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1999 by David Holland <davidh@iquest.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the names of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef i386 +#define _NEED_SYSI86 +#endif +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +extern char *apertureDevName; + +/* + * Read BIOS via mmap()ing physical memory. + */ +int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int fd; + unsigned char *ptr; + char solx86_vtname[20]; + int psize; + int mlen; + + /* + * Solaris 2.1 x86 SVR4 (10/27/93) + * The server must treat the virtual terminal device file + * as the standard SVR4 /dev/pmem. By default, then used VT + * is considered the "default" file to open. + * + * Solaris 2.8 x86 (7/26/99) - DWH + * + * Use /dev/xsvc for everything. + */ + psize = xf86getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); +#if defined(i386) && !defined(__SOL8__) + if (Base >= 0xA0000 && Base + mlen < 0xFFFFF && xf86Info.vtno >= 0) + sprintf(solx86_vtname, "/dev/vt%02d", xf86Info.vtno); + else +#endif + { + if (!xf86LinearVidMem()) + FatalError("xf86ReadBIOS: Could not mmap BIOS" + " [a=%x]\n", Base); + sprintf(solx86_vtname, apertureDevName); + } + + if ((fd = open(solx86_vtname, O_RDONLY)) < 0) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n", + solx86_vtname, strerror(errno)); + return(-1); + } + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, fd, (off_t)Base); + if (ptr == MAP_FAILED) + { + xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed " + "[0x%05x, 0x%04x]\n", + solx86_vtname, Base, mlen); + close(fd); + return -1; + } + + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); + (void)close(fd); + + return Len; +} diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c new file mode 100644 index 000000000..b08529a00 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_init.c @@ -0,0 +1,375 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.6 2002/06/06 13:49:34 dawes Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * Copyright 1999 by David Holland <davidh@iquest.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the names of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static Bool KeepTty = FALSE; +static Bool Protect0 = FALSE; +#ifdef HAS_USL_VTS +static int VTnum = -1; +static int xf86StartVT = -1; +#endif + +static char fb_dev[PATH_MAX] = "/dev/console"; + +void +xf86OpenConsole(void) +{ +#ifdef HAS_USL_VTS + int fd, i; + struct vt_mode VT; + struct vt_stat vtinfo; + int FreeVTslot; + MessageType from = X_PROBED; +#endif + + if (serverGeneration == 1) + { + /* Check if we're run with euid==0 */ + if (geteuid() != 0) + FatalError("xf86OpenConsole: Server must be suid root\n"); + + /* Protect page 0 to help find NULL dereferencing */ + /* mprotect() doesn't seem to work */ + if (Protect0) + { + int fd = -1; + + if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: cannot open /dev/zero (%s)\n", + strerror(errno)); + } + else + { + if ((int)mmap(0, 0x1000, PROT_NONE, + MAP_FIXED | MAP_SHARED, fd, 0) == -1) + xf86Msg(X_WARNING, + "xf86OpenConsole: failed to protect page 0 (%s)\n", + strerror(errno)); + + close(fd); + } + } + +#ifdef HAS_USL_VTS + + /* + * Setup the virtual terminal manager + */ + if (VTnum != -1) + { + xf86Info.vtno = VTnum; + from = X_CMDLINE; + } + else + { + if ((fd = open("/dev/vt00",O_RDWR,0)) < 0) + FatalError("xf86OpenConsole: Cannot open /dev/vt00 (%s)\n", + strerror(errno)); + + if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0) + FatalError("xf86OpenConsole: Cannot determine current VT\n"); + + xf86StartVT = vtinfo.v_active; + + /* + * There is a SEVERE problem with x86's VT's. The VT_OPENQRY + * ioctl() will panic the entire system if all 8 (7 VT's+Console) + * terminals are used. The only other way I've found to determine + * if there is a free VT is to try activating all the the available + * VT's and see if they all succeed - if they do, there there is no + * free VT, and the Xserver cannot continue without panic'ing the + * system. (It's ugly, but it seems to work.) Note there is a + * possible race condition here. + * + * David Holland 2/23/94 + */ + + FreeVTslot = 0; + for (i = 7; (i >= 0) && !FreeVTslot; i--) + if (ioctl(fd, VT_ACTIVATE, i) != 0) + FreeVTslot = 1; + + if (!FreeVTslot || + (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) || + (xf86Info.vtno == -1)) + FatalError("xf86OpenConsole: Cannot find a free VT\n"); + + close(fd); + } + + xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); + + sprintf(fb_dev, "/dev/vt%02d", xf86Info.vtno); /* Solaris 2.1 x86 */ + +#endif /* HAS_USL_VTS */ + + if (!KeepTty) + setpgrp(); + + if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0)) + FatalError("xf86OpenConsole: Cannot open %s (%s)\n", + fb_dev, strerror(errno)); + +#ifdef HAS_USL_VTS + + /* Change ownership of the vt */ + chown(fb_dev, getuid(), getgid()); + + /* + * Now get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) + FatalError("xf86OpenConsole: VT_GETMODE failed\n"); + + signal(SIGUSR1, xf86VTRequest); + + VT.mode = VT_PROCESS; + VT.relsig = SIGUSR1; + VT.acqsig = SIGUSR1; + + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n"); + + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n"); + } + else /* serverGeneration != 1 */ + { + /* + * Now re-get the VT + */ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0) + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + + /* + * If the server doesn't have the VT when the reset occurs, + * this is to make sure we don't continue until the activate + * signal is received. + */ + if (!xf86Screens[0]->vtSema) + sleep(5); + +#endif /* HAS_USL_VTS */ + + } +} + +void +xf86CloseConsole(void) +{ +#ifdef HAS_USL_VTS + struct vt_mode VT; +#endif +#if defined(__SOL8__) || !defined(i386) + int tmp; +#endif + +#ifndef i386 + + if (!xf86DoProbe && !xf86DoConfigure) { + int fd; + + /* + * Wipe out framebuffer just like the non-SI Xsun server does. This + * could be improved by saving framebuffer contents in + * xf86OpenConsole() above and restoring them here. Also, it's unclear + * at this point whether this should be done for all framebuffers in + * the system, rather than only the console. + */ + if ((fd = open("/dev/fb", O_RDWR, 0)) < 0) { + xf86Msg(X_WARNING, + "xf86CloseConsole(): unable to open framebuffer (%s)\n", + strerror(errno)); + } else { + struct fbgattr fbattr; + + if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) && + (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) { + xf86Msg(X_WARNING, + "xf86CloseConsole(): unable to retrieve framebuffer" + " attributes (%s)\n", strerror(errno)); + } else { + pointer fbdata; + + fbdata = mmap(NULL, fbattr.fbtype.fb_size, + PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (fbdata == MAP_FAILED) { + xf86Msg(X_WARNING, + "xf86CloseConsole(): unable to mmap framebuffer" + " (%s)\n", strerror(errno)); + } else { + (void)memset(fbdata, 0, fbattr.fbtype.fb_size); + (void)munmap(fbdata, fbattr.fbtype.fb_size); + } + } + + close(fd); + } + } + +#endif + +#ifdef HAS_USL_VTS + + /* + * Solaris 2.1 x86 doesn't seem to "switch" back to the console when the VT + * is relinquished and its mode is reset to auto. Also, Solaris 2.1 seems + * to associate vt00 with the console so I've opened the "console" back up + * and made it the active vt again in text mode and then closed it. There + * must be a better hack for this but I'm not aware of one at this time. + * + * Doug Anson 11/6/93 + * danson@lgc.com + * + * Fixed - 12/5/93 - David Holland - davidh@dorite.use.com + * Did the whole thing similarly to the way linux does it + */ + + /* Reset the display back to text mode */ + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; /* Set default vt handling */ + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); + } + + /* Activate the VT that X was started on */ + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT); + +#endif /* HAS_USL_VTS */ + + close(xf86Info.consoleFd); + +#if defined(__SOL8__) || !defined(i386) + + /* + * This probably shouldn't be here. However, there is no corresponding + * xf86CloseKbd() routine - DWH + */ + + /* Set the keyboard into "indirect" mode and turn off even translation */ + tmp = 0; + (void) ioctl(xf86Info.kbdFd, KIOCSDIRECT, &tmp); + tmp = TR_ASCII; + (void) ioctl(xf86Info.kbdFd, KIOCTRANS, &tmp); + + close(xf86Info.kbdFd); + +#endif +} + +int +xf86ProcessArgument(int argc, char **argv, int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful when + * debugging, so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return 1; + } + + /* + * Undocumented flag to protect page 0 from read/write to help catch NULL + * pointer dereferences. This is purely a debugging flag. + */ + if (!strcmp(argv[i], "-protect0")) + { + Protect0 = TRUE; + return 1; + } + +#ifdef HAS_USL_VTS + + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0) + { + UseMsg(); + VTnum = -1; + return 0; + } + + return 1; + } + +#endif /* HAS_USL_VTS */ + +#if defined(__SOL8__) || !defined(i386) + + if ((i + 1) < argc) { + if (!strcmp(argv[i], "-dev")) { + strncpy(fb_dev, argv[i+1], PATH_MAX); + fb_dev[PATH_MAX - 1] = '\0'; + return 2; + } + + if (!strcmp(argv[i], "-ar1")) { + xf86Info.kbdDelay = atoi(argv[i + 1]) * 1000; + return 2; + } + + if (!strcmp(argv[i], "-ar2")) { + xf86Info.kbdRate = atoi(argv[i + 1]) * 1000; + return 2; + } + } + +#endif + + return 0; +} + +void xf86UseMsg() +{ +#ifdef HAS_USL_VTS + ErrorF("vtXX Use the specified VT number\n"); +#endif +#if defined(__SOL8__) || !defined(i386) + ErrorF("-dev <fb> Framebuffer device\n"); + ErrorF("-ar1 <float> Set autorepeat initiate time (sec)\n"); + ErrorF(" (if not using XKB)\n"); + ErrorF("-ar2 <float> Set autorepeat interval time (sec)\n"); + ErrorF(" (if not using XKB)\n"); +#endif + ErrorF("-keeptty Don't detach controlling tty\n"); + ErrorF(" (for debugging only)\n"); +} diff --git a/hw/xfree86/os-support/solaris/sun_inout.s b/hw/xfree86/os-support/solaris/sun_inout.s new file mode 100644 index 000000000..e8f03d0e8 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_inout.s @@ -0,0 +1,124 @@ +/ $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s,v 1.1 2001/05/28 02:42:31 tsi Exp $ +/ +/ Copyright 1994-2001 The XFree86 Project, Inc. All Rights Reserved. +/ +/ Permission is hereby granted, free of charge, to any person obtaining a copy +/ of this software and associated documentation files (the "Software"), to deal +/ in the Software without restriction, including without limitation the rights +/ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +/ copies of the Software, and to permit persons to whom the Software is +/ furnished to do so, subject to the following conditions: +/ +/ The above copyright notice and this permission notice shall be included in +/ all copies or substantial portions of the Software. +/ +/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +/ XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +/ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +/ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +/ +/ Except as contained in this notice, the name of the XFree86 Project shall not +/ be used in advertising or otherwise to promote the sale, use or other +/ dealings in this Software without prior written authorization from the +/ XFree86 Project. +/ +/ +/ File: sun_inout.s +/ +/ Purpose: Provide inb(), inw(), inl(), outb(), outw(), outl() functions +/ for Solaris x86 using the ProWorks compiler by SunPro +/ +/ Author: Installed into XFree86 SuperProbe by Doug Anson (danson@lgc.com) +/ Portions donated to XFree86 by Steve Dever (Steve.Dever@Eng.Sun.Com) +/ +/ Synopsis: (c callable external declarations) +/ extern unsigned char inb(int port); +/ extern unsigned short inw(int port); +/ extern unsigned long inl(int port); +/ extern void outb(int port, unsigned char value); +/ extern void outw(int port, unsigned short value); +/ extern void outl(int port, unsigned long value); +/ + +.file "sunos_inout.s" +.text + +.globl inb +.globl inw +.globl inl +.globl outb +.globl outw +.globl outl + +/ +/ unsigned char inb(int port); +/ +.align 4 +inb: + movl 4(%esp),%edx + subl %eax,%eax + inb (%dx) + ret +.type inb,@function +.size inb,.-inb + +/ +/ unsigned short inw(int port); +/ +.align 4 +inw: + movl 4(%esp),%edx + subl %eax,%eax + inw (%dx) + ret +.type inw,@function +.size inw,.-inw + +/ +/ unsigned long inl(int port); +/ +.align 4 +inl: + movl 4(%esp),%edx + inl (%dx) + ret +.type inl,@function +.size inl,.-inl + +/ +/ void outb(int port, unsigned char value); +/ +.align 4 +outb: + movl 4(%esp),%edx + movl 8(%esp),%eax + outb (%dx) + ret +.type outb,@function +.size outb,.-outb + +/ +/ void outw(int port, unsigned short value); +/ +.align 4 +outw: + movl 4(%esp),%edx + movl 8(%esp),%eax + outw (%dx) + ret +.type outw,@function +.size outw,.-outw + +/ +/ void outl(int port, unsigned long value); +/ +.align 4 +outl: + movl 4(%esp),%edx + movl 8(%esp),%eax + outl (%dx) + ret +.type outl,@function +.size outl,.-outl diff --git a/hw/xfree86/os-support/solaris/sun_io.c b/hw/xfree86/os-support/solaris/sun_io.c new file mode 100644 index 000000000..27996d312 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_io.c @@ -0,0 +1,64 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.3 2003/02/17 15:12:00 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 DISCLAIM 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. + * + */ + +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +void +xf86SoundKbdBell(int loudness, int pitch, int duration) +{ + int kbdCmd; + + if (loudness && pitch) + { + kbdCmd = KBD_CMD_BELL; + if (ioctl (xf86Info.kbdFd, KIOCCMD, &kbdCmd) == -1) { + ErrorF("Failed to activate bell\n"); + return; + } + + usleep(xf86Info.bell_duration * loudness * 20); + + kbdCmd = KBD_CMD_NOBELL; + if (ioctl (xf86Info.kbdFd, KIOCCMD, &kbdCmd) == -1) + ErrorF ("Failed to deactivate bell\n"); + } +} + +void +xf86SetKbdLeds(int leds) +{ + if( ioctl(xf86Info.kbdFd, KIOCSLED, &leds) < 0 ) + ErrorF("Failed to set Keyboard LED's\n"); +} + +#include "xf86OSKbd.h" + +Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + return FALSE; +} diff --git a/hw/xfree86/os-support/solaris/sun_kbd.c b/hw/xfree86/os-support/solaris/sun_kbd.c new file mode 100644 index 000000000..7e4998817 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_kbd.c @@ -0,0 +1,112 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.1 2001/05/28 02:42:31 tsi Exp $ */ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Dawes <dawes@XFree86.org> + * Copyright 1999 by David Holland <davidh@iquest.net) + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the names of Thomas Roell, David Dawes, and David Holland not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Thomas Roell, David Dawes, and + * David Holland make no representations about the suitability of this software + * for any purpose. It is provided "as is" without express or implied + * warranty. + * + * THOMAS ROELL, DAVID DAWES, AND DAVID HOLLAND DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THOMAS ROELL, DAVID DAWES, OR DAVID HOLLAND + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +static int sun_otranslation = -1; +static int sun_odirect = -1; + +int +xf86GetKbdLeds() +{ + int leds; + + ioctl(xf86Info.kbdFd, KIOCGLED, &leds); + return leds; +} + +void +xf86SetKbdRepeat(char rad) +{ + /* Nothing to do */ +} + +/* + * Save initial keyboard state. This is called at the start of each server + * generation. + */ + +void +xf86KbdInit() +{ + int ktype, klayout; + + if (xf86Info.kbdFd < 0) { + xf86Info.kbdFd = open("/dev/kbd", O_RDWR|O_NONBLOCK); + if(xf86Info.kbdFd < 0) + FatalError("Unable to open keyboard: /dev/kbd\n"); + } + + /* + * None of the followin should ever fail. If it does, something is + * broken (IMO) - DWH 8/21/99 + */ + + if (ioctl(xf86Info.kbdFd, KIOCTYPE, &ktype) < 0) + FatalError("Unable to determine keyboard type: %d\n", errno); + + if (ioctl(xf86Info.kbdFd, KIOCLAYOUT, &klayout) < 0) + FatalError("Unable to determine keyboard layout: %d\n", errno); + + if (ioctl(xf86Info.kbdFd, KIOCGTRANS, &sun_otranslation) < 0) + FatalError("Unable to determine keyboard translation mode\n"); + + if (ioctl(xf86Info.kbdFd, KIOCGDIRECT, &sun_odirect) < 0) + FatalError("Unable to determine keyboard direct setting\n"); +} + +int +xf86KbdOn(void) +{ + int tmp = 1; + + if (ioctl(xf86Info.kbdFd, KIOCSDIRECT, &tmp) == -1) + FatalError("Setting keyboard direct mode on\n"); + + /* Setup translation */ + + tmp = TR_UNTRANS_EVENT; + + if (ioctl(xf86Info.kbdFd, KIOCTRANS, &tmp) == -1) + FatalError("Setting keyboard translation\n"); + + return xf86Info.kbdFd; +} + +int +xf86KbdOff() +{ + if ((sun_otranslation != -1) && + (ioctl(xf86Info.kbdFd, KIOCTRANS, &sun_otranslation) < 0)) + FatalError("Unable to restore keyboard translation mode\n"); + + if ((sun_odirect != 0) && + (ioctl(xf86Info.kbdFd, KIOCSDIRECT, &sun_odirect) < 0 )) + FatalError("Unable to restore keyboard direct setting\n"); + + return xf86Info.kbdFd; +} diff --git a/hw/xfree86/os-support/solaris/sun_kbdEv.c b/hw/xfree86/os-support/solaris/sun_kbdEv.c new file mode 100644 index 000000000..ff4ef3288 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_kbdEv.c @@ -0,0 +1,672 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.4 2001/11/08 04:15:33 tsi 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 make 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 DISCLAIM 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. + */ + +/* [JCH-96/01/21] Extended std reverse map to four buttons. */ + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef XINPUT +#include "XI.h" +#include "XIproto.h" +#include "xf86Xinput.h" +#else +#include "inputstr.h" +#endif + +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +#include <sys/vuid_event.h> +#include "atKeynames.h" + +#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 + +#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 + +#endif + +static void startautorepeat(long keycode); +static CARD32 processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg); + +static OsTimerPtr sunTimer = NULL; + +/* Map the Solaris keycodes to the "XFree86" keycodes. */ +/* + * This doesn't seem right. It probably needs to be dependent on a keyboard + * type. + */ +static unsigned char map[256] = { +#if defined(i368) || defined(__i386) || defined(__i386__) + KEY_NOTUSED, /* 0 */ + KEY_Tilde, /* 1 */ + KEY_1, /* 2 */ + KEY_2, /* 3 */ + KEY_3, /* 4 */ + KEY_4, /* 5 */ + KEY_5, /* 6 */ + KEY_6, /* 7 */ + KEY_7, /* 8 */ + KEY_8, /* 9 */ + KEY_9, /* 10 */ + KEY_0, /* 11 */ + KEY_Minus, /* 12 */ + KEY_Equal, /* 13 */ + 0x7D, /*KEY_P_YEN*/ /* 14 */ + KEY_BackSpace, /* 15 */ + KEY_Tab, /* 16 */ + KEY_Q, /* 17 */ + KEY_W, /* 18 */ + KEY_E, /* 19 */ + KEY_R, /* 20 */ + KEY_T, /* 21 */ + KEY_Y, /* 22 */ + KEY_U, /* 23 */ + KEY_I, /* 24 */ + KEY_O, /* 25 */ + KEY_P, /* 26 */ + KEY_LBrace, /* 27 */ + KEY_RBrace, /* 28 */ + KEY_BSlash, /* 29 */ + KEY_CapsLock, /* 30 */ + KEY_A, /* 31 */ + KEY_S, /* 32 */ + KEY_D, /* 33 */ + KEY_F, /* 34 */ + KEY_G, /* 35 */ + KEY_H, /* 36 */ + KEY_J, /* 37 */ + KEY_K, /* 38 */ + KEY_L, /* 39 */ + KEY_SemiColon, /* 40 */ + KEY_Quote, /* 41 */ + KEY_UNKNOWN, /* 42 */ + KEY_Enter, /* 43 */ + KEY_ShiftL, /* 44 */ + KEY_Less, /* 45 */ + KEY_Z, /* 46 */ + KEY_X, /* 47 */ + KEY_C, /* 48 */ + KEY_V, /* 49 */ + KEY_B, /* 50 */ + KEY_N, /* 51 */ + KEY_M, /* 52 */ + KEY_Comma, /* 53 */ + KEY_Period, /* 54 */ + KEY_Slash, /* 55 */ + KEY_BSlash2, /* 56 */ + KEY_ShiftR, /* 57 */ + KEY_LCtrl, /* 58 */ + KEY_LMeta, /* 59 */ + KEY_Alt, /* 60 */ + KEY_Space, /* 61 */ + KEY_AltLang, /* 62 */ + KEY_RMeta, /* 63 */ + KEY_RCtrl, /* 64 */ + KEY_Menu, /* 65 */ + KEY_UNKNOWN, /* 66 */ + KEY_UNKNOWN, /* 67 */ + KEY_UNKNOWN, /* 68 */ + KEY_UNKNOWN, /* 69 */ + KEY_UNKNOWN, /* 70 */ + KEY_UNKNOWN, /* 71 */ + KEY_UNKNOWN, /* 72 */ + KEY_UNKNOWN, /* 73 */ + KEY_UNKNOWN, /* 74 */ + KEY_Insert, /* 75 */ + KEY_Delete, /* 76 */ + KEY_UNKNOWN, /* 77 */ + KEY_UNKNOWN, /* 78 */ + KEY_Left, /* 79 */ + KEY_Home, /* 80 */ + KEY_End, /* 81 */ + KEY_UNKNOWN, /* 82 */ + KEY_Up, /* 83 */ + KEY_Down, /* 84 */ + KEY_PgUp, /* 85 */ + KEY_PgDown, /* 86 */ + KEY_UNKNOWN, /* 87 */ + KEY_UNKNOWN, /* 88 */ + KEY_Right, /* 89 */ + KEY_NumLock, /* 90 */ + KEY_KP_7, /* 91 */ + KEY_KP_4, /* 92 */ + KEY_KP_1, /* 93 */ + KEY_UNKNOWN, /* 94 */ + KEY_KP_Divide, /* 95 */ + KEY_KP_8, /* 96 */ + KEY_KP_5, /* 97 */ + KEY_KP_2, /* 98 */ + KEY_KP_0, /* 99 */ + KEY_KP_Multiply, /* 100 */ + KEY_KP_9, /* 101 */ + KEY_KP_6, /* 102 */ + KEY_KP_3, /* 103 */ + KEY_KP_Decimal, /* 104 */ + KEY_KP_Minus, /* 105 */ + KEY_KP_Plus, /* 106 */ + KEY_UNKNOWN, /* 107 */ + KEY_KP_Enter, /* 108 */ + KEY_UNKNOWN, /* 109 */ + KEY_Escape, /* 110 */ + KEY_UNKNOWN, /* 111 */ + KEY_F1, /* 112 */ + KEY_F2, /* 113 */ + KEY_F3, /* 114 */ + KEY_F4, /* 115 */ + KEY_F5, /* 116 */ + KEY_F6, /* 117 */ + KEY_F7, /* 118 */ + KEY_F8, /* 119 */ + KEY_F9, /* 120 */ + KEY_F10, /* 121 */ + KEY_F11, /* 122 */ + KEY_F12, /* 123 */ + KEY_Print, /* 124 */ + KEY_ScrollLock, /* 125 */ + KEY_Pause, /* 126 */ + KEY_UNKNOWN, /* 127 */ + KEY_UNKNOWN, /* 128 */ + KEY_UNKNOWN, /* 129 */ + KEY_UNKNOWN, /* 130 */ + KEY_NFER, /* 131 */ + KEY_XFER, /* 132 */ + KEY_HKTG, /* 133 */ + KEY_UNKNOWN, /* 134 */ +#elif defined(sparc) || defined(__sparc__) + KEY_UNKNOWN, /* 0x00 */ + KEY_UNKNOWN, /* 0x01 */ + KEY_UNKNOWN, /* 0x02 */ + KEY_UNKNOWN, /* 0x03 */ + KEY_UNKNOWN, /* 0x04 */ + KEY_F1, /* 0x05 */ + KEY_F2, /* 0x06 */ + KEY_F10, /* 0x07 */ + KEY_F3, /* 0x08 */ + KEY_F11, /* 0x09 */ + KEY_F4, /* 0x0A */ + KEY_F12, /* 0x0B */ + KEY_F5, /* 0x0C */ + KEY_UNKNOWN, /* 0x0D */ + KEY_F6, /* 0x0E */ + KEY_UNKNOWN, /* 0x0F */ + KEY_F7, /* 0x10 */ + KEY_F8, /* 0x11 */ + KEY_F9, /* 0x12 */ + KEY_Alt, /* 0x13 */ + KEY_Up, /* 0x14 */ + KEY_Pause, /* 0x15 */ + KEY_SysReqest, /* 0x16 */ + KEY_ScrollLock, /* 0x17 */ + KEY_Left, /* 0x18 */ + KEY_UNKNOWN, /* 0x19 */ + KEY_UNKNOWN, /* 0x1A */ + KEY_Down, /* 0x1B */ + KEY_Right, /* 0x1C */ + KEY_Escape, /* 0x1D */ + KEY_1, /* 0x1E */ + KEY_2, /* 0x1F */ + KEY_3, /* 0x20 */ + KEY_4, /* 0x21 */ + KEY_5, /* 0x22 */ + KEY_6, /* 0x23 */ + KEY_7, /* 0x24 */ + KEY_8, /* 0x25 */ + KEY_9, /* 0x26 */ + KEY_0, /* 0x27 */ + KEY_Minus, /* 0x28 */ + KEY_Equal, /* 0x29 */ + KEY_Tilde, /* 0x2A */ + KEY_BackSpace, /* 0x2B */ + KEY_Insert, /* 0x2C */ + KEY_UNKNOWN, /* 0x2D */ + KEY_KP_Divide, /* 0x2E */ + KEY_KP_Multiply, /* 0x2F */ + KEY_UNKNOWN, /* 0x30 */ + KEY_UNKNOWN, /* 0x31 */ + KEY_KP_Decimal, /* 0x32 */ + KEY_UNKNOWN, /* 0x33 */ + KEY_Home, /* 0x34 */ + KEY_Tab, /* 0x35 */ + KEY_Q, /* 0x36 */ + KEY_W, /* 0x37 */ + KEY_E, /* 0x38 */ + KEY_R, /* 0x39 */ + KEY_T, /* 0x3A */ + KEY_Y, /* 0x3B */ + KEY_U, /* 0x3C */ + KEY_I, /* 0x3D */ + KEY_O, /* 0x3E */ + KEY_P, /* 0x3F */ + KEY_LBrace, /* 0x40 */ + KEY_RBrace, /* 0x41 */ + KEY_Delete, /* 0x42 */ + KEY_UNKNOWN, /* 0x43 */ + KEY_KP_7, /* 0x44 */ + KEY_KP_8, /* 0x45 */ + KEY_KP_9, /* 0x46 */ + KEY_KP_Minus, /* 0x47 */ + KEY_UNKNOWN, /* 0x48 */ + KEY_UNKNOWN, /* 0x49 */ + KEY_End, /* 0x4A */ + KEY_UNKNOWN, /* 0x4B */ + KEY_LCtrl, /* 0x4C */ + KEY_A, /* 0x4D */ + KEY_S, /* 0x4E */ + KEY_D, /* 0x4F */ + KEY_F, /* 0x50 */ + KEY_G, /* 0x51 */ + KEY_H, /* 0x52 */ + KEY_J, /* 0x53 */ + KEY_K, /* 0x54 */ + KEY_L, /* 0x55 */ + KEY_SemiColon, /* 0x56 */ + KEY_Quote, /* 0x57 */ + KEY_BSlash, /* 0x58 */ + KEY_Enter, /* 0x59 */ + KEY_KP_Enter, /* 0x5A */ + KEY_KP_4, /* 0x5B */ + KEY_KP_5, /* 0x5C */ + KEY_KP_6, /* 0x5D */ + KEY_KP_0, /* 0x5E */ + KEY_UNKNOWN, /* 0x5F */ + KEY_PgUp, /* 0x60 */ + KEY_UNKNOWN, /* 0x61 */ + KEY_NumLock, /* 0x62 */ + KEY_ShiftL, /* 0x63 */ + KEY_Z, /* 0x64 */ + KEY_X, /* 0x65 */ + KEY_C, /* 0x66 */ + KEY_V, /* 0x67 */ + KEY_B, /* 0x68 */ + KEY_N, /* 0x69 */ + KEY_M, /* 0x6A */ + KEY_Comma, /* 0x6B */ + KEY_Period, /* 0x6C */ + KEY_Slash, /* 0x6D */ + KEY_ShiftR, /* 0x6E */ + KEY_UNKNOWN, /* 0x6F */ + KEY_KP_1, /* 0x70 */ + KEY_KP_2, /* 0x71 */ + KEY_KP_3, /* 0x72 */ + KEY_UNKNOWN, /* 0x73 */ + KEY_UNKNOWN, /* 0x74 */ + KEY_UNKNOWN, /* 0x75 */ + KEY_UNKNOWN, /* 0x76 */ + KEY_CapsLock, /* 0x77 */ + KEY_LMeta, /* 0x78 */ + KEY_Space, /* 0x79 */ + KEY_RMeta, /* 0x7A */ + KEY_PgDown, /* 0x7B */ + KEY_UNKNOWN, /* 0x7C */ + KEY_KP_Plus, /* 0x7D */ + KEY_UNKNOWN, /* 0x7E */ + KEY_UNKNOWN, /* 0x7F */ +#endif + /* The rest default to KEY_UNKNOWN */ +}; + +/* + * sunPostKbdEvent -- + * Translate the raw hardware Firm_event into an XEvent, and tell DIX + * about it. KeyCode preprocessing and so on is done ... + * + * Most of the Solaris stuff has whacked Panix/PC98 support in the + * interests of simplicity - DWH 8/30/99 + */ + +static void +sunPostKbdEvent(Firm_event *event) +{ + Bool down; + KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key; + Bool updateLeds = FALSE; + xEvent kevent; + KeySym *keysym; + int keycode; + static int lockkeys = 0; + + /* Give down a value */ + if (event->value == VKEY_DOWN) + down = TRUE; + else + down = FALSE; + + /* + * and now get some special keysequences + */ + + keycode = map[event->id]; + + if ((ModifierDown(ControlMask | AltMask)) || + (ModifierDown(ControlMask | AltLangMask))) + { + switch (keycode) { + /* + * 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_BackSpace: + if (!xf86Info.dontZap) { + DGAShutdown(); + GiveUp(0); + } + break; + + /* Check grabs */ + case KEY_KP_Divide: + if (!xf86Info.grabInfo.disabled && + xf86Info.grabInfo.allowDeactivate) { + if (inputInfo.pointer && inputInfo.pointer->grab != NULL && + inputInfo.pointer->DeactivateGrab) + (*inputInfo.pointer->DeactivateGrab)(inputInfo.pointer); + if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL && + inputInfo.keyboard->DeactivateGrab) + (*inputInfo.keyboard->DeactivateGrab)(inputInfo.keyboard); + } + break; + + case KEY_KP_Multiply: + if (!xf86Info.grabInfo.disabled && + xf86Info.grabInfo.allowClosedown) { + ClientPtr pointer, keyboard, server; + + pointer = keyboard = server = NULL; + if (inputInfo.pointer && inputInfo.pointer->grab != NULL) + pointer = + clients[CLIENT_ID(inputInfo.pointer->grab->resource)]; + + if (inputInfo.keyboard && inputInfo.keyboard->grab != NULL) { + keyboard = + clients[CLIENT_ID(inputInfo.keyboard->grab->resource)]; + if (keyboard == pointer) + keyboard = NULL; + } + + if ((xf86Info.grabInfo.server.grabstate == SERVER_GRABBED) && + (((server = xf86Info.grabInfo.server.client) == pointer) || + (server == keyboard))) + server = NULL; + + if (pointer) + CloseDownClient(pointer); + if (keyboard) + CloseDownClient(keyboard); + if (server) + CloseDownClient(server); + } + break; + + 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; + } + } + + /* + * Now map the scancodes to real X-keycodes ... + */ + if (keycode == KEY_NOTUSED) { + xf86MsgVerb(X_INFO, 0, + "raw code %d mapped to KEY_NOTUSED -- please report\n", event->id); + return; + } + if (keycode == KEY_UNKNOWN) { + xf86MsgVerb(X_INFO, 0, + "raw code %d mapped to KEY_UNKNOWN -- please report\n", event->id); + return; + } + keycode += MIN_KEYCODE; + keysym = keyc->curKeySyms.map + + (keyc->curKeySyms.mapWidth * + (keycode - keyc->curKeySyms.minKeyCode)); + +#ifdef XKB + if (noXkbExtension) +#endif + { + /* + * Toggle lock keys. + */ +#define CAPSFLAG 0x01 +#define NUMFLAG 0x02 +#define SCROLLFLAG 0x04 +#define MODEFLAG 0x08 + + if (down) { + /* + * Handle the KeyPresses of the lock keys. + */ + + switch (keysym[0]) { + + case XK_Caps_Lock: + if (lockkeys & CAPSFLAG) { + lockkeys &= ~CAPSFLAG; + return; + } + lockkeys |= CAPSFLAG; + updateLeds = TRUE; + xf86Info.capsLock = down; + break; + + case XK_Num_Lock: + if (lockkeys & NUMFLAG) { + lockkeys &= ~NUMFLAG; + return; + } + lockkeys |= NUMFLAG; + updateLeds = TRUE; + xf86Info.numLock = down; + break; + + case XK_Scroll_Lock: + if (lockkeys & SCROLLFLAG) { + lockkeys &= ~SCROLLFLAG; + return; + } + lockkeys |= SCROLLFLAG; + updateLeds = TRUE; + xf86Info.scrollLock = down; + break; + } + } else { + /* + * Handle the releases of the lock keys. + */ + + switch (keysym[0]) { + + case XK_Caps_Lock: + if (lockkeys & CAPSFLAG) + return; + updateLeds = TRUE; + xf86Info.capsLock = down; + break; + + case XK_Num_Lock: + if (lockkeys & NUMFLAG) + return; + updateLeds = TRUE; + xf86Info.numLock = down; + break; + + case XK_Scroll_Lock: + if (lockkeys & SCROLLFLAG) + return; + updateLeds = TRUE; + xf86Info.scrollLock = down; + break; + } + } + + if (updateLeds) + xf86KbdLeds(); + + /* + * If this keycode is not a modifier key, and its down initiate the + * autorepeate sequence. (Only necessary if not using XKB). + * + * If its not down, then reset the timer. + */ + if (!keyc->modifierMap[keycode]) { + if (down) { + startautorepeat(keycode); + } else { + TimerFree(sunTimer); + sunTimer = NULL; + } + } + } + + xf86Info.lastEventTime = + kevent.u.keyButtonPointer.time = + GetTimeInMillis(); + + /* + * And now send these prefixes ... + * NOTE: There cannot be multiple Mode_Switch keys !!!! + */ + + ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); +} + +/* + * Lets try reading more than one keyboard event at a time in the hopes that + * this will be slightly more efficient. Or we could just try the MicroSoft + * method, and forget about efficiency. :-) + */ +void +xf86KbdEvents() +{ + Firm_event event[64]; + int nBytes, i; + + /* I certainly hope its not possible to read partial events */ + + if ((nBytes = read(xf86Info.kbdFd, (char *)event, sizeof(event))) > 0) + { + for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) + sunPostKbdEvent(&event[i]); + } +} + +/* + * Autorepeat stuff + */ + +void +startautorepeat(long keycode) +{ + sunTimer = TimerSet(sunTimer, /* Timer */ + 0, /* Flags */ + xf86Info.kbdDelay, /* millis */ + processautorepeat, /* callback */ + (pointer) keycode); /* arg for timer */ +} + +CARD32 +processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg) +{ + xEvent kevent; + int keycode; + + keycode = (long)arg; + + xf86Info.lastEventTime = + kevent.u.keyButtonPointer.time = + GetTimeInMillis(); + + /* + * Repeat a key by faking a KeyRelease, and a KeyPress event in rapid + * succession + */ + + ENQUEUE(&kevent, keycode, KeyRelease, XE_KEYBOARD); + ENQUEUE(&kevent, keycode, KeyPress, XE_KEYBOARD); + + /* And return the appropriate value so we get rescheduled */ + return xf86Info.kbdRate; +} diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c new file mode 100644 index 000000000..2e9cee2b1 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_mouse.c @@ -0,0 +1,322 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.4 2002/01/25 21:56:21 tsi Exp $ */ +/* + * Copyright 1999-2001 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project shall + * not be used in advertising or otherwise to promote the sale, use or other + * dealings in this Software without prior written authorization from the + * XFree86 Project. + */ + +#include "xf86.h" +#include "xf86_OSlib.h" +#include "xf86OSmouse.h" + +#if defined(__SOL8__) || !defined(i386) + +#include "xisb.h" +#include "mipointer.h" +#include <sys/vuid_event.h> + +/* Names of protocols that are handled internally here. */ + +static const char *internalNames[] = { + "VUID", + NULL +}; + +typedef struct _VuidMseRec { + Firm_event event; + unsigned char *buffer; +} VuidMseRec, *VuidMsePtr; + + +static int vuidMouseProc(DeviceIntPtr pPointer, int what); +static void vuidReadInput(InputInfoPtr pInfo); + +/* This function is called when the protocol is "VUID". */ +static Bool +vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse = pInfo->private; + VuidMsePtr pVuidMse; + + pVuidMse = xalloc(sizeof(VuidMseRec)); + if (pVuidMse == NULL) { + xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name); + xfree(pMse); + return FALSE; + } + + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pVuidMse); + xfree(pMse); + return FALSE; + } + } + pVuidMse->buffer = (unsigned char *)&pVuidMse->event; + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Private structure */ + pMse->mousePriv = pVuidMse; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->device_control = vuidMouseProc; + pInfo->read_input = vuidReadInput; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} + +static void +vuidReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + VuidMsePtr pVuidMse; + int buttons; + int dx = 0, dy = 0, dz = 0, dw = 0; + unsigned int n; + int c; + unsigned char *pBuf; + + pMse = pInfo->private; + pVuidMse = pMse->mousePriv; + buttons = pMse->lastButtons; + XisbBlockDuration(pMse->buffer, -1); + pBuf = pVuidMse->buffer; + n = 0; + + do { + while (n < sizeof(Firm_event) && (c = XisbRead(pMse->buffer)) >= 0) { + pBuf[n++] = (unsigned char)c; + } + + if (n == 0) + return; + + if (n != sizeof(Firm_event)) { + xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", + pInfo->name, n); + } + + if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) { + /* button */ + int butnum = pVuidMse->event.id - BUT_FIRST; + if (butnum < 3) + butnum = 2 - butnum; + if (!pVuidMse->event.value) + buttons &= ~(1 << butnum); + else + buttons |= (1 << butnum); + } else if (pVuidMse->event.id >= VLOC_FIRST && + pVuidMse->event.id <= VLOC_LAST) { + /* axis */ + int delta = pVuidMse->event.value; + switch(pVuidMse->event.id) { + case LOC_X_DELTA: + dx += delta; + break; + case LOC_Y_DELTA: + dy -= delta; + break; + } + } + + n = 0; + if ((c = XisbRead(pMse->buffer)) >= 0) { + /* Another packet. Handle it right away. */ + pBuf[n++] = c; + } + } while (n != 0); + + pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); + return; +} + +#define NUMEVENTS 64 + +static int +vuidMouseProc(DeviceIntPtr pPointer, int what) +{ + InputInfoPtr pInfo; + MouseDevPtr pMse; + VuidMsePtr pVuidMse; + unsigned char map[MSE_MAXBUTTONS + 1]; + int nbuttons; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + pVuidMse = pMse->mousePriv; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons) + map[nbuttons + 1] = nbuttons + 1; + + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + min(pMse->buttons, MSE_MAXBUTTONS), + miPointerGetMotionEvents, + pMse->Ctrl, + miPointerGetMotionBufferSize()); + + /* X valuator */ + xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 0); + /* Y valuator */ + xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 1); + xf86MotionHistoryAllocate(pInfo); + break; + + case DEVICE_ON: + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + pMse->buffer = XisbNew(pInfo->fd, + NUMEVENTS * sizeof(Firm_event)); + if (!pMse->buffer) { + xfree(pMse); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } else { + int fmt = VUID_FIRM_EVENT; + ioctl(pInfo->fd, VUIDSFORMAT, &fmt); + xf86FlushInput(pInfo->fd); + AddEnabledDevice(pInfo->fd); + } + } + pMse->lastButtons = 0; + pMse->emulateState = 0; + pPointer->public.on = TRUE; + break; + + case DEVICE_OFF: + case DEVICE_CLOSE: + if (pInfo->fd != -1) { + RemoveEnabledDevice(pInfo->fd); + if (pMse->buffer) { + XisbFree(pMse->buffer); + pMse->buffer = NULL; + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } + pPointer->public.on = FALSE; + usleep(300000); + break; + } + return Success; +} + +static Bool +sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + /* The protocol is guaranteed to be one of the internalNames[] */ + if (xf86NameCmp(protocol, "VUID") == 0) { + return vuidPreInit(pInfo, protocol, flags); + } + return TRUE; +} + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + + return FALSE; +} + +static const char * +DefaultProtocol(void) +{ + return "VUID"; +} + +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + return DefaultProtocol(); +} + +#else /* __SOL8__ || !i386 */ + +#undef MSE_MISC +#define MSE_MISC 0 + +#endif /* !__SOL8__ && i386 */ + +static int +SupportedInterfaces(void) +{ + /* XXX This needs to be checked. */ + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_XPS2 | MSE_MISC; +} + +OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; +#if defined(__SOL8__) || !defined(i386) + p->BuiltinNames = BuiltinNames; + p->CheckProtocol = CheckProtocol; + p->PreInit = sunMousePreInit; + p->DefaultProtocol = DefaultProtocol; + p->SetupAuto = SetupAuto; +#endif + return p; +} + diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c new file mode 100644 index 000000000..2f4b84e99 --- /dev/null +++ b/hw/xfree86/os-support/solaris/sun_vid.c @@ -0,0 +1,229 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.3 2002/10/03 02:04:19 tsi 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 the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + */ + +#ifdef i386 +#define _NEED_SYSI86 +#endif +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +char *apertureDevName = NULL; + +Bool +xf86LinearVidMem(void) +{ + int mmapFd; + + if (apertureDevName) + return TRUE; + + apertureDevName = "/dev/xsvc"; + if ((mmapFd = open(apertureDevName, O_RDWR)) < 0) + { + apertureDevName = "/dev/fbs/aperture"; + if((mmapFd = open(apertureDevName, O_RDWR)) < 0) + { + xf86MsgVerb(X_WARNING, 0, + "xf86LinearVidMem: failed to open %s (%s)\n", + apertureDevName, strerror(errno)); + xf86MsgVerb(X_WARNING, 0, + "xf86LinearVidMem: either /dev/fbs/aperture or /dev/xsvc" + " device driver required\n"); + xf86MsgVerb(X_WARNING, 0, + "xf86LinearVidMem: linear memory access disabled\n"); + apertureDevName = NULL; + return FALSE; + } + } + close(mmapFd); + return TRUE; +} + +pointer +xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size) +{ + pointer base; + int fd; + char vtname[20]; + + /* + * Solaris 2.1 x86 SVR4 (10/27/93) + * The server must treat the virtual terminal device file as the + * standard SVR4 /dev/pmem. + * + * Using the /dev/vtXX device as /dev/pmem only works for the + * A0000-FFFFF region - If we wish you mmap the linear aperture + * it requires a device driver. + * + * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and + * try to use the /dev/fbs/aperture or /dev/xsvc driver if the server + * tries to mmap anything > FFFFF. Its very very unlikely that the + * server will try to mmap anything below FFFFF that can't be handled + * by /dev/vtXX. + * + * DWH - 2/23/94 + * DWH - 1/31/99 (Gee has it really been 5 years?) + * + * Solaris 2.8 7/26/99 + * Use /dev/xsvc for everything + * + * DWH - 7/26/99 - Solaris8/dev/xsvc changes + * + * TSI - 2001.09 - SPARC changes + */ + +#if defined(i386) && !defined(__SOL8__) + if(Base < 0xFFFFF) + sprintf(vtname, "/dev/vt%02d", xf86Info.vtno); + else +#endif + { + if (!xf86LinearVidMem()) + FatalError("xf86MapVidMem: no aperture device\n"); + + strcpy(vtname, apertureDevName); + } + + fd = open(vtname, (Flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); + if (fd < 0) + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + vtname, strerror(errno)); + + base = mmap(NULL, Size, + (Flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, (off_t)Base); + close(fd); + if (base == MAP_FAILED) + FatalError("xf86MapVidMem: mmap failure: %s\n", + strerror(errno)); + + return(base); +} + +/* ARGSUSED */ +void +xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +#ifdef i386 +static Bool ExtendedEnabled = FALSE; +#endif + +void +xf86EnableIO(void) +{ +#ifdef i386 + if (ExtendedEnabled) + return; + + if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) + FatalError("xf86EnableIOPorts: Failed to set IOPL for I/O\n"); + + ExtendedEnabled = TRUE; +#endif /* i386 */ +} + +void +xf86DisableIO(void) +{ +#ifdef i386 + if(!ExtendedEnabled) + return; + + sysi86(SI86V86, V86SC_IOPL, 0); + + ExtendedEnabled = FALSE; +#endif /* i386 */ +} + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +Bool xf86DisableInterrupts(void) +{ +#ifdef i386 + if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)) + return FALSE; + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + sysi86(SI86V86, V86SC_IOPL, 0); +#endif /* i386 */ + + return TRUE; +} + +void xf86EnableInterrupts(void) +{ +#ifdef i386 + if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)) + return; + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + if (!ExtendedEnabled) + sysi86(SI86V86, V86SC_IOPL, 0); +#endif /* i386 */ +} + +void +xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base, + unsigned long Size) +{ +} + +Bool +xf86CheckMTRR(int ScreenNum) +{ + return FALSE; +} + |