diff options
author | ben <ben@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-04-06 15:20:49 +0000 |
---|---|---|
committer | ben <ben@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-04-06 15:20:49 +0000 |
commit | 51ba40dcd64518c8d5f9ce586171c8fb347a42c0 (patch) | |
tree | 590b1ce6d17f2126b67d1a5cb1576cdd7e8dea5c /vidix | |
parent | 3099d0da16505cbc0aaab34f9299404e9ec19241 (diff) | |
download | mpv-51ba40dcd64518c8d5f9ce586171c8fb347a42c0.tar.bz2 mpv-51ba40dcd64518c8d5f9ce586171c8fb347a42c0.tar.xz |
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
Diffstat (limited to 'vidix')
57 files changed, 17393 insertions, 28 deletions
diff --git a/vidix/AsmMacros.h b/vidix/AsmMacros.h new file mode 100644 index 0000000000..5e4e1addc4 --- /dev/null +++ b/vidix/AsmMacros.h @@ -0,0 +1,117 @@ +/* $XConsortium: AsmMacros.h /main/13 1996/10/25 11:33:12 kaleb $ */ +/* + * (c) Copyright 1993,1994 by David Wexelblat <dwex@xfree86.org> + * + * 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 <sys/types.h> +# ifndef __USLC__ +# define __USLC__ +# endif +# endif +#ifndef SCO325 +# include <sys/inline.h> +#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/vidix/Makefile b/vidix/Makefile index b05b3b4fe2..a97666fe26 100644 --- a/vidix/Makefile +++ b/vidix/Makefile @@ -3,11 +3,25 @@ include ../config.mak LIBNAME_MPLAYER = libvidix.a SRCS_MPLAYER = vidixlib.c \ + libdha.c \ + mtrr.c \ + pci.c \ + pci_names.c \ + pci_dev_ids.c \ $(wildcard *.c) OBJS_MPLAYER = mga_crtc2_vid.o \ rage128_vid.o \ +# If you want libdha to use svgalib_helper for hardware access, +# uncomment this statement, and change the -I to the correct directory +# that includes svgalib_helper.o: +#CFLAGS += -DDEV_SVGA=\"/dev/svga\" -DCONFIG_SVGAHELPER -Isvgalib_helper/ + +libs: pci_names.c + +dep depend:: pci_names.c + include ../mpcommon.mak mga_crtc2_vid.o: mga_vid.c @@ -15,3 +29,9 @@ mga_crtc2_vid.o: mga_vid.c rage128_vid.o: radeon_vid.c $(CC) -c $(CFLAGS) -DRAGE128 -o $@ $< + +pci_names.c pci_dev_ids.c: pci.db + LC_ALL=C $(AWK) -f pci_db2c.awk $< + +clean:: + rm -f pci_*.c pci_*.h diff --git a/vidix/bin/README b/vidix/bin/README new file mode 100644 index 0000000000..fe4bfa6f34 --- /dev/null +++ b/vidix/bin/README @@ -0,0 +1,6 @@ +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/vidix/bin/mapdev.copyright b/vidix/bin/mapdev.copyright new file mode 100644 index 0000000000..b22433d291 --- /dev/null +++ b/vidix/bin/mapdev.copyright @@ -0,0 +1,70 @@ +From khazzah@melita.com Mon Jun 23 21:48:19 1997 +Return-Path: <khazzah@melita.com> +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 <Stefan.Dirsch@stud.uni-erlangen.de>; 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 <khazzah@melita.com> +To: "'Stefan.Dirsch@stud.uni-erlangen.de'" <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: <KHazzah@melita.com> +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 <sndirsch@suse.de>; 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 <sndirsch@suse.de>; Tue, 3 Mar 1998 19:48:10 -0500 +Received: by zippy.melita.com with Internet Mail Service (5.5.1960.3) + id <F5X7MBSS>; Tue, 3 Mar 1998 18:00:26 -0500 +Message-ID: <D8EE8292EB83D111A15E00805FA67447166532@zippy.melita.com> +From: "Hazzah, Karen" <KHazzah@melita.com> +To: Stefan Dirsch <sndirsch@suse.de> +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/vidix/bin/mapdev.vxd b/vidix/bin/mapdev.vxd Binary files differnew file mode 100644 index 0000000000..e09194b842 --- /dev/null +++ b/vidix/bin/mapdev.vxd diff --git a/vidix/cyberblade_vid.c b/vidix/cyberblade_vid.c index f0109bf81f..ebb4869226 100644 --- a/vidix/cyberblade_vid.c +++ b/vidix/cyberblade_vid.c @@ -46,9 +46,9 @@ #include "vidix.h" #include "vidixlib.h" #include "fourcc.h" -#include "../libdha/libdha.h" -#include "../libdha/pci_ids.h" -#include "../libdha/pci_names.h" +#include "libdha.h" +#include "pci_ids.h" +#include "pci_names.h" #include "../config.h" #include "cyberblade_regs.h" diff --git a/vidix/dhahelperwin/MAKEFILE b/vidix/dhahelperwin/MAKEFILE new file mode 100644 index 0000000000..58189757d6 --- /dev/null +++ b/vidix/dhahelperwin/MAKEFILE @@ -0,0 +1,7 @@ +# +# 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/vidix/dhahelperwin/SOURCES b/vidix/dhahelperwin/SOURCES new file mode 100644 index 0000000000..e44aa06971 --- /dev/null +++ b/vidix/dhahelperwin/SOURCES @@ -0,0 +1,6 @@ +TARGETNAME=dhahelper +TARGETPATH=. +TARGETTYPE=DRIVER +NTDEBUG=ntsd + +SOURCES= dhahelper.c diff --git a/vidix/dhahelperwin/dhahelper.c b/vidix/dhahelperwin/dhahelper.c new file mode 100644 index 0000000000..230d44a372 --- /dev/null +++ b/vidix/dhahelperwin/dhahelper.c @@ -0,0 +1,359 @@ +/****************************************************************************** + * dhahelper.c: direct hardware access under Windows NT/2000/XP + * Copyright (c) 2004 Sascha Sommer <saschasommer@freenet.de>. + * + * 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 <ntddk.h> +#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"); + |