aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
commitf4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch)
tree2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/programs/Xserver/hw/xfree86/os-support/sunos
parenta840692edc9c6d19cd7c057f68e39c7d95eb767d (diff)
downloadnx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository
Diffstat (limited to 'nx-X11/programs/Xserver/hw/xfree86/os-support/sunos')
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile119
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h109
-rwxr-xr-xnx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl150
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S73
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S73
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S144
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c339
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c104
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c393
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s124
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c160
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c662
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h72
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c892
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c719
-rw-r--r--nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c237
16 files changed, 4370 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile
new file mode 100644
index 000000000..2ef24f5e4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile
@@ -0,0 +1,119 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v 1.4 2002/10/17 02:22:49 dawes Exp $
+XCOMM $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/Imakefile,v 1.8 2005/11/06 03:49:22 alanc Exp $
+XCOMM
+XCOMM Copyright 2001 The XFree86 Project, Inc. All Rights Reserved.
+XCOMM
+XCOMM Permission is hereby granted, free of charge, to any person obtaining a
+XCOMM copy of this software and associated documentation files (the
+XCOMM "Software"), to deal in the Software without restriction, including
+XCOMM without limitation the rights to use, copy, modify, merge, publish,
+XCOMM distribute, sublicense, and/or sell copies of the Software, and to permit
+XCOMM persons to whom the Software is furnished to do so, subject to the
+XCOMM following conditions:
+XCOMM
+XCOMM The above copyright notice and this permission notice shall be included
+XCOMM in all copies or substantial portions of the Software.
+XCOMM
+XCOMM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+XCOMM OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+XCOMM MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+XCOMM IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR
+XCOMM OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+XCOMM ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+XCOMM OTHER DEALINGS IN THE SOFTWARE.
+XCOMM
+XCOMM Except as contained in this notice, the name of the XFree86 Project shall
+XCOMM not be used in advertising or otherwise to promote the sale, use or other
+XCOMM dealings in this Software without prior written authorization from the
+XCOMM XFree86 Project.
+XCOMM
+
+/* This is a combined Imakefile intended for all SunOS variants */
+
+#include <Server.tmpl>
+
+#if !HasGcc
+# if HasSunC
+# if !defined(AsmArch) || !defined(AsmFlags)
+# error "Unsupported Architecture for building Xorg server with Sun compilers."
+# error "Need to use gcc or add AsmArch & AsmFlag settings in xc/config/cf/sun.cf"
+# endif
+PROWORKS_ASM_ARCH = AsmArch
+PROWORKS_ASM_FLAGS = AsmFlags
+PROWORKS_INOUT_SRC = solaris-$(PROWORKS_ASM_ARCH).S
+PROWORKS_INOUT_OBJ = solaris-$(PROWORKS_ASM_ARCH).o
+
+all:: $(PROWORKS_ASM_ARCH).il
+includes:: $(PROWORKS_ASM_ARCH).il
+
+CppFileTarget($(PROWORKS_ASM_ARCH).il,solaris-$(PROWORKS_ASM_ARCH).S,-DINLINE_ASM,NullParameter)
+
+$(PROWORKS_INOUT_OBJ): $(PROWORKS_INOUT_SRC)
+ $(AS) -P -o $@ $(PROWORKS_ASM_FLAGS) $(PROWORKS_INOUT_SRC)
+
+# elif defined(i386Architecture)
+PROWORKS_INOUT_SRC = sun_inout.s
+PROWORKS_INOUT_OBJ = sun_inout.o
+# endif
+#endif
+
+#if defined(i386Architecture) && (OSMinorVersion < 8)
+IO_SRC = sysv_io.c
+IO_OBJ = sysv_io.o
+KBD_SRCS = sysv_kbd.c std_kbdEv.c
+KBD_OBJS = sysv_kbd.o std_kbdEv.o
+VTSW_SRC = VTsw_usl.c
+VTSW_OBJ = VTsw_usl.o
+#else
+IO_SRC = sun_io.c
+IO_OBJ = sun_io.o
+KBD_SRCS = sun_kbd.c sun_kbdEv.c
+KBD_OBJS = sun_kbd.o sun_kbdEv.o
+VTSW_SRC = VTsw_noop.c
+VTSW_OBJ = VTsw_noop.o
+#endif
+
+#if defined(i386Architecture) || defined(AMD64Architecture)
+AGP_SRC = sun_agp.c
+AGP_OBJ = sun_agp.o
+#else
+AGP_SRC = agp_noop.c
+AGP_OBJ = agp_noop.o
+#endif
+
+#ifdef SVR4Architecture
+SYSVIPCDEFINES = -DHAVE_SYSV_IPC
+#endif
+
+SRCS = sun_bios.c sun_init.c $(IO_SRC) $(KBD_SRCS) $(PROWORKS_INOUT_SRC) \
+ sun_mouse.c sun_vid.c $(AGP_SRC) libc_wrapper.c kmod_noop.c pm_noop.c \
+ posix_tty.c sigiostubs.c stdPci.c stdResource.c $(VTSW_SRC)
+OBJS = sun_bios.o sun_init.o $(IO_OBJ) $(KBD_OBJS) $(PROWORKS_INOUT_OBJ) \
+ sun_mouse.o sun_vid.o $(AGP_OBJ) libc_wrapper.o kmod_noop.o pm_noop.o \
+ posix_tty.o sigiostubs.o stdPci.o stdResource.o $(VTSW_OBJ)
+
+INCLUDES = -I. -I$(XF86OSSRC) -I$(XF86COMSRC) \
+ -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(SERVERSRC)/Xext \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+DEFINES = -DUSESTDRES $(VENDOR_DEFINES) $(SYSVIPCDEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+NormalAsmObjectRule()
+
+LinkSourceFile($(VTSW_SRC),../shared)
+LinkSourceFile(agp_noop.c,../shared)
+LinkSourceFile(libc_wrapper.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
+LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(posix_tty.c,../shared)
+LinkSourceFile(sigiostubs.c,../shared)
+LinkSourceFile(stdPci.c,../shared)
+LinkSourceFile(stdResource.c,../shared)
+LinkSourceFile(std_kbdEv.c,../shared)
+LinkSourceFile(sysv_io.c,../sysv)
+LinkSourceFile(sysv_kbd.c,../shared)
+
+DependTarget()
+LintTarget()
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h
new file mode 100644
index 000000000..637087527
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h
@@ -0,0 +1,109 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/agpgart.h,v 1.2 2005/07/01 22:43:25 daniels Exp $ */
+/*
+ * AGPGART module version 0.99
+ * Copyright (C) 1999 Jeff Hartmann
+ * Copyright (C) 1999 Precision Insight, Inc.
+ * Copyright (C) 1999 Xi Graphics, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/*
+ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifndef _AGPGART_H
+#define _AGPGART_H
+
+#pragma ident "@(#)agpgart.h 1.1 05/04/04 SMI"
+
+typedef struct _agp_version {
+ uint16_t agpv_major;
+ uint16_t agpv_minor;
+} agp_version_t;
+
+typedef struct _agp_info {
+ agp_version_t agpi_version;
+ uint32_t agpi_devid; /* bridge vendor + device */
+ uint32_t agpi_mode; /* mode of bridge */
+ ulong_t agpi_aperbase; /* base of aperture */
+ size_t agpi_apersize; /* aperture range size */
+ uint32_t agpi_pgtotal; /* max number of pages in aperture */
+ uint32_t agpi_pgsystem; /* same as pg_total */
+ uint32_t agpi_pgused; /* NUMBER of currently used pages */
+} agp_info_t;
+
+typedef struct _agp_setup {
+ uint32_t agps_mode;
+} agp_setup_t;
+
+typedef struct _agp_allocate {
+ int32_t agpa_key;
+ uint32_t agpa_pgcount;
+ uint32_t agpa_type;
+ uint32_t agpa_physical; /* for i810/830 driver */
+} agp_allocate_t;
+
+typedef struct _agp_bind {
+ int32_t agpb_key;
+ uint32_t agpb_pgstart;
+} agp_bind_t;
+
+typedef struct _agp_unbind {
+ int32_t agpu_key;
+ uint32_t agpu_pri; /* no use in solaris */
+} agp_unbind_t;
+
+#define AGPIOC_BASE 'G'
+#define AGPIOC_INFO _IOR(AGPIOC_BASE, 0, 100)
+#define AGPIOC_ACQUIRE _IO(AGPIOC_BASE, 1)
+#define AGPIOC_RELEASE _IO(AGPIOC_BASE, 2)
+#define AGPIOC_SETUP _IOW(AGPIOC_BASE, 3, agp_setup_t)
+#define AGPIOC_ALLOCATE _IOWR(AGPIOC_BASE, 4, agp_allocate_t)
+#define AGPIOC_DEALLOCATE _IOW(AGPIOC_BASE, 5, int)
+#define AGPIOC_BIND _IOW(AGPIOC_BASE, 6, agp_bind_t)
+#define AGPIOC_UNBIND _IOW(AGPIOC_BASE, 7, agp_unbind_t)
+
+#define AGP_DEVICE "/dev/agpgart"
+
+#endif /* _AGPGART_H */
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl
new file mode 100755
index 000000000..2eac14f47
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl
@@ -0,0 +1,150 @@
+#!/usr/bin/perl -w
+#
+# $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/find_deps.pl,v 1.2 2004/09/22 17:20:56 alanc Exp $
+#
+# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, and/or sell copies of the Software, and to permit persons
+# to whom the Software is furnished to do so, provided that the above
+# copyright notice(s) and this permission notice appear in all copies of
+# the Software and that both the above copyright notice(s) and this
+# permission notice appear in supporting documentation.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in this Software without prior written authorization
+# of the copyright holder.
+#
+#------------------------------------------------------------------------------
+#
+# This script scans the X server, it's libraries, and shared object drivers
+# and generates the linker flags necessary to allow the shared object modules
+# to load via dlopen().
+#
+# WARNING: Do not try this at home boys and girls! Only trained professionals
+# should try this stunt. This script is not intended to serve as an example of
+# proper use of the linker or associated tools, but merely as an unfortunately
+# necessary bit of hackery to get Xserver modules to load via Solaris dlopen
+# instead of the XFree86 custom loader/runtime linker.
+#
+# No guarantee of usability or suitablity is made - in fact it's almost
+# guaranteed this is not suitable for any other use, and maybe not even
+# for the one it was intended.
+#
+# Usage: find_deps.pl [-R ProjectRoot] <paths_to_scan>
+# Expects to be called while cwd is a directory containing Xorg or XFree86
+# server binary.
+
+use strict;
+use File::Find;
+use Getopt::Std;
+
+my @objlist = ();
+my %symtable = ();
+
+my $servername;
+
+my $ProjectRoot = "/usr/X11R6";
+
+my %opts;
+getopts('R:', \%opts);
+if (exists($opts{"R"})) {
+ $ProjectRoot = $opts{"R"};
+}
+
+if (-f "Xorg") {
+ $servername = "Xorg";
+} elsif (-f "XFree86") {
+ $servername = "XFree86";
+} else {
+ die "Cannot find X server";
+}
+
+$File::Find::name = $servername;
+$_ = $servername;
+&scanobjs;
+
+find({wanted => \&scanobjs, preprocess => \&filterobjs}, @ARGV);
+
+for my $f (@objlist) {
+ open(ELFDUMP, "/usr/ccs/bin/elfdump -r $f|") || die "Cannot open file";
+ my $edline;
+ my %deps = ();
+ while ($edline = <ELFDUMP>) {
+ next unless $edline =~ /(GLOB_DAT|R_386_32|R_SPARC_32)/;
+ my @edpart = split /\s+/, $edline;
+ if (exists $symtable{$edpart[$#edpart]}) {
+# print "$f : $edpart[$#edpart] - $symtable{$edpart[$#edpart]}\n";
+ $deps{$symtable{$edpart[$#edpart]}} += 1;
+ } else {
+ print "$f : $edpart[$#edpart] - not found\n";
+ }
+ }
+ close(ELFDUMP);
+
+ my $depslist = "";
+
+ for my $d (sort keys %deps) {
+ next if ($f =~ /$d/ || $d !~ /\.so$/);
+ $depslist .= " -Wl,-N,$d";
+ }
+ print "$f : $depslist\n";
+ my $depsfile = $f ."_deps";
+ if ($depslist ne "") {
+ my $dirlist = "-R $ProjectRoot/lib/modules";
+ if ($f =~ /drivers/) {
+ $dirlist .= " -R $ProjectRoot/lib/modules/drivers";
+ }
+ if ($depslist =~ /libfbdevhw.so/) {
+ $dirlist .= " -R $ProjectRoot/lib/modules/linux/";
+ }
+ if ($depslist =~ /libGLcore.so/) {
+ $dirlist .= " -R $ProjectRoot/lib/modules/extensions/";
+ }
+
+ open(MODDEPSFILE, '>', $depsfile) || die "Cannot write to $depsfile";
+ print MODDEPSFILE $dirlist, $depslist, "\n";
+ close(MODDEPSFILE);
+ } elsif (! -z $depsfile) {
+ unlink($depsfile);
+ system("touch $depsfile");
+ }
+}
+
+
+sub filterobjs {
+ return (grep( ($_ =~ /\.so$/) || (-d $_) , @_));
+}
+
+sub scanobjs {
+ return if /libXfont.so/;
+ return if (-d $_);
+ print "Scanning $File::Find::name ...\n";
+ push @objlist, $File::Find::name;
+ open(NMOUT, "/usr/ccs/bin/nm $_|") || die "Cannot nm file $_";
+ my $nmline;
+ while ($nmline = <NMOUT>) {
+ next unless $nmline =~ /\|/;
+ my @nmpart = split(/\s*\|\s*/, $nmline);
+ next unless ($nmpart[4] eq "GLOB") && ($nmpart[6] ne "UNDEF");
+ chomp($nmpart[7]);
+ if (! exists $symtable{$nmpart[7]}) {
+ $symtable{$nmpart[7]} = $_;
+ }
+ }
+ close(NMOUT);
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S
new file mode 100644
index 000000000..9f5e58cb0
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-amd64.S
@@ -0,0 +1,73 @@
+/ Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+/
+/ Permission is hereby granted, free of charge, to any person obtaining a
+/ copy of this software and associated documentation files (the
+/ "Software"), to deal in the Software without restriction, including
+/ without limitation the rights to use, copy, modify, merge, publish,
+/ distribute, and/or sell copies of the Software, and to permit persons
+/ to whom the Software is furnished to do so, provided that the above
+/ copyright notice(s) and this permission notice appear in all copies of
+/ the Software and that both the above copyright notice(s) and this
+/ permission notice appear in supporting documentation.
+/
+/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+/ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+/ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+/ INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+/ FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+/ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+/ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/
+/ Except as contained in this notice, the name of a copyright holder
+/ shall not be used in advertising or otherwise to promote the sale, use
+/ or other dealings in this Software without prior written authorization
+/ of the copyright holder.
+
+#ifdef INLINE_ASM
+#define FUNCTION_START(f,n) .inline f,n
+#define FUNCTION_END(f) .end
+#else
+#define _ASM
+#include <sys/asm_linkage.h>
+#define FUNCTION_START(f,n) ENTRY(f)
+#define FUNCTION_END(f) SET_SIZE(f)
+#endif
+
+ FUNCTION_START(inb,4)
+ movq %rdi, %rdx
+ xorq %rax, %rax
+ inb (%dx)
+ FUNCTION_END(inb)
+
+ FUNCTION_START(inw,4)
+ movq %rdi, %rdx
+ xorq %rax, %rax
+ inw (%dx)
+ FUNCTION_END(inw)
+
+ FUNCTION_START(inl,4)
+ movq %rdi, %rdx
+ xorq %rax, %rax
+ inl (%dx)
+ FUNCTION_END(inl)
+
+ FUNCTION_START(outb,8)
+ movq %rdi, %rdx
+ movq %rsi, %rax
+ outb (%dx)
+ FUNCTION_END(outb)
+
+ FUNCTION_START(outw,8)
+ movq %rdi, %rdx
+ movq %rsi, %rax
+ outw (%dx)
+ FUNCTION_END(outw)
+
+ FUNCTION_START(outl,8)
+ movq %rdi, %rdx
+ movq %rsi, %rax
+ outl (%dx)
+ FUNCTION_END(outl)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S
new file mode 100644
index 000000000..e2d9cf60a
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-ia32.S
@@ -0,0 +1,73 @@
+/ Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+/
+/ Permission is hereby granted, free of charge, to any person obtaining a
+/ copy of this software and associated documentation files (the
+/ "Software"), to deal in the Software without restriction, including
+/ without limitation the rights to use, copy, modify, merge, publish,
+/ distribute, and/or sell copies of the Software, and to permit persons
+/ to whom the Software is furnished to do so, provided that the above
+/ copyright notice(s) and this permission notice appear in all copies of
+/ the Software and that both the above copyright notice(s) and this
+/ permission notice appear in supporting documentation.
+/
+/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+/ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+/ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+/ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+/ INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+/ FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+/ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+/ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+/
+/ Except as contained in this notice, the name of a copyright holder
+/ shall not be used in advertising or otherwise to promote the sale, use
+/ or other dealings in this Software without prior written authorization
+/ of the copyright holder.
+
+#ifdef INLINE_ASM
+#define FUNCTION_START(f,n) .inline f,n
+#define FUNCTION_END(f) .end
+#else
+#define _ASM
+#include <sys/asm_linkage.h>
+#define FUNCTION_START(f,n) ENTRY(f)
+#define FUNCTION_END(f) SET_SIZE(f)
+#endif
+
+ FUNCTION_START(inb,4)
+ movl (%esp), %edx
+ xorl %eax, %eax
+ inb (%dx)
+ FUNCTION_END(inb)
+
+ FUNCTION_START(inw,4)
+ movl (%esp), %edx
+ xorl %eax, %eax
+ inw (%dx)
+ FUNCTION_END(inw)
+
+ FUNCTION_START(inl,4)
+ movl (%esp), %edx
+ xorl %eax, %eax
+ inl (%dx)
+ FUNCTION_END(inl)
+
+ FUNCTION_START(outb,8)
+ movl (%esp), %edx
+ movl 4(%esp), %eax
+ outb (%dx)
+ FUNCTION_END(outb)
+
+ FUNCTION_START(outw,8)
+ movl (%esp), %edx
+ movl 4(%esp), %eax
+ outw (%dx)
+ FUNCTION_END(outw)
+
+ FUNCTION_START(outl,8)
+ movl (%esp), %edx
+ movl 4(%esp), %eax
+ outl (%dx)
+ FUNCTION_END(outl)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S
new file mode 100644
index 000000000..fb23942ef
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/solaris-sparcv8plus.S
@@ -0,0 +1,144 @@
+/* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifdef INLINE_ASM
+#define FUNCTION_START(f,n) .inline f,n
+#define FUNCTION_END(f) .end
+#else
+#define _ASM
+#include <sys/asm_linkage.h>
+#define FUNCTION_START(f,n) ENTRY(f)
+#define FUNCTION_END(f) SET_SIZE(f)
+#endif
+
+/* Converted from common/compiler.h gcc inline format to Sun cc inline
+ * format by Kenjiro Tsuji
+ *
+ * The value 0x88 means ASI_PRIMARY_LITTLE.
+ * The store or load to/from the address space will be done
+ * as little-endian. In the original xrog code, the value
+ * is defined as the macro ASI_PL.
+ *
+ * In the original xorg code, "membar #StoreStore|#StoreLoad"
+ * is directly implemented as an instruction "0x8143e00a".
+ *
+ */
+
+ FUNCTION_START(outb, 0)
+ stba %o1, [%o0] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(outb)
+
+ FUNCTION_START(outw, 0)
+ stha %o1, [%o0] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(outw)
+
+ FUNCTION_START(outl, 0)
+ sta %o1, [%o0] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(outl)
+
+ FUNCTION_START(inb, 0)
+ lduba [%o0] 0x88, %o0
+ FUNCTION_END(inb)
+
+ FUNCTION_START(inw, 0)
+ lduha [%o0] 0x88, %o0
+ FUNCTION_END(inw)
+
+ FUNCTION_START(inl, 0)
+ lda [%o0] 0x88, %o0
+ FUNCTION_END(inl)
+
+ FUNCTION_START(xf86ReadMmio8, 0)
+ lduba [%o0 + %o1] 0x88, %o0
+ FUNCTION_END(xf86ReadMmio8)
+
+ FUNCTION_START(xf86ReadMmio16Be, 0)
+ lduh [%o0 + %o1], %o0
+ FUNCTION_END(xf86ReadMmio16Be)
+
+ FUNCTION_START(xf86ReadMmio16Le, 0)
+ lduha [%o0 + %o1] 0x88, %o0
+ FUNCTION_END(xf86ReadMmio16Le)
+
+ FUNCTION_START(xf86ReadMmio32Be, 0)
+ ld [%o0 + %o1], %o0
+ FUNCTION_END(xf86ReadMmio32Be)
+
+ FUNCTION_START(xf86ReadMmio32Le, 0)
+ lda [%o0 + %o1] 0x88, %o0
+ FUNCTION_END(xf86ReadMmio32Le)
+
+ FUNCTION_START(xf86WriteMmio8, 0)
+ stba %o2, [%o0 + %o1] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio8)
+
+ FUNCTION_START(xf86WriteMmio16Be, 0)
+ sth %o2, [%o0 + %o1]
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio16Be)
+
+ FUNCTION_START(xf86WriteMmio16Le, 0)
+ stha %o2, [%o0 + %o1] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio16Le)
+
+ FUNCTION_START(xf86WriteMmio32Be, 0)
+ st %o2, [%o0 + %o1]
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio32Be)
+
+ FUNCTION_START(xf86WriteMmio32Le, 0)
+ sta %o2, [%o0 + %o1] 0x88
+ membar #StoreStore|#StoreLoad
+ FUNCTION_END(xf86WriteMmio32Le)
+
+ FUNCTION_START(xf86WriteMmio8NB, 0)
+ add %o0, %o1, %o0
+ stba %o2, [%o0] 0x88
+ FUNCTION_END(xf86WriteMmio8NB)
+
+ FUNCTION_START(xf86WriteMmio16BeNB, 0)
+ sth %o2, [%o0 + %o1]
+ FUNCTION_END(xf86WriteMmio16BeNB)
+
+ FUNCTION_START(xf86WriteMmio16LeNB, 0)
+ stha %o2, [%o0 + %o1] 0x88
+ FUNCTION_END(xf86WriteMmio16LeNB)
+
+ FUNCTION_START(xf86WriteMmio32BeNB, 0)
+ st %o2, [%o0 + %o1]
+ FUNCTION_END(xf86WriteMmio32BeNB)
+
+ FUNCTION_START(xf86WriteMmio32LeNB, 0)
+ sta %o2, [%o0 + %o1] 0x88
+ FUNCTION_END(xf86WriteMmio32LeNB)
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c
new file mode 100644
index 000000000..0460f1299
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c
@@ -0,0 +1,339 @@
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_agp.c,v 1.5 2005/08/24 22:37:15 alanc Exp $ */
+/*
+ * Abstraction of the AGP GART interface.
+ *
+ * This version is for Solaris.
+ *
+ * Copyright © 2000 VA Linux Systems, Inc.
+ * Copyright © 2001 The XFree86 Project, Inc.
+ */
+/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#pragma ident "@(#)sun_agp.c 1.1 05/04/04 SMI"
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86_OSproc.h"
+#include <unistd.h>
+#include <sys/ioccom.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include "agpgart.h"
+
+#ifndef AGP_DEVICE
+#define AGP_DEVICE "/dev/agpgart"
+#endif
+/* AGP page size is independent of the host page size. */
+#ifndef AGP_PAGE_SIZE
+#define AGP_PAGE_SIZE 4096
+#endif
+
+static int gartFd = -1;
+static int acquiredScreen = -1;
+static Bool initDone = FALSE;
+/*
+ * Close /dev/agpgart. This frees all associated memory allocated during
+ * this server generation.
+ */
+Bool
+xf86GARTCloseScreen(int screenNum)
+{
+ if (gartFd != -1) {
+ close(gartFd);
+ acquiredScreen = -1;
+ gartFd = -1;
+ initDone = FALSE;
+
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86GARTCloseScreen: device closed successfully\n");
+
+ }
+ return TRUE;
+}
+
+/*
+ * Open /dev/agpgart. Keep it open until xf86GARTCloseScreen is called.
+ */
+static Bool
+GARTInit(int screenNum)
+{
+ if (initDone)
+ return (gartFd != -1);
+
+ if (gartFd == -1)
+ gartFd = open(AGP_DEVICE, O_RDWR);
+ else
+ return FALSE;
+
+ if (gartFd == -1) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ initDone = TRUE;
+ xf86DrvMsg(screenNum, X_INFO,
+ "GARTInit: " AGP_DEVICE " opened successfully\n");
+
+ return TRUE;
+}
+
+Bool
+xf86AgpGARTSupported(void)
+{
+ return (GARTInit(-1));
+
+}
+
+AgpInfoPtr
+xf86GetAGPInfo(int screenNum)
+{
+ agp_info_t agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit(screenNum))
+ return NULL;
+
+ if ((info = xcalloc(sizeof(AgpInfo), 1)) == NULL) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ info->bridgeId = agpinf.agpi_devid;
+ info->agpMode = agpinf.agpi_mode;
+ info->base = agpinf.agpi_aperbase;
+ info->size = agpinf.agpi_apersize;
+ info->totalPages = (unsigned long)agpinf.agpi_pgtotal;
+ info->systemPages = (unsigned long)agpinf.agpi_pgsystem;
+ info->usedPages = (unsigned long)agpinf.agpi_pgused;
+
+ return info;
+}
+
+Bool
+xf86AcquireGART(int screenNum)
+{
+
+ if (!GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86AcquireGART: AGPIOC_ACQUIRE succeeded\n");
+ }
+ return TRUE;
+}
+
+Bool
+xf86ReleaseGART(int screenNum)
+{
+
+ if (!GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ /*
+ * The FreeBSD agp driver removes allocations on release.
+ * The Solaris driver doesn't. xf86ReleaseGART() is expected
+ * to give up access to the GART, but not to remove any
+ * allocations.
+ */
+
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86ReleaseGART: AGPIOC_RELEASE succeeded\n");
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical)
+{
+ agp_allocate_t alloc;
+ int pages;
+
+ /*
+ * Allocates "size" bytes of GART memory (rounds up to the next
+ * page multiple) or type "type". A handle (key) for the allocated
+ * memory is returned. On error, the return value is -1.
+ * "size" should be larger than 0, or AGPIOC_ALLOCATE ioctl will
+ * return error.
+ */
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return -1;
+
+ pages = (size / AGP_PAGE_SIZE);
+ if (size % AGP_PAGE_SIZE != 0)
+ pages++;
+
+ alloc.agpa_pgcount = pages;
+ alloc.agpa_type = type;
+
+ if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = (unsigned long)alloc.agpa_physical;
+
+ return alloc.agpa_key;
+}
+
+Bool
+xf86DeallocateGARTMemory(int screenNum, int key)
+{
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: "
+ "deallocation of gart memory with key %d failed\n"
+ "\t(%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Bind GART memory with "key" at "offset" */
+Bool
+xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ agp_bind_t bind;
+ int pageOffset;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86BindGARTMemory: bind key %d at 0x%08lx "
+ "(pgoffset %d)\n", key, offset, pageOffset);
+
+ bind.agpb_pgstart = pageOffset;
+ bind.agpb_key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "binding of gart memory with key %d\n"
+ "\tat offset 0x%lx failed (%s)\n",
+ key, offset, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Unbind GART memory with "key" */
+Bool
+xf86UnbindGARTMemory(int screenNum, int key)
+{
+ agp_unbind_t unbind;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ unbind.agpu_pri = 0;
+ unbind.agpu_key = key;
+
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86UnbindGARTMemory: unbind key %d\n", key);
+
+ return TRUE;
+}
+
+
+/* XXX Interface may change. */
+Bool
+xf86EnableAGP(int screenNum, CARD32 mode)
+{
+ agp_setup_t setup;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ setup.agps_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
+ "AGPIOC_SETUP with mode %x failed (%s)\n",
+ mode, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c
new file mode 100644
index 000000000..8319de04e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c
@@ -0,0 +1,104 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_bios.c,v 1.2tsi 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 HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#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=%lx]\n", Base);
+ sprintf(solx86_vtname, apertureDevName);
+ }
+
+ if ((fd = open(solx86_vtname, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ solx86_vtname, strerror(errno));
+ return(-1);
+ }
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)Base);
+ if (ptr == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed "
+ "[0x%08lx, 0x%04x]\n",
+ solx86_vtname, Base, mlen);
+ close(fd);
+ return -1;
+ }
+
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+ (void)close(fd);
+
+ return Len;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
new file mode 100644
index 000000000..b2fc3a41e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
@@ -0,0 +1,393 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.5 2001/11/25 13:51:24 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, 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.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.5 2005/07/03 07:01:36 daniels Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#if defined(__i386) || defined(__x86)
+# include <sys/kd.h>
+#endif
+
+static Bool KeepTty = FALSE;
+static Bool Protect0 = FALSE;
+#ifdef HAS_USL_VTS
+static int VTnum = -1;
+static int xf86StartVT = -1;
+#endif
+
+#if defined(__SOL8__) || !defined(__i386)
+static char fb_dev[PATH_MAX] = "/dev/fb";
+#else
+static char fb_dev[PATH_MAX] = "/dev/console";
+#endif
+
+void
+xf86OpenConsole(void)
+{
+#ifdef HAS_USL_VTS
+ int fd, i;
+ struct vt_mode VT;
+ struct vt_stat vtinfo;
+ int FreeVTslot;
+ MessageType from = X_PROBED;
+#endif
+
+ if (serverGeneration == 1)
+ {
+ /* Check if we're run with euid==0 */
+ if (geteuid() != 0)
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+
+ close(fd);
+ }
+ }
+
+#ifdef HAS_USL_VTS
+
+ /*
+ * Setup the virtual terminal manager
+ */
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else
+ {
+ if ((fd = open("/dev/vt00",O_RDWR,0)) < 0)
+ FatalError("xf86OpenConsole: Cannot open /dev/vt00 (%s)\n",
+ strerror(errno));
+
+ if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+ FatalError("xf86OpenConsole: Cannot determine current VT\n");
+
+ xf86StartVT = vtinfo.v_active;
+
+ /*
+ * There is a SEVERE problem with x86's VT's. The VT_OPENQRY
+ * ioctl() will panic the entire system if all 8 (7 VT's+Console)
+ * terminals are used. The only other way I've found to determine
+ * if there is a free VT is to try activating all the the available
+ * VT's and see if they all succeed - if they do, there there is no
+ * free VT, and the Xserver cannot continue without panic'ing the
+ * system. (It's ugly, but it seems to work.) Note there is a
+ * possible race condition here.
+ *
+ * David Holland 2/23/94
+ */
+
+ FreeVTslot = 0;
+ for (i = 7; (i >= 0) && !FreeVTslot; i--)
+ if (ioctl(fd, VT_ACTIVATE, i) != 0)
+ FreeVTslot = 1;
+
+ if (!FreeVTslot ||
+ (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+
+ close(fd);
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ sprintf(fb_dev, "/dev/vt%02d", xf86Info.vtno); /* Solaris 2.1 x86 */
+
+#endif /* HAS_USL_VTS */
+
+ if (!KeepTty)
+ setpgrp();
+
+ if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0))
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ fb_dev, strerror(errno));
+
+#ifdef HAS_USL_VTS
+
+ /* Change ownership of the vt */
+ chown(fb_dev, getuid(), getgid());
+
+ /*
+ * Now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+#endif
+#ifdef KDSETMODE
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+#endif
+ }
+ else /* serverGeneration != 1 */
+ {
+#ifdef HAS_USL_VTS
+ /*
+ * Now re-get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+
+#endif /* HAS_USL_VTS */
+
+ }
+}
+
+void
+xf86CloseConsole(void)
+{
+#ifdef HAS_USL_VTS
+ struct vt_mode VT;
+#endif
+#if defined(__SOL8__) || !defined(i386)
+ int tmp;
+#endif
+
+#if !defined(i386) && !defined(__x86)
+
+ if (!xf86DoProbe && !xf86DoConfigure) {
+ int fd;
+
+ /*
+ * Wipe out framebuffer just like the non-SI Xsun server does. This
+ * could be improved by saving framebuffer contents in
+ * xf86OpenConsole() above and restoring them here. Also, it's unclear
+ * at this point whether this should be done for all framebuffers in
+ * the system, rather than only the console.
+ */
+ if ((fd = open("/dev/fb", O_RDWR, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to open framebuffer (%s)\n",
+ strerror(errno));
+ } else {
+ struct fbgattr fbattr;
+
+ if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
+ (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to retrieve framebuffer"
+ " attributes (%s)\n", strerror(errno));
+ } else {
+ pointer fbdata;
+
+ fbdata = mmap(NULL, fbattr.fbtype.fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (fbdata == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to mmap framebuffer"
+ " (%s)\n", strerror(errno));
+ } else {
+ (void)memset(fbdata, 0, fbattr.fbtype.fb_size);
+ (void)munmap(fbdata, fbattr.fbtype.fb_size);
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+#endif
+
+#ifdef KDSETMODE
+ /* Reset the display back to text mode */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);
+#endif
+
+#ifdef HAS_USL_VTS
+
+ /*
+ * Solaris 2.1 x86 doesn't seem to "switch" back to the console when the VT
+ * is relinquished and its mode is reset to auto. Also, Solaris 2.1 seems
+ * to associate vt00 with the console so I've opened the "console" back up
+ * and made it the active vt again in text mode and then closed it. There
+ * must be a better hack for this but I'm not aware of one at this time.
+ *
+ * Doug Anson 11/6/93
+ * danson@lgc.com
+ *
+ * Fixed - 12/5/93 - David Holland - davidh@dorite.use.com
+ * Did the whole thing similarly to the way linux does it
+ */
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO; /* Set default vt handling */
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ }
+
+ /* Activate the VT that X was started on */
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT);
+
+#endif /* HAS_USL_VTS */
+
+ close(xf86Info.consoleFd);
+
+#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/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s
new file mode 100644
index 000000000..5c0b23ef6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_inout.s
@@ -0,0 +1,124 @@
+/ $XFree86$
+/
+/ 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/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c
new file mode 100644
index 000000000..2269ef3c9
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c
@@ -0,0 +1,160 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.2 2002/10/11 01:40:37 dawes Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_io.c,v 1.4 2005/08/13 00:11:28 alanc 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.
+ *
+ */
+/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+/* Solaris support routines for builtin "keyboard" driver */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "sun_kbd.h"
+
+static sunKbdPrivRec sunKeyboardPriv;
+
+_X_HIDDEN void
+xf86KbdInit(void)
+{
+ const char *kbdName = "keyboard";
+ pointer *kbdOptions = NULL;
+ IDevPtr pDev;
+
+ /* There should be a better way to find the keyboard device name, but
+ this seems to work for now. */
+ for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
+ if (!xf86NameCmp(pDev->driver, "keyboard")) {
+ kbdName = pDev->identifier;
+ kbdOptions = pDev->commonOptions;
+ break;
+ }
+ }
+
+ if (xf86Info.kbdFd < 0) {
+ xf86Info.kbdFd = sunKbdOpen(kbdName, kbdOptions);
+ if (xf86Info.kbdFd < 0) {
+ FatalError("Unable to open keyboard: /dev/kbd\n");
+ }
+ }
+
+ memset(&sunKeyboardPriv, 0, sizeof(sunKbdPrivRec));
+ if (sunKbdInit(&sunKeyboardPriv, xf86Info.kbdFd,
+ kbdName, kbdOptions) != Success) {
+ FatalError("Unable to initialize keyboard driver\n");
+ }
+}
+
+_X_HIDDEN int
+xf86KbdOn(void)
+{
+ if (sunKbdOn(&sunKeyboardPriv) != Success) {
+ FatalError("Enabling keyboard");
+ }
+
+ return xf86Info.kbdFd;
+}
+
+_X_HIDDEN int
+xf86KbdOff(void)
+{
+ if (sunKbdOff(&sunKeyboardPriv) != Success) {
+ FatalError("Disabling keyboard");
+ }
+
+ return xf86Info.kbdFd;
+}
+
+_X_EXPORT void
+xf86SoundKbdBell(int loudness, int pitch, int duration)
+{
+ sunKbdSoundBell(&sunKeyboardPriv, loudness, pitch, duration);
+}
+
+_X_HIDDEN void
+xf86SetKbdLeds(int leds)
+{
+ sunKbdSetLeds(&sunKeyboardPriv, leds);
+}
+
+_X_HIDDEN int
+xf86GetKbdLeds(void)
+{
+ return sunKbdGetLeds(&sunKeyboardPriv);
+}
+
+_X_HIDDEN void
+xf86SetKbdRepeat(char rad)
+{
+ sunKbdSetRepeat(&sunKeyboardPriv, rad);
+}
+
+/*
+ * 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. :-)
+ */
+_X_HIDDEN void
+xf86KbdEvents(void)
+{
+ 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(sunKeyboardPriv.ktype, &event[i]);
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c
new file mode 100644
index 000000000..0a39155f4
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c
@@ -0,0 +1,662 @@
+/* $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.
+ */
+/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.c,v 1.7 2005/08/30 22:34:14 alanc Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSKbd.h"
+#include "sun_kbd.h"
+
+/* Define to provide support for using /dev/audio to ring the bell instead of
+ the keyboard beeper */
+#define AUDIO_BELL
+
+#ifdef AUDIO_BELL
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+#endif
+
+/***************************************************************************
+ * Common implementation of routines shared by "keyboard" driver in sun_io.c
+ * and "kbd" driver (later on in this file)
+ */
+
+#include <sys/stropts.h>
+#include <sys/vuid_event.h>
+#include <sys/kbd.h>
+
+_X_HIDDEN int
+sunKbdOpen(const char *devName, pointer options)
+{
+ int kbdFD;
+ const char *kbdPath = NULL;
+ const char *defaultKbd = "/dev/kbd";
+
+ if (options != NULL) {
+ kbdPath = xf86SetStrOption(options, "Device", NULL);
+ }
+ if (kbdPath == NULL) {
+ kbdPath = defaultKbd;
+ }
+
+ kbdFD = open(kbdPath, O_RDONLY | O_NONBLOCK);
+
+ if (kbdFD == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", devName, kbdPath);
+ } else {
+ xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", devName, kbdPath);
+ }
+
+ if ((kbdPath != NULL) && (kbdPath != defaultKbd)) {
+ xfree(kbdPath);
+ }
+ return kbdFD;
+}
+
+
+/*
+ * Save initial keyboard state. This is called at the start of each server
+ * generation.
+ */
+
+_X_HIDDEN int
+sunKbdInit(sunKbdPrivPtr priv, int kbdFD, const char *devName, pointer options)
+{
+ int ktype, klayout, i;
+ const char *ktype_name;
+
+ priv->kbdFD = kbdFD;
+ priv->devName = devName;
+ priv->otranslation = -1;
+ priv->odirect = -1;
+
+ if (options != NULL) {
+ priv->strmod = xf86SetStrOption(options, "StreamsModule", NULL);
+ priv->audioDevName = xf86SetStrOption(options, "BellDevice", NULL);
+
+ if (priv->audioDevName && (priv->audioDevName[0] == '\0')) {
+ xfree(priv->audioDevName);
+ priv->audioDevName = NULL;
+ }
+ } else {
+ priv->strmod = NULL;
+ priv->audioDevName = NULL;
+ }
+
+ if (priv->strmod) {
+ SYSCALL(i = ioctl(priv->kbdFD, I_PUSH, priv->strmod));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: cannot push module '%s' onto keyboard device: %s\n",
+ priv->devName, priv->strmod, strerror(errno));
+ }
+ }
+
+ SYSCALL(i = ioctl(kbdFD, KIOCTYPE, &ktype));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n",
+ devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ SYSCALL(i = ioctl(kbdFD, KIOCLAYOUT, &klayout));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Unable to determine keyboard layout: %s\n",
+ devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ switch (ktype) {
+ case KB_SUN3:
+ ktype_name = "Sun Type 3"; break;
+ case KB_SUN4:
+ ktype_name = "Sun Type 4/5/6"; break;
+ case KB_USB:
+ ktype_name = "USB"; break;
+ case KB_PC:
+ ktype_name = "PC"; break;
+ default:
+ ktype_name = "Unknown"; break;
+ }
+
+ xf86Msg(X_PROBED, "%s: Keyboard type: %s (%d)\n",
+ devName, ktype_name, ktype);
+ xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", devName, klayout);
+
+ priv->ktype = ktype;
+ priv->keyMap = sunGetKbdMapping(ktype);
+ priv->audioState = AB_INITIALIZING;
+ priv->oleds = sunKbdGetLeds(priv);
+
+ return Success;
+}
+
+_X_HIDDEN int
+sunKbdOn(sunKbdPrivPtr priv)
+{
+ int ktrans, kdirect, i;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCGDIRECT, &kdirect));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to determine keyboard direct setting: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ priv->odirect = kdirect;
+ kdirect = 1;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &kdirect));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed turning keyboard direct mode on: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ /* Setup translation */
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCGTRANS, &ktrans));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to determine keyboard translation mode: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ priv->otranslation = ktrans;
+ ktrans = TR_UNTRANS_EVENT;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &ktrans));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed setting keyboard translation mode: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+
+ return Success;
+}
+
+_X_HIDDEN int
+sunKbdOff(sunKbdPrivPtr priv)
+{
+ int i;
+
+ /* restore original state */
+
+ sunKbdSetLeds(priv, priv->oleds);
+
+ if (priv->otranslation != -1) {
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &priv->otranslation));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to restore keyboard translation mode: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+ priv->otranslation = -1;
+ }
+
+ if (priv->odirect != -1) {
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &priv->odirect));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: Unable to restore keyboard direct setting: %s\n",
+ priv->devName, strerror(errno));
+ return BadImplementation;
+ }
+ priv->odirect = -1;
+ }
+
+ if (priv->strmod) {
+ SYSCALL(i = ioctl(priv->kbdFD, I_POP, priv->strmod));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off keyboard device: %s\n",
+ priv->devName, priv->strmod, strerror(errno));
+ }
+ }
+
+ return Success;
+}
+
+#ifdef AUDIO_BELL
+
+/* Helper function to ring bell via audio device instead of keyboard beeper */
+
+#define BELL_RATE 48000 /* Samples per second */
+#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
+#define BELL_MS (1000/BELL_HZ) /* MS */
+#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
+#define BELL_MIN 3 /* Min # of repeats */
+
+static int
+sunKbdAudioBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
+{
+ static short samples[BELL_SAMPLES];
+ static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+ static int lastFreq;
+ int cnt;
+ int i;
+ int written;
+ int repeats;
+ int freq;
+ audio_info_t audioInfo;
+ struct iovec iov[IOV_MAX];
+ int iovcnt;
+ double ampl, cyclen, phase;
+ int audioFD;
+
+ if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+ return 0;
+ }
+
+ if ((priv == NULL) || (priv->audioDevName == NULL)) {
+ return -1;
+ }
+
+ if (priv->audioState == AB_INITIALIZING) {
+ priv->audioState = AB_NORMAL;
+ lastFreq = 0;
+ bzero(silence, sizeof(silence));
+ }
+
+ audioFD = open(priv->audioDevName, O_WRONLY | O_NONBLOCK);
+ if (audioFD == -1) {
+ xf86Msg(X_ERROR, "%s: cannot open audio device \"%s\": %s\n",
+ priv->devName, priv->audioDevName, strerror(errno));
+ return -1;
+ }
+
+ freq = pitch;
+ freq = min(freq, (BELL_RATE / 2) - 1);
+ freq = max(freq, 2 * BELL_HZ);
+
+ /*
+ * Ensure full waves per buffer
+ */
+ freq -= freq % BELL_HZ;
+
+ if (freq != lastFreq) {
+ lastFreq = freq;
+ ampl = 16384.0;
+
+ cyclen = (double) freq / (double) BELL_RATE;
+ phase = 0.0;
+
+ for (i = 0; i < BELL_SAMPLES; i++) {
+ samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+ phase += cyclen;
+ if (phase >= 1.0)
+ phase -= 1.0;
+ }
+ }
+
+ repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+ repeats = max(repeats, BELL_MIN);
+
+ loudness = max(0, loudness);
+ loudness = min(loudness, 100);
+
+#ifdef DEBUG
+ ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+ freq, loudness, duration, repeats);
+#endif
+
+ AUDIO_INITINFO(&audioInfo);
+ audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+ audioInfo.play.sample_rate = BELL_RATE;
+ audioInfo.play.channels = 2;
+ audioInfo.play.precision = 16;
+ audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+ if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+ xf86Msg(X_ERROR,
+ "%s: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+ priv->devName, priv->audioDevName, strerror(errno));
+ close(audioFD);
+ return -1;
+ }
+
+ iovcnt = 0;
+
+ for (cnt = 0; cnt <= repeats; cnt++) {
+ iov[iovcnt].iov_base = (char *) samples;
+ iov[iovcnt++].iov_len = sizeof(samples);
+ if (cnt == repeats) {
+ /* Insert a bit of silence so that multiple beeps are distinct and
+ * not compressed into a single tone.
+ */
+ iov[iovcnt].iov_base = (char *) silence;
+ iov[iovcnt++].iov_len = sizeof(silence);
+ }
+ if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+ written = writev(audioFD, iov, iovcnt);
+
+ if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+ /* audio buffer was full! */
+
+ int naptime;
+
+ if (written == -1) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_ERROR,
+ "%s: writev failed on audio device \"%s\": %s\n",
+ priv->devName, priv->audioDevName,
+ strerror(errno));
+ close(audioFD);
+ return -1;
+ }
+ i = iovcnt;
+ } else {
+ i = ((sizeof(samples) * iovcnt) - written)
+ / sizeof(samples);
+ }
+ cnt -= i;
+
+ /* sleep a little to allow audio buffer to drain */
+ naptime = BELL_MS * i;
+ poll(NULL, 0, naptime);
+
+ i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+ iovcnt = 0;
+ if ((written != -1) && (i > 0)) {
+ iov[iovcnt].iov_base = ((char *) samples) + i;
+ iov[iovcnt++].iov_len = sizeof(samples) - i;
+ }
+ } else {
+ iovcnt = 0;
+ }
+ }
+ }
+
+ close(audioFD);
+ return 0;
+}
+
+#endif /* AUDIO_BELL */
+
+_X_HIDDEN void
+sunKbdSoundBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
+{
+ int kbdCmd, i;
+
+ if (loudness && pitch)
+ {
+#ifdef AUDIO_BELL
+ if (priv->audioDevName != NULL) {
+ if (sunKbdAudioBell(priv, loudness, pitch, duration) == 0) {
+ return;
+ }
+ }
+#endif
+
+ kbdCmd = KBD_CMD_BELL;
+
+ SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to activate bell: %s\n",
+ priv->devName, strerror(errno));
+ }
+
+ usleep(duration * loudness * 20);
+
+ kbdCmd = KBD_CMD_NOBELL;
+ SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to deactivate bell: %s\n",
+ priv->devName, strerror(errno));
+ }
+ }
+}
+
+_X_HIDDEN void
+sunKbdSetLeds(sunKbdPrivPtr priv, int leds)
+{
+ int i;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCSLED, &leds));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to set keyboard LED's: %s\n",
+ priv->devName, strerror(errno));
+ }
+}
+
+_X_HIDDEN int
+sunKbdGetLeds(sunKbdPrivPtr priv)
+{
+ int i, leds = 0;
+
+ SYSCALL(i = ioctl(priv->kbdFD, KIOCGLED, &leds));
+ if (i < 0) {
+ xf86Msg(X_ERROR, "%s: Failed to get keyboard LED's: %s\n",
+ priv->devName, strerror(errno));
+ }
+ return leds;
+}
+
+/* ARGSUSED0 */
+_X_HIDDEN void
+sunKbdSetRepeat(sunKbdPrivPtr priv, char rad)
+{
+ /* Nothing to do */
+}
+
+/***************************************************************************
+ * Routines called from "kbd" driver via proc vectors filled in by
+ * xf86OSKbdPreInit().
+ */
+
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ return sunKbdInit(priv, pInfo->fd, pInfo->name, pInfo->options);
+}
+
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ return sunKbdOn(priv);
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ return sunKbdOff(priv);
+}
+
+
+static void
+SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ sunKbdSoundBell(priv, loudness, pitch, duration);
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ int real_leds = sunKbdGetLeds(priv);
+
+ real_leds &= ~(LED_CAPS_LOCK | LED_NUM_LOCK | LED_SCROLL_LOCK | LED_COMPOSE);
+
+ if (leds & XLED1) real_leds |= LED_CAPS_LOCK;
+ if (leds & XLED2) real_leds |= LED_NUM_LOCK;
+ if (leds & XLED3) real_leds |= LED_SCROLL_LOCK;
+ if (leds & XLED4) real_leds |= LED_COMPOSE;
+
+ sunKbdSetLeds(priv, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ int leds = 0;
+ int real_leds = sunKbdGetLeds(priv);
+
+ if (real_leds & LED_CAPS_LOCK) leds |= XLED1;
+ if (real_leds & LED_NUM_LOCK) leds |= XLED2;
+ if (real_leds & LED_SCROLL_LOCK) leds |= XLED3;
+ if (real_leds & LED_COMPOSE) leds |= XLED4;
+
+ return leds;
+}
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+
+ sunKbdSetRepeat(priv, rad);
+}
+
+static void
+KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ /* Should probably do something better here */
+ xf86KbdGetMapping(pKeySyms, pModMap);
+}
+
+static void
+ReadInput(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ Firm_event event[64];
+ int nBytes, i;
+
+ /* I certainly hope its not possible to read partial events */
+
+ if ((nBytes = read(pInfo->fd, (char *)event, sizeof(event))) > 0)
+ {
+ for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) {
+ pKbd->PostEvent(pInfo, priv->keyMap[event[i].id],
+ event[i].value == VKEY_DOWN ? TRUE : FALSE);
+ }
+ }
+}
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+ pInfo->fd = sunKbdOpen(pInfo->name, pInfo->options);
+
+ if (pInfo->fd >= 0) {
+ pInfo->read_input = ReadInput;
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+_X_EXPORT Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+ KbdDevPtr pKbd = pInfo->private;
+
+ pKbd->KbdInit = KbdInit;
+ pKbd->KbdOn = KbdOn;
+ pKbd->KbdOff = KbdOff;
+ pKbd->Bell = SoundKbdBell;
+ pKbd->SetLeds = SetKbdLeds;
+ pKbd->GetLeds = GetKbdLeds;
+ pKbd->SetKbdRepeat = SetKbdRepeat;
+ pKbd->KbdGetMapping = KbdGetMapping;
+
+ pKbd->RemapScanCode = NULL;
+ pKbd->GetSpecialKey = NULL;
+ pKbd->SpecialKey = NULL;
+
+ pKbd->OpenKeyboard = OpenKeyboard;
+
+ pKbd->vtSwitchSupported = FALSE;
+ pKbd->CustomKeycodes = FALSE;
+
+ pKbd->private = xcalloc(sizeof(sunKbdPrivRec), 1);
+ if (pKbd->private == NULL) {
+ xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+ return FALSE;
+ } else {
+ sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
+ priv->otranslation = -1;
+ priv->odirect = -1;
+ }
+
+ return TRUE;
+}
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h
new file mode 100644
index 000000000..ed2824b1f
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbd.h
@@ -0,0 +1,72 @@
+/* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifndef _XORG_SUN_KBD_H_
+#define _XORG_SUN_KBD_H_
+
+/*
+ * Keyboard common implementation routines shared by "keyboard" driver
+ * in sun_io.c and "kbd" driver in sun_kbd.c
+ */
+
+typedef struct {
+ int kbdFD;
+ const char * devName;
+ int ktype; /* Keyboard type from KIOCTYPE */
+ Bool kbdActive; /* Have we set kbd modes for X? */
+ int otranslation; /* Original translation mode */
+ int odirect; /* Original "direct" mode setting */
+ unsigned char oleds; /* Original LED state */
+ const char * strmod; /* Streams module pushed on kbd device */
+ const char * audioDevName; /* Audio device path to use for bell
+ or NULL to use keyboard beeper */
+ enum {AB_INITIALIZING, AB_NORMAL} audioState;
+ const unsigned char *keyMap;
+} sunKbdPrivRec, *sunKbdPrivPtr;
+
+/* sun_kbd.c */
+extern int sunKbdOpen (const char *devName, pointer options);
+extern int sunKbdInit (sunKbdPrivPtr priv, int kbdFD,
+ const char *devName, pointer options);
+extern int sunKbdOn (sunKbdPrivPtr priv);
+extern int sunKbdOff (sunKbdPrivPtr priv);
+
+extern void sunKbdSoundBell (sunKbdPrivPtr priv,
+ int loudness, int pitch, int duration);
+
+extern void sunKbdSetLeds (sunKbdPrivPtr priv, int leds);
+extern int sunKbdGetLeds (sunKbdPrivPtr priv);
+extern void sunKbdSetRepeat (sunKbdPrivPtr priv, char rad);
+
+/* sun_kbdEv.c */
+#include <sys/vuid_event.h>
+extern void sunPostKbdEvent (int ktype, Firm_event *event);
+
+extern const unsigned char *sunGetKbdMapping(int ktype);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c
new file mode 100644
index 000000000..dbae7c775
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c
@@ -0,0 +1,892 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.5 2003/08/26 19:00:36 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. */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_kbdEv.c,v 1.9 2005/08/16 00:40:25 alanc Exp $ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "sun_kbd.h"
+
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "xf86Xinput.h"
+#else
+#include "inputstr.h"
+#endif
+
+#ifdef XFreeXDGA
+#include "dgaproc.h"
+#endif
+
+#include <sys/kbd.h>
+#include "atKeynames.h"
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+#define XE_POINTER 1
+#define XE_KEYBOARD 2
+
+#ifdef XTESTEXT1
+
+#define XTestSERVER_SIDE
+#include <X11/extensions/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.
+ */
+
+/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */
+#define KEY_Kanji 0x82
+#define KEY_Execute 0x83
+
+static unsigned char map[256] = {
+#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__x86)
+ 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 */
+};
+
+#if defined(KB_USB)
+static unsigned char usbmap[256] = {
+/*
+ * partially taken from ../bsd/bsd_KbdMap.c
+ *
+ * added keycodes for Sun special keys (left function keys, audio control)
+ */
+ /* 0 */ KEY_NOTUSED,
+ /* 1 */ KEY_NOTUSED,
+ /* 2 */ KEY_NOTUSED,
+ /* 3 */ KEY_NOTUSED,
+ /* 4 */ KEY_A,
+ /* 5 */ KEY_B,
+ /* 6 */ KEY_C,
+ /* 7 */ KEY_D,
+ /* 8 */ KEY_E,
+ /* 9 */ KEY_F,
+ /* 10 */ KEY_G,
+ /* 11 */ KEY_H,
+ /* 12 */ KEY_I,
+ /* 13 */ KEY_J,
+ /* 14 */ KEY_K,
+ /* 15 */ KEY_L,
+ /* 16 */ KEY_M,
+ /* 17 */ KEY_N,
+ /* 18 */ KEY_O,
+ /* 19 */ KEY_P,
+ /* 20 */ KEY_Q,
+ /* 21 */ KEY_R,
+ /* 22 */ KEY_S,
+ /* 23 */ KEY_T,
+ /* 24 */ KEY_U,
+ /* 25 */ KEY_V,
+ /* 26 */ KEY_W,
+ /* 27 */ KEY_X,
+ /* 28 */ KEY_Y,
+ /* 29 */ KEY_Z,
+ /* 30 */ KEY_1, /* 1 !*/
+ /* 31 */ KEY_2, /* 2 @ */
+ /* 32 */ KEY_3, /* 3 # */
+ /* 33 */ KEY_4, /* 4 $ */
+ /* 34 */ KEY_5, /* 5 % */
+ /* 35 */ KEY_6, /* 6 ^ */
+ /* 36 */ KEY_7, /* 7 & */
+ /* 37 */ KEY_8, /* 8 * */
+ /* 38 */ KEY_9, /* 9 ( */
+ /* 39 */ KEY_0, /* 0 ) */
+ /* 40 */ KEY_Enter, /* Return */
+ /* 41 */ KEY_Escape, /* Escape */
+ /* 42 */ KEY_BackSpace, /* Backspace Delete */
+ /* 43 */ KEY_Tab, /* Tab */
+ /* 44 */ KEY_Space, /* Space */
+ /* 45 */ KEY_Minus, /* - _ */
+ /* 46 */ KEY_Equal, /* = + */
+ /* 47 */ KEY_LBrace, /* [ { */
+ /* 48 */ KEY_RBrace, /* ] } */
+ /* 49 */ KEY_BSlash, /* \ | */
+ /* 50 */ KEY_BSlash, /* \ _ # ~ on some keyboards */
+ /* 51 */ KEY_SemiColon, /* ; : */
+ /* 52 */ KEY_Quote, /* ' " */
+ /* 53 */ KEY_Tilde, /* ` ~ */
+ /* 54 */ KEY_Comma, /* , < */
+ /* 55 */ KEY_Period, /* . > */
+ /* 56 */ KEY_Slash, /* / ? */
+ /* 57 */ KEY_CapsLock, /* Caps Lock */
+ /* 58 */ KEY_F1, /* F1 */
+ /* 59 */ KEY_F2, /* F2 */
+ /* 60 */ KEY_F3, /* F3 */
+ /* 61 */ KEY_F4, /* F4 */
+ /* 62 */ KEY_F5, /* F5 */
+ /* 63 */ KEY_F6, /* F6 */
+ /* 64 */ KEY_F7, /* F7 */
+ /* 65 */ KEY_F8, /* F8 */
+ /* 66 */ KEY_F9, /* F9 */
+ /* 67 */ KEY_F10, /* F10 */
+ /* 68 */ KEY_F11, /* F11 */
+ /* 69 */ KEY_F12, /* F12 */
+ /* 70 */ KEY_Print, /* PrintScrn SysReq */
+ /* 71 */ KEY_ScrollLock, /* Scroll Lock */
+ /* 72 */ KEY_Pause, /* Pause Break */
+ /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */
+ /* 74 */ KEY_Home, /* Home */
+ /* 75 */ KEY_PgUp, /* Page Up */
+ /* 76 */ KEY_Delete, /* Delete */
+ /* 77 */ KEY_End, /* End */
+ /* 78 */ KEY_PgDown, /* Page Down */
+ /* 79 */ KEY_Right, /* Right Arrow */
+ /* 80 */ KEY_Left, /* Left Arrow */
+ /* 81 */ KEY_Down, /* Down Arrow */
+ /* 82 */ KEY_Up, /* Up Arrow */
+ /* 83 */ KEY_NumLock, /* Num Lock */
+ /* 84 */ KEY_KP_Divide, /* Keypad / */
+ /* 85 */ KEY_KP_Multiply, /* Keypad * */
+ /* 86 */ KEY_KP_Minus, /* Keypad - */
+ /* 87 */ KEY_KP_Plus, /* Keypad + */
+ /* 88 */ KEY_KP_Enter, /* Keypad Enter */
+ /* 89 */ KEY_KP_1, /* Keypad 1 End */
+ /* 90 */ KEY_KP_2, /* Keypad 2 Down */
+ /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */
+ /* 92 */ KEY_KP_4, /* Keypad 4 Left */
+ /* 93 */ KEY_KP_5, /* Keypad 5 */
+ /* 94 */ KEY_KP_6, /* Keypad 6 */
+ /* 95 */ KEY_KP_7, /* Keypad 7 Home */
+ /* 96 */ KEY_KP_8, /* Keypad 8 Up */
+ /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */
+ /* 98 */ KEY_KP_0, /* Keypad 0 Ins */
+ /* 99 */ KEY_KP_Decimal, /* Keypad . Del */
+ /* 100 */ KEY_Less, /* < > on some keyboards */
+ /* 101 */ KEY_Menu, /* Menu */
+ /* 102 */ KEY_Power, /* Sun: Power */
+ /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
+ /* 104 */ KEY_NOTUSED,
+ /* 105 */ KEY_NOTUSED,
+ /* 106 */ KEY_NOTUSED,
+ /* 107 */ KEY_NOTUSED,
+ /* 108 */ KEY_NOTUSED,
+ /* 109 */ KEY_NOTUSED,
+ /* 110 */ KEY_NOTUSED,
+ /* 111 */ KEY_NOTUSED,
+ /* 112 */ KEY_NOTUSED,
+ /* 113 */ KEY_NOTUSED,
+ /* 114 */ KEY_NOTUSED,
+ /* 115 */ KEY_NOTUSED,
+ /* 116 */ KEY_L7, /* Sun: Open */
+ /* 117 */ KEY_Help, /* Sun: Help */
+ /* 118 */ KEY_L3, /* Sun: Props */
+ /* 119 */ KEY_L5, /* Sun: Front */
+ /* 120 */ KEY_L1, /* Sun: Stop */
+ /* 121 */ KEY_L2, /* Sun: Again */
+ /* 122 */ KEY_L4, /* Sun: Undo */
+ /* 123 */ KEY_L10, /* Sun: Cut */
+ /* 124 */ KEY_L6, /* Sun: Copy */
+ /* 125 */ KEY_L8, /* Sun: Paste */
+ /* 126 */ KEY_L9, /* Sun: Find */
+ /* 127 */ KEY_Mute, /* Sun: AudioMute */
+ /* 128 */ KEY_AudioRaise, /* Sun: AudioRaise */
+ /* 129 */ KEY_AudioLower, /* Sun: AudioLower */
+ /* 130 */ KEY_NOTUSED,
+ /* 131 */ KEY_NOTUSED,
+ /* 132 */ KEY_NOTUSED,
+ /* 133 */ KEY_NOTUSED,
+ /* 134 */ KEY_NOTUSED,
+ /* 135 */ KEY_BSlash2, /* Sun Japanese Kbd: Backslash / Underscore */
+ /* 136 */ KEY_XFER, /* Sun Japanese Kbd: Henkan Mode */
+ /* 137 */ KEY_Yen, /* Sun Japanese Kbd: Yen / Brokenbar */
+ /* 138 */ KEY_Kanji, /* Sun Japanese Kbd: Kanji */
+ /* 139 */ KEY_Execute, /* Sun Japanese Kbd: Execute */
+ /* 140 */ KEY_NOTUSED,
+ /* 141 */ KEY_NOTUSED,
+ /* 142 */ KEY_NOTUSED,
+ /* 143 */ KEY_NOTUSED,
+ /* 144 */ KEY_NOTUSED,
+ /* 145 */ KEY_NOTUSED,
+ /* 146 */ KEY_NOTUSED,
+ /* 147 */ KEY_NOTUSED,
+ /* 148 */ KEY_NOTUSED,
+ /* 149 */ KEY_NOTUSED,
+ /* 150 */ KEY_NOTUSED,
+ /* 151 */ KEY_NOTUSED,
+ /* 152 */ KEY_NOTUSED,
+ /* 153 */ KEY_NOTUSED,
+ /* 154 */ KEY_NOTUSED,
+ /* 155 */ KEY_NOTUSED,
+ /* 156 */ KEY_NOTUSED,
+ /* 157 */ KEY_NOTUSED,
+ /* 158 */ KEY_NOTUSED,
+ /* 159 */ KEY_NOTUSED,
+ /* 160 */ KEY_NOTUSED,
+ /* 161 */ KEY_NOTUSED,
+ /* 162 */ KEY_NOTUSED,
+ /* 163 */ KEY_NOTUSED,
+ /* 164 */ KEY_NOTUSED,
+ /* 165 */ KEY_NOTUSED,
+ /* 166 */ KEY_NOTUSED,
+ /* 167 */ KEY_NOTUSED,
+ /* 168 */ KEY_NOTUSED,
+ /* 169 */ KEY_NOTUSED,
+ /* 170 */ KEY_NOTUSED,
+ /* 171 */ KEY_NOTUSED,
+ /* 172 */ KEY_NOTUSED,
+ /* 173 */ KEY_NOTUSED,
+ /* 174 */ KEY_NOTUSED,
+ /* 175 */ KEY_NOTUSED,
+ /* 176 */ KEY_NOTUSED,
+ /* 177 */ KEY_NOTUSED,
+ /* 178 */ KEY_NOTUSED,
+ /* 179 */ KEY_NOTUSED,
+ /* 180 */ KEY_NOTUSED,
+ /* 181 */ KEY_NOTUSED,
+ /* 182 */ KEY_NOTUSED,
+ /* 183 */ KEY_NOTUSED,
+ /* 184 */ KEY_NOTUSED,
+ /* 185 */ KEY_NOTUSED,
+ /* 186 */ KEY_NOTUSED,
+ /* 187 */ KEY_NOTUSED,
+ /* 188 */ KEY_NOTUSED,
+ /* 189 */ KEY_NOTUSED,
+ /* 190 */ KEY_NOTUSED,
+ /* 191 */ KEY_NOTUSED,
+ /* 192 */ KEY_NOTUSED,
+ /* 193 */ KEY_NOTUSED,
+ /* 194 */ KEY_NOTUSED,
+ /* 195 */ KEY_NOTUSED,
+ /* 196 */ KEY_NOTUSED,
+ /* 197 */ KEY_NOTUSED,
+ /* 198 */ KEY_NOTUSED,
+ /* 199 */ KEY_NOTUSED,
+ /* 200 */ KEY_NOTUSED,
+ /* 201 */ KEY_NOTUSED,
+ /* 202 */ KEY_NOTUSED,
+ /* 203 */ KEY_NOTUSED,
+ /* 204 */ KEY_NOTUSED,
+ /* 205 */ KEY_NOTUSED,
+ /* 206 */ KEY_NOTUSED,
+ /* 207 */ KEY_NOTUSED,
+ /* 208 */ KEY_NOTUSED,
+ /* 209 */ KEY_NOTUSED,
+ /* 210 */ KEY_NOTUSED,
+ /* 211 */ KEY_NOTUSED,
+ /* 212 */ KEY_NOTUSED,
+ /* 213 */ KEY_NOTUSED,
+ /* 214 */ KEY_NOTUSED,
+ /* 215 */ KEY_NOTUSED,
+ /* 216 */ KEY_NOTUSED,
+ /* 217 */ KEY_NOTUSED,
+ /* 218 */ KEY_NOTUSED,
+ /* 219 */ KEY_NOTUSED,
+ /* 220 */ KEY_NOTUSED,
+ /* 221 */ KEY_NOTUSED,
+ /* 222 */ KEY_NOTUSED,
+ /* 223 */ KEY_NOTUSED,
+ /* 224 */ KEY_LCtrl, /* Left Control */
+ /* 225 */ KEY_ShiftL, /* Left Shift */
+ /* 226 */ KEY_Alt, /* Left Alt */
+ /* 227 */ KEY_LMeta, /* Left Meta */
+ /* 228 */ KEY_RCtrl, /* Right Control */
+ /* 229 */ KEY_ShiftR, /* Right Shift */
+ /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */
+ /* 231 */ KEY_RMeta, /* Right Meta */
+};
+
+#endif /* KB_USB */
+
+_X_HIDDEN const unsigned char *
+sunGetKbdMapping(int ktype) {
+#if defined(KB_USB)
+ if (ktype == KB_USB)
+ return usbmap;
+ else
+#endif
+ return map;
+}
+
+
+/*
+ * 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
+ */
+
+_X_HIDDEN void
+sunPostKbdEvent(int sun_ktype, 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;
+
+
+#if defined(KB_USB)
+ if(sun_ktype == KB_USB)
+ keycode = usbmap[event->id];
+ else
+#endif
+ keycode = map[event->id];
+
+ /*
+ * and now get some special keysequences
+ */
+
+#ifdef XKB
+ if (((xf86Info.ddxSpecialKeys == SKWhenNeeded) &&
+ (!xf86Info.ActionKeyBindingsSet)) ||
+ noXkbExtension || (xf86Info.ddxSpecialKeys == SKAlways))
+#endif
+ {
+ if (!(ModifierDown(ShiftMask)) &&
+ ((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:
+ xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
+ break;
+
+ /*
+ * Check grabs
+ */
+ case KEY_KP_Divide:
+ xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
+ break;
+ case KEY_KP_Multiply:
+ xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
+ break;
+
+ /*
+ * Video mode switches
+ */
+ case KEY_KP_Minus: /* Keypad - */
+ if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
+ if (!xf86Info.dontZoom) return;
+ break;
+
+ case KEY_KP_Plus: /* Keypad + */
+ if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
+ if (!xf86Info.dontZoom) 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);
+}
+
+
+
+/*
+ * 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/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c
new file mode 100644
index 000000000..928609f0e
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c
@@ -0,0 +1,719 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.4 2002/01/25 21:56:21 tsi Exp $ */
+/* $XdotOrg: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_mouse.c,v 1.8 2005/07/28 02:38:23 alanc 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.
+ */
+/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSlib.h"
+#include "xf86OSmouse.h"
+
+#if defined(__SOL8__) || !defined(__i386)
+
+#include "xisb.h"
+#include "mipointer.h"
+#include <sys/stropts.h>
+#include <sys/vuid_event.h>
+#include <sys/msio.h>
+
+/* Wheel mouse support in VUID drivers in Solaris 9 updates & Solaris 10 */
+#ifdef WHEEL_DEVID /* Defined in vuid_event.h if VUID wheel support present */
+# define HAVE_VUID_WHEEL
+#endif
+#ifdef HAVE_VUID_WHEEL
+# include <sys/vuid_wheel.h>
+#endif
+
+/* Support for scaling absolute coordinates to screen size in
+ * Solaris 10 updates and beyond */
+#if !defined(HAVE_ABSOLUTE_MOUSE_SCALING)
+# ifdef MSIOSRESOLUTION /* Defined in msio.h if scaling support present */
+# define HAVE_ABSOLUTE_MOUSE_SCALING
+# endif
+#endif
+
+/* Names of protocols that are handled internally here. */
+
+static const char *internalNames[] = {
+ "VUID",
+ NULL
+};
+
+static const char *solarisMouseDevs[] = {
+ /* Device file: Protocol: */
+ "/dev/mouse", "VUID", /* USB or SPARC */
+#if defined(__i386) || defined(__x86)
+ "/dev/kdmouse", "PS/2", /* PS/2 */
+#endif
+ NULL
+};
+
+typedef struct _VuidMseRec {
+ struct _VuidMseRec *next;
+ InputInfoPtr pInfo;
+ Firm_event event;
+ unsigned char * buffer;
+ char * strmod;
+ Bool(*wrapped_device_control)(DeviceIntPtr device, int what);
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ Ms_screen_resolution absres;
+#endif
+} VuidMseRec, *VuidMsePtr;
+
+static VuidMsePtr vuidMouseList = NULL;
+
+static int vuidMouseProc(DeviceIntPtr pPointer, int what);
+static void vuidReadInput(InputInfoPtr pInfo);
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
+static void vuidMouseAdjustFrame(int index, int x, int y, int flags);
+
+static int vuidMouseGeneration = 0;
+static int vuidMouseScreenIndex;
+#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr)
+#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
+
+static inline
+VuidMsePtr getVuidMsePriv(InputInfoPtr pInfo)
+{
+ VuidMsePtr m = vuidMouseList;
+
+ while ((m != NULL) && (m->pInfo != pInfo)) {
+ m = m->next;
+ }
+
+ return m;
+}
+
+
+/*
+ * Initialize and enable the mouse wheel, if present.
+ *
+ * Returns 1 if mouse wheel was successfully enabled.
+ * Returns 0 if an error occurred or if there is no mouse wheel.
+ */
+static int
+vuidMouseWheelInit(InputInfoPtr pInfo)
+{
+#ifdef HAVE_VUID_WHEEL
+ wheel_state wstate;
+ int nwheel = -1;
+ int i;
+
+ wstate.vers = VUID_WHEEL_STATE_VERS;
+ wstate.id = 0;
+ wstate.stateflags = -1;
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELCOUNT, &nwheel));
+ if (i != 0)
+ return (0);
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDGWHEELSTATE, &wstate));
+ if (i != 0) {
+ xf86Msg(X_WARNING, "%s: couldn't get wheel state\n", pInfo->name);
+ return (0);
+ }
+
+ wstate.stateflags |= VUID_WHEEL_STATE_ENABLED;
+
+ SYSCALL(i = ioctl(pInfo->fd, VUIDSWHEELSTATE, &wstate));
+ if (i != 0) {
+ xf86Msg(X_WARNING, "%s: couldn't enable wheel\n", pInfo->name);
+ return (0);
+ }
+
+ return (1);
+#else
+ return (0);
+#endif
+}
+
+
+/* This function is called when the protocol is "VUID". */
+static Bool
+vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ MouseDevPtr pMse = pInfo->private;
+ VuidMsePtr pVuidMse;
+ int buttons, i;
+
+ pVuidMse = xcalloc(sizeof(VuidMseRec), 1);
+ if (pVuidMse == NULL) {
+ xf86Msg(X_ERROR, "%s: cannot allocate VuidMouseRec\n", pInfo->name);
+ xfree(pMse);
+ return FALSE;
+ }
+
+ pMse->protocol = protocol;
+ xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
+
+ /* Collect the options, and process the common options. */
+ xf86CollectInputOptions(pInfo, NULL, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ /* Check if the device can be opened. */
+ pInfo->fd = xf86OpenSerial(pInfo->options);
+ if (pInfo->fd == -1) {
+ if (xf86GetAllowMouseOpenFail())
+ xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name);
+ else {
+ xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
+ xfree(pVuidMse);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+
+ pVuidMse->buffer = (unsigned char *)&pVuidMse->event;
+
+ pVuidMse->strmod = xf86SetStrOption(pInfo->options, "StreamsModule", NULL);
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+ if (i < 0) {
+ xf86Msg(X_ERROR,
+ "%s: cannot push module '%s' onto mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ xfree(pVuidMse->strmod);
+ xfree(pVuidMse);
+ xfree(pMse);
+ return FALSE;
+ }
+ }
+
+ buttons = xf86SetIntOption(pInfo->options, "Buttons", 0);
+ if (buttons == 0) {
+ SYSCALL(i = ioctl(pInfo->fd, MSIOBUTTONS, &buttons));
+ if (i == 0) {
+ pInfo->conf_idev->commonOptions =
+ xf86ReplaceIntOption(pInfo->conf_idev->commonOptions,
+ "Buttons", buttons);
+ xf86Msg(X_INFO, "%s: Setting Buttons option to \"%d\"\n",
+ pInfo->name, buttons);
+ }
+ }
+
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+ if (i == -1) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
+ }
+
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pVuidMse->wrapped_device_control = pInfo->device_control;
+ pInfo->device_control = vuidMouseProc;
+ pInfo->read_input = vuidReadInput;
+
+ pMse->xisbscale = sizeof(Firm_event);
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ pVuidMse->absres.height = pVuidMse->absres.width = 0;
+#endif
+ pVuidMse->pInfo = pInfo;
+ pVuidMse->next = vuidMouseList;
+ vuidMouseList = pVuidMse;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+static void
+vuidFlushAbsEvents(InputInfoPtr pInfo, int absX, int absY,
+ Bool *absXset, Bool *absYset)
+{
+#ifdef DEBUG
+ ErrorF("vuidFlushAbsEvents: %d,%d (set: %d, %d)\n", absX, absY,
+ *absXset, *absYset);
+#endif
+ if ((*absXset) && (*absYset)) {
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 0,
+ /* num_valuators: */ 2,
+ absX, absY);
+ } else if (*absXset) {
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 0,
+ /* num_valuators: */ 1,
+ absX);
+ } else if (*absYset) {
+ xf86PostMotionEvent(pInfo->dev,
+ /* is_absolute: */ TRUE,
+ /* first_valuator: */ 1,
+ /* num_valuators: */ 1,
+ absY);
+ }
+
+ *absXset = FALSE;
+ *absYset = FALSE;
+}
+
+static void
+vuidReadInput(InputInfoPtr pInfo)
+{
+ MouseDevPtr pMse;
+ VuidMsePtr pVuidMse;
+ int buttons;
+ int dx = 0, dy = 0, dz = 0, dw = 0;
+ unsigned int n;
+ int c;
+ unsigned char *pBuf;
+ int wmask;
+ int absX, absY;
+ Bool absXset = FALSE, absYset = FALSE;
+
+ pMse = pInfo->private;
+ pVuidMse = getVuidMsePriv(pInfo);
+ buttons = pMse->lastButtons;
+ XisbBlockDuration(pMse->buffer, -1);
+ pBuf = pVuidMse->buffer;
+ n = 0;
+
+ do {
+ while (n < sizeof(Firm_event) && (c = XisbRead(pMse->buffer)) >= 0) {
+ pBuf[n++] = (unsigned char)c;
+ }
+
+ if (n == 0)
+ return;
+
+ if (n != sizeof(Firm_event)) {
+ xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n",
+ pInfo->name, n);
+ }
+
+#ifdef DEBUG
+ ErrorF("vuidReadInput: event type: %3d value: %5d\n",
+ pVuidMse->event.id, pVuidMse->event.value);
+#endif
+
+ if (pVuidMse->event.id >= BUT_FIRST && pVuidMse->event.id <= BUT_LAST) {
+ /* button */
+ int butnum = pVuidMse->event.id - BUT_FIRST;
+
+ if (butnum < 3)
+ butnum = 2 - butnum;
+ if (!pVuidMse->event.value)
+ buttons &= ~(1 << butnum);
+ else
+ buttons |= (1 << butnum);
+ } else if (pVuidMse->event.id >= VLOC_FIRST &&
+ pVuidMse->event.id <= VLOC_LAST) {
+ /* axis */
+ int delta = pVuidMse->event.value;
+ switch(pVuidMse->event.id) {
+ case LOC_X_DELTA:
+ dx += delta;
+ break;
+ case LOC_Y_DELTA:
+ dy -= delta;
+ break;
+ case LOC_X_ABSOLUTE:
+ if (absXset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+ absX = delta;
+ absXset = TRUE;
+ break;
+ case LOC_Y_ABSOLUTE:
+ if (absYset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+ absY = delta;
+ absYset = TRUE;
+ break;
+ }
+ }
+#ifdef HAVE_VUID_WHEEL
+ else if (vuid_in_range(VUID_WHEEL, pVuidMse->event.id)) {
+ if (vuid_id_offset(pVuidMse->event.id) == 0)
+ dz -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ else
+ dw -= VUID_WHEEL_GETDELTA(pVuidMse->event.value);
+ }
+#endif
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) {
+ /* force sending absolute resolution scaling ioctl */
+ pVuidMse->absres.height = pVuidMse->absres.width = 0;
+ vuidMouseSendScreenSize(miPointerCurrentScreen(), pVuidMse);
+ }
+#endif
+
+ n = 0;
+ if ((c = XisbRead(pMse->buffer)) >= 0) {
+ /* Another packet. Handle it right away. */
+ pBuf[n++] = c;
+ }
+ } while (n != 0);
+
+ if (absXset || absYset) {
+ vuidFlushAbsEvents(pInfo, absX, absY, &absXset, &absYset);
+ }
+
+ pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+ return;
+}
+
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse)
+{
+ InputInfoPtr pInfo = pVuidMse->pInfo;
+ ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
+ int result;
+
+ if ((pVuidMse->absres.width != pScr->currentMode->HDisplay) ||
+ (pVuidMse->absres.height != pScr->currentMode->VDisplay))
+ {
+ pVuidMse->absres.width = pScr->currentMode->HDisplay;
+ pVuidMse->absres.height = pScr->currentMode->VDisplay;
+
+ do {
+ result = ioctl(pInfo->fd, MSIOSRESOLUTION, &(pVuidMse->absres));
+ } while ( (result != 0) && (errno == EINTR) );
+
+ if (result != 0) {
+ xf86Msg(X_WARNING,
+ "%s: couldn't set absolute mouse scaling resolution: %s\n",
+ pInfo->name, strerror(errno));
+#ifdef DEBUG
+ } else {
+ xf86Msg(X_INFO,
+ "%s: absolute mouse scaling resolution set to %d x %d\n",
+ pInfo->name,
+ pVuidMse->absres.width, pVuidMse->absres.height);
+#endif
+ }
+ }
+}
+
+static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[index];
+ ScreenPtr pScreen = pScrn->pScreen;
+ xf86AdjustFrameProc *wrappedAdjustFrame
+ = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen);
+ VuidMsePtr m;
+
+ if(wrappedAdjustFrame) {
+ pScrn->AdjustFrame = wrappedAdjustFrame;
+ (*pScrn->AdjustFrame)(index, x, y, flags);
+ pScrn->AdjustFrame = vuidMouseAdjustFrame;
+ }
+
+ if (miPointerCurrentScreen() == pScreen) {
+ for (m = vuidMouseList; m != NULL ; m = m->next) {
+ vuidMouseSendScreenSize(pScreen, m);
+ }
+ }
+}
+#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
+
+
+static int
+vuidMouseProc(DeviceIntPtr pPointer, int what)
+{
+ InputInfoPtr pInfo;
+ MouseDevPtr pMse;
+ VuidMsePtr pVuidMse;
+ int ret = Success;
+ int i;
+
+ pInfo = pPointer->public.devicePrivate;
+ pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ pVuidMse = getVuidMsePriv(pInfo);
+ if (pVuidMse == NULL) {
+ return BadImplementation;
+ }
+
+ switch (what) {
+
+ case DEVICE_INIT:
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ if (vuidMouseGeneration != serverGeneration) {
+ if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) {
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ ScreenPtr pScreen = screenInfo.screens[i];
+ ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
+ vuidMouseScreenPrivate(pScreen)
+ = (pointer) pScrn->AdjustFrame;
+ pScrn->AdjustFrame = vuidMouseAdjustFrame;
+ }
+ }
+ vuidMouseGeneration = serverGeneration;
+ }
+#endif
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
+
+ case DEVICE_ON:
+ ret = pVuidMse->wrapped_device_control(pPointer, DEVICE_ON);
+
+ if ((ret == Success) && (pInfo->fd != -1)) {
+ int fmt = VUID_FIRM_EVENT;
+
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_PUSH, pVuidMse->strmod));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot push module '%s' onto mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ xfree(pVuidMse->strmod);
+ pVuidMse->strmod = NULL;
+ }
+ }
+ SYSCALL(i = ioctl(pInfo->fd, VUIDSFORMAT, &fmt));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "%s: cannot set mouse device to VUID mode: %s\n",
+ pInfo->name, strerror(errno));
+ }
+ vuidMouseWheelInit(pInfo);
+#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
+ vuidMouseSendScreenSize(screenInfo.screens[0], pVuidMse);
+#endif
+ xf86FlushInput(pInfo->fd);
+ }
+ break;
+
+ case DEVICE_OFF:
+ case DEVICE_CLOSE:
+ if (pInfo->fd != -1) {
+ if (pVuidMse->strmod) {
+ SYSCALL(i = ioctl(pInfo->fd, I_POP, pVuidMse->strmod));
+ if (i == -1) {
+ xf86Msg(X_WARNING,
+ "%s: cannot pop module '%s' off mouse device: %s\n",
+ pInfo->name, pVuidMse->strmod, strerror(errno));
+ }
+ }
+ }
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
+
+ default: /* Should never be called, but just in case */
+ ret = pVuidMse->wrapped_device_control(pPointer, what);
+ break;
+ }
+ return ret;
+}
+
+static Bool
+sunMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ /* The protocol is guaranteed to be one of the internalNames[] */
+ if (xf86NameCmp(protocol, "VUID") == 0) {
+ return vuidPreInit(pInfo, protocol, flags);
+ }
+ return TRUE;
+}
+
+static const char **
+BuiltinNames(void)
+{
+ return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+ int i;
+
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+
+ return FALSE;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+ return "Auto";
+}
+
+static Bool
+solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
+ const char **device)
+{
+ const char **pdev, **pproto, *dev = NULL;
+ int fd = -1;
+ Bool found;
+
+ for (pdev = solarisMouseDevs; *pdev; pdev += 2) {
+ pproto = pdev + 1;
+ if ((*protocol != NULL) && (strcmp(*protocol, "Auto") != 0) &&
+ (*pproto != NULL) && (strcmp(*pproto, *protocol) != 0)) {
+ continue;
+ }
+ if ((*device != NULL) && (strcmp(*device, *pdev) != 0)) {
+ continue;
+ }
+ SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+ if (fd == -1) {
+#ifdef DEBUG
+ ErrorF("Cannot open %s (%s)\n", pdev, strerror(errno));
+#endif
+ } else {
+ found = TRUE;
+ if ((*pproto != NULL) && (strcmp(*pproto, "VUID") == 0)) {
+ int i, r;
+ SYSCALL(r = ioctl(fd, VUIDGFORMAT, &i));
+ if (r < 0) {
+ found = FALSE;
+ }
+ }
+ close(fd);
+ if (found == TRUE) {
+ if (*pproto != NULL) {
+ *protocol = *pproto;
+ }
+ *device = *pdev;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+ const char *pdev = NULL;
+ const char *pproto = NULL;
+ MouseDevPtr pMse = pInfo->private;
+
+ if (pInfo->fd == -1) {
+ /* probe to find device/protocol to use */
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, pdev);
+ }
+ } else if (pMse->protocolID == PROT_AUTO) {
+ pdev = xf86CheckStrOption(pInfo->conf_idev->commonOptions,
+ "Device", NULL);
+ solarisMouseAutoProbe(pInfo, &pproto, &pdev);
+ }
+ return pproto;
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+ const char *pdev = NULL;
+ const char *pproto = protocol;
+
+ if (solarisMouseAutoProbe(pInfo, &pproto, &pdev) != FALSE) {
+ /* Set the Device option. */
+ pInfo->conf_idev->commonOptions =
+ xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", pdev);
+ xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+ pInfo->name, pdev);
+ }
+ return pdev;
+}
+
+#else /* __SOL8__ || !__i386 */
+
+#undef MSE_MISC
+#define MSE_MISC 0
+
+#endif /* !__SOL8__ && __i386 */
+
+static int
+SupportedInterfaces(void)
+{
+ /* XXX This needs to be checked. */
+ return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_XPS2 | MSE_MISC;
+}
+
+OSMouseInfoPtr
+xf86OSMouseInit(int flags)
+{
+ OSMouseInfoPtr p;
+
+ p = xcalloc(sizeof(OSMouseInfoRec), 1);
+ if (!p)
+ return NULL;
+ p->SupportedInterfaces = SupportedInterfaces;
+#if defined(__SOL8__) || !defined(__i386)
+ p->BuiltinNames = BuiltinNames;
+ p->CheckProtocol = CheckProtocol;
+ p->PreInit = sunMousePreInit;
+ p->DefaultProtocol = DefaultProtocol;
+ p->SetupAuto = SetupAuto;
+ p->FindDevice = FindDevice;
+#endif
+ return p;
+}
+
diff --git a/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c
new file mode 100644
index 000000000..82cd1ae7b
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c
@@ -0,0 +1,237 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_vid.c,v 1.2 2001/10/28 03:34:03 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 HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/types.h> /* get __x86 definition if not set by compiler */
+
+#if defined(i386) || defined(__x86)
+#define _NEED_SYSI86
+#endif
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+char *apertureDevName = NULL;
+
+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 */
+/***************************************************************************/
+
+#if defined(i386) || defined(__x86)
+static Bool ExtendedEnabled = FALSE;
+#endif
+
+Bool
+xf86EnableIO(void)
+{
+#if defined(i386) || defined(__x86)
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: Failed to set IOPL for I/O\n");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+#endif /* i386 */
+ return TRUE;
+}
+
+void
+xf86DisableIO(void)
+{
+#if defined(i386) || defined(__x86)
+ if(!ExtendedEnabled)
+ return;
+
+ sysi86(SI86V86, V86SC_IOPL, 0);
+
+ ExtendedEnabled = FALSE;
+#endif /* i386 */
+}
+
+
+/***************************************************************************/
+/* Interrupt Handling section */
+/***************************************************************************/
+
+Bool xf86DisableInterrupts(void)
+{
+#if defined(i386) || defined(__x86)
+ if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
+ return FALSE;
+
+#ifdef __GNUC__
+ __asm__ __volatile__("cli");
+#else
+ asm("cli");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ sysi86(SI86V86, V86SC_IOPL, 0);
+#endif /* i386 */
+
+ return TRUE;
+}
+
+void xf86EnableInterrupts(void)
+{
+#if defined(i386) || defined(__x86)
+ if (!ExtendedEnabled && (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0))
+ return;
+
+#ifdef __GNUC__
+ __asm__ __volatile__("sti");
+#else
+ asm("sti");
+#endif /* __GNUC__ */
+
+ if (!ExtendedEnabled)
+ sysi86(SI86V86, V86SC_IOPL, 0);
+#endif /* i386 */
+}
+
+void
+xf86MapReadSideEffects(int ScreenNum, int Flags, pointer Base,
+ unsigned long Size)
+{
+}
+
+Bool
+xf86CheckMTRR(int ScreenNum)
+{
+ return FALSE;
+}
+