[Wine-patches] [eterhack] [0009/0021] Add parport.sys.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Ср Янв 28 21:10:06 MSK 2009


---
 configure.ac                      |   13 ++++
 dlls/parport.sys/Makefile.in      |   15 ++++
 dlls/parport.sys/parport.c        |  133 +++++++++++++++++++++++++++++++++++++
 dlls/parport.sys/parport.sys.spec |    1 +
 include/ddk/parallel.h            |    3 +
 tools/wine.inf.in                 |    9 +++
 6 files changed, 174 insertions(+), 0 deletions(-)
 create mode 100644 dlls/parport.sys/Makefile.in
 create mode 100644 dlls/parport.sys/parport.c
 create mode 100644 dlls/parport.sys/parport.sys.spec

diff --git a/configure.ac b/configure.ac
index 46aa2b1..5ca281d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,6 +42,7 @@ AC_ARG_WITH(glu,       AS_HELP_STRING([--without-glu],[do not use the GLU librar
             [if test "x$withval" = "xno"; then ac_cv_header_GL_glu_h=no; fi])
 AC_ARG_WITH(gnutls,    AS_HELP_STRING([--without-gnutls],[do not use GnuTLS (schannel support)]))
 AC_ARG_WITH(hal,       AS_HELP_STRING([--without-hal],[do not use HAL (dynamic device support)]))
+AC_ARG_WITH(ieee1284,  AS_HELP_STRING([--without-ieee1284],[do not use libieee1284]))
 AC_ARG_WITH(jack,      AS_HELP_STRING([--without-jack],[do not use the Jack sound support]),
             [if test "x$withval" = "xno"; then ac_cv_header_jack_jack_h=no; fi])
 AC_ARG_WITH(jpeg,      AS_HELP_STRING([--without-jpeg],[do not use JPEG]),
@@ -1006,6 +1007,18 @@ fi
 WINE_NOTICE_WITH(sane,[test "x$ac_cv_lib_soname_sane" = "x"],
                  [libsane ${notice_platform}development files not found, scanners won't be supported.])
 
+dnl **** Check for libieee1284 ****
+AC_SUBST(IEEE1284LIBS,"")
+if test "x$with_ieee1284" != "xno"
+then
+    AC_CHECK_HEADER(ieee1284.h,
+        AC_CHECK_LIB(ieee1284, ieee1284_find_ports,
+            [AC_DEFINE(HAVE_LIBIEEE1284, 1, [Define if you have the libieee1284 library and header])
+             IEEE1284LIBS="-lieee1284"]))
+fi
+WINE_NOTICE_WITH(ieee1284,[test "x$ac_cv_lib_ieee1284_ieee1284_find_ports" = "x"],
+                 [libieee1284 ${notice_platform}development files not found, no dynamic device support.])
+
 dnl **** Check for LIBUSB ****
 AC_SUBST(USBLIBS,"")
 if test "$ac_cv_header_usb_h" = "yes" -a "x$with_usb" != "xno"
diff --git a/dlls/parport.sys/Makefile.in b/dlls/parport.sys/Makefile.in
new file mode 100644
index 0000000..2cae1a8
--- /dev/null
+++ b/dlls/parport.sys/Makefile.in
@@ -0,0 +1,15 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = parport.sys
+IMPORTS   = ntoskrnl.exe
+EXTRADLLFLAGS = -Wb,--subsystem,native
+EXTRALIBS = @IEEE1284LIBS@
+
+C_SRCS = \
+	parport.c
+
+ на MAKE_DLL_RULES@
+
+ на DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/parport.sys/parport.c b/dlls/parport.sys/parport.c
new file mode 100644
index 0000000..532e7a6
--- /dev/null
+++ b/dlls/parport.sys/parport.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2009 Alexander Morozov for Etersoft
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#ifdef HAVE_LIBIEEE1284
+#include <ieee1284.h>
+#endif
+
+#define NONAMELESSUNION
+#define NONAMELESSSTRUCT
+
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "winternl.h"
+#include "winioctl.h"
+#include "ddk/ntddk.h"
+#include "ddk/parallel.h"
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(parport);
+
+
+#ifdef HAVE_LIBIEEE1284
+extern void CDECL wine_complete_request( IRP *irp, UCHAR priority_boost );
+
+struct ParPortExtension
+{
+    unsigned long int base_addr;
+};
+
+static NTSTATUS WINAPI parport_ioctl( DEVICE_OBJECT *device, IRP *irp )
+{
+    IO_STACK_LOCATION *irpsp = irp->Tail.Overlay.s.u.CurrentStackLocation;
+    NTSTATUS status = STATUS_NOT_SUPPORTED;
+
+    TRACE( "%p, %p\n", device, irp );
+
+    switch(irpsp->Parameters.DeviceIoControl.IoControlCode)
+    {
+    case IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO:
+    {
+        PARALLEL_PORT_INFORMATION *ppi = irp->AssociatedIrp.SystemBuffer;
+        struct ParPortExtension *ppe = device->DeviceExtension;
+
+        if (irpsp->Parameters.DeviceIoControl.OutputBufferLength
+                < sizeof(PARALLEL_PORT_INFORMATION))
+        {
+            status = STATUS_BUFFER_TOO_SMALL;
+            break;
+        }
+        RtlZeroMemory( ppi, sizeof(*ppi) );
+        ppi->OriginalController.QuadPart = ppe->base_addr;
+        ppi->Controller = (PUCHAR)ppe->base_addr;
+        irp->IoStatus.Information = sizeof(PARALLEL_PORT_INFORMATION);
+        status = STATUS_SUCCESS;
+        break;
+    }
+    case IOCTL_INTERNAL_GET_MORE_PARALLEL_PORT_INFO:
+        irp->IoStatus.Information = 0;
+        status = STATUS_SUCCESS;
+    }
+    irp->IoStatus.u.Status = status;
+    wine_complete_request( irp, IO_NO_INCREMENT );
+    return status;
+}
+
+static void create_parport_device( DRIVER_OBJECT *driver, int n, unsigned long int base )
+{
+    static const WCHAR parallel_portW[] = {'\\','D','e','v','i','c','e',
+                                           '\\','P','a','r','a','l','l','e','l',
+                                           'P','o','r','t','%','d',0};
+
+    struct ParPortExtension *ppe;
+    UNICODE_STRING parallel_port;
+    DEVICE_OBJECT *parport_dev;
+    WCHAR device_name[MAX_PATH];
+    NTSTATUS status;
+
+    snprintfW( device_name, MAX_PATH, parallel_portW, n );
+    RtlInitUnicodeString( &parallel_port, device_name );
+    status = IoCreateDevice( driver, sizeof(struct ParPortExtension), &parallel_port,
+            FILE_DEVICE_PARALLEL_PORT, FILE_DEVICE_SECURE_OPEN, FALSE, &parport_dev );
+    if (status == STATUS_SUCCESS)
+    {
+        ppe = parport_dev->DeviceExtension;
+        ppe->base_addr = base;
+        parport_dev->Flags &= ~DO_DEVICE_INITIALIZING;
+    }
+}
+
+static void enum_par_devices( DRIVER_OBJECT *driver )
+{
+    struct parport_list list;
+    struct parport *pp;
+    int ret, k;
+
+    ret = ieee1284_find_ports( &list, 0 );
+    if (ret != E1284_OK) return;
+    for (k = 0; k < list.portc; ++k)
+    {
+        pp = list.portv[k];
+        create_parport_device( driver, k, pp->base_addr );
+    }
+    ieee1284_free_ports( &list );
+}
+#endif  /* HAVE_LIBIEEE1284 */
+
+NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
+{
+#ifdef HAVE_LIBIEEE1284
+    driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = parport_ioctl;
+    enum_par_devices( driver );
+#endif
+    return STATUS_SUCCESS;
+}
diff --git a/dlls/parport.sys/parport.sys.spec b/dlls/parport.sys/parport.sys.spec
new file mode 100644
index 0000000..76421d7
--- /dev/null
+++ b/dlls/parport.sys/parport.sys.spec
@@ -0,0 +1 @@
+# nothing to export
diff --git a/include/ddk/parallel.h b/include/ddk/parallel.h
index d0b5eae..da5ec2a 100644
--- a/include/ddk/parallel.h
+++ b/include/ddk/parallel.h
@@ -17,6 +17,9 @@
 #ifndef _PARALLEL_
 #define _PARALLEL_
 
+#define IOCTL_INTERNAL_GET_PARALLEL_PORT_INFO      CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#define IOCTL_INTERNAL_GET_MORE_PARALLEL_PORT_INFO CTL_CODE(FILE_DEVICE_PARALLEL_PORT, 17, METHOD_BUFFERED, FILE_ANY_ACCESS)
+
 typedef BOOLEAN (WINAPI *PPARALLEL_TRY_ALLOCATE_ROUTINE)(PVOID TryAllocateContext);
 typedef void (WINAPI *PPARALLEL_FREE_ROUTINE)(PVOID FreeContext);
 typedef ULONG (WINAPI *PPARALLEL_QUERY_WAITERS_ROUTINE)(PVOID QueryAllocsContext);
diff --git a/tools/wine.inf.in b/tools/wine.inf.in
index f08ecf8..c05ce25 100644
--- a/tools/wine.inf.in
+++ b/tools/wine.inf.in
@@ -79,11 +79,13 @@ AddReg=\
 
 [DefaultInstall.Services]
 AddService=MountMgr,0x800,MountMgrService
+AddService=Parport,0,ParPortService
 AddService=Spooler,0,SpoolerService
 AddService=Usbhub,0,UsbhubService
 
 [DefaultInstall.NT.Services]
 AddService=MountMgr,0x800,MountMgrService
+AddService=Parport,0,ParPortService
 AddService=Spooler,0,SpoolerService
 AddService=Usbhub,0,UsbhubService
 
@@ -2324,6 +2326,7 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G"
 11,,ws2_32.dll
 11,,wsock32.dll
 12,,mountmgr.sys
+12,,parport.sys
 12,,usbhub.sys
 16422,Internet Explorer,iexplore.exe
 
@@ -2711,6 +2714,12 @@ ServiceType=1
 StartType=2
 ErrorControl=1
 
+[ParPortService]
+ServiceBinary="%12%\parport.sys"
+ServiceType=1
+StartType=2
+ErrorControl=1
+
 [SpoolerService]
 Description="Loads files to memory for later printing"
 DisplayName="Print Spooler"
-- 
1.6.0.2.GIT



Подробная информация о списке рассылки Wine-patches