2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: services/parallel/parallel.c
5 * PURPOSE: Parallel port driver
6 * PROGRAMMER: David Welch (welch@mcmail.com)
9 * 18/06/98: Made more NT like
12 /* FUNCTIONS **************************************************************/
14 #include <ddk/ntddk.h>
19 #define LP_S (inb_p(LP_B+1))
22 static void Parallel_Reset(void)
24 * FUNCTION: Resets the device attached to the parallel port
30 for (i
=0;i
<LP_DELAY
;i
++);
31 outb_p(LP_C
,LP_PSELECP
| LP_PINITP
);
34 static void Parallel_putchar(unsigned char ch
)
36 * FUNCTION: Writes a character to the parallel port
38 * ch = character to write
51 while ( count
< 500000 && !(status
& LP_PBUSY
) );
55 printk("printer_putchar(): timed out\n");
60 while (wait
!= 10000) { wait
++; }
61 outb_p(LP_C
, (LP_PSELECP
| LP_PINITP
| LP_PSTROBE
));
62 while (wait
) { wait
--; }
63 outb_p(LP_C
, LP_PSELECP
| LP_PINITP
);
66 NTSTATUS
Dispatch(PDEVICE_OBJECT DeviceObject
, PIRP Irp
)
68 * FUNCTION: Handles user mode requests
70 * DeviceObject = Device for request
71 * Irp = I/O request packet describing request
72 * RETURNS: Success or failure
75 PIO_STACK_LOCATION Stack
= IoGetCurrentIrpStackLocation(Irp
);
79 switch (Stack
->MajorFunction
)
82 printk("(Parallel Port Driver) Creating\n");
84 status
= STATUS_SUCCESS
;
88 status
= STATUS_SUCCESS
;
92 printk("(Parallel Port Driver) Writing %d bytes\n",
93 Stack
->Parameters
.Write
.Length
);
94 for (i
=0;i
<Stack
->Parameters
.Write
.Length
;i
++)
96 Parallel_putchar(((char *)Irp
->UserBuffer
)[i
]);
98 status
= STATUS_SUCCESS
;
102 status
= STATUS_NOT_IMPLEMENTED
;
106 Irp
->IoStatus
.Status
= status
;
107 Irp
->IoStatus
.Information
= 0;
109 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
113 NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObject
, PUNICODE_STRING RegistryPath
)
115 * FUNCTION: Called by the system to initalize the driver
117 * DriverObject = object describing this driver
118 * RegistryPath = path to our configuration entries
119 * RETURNS: Success or failure
122 PDEVICE_OBJECT DeviceObject
;
125 printk("Parallel Port Driver 0.0.1\n");
128 ret
= IoCreateDevice(DriverObject
,0,"\\Device\\Parallel",
129 FILE_DEVICE_PARALLEL_PORT
,0,FALSE
,&DeviceObject
);
130 if (ret
!=STATUS_SUCCESS
)
135 DeviceObject
->Flags
=0;
136 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = Dispatch
;
137 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = Dispatch
;
138 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = Dispatch
;
139 DriverObject
->MajorFunction
[IRP_MJ_WRITE
] = Dispatch
;
140 DriverObject
->DriverUnload
= NULL
;
142 return(STATUS_SUCCESS
);