mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Replaced linux io calls
svn path=/trunk/; revision=1414
This commit is contained in:
parent
1db1c12cf3
commit
9267a79b9e
1 changed files with 38 additions and 39 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: parallel.c,v 1.5 2000/06/29 23:35:49 dwelch Exp $
|
/* $Id: parallel.c,v 1.6 2000/10/22 02:02:28 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -13,7 +13,6 @@
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include "../../../ntoskrnl/include/internal/i386/io.h"
|
|
||||||
|
|
||||||
#include "parallel.h"
|
#include "parallel.h"
|
||||||
|
|
||||||
|
@ -22,20 +21,20 @@
|
||||||
|
|
||||||
|
|
||||||
#define LP_B (0x378)
|
#define LP_B (0x378)
|
||||||
#define LP_S (inb_p(LP_B+1))
|
#define LP_S (READ_PORT_UCHAR((PUCHAR)(LP_B+1)))
|
||||||
#define LP_C (LP_B+2)
|
#define LP_C (LP_B+2)
|
||||||
|
|
||||||
static void Parallel_Reset(void)
|
static void Parallel_Reset(void)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Resets the device attached to the parallel port
|
* FUNCTION: Resets the device attached to the parallel port
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
outb_p(LP_C,0);
|
WRITE_PORT_UCHAR((PUCHAR)LP_C,0);
|
||||||
for (i=0;i<LP_DELAY;i++);
|
for (i=0;i<LP_DELAY;i++);
|
||||||
outb_p(LP_C,LP_PSELECP | LP_PINITP);
|
WRITE_PORT_UCHAR((PUCHAR)LP_C,LP_PSELECP | LP_PINITP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Parallel_putchar(unsigned char ch)
|
static void Parallel_putchar(unsigned char ch)
|
||||||
/*
|
/*
|
||||||
|
@ -43,7 +42,7 @@ static void Parallel_putchar(unsigned char ch)
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* ch = character to write
|
* ch = character to write
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
|
||||||
int count=0;
|
int count=0;
|
||||||
int status;
|
int status;
|
||||||
|
@ -56,20 +55,21 @@ static void Parallel_putchar(unsigned char ch)
|
||||||
}
|
}
|
||||||
while ( count < 500000 && !(status & LP_PBUSY) );
|
while ( count < 500000 && !(status & LP_PBUSY) );
|
||||||
|
|
||||||
if (count==500000)
|
if (count==500000)
|
||||||
{
|
{
|
||||||
DPRINT("printer_putchar(): timed out\n");
|
DPRINT("printer_putchar(): timed out\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
outb_p(LP_B,ch);
|
WRITE_PORT_UCHAR((PUCHAR)LP_B,ch);
|
||||||
while (wait != 10000) { wait++; }
|
while (wait != 10000) { wait++; }
|
||||||
outb_p(LP_C, (LP_PSELECP | LP_PINITP | LP_PSTROBE ));
|
WRITE_PORT_UCHAR((PUCHAR)LP_C, (LP_PSELECP | LP_PINITP | LP_PSTROBE ));
|
||||||
while (wait) { wait--; }
|
while (wait) { wait--; }
|
||||||
outb_p(LP_C, LP_PSELECP | LP_PINITP);
|
WRITE_PORT_UCHAR((PUCHAR)LP_C, LP_PSELECP | LP_PINITP);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
NTSTATUS STDCALL
|
||||||
|
Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Handles user mode requests
|
* FUNCTION: Handles user mode requests
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -85,7 +85,7 @@ NTSTATUS Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
switch (Stack->MajorFunction)
|
switch (Stack->MajorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MJ_CREATE:
|
case IRP_MJ_CREATE:
|
||||||
DPRINT("(Parallel Port Driver) Creating\n");
|
DPRINT("(Parallel Port Driver) Creating\n");
|
||||||
Parallel_Reset();
|
Parallel_Reset();
|
||||||
status = STATUS_SUCCESS;
|
status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
@ -95,17 +95,17 @@ NTSTATUS Dispatch(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MJ_WRITE:
|
case IRP_MJ_WRITE:
|
||||||
DPRINT("(Parallel Port Driver) Writing %d bytes\n",
|
DPRINT("(Parallel Port Driver) Writing %d bytes\n",
|
||||||
Stack->Parameters.Write.Length);
|
Stack->Parameters.Write.Length);
|
||||||
for (i=0;i<Stack->Parameters.Write.Length;i++)
|
for (i=0;i<Stack->Parameters.Write.Length;i++)
|
||||||
{
|
{
|
||||||
Parallel_putchar(((char *)Irp->UserBuffer)[i]);
|
Parallel_putchar(((char *)Irp->UserBuffer)[i]);
|
||||||
}
|
}
|
||||||
status = STATUS_SUCCESS;
|
status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
status = STATUS_NOT_IMPLEMENTED;
|
status = STATUS_NOT_IMPLEMENTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,33 +127,32 @@ DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
NTSTATUS ret;
|
UNICODE_STRING DeviceName;
|
||||||
ANSI_STRING ansi_device_name;
|
NTSTATUS Status;
|
||||||
UNICODE_STRING device_name;
|
|
||||||
|
|
||||||
DbgPrint("Parallel Port Driver 0.0.1\n");
|
DbgPrint("Parallel Port Driver 0.0.1\n");
|
||||||
|
|
||||||
RtlInitAnsiString (&ansi_device_name, "\\Device\\Parallel");
|
RtlInitUnicodeString (&DeviceName,
|
||||||
RtlAnsiStringToUnicodeString (&device_name, &ansi_device_name, TRUE);
|
L"\\Device\\Parallel");
|
||||||
ret = IoCreateDevice(DriverObject,
|
Status = IoCreateDevice(DriverObject,
|
||||||
0,
|
0,
|
||||||
&device_name,
|
&DeviceName,
|
||||||
FILE_DEVICE_PARALLEL_PORT,
|
FILE_DEVICE_PARALLEL_PORT,
|
||||||
0,
|
0,
|
||||||
FALSE,
|
FALSE,
|
||||||
&DeviceObject);
|
&DeviceObject);
|
||||||
if (ret!=STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(ret);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceObject->Flags=0;
|
DeviceObject->Flags=0;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = Dispatch;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = Dispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = Dispatch;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = Dispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = Dispatch;
|
DriverObject->MajorFunction[IRP_MJ_WRITE] = Dispatch;
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = Dispatch;
|
|
||||||
DriverObject->DriverUnload = NULL;
|
DriverObject->DriverUnload = NULL;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue