diff options
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/bsd')
27 files changed, 8352 insertions, 0 deletions
diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.am b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am new file mode 100644 index 000000000..4fc270aa9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.am @@ -0,0 +1,86 @@ +noinst_LTLIBRARIES = libbsd.la + +# FIXME: Add USB mouse support? + +# FIXME: APM support. +APM_SOURCES = $(srcdir)/../shared/pm_noop.c + +if FREEBSD_KLDLOAD +KMOD_SOURCES = bsd_kmod.c +else +KMOD_SOURCES = $(srcdir)/../shared/kmod_noop.c +endif + +# FIXME: Non-i386/ia64 resource support. +RES_SOURCES = $(srcdir)/../shared/stdResource.c + +if AGP +AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c +else +AGP_SOURCES = $(srcdir)/../shared/agp_noop.c +endif + +if ALPHA_VIDEO +# Cheat here and piggyback other alpha bits on ALPHA_VIDEO. +ARCH_SOURCES = \ + alpha_video.c \ + bsd_ev56.c \ + bsd_axp.c \ + $(srcdir)/../shared/xf86Axp.c +endif + +if ARM_VIDEO +ARCH_SOURCES = arm_video.c +endif + +if I386_VIDEO +ARCH_SOURCES = i386_video.c +endif + +if PPC_VIDEO +ARCH_SOURCES = ppc_video.c +endif + +if SPARC64_VIDEO +# Cheat here and piggyback other sparc64 bits on SPARC64_VIDEO. +ARCH_SOURCES = \ + sparc64_video.c \ + $(srcdir)/../shared/ioperm_noop.c +endif + +# FIXME: NetBSD Aperture defines (configure.ac) +AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS) + +INCLUDES = $(XORG_INCS) + +libbsd_la_SOURCES = \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c \ + $(srcdir)/../shared/vidmem.c \ + bsd_VTsw.c \ + bsd_init.c \ + bsd_mouse.c \ + bsd_bell.c \ + $(ARCH_SOURCES) \ + $(AGP_SOURCES) \ + $(APM_SOURCES) \ + $(AXP_SOURCES) \ + $(DRI_SOURCES) \ + $(KMOD_SOURCES) \ + $(RES_SOURCES) + +# FIXME: Add these files to the build as needed +EXTRA_DIST = \ + bsd_apm.c \ + bsd_jstk.c \ + bsd_kqueue_apm.c \ + bsdResource.c \ + memrange.h \ + libusb/data.c \ + libusb/descr.c \ + libusb/parse.c \ + libusb/usage.c \ + libusb/usb.3 \ + libusb/usb.h \ + libusb/usb_hid_usages \ + libusb/usbvar.h diff --git a/xorg-server/hw/xfree86/os-support/bsd/Makefile.in b/xorg-server/hw/xfree86/os-support/bsd/Makefile.in new file mode 100644 index 000000000..d59e73c87 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/Makefile.in @@ -0,0 +1,822 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = hw/xfree86/os-support/bsd +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \ + $(top_builddir)/include/xorg-server.h \ + $(top_builddir)/include/dix-config.h \ + $(top_builddir)/include/xgl-config.h \ + $(top_builddir)/include/xorg-config.h \ + $(top_builddir)/include/xkb-config.h \ + $(top_builddir)/include/xwin-config.h \ + $(top_builddir)/include/kdrive-config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libbsd_la_LIBADD = +am__libbsd_la_SOURCES_DIST = $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c $(srcdir)/../shared/vidmem.c \ + bsd_VTsw.c bsd_init.c bsd_mouse.c bsd_bell.c alpha_video.c \ + bsd_ev56.c bsd_axp.c $(srcdir)/../shared/xf86Axp.c arm_video.c \ + i386_video.c ppc_video.c sparc64_video.c \ + $(srcdir)/../shared/ioperm_noop.c \ + $(srcdir)/../shared/agp_noop.c $(srcdir)/../linux/lnx_agp.c \ + $(srcdir)/../shared/pm_noop.c $(srcdir)/../shared/kmod_noop.c \ + bsd_kmod.c $(srcdir)/../shared/stdResource.c +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@am__objects_1 = sparc64_video.lo \ +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_FALSE@@SPARC64_VIDEO_TRUE@ ioperm_noop.lo +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_FALSE@@PPC_VIDEO_TRUE@am__objects_1 = ppc_video.lo +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_FALSE@@I386_VIDEO_TRUE@am__objects_1 = i386_video.lo +@ALPHA_VIDEO_FALSE@@ARM_VIDEO_TRUE@am__objects_1 = arm_video.lo +@ALPHA_VIDEO_TRUE@am__objects_1 = alpha_video.lo bsd_ev56.lo \ +@ALPHA_VIDEO_TRUE@ bsd_axp.lo xf86Axp.lo +@AGP_FALSE@am__objects_2 = agp_noop.lo +@AGP_TRUE@am__objects_2 = lnx_agp.lo +am__objects_3 = pm_noop.lo +@FREEBSD_KLDLOAD_FALSE@am__objects_4 = kmod_noop.lo +@FREEBSD_KLDLOAD_TRUE@am__objects_4 = bsd_kmod.lo +am__objects_5 = stdResource.lo +am_libbsd_la_OBJECTS = posix_tty.lo sigio.lo vidmem.lo bsd_VTsw.lo \ + bsd_init.lo bsd_mouse.lo bsd_bell.lo $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) +libbsd_la_OBJECTS = $(am_libbsd_la_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libbsd_la_SOURCES) +DIST_SOURCES = $(am__libbsd_la_SOURCES_DIST) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ADMIN_MAN_DIR = @ADMIN_MAN_DIR@ +ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@ +ALLOCA = @ALLOCA@ +AMTAR = @AMTAR@ +APPDEFAULTDIR = @APPDEFAULTDIR@ +APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@ +APP_MAN_DIR = @APP_MAN_DIR@ +APP_MAN_SUFFIX = @APP_MAN_SUFFIX@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BASE_FONT_PATH = @BASE_FONT_PATH@ +BUILD_DATE = @BUILD_DATE@ +BUILD_TIME = @BUILD_TIME@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DARWIN_LIBS = @DARWIN_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@ +DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@ +DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DGA_CFLAGS = @DGA_CFLAGS@ +DGA_LIBS = @DGA_LIBS@ +DIX_CFLAGS = @DIX_CFLAGS@ +DLLTOOL = @DLLTOOL@ +DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@ +DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@ +DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@ +DMXMODULES_LIBS = @DMXMODULES_LIBS@ +DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@ +DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@ +DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@ +DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@ +DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ +DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ +DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@ +DRIPROTO_LIBS = @DRIPROTO_LIBS@ +DRIVER_MAN_DIR = @DRIVER_MAN_DIR@ +DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@ +DRI_DRIVER_PATH = @DRI_DRIVER_PATH@ +DSYMUTIL = @DSYMUTIL@ +DTRACE = @DTRACE@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +FILE_MAN_DIR = @FILE_MAN_DIR@ +FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@ +GLX_DEFINES = @GLX_DEFINES@ +GL_CFLAGS = @GL_CFLAGS@ +GL_LIBS = @GL_LIBS@ +GREP = @GREP@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KDRIVE_CFLAGS = @KDRIVE_CFLAGS@ +KDRIVE_INCS = @KDRIVE_INCS@ +KDRIVE_LIBS = @KDRIVE_LIBS@ +KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@ +KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@ +KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@ +LAUNCHD = @LAUNCHD@ +LDFLAGS = @LDFLAGS@ +LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ +LIBDRM_LIBS = @LIBDRM_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIB_MAN_DIR = @LIB_MAN_DIR@ +LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@ +LINUXDOC = @LINUXDOC@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKE_HTML = @MAKE_HTML@ +MAKE_PDF = @MAKE_PDF@ +MAKE_PS = @MAKE_PS@ +MAKE_TEXT = @MAKE_TEXT@ +MESA_SOURCE = @MESA_SOURCE@ +MISC_MAN_DIR = @MISC_MAN_DIR@ +MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@ +MKDIR_P = @MKDIR_P@ +MKFONTDIR = @MKFONTDIR@ +MKFONTSCALE = @MKFONTSCALE@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCCLD = @OBJCCLD@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJCFLAGS = @OBJCFLAGS@ +OBJCLINK = @OBJCLINK@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ +OPENSSL_LIBS = @OPENSSL_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@ +PCIACCESS_LIBS = @PCIACCESS_LIBS@ +PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +PROJECTROOT = @PROJECTROOT@ +PS2PDF = @PS2PDF@ +RANLIB = @RANLIB@ +RAWCPP = @RAWCPP@ +RAWCPPFLAGS = @RAWCPPFLAGS@ +SED = @SED@ +SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@ +SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@ +STRIP = @STRIP@ +TSLIB_CFLAGS = @TSLIB_CFLAGS@ +TSLIB_LIBS = @TSLIB_LIBS@ +UTILS_SYS_LIBS = @UTILS_SYS_LIBS@ +VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@ +VENDOR_NAME = @VENDOR_NAME@ +VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@ +VENDOR_RELEASE = @VENDOR_RELEASE@ +VERSION = @VERSION@ +X11APP_ARCHS = @X11APP_ARCHS@ +X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@ +X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@ +XDMCP_CFLAGS = @XDMCP_CFLAGS@ +XDMCP_LIBS = @XDMCP_LIBS@ +XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@ +XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@ +XDMX_CFLAGS = @XDMX_CFLAGS@ +XDMX_LIBS = @XDMX_LIBS@ +XDMX_SYS_LIBS = @XDMX_SYS_LIBS@ +XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@ +XEGL_LIBS = @XEGL_LIBS@ +XEGL_SYS_LIBS = @XEGL_SYS_LIBS@ +XEPHYR_CFLAGS = @XEPHYR_CFLAGS@ +XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@ +XEPHYR_INCS = @XEPHYR_INCS@ +XEPHYR_LIBS = @XEPHYR_LIBS@ +XF86CONFIGFILE = @XF86CONFIGFILE@ +XF86MISC_CFLAGS = @XF86MISC_CFLAGS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ +XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ +XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@ +XGLMODULES_LIBS = @XGLMODULES_LIBS@ +XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@ +XGLXMODULES_LIBS = @XGLXMODULES_LIBS@ +XGLX_LIBS = @XGLX_LIBS@ +XGLX_SYS_LIBS = @XGLX_SYS_LIBS@ +XGL_LIBS = @XGL_LIBS@ +XGL_MODULE_PATH = @XGL_MODULE_PATH@ +XGL_SYS_LIBS = @XGL_SYS_LIBS@ +XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@ +XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@ +XKB_COMPILED_DIR = @XKB_COMPILED_DIR@ +XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@ +XLIB_CFLAGS = @XLIB_CFLAGS@ +XLIB_LIBS = @XLIB_LIBS@ +XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@ +XNESTMODULES_LIBS = @XNESTMODULES_LIBS@ +XNEST_LIBS = @XNEST_LIBS@ +XNEST_SYS_LIBS = @XNEST_SYS_LIBS@ +XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@ +XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@ +XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@ +XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@ +XORG_CFLAGS = @XORG_CFLAGS@ +XORG_INCS = @XORG_INCS@ +XORG_LIBS = @XORG_LIBS@ +XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@ +XORG_MODULES_LIBS = @XORG_MODULES_LIBS@ +XORG_OS = @XORG_OS@ +XORG_OS_SUBDIR = @XORG_OS_SUBDIR@ +XORG_SYS_LIBS = @XORG_SYS_LIBS@ +XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@ +XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@ +XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@ +XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@ +XPRINT_CFLAGS = @XPRINT_CFLAGS@ +XPRINT_LIBS = @XPRINT_LIBS@ +XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@ +XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@ +XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@ +XSDL_INCS = @XSDL_INCS@ +XSDL_LIBS = @XSDL_LIBS@ +XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@ +XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@ +XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@ +XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@ +XSERVER_LIBS = @XSERVER_LIBS@ +XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@ +XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@ +XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@ +XVFB_LIBS = @XVFB_LIBS@ +XVFB_SYS_LIBS = @XVFB_SYS_LIBS@ +XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@ +XWINMODULES_LIBS = @XWINMODULES_LIBS@ +XWIN_LIBS = @XWIN_LIBS@ +XWIN_SERVER_NAME = @XWIN_SERVER_NAME@ +XWIN_SYS_LIBS = @XWIN_SYS_LIBS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +__XCONFIGFILE__ = @__XCONFIGFILE__@ +abi_ansic = @abi_ansic@ +abi_extension = @abi_extension@ +abi_font = @abi_font@ +abi_videodrv = @abi_videodrv@ +abi_xinput = @abi_xinput@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +driverdir = @driverdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extdir = @extdir@ +ft_config = @ft_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +launchagentsdir = @launchagentsdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +logdir = @logdir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +moduledir = @moduledir@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sdkdir = @sdkdir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +xglmoduledir = @xglmoduledir@ +xpconfigdir = @xpconfigdir@ +noinst_LTLIBRARIES = libbsd.la + +# FIXME: Add USB mouse support? + +# FIXME: APM support. +APM_SOURCES = $(srcdir)/../shared/pm_noop.c +@FREEBSD_KLDLOAD_FALSE@KMOD_SOURCES = $(srcdir)/../shared/kmod_noop.c +@FREEBSD_KLDLOAD_TRUE@KMOD_SOURCES = bsd_kmod.c + +# FIXME: Non-i386/ia64 resource support. +RES_SOURCES = $(srcdir)/../shared/stdResource.c +@AGP_FALSE@AGP_SOURCES = $(srcdir)/../shared/agp_noop.c +@AGP_TRUE@AGP_SOURCES = $(srcdir)/../linux/lnx_agp.c + +# Cheat here and piggyback other alpha bits on ALPHA_VIDEO. +@ALPHA_VIDEO_TRUE@ARCH_SOURCES = \ +@ALPHA_VIDEO_TRUE@ alpha_video.c \ +@ALPHA_VIDEO_TRUE@ bsd_ev56.c \ +@ALPHA_VIDEO_TRUE@ bsd_axp.c \ +@ALPHA_VIDEO_TRUE@ $(srcdir)/../shared/xf86Axp.c + +@ARM_VIDEO_TRUE@ARCH_SOURCES = arm_video.c +@I386_VIDEO_TRUE@ARCH_SOURCES = i386_video.c +@PPC_VIDEO_TRUE@ARCH_SOURCES = ppc_video.c + +# Cheat here and piggyback other sparc64 bits on SPARC64_VIDEO. +@SPARC64_VIDEO_TRUE@ARCH_SOURCES = \ +@SPARC64_VIDEO_TRUE@ sparc64_video.c \ +@SPARC64_VIDEO_TRUE@ $(srcdir)/../shared/ioperm_noop.c + + +# FIXME: NetBSD Aperture defines (configure.ac) +AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS) $(DIX_CFLAGS) +INCLUDES = $(XORG_INCS) +libbsd_la_SOURCES = \ + $(srcdir)/../shared/posix_tty.c \ + $(srcdir)/../shared/sigio.c \ + $(srcdir)/../shared/vidmem.c \ + bsd_VTsw.c \ + bsd_init.c \ + bsd_mouse.c \ + bsd_bell.c \ + $(ARCH_SOURCES) \ + $(AGP_SOURCES) \ + $(APM_SOURCES) \ + $(AXP_SOURCES) \ + $(DRI_SOURCES) \ + $(KMOD_SOURCES) \ + $(RES_SOURCES) + + +# FIXME: Add these files to the build as needed +EXTRA_DIST = \ + bsd_apm.c \ + bsd_jstk.c \ + bsd_kqueue_apm.c \ + bsdResource.c \ + memrange.h \ + libusb/data.c \ + libusb/descr.c \ + libusb/parse.c \ + libusb/usage.c \ + libusb/usb.3 \ + libusb/usb.h \ + libusb/usb_hid_usages \ + libusb/usbvar.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/xfree86/os-support/bsd/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --foreign hw/xfree86/os-support/bsd/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libbsd.la: $(libbsd_la_OBJECTS) $(libbsd_la_DEPENDENCIES) + $(LINK) $(libbsd_la_OBJECTS) $(libbsd_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agp_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alpha_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_VTsw.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_axp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_bell.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_ev56.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_init.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_kmod.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsd_mouse.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioperm_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kmod_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lnx_agp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm_noop.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix_tty.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppc_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigio.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparc64_video.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdResource.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vidmem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xf86Axp.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +posix_tty.lo: $(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT posix_tty.lo -MD -MP -MF $(DEPDIR)/posix_tty.Tpo -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/posix_tty.Tpo $(DEPDIR)/posix_tty.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/posix_tty.c' object='posix_tty.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o posix_tty.lo `test -f '$(srcdir)/../shared/posix_tty.c' || echo '$(srcdir)/'`$(srcdir)/../shared/posix_tty.c + +sigio.lo: $(srcdir)/../shared/sigio.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sigio.lo -MD -MP -MF $(DEPDIR)/sigio.Tpo -c -o sigio.lo `test -f '$(srcdir)/../shared/sigio.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigio.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/sigio.Tpo $(DEPDIR)/sigio.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/sigio.c' object='sigio.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sigio.lo `test -f '$(srcdir)/../shared/sigio.c' || echo '$(srcdir)/'`$(srcdir)/../shared/sigio.c + +vidmem.lo: $(srcdir)/../shared/vidmem.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT vidmem.lo -MD -MP -MF $(DEPDIR)/vidmem.Tpo -c -o vidmem.lo `test -f '$(srcdir)/../shared/vidmem.c' || echo '$(srcdir)/'`$(srcdir)/../shared/vidmem.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/vidmem.Tpo $(DEPDIR)/vidmem.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/vidmem.c' object='vidmem.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vidmem.lo `test -f '$(srcdir)/../shared/vidmem.c' || echo '$(srcdir)/'`$(srcdir)/../shared/vidmem.c + +xf86Axp.lo: $(srcdir)/../shared/xf86Axp.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT xf86Axp.lo -MD -MP -MF $(DEPDIR)/xf86Axp.Tpo -c -o xf86Axp.lo `test -f '$(srcdir)/../shared/xf86Axp.c' || echo '$(srcdir)/'`$(srcdir)/../shared/xf86Axp.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/xf86Axp.Tpo $(DEPDIR)/xf86Axp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/xf86Axp.c' object='xf86Axp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o xf86Axp.lo `test -f '$(srcdir)/../shared/xf86Axp.c' || echo '$(srcdir)/'`$(srcdir)/../shared/xf86Axp.c + +ioperm_noop.lo: $(srcdir)/../shared/ioperm_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ioperm_noop.lo -MD -MP -MF $(DEPDIR)/ioperm_noop.Tpo -c -o ioperm_noop.lo `test -f '$(srcdir)/../shared/ioperm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/ioperm_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/ioperm_noop.Tpo $(DEPDIR)/ioperm_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/ioperm_noop.c' object='ioperm_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ioperm_noop.lo `test -f '$(srcdir)/../shared/ioperm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/ioperm_noop.c + +agp_noop.lo: $(srcdir)/../shared/agp_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT agp_noop.lo -MD -MP -MF $(DEPDIR)/agp_noop.Tpo -c -o agp_noop.lo `test -f '$(srcdir)/../shared/agp_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/agp_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/agp_noop.Tpo $(DEPDIR)/agp_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/agp_noop.c' object='agp_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o agp_noop.lo `test -f '$(srcdir)/../shared/agp_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/agp_noop.c + +lnx_agp.lo: $(srcdir)/../linux/lnx_agp.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lnx_agp.lo -MD -MP -MF $(DEPDIR)/lnx_agp.Tpo -c -o lnx_agp.lo `test -f '$(srcdir)/../linux/lnx_agp.c' || echo '$(srcdir)/'`$(srcdir)/../linux/lnx_agp.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/lnx_agp.Tpo $(DEPDIR)/lnx_agp.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../linux/lnx_agp.c' object='lnx_agp.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lnx_agp.lo `test -f '$(srcdir)/../linux/lnx_agp.c' || echo '$(srcdir)/'`$(srcdir)/../linux/lnx_agp.c + +pm_noop.lo: $(srcdir)/../shared/pm_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pm_noop.lo -MD -MP -MF $(DEPDIR)/pm_noop.Tpo -c -o pm_noop.lo `test -f '$(srcdir)/../shared/pm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/pm_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/pm_noop.Tpo $(DEPDIR)/pm_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/pm_noop.c' object='pm_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pm_noop.lo `test -f '$(srcdir)/../shared/pm_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/pm_noop.c + +kmod_noop.lo: $(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kmod_noop.lo -MD -MP -MF $(DEPDIR)/kmod_noop.Tpo -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/kmod_noop.Tpo $(DEPDIR)/kmod_noop.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/kmod_noop.c' object='kmod_noop.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kmod_noop.lo `test -f '$(srcdir)/../shared/kmod_noop.c' || echo '$(srcdir)/'`$(srcdir)/../shared/kmod_noop.c + +stdResource.lo: $(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stdResource.lo -MD -MP -MF $(DEPDIR)/stdResource.Tpo -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/stdResource.Tpo $(DEPDIR)/stdResource.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/../shared/stdResource.c' object='stdResource.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stdResource.lo `test -f '$(srcdir)/../shared/stdResource.c' || echo '$(srcdir)/'`$(srcdir)/../shared/stdResource.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-exec-am: + +install-html: install-html-am + +install-info: install-info-am + +install-man: + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c new file mode 100644 index 000000000..523c4488e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c @@ -0,0 +1,732 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include <sys/param.h> +#ifndef __NetBSD__ +# include <sys/sysctl.h> +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +# include <machine/sysarch.h> +# endif +# else +# include <machine/sysarch.h> +#endif + +#include "xf86Axp.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +axpDevice bsdGetAXP(void); + +#ifndef __NetBSD__ +extern unsigned long dense_base(void); + +static int axpSystem = -1; +static unsigned long hae_thresh; +static unsigned long hae_mask; +static unsigned long bus_base; +static unsigned long sparse_size; + +static unsigned long +memory_base(void) +{ + static unsigned long base = 0; + + if (base == 0) { + size_t len = sizeof(base); + int error; +#ifdef __OpenBSD__ + int mib[3]; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CHIPSET; + mib[2] = CPU_CHIPSET_MEM; + + if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0) +#else + if ((error = sysctlbyname("hw.chipset.memory", &base, &len, + 0, 0)) < 0) +#endif + FatalError("xf86MapVidMem: can't find memory\n"); + } + + return base; +} + +static int +has_bwx(void) +{ + static int bwx = 0; + size_t len = sizeof(bwx); + int error; +#ifdef __OpenBSD__ + int mib[3]; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CHIPSET; + mib[2] = CPU_CHIPSET_BWX; + + if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0) + return FALSE; + else + return bwx; +#else + if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0) + return FALSE; + else + return bwx; +#endif +} +#else /* __NetBSD__ */ +static unsigned long hae_thresh = (1UL << 24); +static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */ +static struct alpha_bus_window *abw; +static int abw_count = -1; + +static void +init_abw(void) +{ + if (abw_count < 0) { + abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw); + if (abw_count <= 0) + FatalError("init_abw: alpha_bus_getwindows failed\n"); + } +} + +static int +has_bwx(void) +{ + if (abw_count < 0) + init_abw(); + + xf86Msg(X_INFO, "has_bwx = %d\n", + abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */ + return abw[0].abw_abst.abst_flags & ABST_BWX; +} + +static unsigned long +dense_base(void) +{ + if (abw_count < 0) + init_abw(); + + /* XXX check abst_flags for ABST_DENSE just to be safe? */ + xf86Msg(X_INFO, "dense base = %#lx\n", + abw[0].abw_abst.abst_sys_start); /* XXXX */ + return abw[0].abw_abst.abst_sys_start; +} + +static unsigned long +memory_base(void) +{ + if (abw_count < 0) + init_abw(); + + if (abw_count > 0) { + xf86Msg(X_INFO, "memory base = %#lx\n", + abw[1].abw_abst.abst_sys_start); /* XXXX */ + return abw[1].abw_abst.abst_sys_start; + } else { + xf86Msg(X_INFO, "no memory base\n"); /* XXXX */ + return 0; + } +} +#endif /* __NetBSD__ */ + +#define BUS_BASE dense_base() +#define BUS_BASE_BWX memory_base() + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +#ifdef __OpenBSD__ +#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details" +#endif + +static Bool useDevMem = FALSE; +static int devMemFd = -1; + +#ifdef HAS_APERTURE_DRV +#define DEV_APERTURE "/dev/xf86" +#endif +#define DEV_MEM "/dev/mem" + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); +static pointer mapVidMemSparse(int, unsigned long, unsigned long, int); +static void unmapVidMemSparse(int, pointer, unsigned long); + +/* + * Check if /dev/mem can be mmap'd. If it can't print a warning when + * "warn" is TRUE. + */ +static void +checkDevMem(Bool warn) +{ + static Bool devMemChecked = FALSE; + int fd; + pointer base; + + if (devMemChecked) + return; + devMemChecked = TRUE; + +#ifdef HAS_APERTURE_DRV + /* Try the aperture driver first */ + if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); + + if (base != MAP_FAILED) { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", + DEV_APERTURE); + return; + } else { + if (warn) { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_APERTURE, strerror(errno)); + } + } + } +#endif + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); + + if (base != MAP_FAILED) { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + return; + } else { + if (warn) { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + } + } + } + if (warn) { +#ifndef HAS_APERTURE_DRV + xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n", + DEV_MEM, strerror(errno)); +#else +#ifndef __OpenBSD__ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno)); +#else /* __OpenBSD__ */ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno), + SYSCTL_MSG); +#endif /* __OpenBSD__ */ +#endif + xf86ErrorF("\tlinear framebuffer access unavailable\n"); + } + useDevMem = FALSE; + return; +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + checkDevMem(TRUE); + pVidMem->linearSupported = useDevMem; + + if (has_bwx()) { + xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n"); + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + } else { + xf86Msg(X_PROBED,"Machine needs sparse mapping\n"); + pVidMem->mapMem = mapVidMemSparse; + pVidMem->unmapMem = unmapVidMemSparse; +#ifndef __NetBSD__ + if (axpSystem == -1) + axpSystem = bsdGetAXP(); + hae_thresh = xf86AXPParams[axpSystem].hae_thresh; + hae_mask = xf86AXPParams[axpSystem].hae_mask; + sparse_size = xf86AXPParams[axpSystem].size; +#endif /* __NetBSD__ */ + } + pVidMem->initialised = TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + + checkDevMem(FALSE); + Base = Base & ((1L<<32) - 1); + + if (useDevMem) + { + if (devMemFd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); + if (base == MAP_FAILED) + { + FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n", + "xf86MapVidMem", DEV_MEM, Size, Base, + strerror(errno)); + } + return(base); + } + + /* else, mmap /dev/vga */ + if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) + { + FatalError("%s: Address 0x%lx outside allowable range\n", + "xf86MapVidMem", Base); + } + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, xf86Info.screenFd, + (unsigned long)Base + BUS_BASE); + if (base == MAP_FAILED) + { + FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", + strerror(errno)); + } + return(base); +} + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, Size); +} + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + unsigned char *ptr; + int psize; + int mlen; + + checkDevMem(TRUE); + if (devMemFd == -1) { + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); + if ((long)ptr == -1) + { + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); + return(-1); + } +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); +#endif + return(Len); +} + + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) + +extern int ioperm(unsigned long from, unsigned long num, int on); + +_X_EXPORT Bool +xf86EnableIO() +{ + if (!ioperm(0, 65536, TRUE)) + return TRUE; + return FALSE; +} + +_X_EXPORT void +xf86DisableIO() +{ + return; +} + +#endif /* __FreeBSD_kernel__ || __OpenBSD__ */ + +#ifdef USE_ALPHA_PIO + +Bool +xf86EnableIO() +{ + alpha_pci_io_enable(1); + return TRUE; +} + +void +xf86DisableIO() +{ + alpha_pci_io_enable(0); +} + +#endif /* USE_ALPHA_PIO */ + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + return; +} + + +#define vuip volatile unsigned int * + +static unsigned long msb_set = 0; +static pointer memSBase = 0; +static pointer memBase = 0; + +extern int readDense8(pointer Base, register unsigned long Offset); +extern int readDense16(pointer Base, register unsigned long Offset); +extern int readDense32(pointer Base, register unsigned long Offset); +extern void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset); +extern void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset); +extern void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense8(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense16(int Value, pointer Base, register unsigned long Offset); +extern void +writeDense32(int Value, pointer Base, register unsigned long Offset); + +static int readSparse8(pointer Base, register unsigned long Offset); +static int readSparse16(pointer Base, register unsigned long Offset); +static int readSparse32(pointer Base, register unsigned long Offset); +static void +writeSparseNB8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseNB16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparseNB32(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse8(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse16(int Value, pointer Base, register unsigned long Offset); +static void +writeSparse32(int Value, pointer Base, register unsigned long Offset); + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +extern int sysarch(int, void *); +#endif + +struct parms { + u_int64_t hae; +}; + +#ifndef __NetBSD__ +static int +sethae(u_int64_t hae) +{ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#ifndef ALPHA_SETHAE +#define ALPHA_SETHAE 0 +#endif + struct parms p; + p.hae = hae; + return (sysarch(ALPHA_SETHAE, (char *)&p)); +#endif +#ifdef __OpenBSD__ + return -1; +#endif +} +#endif /* __NetBSD__ */ + +static pointer +mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + static Bool was_here = FALSE; + + if (!was_here) { + was_here = TRUE; + + checkDevMem(FALSE); + + xf86WriteMmio8 = writeSparse8; + xf86WriteMmio16 = writeSparse16; + xf86WriteMmio32 = writeSparse32; + xf86WriteMmioNB8 = writeSparseNB8; + xf86WriteMmioNB16 = writeSparseNB16; + xf86WriteMmioNB32 = writeSparseNB32; + xf86ReadMmio8 = readSparse8; + xf86ReadMmio16 = readSparse16; + xf86ReadMmio32 = readSparse32; + + memBase = mmap((caddr_t)0, 0x100000000, + PROT_READ | PROT_WRITE, + MAP_SHARED, devMemFd, + (off_t) BUS_BASE); + memSBase = mmap((caddr_t)0, 0x100000000, + PROT_READ | PROT_WRITE, + MAP_SHARED, devMemFd, + (off_t) BUS_BASE_BWX); + + if (memSBase == MAP_FAILED || memBase == MAP_FAILED) { + FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n", + strerror(errno)); + } + } + return (pointer)((unsigned long)memBase + Base); +} + +static void +unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size) +{ +} + +static int +readSparse8(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + register unsigned long msb; + mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + shift = (Offset & 0x3) << 3; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + result = *(vuip) ((unsigned long)memSBase + (Offset << 5)); + result >>= shift; + return 0xffUL & result; +} + +static int +readSparse16(pointer Base, register unsigned long Offset) +{ + register unsigned long result, shift; + register unsigned long msb; + + mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + shift = (Offset & 0x2) << 3; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))); + result >>= shift; + return 0xffffUL & result; +} + +static int +readSparse32(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(vuip)((unsigned long)Base+(Offset)); +} + +static void +writeSparse8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int b = Value & 0xffU; + + write_mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; +} + +static void +writeSparse16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int w = Value & 0xffffU; + + write_mem_barrier(); + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = + w * 0x00010001; + +} + +static void +writeSparse32(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(vuip)((unsigned long)Base + (Offset)) = Value; + return; +} + +static void +writeSparseNB8(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int b = Value & 0xffU; + + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101; +} + +static void +writeSparseNB16(int Value, pointer Base, register unsigned long Offset) +{ + register unsigned long msb; + register unsigned int w = Value & 0xffffU; + + Offset += (unsigned long)Base - (unsigned long)memBase; + if (Offset >= (hae_thresh)) { + msb = Offset & hae_mask ; + Offset -= msb; + if (msb_set != msb) { +#ifndef __NetBSD__ + sethae(msb); +#endif + msb_set = msb; + } + } + *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) = + w * 0x00010001; +} + +static void +writeSparseNB32(int Value, pointer Base, register unsigned long Offset) +{ + *(vuip)((unsigned long)Base + (Offset)) = Value; + return; +} + +_X_EXPORT void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset) + = writeDense8; +_X_EXPORT void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset) + = writeDense16; +_X_EXPORT void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset) + = writeDense32; +_X_EXPORT void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB8; +_X_EXPORT void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB16; +_X_EXPORT void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset) + = writeDenseNB32; +_X_EXPORT int (*xf86ReadMmio8)(pointer Base, unsigned long Offset) + = readDense8; +_X_EXPORT int (*xf86ReadMmio16)(pointer Base, unsigned long Offset) + = readDense16; +_X_EXPORT int (*xf86ReadMmio32)(pointer Base, unsigned long Offset) + = readDense32; + diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c new file mode 100644 index 000000000..23948b5d6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c @@ -0,0 +1,687 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* + * The ARM32 code here carries the following copyright: + * + * Copyright 1997 + * Digital Equipment Corporation. All rights reserved. + * This software is furnished under license and may be used and copied only in + * accordance with the following terms and conditions. Subject to these + * conditions, you may download, copy, install, use, modify and distribute + * this software in source and/or binary form. No title or ownership is + * transferred hereby. + * + * 1) Any source code used, modified or distributed must reproduce and retain + * this copyright notice and list of conditions as they appear in the + * source file. + * + * 2) No right is granted to use any trade name, trademark, or logo of Digital + * Equipment Corporation. Neither the "Digital Equipment Corporation" + * name nor any trademark or logo of Digital Equipment Corporation may be + * used to endorse or promote products derived from this software without + * the prior written permission of Digital Equipment Corporation. + * + * 3) This software is provided "AS-IS" and any express or implied warranties, + * including but not limited to, any implied warranties of merchantability, + * fitness for a particular purpose, or non-infringement are disclaimed. + * In no event shall DIGITAL be liable for any damages whatsoever, and in + * particular, DIGITAL shall not be liable for special, indirect, + * consequential, or incidental damages or damages for lost profits, loss + * of revenue or loss of use, whether such damages arise in contract, + * negligence, tort, under statute, in equity, at law or otherwise, even + * if advised of the possibility of such damage. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifdef __arm32__ +#include "machine/devmap.h" +struct memAccess +{ + int ioctl; + struct map_info memInfo; + pointer regionVirtBase; + Bool Checked; + Bool OK; +}; + +static pointer xf86MapInfoMap(); +static void xf86MapInfoUnmap(); +static struct memAccess *checkMapInfo(); +extern int vgaPhysLinearBase; + +/* A memAccess structure is needed for each possible region */ +struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL, + FALSE, FALSE }; +struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL, + FALSE, FALSE }; +struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL, + FALSE, FALSE }; +#endif /* __arm32__ */ + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + + +#define BUS_BASE 0L +#define BUS_BASE_BWX 0L + + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static Bool useDevMem = FALSE; +static int devMemFd = -1; + +#define DEV_MEM "/dev/mem" + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); + +/* + * Check if /dev/mem can be mmap'd. If it can't print a warning when + * "warn" is TRUE. + */ +static void +checkDevMem(Bool warn) +{ + static Bool devMemChecked = FALSE; + int fd; + pointer base; + + if (devMemChecked) + return; + devMemChecked = TRUE; + + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) + { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE); + + if (base != MAP_FAILED) + { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + return; + } else { + /* This should not happen */ + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; + } + } + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + + checkDevMem(TRUE); + pVidMem->linearSupported = useDevMem; + pVidMem->mapMem = armMapVidMem; + pVidMem->unmapVidMem = armUnmapVidMem; + + pVidMem->initialised = TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + + checkDevMem(FALSE); + + if (useDevMem) + { + if (devMemFd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX); + if (base == MAP_FAILED) + { + FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n", + "xf86MapVidMem", DEV_MEM, Size, Base, + strerror(errno)); + } + return(base); + } + + /* else, mmap /dev/vga */ + if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) + { + FatalError("%s: Address 0x%x outside allowable range\n", + "xf86MapVidMem", Base); + } + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, xf86Info.screenFd, + (unsigned long)Base - 0xA0000); + if (base == MAP_FAILED) + { + FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n", + strerror(errno)); + } + return(base); +} + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, Size); +} + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + unsigned char *ptr; + int psize; + int mlen; + + checkDevMem(TRUE); + if (devMemFd == -1) { + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE); + if ((long)ptr == -1) + { + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); + return(-1); + } +#ifdef DEBUG + ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); +#endif + return(Len); +} + + +/* XXX This needs to be updated for the ND */ + +/* +** Find out whether the console driver provides memory mapping information +** for the specified region and return the map_info pointer. Print a warning if required. +*/ +static struct memAccess * +checkMapInfo(Bool warn, int Region) +{ + struct memAccess *memAccP; + + switch (Region) + { + case VGA_REGION: + memAccP = &vgaMemInfo; + break; + + case LINEAR_REGION: + memAccP = &linearMemInfo; + break; + + case MMIO_REGION: + memAccP = &ioMemInfo; + break; + + default: + return NULL; + break; + } + + if(!memAccP->Checked) + { + if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1) + { + if(warn) + { + xf86Msg(X_WARNING, + "checkMapInfo: failed to get map info for region %d\n\t(%s)\n", + Region, strerror(errno)); + } + } + else + { + if(memAccP->memInfo.u.map_info_mmap.map_offset + != MAP_INFO_UNKNOWN) + memAccP->OK = TRUE; + } + memAccP->Checked = TRUE; + } + if (memAccP->OK) + { + return memAccP; + } + else + { + return NULL; + } +} + +static pointer +xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size) +{ + struct map_info *mapInfoP = &(memInfoP->memInfo); + + if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) + { + Size = (unsigned long)Base + Size; + } + else + { + Size = mapInfoP->u.map_info_mmap.map_size; + } + + switch(mapInfoP->method) + { + case MAP_MMAP: + /* Need to remap if size is unknown because we may not have + mapped the whole region initially */ + if(memInfoP->regionVirtBase == NULL || + mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) + { + if((memInfoP->regionVirtBase = + mmap((caddr_t)0, + Size, + PROT_READ | PROT_WRITE, + MAP_SHARED, + xf86Info.screenFd, + (unsigned long)mapInfoP->u.map_info_mmap.map_offset)) + == (pointer)-1) + { + FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n", + mapInfoP->u.map_info_mmap.map_offset, strerror(errno)); + } + if(mapInfoP->u.map_info_mmap.internal_offset > 0) + memInfoP->regionVirtBase += + mapInfoP->u.map_info_mmap.internal_offset; + } + break; + + default: + FatalError("xf86MapInfoMap: Unsuported mapping method\n"); + break; + } + + return (pointer)((int)memInfoP->regionVirtBase + (int)Base); +} + +static void +xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size) +{ + struct map_info *mapInfoP = &(memInfoP->memInfo); + + switch(mapInfoP->method) + { + case MAP_MMAP: + if(memInfoP->regionVirtBase != NULL) + { + if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN) + Size = mapInfoP->u.map_info_mmap.map_size; + munmap((caddr_t)memInfoP->regionVirtBase, Size); + memInfoP->regionVirtBase = NULL; + } + break; + default: + FatalError("xf86MapInfoMap: Unsuported mapping method\n"); + break; + } +} + +static pointer +armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + struct memAccess *memInfoP; + + if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) + { + /* + ** xf86 passes in a physical address offset from the start + ** of physical memory, but xf86MapInfoMap expects an + ** offset from the start of the specified region - it gets + ** the physical address of the region from the display driver. + */ + switch(Region) + { + case LINEAR_REGION: + if (vgaPhysLinearBase) + { + Base -= vgaPhysLinearBase; + } + break; + case VGA_REGION: + Base -= 0xA0000; + break; + } + + base = xf86MapInfoMap(memInfoP, Base, Size); + return (base); + } + return mapVidMem(ScreenNum, Base, Size, flags); +} + +static void +armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + struct memAccess *memInfoP; + + if((memInfoP = checkMapInfo(FALSE, Region)) != NULL) + { + xf86MapInfoUnmap(memInfoP, Base, Size); + } + unmapVidMem(ScreenNum, Base, Size); +} + +#ifdef USE_DEV_IO +static int IoFd = -1; + +_X_EXPORT Bool +xf86EnableIO() +{ + if (IoFd >= 0) + return TRUE; + + if ((IoFd = open("/dev/io", O_RDWR)) == -1) + { + xf86Msg(X_WARNING,"xf86EnableIO: " + "Failed to open /dev/io for extended I/O\n"); + return FALSE; + } + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (IoFd < 0) + return; + + close(IoFd); + IoFd = -1; + return; +} + +#endif + +#if defined(USE_ARC_MMAP) || defined(__arm32__) + +Bool +xf86EnableIO() +{ + int fd; + pointer base; + + if (ExtendedEnabled) + return TRUE; + + if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { + /* Try to map a page at the pccons I/O space */ + base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0x0000); + + if (base != (pointer)-1) { + IOPortBase = base; + } + else { + xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + return FALSE; + } + } + else { + xf86Msg("EnableIO: failed to open %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + return FALSE; + } + + ExtendedEnabled = TRUE; + + return TRUE; +} + +void +xf86DisableIO() +{ + return; +} + +#endif /* USE_ARC_MMAP */ + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + + return; +} + + + +#if 0 +/* + * XXX This is here for reference. It needs to be handled differently for the + * ND. + */ +#if defined(USE_ARC_MMAP) || defined(__arm32__) + +#ifdef USE_ARM32_MMAP +#define DEV_MEM_IOBASE 0x43000000 +#endif + +static Bool ScreenEnabled[MAXSCREENS]; +static Bool ExtendedEnabled = FALSE; +static Bool InitDone = FALSE; + +Bool +xf86EnableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; + int fd; + pointer base; + +#ifdef __arm32__ + struct memAccess *memInfoP; + int *Size; +#endif + + ScreenEnabled[ScreenNum] = TRUE; + + if (ExtendedEnabled) + return TRUE; + +#ifdef USE_ARC_MMAP + if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) { + /* Try to map a page at the pccons I/O space */ + base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0x0000); + + if (base != (pointer)-1) { + IOPortBase = base; + } + else { + xf86Msg(X_ERROR, + "EnableIOPorts: failed to mmap %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + } + } + else { + xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n", + "/dev/ttyC0", strerror(errno)); + } +#endif + +#ifdef __arm32__ + IOPortBase = (unsigned int)-1; + + if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL) + { + /* + * xf86MapInfoMap maps an offset from the start of video IO + * space (e.g. 0x3B0), but IOPortBase is expected to map to + * physical address 0x000, so subtract the start of video I/O + * space from the result. This is safe for now becase we + * actually mmap the start of the page, then the start of video + * I/O space is added as an internal offset. + */ + IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP, + (caddr_t)0x0, 0L) + - memInfoP->memInfo.u.map_info_mmap.internal_offset; + ExtendedEnabled = TRUE; + return TRUE; + } +#ifdef USE_ARM32_MMAP + checkDevMem(TRUE); + + if (devMemFd >= 0 && useDevMem) + { + base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE, + MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE); + + if (base != (pointer)-1) + IOPortBase = (unsigned int)base; + } + + if (IOPortBase == (unsigned int)-1) + { + xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ +Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n"); + return FALSE; + } +#else + /* We don't have the IOBASE, so we can't map the address */ + xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\ +Try building the server with USE_ARM32_MMAP defined\n"); + return FALSE; +#endif +#endif + + ExtendedEnabled = TRUE; + + return TRUE; +} + +void +xf86DisableIOPorts(ScreenNum) +int ScreenNum; +{ + int i; +#ifdef __arm32__ + struct memAccess *memInfoP; +#endif + + ScreenEnabled[ScreenNum] = FALSE; + +#ifdef __arm32__ + if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL) + { + xf86MapInfoUnmap(memInfoP, 0); + } +#endif + +#ifdef USE_ARM32_MMAP + if (!ExtendedEnabled) + return; + + for (i = 0; i < MAXSCREENS; i++) + if (ScreenEnabled[i]) + return; + + munmap((caddr_t)IOPortBase, 0x400); + IOPortBase = (unsigned int)-1; + ExtendedEnabled = FALSE; +#endif + + return; +} + +#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */ +#endif + + diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsdResource.c b/xorg-server/hw/xfree86/os-support/bsd/bsdResource.c new file mode 100644 index 000000000..d1ee787f1 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsdResource.c @@ -0,0 +1,92 @@ + +/* Resource information code */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" +#include "xf86Pci.h" +#include "xf86Resources.h" +#define NEED_OS_RAC_PROTOS +#include "xf86_OSlib.h" + +/* Avoid Imakefile changes */ +#include "bus/Pci.h" + +#ifdef INCLUDE_XF86_NO_DOMAIN + +#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__) || defined(__x86_64__) + +resPtr +xf86AccResFromOS(resPtr ret) +{ + resRange range; + + /* + * Fallback is to claim the following areas: + * + * 0x000c0000 - 0x000effff location of VGA and other extensions ROMS + */ + + RANGE(range, 0x000c0000, 0x000effff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* + * Fallback would be to claim well known ports in the 0x0 - 0x3ff range + * along with their sparse I/O aliases, but that's too imprecise. Instead + * claim a bare minimum here. + */ + RANGE(range, 0x00000000, 0x000000ff, ResExcIoBlock); /* For mainboard */ + ret = xf86AddResToList(ret, &range, -1); + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); +/* RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); */ + RANGE(range, 0xffffffff, 0xffffffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + /* XXX add others */ + return ret; +} + +#elif defined(__powerpc__) + +resPtr +xf86AccResFromOS(resPtr ret) +{ + resRange range; + + /* + * At minimum, the top and bottom resources must be claimed, so that + * resources that are (or appear to be) unallocated can be relocated. + */ + RANGE(range, 0x00000000, 0x00000000, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0xffffffff, 0xffffffff, ResExcMemBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x00000000, 0x00000000, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + RANGE(range, 0x0000ffff, 0x0000ffff, ResExcIoBlock); + ret = xf86AddResToList(ret, &range, -1); + + return ret; +} + +#else + +#error : Put your platform dependent code here!! + +#endif + +#endif /* INCLUDE_XF86_NO_DOMAIN */ diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c new file mode 100644 index 000000000..476a0e957 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c @@ -0,0 +1,94 @@ +/* + * Derived from VTsw_usl.c which is + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * by S_ren Schmidt (sos@login.dkuug.dk) + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of David Wexelblat not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. David Wexelblat makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +/* + * Handle the VT-switching interface for OSs that use USL-style ioctl()s + * (the bsd, sysv, sco, and linux subdirs). + */ + +/* + * This function is the signal handler for the VT-switching signal. It + * is only referenced inside the OS-support layer. + */ +void +xf86VTRequest(int sig) +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = TRUE; + } +#endif + return; +} + +Bool +xf86VTSwitchPending() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + return(xf86Info.vtRequestsPending ? TRUE : FALSE); + } +#endif + return FALSE; +} + +Bool +xf86VTSwitchAway() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0) + return(FALSE); + else + return(TRUE); + } +#endif + return FALSE; +} + +Bool +xf86VTSwitchTo() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) { + xf86Info.vtRequestsPending = FALSE; + if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) + return(FALSE); + else + return(TRUE); + } +#endif + return(TRUE); +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c new file mode 100644 index 000000000..43eda7421 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_apm.c @@ -0,0 +1,139 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + +#include <machine/apmvar.h> + +#define APM_DEVICE "/dev/apm" + +static pointer APMihPtr = NULL; +static void bsdCloseAPM(void); + +static struct { + u_int apmBsd; + pmEvent xf86; +} bsdToXF86Array [] = { + { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, + { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, + { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, + { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#ifdef APM_CAPABILITY_CHANGE + { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, +#endif +}; + +#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0])) + +static pmEvent +bsdToXF86(int type) +{ + int i; + + for (i = 0; i < numApmEvents; i++) { + if (type == bsdToXF86Array[i].apmBsd) { + return bsdToXF86Array[i].xf86; + } + } + return XF86_APM_UNKNOWN; +} + +/* + * APM events can be requested direclty from /dev/apm + */ +static int +bsdPMGetEventFromOS(int fd, pmEvent *events, int num) +{ + struct apm_event_info bsdEvent; + int i; + + for (i = 0; i < num; i++) { + + if (ioctl(fd, APM_IOC_NEXTEVENT, &bsdEvent) < 0) { + if (errno != EAGAIN) { + xf86Msg(X_WARNING, "bsdPMGetEventFromOS: APM_IOC_NEXTEVENT" + " %s\n", strerror(errno)); + } + break; + } + events[i] = bsdToXF86(bsdEvent.type); + } + return i; +} + +/* + * XXX This won't work on /dev/apm ! + * We should either use /dev/apm_ctl (and kill apmd(8)) + * or talk to apmd (but its protocol is not publically available)... + */ +static pmWait +bsdPMConfirmEventToOs(int fd, pmEvent event) +{ + switch (event) { + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0) + return PM_WAIT; /* should we stop the Xserver in standby, too? */ + else + return PM_NONE; + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_WAIT; + else + return PM_NONE; + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + return PM_CONTINUE; + default: + return PM_NONE; + } +} + +PMClose +xf86OSPMOpen(void) +{ + int fd; + + if (APMihPtr || !xf86Info.pmFlag) { + return NULL; + } + + if ((fd = open(APM_DEVICE, O_RDWR)) == -1) { + return NULL; + } + xf86PMGetEventFromOs = bsdPMGetEventFromOS; + xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(fd, xf86HandlePMEvents, NULL); + return bsdCloseAPM; +} + +static void +bsdCloseAPM(void) +{ + int fd; + + if (APMihPtr) { + fd = xf86RemoveInputHandler(APMihPtr); + close(fd); + APMihPtr = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c new file mode 100644 index 000000000..51ffef148 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_axp.c @@ -0,0 +1,72 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Axp.h" +#include <sys/param.h> +#include "xf86_OSlib.h" +#include <stdio.h> +#include <sys/sysctl.h> + +axpDevice bsdGetAXP(void); + +/* + * BSD does a very nice job providing system information to + * user space programs. Unfortunately it doesn't provide all + * the information required. Therefore we just obtain the + * system type and look up the rest from a list we maintain + * ourselves. + */ + +typedef struct { + char *name; + int type; +} _AXP; + +static _AXP axpList[] = { + {"apecs",APECS}, + {"pyxis",PYXIS}, + {"cia",CIA}, + {"irongate",IRONGATE}, + {"lca",LCA}, + {"t2",T2}, + {"tsunami",TSUNAMI}, + {NULL,NONE} +}; + +axpDevice +bsdGetAXP(void) +{ + int i; + char sysname[64]; + size_t len = sizeof(sysname); + +#ifdef __OpenBSD__ + int mib[3]; + int error; + + mib[0] = CTL_MACHDEP; + mib[1] = CPU_CHIPSET; + mib[2] = CPU_CHIPSET_TYPE; + + if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0) +#else + if ((sysctlbyname("hw.chipset.type", &sysname, &len, + 0, 0)) < 0) +#endif + FatalError("bsdGetAXP: can't find machine type\n"); +#ifdef DEBUG + xf86Msg(X_INFO,"AXP is a: %s\n",sysname); +#endif + for (i=0;;i++) { + if (axpList[i].name == NULL) + return NONE; + if (!strcmp(sysname, axpList[i].name)) + return axpList[i].type; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c new file mode 100644 index 000000000..0d2420102 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_bell.c @@ -0,0 +1,86 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Dawes <dawes@xfree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Dawes + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Dawes make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#if defined (SYSCONS_SUPPORT) +#include <sys/kbio.h> +#endif + +#include <termios.h> + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#ifdef WSCONS_SUPPORT +#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd) +#endif + +_X_EXPORT void +xf86OSRingBell(int loudness, int pitch, int duration) +{ +#ifdef WSCONS_SUPPORT + struct wskbd_bell_data wsb; +#endif + + if (loudness && pitch) + { +#ifdef PCCONS_SUPPORT + int data[2]; +#endif + + switch (xf86Info.consType) { + +#ifdef PCCONS_SUPPORT + case PCCONS: + data[0] = pitch; + data[1] = (duration * loudness) / 50; + ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data); + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration*loudness/50)<<16)); + break; +#endif +#if defined (WSCONS_SUPPORT) + case WSCONS: + wsb.which = WSKBD_BELL_DOALL; + wsb.pitch = pitch; + wsb.period = duration; + wsb.volume = loudness; + ioctl(xf86Info.consoleFd, WSKBDIO_COMPLEXBELL, + &wsb); + break; +#endif + } + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c new file mode 100644 index 000000000..b2141192e --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_ev56.c @@ -0,0 +1,90 @@ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "input.h" +#include "scrnintstr.h" +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +int readDense8(pointer Base, register unsigned long Offset); +int readDense16(pointer Base, register unsigned long Offset); +int readDense32(pointer Base, register unsigned long Offset); +void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset); +void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset); +void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset); +void +writeDense8(int Value, pointer Base, register unsigned long Offset); +void +writeDense16(int Value, pointer Base, register unsigned long Offset); +void +writeDense32(int Value, pointer Base, register unsigned long Offset); + +int +readDense8(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD8*) ((unsigned long)Base+(Offset)); +} + +int +readDense16(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD16*) ((unsigned long)Base+(Offset)); +} + +int +readDense32(pointer Base, register unsigned long Offset) +{ + mem_barrier(); + return *(volatile CARD32*)((unsigned long)Base+(Offset)); +} + +void +writeDenseNB8(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD8*)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDenseNB16(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD16*)((unsigned long)Base + (Offset)) = Value; +} + +void +writeDenseNB32(int Value, pointer Base, register unsigned long Offset) +{ + *(volatile CARD32*)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense8(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD8 *)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense16(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD16 *)((unsigned long)Base+(Offset)) = Value; +} + +void +writeDense32(int Value, pointer Base, register unsigned long Offset) +{ + write_mem_barrier(); + *(volatile CARD32 *)((unsigned long)Base+(Offset)) = Value; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c new file mode 100644 index 000000000..83583d5b9 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c @@ -0,0 +1,739 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include <sys/utsname.h> +#include <sys/ioctl.h> +#include <stdlib.h> +#include <errno.h> + +static Bool KeepTty = FALSE; +static int devConsoleFd = -1; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) +static int VTnum = -1; +static int initialVT = -1; +#endif + +#ifdef PCCONS_SUPPORT +/* Stock 0.1 386bsd pccons console driver interface */ +#ifndef __OpenBSD__ +# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0" +#else +# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0" +#endif +#define PCCONS_CONSOLE_DEV2 "/dev/vga" +#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#ifdef SYSCONS_SUPPORT +/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */ +#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0" +#define SYSCONS_CONSOLE_DEV2 "/dev/vga" +#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#ifdef PCVT_SUPPORT +/* Hellmuth Michaelis' pcvt driver */ +#ifndef __OpenBSD__ +# define PCVT_CONSOLE_DEV "/dev/ttyv0" +#else +# define PCVT_CONSOLE_DEV "/dev/ttyC0" +#endif +#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY +#endif + +#if defined(WSCONS_SUPPORT) && defined(__NetBSD__) +/* NetBSD's new console driver */ +#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0" +#endif + +#ifdef __GLIBC__ +#define setpgrp setpgid +#endif + +#define CHECK_DRIVER_MSG \ + "Check your kernel's console driver configuration and /dev entries" + +static char *supported_drivers[] = { +#ifdef PCCONS_SUPPORT + "pccons (with X support)", +#endif +#ifdef SYSCONS_SUPPORT + "syscons", +#endif +#ifdef PCVT_SUPPORT + "pcvt", +#endif +#ifdef WSCONS_SUPPORT + "wscons", +#endif +}; + + +/* + * Functions to probe for the existance of a supported console driver. + * Any function returns either a valid file descriptor (driver probed + * succesfully), -1 (driver not found), or uses FatalError() if the + * driver was found but proved to not support the required mode to run + * an X server. + */ + +typedef int (*xf86ConsOpen_t)(void); + +#ifdef PCCONS_SUPPORT +static int xf86OpenPccons(void); +#endif /* PCCONS_SUPPORT */ + +#ifdef SYSCONS_SUPPORT +static int xf86OpenSyscons(void); +#endif /* SYSCONS_SUPPORT */ + +#ifdef PCVT_SUPPORT +static int xf86OpenPcvt(void); +#endif /* PCVT_SUPPORT */ + +#ifdef WSCONS_SUPPORT +static int xf86OpenWScons(void); +#endif + +/* + * The sequence of the driver probes is important; start with the + * driver that is best distinguishable, and end with the most generic + * driver. (Otherwise, pcvt would also probe as syscons, and either + * pcvt or syscons might succesfully probe as pccons.) + */ +static xf86ConsOpen_t xf86ConsTab[] = { +#ifdef PCVT_SUPPORT + xf86OpenPcvt, +#endif +#ifdef SYSCONS_SUPPORT + xf86OpenSyscons, +#endif +#ifdef PCCONS_SUPPORT + xf86OpenPccons, +#endif +#ifdef WSCONS_SUPPORT + xf86OpenWScons, +#endif + (xf86ConsOpen_t)NULL +}; + + +void +xf86OpenConsole() +{ + int i, fd = -1; + xf86ConsOpen_t *driver; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + int result; +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + struct utsname uts; +#endif + vtmode_t vtmode; +#endif + + if (serverGeneration == 1) + { + /* check if we are run with euid==0 */ + if (geteuid() != 0) + { + FatalError("xf86OpenConsole: Server must be suid root"); + } + + if (!KeepTty) + { + /* + * detaching the controlling tty solves problems of kbd character + * loss. This is not interesting for CO driver, because it is + * exclusive. + */ + setpgrp(0, getpid()); + if ((i = open("/dev/tty",O_RDWR)) >= 0) + { + ioctl(i,TIOCNOTTY,(char *)0); + close(i); + } + } + + /* detect which driver we are running on */ + for (driver = xf86ConsTab; *driver; driver++) + { + if ((fd = (*driver)()) >= 0) + break; + } + + /* Check that a supported console driver was found */ + if (fd < 0) + { + char cons_drivers[80] = {0, }; + for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++) + { + if (i) + { + strcat(cons_drivers, ", "); + } + strcat(cons_drivers, supported_drivers[i]); + } + FatalError( + "%s: No console driver found\n\tSupported drivers: %s\n\t%s", + "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG); + } +#if 0 /* stdin is already closed in OsInit() */ + fclose(stdin); +#endif + xf86Info.consoleFd = fd; + xf86Info.screenFd = fd; + + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS: + if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0) + { + FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + /* + * Hack to prevent keyboard hanging when syslogd closes + * /dev/console + */ + if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: couldn't open /dev/console (%s)\n", + strerror(errno)); + } + break; +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt + * switching anymore. Here we check for FreeBSD 3.1 and up. + * Add cases for other *BSD that behave the same. + */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + uname (&uts); + i = atof(uts.release) * 100; + if (i >= 310) goto acquire_vt; +#endif + /* otherwise fall through */ + case PCVT: +#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000)) + /* + * First activate the #1 VT. This is a hack to allow a server + * to be started while another one is active. There should be + * a better way. + */ + if (initialVT != 1) { + + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0) + { + xf86Msg(X_WARNING, + "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + sleep(1); + } +#endif +acquire_vt: + /* + * now get the VT + */ + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno)); + if (result != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + SYSCALL(result = + ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno)); + if (result != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n"); + } + + signal(SIGUSR1, xf86VTRequest); + + vtmode.mode = VT_PROCESS; + vtmode.relsig = SIGUSR1; + vtmode.acqsig = SIGUSR1; + vtmode.frsig = SIGUSR1; + if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0) + { + FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed"); + } +#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) + if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0) + { + FatalError("xf86OpenConsole: KDENABIO failed (%s)", + strerror(errno)); + } +#endif + if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) + { + FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed"); + } + break; +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + fprintf(stderr, "xf86OpenConsole\n"); + /* xf86Info.consoleFd = open("/dev/wskbd0", 0); */ + break; +#endif + } + } + else + { + /* serverGeneration != 1 */ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) + { + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) + { + xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n"); + } + } +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + } + return; +} + + +#ifdef PCCONS_SUPPORT + +static int +xf86OpenPccons() +{ + int fd = -1; + + if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0)) + >= 0 || + (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0)) + >= 0) + { + if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0) + { + FatalError( + "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s", + "xf86OpenPccons", + strerror(errno), + "Was expecting pccons driver with X support", + CHECK_DRIVER_MSG); + } + xf86Info.consType = PCCONS; + xf86Msg(X_PROBED, "Using pccons driver with X support\n"); + } + return fd; +} + +#endif /* PCCONS_SUPPORT */ + +#ifdef SYSCONS_SUPPORT + +static int +xf86OpenSyscons() +{ + int fd = -1; + vtmode_t vtmode; + char vtname[12]; + struct stat status; + long syscons_version; + MessageType from; + + /* Check for syscons */ + if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0 + || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0) + { + if (ioctl(fd, VT_GETMODE, &vtmode) >= 0) + { + /* Get syscons version */ + if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0) + { + syscons_version = 0; + } + + xf86Info.vtno = VTnum; + from = X_CMDLINE; + +#ifdef VT_GETACTIVE + if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) + initialVT = -1; +#endif + if (xf86Info.vtno == -1) + { + /* + * For old syscons versions (<0x100), VT_OPENQRY returns + * the current VT rather than the next free VT. In this + * case, the server gets started on the current VT instead + * of the next free VT. + */ + +#if 0 + /* check for the fixed VT_OPENQRY */ + if (syscons_version >= 0x100) + { +#endif + if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) + { + /* No free VTs */ + xf86Info.vtno = -1; + } +#if 0 + } +#endif + + if (xf86Info.vtno == -1) + { + /* + * All VTs are in use. If initialVT was found, use it. + * Otherwise, if stdin is a VT, use that one. + * XXX stdin is already closed, so this won't work. + */ + if (initialVT != -1) + { + xf86Info.vtno = initialVT; + } + else if ((fstat(0, &status) >= 0) + && S_ISCHR(status.st_mode) + && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) + { + /* stdin is a VT */ + xf86Info.vtno = minor(status.st_rdev) + 1; + } + else + { + if (syscons_version >= 0x100) + { + FatalError("%s: Cannot find a free VT", + "xf86OpenSyscons"); + } + /* Should no longer reach here */ + FatalError("%s: %s %s\n\t%s %s", + "xf86OpenSyscons", + "syscons versions prior to 1.0 require", + "either the", + "server's stdin be a VT", + "or the use of the vtxx server option"); + } + } + from = X_PROBED; + } + + close(fd); +#ifndef __OpenBSD__ + sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1); +#else + sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1); +#endif + if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0) + { + FatalError("xf86OpenSyscons: Cannot open %s (%s)", + vtname, strerror(errno)); + } + if (ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("xf86OpenSyscons: VT_GETMODE failed"); + } + xf86Info.consType = SYSCONS; + xf86Msg(X_PROBED, "Using syscons driver with X support"); + if (syscons_version >= 0x100) + { + xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8, + syscons_version & 0xFF); + } + else + { + xf86ErrorF(" (version 0.x)\n"); + } + xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno); + } + else + { + /* VT_GETMODE failed, probably not syscons */ + close(fd); + fd = -1; + } + } + return fd; +} + +#endif /* SYSCONS_SUPPORT */ + + +#ifdef PCVT_SUPPORT + +static int +xf86OpenPcvt() +{ + /* This looks much like syscons, since pcvt is API compatible */ + int fd = -1; + vtmode_t vtmode; + char vtname[12], *vtprefix; + struct stat status; + struct pcvtid pcvt_version; + +#ifndef __OpenBSD__ + vtprefix = "/dev/ttyv"; +#else + vtprefix = "/dev/ttyC"; +#endif + + fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); +#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV + if (fd < 0) + { + fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0); + vtprefix = "/dev/ttyE"; + } +#endif + if (fd >= 0) + { + if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0) + { + if(ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("%s: VT_GETMODE failed\n%s%s\n%s", + "xf86OpenPcvt", + "Found pcvt driver but X11 seems to be", + " not supported.", CHECK_DRIVER_MSG); + } + + xf86Info.vtno = VTnum; + + if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0) + initialVT = -1; + + if (xf86Info.vtno == -1) + { + if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) + { + /* No free VTs */ + xf86Info.vtno = -1; + } + + if (xf86Info.vtno == -1) + { + /* + * All VTs are in use. If initialVT was found, use it. + * Otherwise, if stdin is a VT, use that one. + * XXX stdin is already closed, so this won't work. + */ + if (initialVT != -1) + { + xf86Info.vtno = initialVT; + } + else if ((fstat(0, &status) >= 0) + && S_ISCHR(status.st_mode) + && (ioctl(0, VT_GETMODE, &vtmode) >= 0)) + { + /* stdin is a VT */ + xf86Info.vtno = minor(status.st_rdev) + 1; + } + else + { + FatalError("%s: Cannot find a free VT", + "xf86OpenPcvt"); + } + } + } + + close(fd); + sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1); + if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) + { + FatalError("xf86OpenPcvt: Cannot open %s (%s)", + vtname, strerror(errno)); + } + if (ioctl(fd, VT_GETMODE, &vtmode) < 0) + { + FatalError("xf86OpenPcvt: VT_GETMODE failed"); + } + xf86Info.consType = PCVT; +#ifdef WSCONS_SUPPORT + xf86Msg(X_PROBED, + "Using wscons driver in pcvt compatibility mode " + "(version %d.%d)\n", + pcvt_version.rmajor, pcvt_version.rminor); +#else + xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n", + pcvt_version.rmajor, pcvt_version.rminor); +#endif + } + else + { + /* Not pcvt */ + close(fd); + fd = -1; + } + } + return fd; +} + +#endif /* PCVT_SUPPORT */ + +#ifdef WSCONS_SUPPORT + +static int +xf86OpenWScons() +{ + int fd = -1; + int mode = WSDISPLAYIO_MODE_MAPPED; + int i; + char ttyname[16]; + + /* XXX Is this ok? */ + for (i = 0; i < 8; i++) { +#if defined(__NetBSD__) + sprintf(ttyname, "/dev/ttyE%d", i); +#elif defined(__OpenBSD__) + sprintf(ttyname, "/dev/ttyC%d", i); +#endif + if ((fd = open(ttyname, 2)) != -1) + break; + } + if (fd != -1) { + if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) { + FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s", + "xf86OpenConsole", strerror(errno), + CHECK_DRIVER_MSG); + } + xf86Info.consType = WSCONS; + xf86Msg(X_PROBED, "Using wscons driver\n"); + } + return fd; +} + +#endif /* WSCONS_SUPPORT */ + +void +xf86CloseConsole() +{ +#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) + struct vt_mode VT; +#endif + + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS: + ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0); + break; +#endif /* PCCONS_SUPPORT */ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */ + if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) + { + VT.mode = VT_AUTO; + ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */ + } +#if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL) + if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0) + { + xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)", + strerror(errno)); + } +#endif + if (initialVT != -1) + ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT); + break; +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ +#ifdef WSCONS_SUPPORT + case WSCONS: + { + int mode = WSDISPLAYIO_MODE_EMUL; + ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode); + break; + } +#endif + } + + if (xf86Info.screenFd != xf86Info.consoleFd) + { + close(xf86Info.screenFd); + close(xf86Info.consoleFd); + if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0) + { + xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)", + strerror(errno)); + } + } + close(xf86Info.consoleFd); + if (devConsoleFd >= 0) + close(devConsoleFd); + return; +} + +int +xf86ProcessArgument(int argc, char *argv[], int i) +{ + /* + * Keep server from detaching from controlling tty. This is useful + * when debugging (so the server can receive keyboard signals. + */ + if (!strcmp(argv[i], "-keeptty")) + { + KeepTty = TRUE; + return(1); + } +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if ((argv[i][0] == 'v') && (argv[i][1] == 't')) + { + if (sscanf(argv[i], "vt%2d", &VTnum) == 0 || + VTnum < 1 || VTnum > 12) + { + UseMsg(); + VTnum = -1; + return(0); + } + return(1); + } +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + return(0); +} + +void +xf86UseMsg() +{ +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + ErrorF("vtXX use the specified VT number (1-12)\n"); +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + ErrorF("-keeptty "); + ErrorF("don't detach controlling tty (for debugging only)\n"); + return; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c new file mode 100644 index 000000000..b5b91b0c7 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_jstk.c @@ -0,0 +1,183 @@ +/* + * Copyright 1995 by Frederic Lepied, France. <fred@sugix.frmug.fr.net> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Frederic Lepied not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Frederic Lepied makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * FREDERIC LEPIED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL FREDERIC LEPIED BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ + +/* Modified for FreeBSD by David Dawes <dawes@XFree86.org> */ + + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <machine/joystick.h> +#include <fcntl.h> + +#include "misc.h" +#include "xf86.h" + +#define JS_RETURN sizeof(struct joystick) + +/*********************************************************************** + * + * xf86JoystickOn -- + * + * open the device and init timeout according to the device value. + * + *********************************************************************** + */ + +int +xf86JoystickOn(char * name, int *timeout, int *centerX, int *centerY) +{ + int status; + int changed = 0; + int timeinmicros; + struct joystick js; + +#ifdef DEBUG + ErrorF("xf86JoystickOn: %s\n", name); +#endif + + if ((status = open(name, O_RDWR | O_NDELAY, 0)) < 0) + { + xf86Msg(X_WARNING, "xf86JoystickOn: Cannot open joystick '%s' (%s)\n", + name, strerror(errno)); + return -1; + } + + if (*timeout <= 0) { + /* Use the current setting */ + ioctl(status, JOY_GETTIMEOUT, (char *)&timeinmicros); + *timeout = timeinmicros / 1000; + if (*timeout == 0) + *timeout = 1; + changed = 1; + } + /* Maximum allowed timeout in the FreeBSD driver is 10ms */ + if (*timeout > 10) { + *timeout = 10; + changed = 1; + } + + if (changed) + xf86Msg(X_PROBED, "Joystick: timeout value = %d\n", *timeout); + + timeinmicros = *timeout * 1000; + + /* Assume the joystick is centred when this is called */ + read(status, &js, JS_RETURN); + if (*centerX < 0) { + *centerX = js.x; + xf86Msg(X_PROBED, "Joystick: CenterX set to %d\n", *centerX); + } + if (*centerY < 0) { + *centerY = js.y; + xf86Msg(X_PROBED, "Joystick: CenterY set to %d\n", *centerY); + } + + return status; +} + +/*********************************************************************** + * + * xf86JoystickInit -- + * + * called when X device is initialized. + * + *********************************************************************** + */ + +void +xf86JoystickInit() +{ + return; +} + +/*********************************************************************** + * + * xf86JoystickOff -- + * + * close the handle. + * + *********************************************************************** + */ + +int +xf86JoystickOff(int *fd, int doclose) +{ + int oldfd; + + if (((oldfd = *fd) >= 0) && doclose) { + close(*fd); + *fd = -1; + } + return oldfd; +} + +/*********************************************************************** + * + * xf86JoystickGetState -- + * + * return the state of buttons and the position of the joystick. + * + *********************************************************************** + */ + +int +xf86JoystickGetState(int fd, int *x, int *y, int *buttons) +{ + struct joystick js; + int status; + + status = read(fd, &js, JS_RETURN); + + if (status != JS_RETURN) + { + Error("Joystick read"); + return 0; + } + + *x = js.x; + *y = js.y; + *buttons = js.b1 | (js.b2 << 1); +#ifdef DEBUG + ErrorF("xf86JoystickGetState: x = %d, y = %d, buttons = %d\n", *x, *y, + *buttons); +#endif + + return 1; +} + +/* + * Entry point for XFree86 Loader + */ +void +bsd_jstkModuleInit(pointer *data, INT32 *magic) +{ + *magic = MAGIC_DONE; + *data = NULL; +} +/* end of bsd_jstk.c */ diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c new file mode 100644 index 000000000..b6c755852 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kmod.c @@ -0,0 +1,28 @@ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/param.h> +#include <sys/linker.h> + +#include "xf86_OSproc.h" + +/* + * Load a FreeBSD kernel module. + * This is used by the DRI/DRM to load a DRM kernel module when + * the X server starts. It could be used for other purposes in the future. + * Input: + * modName - name of the kernel module (Ex: "tdfx") + * Return: + * 0 for failure, 1 for success + */ +_X_EXPORT int xf86LoadKernelModule(const char *modName) +{ + if (kldload(modName) != -1) + return 1; + else + return 0; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c new file mode 100644 index 000000000..b37070c37 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_kqueue_apm.c @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the XFree86 Project + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * from the XFree86 Project. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + +#include <sys/event.h> +#include <machine/apmvar.h> + +#define _PATH_APM_SOCKET "/var/run/apmdev" +#define _PATH_APM_DEV "/dev/apm" +#define _PATH_APM_CTLDEV "/dev/apmctl" + +static pointer APMihPtr = NULL; +static int devFd = -1; +static int ctlFd = -1; +static void bsdCloseAPM(void); + +static struct { + u_int apmBsd; + pmEvent xf86; +} bsdToXF86Array [] = { + { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY }, + { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND }, + { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME }, + { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME }, + { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY }, + { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE }, + { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME }, + { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND }, + { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY }, + { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND }, + { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME }, +#ifdef APM_CAPABILITY_CHANGE + { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED }, +#endif +}; + +#define numApmEvents (sizeof(bsdToXF86Array) / sizeof(bsdToXF86Array[0])) + +static pmEvent +bsdToXF86(int type) +{ + int i; + + for (i = 0; i < numApmEvents; i++) { + if (type == bsdToXF86Array[i].apmBsd) { + return bsdToXF86Array[i].xf86; + } + } + return XF86_APM_UNKNOWN; +} + +/* + * APM events can be requested direclty from /dev/apm + */ +static int +bsdPMGetEventFromOS(int kq, pmEvent *events, int num) +{ + struct kevent ev; + int i, result; + struct timespec ts = { 0, 0 }; + + for (i = 0; i < num; i++) { + result = kevent(kq, NULL, 0, &ev, 1, &ts); + if (result == 0 || APM_EVENT_TYPE(ev.data) == APM_NOEVENT) { + /* no event */ + break; + } else if (result < 0) { + xf86Msg(X_WARNING, "bsdPMGetEventFromOS: kevent returns" + " %s\n", strerror(errno)); + break; + } + events[i] = bsdToXF86(APM_EVENT_TYPE(ev.data)); + } + return i; +} + +/* + * If apmd(8) is running, he will get the events and handle them, + * so, we've nothing to do here. + * Otherwise, opening /dev/apmctl will succeed and we have to send the + * confirmations to /dev/apmctl. + */ +static pmWait +bsdPMConfirmEventToOs(int dummyfd, pmEvent event) +{ + if (ctlFd < 0) { + if ((ctlFd = open(_PATH_APM_CTLDEV, O_RDWR)) < 0) { + return PM_NONE; + } + } + /* apmctl open succeedeed */ + switch (event) { + case XF86_APM_SYS_STANDBY: + case XF86_APM_USER_STANDBY: + if (ioctl( ctlFd, APM_IOC_STANDBY, NULL ) == 0) + return PM_WAIT; /* should we stop the Xserver in standby, too? */ + else + return PM_NONE; + + case XF86_APM_SYS_SUSPEND: + case XF86_APM_CRITICAL_SUSPEND: + case XF86_APM_USER_SUSPEND: + if (ioctl( ctlFd, APM_IOC_SUSPEND, NULL ) == 0) + return PM_WAIT; + else + return PM_NONE; + break; + case XF86_APM_STANDBY_RESUME: + case XF86_APM_NORMAL_RESUME: + case XF86_APM_CRITICAL_RESUME: + case XF86_APM_STANDBY_FAILED: + case XF86_APM_SUSPEND_FAILED: + return PM_CONTINUE; + break; + default: + return PM_NONE; + } +} + +PMClose +xf86OSPMOpen(void) +{ + int kq; + struct kevent ev; + + if (APMihPtr || !xf86Info.pmFlag) { + return NULL; + } + if ((devFd = open(_PATH_APM_DEV, O_RDONLY)) == -1) { + return NULL; + } + if ((kq = kqueue()) <= 0) { + close(devFd); + return NULL; + } + EV_SET(&ev, devFd, EVFILT_READ, EV_ADD | EV_ENABLE | EV_CLEAR, + 0, 0, NULL); + if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0) { + close(devFd); + return NULL; + } + + xf86PMGetEventFromOs = bsdPMGetEventFromOS; + xf86PMConfirmEventToOs = bsdPMConfirmEventToOs; + APMihPtr = xf86AddInputHandler(kq, xf86HandlePMEvents, NULL); + return bsdCloseAPM; +} + +static void +bsdCloseAPM(void) +{ + int kq; + + if (APMihPtr) { + kq = xf86RemoveInputHandler(APMihPtr); + close(devFd); + devFd = -1; + close(kq); + if (ctlFd >= 0) { + close(ctlFd); + ctlFd = -1; + } + APMihPtr = NULL; + } +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c new file mode 100644 index 000000000..ca2c1bbd5 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_mouse.c @@ -0,0 +1,791 @@ + +/* + * Copyright (c) 1999-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Xinput.h" +#include "xf86OSmouse.h" +#include "xisb.h" +#include "mipointer.h" +#ifdef WSCONS_SUPPORT +#include <dev/wscons/wsconsio.h> +#endif +#ifdef USBMOUSE_SUPPORT +#ifdef HAS_LIB_USB_HID +#include <usbhid.h> +#else +#include "usb.h" +#endif + +#include <dev/usb/usb.h> +#ifdef USB_GET_REPORT_ID +#define USB_NEW_HID +#endif + +#define HUP_GENERIC_DESKTOP 0x0001 +#define HUP_BUTTON 0x0009 + +#define HUG_X 0x0030 +#define HUG_Y 0x0031 +#define HUG_Z 0x0032 +#define HUG_WHEEL 0x0038 + +#define HID_USAGE2(p,u) (((p) << 16) | u) + +/* The UMS mices have middle button as number 3 */ +#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i)) +#endif /* USBMOUSE_SUPPORT */ + +#ifdef USBMOUSE_SUPPORT +static void usbSigioReadInput (int fd, void *closure); +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +/* These are for FreeBSD and DragonFly */ +#define DEFAULT_MOUSE_DEV "/dev/mouse" +#define DEFAULT_SYSMOUSE_DEV "/dev/sysmouse" +#define DEFAULT_PS2_DEV "/dev/psm0" + +static const char *mouseDevs[] = { + DEFAULT_MOUSE_DEV, + DEFAULT_SYSMOUSE_DEV, + DEFAULT_PS2_DEV, + NULL +}; +#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) +/* Only wsmouse mices are autoconfigured for now on OpenBSD */ +#define DEFAULT_WSMOUSE_DEV "/dev/wsmouse" +#define DEFAULT_WSMOUSE0_DEV "/dev/wsmouse0" + +static const char *mouseDevs[] = { + DEFAULT_WSMOUSE_DEV, + DEFAULT_WSMOUSE0_DEV, + NULL +}; +#endif + +static int +SupportedInterfaces(void) +{ +#if defined(__NetBSD__) + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO; +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC; +#else + return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO; +#endif +} + +/* Names of protocols that are handled internally here. */ +static const char *internalNames[] = { +#if defined(WSCONS_SUPPORT) + "WSMouse", +#endif +#if defined(USBMOUSE_SUPPORT) + "usb", +#endif + NULL +}; + +/* + * Names of MSC_MISC protocols that the OS supports. These are decoded by + * main "mouse" driver. + */ +static const char *miscNames[] = { +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + "SysMouse", +#endif + NULL +}; + +static const char ** +BuiltinNames(void) +{ + return internalNames; +} + +static Bool +CheckProtocol(const char *protocol) +{ + int i; + + for (i = 0; internalNames[i]; i++) + if (xf86NameCmp(protocol, internalNames[i]) == 0) + return TRUE; + for (i = 0; miscNames[i]; i++) + if (xf86NameCmp(protocol, miscNames[i]) == 0) + return TRUE; + return FALSE; +} + +static const char * +DefaultProtocol(void) +{ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + return "Auto"; +#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) + return "WSMouse"; +#else + return NULL; +#endif +} + +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE) +static struct { + int dproto; + const char *name; +} devproto[] = { + { MOUSE_PROTO_MS, "Microsoft" }, + { MOUSE_PROTO_MSC, "MouseSystems" }, + { MOUSE_PROTO_LOGI, "Logitech" }, + { MOUSE_PROTO_MM, "MMSeries" }, + { MOUSE_PROTO_LOGIMOUSEMAN, "MouseMan" }, + { MOUSE_PROTO_BUS, "BusMouse" }, + { MOUSE_PROTO_INPORT, "BusMouse" }, + { MOUSE_PROTO_PS2, "PS/2" }, + { MOUSE_PROTO_HITTAB, "MMHitTab" }, + { MOUSE_PROTO_GLIDEPOINT, "GlidePoint" }, + { MOUSE_PROTO_INTELLI, "Intellimouse" }, + { MOUSE_PROTO_THINK, "ThinkingMouse" }, + { MOUSE_PROTO_SYSMOUSE, "SysMouse" } +}; + +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + int i; + mousehw_t hw; + mousemode_t mode; + + if (pInfo->fd == -1) + return NULL; + + /* set the driver operation level, if applicable */ + i = 1; + ioctl(pInfo->fd, MOUSE_SETLEVEL, &i); + + /* interrogate the driver and get some intelligence on the device. */ + hw.iftype = MOUSE_IF_UNKNOWN; + hw.model = MOUSE_MODEL_GENERIC; + ioctl(pInfo->fd, MOUSE_GETHWINFO, &hw); + xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: hw.iftype is %d, hw.model is %d\n", + pInfo->name, hw.iftype, hw.model); + if (ioctl(pInfo->fd, MOUSE_GETMODE, &mode) == 0) { + for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) { + if (mode.protocol == devproto[i].dproto) { + /* override some parameters */ + if (protoPara) { + protoPara[4] = mode.packetsize; + protoPara[0] = mode.syncmask[0]; + protoPara[1] = mode.syncmask[1]; + } + xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n", + pInfo->name, devproto[i].name); + return devproto[i].name; + } + } + } + return NULL; +} + +static void +SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) +{ + mousemode_t mode; + MouseDevPtr pMse; + + pMse = pInfo->private; + + mode.rate = rate > 0 ? rate : -1; + mode.resolution = res > 0 ? res : -1; + mode.accelfactor = -1; +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + if (pMse->autoProbe || + (protocol && xf86NameCmp(protocol, "SysMouse") == 0)) { + /* + * As the FreeBSD sysmouse driver defaults to protocol level 0 + * everytime it is opened we enforce protocol level 1 again at + * this point. + */ + mode.level = 1; + } else + mode.level = -1; +#else + mode.level = -1; +#endif + ioctl(pInfo->fd, MOUSE_SETMODE, &mode); +} +#endif + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) + +#define MOUSED_PID_FILE "/var/run/moused.pid" + +/* + * Try to check if moused is running. DEFAULT_SYSMOUSE_DEV is useless without + * it. There doesn't seem to be a better way of checking. + */ +static Bool +MousedRunning(void) +{ + FILE *f = NULL; + unsigned int pid; + + if ((f = fopen(MOUSED_PID_FILE, "r")) != NULL) { + if (fscanf(f, "%u", &pid) == 1 && pid > 0) { + if (kill(pid, 0) == 0) { + fclose(f); + return TRUE; + } + } + fclose(f); + } + return FALSE; +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + int fd = -1; + const char **pdev, *dev = NULL; + Bool devMouse = FALSE; + struct stat devMouseStat; + struct stat sb; + + for (pdev = mouseDevs; *pdev; pdev++) { + SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK)); + if (fd == -1) { +#ifdef DEBUG + ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno)); +#endif + } else { + /* + * /dev/mouse is held until checks for matches with other devices + * are done. This is so that when it points to /dev/sysmouse, + * the test for whether /dev/sysmouse is usable can be made. + */ + if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) { + if (fstat(fd, &devMouseStat) == 0) + devMouse = TRUE; + close(fd); + continue; + } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) { + /* Check if /dev/mouse is the same as /dev/sysmouse. */ + if (devMouse && fstat(fd, &sb) == 0 && + devMouseStat.st_dev == sb.st_dev && + devMouseStat.st_ino == sb.st_ino) { + /* If the same, use /dev/sysmouse. */ + devMouse = FALSE; + } + close(fd); + if (MousedRunning()) + break; + else { +#ifdef DEBUG + ErrorF("moused isn't running\n"); +#endif + } + } else { + close(fd); + break; + } + } + } + + if (*pdev) + dev = *pdev; + else if (devMouse) + dev = DEFAULT_MOUSE_DEV; + + if (dev) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", dev); + xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n", + pInfo->name, dev); + } + + return *pdev; +} +#endif + +#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) + +/* Only support wsmouse configuration for now */ +static const char * +SetupAuto(InputInfoPtr pInfo, int *protoPara) +{ + + xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n", + pInfo->name, "wsmouse"); + return "wsmouse"; +} + +static void +SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res) +{ + + xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n", + pInfo->name, protocol, rate, res); +} + +static const char * +FindDevice(InputInfoPtr pInfo, const char *protocol, int flags) +{ + int fd = -1; + const char **pdev; + + for (pdev = mouseDevs; *pdev; pdev++) { + SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK)); + if (fd != -1) { + /* Set the Device option. */ + pInfo->conf_idev->commonOptions = + xf86AddNewOption(pInfo->conf_idev->commonOptions, + "Device", *pdev); + xf86Msg(X_INFO, "%s: found Device \"%s\"\n", + pInfo->name, *pdev); + close(fd); + break; + } + } + return *pdev; +} +#endif /* __OpenBSD__ || __NetBSD__ && WSCONS_SUPPORT */ + +#ifdef WSCONS_SUPPORT +#define NUMEVENTS 64 + +static void +wsconsReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + static struct wscons_event eventList[NUMEVENTS]; + int n, c; + struct wscons_event *event = eventList; + unsigned char *pBuf; + + pMse = pInfo->private; + + XisbBlockDuration(pMse->buffer, -1); + pBuf = (unsigned char *)eventList; + n = 0; + while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0) { + pBuf[n++] = (unsigned char)c; + } + + if (n == 0) + return; + + n /= sizeof(struct wscons_event); + while( n-- ) { + int buttons = pMse->lastButtons; + int dx = 0, dy = 0, dz = 0, dw = 0; + switch (event->type) { + case WSCONS_EVENT_MOUSE_UP: +#define BUTBIT (1 << (event->value <= 2 ? 2 - event->value : event->value)) + buttons &= ~BUTBIT; + break; + case WSCONS_EVENT_MOUSE_DOWN: + buttons |= BUTBIT; + break; + case WSCONS_EVENT_MOUSE_DELTA_X: + dx = event->value; + break; + case WSCONS_EVENT_MOUSE_DELTA_Y: + dy = -event->value; + break; +#ifdef WSCONS_EVENT_MOUSE_DELTA_Z + case WSCONS_EVENT_MOUSE_DELTA_Z: + dz = event->value; + break; +#endif + default: + xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name, + event->type); + ++event; + continue; + } + + pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); + ++event; + } + return; +} + + +/* This function is called when the protocol is "wsmouse". */ +static Bool +wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse = pInfo->private; + + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pMse); + return FALSE; + } + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local input proc. */ + pInfo->read_input = wsconsReadInput; + pMse->xisbscale = sizeof(struct wscons_event); + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} +#endif + +#if defined(USBMOUSE_SUPPORT) + +typedef struct _UsbMseRec { + int packetSize; + int iid; + hid_item_t loc_x; /* x locator item */ + hid_item_t loc_y; /* y locator item */ + hid_item_t loc_z; /* z (wheel) locator item */ + hid_item_t loc_btn[MSE_MAXBUTTONS]; /* buttons locator items */ + unsigned char *buffer; +} UsbMseRec, *UsbMsePtr; + +static int +usbMouseProc(DeviceIntPtr pPointer, int what) +{ + InputInfoPtr pInfo; + MouseDevPtr pMse; + UsbMsePtr pUsbMse; + unsigned char map[MSE_MAXBUTTONS + 1]; + int nbuttons; + + pInfo = pPointer->public.devicePrivate; + pMse = pInfo->private; + pMse->device = pPointer; + pUsbMse = pMse->mousePriv; + + switch (what) { + case DEVICE_INIT: + pPointer->public.on = FALSE; + + for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons) + map[nbuttons + 1] = nbuttons + 1; + + InitPointerDeviceStruct((DevicePtr)pPointer, + map, + min(pMse->buttons, MSE_MAXBUTTONS), + miPointerGetMotionEvents, + pMse->Ctrl, + miPointerGetMotionBufferSize()); + + /* X valuator */ + xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 0); + /* Y valuator */ + xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1); + xf86InitValuatorDefaults(pPointer, 1); + xf86MotionHistoryAllocate(pInfo); + break; + + case DEVICE_ON: + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + pMse->buffer = XisbNew(pInfo->fd, pUsbMse->packetSize); + if (!pMse->buffer) { + xfree(pMse); + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } else { + xf86FlushInput(pInfo->fd); + if (!xf86InstallSIGIOHandler (pInfo->fd, usbSigioReadInput, + pInfo)) + AddEnabledDevice(pInfo->fd); + } + } + pMse->lastButtons = 0; + pMse->lastMappedButtons = 0; + pMse->emulateState = 0; + pPointer->public.on = TRUE; + break; + + case DEVICE_OFF: + case DEVICE_CLOSE: + if (pInfo->fd != -1) { + RemoveEnabledDevice(pInfo->fd); + if (pUsbMse->packetSize > 8 && pUsbMse->buffer) { + xfree(pUsbMse->buffer); + } + if (pMse->buffer) { + XisbFree(pMse->buffer); + pMse->buffer = NULL; + } + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + } + pPointer->public.on = FALSE; + usleep(300000); + break; + } + return Success; +} + +static void +usbReadInput(InputInfoPtr pInfo) +{ + MouseDevPtr pMse; + UsbMsePtr pUsbMse; + int buttons = pMse->lastButtons; + int dx = 0, dy = 0, dz = 0, dw = 0; + int n, c; + unsigned char *pBuf; + + pMse = pInfo->private; + pUsbMse = pMse->mousePriv; + + XisbBlockDuration(pMse->buffer, -1); + pBuf = pUsbMse->buffer; + n = 0; + while ((c = XisbRead(pMse->buffer)) >= 0 && n < pUsbMse->packetSize) { + pBuf[n++] = (unsigned char)c; + } + if (n == 0) + return; + if (n != pUsbMse->packetSize) { + xf86Msg(X_WARNING, "%s: incomplete packet, size %d\n", pInfo->name, + n); + } + /* discard packets with an id that don't match the mouse */ + /* XXX this is probably not the right thing */ + if (pUsbMse->iid != 0) { + if (*pBuf++ != pUsbMse->iid) + return; + } + dx = hid_get_data(pBuf, &pUsbMse->loc_x); + dy = hid_get_data(pBuf, &pUsbMse->loc_y); + dz = hid_get_data(pBuf, &pUsbMse->loc_z); + + buttons = 0; + for (n = 0; n < pMse->buttons; n++) { + if (hid_get_data(pBuf, &pUsbMse->loc_btn[n])) + buttons |= (1 << UMS_BUT(n)); + } + pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw); + return; +} + +static void +usbSigioReadInput (int fd, void *closure) +{ + usbReadInput ((InputInfoPtr) closure); +} + +/* This function is called when the protocol is "usb". */ +static Bool +usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + MouseDevPtr pMse = pInfo->private; + UsbMsePtr pUsbMse; + report_desc_t reportDesc; + int i; + + pUsbMse = xalloc(sizeof(UsbMseRec)); + if (pUsbMse == NULL) { + xf86Msg(X_ERROR, "%s: cannot allocate UsbMouseRec\n", pInfo->name); + xfree(pMse); + return FALSE; + } + + pMse->protocol = protocol; + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); + + /* Collect the options, and process the common options. */ + xf86CollectInputOptions(pInfo, NULL, NULL); + xf86ProcessCommonOptions(pInfo, pInfo->options); + + /* Check if the device can be opened. */ + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + if (xf86GetAllowMouseOpenFail()) + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); + else { + xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name); + xfree(pUsbMse); + xfree(pMse); + return FALSE; + } + } + /* Get USB informations */ + reportDesc = hid_get_report_desc(pInfo->fd); + /* Get packet size & iid */ +#ifdef USB_NEW_HID + if (ioctl(pInfo->fd, USB_GET_REPORT_ID, &pUsbMse->iid) == -1) { + xf86Msg(X_ERROR, "Error ioctl USB_GET_REPORT_ID on %s : %s\n", + pInfo->name, strerror(errno)); + return FALSE; + } + pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, + pUsbMse->iid); +#else + pUsbMse->packetSize = hid_report_size(reportDesc, hid_input, + &pUsbMse->iid); +#endif + /* Allocate buffer */ + if (pUsbMse->packetSize <= 8) { + pUsbMse->buffer = pMse->protoBuf; + } else { + pUsbMse->buffer = xalloc(pUsbMse->packetSize); + } + if (pUsbMse->buffer == NULL) { + xf86Msg(X_ERROR, "%s: cannot allocate buffer\n", pInfo->name); + xfree(pUsbMse); + xfree(pMse); + xf86CloseSerial(pInfo->fd); + return FALSE; + } +#ifdef USB_NEW_HID + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), + hid_input, &pUsbMse->loc_x, pUsbMse->iid) < 0) { + xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), + hid_input, &pUsbMse->loc_y, pUsbMse->iid) < 0) { + xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), + hid_input, &pUsbMse->loc_z, pUsbMse->iid) < 0) { + } +#else + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X), + hid_input, &pUsbMse->loc_x) < 0) { + xf86Msg(X_WARNING, "%s: no x locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y), + hid_input, &pUsbMse->loc_y) < 0) { + xf86Msg(X_WARNING, "%s: no y locator\n", pInfo->name); + } + if (hid_locate(reportDesc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_WHEEL), + hid_input, &pUsbMse->loc_z) < 0) { + } +#endif + /* Probe for number of buttons */ + for (i = 1; i <= MSE_MAXBUTTONS; i++) { + if (!hid_locate(reportDesc, HID_USAGE2(HUP_BUTTON, i), + hid_input, &pUsbMse->loc_btn[i-1] +#ifdef USB_NEW_HID + , pUsbMse->iid +#endif + )) + break; + } + pMse->buttons = i-1; + + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; + + /* Private structure */ + pMse->mousePriv = pUsbMse; + + /* Process common mouse options (like Emulate3Buttons, etc). */ + pMse->CommonOptions(pInfo); + + /* Setup the local procs. */ + pInfo->device_control = usbMouseProc; + pInfo->read_input = usbReadInput; + + pInfo->flags |= XI86_CONFIGURED; + return TRUE; +} +#endif /* USBMOUSE */ + +static Bool +bsdMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) +{ + /* The protocol is guaranteed to be one of the internalNames[] */ +#ifdef WSCONS_SUPPORT + if (xf86NameCmp(protocol, "WSMouse") == 0) { + return wsconsPreInit(pInfo, protocol, flags); + } +#endif +#ifdef USBMOUSE_SUPPORT + if (xf86NameCmp(protocol, "usb") == 0) { + return usbPreInit(pInfo, protocol, flags); + } +#endif + return TRUE; +} + +_X_EXPORT OSMouseInfoPtr +xf86OSMouseInit(int flags) +{ + OSMouseInfoPtr p; + + p = xcalloc(sizeof(OSMouseInfoRec), 1); + if (!p) + return NULL; + p->SupportedInterfaces = SupportedInterfaces; + p->BuiltinNames = BuiltinNames; + p->DefaultProtocol = DefaultProtocol; + p->CheckProtocol = CheckProtocol; +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE) + p->SetupAuto = SetupAuto; + p->SetPS2Res = SetSysMouseRes; + p->SetBMRes = SetSysMouseRes; + p->SetMiscRes = SetSysMouseRes; +#endif +#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT) + p->SetupAuto = SetupAuto; + p->SetMiscRes = SetMouseRes; +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) + p->FindDevice = FindDevice; +#endif + p->PreInit = bsdMousePreInit; + return p; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c new file mode 100644 index 000000000..e2f6420d8 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c @@ -0,0 +1,1006 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include <errno.h> +#include <sys/mman.h> + +#ifdef HAS_MTRR_SUPPORT +#ifndef __NetBSD__ +#include <sys/types.h> +#include <sys/memrange.h> +#else +#include "memrange.h" +#endif +#define X_MTRR_ID "XFree86" +#endif + +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) +#include <machine/mtrr.h> +#include <machine/sysarch.h> +#include <sys/queue.h> +#ifdef __x86_64__ +#define i386_set_mtrr x86_64_set_mtrr +#define i386_get_mtrr x86_64_get_mtrr +#define i386_iopl x86_64_iopl +#endif +#endif + +#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__)) +#include <machine/mtrr.h> +#include <machine/sysarch.h> +#endif + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#if defined(__NetBSD__) && !defined(MAP_FILE) +#define MAP_FLAGS MAP_SHARED +#else +#define MAP_FLAGS (MAP_FILE | MAP_SHARED) +#endif + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +#ifdef __OpenBSD__ +#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details" +#define SYSCTL_MSG2 \ + "Check that you have set 'machdep.allowaperture=2'\n" \ + "\tin /etc/sysctl.conf and reboot your machine\n" \ + "\trefer to xf86(4) for details" +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static Bool useDevMem = FALSE; +static int devMemFd = -1; + +#ifdef HAS_APERTURE_DRV +#define DEV_APERTURE "/dev/xf86" +#endif +#define DEV_MEM "/dev/mem" + +static pointer mapVidMem(int, unsigned long, unsigned long, int); +static void unmapVidMem(int, pointer, unsigned long); + +#ifdef HAS_MTRR_SUPPORT +static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType); +static void undoWC(int, pointer); +static Bool cleanMTRR(void); +#endif +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) +static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool, + MessageType); +static void NetBSDundoWC(int, pointer); +#endif +#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__) +static pointer amd64setWC(int, unsigned long, unsigned long, Bool, + MessageType); +static void amd64undoWC(int, pointer); +#endif + +/* + * Check if /dev/mem can be mmap'd. If it can't print a warning when + * "warn" is TRUE. + */ +static void +checkDevMem(Bool warn) +{ + static Bool devMemChecked = FALSE; + int fd; + pointer base; + + if (devMemChecked) + return; + devMemChecked = TRUE; + + if ((fd = open(DEV_MEM, O_RDWR)) >= 0) + { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000); + + if (base != MAP_FAILED) + { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + return; + } else { + /* This should not happen */ + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; + } + } +#ifndef HAS_APERTURE_DRV + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n", + DEV_MEM, strerror(errno)); + } + useDevMem = FALSE; + return; +#else + /* Failed to open /dev/mem, try the aperture driver */ + if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) + { + /* Try to map a page at the VGA address */ + base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE, + MAP_FLAGS, fd, (off_t)0xA0000); + + if (base != MAP_FAILED) + { + munmap((caddr_t)base, 4096); + devMemFd = fd; + useDevMem = TRUE; + xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n", + DEV_APERTURE); + return; + } else { + + if (warn) + { + xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n", + DEV_APERTURE, strerror(errno)); + } + } + } else { + if (warn) + { +#ifndef __OpenBSD__ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n", DEV_MEM, DEV_APERTURE, strerror(errno)); +#else /* __OpenBSD__ */ + xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n" + "\t(%s)\n%s", DEV_MEM, DEV_APERTURE, strerror(errno), + SYSCTL_MSG); +#endif /* __OpenBSD__ */ + } + } + + useDevMem = FALSE; + return; + +#endif +} + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + checkDevMem(TRUE); + pVidMem->linearSupported = useDevMem; + pVidMem->mapMem = mapVidMem; + pVidMem->unmapMem = unmapVidMem; + +#if HAVE_PCI_SYSTEM_INIT_DEV_MEM + if (useDevMem) + pci_system_init_dev_mem(devMemFd); +#endif + +#ifdef HAS_MTRR_SUPPORT + if (useDevMem) { + if (cleanMTRR()) { + pVidMem->setWC = setWC; + pVidMem->undoWC = undoWC; + } + } +#endif +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) + pVidMem->setWC = NetBSDsetWC; + pVidMem->undoWC = NetBSDundoWC; +#endif +#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__) + pVidMem->setWC = amd64setWC; + pVidMem->undoWC = amd64undoWC; +#endif + pVidMem->initialised = TRUE; +} + +static pointer +mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + pointer base; + + checkDevMem(FALSE); + + if (useDevMem) + { + if (devMemFd < 0) + { + FatalError("xf86MapVidMem: failed to open %s (%s)", + DEV_MEM, strerror(errno)); + } + base = mmap((caddr_t)0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, devMemFd, (off_t)Base); + if (base == MAP_FAILED) + { + FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)", + "xf86MapVidMem", DEV_MEM, Size, Base, + strerror(errno)); + } + return(base); + } + + /* else, mmap /dev/vga */ + if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000) + { + FatalError("%s: Address 0x%lx outside allowable range", + "xf86MapVidMem", Base); + } + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_FLAGS, xf86Info.screenFd, + (unsigned long)Base - 0xA0000 + ); + if (base == MAP_FAILED) + { + FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)", + strerror(errno)); + } + return(base); +} + +static void +unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap((caddr_t)Base, Size); +} + +/* + * Read BIOS via mmap()ing DEV_MEM + */ + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + unsigned char *ptr; + int psize; + int mlen; + + checkDevMem(TRUE); + if (devMemFd == -1) { + return(-1); + } + + psize = getpagesize(); + Offset += Base & (psize - 1); + Base &= ~(psize - 1); + mlen = (Offset + Len + psize - 1) & ~(psize - 1); + ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ, + MAP_SHARED, devMemFd, (off_t)Base); + if ((long)ptr == -1) + { + xf86Msg(X_WARNING, + "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n", + DEV_MEM, Len, Base, Offset, strerror(errno)); +#ifdef __OpenBSD__ + if (Base < 0xa0000) { + xf86Msg(X_WARNING, SYSCTL_MSG2); + } +#endif + return(-1); + } +#ifdef DEBUG + ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", + Base, ptr[0] | (ptr[1] << 8)); +#endif + (void)memcpy(Buf, (void *)(ptr + Offset), Len); + (void)munmap((caddr_t)ptr, mlen); +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)" + "-> %02x %02x %02x %02x...\n", + Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]); +#endif + return(Len); +} + +#ifdef USE_I386_IOPL +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; + +_X_EXPORT Bool +xf86EnableIO() +{ + if (ExtendedEnabled) + return TRUE; + + if (i386_iopl(TRUE) < 0) + { +#ifndef __OpenBSD__ + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O", + "xf86EnableIO"); +#else + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif + return FALSE; + } + ExtendedEnabled = TRUE; + + return TRUE; +} + +_X_EXPORT void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + i386_iopl(FALSE); + ExtendedEnabled = FALSE; + + return; +} + +#endif /* USE_I386_IOPL */ + +#ifdef USE_AMD64_IOPL +/***************************************************************************/ +/* I/O Permissions section */ +/***************************************************************************/ + +static Bool ExtendedEnabled = FALSE; + +Bool +xf86EnableIO() +{ + if (ExtendedEnabled) + return TRUE; + + if (amd64_iopl(TRUE) < 0) + { +#ifndef __OpenBSD__ + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O", + "xf86EnableIO"); +#else + xf86Msg(X_WARNING,"%s: Failed to set IOPL for extended I/O\n%s", + "xf86EnableIO", SYSCTL_MSG); +#endif + return FALSE; + } + ExtendedEnabled = TRUE; + + return TRUE; +} + +void +xf86DisableIO() +{ + if (!ExtendedEnabled) + return; + + if (amd64_iopl(FALSE) == 0) { + ExtendedEnabled = FALSE; + } + /* Otherwise, the X server has revoqued its root uid, + and thus cannot give up IO privileges any more */ + + return; +} + +#endif /* USE_AMD64_IOPL */ + +#ifdef USE_DEV_IO +static int IoFd = -1; + +Bool +xf86EnableIO() +{ + if (IoFd >= 0) + return TRUE; + + if ((IoFd = open("/dev/io", O_RDWR)) == -1) + { + xf86Msg(X_WARNING,"xf86EnableIO: " + "Failed to open /dev/io for extended I/O"); + return FALSE; + } + return TRUE; +} + +void +xf86DisableIO() +{ + if (IoFd < 0) + return; + + close(IoFd); + IoFd = -1; + return; +} + +#endif + + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + +#ifdef __GNUC__ + __asm__ __volatile__("cli"); +#else + asm("cli"); +#endif /* __GNUC__ */ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + +#ifdef __GNUC__ + __asm__ __volatile__("sti"); +#else + asm("sti"); +#endif /* __GNUC__ */ + + return; +} + + +#ifdef __NetBSD__ +/***************************************************************************/ +/* Set TV output mode */ +/***************************************************************************/ +void +xf86SetTVOut(int mode) +{ + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS:{ + + if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_ON, &mode) < 0) + { + xf86Msg(X_WARNING, + "xf86SetTVOut: Could not set console to TV output, %s\n", + strerror(errno)); + } + } + break; +#endif /* PCCONS_SUPPORT */ + + default: + FatalError("Xf86SetTVOut: Unsupported console"); + break; + } + return; +} + +void +xf86SetRGBOut() +{ + switch (xf86Info.consType) + { +#ifdef PCCONS_SUPPORT + case PCCONS:{ + + if (ioctl (xf86Info.consoleFd, CONSOLE_X_TV_OFF, 0) < 0) + { + xf86Msg(X_WARNING, + "xf86SetTVOut: Could not set console to RGB output, %s\n", + strerror(errno)); + } + } + break; +#endif /* PCCONS_SUPPORT */ + + default: + FatalError("Xf86SetTVOut: Unsupported console"); + break; + } + return; +} +#endif + +#ifdef HAS_MTRR_SUPPORT +/* memory range (MTRR) support for FreeBSD */ + +/* + * This code is experimental. Some parts may be overkill, and other parts + * may be incomplete. + */ + +/* + * getAllRanges returns the full list of memory ranges with attributes set. + */ + +static struct mem_range_desc * +getAllRanges(int *nmr) +{ + struct mem_range_desc *mrd; + struct mem_range_op mro; + + /* + * Find how many ranges there are. If this fails, then the kernel + * probably doesn't have MTRR support. + */ + mro.mo_arg[0] = 0; + if (ioctl(devMemFd, MEMRANGE_GET, &mro)) + return NULL; + *nmr = mro.mo_arg[0]; + mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc)); + mro.mo_arg[0] = *nmr; + mro.mo_desc = mrd; + if (ioctl(devMemFd, MEMRANGE_GET, &mro)) { + xfree(mrd); + return NULL; + } + return mrd; +} + +/* + * cleanMTRR removes any memory attribute that may be left by a previous + * X server. Normally there won't be any, but this takes care of the + * case where a server crashed without being able finish cleaning up. + */ + +static Bool +cleanMTRR() +{ + struct mem_range_desc *mrd; + struct mem_range_op mro; + int nmr, i; + + /* This shouldn't happen */ + if (devMemFd < 0) + return FALSE; + + if (!(mrd = getAllRanges(&nmr))) + return FALSE; + + for (i = 0; i < nmr; i++) { + if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 && + (mrd[i].mr_flags & MDF_ACTIVE)) { +#ifdef DEBUG + ErrorF("Clean for (0x%lx,0x%lx)\n", + (unsigned long)mrd[i].mr_base, + (unsigned long)mrd[i].mr_len); +#endif + if (mrd[i].mr_flags & MDF_FIXACTIVE) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + mrd[i].mr_flags = MDF_UNCACHEABLE; + } else { + mro.mo_arg[0] = MEMRANGE_SET_REMOVE; + } + mro.mo_desc = mrd + i; + ioctl(devMemFd, MEMRANGE_SET, &mro); + } + } +#ifdef DEBUG + sleep(10); +#endif + xfree(mrd); + return TRUE; +} + +typedef struct x_RangeRec { + struct mem_range_desc mrd; + Bool wasWC; + struct x_RangeRec * next; +} RangeRec, *RangePtr; + +static void +freeRangeList(RangePtr range) +{ + RangePtr rp; + + while (range) { + rp = range; + range = rp->next; + xfree(rp); + } +} + +static RangePtr +dupRangeList(RangePtr list) +{ + RangePtr new = NULL, rp, p; + + rp = list; + while (rp) { + p = xnfalloc(sizeof(RangeRec)); + *p = *rp; + p->next = new; + new = p; + rp = rp->next; + } + return new; +} + +static RangePtr +sortRangeList(RangePtr list) +{ + RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev; + unsigned long minBase; + + /* Sort by base address */ + rp1 = copy = dupRangeList(list); + while (rp1) { + minBase = rp1->mrd.mr_base; + minp = rp1; + minprev = NULL; + prev = rp1; + rp2 = rp1->next; + while (rp2) { + if (rp2->mrd.mr_base < minBase) { + minBase = rp2->mrd.mr_base; + minp = rp2; + minprev = prev; + } + prev = rp2; + rp2 = rp2->next; + } + if (minprev) { + minprev->next = minp->next; + rp1 = copy; + } else { + rp1 = minp->next; + } + minp->next = sorted; + sorted = minp; + } + return sorted; +} + +/* + * findRanges returns a list of ranges that overlap the specified range. + */ + +static void +findRanges(unsigned long base, unsigned long size, RangePtr *ucp, RangePtr *wcp) +{ + struct mem_range_desc *mrd; + int nmr, i; + RangePtr rp, *p; + + if (!(mrd = getAllRanges(&nmr))) + return; + + for (i = 0; i < nmr; i++) { + if ((mrd[i].mr_flags & MDF_ACTIVE) && + mrd[i].mr_base < base + size && + mrd[i].mr_base + mrd[i].mr_len > base) { + if (mrd[i].mr_flags & MDF_WRITECOMBINE) + p = wcp; + else if (mrd[i].mr_flags & MDF_UNCACHEABLE) + p = ucp; + else + continue; + rp = xnfalloc(sizeof(RangeRec)); + rp->mrd = mrd[i]; + rp->next = *p; + *p = rp; + } + } + xfree(mrd); +} + +/* + * This checks if the existing overlapping ranges fully cover the requested + * range. Is this overkill? + */ + +static Bool +fullCoverage(unsigned long base, unsigned long size, RangePtr overlap) +{ + RangePtr rp1, sorted = NULL; + unsigned long end; + + sorted = sortRangeList(overlap); + /* Look for gaps */ + rp1 = sorted; + end = base + size; + while (rp1) { + if (rp1->mrd.mr_base > base) { + freeRangeList(sorted); + return FALSE; + } else { + base = rp1->mrd.mr_base + rp1->mrd.mr_len; + } + if (base >= end) { + freeRangeList(sorted); + return TRUE; + } + rp1 = rp1->next; + } + freeRangeList(sorted); + return FALSE; +} + +static pointer +addWC(int screenNum, unsigned long base, unsigned long size, MessageType from) +{ + RangePtr uc = NULL, wc = NULL, retlist = NULL; + struct mem_range_desc mrd; + struct mem_range_op mro; + + findRanges(base, size, &uc, &wc); + + /* See of the full range is already WC */ + if (!uc && fullCoverage(base, size, wc)) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx) was already set\n", + base, size); + return NULL; + } + + /* Otherwise, try to add the new range */ + mrd.mr_base = base; + mrd.mr_len = size; + strcpy(mrd.mr_owner, X_MTRR_ID); + mrd.mr_flags = MDF_WRITECOMBINE; + mro.mo_desc = &mrd; + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to set write-combining range " + "(0x%lx,0x%lx)\n", base, size); + return NULL; + } else { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx)\n", base, size); + retlist = xnfalloc(sizeof(RangeRec)); + retlist->mrd = mrd; + retlist->wasWC = FALSE; + retlist->next = NULL; + return retlist; + } +} + +static pointer +delWC(int screenNum, unsigned long base, unsigned long size, MessageType from) +{ + RangePtr uc = NULL, wc = NULL, retlist = NULL; + struct mem_range_desc mrd; + struct mem_range_op mro; + + findRanges(base, size, &uc, &wc); + + /* + * See of the full range is already not WC, or if there is full + * coverage from UC ranges. + */ + if (!wc || fullCoverage(base, size, uc)) { + xf86DrvMsg(screenNum, from, + "Write-combining range (0x%lx,0x%lx) was already clear\n", + base, size); + return NULL; + } + + /* Otherwise, try to add the new range */ + mrd.mr_base = base; + mrd.mr_len = size; + strcpy(mrd.mr_owner, X_MTRR_ID); + mrd.mr_flags = MDF_UNCACHEABLE; + mro.mo_desc = &mrd; + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to remove write-combining range " + "(0x%lx,0x%lx)\n", base, size); + /* XXX Should then remove all of the overlapping WC ranges */ + return NULL; + } else { + xf86DrvMsg(screenNum, from, + "Removed Write-combining range (0x%lx,0x%lx)\n", + base, size); + retlist = xnfalloc(sizeof(RangeRec)); + retlist->mrd = mrd; + retlist->wasWC = TRUE; + retlist->next = NULL; + return retlist; + } +} + +static pointer +setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + if (enable) + return addWC(screenNum, base, size, from); + else + return delWC(screenNum, base, size, from); +} + +static void +undoWC(int screenNum, pointer list) +{ + RangePtr rp; + struct mem_range_op mro; + Bool failed; + + rp = list; + while (rp) { +#ifdef DEBUG + ErrorF("Undo for (0x%lx,0x%lx), %d\n", + (unsigned long)rp->mrd.mr_base, + (unsigned long)rp->mrd.mr_len, rp->wasWC); +#endif + failed = FALSE; + if (rp->wasWC) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + rp->mrd.mr_flags = MDF_WRITECOMBINE; + strcpy(rp->mrd.mr_owner, "unknown"); + } else { + mro.mo_arg[0] = MEMRANGE_SET_REMOVE; + } + mro.mo_desc = &rp->mrd; + + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) { + if (!rp->wasWC) { + mro.mo_arg[0] = MEMRANGE_SET_UPDATE; + rp->mrd.mr_flags = MDF_UNCACHEABLE; + strcpy(rp->mrd.mr_owner, "unknown"); + if (ioctl(devMemFd, MEMRANGE_SET, &mro)) + failed = TRUE; + } else + failed = TRUE; + } + if (failed) { + xf86DrvMsg(screenNum, X_WARNING, + "Failed to restore MTRR range (0x%lx,0x%lx)\n", + (unsigned long)rp->mrd.mr_base, + (unsigned long)rp->mrd.mr_len); + } + rp = rp->next; + } +} + +#endif /* HAS_MTRR_SUPPORT */ + + +#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__) +static pointer +NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + struct mtrr *mtrrp; + int n; + + xf86DrvMsg(screenNum, X_WARNING, + "%s MTRR %lx - %lx\n", enable ? "set" : "remove", + base, (base + size)); + + mtrrp = xnfalloc(sizeof (struct mtrr)); + mtrrp->base = base; + mtrrp->len = size; + mtrrp->type = MTRR_TYPE_WC; + + /* + * MTRR_PRIVATE will make this MTRR get reset automatically + * if this process exits, so we have no need for an explicit + * cleanup operation when starting a new server. + */ + + if (enable) + mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; + else + mtrrp->flags = 0; + n = 1; + + if (i386_set_mtrr(mtrrp, &n) < 0) { + xfree(mtrrp); + return NULL; + } + return mtrrp; +} + +static void +NetBSDundoWC(int screenNum, pointer list) +{ + struct mtrr *mtrrp = (struct mtrr *)list; + int n; + + if (mtrrp == NULL) + return; + n = 1; + mtrrp->flags &= ~MTRR_VALID; + i386_set_mtrr(mtrrp, &n); + xfree(mtrrp); +} +#endif + +#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__)) +static pointer +amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable, + MessageType from) +{ + struct mtrr *mtrrp; + int n; + + xf86DrvMsg(screenNum, X_WARNING, + "%s MTRR %lx - %lx\n", enable ? "set" : "remove", + base, (base + size)); + + mtrrp = xnfalloc(sizeof (struct mtrr)); + mtrrp->base = base; + mtrrp->len = size; + mtrrp->type = MTRR_TYPE_WC; + + /* + * MTRR_PRIVATE will make this MTRR get reset automatically + * if this process exits, so we have no need for an explicit + * cleanup operation when starting a new server. + */ + + if (enable) + mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; + else + mtrrp->flags = 0; + n = 1; + + if (amd64_set_mtrr(mtrrp, &n) < 0) { + xfree(mtrrp); + return NULL; + } + return mtrrp; +} + +static void +amd64undoWC(int screenNum, pointer list) +{ + struct mtrr *mtrrp = (struct mtrr *)list; + int n; + + if (mtrrp == NULL) + return; + n = 1; + mtrrp->flags &= ~MTRR_VALID; + amd64_set_mtrr(mtrrp, &n); + xfree(mtrrp); +} +#endif /* OpenBSD/amd64 */ + diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/data.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/data.c new file mode 100644 index 000000000..292e5d885 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/data.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <assert.h> +#include <stdlib.h> +#include "usb.h" + +int +hid_get_data(void *p, hid_item_t *h) +{ + unsigned char *buf; + unsigned int hpos; + unsigned int hsize; + int data; + int i, end, offs; + + _DIAGASSERT(p != NULL); + _DIAGASSERT(h != NULL); + + buf = p; + hpos = h->pos; /* bit position of data */ + hsize = h->report_size; /* bit length of data */ + + if (hsize == 0) + return (0); + offs = hpos / 8; + end = (hpos + hsize) / 8 - offs; + data = 0; + for (i = 0; i <= end; i++) + data |= buf[offs + i] << (i*8); + data >>= hpos % 8; + data &= (1 << hsize) - 1; + if (h->logical_minimum < 0) { + /* Need to sign extend */ + hsize = sizeof data * 8 - hsize; + data = (data << hsize) >> hsize; + } + return (data); +} + +void +hid_set_data(void *p, hid_item_t *h, int data) +{ + unsigned char *buf; + unsigned int hpos; + unsigned int hsize; + int i, end, offs; + + _DIAGASSERT(p != NULL); + _DIAGASSERT(h != NULL); + + buf = p; + hpos = h->pos; /* bit position of data */ + hsize = h->report_size; /* bit length of data */ + + if (hsize != 32) + data &= (1 << hsize) - 1; + data <<= (hpos % 8); + + offs = hpos / 8; + end = (hpos + hsize) / 8 - offs; + data = 0; + for (i = 0; i <= end; i++) + buf[offs + i] |= (data >> (i*8)) & 0xff; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c new file mode 100644 index 000000000..4dc3524d5 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/descr.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <sys/types.h> + +#include <assert.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/time.h> + +#include <dev/usb/usb.h> + +#include "usb.h" +#include "usbvar.h" + +report_desc_t +hid_get_report_desc(fd) + int fd; +{ + struct usb_ctl_report_desc rep; + report_desc_t r; + + _DIAGASSERT(fd != -1); + + rep.size = 0; + if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) + return (0); + r = malloc(sizeof *r + rep.size); + if (r == 0) { + errno = ENOMEM; + return (0); + } + r->size = rep.size; + memcpy(r->data, rep.data, (unsigned int)rep.size); + return (r); +} + +void +hid_dispose_report_desc(r) + report_desc_t r; +{ + + free(r); +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c new file mode 100644 index 000000000..0a846e42b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/parse.c @@ -0,0 +1,401 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <assert.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbhid.h> + +#include "usb.h" +#include "usbvar.h" + +#define MAXUSAGE 100 +struct hid_data { + u_char *start; + u_char *end; + u_char *p; + hid_item_t cur; + unsigned int usages[MAXUSAGE]; + int nusage; + int minset; + int multi; + int multimax; + int kindset; +}; + +static int min(int x, int y) { return x < y ? x : y; } + +static void +hid_clear_local(hid_item_t *c) +{ + + _DIAGASSERT(c != NULL); + + c->usage = 0; + c->usage_minimum = 0; + c->usage_maximum = 0; + c->designator_index = 0; + c->designator_minimum = 0; + c->designator_maximum = 0; + c->string_index = 0; + c->string_minimum = 0; + c->string_maximum = 0; + c->set_delimiter = 0; +} + +hid_data_t +hid_start_parse(report_desc_t d, int kindset) +{ + struct hid_data *s; + + _DIAGASSERT(d != NULL); + + s = malloc(sizeof *s); + memset(s, 0, sizeof *s); + s->start = s->p = d->data; + s->end = d->data + d->size; + s->kindset = kindset; + return (s); +} + +void +hid_end_parse(hid_data_t s) +{ + + _DIAGASSERT(s != NULL); + + while (s->cur.next) { + hid_item_t *hi = s->cur.next->next; + free(s->cur.next); + s->cur.next = hi; + } + free(s); +} + +int +hid_get_item(hid_data_t s, hid_item_t *h) +{ + hid_item_t *c; + unsigned int bTag = 0, bType = 0, bSize; + unsigned char *data; + int dval; + unsigned char *p; + hid_item_t *hi; + int i; + + _DIAGASSERT(s != NULL); + _DIAGASSERT(h != NULL); + + c = &s->cur; + + top: + if (s->multimax) { + if (s->multi < s->multimax) { + c->usage = s->usages[min(s->multi, s->nusage-1)]; + s->multi++; + *h = *c; + c->pos += c->report_size; + h->next = 0; + return (1); + } else { + c->report_count = s->multimax; + s->multimax = 0; + s->nusage = 0; + hid_clear_local(c); + } + } + for (;;) { + p = s->p; + if (p >= s->end) + return (0); + + bSize = *p++; + if (bSize == 0xfe) { + /* long item */ + bSize = *p++; + bSize |= *p++ << 8; + bTag = *p++; + data = p; + p += bSize; + } else { + /* short item */ + bTag = bSize >> 4; + bType = (bSize >> 2) & 3; + bSize &= 3; + if (bSize == 3) bSize = 4; + data = p; + p += bSize; + } + s->p = p; + /* + * The spec is unclear if the data is signed or unsigned. + */ + switch(bSize) { + case 0: + dval = 0; + break; + case 1: + dval = (int8_t)*data++; + break; + case 2: + dval = *data++; + dval |= *data++ << 8; + dval = (int16_t)dval; + break; + case 4: + dval = *data++; + dval |= *data++ << 8; + dval |= *data++ << 16; + dval |= *data++ << 24; + break; + default: + return (-1); + } + + switch (bType) { + case 0: /* Main */ + switch (bTag) { + case 8: /* Input */ + if (!(s->kindset & (1 << hid_input))) + continue; + c->kind = hid_input; + c->flags = dval; + ret: + if (c->flags & HIO_VARIABLE) { + s->multimax = c->report_count; + s->multi = 0; + c->report_count = 1; + if (s->minset) { + for (i = c->usage_minimum; + i <= c->usage_maximum; + i++) { + s->usages[s->nusage] = i; + if (s->nusage < MAXUSAGE-1) + s->nusage++; + } + s->minset = 0; + } + goto top; + } else { + if (s->minset) + c->usage = c->usage_minimum; + *h = *c; + h->next = 0; + c->pos += c->report_size * c->report_count; + hid_clear_local(c); + s->minset = 0; + return (1); + } + case 9: /* Output */ + if (!(s->kindset & (1 << hid_output))) + continue; + c->kind = hid_output; + c->flags = dval; + goto ret; + case 10: /* Collection */ + c->kind = hid_collection; + c->collection = dval; + c->collevel++; + *h = *c; + hid_clear_local(c); + s->nusage = 0; + return (1); + case 11: /* Feature */ + if (!(s->kindset & (1 << hid_feature))) + continue; + c->kind = hid_feature; + c->flags = dval; + goto ret; + case 12: /* End collection */ + c->kind = hid_endcollection; + c->collevel--; + *h = *c; + hid_clear_local(c); + s->nusage = 0; + return (1); + default: + return (-2); + } + + case 1: /* Global */ + switch (bTag) { + case 0: + c->_usage_page = dval << 16; + break; + case 1: + c->logical_minimum = dval; + break; + case 2: + c->logical_maximum = dval; + break; + case 3: + c->physical_maximum = dval; + break; + case 4: + c->physical_maximum = dval; + break; + case 5: + c->unit_exponent = dval; + break; + case 6: + c->unit = dval; + break; + case 7: + c->report_size = dval; + break; + case 8: + c->report_ID = dval; + break; + case 9: + c->report_count = dval; + break; + case 10: /* Push */ + hi = malloc(sizeof *hi); + *hi = s->cur; + c->next = hi; + break; + case 11: /* Pop */ + hi = c->next; + s->cur = *hi; + free(hi); + break; + default: + return (-3); + } + break; + case 2: /* Local */ + switch (bTag) { + case 0: + if (bSize == 1) + dval = c->_usage_page | (dval&0xff); + else if (bSize == 2) + dval = c->_usage_page | (dval&0xffff); + c->usage = dval; + if (s->nusage < MAXUSAGE) + s->usages[s->nusage++] = dval; + /* else XXX */ + break; + case 1: + s->minset = 1; + if (bSize == 1) + dval = c->_usage_page | (dval&0xff); + else if (bSize == 2) + dval = c->_usage_page | (dval&0xffff); + c->usage_minimum = dval; + break; + case 2: + if (bSize == 1) + dval = c->_usage_page | (dval&0xff); + else if (bSize == 2) + dval = c->_usage_page | (dval&0xffff); + c->usage_maximum = dval; + break; + case 3: + c->designator_index = dval; + break; + case 4: + c->designator_minimum = dval; + break; + case 5: + c->designator_maximum = dval; + break; + case 7: + c->string_index = dval; + break; + case 8: + c->string_minimum = dval; + break; + case 9: + c->string_maximum = dval; + break; + case 10: + c->set_delimiter = dval; + break; + default: + return (-4); + } + break; + default: + return (-5); + } + } +} + +int +hid_report_size(report_desc_t r, enum hid_kind k, int *idp) +{ + struct hid_data *d; + hid_item_t h; + int size, id; + + _DIAGASSERT(r != NULL); + /* idp may be NULL */ + + id = 0; + if (idp) + *idp = 0; + memset(&h, 0, sizeof h); + for (d = hid_start_parse(r, 1<<k); hid_get_item(d, &h); ) { + if (h.report_ID != 0) { + if (idp) + *idp = h.report_ID; + id = 8; + } + } + hid_end_parse(d); + size = h.pos + id; + return ((size + 7) / 8); +} + +int +hid_locate(desc, u, k, h) + report_desc_t desc; + unsigned int u; + enum hid_kind k; + hid_item_t *h; +{ + hid_data_t d; + + _DIAGASSERT(desc != NULL); + _DIAGASSERT(h != NULL); + + for (d = hid_start_parse(desc, 1<<k); hid_get_item(d, h); ) { + if (h->kind == k && !(h->flags & HIO_CONST) && h->usage == u) { + hid_end_parse(d); + return (1); + } + } + hid_end_parse(d); + h->report_size = 0; + return (0); +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c b/xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c new file mode 100644 index 000000000..9b491c57a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usage.c @@ -0,0 +1,196 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <ctype.h> +#include <err.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "usb.h" + +#define _PATH_HIDTABLE "/usr/share/misc/usb_hid_usages" + +struct usage_in_page { + char *name; + int usage; +}; + +static struct usage_page { + char *name; + int usage; + struct usage_in_page *page_contents; + int pagesize, pagesizemax; +} *pages; +static int npages, npagesmax; + +#ifdef DEBUG +void +dump_hid_table(void) +{ + int i, j; + + for (i = 0; i < npages; i++) { + printf("%d\t%s\n", pages[i].usage, pages[i].name); + for (j = 0; j < pages[i].pagesize; j++) { + printf("\t%d\t%s\n", pages[i].page_contents[j].usage, + pages[i].page_contents[j].name); + } + } +} +#endif + +void +hid_init(char *hidname) +{ + FILE *f; + char line[100], name[100], *p, *n; + int no; + int lineno; + struct usage_page *curpage = 0; + + if (hidname == 0) + hidname = _PATH_HIDTABLE; + + f = fopen(hidname, "r"); + if (f == NULL) + err(1, "%s", hidname); + for (lineno = 1; ; lineno++) { + if (fgets(line, sizeof line, f) == NULL) + break; + if (line[0] == '#') + continue; + for (p = line; *p && isspace(*p); p++) + ; + if (!*p) + continue; + if (sscanf(line, " * %[^\n]", name) == 1) + no = -1; + else if (sscanf(line, " 0x%x %[^\n]", &no, name) != 2 && + sscanf(line, " %d %[^\n]", &no, name) != 2) + errx(1, "file %s, line %d, syntax error\n", + hidname, lineno); + for (p = name; *p; p++) + if (isspace(*p) || *p == '.') + *p = '_'; + n = strdup(name); + if (!n) + err(1, "strdup"); + if (isspace(line[0])) { + if (!curpage) + errx(1, "file %s, line %d, syntax error\n", + hidname, lineno); + if (curpage->pagesize >= curpage->pagesizemax) { + curpage->pagesizemax += 10; + curpage->page_contents = + realloc(curpage->page_contents, + curpage->pagesizemax * + sizeof (struct usage_in_page)); + if (!curpage->page_contents) + err(1, "realloc"); + } + curpage->page_contents[curpage->pagesize].name = n; + curpage->page_contents[curpage->pagesize].usage = no; + curpage->pagesize++; + } else { + if (npages >= npagesmax) { + if (pages == 0) { + npagesmax = 5; + pages = malloc(npagesmax * + sizeof (struct usage_page)); + } else { + npagesmax += 5; + pages = realloc(pages, + npagesmax * + sizeof (struct usage_page)); + } + if (!pages) + err(1, "alloc"); + } + curpage = &pages[npages++]; + curpage->name = n; + curpage->usage = no; + curpage->pagesize = 0; + curpage->pagesizemax = 10; + curpage->page_contents = + malloc(curpage->pagesizemax * + sizeof (struct usage_in_page)); + if (!curpage->page_contents) + err(1, "malloc"); + } + } + fclose(f); +#ifdef DEBUG + dump_hid_table(); +#endif +} + +char * +hid_usage_page(int i) +{ + static char b[10]; + int k; + + if (!pages) + errx(1, "no hid table\n"); + + for (k = 0; k < npages; k++) + if (pages[k].usage == i) + return pages[k].name; + sprintf(b, "0x%02x", i); + return b; +} + +char * +hid_usage_in_page(unsigned int u) +{ + int page = HID_PAGE(u); + int i = HID_USAGE(u); + static char b[100]; + int j, k, us; + + for (k = 0; k < npages; k++) + if (pages[k].usage == page) + break; + if (k >= npages) + goto bad; + for (j = 0; j < pages[k].pagesize; j++) { + us = pages[k].page_contents[j].usage; + if (us == -1) { + sprintf(b, pages[k].page_contents[j].name, i); + return b; + } + if (us == i) + return pages[k].page_contents[j].name; + } + bad: + sprintf(b, "0x%02x", i); + return b; +} diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 new file mode 100644 index 000000000..f88a28cd6 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.3 @@ -0,0 +1,191 @@ +.\" $NetBSD: usb.3,v 1.9 1999/11/08 22:33:40 augustss Exp $ +.\" +.\" Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/libusb/usb.3,v 1.1 2000/02/11 18:06:50 dawes Exp $ +.\" +.Dd May 11, 1999 +.Dt USB 3 +.Os +.Sh NAME +.Nm usb , +.Nm hid_get_report_desc , +.Nm hid_dispose_report_desc , +.Nm hid_start_parse , +.Nm hid_end_parse , +.Nm hid_get_item , +.Nm hid_report_size , +.Nm hid_locate , +.Nm hid_usage_page , +.Nm hid_usage_in_page , +.Nm hid_init , +.Nm hid_get_data , +.Nm hid_set_data +.Nd USB HID access routines +.Sh LIBRARY +.Lb libusb +.Sh SYNOPSIS +.Fd #include <usb.h> +.Ft report_desc_t +.Fn hid_get_report_desc "int file" +.Ft void +.Fn hid_dispose_report_desc "report_desc_t d" +.Ft hid_data_t +.Fn hid_start_parse "report_desc_t d" "int kindset" +.Ft void +.Fn hid_end_parse "hid_data_t s" +.Ft int +.Fn hid_get_item "hid_data_t s" "hid_item_t *h" +.Ft int +.Fn hid_report_size "report_desc_t d" "hid_kind_t k" "int *idp" +.Ft int +.Fn hid_locate "report_desc_t d" "u_int usage" "hid_kind_t k" "hid_item_t *h" +.Ft char * +.Fn hid_usage_page "int i" +.Ft char * +.Fn hid_usage_in_page "u_int u" +.Ft void +.Fn hid_init "char *file" +.Ft int +.Fn hid_get_data "void *data" "hid_item_t *h" +.Ft void +.Fn hid_set_data "void *data" "hid_item_t *h" "u_int data" +.Sh DESCRIPTION +The +.Nm +library provides routines to extract data from USB Human Interface Devices. +.Ss INTRODUCTION +USB HID devices send and receive data layed out a device dependent +way. The +.Nm +library contains routines to extract the +.Em report descriptor +which contains the data layout information and then use this information. +.Pp +The routines can be divided into four parts: extraction of the descriptor, +parsing of the descriptor, translating to/from symbolic names, and +data manipulation. +.Ss DESCRIPTOR FUNCTIONS +A report descriptor can be obtained by calling +.Fn hid_get_report_desc +with a file descriptor obtained by opening a +.Xr uhid 4 +device. +When the report descriptor is no longer needed it should be freed +by calling +.Fn hid_dispose_report_desc . +The type +.Fa report_desc_t +is opaque and should be used when calling the parsing functions. +.Ss DESCRIPTOR PARSING FUNCTIONS +To parse the report descriptor the +.Fn hid_start_parse +function should be called with a report descriptor and a set that +describes which items that are interesting. The set is obtained +by oring together values +.Fa "(1 << k)" +where +.Fa k +is an item of type +.Fa hid_kind_t . +The function returns +.Fa NULL +if the initialization fails, otherwise an opaque value to be used +in subsequent calls. +After parsing the +.Fn hid_end_parse +function should be called to free internal data structures. +.Pp +To iterate through all the items in the report descriptor +.Fn hid_get_item +should be called while it returns a value greater than 0. +When the report descriptor ends it will returns 0; a syntax +error within the report descriptor will cause a return value less +than 0. +The struct pointed to by +.Fa h +will be filled with the relevant data for the item. +The definition of +.Fa hid_item_t +can be found in +.Pa <usb.h> +and the meaning of the components in the USB HID documentation. +.Pp +Data should be read/written to the device in the size of +the report. The size of a report (of a certain kind) can be +computed by the +.Fn hid_report_size +function. If the report is prefixed by an ID byte it is +stored at +.Fa idp , +otherwise it will contain 0. +.Pp +To locate a single item the +.Fn hid_locate +function can be used. It should be given the usage code of +the item and its kind and it will fill the item and return +non-zero if the item was found. +.Pp +.Ss NAME TRANSLATION FUNCTIONS +The function +.Fn hid_usage_page +will return the symbolic name of a usage page, and the function +.Fn hid_usage_in_page +will return the symbolic name of the usage within the page. +Both these functions may return a pointer to static data. +Before either of these functions can be called the usage table +must be parsed, this is done by calling +.Fn hid_init +with the name of the table. Passing +.Fa NULL +to this function will cause it to use the default table. +.Ss DATA EXTRACTION FUNCTIONS +Given the data obtained from a HID device and an item in the +report descriptor the +.Fn hid_get_data +function extracts the value of the item. +Conversely +.Fn hid_set_data +can be used to put data into a report (which must be zeroed first). +.Sh EXAMPLE +Not yet. +.Sh FILES +.Pa /usr/share/misc/usb_hid_usages +The default HID usage table. +.Sh BUGS +This man page is woefully incomplete. +.Sh SEE ALSO +The +.Tn USB +specifications can be found at +.Dv http://www.usb.org/developers/docs.htm . +.Pp +.Xr hid 4 , +.Xr usb 4 . +.Sh HISTORY +The +.Nm +library first appeared in +.Nx 1.5 . diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h new file mode 100644 index 000000000..c39dc063a --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#define _DIAGASSERT(e) assert(e) + +typedef struct report_desc *report_desc_t; + +typedef struct hid_data *hid_data_t; + +typedef enum hid_kind { + hid_input, hid_output, hid_feature, hid_collection, hid_endcollection +}hid_kind_t; + +typedef struct hid_item { + /* Global */ + int _usage_page; + int logical_minimum; + int logical_maximum; + int physical_minimum; + int physical_maximum; + int unit_exponent; + int unit; + int report_size; + int report_ID; + int report_count; + /* Local */ + unsigned int usage; + int usage_minimum; + int usage_maximum; + int designator_index; + int designator_minimum; + int designator_maximum; + int string_index; + int string_minimum; + int string_maximum; + int set_delimiter; + /* Misc */ + int collection; + int collevel; + enum hid_kind kind; + unsigned int flags; + /* Absolute data position (bits) */ + unsigned int pos; + /* */ + struct hid_item *next; +} hid_item_t; + +#define HID_PAGE(u) ((u) >> 16) +#define HID_USAGE(u) ((u) & 0xffff) + +/* Obtaining a report descriptor, descr.c: */ +report_desc_t hid_get_report_desc __P((int file)); +void hid_dispose_report_desc __P((report_desc_t)); + +/* Parsing of a HID report descriptor, parse.c: */ +hid_data_t hid_start_parse __P((report_desc_t d, int kindset)); +void hid_end_parse __P((hid_data_t s)); +int hid_get_item __P((hid_data_t s, hid_item_t *h)); +int hid_report_size __P((report_desc_t d, enum hid_kind k, int *idp)); +int hid_locate __P((report_desc_t d, unsigned int usage, enum hid_kind k, hid_item_t *h)); + +/* Conversion to/from usage names, usage.c: */ +char *hid_usage_page __P((int i)); +char *hid_usage_in_page __P((unsigned int u)); +void hid_init __P((char *file)); + +/* Extracting/insertion of data, data.c: */ +int hid_get_data __P((void *p, hid_item_t *h)); +void hid_set_data __P((void *p, hid_item_t *h, int data)); diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages new file mode 100644 index 000000000..02f122028 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usb_hid_usages @@ -0,0 +1,1079 @@ +# $NetBSD: usb_hid_usages,v 1.3 1999/07/02 15:46:53 simonb Exp $ +# +# USB HID usage table +# Syntax: +# - lines that do not start with a white space give the number and name of +# a usage page. +# - lines that start with a white space give the number and name of +# a usage with the last given page. +# If the number is * then the line matches all usages and the name +# is a printf formatting string that will be given the usage number. +# +# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/libusb/usb_hid_usages,v 1.1.2.2 1999/12/03 10:12:43 hohndel Exp $ +# +1 Generic Desktop + 0x00 Undefined + 0x01 Pointer + 0x02 Mouse + 0x03 Reserved + 0x04 Joystick + 0x05 Game Pad + 0x06 Keyboard + 0x07 Keypad + 0x08 Multi-axis Controller + 0x30 X + 0x31 Y + 0x32 Z + 0x33 Rx + 0x34 Ry + 0x35 Rz + 0x36 Slider + 0x37 Dial + 0x38 Wheel + 0x39 Hat Switch + 0x3A Counted Buffer + 0x3B Byte Count + 0x3C Motion Wakeup + 0x40 Vx + 0x41 Vy + 0x42 Vz + 0x43 Vbrx + 0x44 Vbry + 0x45 Vbrx + 0x46 Vno + 0x80 System Control + 0x81 System Power Down + 0x82 System Sleep + 0x83 System Wake Up + 0x84 System Context Menu + 0x85 System Main Menu + 0x86 System App Menu + 0x87 System Menu Help + 0x88 System Menu Exit + 0x89 System Menu Select + 0x8A System Menu Right + 0x8B System Menu Left + 0x8C System Menu Up + 0x8D System Menu Down + 0x90 D-pad Up + 0x91 D-pad Down + 0x92 D-pad Right + 0x93 D-pad Left + +2 Simulation Controls + 0x00 Undefined + 0x01 Flight Simulation Device + 0x02 Automobile Simulation Device + 0x03 Tank Simulation Device + 0x04 Spaceship Simulation Device + 0x05 Submarine Simulation Device + 0x06 Sailing Simulation Device + 0x07 Motorcycle Simulation Device + 0x08 Sports Simulation Device + 0x09 Airplane Simulation Device + 0x0A Helicopter Simulation Device + 0x0B Magic Carpet Simulation Device + 0x0C Bicycle + 0x20 Flight Control Stick + 0x21 Flight Stick + 0x22 Cyclic Control + 0x23 Cyclic Trim + 0x24 Flight Yoke + 0x25 Track Control + 0x26 Driving Control + 0xB0 Aileron + 0xB1 Aileron Trim + 0xB2 Anti-Torque Control + 0xB3 Auto-pilot Enable + 0xB4 Chaff Release + 0xB5 Collective Control + 0xB6 Dive Brake + 0xB7 Electronic Counter Measures + 0xB8 Elevator + 0xB9 Elevator Trim + 0xBA Rudder + 0xBB Throttle + 0xBC Flight Communication + 0xBD Flare Release + 0xBE Landing Gear + 0xBF Toe Brake + 0xC0 Trigger + 0xC1 Weapons Arm + 0xC2 Weapons Select + 0xC3 Wing Flaps + 0xC4 Accelerator + 0xC5 Brake + 0xC6 Clutch + 0xC7 Shifter + 0xC8 Steering + 0xC9 Turret Direction + 0xCA Barrel Elevation + 0xCB Dive Plane + 0xCC Ballast + 0xCD Bicycle Crank + 0xCE Handle Bars + 0xCF Front Brake + 0xD0 Rear Brake + +3 VR Controls + 0x00 Unidentified + 0x01 Belt + 0x02 Body Suit + 0x03 Flexor + 0x04 Glove + 0x05 Head Tracker + 0x06 Head Mounted Display + 0x07 Hand Tracker + 0x08 Oculometer + 0x09 Vest + 0x0A Animatronic Device + 0x20 Stereo Enable + 0x21 Display Enable + +4 Sports Controls + 0x00 Unidentified + 0x01 Baseball Bat + 0x02 Golf Club + 0x03 Rowing Machine + 0x04 Treadmill + 0x30 Oar + 0x31 Slope + 0x32 Rate + 0x33 Stick Speed + 0x34 Stick Face Angle + 0x35 Stick Heel/Toe + 0x36 Stick Follow Through + 0x37 Stick Tempo + 0x38 Stick Type + 0x39 Stick Height + 0x50 Putter + 0x51 1 Iron + 0x52 2 Iron + 0x53 3 Iron + 0x54 4 Iron + 0x55 5 Iron + 0x56 6 Iron + 0x57 7 Iron + 0x58 8 Iron + 0x59 9 Iron + 0x5A 10 Iron + 0x5B 11 Iron + 0x5C Sand Wedge + 0x5D Loft Wedge + 0x5E Power Wedge + 0x5F 1 Wood + 0x60 3 Wood + 0x61 5 Wood + 0x62 7 Wood + 0x63 9 Wood + +5 Game Controls + 0x00 Undefined + 0x01 3D Game Controller + 0x02 Pinball Device + 0x03 Gun Device + 0x20 Point of View + 0x21 Turn Right/Left + 0x22 Pitch Right/Left + 0x23 Roll Forward/Backward + 0x24 Move Right/Left + 0x25 Move Forward/Backward + 0x26 Move Up/Down + 0x27 Lean Right/Left + 0x28 Lean Forward/Backward + 0x29 Height of POV + 0x2A Flipper + 0x2B Secondary Flipper + 0x2C Bump + 0x2D New Game + 0x2E Shoot Ball + 0x2F Player + 0x30 Gun Bolt + 0x31 Gun Clip + 0x32 Gun Selector + 0x33 Gun Single Shot + 0x34 Gun Burst + 0x35 Gun Automatic + 0x36 Gun Safety + 0x37 Gamepad Fire/Jump + 0x39 Gamepad Trigger + +7 Keyboard + 0x00 Reserved (no event indicated) + 0x01 Keyboard ErrorRollOver + 0x02 Keyboard POSTFail + 0x03 Keyboard ErrorUndefined + 0x04 Keyboard a and A + 0x05 Keyboard b and B + 0x06 Keyboard c and C + 0x07 Keyboard d and D + 0x08 Keyboard e and E + 0x09 Keyboard f and F + 0x0A Keyboard g and G + 0x0B Keyboard h and H + 0x0C Keyboard i and I + 0x0D Keyboard j and J + 0x0E Keyboard k and K + 0x0F Keyboard l and L + 0x10 Keyboard m and M + 0x11 Keyboard n and N + 0x12 Keyboard o and O + 0x13 Keyboard p and P + 0x14 Keyboard q and Q + 0x15 Keyboard r and R + 0x16 Keyboard s and S + 0x17 Keyboard t and T + 0x18 Keyboard u and U + 0x19 Keyboard v and V + 0x1A Keyboard w and W + 0x1B Keyboard x and X + 0x1C Keyboard y and Y + 0x1D Keyboard z and Z + 0x1E Keyboard 1 and ! + 0x1F Keyboard 2 and @ + 0x20 Keyboard 3 and # + 0x21 Keyboard 4 and $ + 0x22 Keyboard 5 and % + 0x23 Keyboard 6 and ^ + 0x24 Keyboard 7 and & + 0x25 Keyboard 8 and * + 0x26 Keyboard 9 and ( + 0x27 Keyboard 0 and ) + 0x28 Keyboard Return (ENTER) + 0x29 Keyboard ESCAPE + 0x2A Keyboard DELETE (Backspace) + 0x2B Keyboard Tab + 0x2C Keyboard Spacebar + 0x2D Keyboard - and (underscore) + 0x2E Keyboard = and + + 0x2F Keyboard [ and { + 0x30 Keyboard ] and } + 0x31 Keyboard \ and | + 0x32 Keyboard Non-US # and ~ + 0x33 Keyboard ; and : + 0x34 Keyboard ' and " + 0x35 Keyboard Grave Accent and Tilde + 0x36 Keyboard, and < + 0x37 Keyboard . and > + 0x38 Keyboard / and ? + 0x39 Keyboard Caps Lock + 0x3A Keyboard F1 + 0x3B Keyboard F2 + 0x3C Keyboard F3 + 0x3D Keyboard F4 + 0x3E Keyboard F5 + 0x3F Keyboard F6 + 0x40 Keyboard F7 + 0x41 Keyboard F8 + 0x42 Keyboard F9 + 0x43 Keyboard F10 + 0x44 Keyboard F11 + 0x45 Keyboard F12 + 0x46 Keyboard PrintScreen + 0x47 Keyboard Scroll Lock + 0x48 Keyboard Pause + 0x49 Keyboard Insert + 0x4A Keyboard Home + 0x4B Keyboard PageUp + 0x4C Keyboard Delete Forward + 0x4D Keyboard End + 0x4E Keyboard PageDown + 0x4F Keyboard RightArrow + 0x50 Keyboard LeftArrow + 0x51 Keyboard DownArrow + 0x52 Keyboard UpArrow + 0x53 Keypad Num Lock and Clear + 0x54 Keypad / + 0x55 Keypad * + 0x56 Keypad - + 0x57 Keypad + + 0x58 Keypad ENTER + 0x59 Keypad 1 and End + 0x5A Keypad 2 and Down Arrow + 0x5B Keypad 3 and PageDn + 0x5C Keypad 4 and Left Arrow + 0x5D Keypad 5 + 0x5E Keypad 6 and Right Arrow + 0x5F Keypad 7 and Home + 0x60 Keypad 8 and Up Arrow + 0x61 Keypad 9 and PageUp + 0x62 Keypad 0 and Insert + 0x63 Keypad . and Delete + 0x64 Keyboard Non-US \ and | + 0x65 Keyboard Application + 0x66 Keyboard Power + 0x67 Keypad = + 0x68 Keyboard F13 + 0x69 Keyboard F14 + 0x6A Keyboard F15 + 0x6B Keyboard F16 + 0x6C Keyboard F17 + 0x6D Keyboard F18 + 0x6E Keyboard F19 + 0x6F Keyboard F20 + 0x70 Keyboard F21 + 0x71 Keyboard F22 + 0x72 Keyboard F23 + 0x73 Keyboard F24 + 0x74 Keyboard Execute + 0x75 Keyboard Help + 0x76 Keyboard Menu + 0x77 Keyboard Select + 0x78 Keyboard Stop + 0x79 Keyboard Again + 0x7A Keyboard Undo + 0x7B Keyboard Cut + 0x7C Keyboard Copy + 0x7D Keyboard Paste + 0x7E Keyboard Find + 0x7F Keyboard Mute + 0x80 Keyboard Volume Up + 0x81 Keyboard Volume Down + 0x82 Keyboard Locking Caps Lock + 0x83 Keyboard Locking Num Lock + 0x84 Keyboard Locking Scroll Lock + 0x85 Keypad Comma + 0x86 Keypad Equal Sign + 0x87 Keyboard International1 + 0x88 Keyboard International2 + 0x89 Keyboard International3 + 0x8A Keyboard International4 + 0x8B Keyboard International5 + 0x8C Keyboard International6 + 0x8D Keyboard International7 + 0x8E Keyboard International8 + 0x8F Keyboard International9 + 0x90 Keyboard LANG1 + 0x91 Keyboard LANG2 + 0x92 Keyboard LANG3 + 0x93 Keyboard LANG4 + 0x94 Keyboard LANG5 + 0x95 Keyboard LANG6 + 0x96 Keyboard LANG7 + 0x97 Keyboard LANG8 + 0x98 Keyboard LANG9 + 0x99 Keyboard Alternate Erase + 0x9A Keyboard SysReq/Attention + 0x9B Keyboard Cancel + 0x9C Keyboard Clear + 0x9D Keyboard Prior + 0x9E Keyboard Return + 0x9F Keyboard Separator + 0xA0 Keyboard Out + 0xA1 Keyboard Oper + 0xA2 Keyboard Clear/Again + 0xA3 Keyboard CrSel/Props + 0xA4 Keyboard ExSel + 0xE0 Keyboard LeftControl + 0xE1 Keyboard LeftShift + 0xE2 Keyboard LeftAlt + 0xE3 Keyboard Left GUI + 0xE4 Keyboard RightControl + 0xE5 Keyboard RightShift + 0xE6 Keyboard RightAlt + 0xE7 Keyboard Right GUI + +8 LEDs + 0x00 Undefined + 0x01 Num Lock + 0x02 Caps Lock + 0x03 Scroll Lock + 0x04 Compose + 0x05 Kana + 0x06 Power + 0x07 Shift + 0x08 Do Not Disturb + 0x09 Mute + 0x0A Tone Enable + 0x0B High Cut Filter + 0x0C Low Cut Filter + 0x0D Equalizer Enable + 0x0E Sound Field On + 0x0F Surround Field On + 0x10 Repeat + 0x11 Stereo + 0x12 Sampling Rate Detect + 0x13 Spinning + 0x14 CAV + 0x15 CLV + 0x16 Recording Format Detect + 0x17 Off-Hook + 0x18 Ring + 0x19 Message Waiting + 0x1A Data Mode + 0x1B Battery Operation + 0x1C Battery OK + 0x1D Battery Low + 0x1E Speaker + 0x1F Head Set + 0x20 Hold + 0x21 Microphone + 0x22 Coverage + 0x23 Night Mode + 0x24 Send Calls + 0x25 Call Pickup + 0x26 Conference + 0x27 Stand-by + 0x28 Camera On + 0x29 Camera Off + 0x2A On-Line + 0x2B Off-Line + 0x2C Busy + 0x2D Ready + 0x2E Paper-Out + 0x2F Paper-Jam + 0x30 Remote + 0x31 Forward + 0x32 Reverse + 0x33 Stop + 0x34 Rewind + 0x35 Fast Forward + 0x36 Play + 0x37 Pause + 0x38 Record + 0x39 Error + 0x3A Usage Selected Indicator + 0x3B Usage In Use Indicator + 0x3C Usage Multi Mode Indicator + 0x3D Indicator On + 0x3E Indicator Flash + 0x3F Indicator Slow Blink + 0x40 Indicator Fast Blink + 0x41 Indicator Off + 0x42 Flash On Time + 0x43 Slow Blink On Time + 0x44 Slow Blink Off Time + 0x45 Fast Blink On Time + 0x46 Fast Blink Off Time + 0x47 Usage Indicator Color + 0x48 Red + 0x49 Green + 0x4A Amber + 0x4B Generic Indicator + 0x4C System Suspend + 0x4D External Power Connected + 0x4C-FFFF Reserved + +9 Button + 0x00 No Button Pressed + * Button %d + +10 Ordinal + 0x00 Unused + * Instance %d + +11 Telephony + 0x00 Unassigned + 0x01 Phone + 0x02 Answering Machine + 0x03 Message Controls + 0x04 Handset + 0x05 Headset + 0x06 Telephony Key Pad + 0x07 Programmable Button + 0x20 Hook Switch + 0x21 Flash + 0x22 Feature + 0x23 Hold + 0x24 Redial + 0x25 Transfer + 0x26 Drop + 0x27 Park + 0x28 Forward Calls + 0x29 Alternate Function + 0x2A Line + 0x2B Speaker Phone + 0x2C Conference + 0x2D Ring Enable + 0x2E Ring Select + 0x2F Phone Mute + 0x30 Caller ID + 0x50 Speed Dial + 0x51 Store Number + 0x52 Recall Number + 0x53 Phone Directory + 0x70 Voice Mail + 0x71 Screen Calls + 0x72 Do Not Disturb + 0x73 Message + 0x74 Answer On/Off + 0x90 Inside Dial Tone + 0x91 Outside Dial Tone + 0x92 Inside Ring Tone + 0x93 Outside Ring Tone + 0x94 Priority Ring Tone + 0x95 Inside Ringback + 0x96 Priority Ringback + 0x97 Line Busy Tone + 0x98 Reorder Tone + 0x99 Call Waiting Tone + 0x9A Confirmation Tone 1 + 0x9B Confirmation Tone 2 + 0x9C Tones Off + 0xB0 Phone Key 0 + 0xB1 Phone Key 1 + 0xB2 Phone Key 2 + 0xB3 Phone Key 3 + 0xB4 Phone Key 4 + 0xB5 Phone Key 5 + 0xB6 Phone Key 6 + 0xB7 Phone Key 7 + 0xB8 Phone Key 8 + 0xB9 Phone Key 9 + 0xBA Phone Key Star + 0xBB Phone Key Pound + 0xBC Phone Key A + 0xBD Phone Key B + 0xBE Phone Key C + 0xBF Phone Key D + +12 Consumer + 0x00 Unassigned + 0x01 Consumer Control + 0x02 Numeric Key Pad + 0x03 Programmable Buttons + 0x20 +10 + 0x21 +100 + 0x22 AM/PM + 0x30 Power + 0x31 Reset + 0x32 Sleep + 0x33 Sleep After + 0x34 Sleep Mode + 0x35 Illumination + 0x36 Function Buttons + 0x40 Menu + 0x41 Menu Pick + 0x42 Menu Up + 0x43 Menu Down + 0x44 Menu Left + 0x45 Menu Right + 0x46 Menu Escape + 0x47 Menu Value Increase + 0x48 Menu Value Decrease + 0x60 Data On Screen + 0x61 Closed Caption + 0x62 Closed Caption Select + 0x63 VCR/TV + 0x64 Broadcast Mode + 0x65 Snapshot + 0x66 Still + 0x80 Selection + 0x81 Assign Selection + 0x82 Mode Step + 0x83 Recall Last + 0x84 Enter Channel + 0x85 Order Movie + 0x86 Channel + 0x87 Media Selection + 0x88 Media Select Computer + 0x89 Media Select TV + 0x8A Media Select WWW + 0x8B Media Select DVD + 0x8C Media Select Telephone + 0x8D Media Select Program Guide + 0x8E Media Select Video Phone + 0x8F Media Select Games + 0x90 Media Select Messages + 0x91 Media Select CD + 0x92 Media Select VCR + 0x93 Media Select Tuner + 0x94 Quit + 0x95 Help + 0x96 Media Select Tape + 0x97 Media Select Cable + 0x98 Media Select Satellite + 0x99 Media Select Security + 0x9A Media Select Home + 0x9B Media Select Call + 0x9C Channel Increment + 0x9D Channel Decrement + 0x9E Media Select SAP + 0xA0 VCR Plus + 0xA1 Once + 0xA2 Daily + 0xA3 Weekly + 0xA4 Monthly + 0xB0 Play + 0xB1 Pause + 0xB2 Record + 0xB3 Fast Forward + 0xB4 Rewind + 0xB5 Scan Next Track + 0xB6 Scan Previous Track + 0xB7 Stop + 0xB8 Eject + 0xB9 Random Play + 0xBA Select DisC + 0xBB Enter Disc + 0xBC Repeat + 0xBD Tracking + 0xBE Track Normal + 0xBF Slow Tracking + 0xC0 Frame Forward + 0xC1 Frame Back + 0xC2 Mark + 0xC3 Clear Mark + 0xC4 Repeat From Mark + 0xC5 Return To Mark + 0xC6 Search Mark Forward + 0xC7 Search Mark Backwards + 0xC8 Counter Reset + 0xC9 Show Counter + 0xCA Tracking Increment + 0xCB Tracking Decrement + 0xE0 Volume + 0xE1 Balance + 0xE2 Mute + 0xE3 Bass + 0xE4 Treble + 0xE5 Bass Boost + 0xE6 Surround Mode + 0xE7 Loudness + 0xE8 MPX + 0xE9 Volume Up + 0xEA Volume Down + 0xF0 Speed Select + 0xF1 Playback Speed + 0xF2 Standard Play + 0xF3 Long Play + 0xF4 Extended Play + 0xF5 Slow + 0x100 Fan Enable + 0x101 Fan Speed + 0x102 Light + 0x103 Light Illumination Level + 0x104 Climate Control Enable + 0x105 Room Temperature + 0x106 Security Enable + 0x107 Fire Alarm + 0x108 Police Alarm + 0x150 Balance Right + 0x151 Balance Left + 0x152 Bass Increment + 0x153 Bass Decrement + 0x154 Treble Increment + 0x155 Treble Decrement + 0x160 Speaker System + 0x161 Channel Left + 0x162 Channel Right + 0x163 Channel Center + 0x164 Channel Front + 0x165 Channel Center Front + 0x166 Channel Side + 0x167 Channel Surround + 0x168 Channel Low Frequency Enhancement + 0x169 Channel Top + 0x16A Channel Unknown + 0x170 Sub-channel + 0x171 Sub-channel Increment + 0x172 Sub-channel Decrement + 0x173 Alternate Audio Increment + 0x174 Alternate Audio Decrement + 0x180 Application Launch Buttons + 0x181 AL Launch Button Configuration Tool + 0x182 AL Programmable Button Configuration + 0x183 AL Consumer Control Configuration + 0x184 AL Word Processor + 0x185 AL Text Editor + 0x186 AL Spreadsheet + 0x187 AL Graphics Editor + 0x188 AL Presentation App + 0x189 AL Database App + 0x18A AL Email Reader + 0x18B AL Newsreader + 0x18C AL Voicemail + 0x18D AL Contacts/Address Book + 0x18E AL Calendar/Schedule + 0x18F AL Task/Project Manager + 0x190 AL Log/Journal/Timecard + 0x191 AL Checkbook/Finance + 0x192 AL Calculator + 0x193 AL A/V Capture/Playback + 0x194 AL Local Machine Browser + 0x195 AL LAN/WAN Browser + 0x196 AL Internet Browser + 0x197 AL Remote Networking/ISP Connect + 0x198 AL Network Conference + 0x199 AL Network Chat + 0x19A AL Telephony/Dialer + 0x19B AL Logon + 0x19C AL Logoff + 0x19D AL Logon/Logoff + 0x19E AL Terminal Lock/Screensaver + 0x19F AL Control Panel + 0x1A0 AL Command Line Processor/Run + 0x1A1 AL Process/Task Manager + 0x1A2 AL Select Tast/Application + 0x1A3 AL Next Task/Application + 0x1A4 AL Previous Task/Application + 0x1A5 AL Preemptive Halt Task/Application + 0x200 Generic GUI Application Controls + 0x201 AC New + 0x202 AC Open + 0x203 AC Close + 0x204 AC Exit + 0x205 AC Maximize + 0x206 AC Minimize + 0x207 AC Save + 0x208 AC Print + 0x209 AC Properties + 0x21A AC Undo + 0x21B AC Copy + 0x21C AC Cut + 0x21D AC Paste + 0x21E AC Select All + 0x21F AC Find + 0x220 AC Find and Replace + 0x221 AC Search + 0x222 AC Go To + 0x223 AC Home + 0x224 AC Back + 0x225 AC Forward + 0x226 AC Stop + 0x227 AC Refresh + 0x228 AC Previous Link + 0x229 AC Next Link + 0x22A AC Bookmarks + 0x22B AC History + 0x22C AC Subscriptions + 0x22D AC Zoom In + 0x22E AC Zoom Out + 0x22F AC Zoom + 0x230 AC Full Screen View + 0x231 AC Normal View + 0x232 AC View Toggle + 0x233 AC Scroll Up + 0x234 AC Scroll Down + 0x235 AC Scroll + 0x236 AC Pan Left + 0x237 AC Pan Right + 0x238 AC Pan + 0x239 AC New Window + 0x23A AC Tile Horizontally + 0x23B AC Tile Vertically + 0x23C AC Format + +13 Digitizer + 0x00 Undefined + 0x01 Digitizer + 0x02 Pen + 0x03 Light Pen + 0x04 Touch Screen + 0x05 Touch Pad + 0x06 White Board + 0x07 Coordinate Measuring Machine + 0x08 3-D Digitizer + 0x09 Stereo Plotter + 0x0A Articulated Arm + 0x0B Armature + 0x0C Multiple Point Digitizer + 0x0D Free Space Wand + 0x20 Stylus + 0x21 Puck + 0x22 Finger + 0x30 Tip Pressure + 0x31 Barrel Pressure + 0x32 In Range + 0x33 Touch + 0x34 Untouch + 0x35 Tap + 0x36 Quality + 0x37 Data Valid + 0x38 Transducer Index + 0x39 Tablet Function Keys + 0x3A Program Change Keys + 0x3B Battery Strength + 0x3C Invert + 0x3D X Tilt + 0x3E Y Tilt + 0x3F Azimuth + 0x40 Altitude + 0x41 Twist + 0x42 Tip Switch + 0x43 Secondary Tip Switch + 0x44 Barrel Switch + 0x45 Eraser + 0x46 Tablet Pick + +15 Physical Interface Device + +16 Unicode + * Unicode Char u%04x + +20 Alphnumeric Display + 0x00 Undefined + 0x01 Alphanumeric Display + 0x20 Display Attributes Report + 0x21 ASCII Character Set + 0x22 Data Read Back + 0x23 Font Read Back + 0x24 Display Control Report + 0x25 Clear Display + 0x26 Display Enable + 0x27 Screen Saver Delay + 0x28 Screen Saver Enable + 0x29 Vertical Scroll + 0x2A Horizontal Scroll + 0x2B Character Report + 0x2C Display Data + 0x2D Display Status + 0x2E Stat Not Ready + 0x2F Stat Ready + 0x30 Err Not a loadable character + 0x31 Err Font data cannot be read + 0x32 Cursor Position Report + 0x33 Row + 0x34 Column + 0x35 Rows + 0x36 Columns + 0x37 Cursor Pixel Positioning + 0x38 Cursor Mode + 0x39 Cursor Enable + 0x3A Cursor Blink + 0x3B Font Report + 0x3C Font Data + 0x3D Character Width + 0x3E Character Height + 0x3F Character Spacing Horizontal + 0x40 Character Spacing Vertical + 0x41 Unicode Character Set + +128 Monitor + 0x00 Undefined + 0x01 Monitor Control + 0x02 EDID Information + 0x03 VDIF Information + 0x04 VESA Version + 0x05 On Screen Display + 0x06 Auto Size Center + 0x07 Polarity Horz Synch + 0x08 Polarity Vert Synch + 0x09 Sync Type + 0x0A Screen Position + 0x0B Horizontal Frequency + 0x0C Vertical Frequency + +129 Monitor Enumerated Values + 0x00 unassigned + * ENUM %d + +130 VESA Virtual Controls + 0x10 Brightness + 0x12 Contrast + 0x16 Video Gain Red + 0x18 Video Gain Green + 0x1A Video Gain Blue + 0x1C Focus + 0x20 Horizontal Position + 0x22 Horizontal Size + 0x24 Horizontal Pincushion + 0x26 Horizontal Pincushion Balance + 0x28 Horizontal Misconvergence + 0x2A Horizontal Linearity + 0x2C Horizontal Linearity Balance + 0x30 Vertical Position + 0x32 Vertical Size + 0x34 Vertical Pincushion + 0x36 Vertical Pincushion Balance + 0x38 Vertical Misconvergence + 0x3A Vertical Linearity + 0x3C Vertical Linearity Balance + 0x40 Parallelogram Distortion + 0x42 Trapezoidal Distortion + 0x44 Tilt + 0x46 Top Corner Distortion Control + 0x48 Top Corner Distortion Balance + 0x4A Bottom Corner Distortion Control + 0x4C Bottom Corner Distortion Balance + 0x56 Moiré Horizontal + 0x58 Moiré Vertical + 0x5E Input Level Select + 0x60 Input Source Select + 0x62 Stereo Mode + 0x6C Video Black Level Red + 0x6E Video Black Level Green + 0x70 Video Black Level Blue + +131 VESA Command + 0x00 Undefined + 0x01 Settings + 0x02 Degauss + +132 Power Device + 0x00 Undefined + 0x01 iName + 0x02 PresentStatus + 0x03 ChangedStatus + 0x04 UPS + 0x05 PowerSupply + 0x10 BatterySystem + 0x11 BatterySystemID + 0x12 Battery + 0x13 BatteryID + 0x14 Charger + 0x15 ChargerID + 0x16 PowerConverter + 0x17 PowerConverterID + 0x18 OutletSystem + 0x19 OutletSystemID + 0x1A Input + 0x1B InputID + 0x1C Output + 0x1D OutputID + 0x1E Flow + 0x1F FlowID + 0x20 Outlet + 0x21 OutletID + 0x22 Gang + 0x23 GangID + 0x24 Sink + 0x25 SinkID + 0x30 Voltage + 0x31 Current + 0x32 Frequency + 0x33 ApparentPower + 0x34 ActivePower + 0x35 PercentLoad + 0x36 Temperature + 0x37 Humidity + 0x40 ConfigVoltage + 0x41 ConfigCurrent + 0x42 ConfigFrequency + 0x43 ConfigApparentPower + 0x44 ConfigActivePower + 0x45 ConfigPercentLoad + 0x46 ConfigTemperature + 0x47 ConfigHumidity + 0x50 SwitchOnControl + 0x51 SwitchOffControl + 0x52 ToggleControl + 0x53 LowVoltageTransfer + 0x54 HighVoltageTransfer + 0x55 DelayBeforeReboot + 0x56 DelayBeforeStartup + 0x57 DelayBeforeShutdown + 0x58 Test + 0x59 Vendorspecificcommand + 0x60 Present + 0x61 Good + 0x62 InternalFailure + 0x63 VoltageOutOfRange + 0x64 FrequencyOutOfRange + 0x65 Overload + 0x66 OverCharged + 0x67 OverTemperature + 0x68 ShutdownRequested + 0x69 ShutdownImminent + 0x6A VendorSpecificAnswerValid + 0x6B SwitchOn/Off + 0x6C Switcheble + 0x6D Used + 0x6E Boost + 0x6F Buck + 0x70 Initialized + 0x71 Tested + +133 Battery System + 0x00 Undefined + 0x01 SMBBatteryMode + 0x02 SMBBatteryStatus + 0x03 SMBAlarmWarning + 0x04 SMBChargerMode + 0x05 SMBChargerStatus + 0x06 SMBChargerSpecInfo + 0x07 SMBSelectorState + 0x08 SMBSelectorPreset + 0x09 SMBSelectorInfo + 0x10 OptionalMfgFunction1 + 0x11 OptionalMfgFunction2 + 0x12 OptionalMfgFunction3 + 0x13 OptionalMfgFunction4 + 0x14 OptionalMfgFunction5 + 0x15 ConnectionToSMBus + 0x16 OutputConnection + 0x17 ChargerConnection + 0x18 BatteryInsertion + 0x19 Usenext + 0x1A OKToUse + 0x28 ManufacturerAccess + 0x29 RemainingCapacityLimit + 0x2A RemainingTimeLimit + 0x2B AtRate + 0x2C CapacityMode + 0x2D BroadcastToCharger + 0x2E PrimaryBattery + 0x2F ChargeController + 0x40 TerminateCharge + 0x41 TermminateDischarge + 0x42 BelowRemainingCapacityLimit + 0x43 RemainingTimeLimitExpired + 0x44 Charging + 0x45 Discharging + 0x46 FullyCharged + 0x47 FullyDischarged + 0x48 ConditionningFlag + 0x49 AtRateOK + 0x4A SMBErrorCode + 0x4B NeedReplacement + 0x60 AtRateTimeToFull + 0x61 AtRateTimeToEmpty + 0x62 AverageCurrent + 0x63 Maxerror + 0x64 RelativeStateOfCharge + 0x65 AbsoluteStateOfCharge + 0x66 RemainingCapacity + 0x67 FullChargeCapacity + 0x68 RunTimeToEmpty + 0x69 AverageTimeToEmpty + 0x6A AverageTimeToFull + 0x6B CycleCount + 0x80 BattPackModelLevel + 0x81 InternalChargeController + 0x82 PrimaryBatterySupport + 0x83 DesignCapacity + 0x84 SpecificationInfo + 0x85 ManufacturerDate + 0x86 SerialNumber + 0x87 iManufacturerName + 0x88 iDevicename + 0x89 iDeviceChemistery + 0x8A iManufacturerData + 0x8B Rechargeable + 0x8C WarningCapacityLimit + 0x8D CapacityGranularity1 + 0x8E CapacityGranularity2 + 0xC0 InhibitCharge + 0xC1 EnablePolling + 0xC2 ResetToZero + 0xD0 ACPresent + 0xD1 BatteryPresent + 0xD2 PowerFail + 0xD3 AlarmInhibited + 0xD4 ThermistorUnderRange + 0xD5 ThermistorHot + 0xD6 ThermistorCold + 0xD7 ThermistorOverRange + 0xD8 VoltageOutOfRange + 0xD9 CurrentOutOfRange + 0xDA CurrentNotRegulated + 0xDB VoltageNotRegulated + 0xDC MasterMode + 0xDD ChargerBattery/HostControlled + 0xF0 ChargerSpecInfo + 0xF1 ChargerSpecRef + 0xF2 Level2 + 0xF3 Level3 + +140 Bar Code Scanner + +141 Scale Device + +144 Camera Control + +145 Arcade Device + +# Some Micro$oft non-standard extensions +0xff00 Microsoft + 0xe9 Base Up + 0xea Base Down diff --git a/xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h b/xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h new file mode 100644 index 000000000..ce38a0730 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/libusb/usbvar.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +struct report_desc { + unsigned int size; + unsigned char data[1]; +}; + diff --git a/xorg-server/hw/xfree86/os-support/bsd/memrange.h b/xorg-server/hw/xfree86/os-support/bsd/memrange.h new file mode 100644 index 000000000..03c479144 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/memrange.h @@ -0,0 +1,69 @@ +/* + * Memory range attribute operations, peformed on /dev/mem + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#ifndef _MEMRANGE_H +#define _MEMRANGE_H + +/* Memory range attributes */ +#define MDF_UNCACHEABLE (1<<0) /* region not cached */ +#define MDF_WRITECOMBINE (1<<1) /* region supports "write combine" + * action */ +#define MDF_WRITETHROUGH (1<<2) /* write-through cached */ +#define MDF_WRITEBACK (1<<3) /* write-back cached */ +#define MDF_WRITEPROTECT (1<<4) /* read-only region */ +#define MDF_ATTRMASK (0x00ffffff) + +#define MDF_FIXBASE (1<<24) /* fixed base */ +#define MDF_FIXLEN (1<<25) /* fixed length */ +#define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */ +#define MDF_ACTIVE (1<<27) /* currently active */ +#define MDF_BOGUS (1<<28) /* we don't like it */ +#define MDF_FIXACTIVE (1<<29) /* can't be turned off */ +#define MDF_BUSY (1<<30) /* range is in use */ + +struct mem_range_desc { + u_int64_t mr_base; + u_int64_t mr_len; + int mr_flags; + char mr_owner[8]; +}; + +struct mem_range_op { + struct mem_range_desc *mo_desc; + int mo_arg[2]; +#define MEMRANGE_SET_UPDATE 0 +#define MEMRANGE_SET_REMOVE 1 + /* XXX want a flag that says "set and undo when I exit" */ +}; +#define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op) +#define MEMRANGE_SET _IOW('m', 51, struct mem_range_op) + +#ifdef _KERNEL + +struct mem_range_softc; +struct mem_range_ops { + void (*init) __P((struct mem_range_softc * sc)); + int (*set) __P((struct mem_range_softc * sc, struct mem_range_desc * mrd, int *arg)); + void (*initAP) __P((struct mem_range_softc * sc)); +}; + +struct mem_range_softc { + struct mem_range_ops *mr_op; + int mr_cap; + int mr_ndesc; + struct mem_range_desc *mr_desc; +}; + +extern struct mem_range_softc mem_range_softc; + +extern int mem_range_attr_get __P((struct mem_range_desc * mrd, int *arg)); +extern int mem_range_attr_set __P((struct mem_range_desc * mrd, int *arg)); +extern void mem_range_AP_init __P((void)); +#endif + +#endif diff --git a/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c new file mode 100644 index 000000000..06be654e1 --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/ppc_video.c @@ -0,0 +1,171 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#include "bus/Pci.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +#ifndef __OpenBSD__ +#define DEV_MEM "/dev/mem" +#else +#define DEV_MEM "/dev/xf86" +#endif + +static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags); +static void ppcUnmapVidMem(int, pointer, unsigned long); + +Bool xf86EnableIO(void); +void xf86DisableIO(void); + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = ppcMapVidMem; + pVidMem->unmapMem = ppcUnmapVidMem; + pVidMem->initialised = TRUE; + xf86EnableIO(); +} + + +_X_EXPORT volatile unsigned char *ioBase = MAP_FAILED; + +static pointer +ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags) +{ + int fd = xf86Info.screenFd; + pointer base; +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", + Base, Size, fd); +#endif + + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + + return base; +} + +static void +ppcUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + int rv; + static int kmem = -1; + + if (kmem == -1) { + kmem = open(DEV_MEM, 2); + if (kmem == -1) { + FatalError("xf86ReadBIOS: open %s", DEV_MEM); + } + } + +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", + Base, Offset, Len); +#endif + + + lseek(kmem, Base + Offset, 0); + rv = read(kmem, Buf, Len); + + return rv; +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + + return; +} + +Bool xf86EnableIO() +{ + int fd = xf86Info.screenFd; + + xf86MsgVerb(X_WARNING, 3, "xf86EnableIO %d\n", fd); + if (ioBase == MAP_FAILED) + { + ioBase=mmap(NULL, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, fd, + 0xf2000000); + xf86MsgVerb(X_INFO, 3, "xf86EnableIO: %08x\n", ioBase); + if (ioBase == MAP_FAILED) { + xf86MsgVerb(X_WARNING, 3, "Can't map IO space!\n"); + return FALSE; + } + } + return TRUE; +} + +void xf86DisableIO() +{ + + if (ioBase != MAP_FAILED) + { + munmap(__UNVOLATILE(ioBase), 0x10000); + ioBase = MAP_FAILED; + } +} + diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c new file mode 100644 index 000000000..fb5e8529b --- /dev/null +++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c @@ -0,0 +1,109 @@ +/* + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Wexelblat <dwex@goblin.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the names of Rich Murphey and David Wexelblat + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. Rich Murphey and + * David Wexelblat make no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF + * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "xf86.h" +#include "xf86Priv.h" + +#include "xf86_OSlib.h" +#include "xf86OSpriv.h" + +#ifndef MAP_FAILED +#define MAP_FAILED ((caddr_t)-1) +#endif + +/***************************************************************************/ +/* Video Memory Mapping section */ +/***************************************************************************/ + +static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int); +static void sparc64UnmapVidMem(int, pointer, unsigned long); + +void +xf86OSInitVidMem(VidMemInfoPtr pVidMem) +{ + pVidMem->linearSupported = TRUE; + pVidMem->mapMem = sparc64MapVidMem; + pVidMem->unmapMem = sparc64UnmapVidMem; + pVidMem->initialised = TRUE; +} + +static pointer +sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, + int flags) +{ + int fd = xf86Info.screenFd; + pointer base; + +#ifdef DEBUG + xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", + Base, Size, fd); +#endif + + base = mmap(0, Size, + (flags & VIDMEM_READONLY) ? + PROT_READ : (PROT_READ | PROT_WRITE), + MAP_SHARED, fd, Base); + if (base == MAP_FAILED) + FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)", + "xf86MapVidMem", Size, Base, strerror(errno)); + return base; +} + +static void +sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size) +{ + munmap(Base, Size); +} + +_X_EXPORT int +xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf, + int Len) +{ + + return (0); +} + +/***************************************************************************/ +/* Interrupt Handling section */ +/***************************************************************************/ + +_X_EXPORT Bool +xf86DisableInterrupts() +{ + + return(TRUE); +} + +_X_EXPORT void +xf86EnableInterrupts() +{ + + return; +} |