[Wine-patches] [eter-1.0.12] parport fixes
Alexander Morozov
amorozov на etersoft.ru
Ср Дек 29 17:58:20 MSK 2010
----------- следующая часть -----------
From a9c2b91a531237c5a79f9a32a4eba677e3793c2f Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 29 Dec 2010 17:30:04 +0300
Subject: [eter-1.0.12 1/3] kernel32: Synchronization is not needed in this case.
---
dlls/kernel32/instr.c | 45 ++++++++++++++++++---------------------------
1 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/dlls/kernel32/instr.c b/dlls/kernel32/instr.c
index 733bc47..bc06cfa 100644
--- a/dlls/kernel32/instr.c
+++ b/dlls/kernel32/instr.c
@@ -49,16 +49,6 @@ WINE_DECLARE_DEBUG_CHANNEL(io);
#define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
#define ISV86(context) ((context)->EFlags & 0x00020000)
-static CRITICAL_SECTION pp_section;
-static CRITICAL_SECTION_DEBUG critsect_debug =
-{
- 0, 0, &pp_section,
- { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
- 0, 0, { (DWORD_PTR)(__FILE__ ": pp_section") }
-};
-static CRITICAL_SECTION pp_section = { &critsect_debug, -1, 0, 0, 0, 0 };
-
-static int parport_flag;
static UCHAR (CDECL *pp_read)( UCHAR* );
static void (CDECL *pp_write)( UCHAR*, UCHAR );
@@ -385,20 +375,13 @@ static void init_parport(void)
{
static const WCHAR parportW[] = {'p','a','r','p','o','r','t','.','s','y','s',0};
- static HMODULE parport;
+ HMODULE parport = GetModuleHandleW( parportW );
- RtlEnterCriticalSection( &pp_section );
- if (!parport_flag)
+ if (parport)
{
- parport = GetModuleHandleW( parportW );
- if (parport)
- {
- pp_read = (void *)GetProcAddress( parport, "__wine_read_parport" );
- pp_write = (void *)GetProcAddress( parport, "__wine_write_parport" );
- }
- parport_flag = 1;
+ pp_read = (void *)GetProcAddress( parport, "__wine_read_parport" );
+ pp_write = (void *)GetProcAddress( parport, "__wine_write_parport" );
}
- RtlLeaveCriticalSection( &pp_section );
}
/***********************************************************************
@@ -411,12 +394,16 @@ static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
DWORD res = ~0U;
if (!winedos.inport) load_winedos();
- if (!parport_flag) init_parport();
LOADETER_FUNC( etersoft_read_port );
if (size == 1)
{
- if (etersoft_read_port) res = etersoft_read_port( (UCHAR *)(int)port );
- else if (pp_read) res = pp_read( (UCHAR *)(int)port );
+ if (etersoft_read_port)
+ res = etersoft_read_port( (UCHAR *)(int)port );
+ else
+ {
+ if (!pp_read) init_parport();
+ if (pp_read) res = pp_read( (UCHAR *)(int)port );
+ }
}
else if (winedos.inport) res = winedos.inport( port, size );
@@ -450,12 +437,16 @@ static DWORD INSTR_inport( WORD port, int size, CONTEXT86 *context )
static void INSTR_outport( WORD port, int size, DWORD val, CONTEXT86 *context )
{
if (!winedos.outport) load_winedos();
- if (!parport_flag) init_parport();
LOADETER_FUNC( etersoft_write_port );
if (size == 1)
{
- if (etersoft_write_port) etersoft_write_port( (UCHAR *)(int)port, val );
- else if (pp_write) pp_write( (UCHAR *)(int)port, val );
+ if (etersoft_write_port)
+ etersoft_write_port( (UCHAR *)(int)port, val );
+ else
+ {
+ if (!pp_write) init_parport();
+ if (pp_write) pp_write( (UCHAR *)(int)port, val );
+ }
}
else if (winedos.outport) winedos.outport( port, size, val );
--
1.7.3.4
----------- следующая часть -----------
From 5e21547245c0d01da2d55324a58bcc783af68fd2 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 29 Dec 2010 16:35:55 +0300
Subject: [eter-1.0.12 2/3] hal: Load parport functions dynamically.
---
dlls/hal/Makefile.in | 2 +-
dlls/hal/hal.c | 31 +++++++++++++++++++++++++++++--
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dlls/hal/Makefile.in b/dlls/hal/Makefile.in
index 7d2754c..026268a 100644
--- a/dlls/hal/Makefile.in
+++ b/dlls/hal/Makefile.in
@@ -3,7 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = hal.dll
-IMPORTS = kernel32 ntdll parport.sys
+IMPORTS = kernel32 ntdll
C_SRCS = \
hal.c
diff --git a/dlls/hal/hal.c b/dlls/hal/hal.c
index d066d84..abbe8b2 100644
--- a/dlls/hal/hal.c
+++ b/dlls/hal/hal.c
@@ -31,6 +31,7 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winternl.h"
+#include "winbase.h"
#include "excpt.h"
#include "ddk/ntddk.h"
#include "wine/debug.h"
@@ -57,6 +58,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntoskrnl);
extern UCHAR CDECL __wine_read_parport( UCHAR *port );
extern void CDECL __wine_write_parport( UCHAR *port, UCHAR value );
+static UCHAR (CDECL *pp_read)( UCHAR* );
+static void (CDECL *pp_write)( UCHAR*, UCHAR );
+
#ifdef DEFINE_FASTCALL1_ENTRYPOINT
DEFINE_FASTCALL1_ENTRYPOINT( ExAcquireFastMutex )
VOID WINAPI __regs_ExAcquireFastMutex(PFAST_MUTEX FastMutex)
@@ -173,14 +177,37 @@ void WINAPI KeStallExecutionProcessor(ULONG MicroSeconds)
nanosleep( &ts, NULL );
}
+static void init_parport(void)
+{
+ static const WCHAR parportW[] = {'p','a','r','p','o','r','t','.','s','y','s',0};
+
+ HMODULE parport = GetModuleHandleW( parportW );
+
+ if (parport)
+ {
+ pp_read = (void *)GetProcAddress( parport, "__wine_read_parport" );
+ pp_write = (void *)GetProcAddress( parport, "__wine_write_parport" );
+ }
+}
+
UCHAR WINAPI READ_PORT_UCHAR(PUCHAR Port)
{
TRACE( "(%p)\n", Port );
- return __wine_read_parport( Port );
+
+ if (!pp_read)
+ init_parport();
+ if (pp_read)
+ return pp_read( Port );
+ else
+ return 0xff;
}
void WINAPI WRITE_PORT_UCHAR(PUCHAR Port, UCHAR Value)
{
TRACE( "(%p %u)\n", Port, Value );
- __wine_write_parport( Port, Value );
+
+ if (!pp_write)
+ init_parport();
+ if (pp_write)
+ pp_write( Port, Value );
}
--
1.7.3.4
----------- следующая часть -----------
From 56ee44c917cafca14ca12c084edf50cec259c73b Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Wed, 29 Dec 2010 17:41:28 +0300
Subject: [eter-1.0.12 3/3] Print an error if failed to load parport functions.
---
dlls/hal/hal.c | 2 ++
dlls/kernel32/instr.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/dlls/hal/hal.c b/dlls/hal/hal.c
index abbe8b2..f9d56b9 100644
--- a/dlls/hal/hal.c
+++ b/dlls/hal/hal.c
@@ -188,6 +188,8 @@ static void init_parport(void)
pp_read = (void *)GetProcAddress( parport, "__wine_read_parport" );
pp_write = (void *)GetProcAddress( parport, "__wine_write_parport" );
}
+ if (!pp_read || !pp_write)
+ ERR( "failed to load parport functions\n" );
}
UCHAR WINAPI READ_PORT_UCHAR(PUCHAR Port)
diff --git a/dlls/kernel32/instr.c b/dlls/kernel32/instr.c
index bc06cfa..685d163 100644
--- a/dlls/kernel32/instr.c
+++ b/dlls/kernel32/instr.c
@@ -382,6 +382,8 @@ static void init_parport(void)
pp_read = (void *)GetProcAddress( parport, "__wine_read_parport" );
pp_write = (void *)GetProcAddress( parport, "__wine_write_parport" );
}
+ if (!pp_read || !pp_write)
+ ERR( "failed to load parport functions\n" );
}
/***********************************************************************
--
1.7.3.4
Подробная информация о списке рассылки Wine-patches