From 51ba40dcd64518c8d5f9ce586171c8fb347a42c0 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 6 Apr 2007 15:20:49 +0000 Subject: merged libdha and libvidix, moved all files from libdha to vidix directory git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22918 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 9 +- libdha/AsmMacros.h | 117 - libdha/bin/README | 6 - libdha/bin/mapdev.copyright | 70 - libdha/bin/mapdev.vxd | Bin 5780 -> 0 bytes libdha/dhahelperwin/MAKEFILE | 7 - libdha/dhahelperwin/SOURCES | 6 - libdha/dhahelperwin/dhahelper.c | 359 - libdha/dhahelperwin/dhahelper.h | 50 - libdha/dhahelperwin/dhasetup.c | 61 - libdha/kernelhelper/Makefile | 21 - libdha/kernelhelper/dhahelper.c | 361 - libdha/kernelhelper/dhahelper.h | 69 - libdha/kernelhelper/test.c | 60 - libdha/libdha.c | 196 - libdha/libdha.h | 75 - libdha/mtrr.c | 73 - libdha/pci.c | 742 -- libdha/pci.db | 13042 ------------------------------------ libdha/pci_db2c.awk | 267 - libdha/sysdep/AsmMacros_alpha.h | 26 - libdha/sysdep/AsmMacros_arm32.h | 50 - libdha/sysdep/AsmMacros_ia64.h | 16 - libdha/sysdep/AsmMacros_powerpc.h | 60 - libdha/sysdep/AsmMacros_sparc.h | 53 - libdha/sysdep/AsmMacros_x86.h | 293 - libdha/sysdep/libdha_os2.c | 161 - libdha/sysdep/libdha_win32.c | 102 - libdha/sysdep/pci_386bsd.c | 38 - libdha/sysdep/pci_alpha.c | 29 - libdha/sysdep/pci_arm32.c | 60 - libdha/sysdep/pci_bsdi.c | 39 - libdha/sysdep/pci_freebsd.c | 38 - libdha/sysdep/pci_ia64.c | 60 - libdha/sysdep/pci_isc.c | 32 - libdha/sysdep/pci_linux.c | 191 - libdha/sysdep/pci_lynx.c | 93 - libdha/sysdep/pci_mach386.c | 25 - libdha/sysdep/pci_netbsd.c | 44 - libdha/sysdep/pci_openbsd.c | 27 - libdha/sysdep/pci_os2.c | 55 - libdha/sysdep/pci_powerpc.c | 30 - libdha/sysdep/pci_sco.c | 33 - libdha/sysdep/pci_sparc.c | 60 - libdha/sysdep/pci_svr4.c | 42 - libdha/sysdep/pci_win32.c | 38 - libdha/sysdep/pci_x86.c | 60 - vidix/AsmMacros.h | 117 + vidix/Makefile | 20 + vidix/bin/README | 6 + vidix/bin/mapdev.copyright | 70 + vidix/bin/mapdev.vxd | Bin 0 -> 5780 bytes vidix/cyberblade_vid.c | 6 +- vidix/dhahelperwin/MAKEFILE | 7 + vidix/dhahelperwin/SOURCES | 6 + vidix/dhahelperwin/dhahelper.c | 359 + vidix/dhahelperwin/dhahelper.h | 50 + vidix/dhahelperwin/dhasetup.c | 61 + vidix/kernelhelper/Makefile | 21 + vidix/kernelhelper/dhahelper.c | 361 + vidix/kernelhelper/dhahelper.h | 69 + vidix/kernelhelper/test.c | 60 + vidix/libdha.c | 196 + vidix/libdha.h | 75 + vidix/mach64_vid.c | 6 +- vidix/mga_vid.c | 6 +- vidix/mtrr.c | 73 + vidix/nvidia_vid.c | 6 +- vidix/pci.c | 742 ++ vidix/pci.db | 13042 ++++++++++++++++++++++++++++++++++++ vidix/pci_db2c.awk | 275 + vidix/pm3_vid.c | 6 +- vidix/radeon_vid.c | 6 +- vidix/savage_vid.c | 6 +- vidix/sis_bridge.c | 2 +- vidix/sis_vid.c | 6 +- vidix/sysdep/AsmMacros_alpha.h | 26 + vidix/sysdep/AsmMacros_arm32.h | 50 + vidix/sysdep/AsmMacros_ia64.h | 16 + vidix/sysdep/AsmMacros_powerpc.h | 60 + vidix/sysdep/AsmMacros_sparc.h | 53 + vidix/sysdep/AsmMacros_x86.h | 293 + vidix/sysdep/libdha_os2.c | 161 + vidix/sysdep/libdha_win32.c | 102 + vidix/sysdep/pci_386bsd.c | 38 + vidix/sysdep/pci_alpha.c | 29 + vidix/sysdep/pci_arm32.c | 60 + vidix/sysdep/pci_bsdi.c | 39 + vidix/sysdep/pci_freebsd.c | 38 + vidix/sysdep/pci_ia64.c | 60 + vidix/sysdep/pci_isc.c | 32 + vidix/sysdep/pci_linux.c | 191 + vidix/sysdep/pci_lynx.c | 93 + vidix/sysdep/pci_mach386.c | 25 + vidix/sysdep/pci_netbsd.c | 44 + vidix/sysdep/pci_openbsd.c | 27 + vidix/sysdep/pci_os2.c | 55 + vidix/sysdep/pci_powerpc.c | 30 + vidix/sysdep/pci_sco.c | 33 + vidix/sysdep/pci_sparc.c | 60 + vidix/sysdep/pci_svr4.c | 42 + vidix/sysdep/pci_win32.c | 38 + vidix/sysdep/pci_x86.c | 60 + vidix/unichrome_vid.c | 6 +- 104 files changed, 17395 insertions(+), 17372 deletions(-) delete mode 100644 libdha/AsmMacros.h delete mode 100644 libdha/bin/README delete mode 100644 libdha/bin/mapdev.copyright delete mode 100644 libdha/bin/mapdev.vxd delete mode 100644 libdha/dhahelperwin/MAKEFILE delete mode 100644 libdha/dhahelperwin/SOURCES delete mode 100644 libdha/dhahelperwin/dhahelper.c delete mode 100644 libdha/dhahelperwin/dhahelper.h delete mode 100644 libdha/dhahelperwin/dhasetup.c delete mode 100644 libdha/kernelhelper/Makefile delete mode 100644 libdha/kernelhelper/dhahelper.c delete mode 100644 libdha/kernelhelper/dhahelper.h delete mode 100644 libdha/kernelhelper/test.c delete mode 100644 libdha/libdha.c delete mode 100644 libdha/libdha.h delete mode 100644 libdha/mtrr.c delete mode 100644 libdha/pci.c delete mode 100644 libdha/pci.db delete mode 100644 libdha/pci_db2c.awk delete mode 100644 libdha/sysdep/AsmMacros_alpha.h delete mode 100644 libdha/sysdep/AsmMacros_arm32.h delete mode 100644 libdha/sysdep/AsmMacros_ia64.h delete mode 100644 libdha/sysdep/AsmMacros_powerpc.h delete mode 100644 libdha/sysdep/AsmMacros_sparc.h delete mode 100644 libdha/sysdep/AsmMacros_x86.h delete mode 100644 libdha/sysdep/libdha_os2.c delete mode 100644 libdha/sysdep/libdha_win32.c delete mode 100644 libdha/sysdep/pci_386bsd.c delete mode 100644 libdha/sysdep/pci_alpha.c delete mode 100644 libdha/sysdep/pci_arm32.c delete mode 100644 libdha/sysdep/pci_bsdi.c delete mode 100644 libdha/sysdep/pci_freebsd.c delete mode 100644 libdha/sysdep/pci_ia64.c delete mode 100644 libdha/sysdep/pci_isc.c delete mode 100644 libdha/sysdep/pci_linux.c delete mode 100644 libdha/sysdep/pci_lynx.c delete mode 100644 libdha/sysdep/pci_mach386.c delete mode 100644 libdha/sysdep/pci_netbsd.c delete mode 100644 libdha/sysdep/pci_openbsd.c delete mode 100644 libdha/sysdep/pci_os2.c delete mode 100644 libdha/sysdep/pci_powerpc.c delete mode 100644 libdha/sysdep/pci_sco.c delete mode 100644 libdha/sysdep/pci_sparc.c delete mode 100644 libdha/sysdep/pci_svr4.c delete mode 100644 libdha/sysdep/pci_win32.c delete mode 100644 libdha/sysdep/pci_x86.c create mode 100644 vidix/AsmMacros.h create mode 100644 vidix/bin/README create mode 100644 vidix/bin/mapdev.copyright create mode 100644 vidix/bin/mapdev.vxd create mode 100644 vidix/dhahelperwin/MAKEFILE create mode 100644 vidix/dhahelperwin/SOURCES create mode 100644 vidix/dhahelperwin/dhahelper.c create mode 100644 vidix/dhahelperwin/dhahelper.h create mode 100644 vidix/dhahelperwin/dhasetup.c create mode 100644 vidix/kernelhelper/Makefile create mode 100644 vidix/kernelhelper/dhahelper.c create mode 100644 vidix/kernelhelper/dhahelper.h create mode 100644 vidix/kernelhelper/test.c create mode 100644 vidix/libdha.c create mode 100644 vidix/libdha.h create mode 100644 vidix/mtrr.c create mode 100644 vidix/pci.c create mode 100644 vidix/pci.db create mode 100644 vidix/pci_db2c.awk create mode 100644 vidix/sysdep/AsmMacros_alpha.h create mode 100644 vidix/sysdep/AsmMacros_arm32.h create mode 100644 vidix/sysdep/AsmMacros_ia64.h create mode 100644 vidix/sysdep/AsmMacros_powerpc.h create mode 100644 vidix/sysdep/AsmMacros_sparc.h create mode 100644 vidix/sysdep/AsmMacros_x86.h create mode 100644 vidix/sysdep/libdha_os2.c create mode 100644 vidix/sysdep/libdha_win32.c create mode 100644 vidix/sysdep/pci_386bsd.c create mode 100644 vidix/sysdep/pci_alpha.c create mode 100644 vidix/sysdep/pci_arm32.c create mode 100644 vidix/sysdep/pci_bsdi.c create mode 100644 vidix/sysdep/pci_freebsd.c create mode 100644 vidix/sysdep/pci_ia64.c create mode 100644 vidix/sysdep/pci_isc.c create mode 100644 vidix/sysdep/pci_linux.c create mode 100644 vidix/sysdep/pci_lynx.c create mode 100644 vidix/sysdep/pci_mach386.c create mode 100644 vidix/sysdep/pci_netbsd.c create mode 100644 vidix/sysdep/pci_openbsd.c create mode 100644 vidix/sysdep/pci_os2.c create mode 100644 vidix/sysdep/pci_powerpc.c create mode 100644 vidix/sysdep/pci_sco.c create mode 100644 vidix/sysdep/pci_sparc.c create mode 100644 vidix/sysdep/pci_svr4.c create mode 100644 vidix/sysdep/pci_win32.c create mode 100644 vidix/sysdep/pci_x86.c diff --git a/Makefile b/Makefile index e683d9e805..12e18a1775 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,7 @@ LIBS_MPLAYER = libvo/libvo.a \ libao2/libao2.a \ input/libinput.a \ -LIBS_MPLAYER-$(VIDIX) += vidix/libvidix.a libdha/libdha.a +LIBS_MPLAYER-$(VIDIX) += vidix/libvidix.a LIBS_MPLAYER-$(GUI) += Gui/libgui.a LIBS_MPLAYER-$(LIBMENU) += libmenu/libmenu.a @@ -134,7 +134,6 @@ PARTS = libmpdemux \ libmpeg2 \ libfaad2 \ tremor \ - libdha \ vidix \ dvdread \ libdvdcss \ @@ -211,10 +210,7 @@ mp3lib/libmp3.a: tremor/libvorbisidec.a: $(MAKE) -C tremor -libdha/libdha.a: - $(MAKE) -C libdha - -vidix/libvidix.a: libdha/libdha.a +vidix/libvidix.a: $(MAKE) -C vidix Gui/libgui.a: @@ -407,7 +403,6 @@ mp3lib/libmp3.a: .norecurse $(wildcard mp3lib/*.[ch]) libfaad2/libfaad2.a: .norecurse $(wildcard libfaad2/*.[ch] libfaad2/*/*.[ch]) loader/libloader.a: .norecurse $(wildcard loader/*.[chSs]) -libdha/libdha.a: .norecurse $(wildcard libdha/*.[ch]) vidix/libvidix.a: .norecurse $(wildcard vidix/*.[ch]) Gui/libgui.a: .norecurse $(wildcard Gui/*.[ch] Gui/*/*.[ch] Gui/*/*/*.[ch]) diff --git a/libdha/AsmMacros.h b/libdha/AsmMacros.h deleted file mode 100644 index 5e4e1addc4..0000000000 --- a/libdha/AsmMacros.h +++ /dev/null @@ -1,117 +0,0 @@ -/* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */ -/* - * (c) Copyright 1993,1994 by David Wexelblat - * - * 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 - * DAVID WEXELBLAT 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 David Wexelblat shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from David Wexelblat. - * - */ -/* - * 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. - * - */ - -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/AsmMacros.h,v 1.1 2001/11/16 21:13:34 tsi Exp $ */ - -/* - * Modified for readability by Nick Kurshev -*/ - -#if defined(__GNUC__) -#if defined(__alpha__) -#include "sysdep/AsmMacros_alpha.h" -#elif defined(__ia64__) -#include "sysdep/AsmMacros_ia64.h" -#elif defined(__sparc__) -#include "sysdep/AsmMacros_sparc.h" -#elif defined( __arm32__ ) -#include "sysdep/AsmMacros_arm32.h" -#elif defined(__powerpc__) -#include "sysdep/AsmMacros_powerpc.h" -#else -#include "sysdep/AsmMacros_x86.h" -#endif - -#else /* __GNUC__ */ - -#if defined(_MINIX) && defined(_ACK) - -/* inb, outb, inw and outw are defined in the library */ -/* ... but I've no idea if the same is true for inl & outl */ - -u8_t inb(U16_t); -void outb(U16_t, U8_t); -u16_t inw(U16_t); -void outw(U16_t, U16_t); -u32_t inl(U16_t); -void outl(U16_t, U32_t); - -#else /* not _MINIX and _ACK */ - -# if defined(__STDC__) && (__STDC__ == 1) -# ifndef NCR -# define asm __asm -# endif -# endif -# ifdef SVR4 -# include -# ifndef __USLC__ -# define __USLC__ -# endif -# endif -#ifndef SCO325 -# include -#else -# include "../common/scoasm.h" -#endif -#define intr_disable() asm("cli") -#define intr_enable() asm("sti") - -#endif /* _MINIX and _ACK */ -#endif /* __GNUC__ */ diff --git a/libdha/bin/README b/libdha/bin/README deleted file mode 100644 index fe4bfa6f34..0000000000 --- a/libdha/bin/README +++ /dev/null @@ -1,6 +0,0 @@ -mapdev.vxd -~~~~~~~~~~ -mapdev.vxd - provides direct hardware access under Win9x. -install: Just copy it into %WINDOWS%\system folder and reboot. -note: This driver won't work under NT-based systems -(like WinNT, Win2000 and even WinME and WinXP due importing NT things). diff --git a/libdha/bin/mapdev.copyright b/libdha/bin/mapdev.copyright deleted file mode 100644 index b22433d291..0000000000 --- a/libdha/bin/mapdev.copyright +++ /dev/null @@ -1,70 +0,0 @@ -From khazzah@melita.com Mon Jun 23 21:48:19 1997 -Return-Path: -Received: from melita.melita.com by max4.rrze.uni-erlangen.de; Mon, 23 Jun 1997 21:48:16 +0200 -Received: from mailgate.melita.com ([192.68.22.8]) by melita.melita.com (8.6.12/8.6.9) with SMTP id QAA29292 for ; Mon, 23 Jun 1997 16:17:55 -0400 -Received: by mailgate.melita.com with Microsoft Mail - id <33AEFD34@mailgate.melita.com>; Mon, 23 Jun 97 15:48:20 PDT -From: Karen Hazzah -To: "'Stefan.Dirsch@stud.uni-erlangen.de'" -Subject: Your post to vxd newsgroup -Date: Sun, 22 Jun 97 20:51:00 PDT -Message-ID: <33AEFD34@mailgate.melita.com> -Encoding: 22 TEXT -X-Mailer: Microsoft Mail V3.0 - - -I posted an answer to your question in the newsgroup. I also have -additional information for you. - -I can email you the binary for VxD which does exactly what you need: -given a physical address, returns a pointer that can be used by a -Win32 application. I'll also give you source for a Win32 app which -uses the VxD to read an area of physical memory. - -I don't offer this solution to everyone, since in most cases the -proper solution is for them to write a VxD which interacts with their -hardware, rather than simply getting a pointer to the hardware and -interacting with it from an application. - -However, in your case, you're just using a VxD as a tool to get your -Linux driver working...you shouldn't have to write a VxD for this :-) - -Let me know if you're interested. -=============================================================================== -Hello Karen - -A long time ago, you sent me your VXD for reading an area of physical -memory under Win32, so I could make register dumps of the graphic -chip. Did I ever mention, that it works perfectly for me? - -Why I contact you is, that I really would like to offer this solution -to all XFree86 members, so that it will be much easier in the future -for XFree86 to develop drivers for graphic boards. - -Can I count with your agreement? Would you like to add a special -copyright to your software? - -Stefan -=============================================================================== -From KHazzah@melita.com Wed Mar 4 00:00:28 1998 -Return-Path: -Received: from melita.melita.com (melita.com [192.68.22.2]) - by Galois.suse.de (8.8.8/8.8.8) with SMTP id AAA03709 - for ; Wed, 4 Mar 1998 00:00:26 +0100 -Received: from norcross.melita.com (norcross.melita.com [192.68.22.10]) by melita.melita.com (8.6.12/8.6.9) with ESMTP id TAA31217 for ; Tue, 3 Mar 1998 19:48:10 -0500 -Received: by zippy.melita.com with Internet Mail Service (5.5.1960.3) - id ; Tue, 3 Mar 1998 18:00:26 -0500 -Message-ID: -From: "Hazzah, Karen" -To: Stefan Dirsch -Subject: RE: VXD binary for Win32 for reading an area of physical memory -Date: Tue, 3 Mar 1998 18:00:25 -0500 -MIME-Version: 1.0 -X-Mailer: Internet Mail Service (5.5.1960.3) -Content-Type: text/plain -Status: ROr - -OK, you have my permission to make it publicly available, as is. - -If you make it available on the web (ftp, etc.), please give me the -URL so I can refer others to it. diff --git a/libdha/bin/mapdev.vxd b/libdha/bin/mapdev.vxd deleted file mode 100644 index e09194b842..0000000000 Binary files a/libdha/bin/mapdev.vxd and /dev/null differ diff --git a/libdha/dhahelperwin/MAKEFILE b/libdha/dhahelperwin/MAKEFILE deleted file mode 100644 index 58189757d6..0000000000 --- a/libdha/dhahelperwin/MAKEFILE +++ /dev/null @@ -1,7 +0,0 @@ -# -# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source -# file to this component. This file merely indirects to the real make file -# that is shared by all the driver components of the Windows NT DDK -# - -!INCLUDE $(NTMAKEENV)\makefile.def diff --git a/libdha/dhahelperwin/SOURCES b/libdha/dhahelperwin/SOURCES deleted file mode 100644 index e44aa06971..0000000000 --- a/libdha/dhahelperwin/SOURCES +++ /dev/null @@ -1,6 +0,0 @@ -TARGETNAME=dhahelper -TARGETPATH=. -TARGETTYPE=DRIVER -NTDEBUG=ntsd - -SOURCES= dhahelper.c diff --git a/libdha/dhahelperwin/dhahelper.c b/libdha/dhahelperwin/dhahelper.c deleted file mode 100644 index 230d44a372..0000000000 --- a/libdha/dhahelperwin/dhahelper.c +++ /dev/null @@ -1,359 +0,0 @@ -/****************************************************************************** - * dhahelper.c: direct hardware access under Windows NT/2000/XP - * Copyright (c) 2004 Sascha Sommer . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - - -#include -#include "dhahelper.h" - -#define OutputDebugString DbgPrint - -#define IOPM_SIZE 0x2000 -typedef char IOPM[IOPM_SIZE]; -static IOPM *pIOPM = NULL; - - - -typedef struct { - PMDL Mdl; - PVOID SystemVirtualAddress; - PVOID UserVirtualAddress; - ULONG PhysMemSizeInBytes; -}alloc_priv; -static alloc_priv* alloclist; -static unsigned int alloccount=0; - - - - - - - -static NTSTATUS dhahelperdispatch(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp); -static void dhahelperunload(IN PDRIVER_OBJECT DriverObject); -static NTSTATUS UnmapPhysicalMemory(PVOID UserVirtualAddress); -static NTSTATUS MapPhysicalMemoryToLinearSpace(PVOID pPhysAddress,ULONG PhysMemSizeInBytes,PVOID *PhysMemLin); - -void Ke386SetIoAccessMap(int, IOPM *); -void Ke386QueryIoAccessMap(int, IOPM *); -void Ke386IoSetAccessProcess(PEPROCESS, int); - - - - -//entry point -NTSTATUS DriverEntry (IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath){ - UNICODE_STRING DeviceNameUnicodeString; - UNICODE_STRING DeviceLinkUnicodeString; - NTSTATUS ntStatus; - PDEVICE_OBJECT DeviceObject = NULL; - - OutputDebugString ("dhahelper: entering DriverEntry"); - - RtlInitUnicodeString (&DeviceNameUnicodeString, L"\\Device\\DHAHELPER"); - - // Create an EXCLUSIVE device object (only 1 thread at a time - // can make requests to this device). - - ntStatus = IoCreateDevice(DriverObject,0,&DeviceNameUnicodeString,FILE_DEVICE_DHAHELPER,0,TRUE,&DeviceObject); - - if (NT_SUCCESS(ntStatus)){ - // Create dispatch points for device control, create, close. - DriverObject->MajorFunction[IRP_MJ_CREATE] = - DriverObject->MajorFunction[IRP_MJ_CLOSE] = - DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = dhahelperdispatch; - DriverObject->DriverUnload = dhahelperunload; - - // Create a symbolic link, e.g. a name that a Win32 app can specify - // to open the device. - - RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\DHAHELPER"); - - ntStatus = IoCreateSymbolicLink(&DeviceLinkUnicodeString,&DeviceNameUnicodeString); - - if (!NT_SUCCESS(ntStatus)){ - // Symbolic link creation failed- note this & then delete the - // device object (it's useless if a Win32 app can't get at it). - OutputDebugString ("dhahelper: IoCreateSymbolicLink failed"); - IoDeleteDevice (DeviceObject); - } - } - else{ - OutputDebugString ("dhahelper: IoCreateDevice failed"); - } - OutputDebugString ("dhahelper: leaving DriverEntry"); - return ntStatus; -} - - -// Process the IRPs sent to this device - -static NTSTATUS dhahelperdispatch(IN PDEVICE_OBJECT DeviceObject,IN PIRP Irp){ - PIO_STACK_LOCATION IrpStack; - ULONG dwInputBufferLength; - ULONG dwOutputBufferLength; - ULONG dwIoControlCode; - PVOID pvIOBuffer; - NTSTATUS ntStatus; - dhahelper_t dhahelper_priv; - - OutputDebugString ("dhahelper: entering dhahelperdispatch"); - - // Init to default settings - - Irp->IoStatus.Status = STATUS_SUCCESS; - Irp->IoStatus.Information = 0; - - IrpStack = IoGetCurrentIrpStackLocation(Irp); - - // Get the pointer to the input/output buffer and it's length - - pvIOBuffer = Irp->AssociatedIrp.SystemBuffer; - dwInputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength; - dwOutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength; - - switch (IrpStack->MajorFunction){ - case IRP_MJ_CREATE: - OutputDebugString("dhahelper: IRP_MJ_CREATE"); - break; - case IRP_MJ_CLOSE: - OutputDebugString("dhahelper: IRP_MJ_CLOSE"); - break; - case IRP_MJ_DEVICE_CONTROL: - OutputDebugString("dhahelper: IRP_MJ_DEVICE_CONTROL"); - dwIoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode; - switch (dwIoControlCode){ - case IOCTL_DHAHELPER_ENABLEDIRECTIO: - OutputDebugString("dhahelper: IOCTL_DHAHELPER_ENABLEDIRECTIO"); - pIOPM = MmAllocateNonCachedMemory(sizeof(IOPM)); - if (pIOPM){ - RtlZeroMemory(pIOPM, sizeof(IOPM)); - Ke386IoSetAccessProcess(PsGetCurrentProcess(), 1); - Ke386SetIoAccessMap(1, pIOPM); - } - else Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; - break; - case IOCTL_DHAHELPER_DISABLEDIRECTIO: - OutputDebugString("dhahelper: IOCTL_DHAHELPER_DISABLEDIRECTIO"); - if (pIOPM){ - Ke386IoSetAccessProcess(PsGetCurrentProcess(), 0); - Ke386SetIoAccessMap(1, pIOPM); - MmFreeNonCachedMemory(pIOPM, sizeof(IOPM)); - pIOPM = NULL; - } - break; - case IOCTL_DHAHELPER_MAPPHYSTOLIN: - OutputDebugString("dhahelper: IOCTL_DHAHELPER_MAPPHYSTOLIN"); - if (dwInputBufferLength){ - memcpy (&dhahelper_priv, pvIOBuffer, dwInputBufferLength); - ntStatus = MapPhysicalMemoryToLinearSpace(dhahelper_priv.base,dhahelper_priv.size,&dhahelper_priv.ptr); - if (NT_SUCCESS(ntStatus)){ - memcpy (pvIOBuffer, &dhahelper_priv, dwInputBufferLength); - Irp->IoStatus.Information = dwInputBufferLength; - } - Irp->IoStatus.Status = ntStatus; - } - else Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; - break; - case IOCTL_DHAHELPER_UNMAPPHYSADDR: - OutputDebugString("dhahelper: IOCTL_DHAHELPER_UNMAPPHYSADDR"); - if (dwInputBufferLength){ - memcpy (&dhahelper_priv, pvIOBuffer, dwInputBufferLength); - ntStatus = UnmapPhysicalMemory(dhahelper_priv.ptr); - Irp->IoStatus.Status = ntStatus; - } - else - Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; - break; - default: - OutputDebugString("dhahelper: unknown IRP_MJ_DEVICE_CONTROL"); - Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; - break; - } - break; - } - - // DON'T get cute and try to use the status field of the irp in the - // return status. That IRP IS GONE as soon as you call IoCompleteRequest. - - ntStatus = Irp->IoStatus.Status; - - IoCompleteRequest (Irp, IO_NO_INCREMENT); - - // We never have pending operation so always return the status code. - - OutputDebugString("dhahelper: leaving dhahelperdispatch"); - - return ntStatus; -} - -// Delete the associated device and return - -static void dhahelperunload(IN PDRIVER_OBJECT DriverObject){ - UNICODE_STRING DeviceLinkUnicodeString; - NTSTATUS ntStatus=STATUS_SUCCESS; - OutputDebugString ("dhahelper: entering dhahelperunload"); - OutputDebugString ("dhahelper: unmapping remaining memory"); - - while(alloccount && (ntStatus==STATUS_SUCCESS))ntStatus = UnmapPhysicalMemory(alloclist[alloccount-1].UserVirtualAddress); - RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\DHAHELPER"); - ntStatus = IoDeleteSymbolicLink (&DeviceLinkUnicodeString); - - if (NT_SUCCESS(ntStatus)){ - IoDeleteDevice (DriverObject->DeviceObject); - } - else { - OutputDebugString ("dhahelper: IoDeleteSymbolicLink failed"); - } - OutputDebugString ("dhahelper: leaving dhahelperunload"); -} - - - - - - -/************************* memory mapping functions ******************************/ -//unlike the functions of other io helpers these functions allow to map adapter memory on windows xp -//even if it has alread been mapped by the original driver -//the technique used is described in -//http://support.microsoft.com/default.aspx?scid=kb;en-us;q189327 -//furthermore it keeps a list of mapped areas to free them when the driver gets unloaded -//I'm not sure what the limitations of ZwMapViewOfSection are but mapping 128MB videoram (that is probably already mapped by the gfxcard driver) -//won't work so it is generally a good idea to map only the memory you really need - -static NTSTATUS MapPhysicalMemoryToLinearSpace(PVOID pPhysAddress,ULONG PhysMemSizeInBytes,PVOID *PhysMemLin){ - alloc_priv* alloclisttmp; - PMDL Mdl=NULL; - PVOID SystemVirtualAddress=NULL; - PVOID UserVirtualAddress=NULL; - PHYSICAL_ADDRESS pStartPhysAddress; - OutputDebugString ("dhahelper: entering MapPhysicalMemoryToLinearSpace"); - - pStartPhysAddress.QuadPart = (ULONGLONG)pPhysAddress; - __try { - SystemVirtualAddress=MmMapIoSpace(pStartPhysAddress,PhysMemSizeInBytes, /*MmWriteCombined*/MmNonCached); - if(!SystemVirtualAddress){ - OutputDebugString("dhahelper: MmMapIoSpace failed"); - return STATUS_INVALID_PARAMETER; - } - OutputDebugString("dhahelper: SystemVirtualAddress 0x%x",SystemVirtualAddress); - Mdl=IoAllocateMdl(SystemVirtualAddress, PhysMemSizeInBytes, FALSE, FALSE,NULL); - if(!Mdl){ - OutputDebugString("dhahelper: IoAllocateMdl failed"); - return STATUS_INSUFFICIENT_RESOURCES; - } - OutputDebugString("dhahelper: Mdl 0x%x",Mdl); - MmBuildMdlForNonPagedPool(Mdl); - UserVirtualAddress = (PVOID)(((ULONG)PAGE_ALIGN(MmMapLockedPages(Mdl,UserMode))) + MmGetMdlByteOffset(Mdl)); - if(!UserVirtualAddress){ - OutputDebugString("dhahelper: MmMapLockedPages failed"); - return STATUS_INSUFFICIENT_RESOURCES; - } - OutputDebugString("dhahelper: UserVirtualAddress 0x%x",UserVirtualAddress); - }__except(EXCEPTION_EXECUTE_HANDLER){ - NTSTATUS ntStatus; - ntStatus = GetExceptionCode(); - OutputDebugString("dhahelper: MapPhysicalMemoryToLinearSpace failed due to exception 0x%0x\n", ntStatus); - return ntStatus; - } - - - OutputDebugString("dhahelper: adding data to internal allocation list"); - alloclisttmp=MmAllocateNonCachedMemory((alloccount+1)*sizeof(alloc_priv)); - - - if(!alloclisttmp){ - OutputDebugString("dhahelper: not enough memory to create temporary allocation list"); - MmUnmapLockedPages(UserVirtualAddress, Mdl); - IoFreeMdl(Mdl); - return STATUS_INSUFFICIENT_RESOURCES; - } - if(alloccount){ - memcpy(alloclisttmp,alloclist,alloccount * sizeof(alloc_priv)); - MmFreeNonCachedMemory(alloclist,alloccount*sizeof(alloc_priv)); - } - alloclist=alloclisttmp; - alloclist[alloccount].Mdl=Mdl; - alloclist[alloccount].SystemVirtualAddress=SystemVirtualAddress; - alloclist[alloccount].UserVirtualAddress=UserVirtualAddress; - alloclist[alloccount].PhysMemSizeInBytes=PhysMemSizeInBytes; - ++alloccount; - - *PhysMemLin=UserVirtualAddress; - - OutputDebugString("dhahelper: leaving MapPhysicalMemoryToLinearSpace"); - return STATUS_SUCCESS; -} - -static NTSTATUS UnmapPhysicalMemory(PVOID UserVirtualAddress){ - unsigned int i; - unsigned int x=0; - unsigned int alloccounttmp=alloccount; - OutputDebugString("dhahelper: entering UnmapPhysicalMemory to unmapp 0x%x",UserVirtualAddress); - if(!alloccount){ - OutputDebugString("dhahelper: UnmapPhysicalMemory: nothing todo -> leaving..."); - return STATUS_SUCCESS; - } - - for(i=0;i -#include - -int main(int argc,char* argv[]){ - SC_HANDLE hSCManager; - SC_HANDLE hService; - char path[MAX_PATH]; - printf("dhasetup (c) 2004 Sascha Sommer\n"); - GetWindowsDirectory(path,MAX_PATH); - strcpy(path+strlen(path),"\\system32\\drivers\\dhahelper.sys"); - if(argc==1){ - printf("Usage:\n"); - printf("dhasetup install - Copies dhahelper.sys from the current directory to\n%s and configures it to start at boot.\n", path); - printf("dhasetup remove - Removes the dhahelper utility.\n"); - return 0; - } - hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); - if(!strcmp(argv[1],"install")){ - printf("Installing dhahelper...\n"); - if(!CopyFile("dhahelper.sys",path,FALSE)){ - printf("Copying dhahelper.sys failed.\nEither dhahelper.sys is not in the current directory or you lack sufficient\nprivileges to write to %s.", path); - return 1; - } - // Install the driver - hService = CreateService(hSCManager, - "DHAHELPER", - "DHAHELPER", - SERVICE_ALL_ACCESS, - SERVICE_KERNEL_DRIVER, - SERVICE_SYSTEM_START, - SERVICE_ERROR_NORMAL, - path, - NULL, - NULL, - NULL, - NULL, - NULL); - if(!hService){ - printf("Unable to register DHAHELPER Service (0x%x).\n",GetLastError()); - } - } - else if(!strcmp(argv[1],"remove")){ - SERVICE_STATUS ServiceStatus; - printf("Removing dhahelper...\n"); - hService = OpenService(hSCManager, "DHAHELPER", SERVICE_ALL_ACCESS); - ControlService(hService, SERVICE_CONTROL_STOP, &ServiceStatus); - DeleteService(hService); - DeleteFile(path); - } - else { - printf("unknown parameter: %s\n",argv[1]); - } - CloseServiceHandle(hService); - CloseServiceHandle(hSCManager); - printf("Please reboot to let the changes take effect.\n"); - return 0; -} diff --git a/libdha/kernelhelper/Makefile b/libdha/kernelhelper/Makefile deleted file mode 100644 index acc4bcee03..0000000000 --- a/libdha/kernelhelper/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -KERNEL_INC = /usr/src/linux/include -CFLAGS = -O2 -D__KERNEL__ -DMODULE -I$(KERNEL_INC) \ - -include $(KERNEL_INC)/linux/modversions.h -VERSION = $(shell grep RELEASE $(KERNEL_INC)/linux/version.h | cut -d'"' -f2) -MDIR = /lib/modules/$(VERSION)/misc - -all: dhahelper.o test - -dhahelper.o: dhahelper.c dhahelper.h - -install: dhahelper.o - -mkdir -p $(MDIR) - install -m 644 dhahelper.o $(MDIR)/dhahelper.o - depmod -a - -dep depend: - -clean: - rm -f *.o *~ test - -distclean: clean diff --git a/libdha/kernelhelper/dhahelper.c b/libdha/kernelhelper/dhahelper.c deleted file mode 100644 index f5b6fe825c..0000000000 --- a/libdha/kernelhelper/dhahelper.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - Direct Hardware Access kernel helper - - (C) 2002 Alex Beregszaszi - - Accessing hardware from userspace as USER (no root needed!) - - Tested on 2.2.x (2.2.19) and 2.4.x (2.4.3,2.4.17). - - License: GPL - - WARNING! THIS MODULE VIOLATES SEVERAL SECURITY LINES! DON'T USE IT - ON PRODUCTION SYSTEMS, ONLY AT HOME, ON A "SINGLE-USER" SYSTEM. - NO WARRANTY! - - Tech: - Communication between userspace and kernelspace goes over character - device using ioctl. - - Usage: - mknod -m 666 /dev/dhahelper c 180 0 - - Also you can change the major number, setting the "dhahelper_major" - module parameter, the default is 180, specified in dhahelper.h. - - Note: do not use other than minor==0, the module forbids it. - - TODO: - * do memory mapping without fops:mmap - * implement unmap memory - * select (request?) a "valid" major number (from Linux project? ;) - * make security - * is pci handling needed? (libdha does this with lowlevel port funcs) - * is mttr handling needed? - * test on older kernels (2.0.x (?)) -*/ - -#ifndef MODULE -#define MODULE -#endif - -#ifndef __KERNEL__ -#define __KERNEL__ -#endif - -#include - -#ifdef CONFIG_MODVERSION -#define MODVERSION -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,10) -#include -#else -#include -#endif - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include "dhahelper.h" - -MODULE_AUTHOR("Alex Beregszaszi "); -MODULE_DESCRIPTION("Provides userspace access to hardware (security violation!)"); -#ifdef MODULE_LICENSE -MODULE_LICENSE("GPL"); -#endif - -static int dhahelper_major = DEFAULT_MAJOR; -MODULE_PARM(dhahelper_major, "i"); -MODULE_PARM_DESC(dhahelper_major, "Major number of dhahelper characterdevice"); - -/* 0 = silent */ -/* 1 = report errors (default) */ -/* 2 = debug */ -static int dhahelper_verbosity = 1; -MODULE_PARM(dhahelper_verbosity, "i"); -MODULE_PARM_DESC(dhahelper_verbosity, "Level of verbosity (0 = silent, 1 = only errors, 2 = debug)"); - -static dhahelper_memory_t last_mem_request; - - -static int dhahelper_open(struct inode *inode, struct file *file) -{ - if (dhahelper_verbosity > 1) - printk(KERN_DEBUG "dhahelper: device opened\n"); - - if (MINOR(inode->i_rdev) != 0) - return(-ENXIO); - - MOD_INC_USE_COUNT; - - return(0); -} - -static int dhahelper_release(struct inode *inode, struct file *file) -{ - if (dhahelper_verbosity > 1) - printk(KERN_DEBUG "dhahelper: device released\n"); - - if (MINOR(inode->i_rdev) != 0) - return(-ENXIO); - - MOD_DEC_USE_COUNT; - - return(0); -} - -static int dhahelper_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) -{ - if (dhahelper_verbosity > 1) - printk(KERN_DEBUG "dhahelper: ioctl(cmd=%x, arg=%lx)\n", - cmd, arg); - - if (MINOR(inode->i_rdev) != 0) - return(-ENXIO); - - switch(cmd) - { - case DHAHELPER_GET_VERSION: - { - int version = API_VERSION; - - if (copy_to_user((int *)arg, &version, sizeof(int))) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: failed copy to userspace\n"); - return(-EFAULT); - } - - break; - } - case DHAHELPER_PORT: - { - dhahelper_port_t port; - - if (copy_from_user(&port, (dhahelper_port_t *)arg, sizeof(dhahelper_port_t))) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: failed copy from userspace\n"); - return(-EFAULT); - } - - switch(port.operation) - { - case PORT_OP_READ: - { - switch(port.size) - { - case 1: - port.value = inb(port.addr); - break; - case 2: - port.value = inw(port.addr); - break; - case 4: - port.value = inl(port.addr); - break; - default: - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: invalid port read size (%d)\n", - port.size); - return(-EINVAL); - } - break; - } - case PORT_OP_WRITE: - { - switch(port.size) - { - case 1: - outb(port.value, port.addr); - break; - case 2: - outw(port.value, port.addr); - break; - case 4: - outl(port.value, port.addr); - break; - default: - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: invalid port write size (%d)\n", - port.size); - return(-EINVAL); - } - break; - } - default: - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: invalid port operation (%d)\n", - port.operation); - return(-EINVAL); - } - - /* copy back only if read was performed */ - if (port.operation == PORT_OP_READ) - if (copy_to_user((dhahelper_port_t *)arg, &port, sizeof(dhahelper_port_t))) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: failed copy to userspace\n"); - return(-EFAULT); - } - - break; - } - case DHAHELPER_MEMORY: - { - dhahelper_memory_t mem; - - if (copy_from_user(&mem, (dhahelper_memory_t *)arg, sizeof(dhahelper_memory_t))) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: failed copy from userspace\n"); - return(-EFAULT); - } - - switch(mem.operation) - { - case MEMORY_OP_MAP: - { -#if 1 - memcpy(&last_mem_request, &mem, sizeof(dhahelper_memory_t)); -#else - mem.ret = do_mmap(file, mem.start, mem.size, PROT_READ|PROT_WRITE, - MAP_SHARED, mem.offset); -#endif - - break; - } - case MEMORY_OP_UNMAP: - break; - default: - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: invalid memory operation (%d)\n", - mem.operation); - return(-EINVAL); - } - - if (copy_to_user((dhahelper_memory_t *)arg, &mem, sizeof(dhahelper_memory_t))) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: failed copy to userspace\n"); - return(-EFAULT); - } - - break; - } - default: - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: invalid ioctl (%x)\n", cmd); - return(-EINVAL); - } - - return(0); -} - -static int dhahelper_mmap(struct file *file, struct vm_area_struct *vma) -{ - if (last_mem_request.operation != MEMORY_OP_MAP) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: mapping not requested before mmap\n"); - return(-EFAULT); - } - - if (dhahelper_verbosity > 1) - printk(KERN_INFO "dhahelper: mapping %x (size: %x)\n", - last_mem_request.start+last_mem_request.offset, last_mem_request.size); - - if (remap_page_range(0, last_mem_request.start + last_mem_request.offset, - last_mem_request.size, vma->vm_page_prot)) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: error mapping memory\n"); - return(-EFAULT); - } - - return(0); -} - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) -static struct file_operations dhahelper_fops = -{ - /*llseek*/ NULL, - /*read*/ NULL, - /*write*/ NULL, - /*readdir*/ NULL, - /*poll*/ NULL, - /*ioctl*/ dhahelper_ioctl, - /*mmap*/ dhahelper_mmap, - /*open*/ dhahelper_open, - /*flush*/ NULL, - /*release*/ dhahelper_release, - /* zero out the last 5 entries too ? */ -}; -#else -static struct file_operations dhahelper_fops = -{ - owner: THIS_MODULE, - ioctl: dhahelper_ioctl, - mmap: dhahelper_mmap, - open: dhahelper_open, - release: dhahelper_release -}; -#endif - -#if KERNEL_VERSION < KERNEL_VERSION(2,4,0) -int init_module(void) -#else -static int __init init_dhahelper(void) -#endif -{ - printk(KERN_INFO "Direct Hardware Access kernel helper (C) Alex Beregszaszi\n"); - - if(register_chrdev(dhahelper_major, "dhahelper", &dhahelper_fops)) - { - if (dhahelper_verbosity > 0) - printk(KERN_ERR "dhahelper: unable to register character device (major: %d)\n", - dhahelper_major); - return(-EIO); - } - - return(0); -} - -#if KERNEL_VERSION < KERNEL_VERSION(2,4,0) -void cleanup_module(void) -#else -static void __exit exit_dhahelper(void) -#endif -{ - unregister_chrdev(dhahelper_major, "dhahelper"); -} - -EXPORT_NO_SYMBOLS; - -#if KERNEL_VERSION >= KERNEL_VERSION(2,4,0) -module_init(init_dhahelper); -module_exit(exit_dhahelper); -#endif diff --git a/libdha/kernelhelper/dhahelper.h b/libdha/kernelhelper/dhahelper.h deleted file mode 100644 index fa6c141adb..0000000000 --- a/libdha/kernelhelper/dhahelper.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Direct Hardware Access kernel helper - - (C) 2002 Alex Beregszaszi -*/ - -#ifndef DHAHELPER_H -#define DHAHELPER_H - -#include - -/* feel free to change */ -#define DEFAULT_MAJOR 180 - -#define API_VERSION 0x1 - -typedef struct dhahelper_port_s -{ -#define PORT_OP_READ 1 -#define PORT_OP_WRITE 2 - int operation; - int size; - int addr; - int value; -} dhahelper_port_t; - -typedef struct dhahelper_memory_s -{ -#define MEMORY_OP_MAP 1 -#define MEMORY_OP_UNMAP 2 - int operation; - int start; - int offset; - int size; - int ret; -#define MEMORY_FLAG_NOCACHE 1 - int flags; -} dhahelper_memory_t; - -typedef struct dhahelper_mtrr_s -{ -#define MTRR_OP_ADD 1 -#define MTRR_OP_DEL 2 - int operation; - int start; - int size; - int type; -} dhahelper_mtrr_t; - -typedef struct dhahelper_pci_s -{ -#define PCI_OP_READ 1 -#define PCI_OP_WRITE 1 - int operation; - int bus; - int dev; - int func; - int cmd; - int size; - int ret; -} dhahelper_pci_t; - -#define DHAHELPER_GET_VERSION _IOW('D', 0, int) -#define DHAHELPER_PORT _IOWR('D', 1, dhahelper_port_t) -#define DHAHELPER_MEMORY _IOWR('D', 2, dhahelper_memory_t) -#define DHAHELPER_MTRR _IOWR('D', 3, dhahelper_mtrr_t) -#define DHAHELPER_PCI _IOWR('D', 4, dhahelper_pci_t) - -#endif /* DHAHELPER_H */ diff --git a/libdha/kernelhelper/test.c b/libdha/kernelhelper/test.c deleted file mode 100644 index 3dca94c748..0000000000 --- a/libdha/kernelhelper/test.c +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "dhahelper.h" - -int main(int argc, char *argv[]) -{ - int fd; - int ret; - - fd = open("/dev/dhahelper", O_RDWR); - - ioctl(fd, DHAHELPER_GET_VERSION, &ret); - - printf("api version: %d\n", ret); - if (ret != API_VERSION) - printf("incompatible api!\n"); - - { - dhahelper_memory_t mem; - - mem.operation = MEMORY_OP_MAP; - //mem.start = 0xe0000000; - mem.start = 0xe4000008; - mem.offset = 0; - mem.size = 0x4000; - mem.ret = 0; - - ret = ioctl(fd, DHAHELPER_MEMORY, &mem); - - printf("ret: %s\n", strerror(errno)); - - mem.ret = (int)mmap(NULL, (size_t)mem.size, PROT_READ, MAP_SHARED, fd, (off_t)0); - printf("allocated to %x\n", mem.ret); - - if (argc > 1) - if (mem.ret != 0) - { - int i; - - for (i = 0; i < 256; i++) - printf("[%x] ", *(int *)(mem.ret+i)); - printf("\n"); - } - - munmap((void *)mem.ret, mem.size); - - mem.operation = MEMORY_OP_UNMAP; - mem.start = mem.ret; - - ioctl(fd, DHAHELPER_MEMORY, &mem); - } - - return(0); -} diff --git a/libdha/libdha.c b/libdha/libdha.c deleted file mode 100644 index 35a9ecf4e3..0000000000 --- a/libdha/libdha.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - libgha.c - Library for direct hardware access - Copyrights: - 1996/10/27 - Robin Cutshaw (robin@xfree86.org) - XFree86 3.3.3 implementation - 1999 - Øyvind Aabling. - Modified for GATOS/win/gfxdump. - - 2002 - library implementation by Nick Kurshev - - dhahelper and some changes by Alex Beregszaszi - - supported O/S's: SVR4, UnixWare, SCO, Solaris, - FreeBSD, NetBSD, 386BSD, BSDI BSD/386, - Linux, Mach/386, ISC - DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) - Licence: GPL - Original location: www.linuxvideo.org/gatos -*/ - -#include "config.h" - -#include "libdha.h" -#include "AsmMacros.h" -#include -#include -#include -#include -#include -#include -#ifdef ARCH_ALPHA -#include -#endif -#include - -#if defined(WIN32) -#include "sysdep/libdha_win32.c" -#elif defined (__EMX__) -#include "sysdep/libdha_os2.c" -#else - -#if defined(SVR4) || defined(SCO325) -# if !(defined(sun) && defined (i386) && defined (SVR4)) -# define DEV_MEM "/dev/pmem" -# elif defined(PowerMAX_OS) -# define DEV_MEM "/dev/iomem" -# endif -# ifdef SCO325 -# undef DEV_MEM -# define DEV_MEM "/dev/mem" -# endif -#elif defined(sun) && defined (i386) -#define DEV_MEM "/dev/xsvc" -# endif /* SVR4 */ - -#if defined(__OpenBSD__) -#define DEV_APERTURE "/dev/xf86" -#endif - -/* Generic version */ -#include - -#ifndef DEV_MEM -#define DEV_MEM "/dev/mem" -#endif - -#ifdef CONFIG_DHAHELPER -#include "kernelhelper/dhahelper.h" -#endif - -#ifdef CONFIG_SVGAHELPER -#include -#endif - -static int mem_fd = -1; - -void *map_phys_mem(unsigned long base, unsigned long size) -{ -#ifdef ARCH_ALPHA -/* TODO: move it into sysdep */ - base += bus_base(); -#endif - -#ifdef CONFIG_SVGAHELPER - if ( (mem_fd = open(DEV_SVGA,O_RDWR)) == -1) { - perror("libdha: SVGAlib kernelhelper failed"); -#ifdef CONFIG_DHAHELPER - goto dha_helper_way; -#else - goto dev_mem_way; -#endif - } - else - goto mmap; -#endif - -#ifdef CONFIG_DHAHELPER -#ifdef CONFIG_SVGAHELPER -dha_helper_way: -#endif - if ( (mem_fd = open("/dev/dhahelper",O_RDWR)) < 0) - { - perror("libdha: DHA kernelhelper failed"); - goto dev_mem_way; - } - else - { - dhahelper_memory_t mem_req; - - mem_req.operation = MEMORY_OP_MAP; - mem_req.start = base; - mem_req.offset = 0; - mem_req.size = size; - - if (ioctl(mem_fd, DHAHELPER_MEMORY, &mem_req) < 0) - { - perror("libdha: DHA kernelhelper failed"); - close(mem_fd); - goto dev_mem_way; - } - else - goto mmap; - } -#endif - -dev_mem_way: -#ifdef DEV_APERTURE - if ((mem_fd = open(DEV_APERTURE, O_RDWR)) == -1) - perror("libdha: opening aperture failed"); - else { - void *p = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); - - if (p == MAP_FAILED) { - perror("libdha: mapping aperture failed"); - close(mem_fd); - } else - return p; - } -#endif - - if ( (mem_fd = open(DEV_MEM,O_RDWR)) == -1) - { - perror("libdha: opening /dev/mem failed"); - return MAP_FAILED; - } - -mmap: - return mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base); -} - -void unmap_phys_mem(void *ptr, unsigned long size) -{ - int res = munmap(ptr,size); - - if (res == (int)MAP_FAILED) - { - perror("libdha: unmapping memory failed"); - return; - } - - close(mem_fd); - mem_fd = -1; - - return; -} - -#endif /* Generic mmap (not win32, nor os2) */ - -unsigned char INPORT8(unsigned idx) -{ - return inb(idx); -} - -unsigned short INPORT16(unsigned idx) -{ - return inw(idx); -} - -unsigned INPORT32(unsigned idx) -{ - return inl(idx); -} - -void OUTPORT8(unsigned idx,unsigned char val) -{ - outb(idx,val); -} - -void OUTPORT16(unsigned idx,unsigned short val) -{ - outw(idx,val); -} - -void OUTPORT32(unsigned idx,unsigned val) -{ - outl(idx,val); -} diff --git a/libdha/libdha.h b/libdha/libdha.h deleted file mode 100644 index 3135b34b76..0000000000 --- a/libdha/libdha.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - libgha.h - Library for direct hardware access - Copyrights: - 1996/10/27 - Robin Cutshaw (robin@xfree86.org) - XFree86 3.3.3 implementation - 1999 - Øyvind Aabling. - Modified for GATOS/win/gfxdump. - 2002 - library implementation by Nick Kurshev - - supported O/S's: SVR4, UnixWare, SCO, Solaris, - FreeBSD, NetBSD, 386BSD, BSDI BSD/386, - Linux, Mach/386, ISC - DOS (WATCOM 9.5 compiler), Win9x (with mapdev.vxd) - Licence: GPL -*/ -#ifndef LIBDHA_H -#define LIBDHA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define MAX_DEV_PER_VENDOR_CFG1 64 -#define MAX_PCI_DEVICES_PER_BUS 32 -#define MAX_PCI_DEVICES 64 -#define PCI_MULTIFUNC_DEV 0x80 -#define PCI_COMMAND_IO 0x1 /* Enable response to I/O space */ - -typedef struct pciinfo_s -{ - int bus,card,func; /* PCI/AGP bus:card:func */ - unsigned short command; /* Device control register */ - unsigned short vendor,device; /* Card vendor+device ID */ - unsigned base0,base1,base2,baserom; /* Memory and I/O base addresses */ -// unsigned base0_limit, base1_limit, base2_limit, baserom_limit; -}pciinfo_t; - -/* needed for mga_vid */ -extern int pci_config_read(unsigned char bus, unsigned char dev, unsigned char func, - unsigned char cmd, int len, unsigned long *val); - /* Fill array pci_list which must have size MAX_PCI_DEVICES - and return 0 if sucessful */ -extern int pci_scan(pciinfo_t *pci_list,unsigned *num_card); - - - /* Enables/disables accessing to IO space from application side. - Should return 0 if o'k or errno on error. */ -extern int enable_app_io( void ); -extern int disable_app_io( void ); - -extern unsigned char INPORT8(unsigned idx); -extern unsigned short INPORT16(unsigned idx); -extern unsigned INPORT32(unsigned idx); -#define INPORT(idx) INPORT32(idx) -extern void OUTPORT8(unsigned idx,unsigned char val); -extern void OUTPORT16(unsigned idx,unsigned short val); -extern void OUTPORT32(unsigned idx,unsigned val); -#define OUTPORT(idx,val) OUTPORT32(idx,val) - -extern void * map_phys_mem(unsigned long base, unsigned long size); -extern void unmap_phys_mem(void *ptr, unsigned long size); - -/* These are the region types */ -#define MTRR_TYPE_UNCACHABLE 0 -#define MTRR_TYPE_WRCOMB 1 -#define MTRR_TYPE_WRTHROUGH 4 -#define MTRR_TYPE_WRPROT 5 -#define MTRR_TYPE_WRBACK 6 -extern int mtrr_set_type(unsigned base,unsigned size,int type); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libdha/mtrr.c b/libdha/mtrr.c deleted file mode 100644 index 04f4d5ac3b..0000000000 --- a/libdha/mtrr.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - mtrr.c - Stuff for optimizing memory access - Copyrights: - 2002 - Linux version by Nick Kurshev - Licence: GPL -*/ - -#include "config.h" - -#include -#include -#include -#include "libdha.h" -#include "AsmMacros.h" - -#if defined (__i386__) && defined (__NetBSD__) -#include -#if __NetBSD_Version__ > 105240000 -#include -#include -#include -#include -#endif -#endif - -int mtrr_set_type(unsigned base,unsigned size,int type) -{ -#ifdef linux - FILE * mtrr_fd; - char * stype; - switch(type) - { - case MTRR_TYPE_UNCACHABLE: stype = "uncachable"; break; - case MTRR_TYPE_WRCOMB: stype = "write-combining"; break; - case MTRR_TYPE_WRTHROUGH: stype = "write-through"; break; - case MTRR_TYPE_WRPROT: stype = "write-protect"; break; - case MTRR_TYPE_WRBACK: stype = "write-back"; break; - default: return EINVAL; - } - mtrr_fd = fopen("/proc/mtrr","wt"); - if(mtrr_fd) - { - char sout[256]; - unsigned wr_len; - sprintf(sout,"base=0x%08X size=0x%08X type=%s\n",base,size,stype); - wr_len = fprintf(mtrr_fd,sout); - /*printf("MTRR: %s\n",sout);*/ - fclose(mtrr_fd); - return wr_len == strlen(sout) ? 0 : EPERM; - } - return ENOSYS; -#elif defined (__i386__ ) && defined (__NetBSD__) && __NetBSD_Version__ > 105240000 - struct mtrr *mtrrp; - int n; - - mtrrp = malloc(sizeof (struct mtrr)); - mtrrp->base = base; - mtrrp->len = size; - mtrrp->type = type; - mtrrp->flags = MTRR_VALID | MTRR_PRIVATE; - n = 1; - - if (i386_set_mtrr(mtrrp, &n) < 0) { - free(mtrrp); - return errno; - } - free(mtrrp); - return 0; -#else - /* NetBSD prior to 1.5Y doesn't have MTRR support */ - return ENOSYS; -#endif -} diff --git a/libdha/pci.c b/libdha/pci.c deleted file mode 100644 index 72f8a62505..0000000000 --- a/libdha/pci.c +++ /dev/null @@ -1,742 +0,0 @@ -/* - (C) 2002 - library implementation by Nick Kyrshev - XFree86 3.3.3 scanpci.c, modified for GATOS/win/gfxdump by Øyvind Aabling. - */ -/* $XConsortium: scanpci.c /main/25 1996/10/27 11:48:40 kaleb $ */ -/* - * name: scanpci.c - * - * purpose: This program will scan for and print details of - * devices on the PCI bus. - - * author: Robin Cutshaw (robin@xfree86.org) - * - * supported O/S's: SVR4, UnixWare, SCO, Solaris, - * FreeBSD, NetBSD, 386BSD, BSDI BSD/386, - * Linux, Mach/386, ISC - * DOS (WATCOM 9.5 compiler) - * - * compiling: [g]cc scanpci.c -o scanpci - * for SVR4 (not Solaris), UnixWare use: - * [g]cc -DSVR4 scanpci.c -o scanpci - * for DOS, watcom 9.5: - * wcc386p -zq -omaxet -7 -4s -s -w3 -d2 name.c - * and link with PharLap or other dos extender for exe - * - */ - -/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.34.2.17 1998/11/10 11:55:40 dawes Exp $ */ - -/* - * Copyright 1995 by Robin Cutshaw - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the names of the above listed copyright holder(s) - * not be used in advertising or publicity pertaining to distribution of - * the software without specific, written prior permission. The above listed - * copyright holder(s) make(s) no representations about the suitability of this - * software for any purpose. It is provided "as is" without express or - * implied warranty. - * - * THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD - * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE - * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY - * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "libdha.h" -#include -#include -#include -#ifdef __unix__ -#include -#endif -#include "AsmMacros.h" -/* OS depended stuff */ -#if defined (linux) -#include "sysdep/pci_linux.c" -#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined(__DragonFly__) -#include "sysdep/pci_freebsd.c" -#elif defined (__386BSD__) -#include "sysdep/pci_386bsd.c" -#elif defined (__NetBSD__) -#include "sysdep/pci_netbsd.c" -#elif defined (__OpenBSD__) -#include "sysdep/pci_openbsd.c" -#elif defined (__bsdi__) -#include "sysdep/pci_bsdi.c" -#elif defined (Lynx) -#include "sysdep/pci_lynx.c" -#elif defined (MACH386) -#include "sysdep/pci_mach386.c" -#elif defined (__SVR4) -#if !defined(SVR4) -#define SVR4 -#endif -#include "sysdep/pci_svr4.c" -#elif defined (SCO) -#include "sysdep/pci_sco.c" -#elif defined (ISC) -#include "sysdep/pci_isc.c" -#elif defined (__EMX__) -#include "sysdep/pci_os2.c" -#elif defined (_WIN32) || defined(__CYGWIN__) -#include "sysdep/pci_win32.c" -#ifdef __MINGW32__ -#define ENOTSUP 134 /* Not supported */ -#endif -#endif - -#if 0 -#if defined(__SUNPRO_C) || defined(sun) || defined(__sun) -#include -#else -#include -#endif -#include -#endif - -#if defined(Lynx) && defined(__powerpc__) -/* let's mimick the Linux Alpha stuff for LynxOS so we don't have - * to change too much code - */ -#include - -static unsigned char *pciConfBase; - -static __inline__ unsigned long -static swapl(unsigned long val) -{ - unsigned char *p = (unsigned char *)&val; - return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0] << 0)); -} - - -#define BUS(tag) (((tag)>>16)&0xff) -#define DFN(tag) (((tag)>>8)&0xff) - -#define PCIBIOS_DEVICE_NOT_FOUND 0x86 -#define PCIBIOS_SUCCESSFUL 0x00 - -int pciconfig_read( - unsigned char bus, - unsigned char dev, - unsigned char offset, - int len, /* unused, alway 4 */ - unsigned long *val) -{ - unsigned long _val; - unsigned long *ptr; - - dev >>= 3; - if (bus || dev >= 16) { - *val = 0xFFFFFFFF; - return PCIBIOS_DEVICE_NOT_FOUND; - } else { - ptr = (unsigned long *)(pciConfBase + ((1<>= 3; - _val = swapl(val); - if (bus || dev >= 16) { - return PCIBIOS_DEVICE_NOT_FOUND; - } else { - ptr = (unsigned long *)(pciConfBase + ((1<