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 <rosrtl/string.h>
25 #define LP_S (READ_PORT_UCHAR((PUCHAR)(LP_B+1)))
28 static void Parallel_Reset(void)
30 * FUNCTION: Resets the device attached to the parallel port
35 WRITE_PORT_UCHAR((PUCHAR
)LP_C
,0);
36 for (i
=0;i
<LP_DELAY
;i
++);
37 WRITE_PORT_UCHAR((PUCHAR
)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");
65 WRITE_PORT_UCHAR((PUCHAR
)LP_B
,ch
);
66 while (wait
!= 10000) { wait
++; }
67 WRITE_PORT_UCHAR((PUCHAR
)LP_C
, (LP_PSELECP
| LP_PINITP
| LP_PSTROBE
));
68 while (wait
) { wait
--; }
69 WRITE_PORT_UCHAR((PUCHAR
)LP_C
, LP_PSELECP
| LP_PINITP
);
73 Dispatch(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
75 * FUNCTION: Handles user mode requests
77 * DeviceObject = Device for request
78 * Irp = I/O request packet describing request
79 * RETURNS: Success or failure
82 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
86 switch (Stack
->MajorFunction
)
89 DPRINT("(Parallel Port Driver) Creating\n");
91 status
= STATUS_SUCCESS
;
95 status
= STATUS_SUCCESS
;
99 DPRINT("(Parallel Port Driver) Writing %d bytes\n",
100 Stack
->Parameters
.Write
.Length
);
101 for (i
=0;i
<Stack
->Parameters
.Write
.Length
;i
++)
103 Parallel_putchar(((char *)Irp
->UserBuffer
)[i
]);
105 status
= STATUS_SUCCESS
;
109 status
= STATUS_NOT_IMPLEMENTED
;
113 Irp
->IoStatus
.Status
= status
;
114 Irp
->IoStatus
.Information
= 0;
116 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
121 DriverEntry(PDRIVER_OBJECT DriverObject
, PUNICODE_STRING RegistryPath
)
123 * FUNCTION: Called by the system to initalize the driver
125 * DriverObject = object describing this driver
126 * RegistryPath = path to our configuration entries
127 * RETURNS: Success or failure
130 PDEVICE_OBJECT DeviceObject
;
131 UNICODE_STRING DeviceName
= ROS_STRING_INITIALIZER(L
"\\Device\\Parallel");
134 DPRINT("Parallel Port Driver 0.0.1\n");
136 Status
= IoCreateDevice(DriverObject
,
139 FILE_DEVICE_PARALLEL_PORT
,
143 if (!NT_SUCCESS(Status
))
148 DeviceObject
->Flags
=0;
149 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = Dispatch
;
150 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = Dispatch
;
151 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = Dispatch
;
152 DriverObject
->DriverUnload
= NULL
;
154 return(STATUS_SUCCESS
);