📄 parport.h
字号:
// error, ack, not busy
//
#define PAR_POWERED_OFF( Status ) ( \
(IsNotNEC_98) ? \
((Status & PAR_STATUS_NOT_ERROR) ^ PAR_STATUS_NOT_ERROR) && \
((Status & PAR_STATUS_NOT_ACK) ^ PAR_STATUS_NOT_ACK) && \
(Status & PAR_STATUS_NOT_BUSY) : \
\
((Status & PAR_STATUS_NOT_ERROR) ^ PAR_STATUS_NOT_ERROR) && \
(Status & PAR_STATUS_NOT_ACK) && \
(Status & PAR_STATUS_NOT_BUSY) \
)
//
// not error, not busy, not select
//
#define PAR_NOT_CONNECTED( Status ) ( \
(Status & PAR_STATUS_NOT_ERROR) && \
(Status & PAR_STATUS_NOT_BUSY) &&\
!(Status & PAR_STATUS_SLCT) )
//
// not error, not busy
//
#define PAR_OK(Status) ( \
(Status & PAR_STATUS_NOT_ERROR) && \
((Status & PAR_STATUS_PE) ^ PAR_STATUS_PE) && \
(Status & PAR_STATUS_NOT_BUSY) )
//
// busy, select, not error
//
#define PAR_POWERED_ON(Status) ( \
((Status & PAR_STATUS_NOT_BUSY) ^ PAR_STATUS_NOT_BUSY) && \
(Status & PAR_STATUS_SLCT) && \
(Status & PAR_STATUS_NOT_ERROR))
//
// busy, not error
//
#define PAR_BUSY(Status) (\
(( Status & PAR_STATUS_NOT_BUSY) ^ PAR_STATUS_NOT_BUSY) && \
( Status & PAR_STATUS_NOT_ERROR ) )
//
// selected
//
#define PAR_SELECTED(Status) ( \
( Status & PAR_STATUS_SLCT ) )
//
// No cable attached.
//
#define PAR_NO_CABLE(Status) ( \
(IsNotNEC_98) ? \
((Status & PAR_STATUS_NOT_BUSY) ^ PAR_STATUS_NOT_BUSY) && \
(Status & PAR_STATUS_NOT_ACK) && \
(Status & PAR_STATUS_PE) && \
(Status & PAR_STATUS_SLCT) && \
(Status & PAR_STATUS_NOT_ERROR) : \
\
(Status & PAR_STATUS_NOT_BUSY) && \
(Status & PAR_STATUS_NOT_ACK) && \
(Status & PAR_STATUS_PE) && \
(Status & PAR_STATUS_SLCT) && \
(Status & PAR_STATUS_NOT_ERROR) \
)
//
// not error, not busy, selected.
//
#define PAR_ONLINE(Status) ( \
(Status & PAR_STATUS_NOT_ERROR) && \
(Status & PAR_STATUS_NOT_BUSY) && \
((Status & PAR_STATUS_PE) ^ PAR_STATUS_PE) && \
(Status & PAR_STATUS_SLCT) )
//BOOLEAN
//ParCompareGuid(
// IN LPGUID guid1,
// IN LPGUID guid2
// )
//
#define ParCompareGuid(g1, g2) ( \
( (g1) == (g2) ) ? \
TRUE : \
RtlCompareMemory( (g1), (g2), sizeof(GUID) ) == sizeof(GUID) \
)
//VOID StoreData(
// IN PUCHAR RegisterBase,
// IN UCHAR DataByte
// )
// Data must be on line before Strobe = 1;
// Strobe = 1, DIR = 0
// Strobe = 0
//
// We change the port direction to output (and make sure stobe is low).
//
// Note that the data must be available at the port for at least
// .5 microseconds before and after you strobe, and that the strobe
// must be active for at least 500 nano seconds. We are going
// to end up stalling for twice as much time as we need to, but, there
// isn't much we can do about that.
//
// We put the data into the port and wait for 1 micro.
// We strobe the line for at least 1 micro
// We lower the strobe and again delay for 1 micro
// We then revert to the original port direction.
//
// Thanks to Olivetti for advice.
//
#define StoreData(RegisterBase,DataByte) \
{ \
PUCHAR _Address = RegisterBase; \
UCHAR _Control; \
_Control = GetControl(_Address); \
ASSERT(!(_Control & PAR_CONTROL_STROBE)); \
StoreControl( \
_Address, \
(UCHAR)(_Control & ~(PAR_CONTROL_STROBE | PAR_CONTROL_DIR)) \
); \
P5WritePortUchar( \
_Address+PARALLEL_DATA_OFFSET, \
(UCHAR)DataByte \
); \
KeStallExecutionProcessor((ULONG)1); \
StoreControl( \
_Address, \
(UCHAR)((_Control | PAR_CONTROL_STROBE) & ~PAR_CONTROL_DIR) \
); \
KeStallExecutionProcessor((ULONG)1); \
StoreControl( \
_Address, \
(UCHAR)(_Control & ~(PAR_CONTROL_STROBE | PAR_CONTROL_DIR)) \
); \
KeStallExecutionProcessor((ULONG)1); \
StoreControl( \
_Address, \
(UCHAR)_Control \
); \
}
//
// Function prototypes
//
//
// parpnp.c
//
#ifndef STATIC_LOAD
NTSTATUS
ParPnpAddDevice(
IN PDRIVER_OBJECT pDriverObject,
IN PDEVICE_OBJECT pPhysicalDeviceObject
);
NTSTATUS
ParParallelPnp (
IN PDEVICE_OBJECT pDeviceObject,
IN PIRP pIrp
);
NTSTATUS
ParSynchCompletionRoutine(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp,
IN PKEVENT Event
);
BOOLEAN
ParMakeNames(
IN ULONG ParallelPortNumber,
OUT PUNICODE_STRING ClassName,
OUT PUNICODE_STRING LinkName
);
VOID
ParCheckParameters(
IN OUT PPDO_EXTENSION Extension
);
#endif
//
// oldinit.c
//
#ifdef STATIC_LOAD
NTSTATUS
DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
);
BOOLEAN
ParMakeNames(
IN ULONG ParallelPortNumber,
OUT PUNICODE_STRING PortName,
OUT PUNICODE_STRING ClassName,
OUT PUNICODE_STRING LinkName
);
VOID
ParInitializeClassDevice(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath,
IN ULONG ParallelPortNumber
);
VOID
ParCheckParameters(
IN PUNICODE_STRING RegistryPath,
IN OUT PPDO_EXTENSION Extension
);
#endif
//
// parclass.c
//
VOID
ParLogError(
IN PDRIVER_OBJECT DriverObject,
IN PDEVICE_OBJECT DeviceObject OPTIONAL,
IN PHYSICAL_ADDRESS P1,
IN PHYSICAL_ADDRESS P2,
IN ULONG SequenceNumber,
IN UCHAR MajorFunctionCode,
IN UCHAR RetryCount,
IN ULONG UniqueErrorValue,
IN NTSTATUS FinalStatus,
IN NTSTATUS SpecificIOStatus
);
NTSTATUS
ParCreateOpen(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParClose(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParCleanup(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
PptPdoReadWrite(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParInternalDeviceControl(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParQueryInformationFile(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParSetInformationFile(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
);
NTSTATUS
ParExportedNegotiateIeeeMode(
IN PPDO_EXTENSION Extension,
IN USHORT ModeMaskFwd,
IN USHORT ModeMaskRev,
IN PARALLEL_SAFETY ModeSafety,
IN BOOLEAN IsForward
);
NTSTATUS
ParExportedTerminateIeeeMode(
IN PPDO_EXTENSION Extension
);
//////////////////////////////////////////////////////////////////
// Modes of operation
//////////////////////////////////////////////////////////////////
//
// spp.c
//
NTSTATUS
ParEnterSppMode(
IN PPDO_EXTENSION Extension,
IN BOOLEAN DeviceIdRequest
);
ULONG
SppWriteLoopPI(
IN PUCHAR Controller,
IN PUCHAR WriteBuffer,
IN ULONG NumBytesToWrite,
IN ULONG BusyDelay
);
ULONG
SppCheckBusyDelay(
IN PPDO_EXTENSION Extension,
IN PUCHAR WriteBuffer,
IN ULONG NumBytesToWrite
);
NTSTATUS
SppWrite(
IN PPDO_EXTENSION Extension,
IN PVOID Buffer,
IN ULONG BytesToWrite,
OUT PULONG BytesTransferred
);
VOID
ParTerminateSppMode(
IN PPDO_EXTENSION Extension
);
NTSTATUS
SppQueryDeviceId(
IN PPDO_EXTENSION Extension,
OUT PCHAR DeviceIdBuffer,
IN ULONG BufferSize,
OUT PULONG DeviceIdSize,
IN BOOLEAN bReturnRawString
);
//
// sppieee.c
//
NTSTATUS
SppIeeeWrite(
IN PPDO_EXTENSION Extension,
IN PVOID Buffer,
IN ULONG BytesToWrite,
OUT PULONG BytesTransferred
);
//
// nibble.c
//
BOOLEAN
ParIsChannelizedNibbleSupported(
IN PPDO_EXTENSION Extension
);
BOOLEAN
ParIsNibbleSupported(
IN PPDO_EXTENSION Extension
);
NTSTATUS
ParEnterNibbleMode(
IN PPDO_EXTENSION Extension,
IN BOOLEAN DeviceIdRequest
);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -