[Wine-patches] [eterhack] [0020/0021] parport.sys: Implement PPARALLEL_{TRY_ALLOCATE, FREE}_ROUTINE callbacks.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Ср Янв 28 21:10:17 MSK 2009
---
dlls/parport.sys/parport.c | 49 ++++++++++++++++++++++++++++++-------------
1 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/dlls/parport.sys/parport.c b/dlls/parport.sys/parport.c
index 1bf7c32..b1f25bb 100644
--- a/dlls/parport.sys/parport.c
+++ b/dlls/parport.sys/parport.c
@@ -43,18 +43,37 @@ extern void CDECL wine_complete_request( IRP *irp, UCHAR priority_boost );
struct ParPortExtension
{
- unsigned long int base_addr;
+ struct parport *pp;
+ int claimed;
};
+struct parport_list pp_list = {0, NULL};
+
static BOOLEAN WINAPI parport_try( void *context )
{
- FIXME( "stub: %p\n", context );
+ struct ParPortExtension *ppe = context;
+
+ if (ieee1284_open( ppe->pp, 0, NULL ) != E1284_OK)
+ return FALSE;
+ if (ieee1284_claim( ppe->pp ) != E1284_OK)
+ {
+ ieee1284_close( ppe->pp );
+ return FALSE;
+ }
+ ppe->claimed = 1;
return TRUE;
}
void WINAPI parport_free( void *context )
{
- FIXME( "stub: %p\n", context );
+ struct ParPortExtension *ppe = context;
+
+ if (ppe->claimed)
+ {
+ ieee1284_release( ppe->pp );
+ ieee1284_close( ppe->pp );
+ ppe->claimed = 0;
+ }
}
ULONG WINAPI parport_query_waiters( void *context )
@@ -84,11 +103,12 @@ static NTSTATUS WINAPI parport_ioctl( DEVICE_OBJECT *device, IRP *irp )
break;
}
RtlZeroMemory( ppi, sizeof(*ppi) );
- ppi->OriginalController.QuadPart = ppe->base_addr;
- ppi->Controller = (PUCHAR)ppe->base_addr;
+ ppi->OriginalController.QuadPart = ppe->pp->base_addr;
+ ppi->Controller = (PUCHAR)ppe->pp->base_addr;
ppi->TryAllocatePort = parport_try;
ppi->FreePort = parport_free;
ppi->QueryNumWaiters = parport_query_waiters;
+ ppi->Context = ppe;
irp->IoStatus.Information = sizeof(PARALLEL_PORT_INFORMATION);
status = STATUS_SUCCESS;
break;
@@ -108,7 +128,7 @@ static NTSTATUS WINAPI parport_ioctl( DEVICE_OBJECT *device, IRP *irp )
return status;
}
-static void create_parport_device( DRIVER_OBJECT *driver, int n, unsigned long int base )
+static void create_parport_device( DRIVER_OBJECT *driver, int n, struct parport *pp )
{
static const WCHAR parallel_portW[] = {'\\','D','e','v','i','c','e',
'\\','P','a','r','a','l','l','e','l',
@@ -127,25 +147,23 @@ static void create_parport_device( DRIVER_OBJECT *driver, int n, unsigned long i
if (status == STATUS_SUCCESS)
{
ppe = parport_dev->DeviceExtension;
- ppe->base_addr = base;
+ ppe->pp = pp;
+ ppe->claimed = 0;
parport_dev->Flags &= ~DO_DEVICE_INITIALIZING;
}
}
static void enum_par_devices( DRIVER_OBJECT *driver )
{
- struct parport_list list;
struct parport *pp;
- int ret, k;
+ int k;
- ret = ieee1284_find_ports( &list, 0 );
- if (ret != E1284_OK) return;
- for (k = 0; k < list.portc; ++k)
+ ieee1284_find_ports( &pp_list, 0 );
+ for (k = 0; k < pp_list.portc; ++k)
{
- pp = list.portv[k];
- create_parport_device( driver, k, pp->base_addr );
+ pp = pp_list.portv[k];
+ create_parport_device( driver, k, pp );
}
- ieee1284_free_ports( &list );
}
#endif /* HAVE_LIBIEEE1284 */
@@ -160,6 +178,7 @@ static void WINAPI parport_unload( DRIVER_OBJECT *driver )
IoDeleteDevice( device );
device = device2;
}
+ ieee1284_free_ports( &pp_list );
#endif
}
--
1.6.0.2.GIT
Подробная информация о списке рассылки Wine-patches