1 /* $Id: parallel.c,v 1.5 2000/06/29 23:35:49 dwelch Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/parallel/parallel.c
6 * PURPOSE: Parallel port driver
7 * PROGRAMMER: David Welch (welch@mcmail.com)
10 * 18/06/98: Made more NT like
13 /* FUNCTIONS **************************************************************/
15 #include <ddk/ntddk.h>
16 #include "../../../ntoskrnl/include/internal/i386/io.h"
25 #define LP_S (inb_p(LP_B+1))
28 static void Parallel_Reset(void)
30 * FUNCTION: Resets the device attached to the parallel port
36 for (i
=0;i
<LP_DELAY
;i
++);
37 outb_p(LP_C
,LP_PSELECP
| LP_PINITP
);
40 static void Parallel_putchar(unsigned char ch
)
42 * FUNCTION: Writes a character to the parallel port
44 * ch = character to write
57 while ( count
< 500000 && !(status
& LP_PBUSY
) );
61 DPRINT("printer_putchar(): timed out\n");
66 while (wait
!= 10000) { wait
++; }
67 outb_p(LP_C
, (LP_PSELECP
| LP_PINITP
| LP_PSTROBE
));
68 while (wait
) { wait
--; }
69 outb_p(LP_C
, LP_PSELECP
| LP_PINITP
);
72 NTSTATUS
Dispatch(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
74 * FUNCTION: Handles user mode requests
76 * DeviceObject = Device for request
77 * Irp = I/O request packet describing request
78 * RETURNS: Success or failure
81 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
85 switch (Stack
->MajorFunction
)
88 DPRINT("(Parallel Port Driver) Creating\n");
90 status
= STATUS_SUCCESS
;
94 status
= STATUS_SUCCESS
;
98 DPRINT("(Parallel Port Driver) Writing %d bytes\n",
99 Stack
->Parameters
.Write
.Length
);
100 for (i
=0;i
<Stack
->Parameters
.Write
.Length
;i
++)
102 Parallel_putchar(((char *)Irp
->UserBuffer
)[i
]);
104 status
= STATUS_SUCCESS
;
108 status
= STATUS_NOT_IMPLEMENTED
;
112 Irp
->IoStatus
.Status
= status
;
113 Irp
->IoStatus
.Information
= 0;
115 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
120 DriverEntry(PDRIVER_OBJECT DriverObject
, PUNICODE_STRING RegistryPath
)
122 * FUNCTION: Called by the system to initalize the driver
124 * DriverObject = object describing this driver
125 * RegistryPath = path to our configuration entries
126 * RETURNS: Success or failure
129 PDEVICE_OBJECT DeviceObject
;
131 ANSI_STRING ansi_device_name
;
132 UNICODE_STRING device_name
;
134 DbgPrint("Parallel Port Driver 0.0.1\n");
136 RtlInitAnsiString (&ansi_device_name
, "\\Device\\Parallel");
137 RtlAnsiStringToUnicodeString (&device_name
, &ansi_device_name
, TRUE
);
138 ret
= IoCreateDevice(DriverObject
,
141 FILE_DEVICE_PARALLEL_PORT
,
145 if (ret
!=STATUS_SUCCESS
)
150 DeviceObject
->Flags
=0;
151 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = Dispatch
;
152 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = Dispatch
;
153 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = Dispatch
;
154 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = Dispatch
;
155 DriverObject
->DriverUnload
= NULL
;
157 return(STATUS_SUCCESS
);