ReactOS 0.4.16-dev-197-g92996da
parallel.c File Reference
#include <wdm.h>
#include "parallel.h"
#include <debug.h>
Include dependency graph for parallel.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define LP_B   (0x378)
 
#define LP_S   (READ_PORT_UCHAR((PUCHAR)(LP_B+1)))
 
#define LP_C   (LP_B+2)
 

Functions

NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
static void Parallel_Reset (void)
 
static void Parallel_putchar (unsigned char ch)
 
static NTSTATUS NTAPI Dispatch (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 

Variables

static DRIVER_DISPATCH Dispatch
 

Macro Definition Documentation

◆ LP_B

#define LP_B   (0x378)

Definition at line 22 of file parallel.c.

◆ LP_C

#define LP_C   (LP_B+2)

Definition at line 24 of file parallel.c.

◆ LP_S

#define LP_S   (READ_PORT_UCHAR((PUCHAR)(LP_B+1)))

Definition at line 23 of file parallel.c.

◆ NDEBUG

#define NDEBUG

Definition at line 18 of file parallel.c.

Function Documentation

◆ Dispatch()

static NTSTATUS NTAPI Dispatch ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)
static

Definition at line 75 of file parallel.c.

83{
86 ULONG i;
87
88 switch (Stack->MajorFunction)
89 {
90 case IRP_MJ_CREATE:
91 DPRINT("(Parallel Port Driver) Creating\n");
94 break;
95
96 case IRP_MJ_CLOSE:
98 break;
99
100 case IRP_MJ_WRITE:
101 DPRINT("(Parallel Port Driver) Writing %d bytes\n",
102 Stack->Parameters.Write.Length);
103 for (i=0;i<Stack->Parameters.Write.Length;i++)
104 {
105 Parallel_putchar(((char *)Irp->UserBuffer)[i]);
106 }
108 break;
109
110 default:
112 break;
113 }
114
115 Irp->IoStatus.Status = status;
116 Irp->IoStatus.Information = 0;
117
119 return(status);
120}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
static void Parallel_Reset(void)
Definition: parallel.c:29
static void Parallel_putchar(unsigned char ch)
Definition: parallel.c:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IoCompleteRequest
Definition: irp.c:1240
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_WRITE
Definition: rdpdr.c:47
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
Definition: wdfrequest.h:639
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 123 of file parallel.c.

131{
133 UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Parallel");
135
136 DPRINT("Parallel Port Driver 0.0.1\n");
137
139 0,
140 &DeviceName,
142 0,
143 FALSE,
144 &DeviceObject);
145 if (!NT_SUCCESS(Status))
146 {
147 return(Status);
148 }
149
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->DriverUnload = NULL;
155
156 return(STATUS_SUCCESS);
157}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static DRIVER_DISPATCH Dispatch
Definition: parallel.c:73
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define L(x)
Definition: ntvdm.h:50
#define FILE_DEVICE_PARALLEL_PORT
Definition: winioctl.h:67
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

◆ Parallel_putchar()

static void Parallel_putchar ( unsigned char  ch)
static

Definition at line 41 of file parallel.c.

47{
48
49 int count=0;
50 int status;
51 int wait=0;
52
53 do
54 {
56 count++;
57 }
58 while ( count < 500000 && !(status & LP_PBUSY) );
59
60 if (count==500000)
61 {
62 DPRINT("printer_putchar(): timed out\n");
63 return;
64 }
65
67 while (wait != 10000) { wait++; }
69 while (wait) { wait--; }
71}
#define LP_B
Definition: parallel.c:22
#define LP_C
Definition: parallel.c:24
#define LP_S
Definition: parallel.c:23
#define LP_PBUSY
Definition: parallel.h:101
#define LP_PINITP
Definition: parallel.h:114
#define LP_PSTROBE
Definition: parallel.h:116
#define LP_PSELECP
Definition: parallel.h:113
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21
unsigned char * PUCHAR
Definition: typedefs.h:53

Referenced by Dispatch().

◆ Parallel_Reset()

static void Parallel_Reset ( void  )
static

Definition at line 29 of file parallel.c.

33{
34 int i;
35
37 for (i=0;i<LP_DELAY;i++);
39}
#define LP_DELAY
Definition: parallel.h:129

Referenced by Dispatch().

Variable Documentation

◆ Dispatch

Definition at line 73 of file parallel.c.

Referenced by DriverEntry().