mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[ISAPNP] Reformat files. No code change.
This commit is contained in:
parent
a8dbe6805a
commit
947b49aac3
6 changed files with 725 additions and 688 deletions
|
@ -13,156 +13,156 @@
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoStartDevice(
|
IsaFdoStartDevice(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(Irp);
|
UNREFERENCED_PARAMETER(Irp);
|
||||||
UNREFERENCED_PARAMETER(IrpSp);
|
UNREFERENCED_PARAMETER(IrpSp);
|
||||||
|
|
||||||
KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
|
KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
|
||||||
Status = IsaHwDetectReadDataPort(FdoExt);
|
Status = IsaHwDetectReadDataPort(FdoExt);
|
||||||
KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
|
KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
FdoExt->Common.State = dsStarted;
|
FdoExt->Common.State = dsStarted;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoQueryDeviceRelations(
|
IsaFdoQueryDeviceRelations(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PISAPNP_PDO_EXTENSION PdoExt;
|
PISAPNP_PDO_EXTENSION PdoExt;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PLIST_ENTRY CurrentEntry;
|
PLIST_ENTRY CurrentEntry;
|
||||||
PISAPNP_LOGICAL_DEVICE IsaDevice;
|
PISAPNP_LOGICAL_DEVICE IsaDevice;
|
||||||
PDEVICE_RELATIONS DeviceRelations;
|
PDEVICE_RELATIONS DeviceRelations;
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
ULONG i = 0;
|
ULONG i = 0;
|
||||||
|
|
||||||
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
||||||
return Irp->IoStatus.Status;
|
return Irp->IoStatus.Status;
|
||||||
|
|
||||||
KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
|
KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
|
||||||
Status = IsaHwFillDeviceList(FdoExt);
|
Status = IsaHwFillDeviceList(FdoExt);
|
||||||
KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
|
KeReleaseSpinLock(&FdoExt->Lock, OldIrql);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceRelations = ExAllocatePool(NonPagedPool,
|
DeviceRelations = ExAllocatePool(NonPagedPool,
|
||||||
sizeof(DEVICE_RELATIONS) + sizeof(DEVICE_OBJECT) * (FdoExt->DeviceCount - 1));
|
sizeof(DEVICE_RELATIONS) + sizeof(DEVICE_OBJECT) * (FdoExt->DeviceCount - 1));
|
||||||
if (!DeviceRelations)
|
if (!DeviceRelations)
|
||||||
{
|
{
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentEntry = FdoExt->DeviceListHead.Flink;
|
CurrentEntry = FdoExt->DeviceListHead.Flink;
|
||||||
while (CurrentEntry != &FdoExt->DeviceListHead)
|
while (CurrentEntry != &FdoExt->DeviceListHead)
|
||||||
{
|
{
|
||||||
IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, ListEntry);
|
IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, ListEntry);
|
||||||
|
|
||||||
if (!IsaDevice->Pdo)
|
if (!IsaDevice->Pdo)
|
||||||
{
|
{
|
||||||
Status = IoCreateDevice(FdoExt->DriverObject,
|
Status = IoCreateDevice(FdoExt->DriverObject,
|
||||||
sizeof(ISAPNP_PDO_EXTENSION),
|
sizeof(ISAPNP_PDO_EXTENSION),
|
||||||
NULL,
|
NULL,
|
||||||
FILE_DEVICE_CONTROLLER,
|
FILE_DEVICE_CONTROLLER,
|
||||||
FILE_DEVICE_SECURE_OPEN | FILE_AUTOGENERATED_DEVICE_NAME,
|
FILE_DEVICE_SECURE_OPEN | FILE_AUTOGENERATED_DEVICE_NAME,
|
||||||
FALSE,
|
FALSE,
|
||||||
&IsaDevice->Pdo);
|
&IsaDevice->Pdo);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsaDevice->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
IsaDevice->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
|
|
||||||
//Device->Pdo->Flags |= DO_POWER_PAGABLE;
|
//Device->Pdo->Flags |= DO_POWER_PAGABLE;
|
||||||
|
|
||||||
PdoExt = (PISAPNP_PDO_EXTENSION)IsaDevice->Pdo->DeviceExtension;
|
PdoExt = (PISAPNP_PDO_EXTENSION)IsaDevice->Pdo->DeviceExtension;
|
||||||
|
|
||||||
RtlZeroMemory(PdoExt, sizeof(ISAPNP_PDO_EXTENSION));
|
RtlZeroMemory(PdoExt, sizeof(ISAPNP_PDO_EXTENSION));
|
||||||
|
|
||||||
PdoExt->Common.IsFdo = FALSE;
|
PdoExt->Common.IsFdo = FALSE;
|
||||||
PdoExt->Common.Self = IsaDevice->Pdo;
|
PdoExt->Common.Self = IsaDevice->Pdo;
|
||||||
PdoExt->Common.State = dsStopped;
|
PdoExt->Common.State = dsStopped;
|
||||||
PdoExt->IsaPnpDevice = IsaDevice;
|
PdoExt->IsaPnpDevice = IsaDevice;
|
||||||
}
|
}
|
||||||
DeviceRelations->Objects[i++] = IsaDevice->Pdo;
|
DeviceRelations->Objects[i++] = IsaDevice->Pdo;
|
||||||
|
|
||||||
ObReferenceObject(IsaDevice->Pdo);
|
ObReferenceObject(IsaDevice->Pdo);
|
||||||
|
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceRelations->Count = FdoExt->DeviceCount;
|
DeviceRelations->Count = FdoExt->DeviceCount;
|
||||||
|
|
||||||
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
|
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoPnp(
|
IsaFdoPnp(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = Irp->IoStatus.Status;
|
NTSTATUS Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
Status = IsaForwardIrpSynchronous(FdoExt, Irp);
|
Status = IsaForwardIrpSynchronous(FdoExt, Irp);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
Status = IsaFdoStartDevice(FdoExt, Irp, IrpSp);
|
Status = IsaFdoStartDevice(FdoExt, Irp, IrpSp);
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
case IRP_MN_STOP_DEVICE:
|
case IRP_MN_STOP_DEVICE:
|
||||||
FdoExt->Common.State = dsStopped;
|
FdoExt->Common.State = dsStopped;
|
||||||
|
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||||
Status = IsaFdoQueryDeviceRelations(FdoExt, Irp, IrpSp);
|
Status = IsaFdoQueryDeviceRelations(FdoExt, Irp, IrpSp);
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
case IRP_MN_FILTER_RESOURCE_REQUIREMENTS:
|
||||||
DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
|
DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
|
DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
IoSkipCurrentIrpStackLocation(Irp);
|
IoSkipCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
return IoCallDriver(FdoExt->Ldo, Irp);
|
return IoCallDriver(FdoExt->Ldo, Irp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,60 +14,70 @@
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteAddress(USHORT Address)
|
WriteAddress(
|
||||||
|
IN USHORT Address)
|
||||||
{
|
{
|
||||||
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_ADDRESS, Address);
|
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_ADDRESS, Address);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteData(USHORT Data)
|
WriteData(
|
||||||
|
IN USHORT Data)
|
||||||
{
|
{
|
||||||
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_WRITE_DATA, Data);
|
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_WRITE_DATA, Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
UCHAR
|
UCHAR
|
||||||
ReadData(PUCHAR ReadDataPort)
|
ReadData(
|
||||||
|
IN PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return READ_PORT_UCHAR(ReadDataPort);
|
return READ_PORT_UCHAR(ReadDataPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteByte(USHORT Address, USHORT Value)
|
WriteByte(
|
||||||
|
IN USHORT Address,
|
||||||
|
IN USHORT Value)
|
||||||
{
|
{
|
||||||
WriteAddress(Address);
|
WriteAddress(Address);
|
||||||
WriteData(Value);
|
WriteData(Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
UCHAR
|
UCHAR
|
||||||
ReadByte(PUCHAR ReadDataPort, USHORT Address)
|
ReadByte(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN USHORT Address)
|
||||||
{
|
{
|
||||||
WriteAddress(Address);
|
WriteAddress(Address);
|
||||||
return ReadData(ReadDataPort);
|
return ReadData(ReadDataPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadWord(PUCHAR ReadDataPort, USHORT Address)
|
ReadWord(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN USHORT Address)
|
||||||
{
|
{
|
||||||
return ((ReadByte(ReadDataPort, Address) << 8) |
|
return ((ReadByte(ReadDataPort, Address) << 8) |
|
||||||
(ReadByte(ReadDataPort, Address + 1)));
|
(ReadByte(ReadDataPort, Address + 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
SetReadDataPort(PUCHAR ReadDataPort)
|
SetReadDataPort(
|
||||||
|
IN PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_READPORT, ((ULONG_PTR)ReadDataPort >> 2));
|
WriteByte(ISAPNP_READPORT, ((ULONG_PTR)ReadDataPort >> 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -75,7 +85,7 @@ inline
|
||||||
VOID
|
VOID
|
||||||
EnterIsolationState(VOID)
|
EnterIsolationState(VOID)
|
||||||
{
|
{
|
||||||
WriteAddress(ISAPNP_SERIALISOLATION);
|
WriteAddress(ISAPNP_SERIALISOLATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -83,7 +93,7 @@ inline
|
||||||
VOID
|
VOID
|
||||||
WaitForKey(VOID)
|
WaitForKey(VOID)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_CONFIGCONTROL, ISAPNP_CONFIG_WAIT_FOR_KEY);
|
WriteByte(ISAPNP_CONFIGCONTROL, ISAPNP_CONFIG_WAIT_FOR_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -91,81 +101,92 @@ inline
|
||||||
VOID
|
VOID
|
||||||
ResetCsn(VOID)
|
ResetCsn(VOID)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_CONFIGCONTROL, ISAPNP_CONFIG_RESET_CSN);
|
WriteByte(ISAPNP_CONFIGCONTROL, ISAPNP_CONFIG_RESET_CSN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
Wake(USHORT Csn)
|
Wake(
|
||||||
|
IN USHORT Csn)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_WAKE, Csn);
|
WriteByte(ISAPNP_WAKE, Csn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadResourceData(PUCHAR ReadDataPort)
|
ReadResourceData(
|
||||||
|
IN PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
|
return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadStatus(PUCHAR ReadDataPort)
|
ReadStatus(
|
||||||
|
IN PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_STATUS);
|
return ReadByte(ReadDataPort, ISAPNP_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteCsn(USHORT Csn)
|
WriteCsn(
|
||||||
|
IN USHORT Csn)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_CARDSELECTNUMBER, Csn);
|
WriteByte(ISAPNP_CARDSELECTNUMBER, Csn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteLogicalDeviceNumber(USHORT LogDev)
|
WriteLogicalDeviceNumber(
|
||||||
|
IN USHORT LogDev)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_LOGICALDEVICENUMBER, LogDev);
|
WriteByte(ISAPNP_LOGICALDEVICENUMBER, LogDev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
ActivateDevice(USHORT LogDev)
|
ActivateDevice(
|
||||||
|
IN USHORT LogDev)
|
||||||
{
|
{
|
||||||
WriteLogicalDeviceNumber(LogDev);
|
WriteLogicalDeviceNumber(LogDev);
|
||||||
WriteByte(ISAPNP_ACTIVATE, 1);
|
WriteByte(ISAPNP_ACTIVATE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
DeactivateDevice(USHORT LogDev)
|
DeactivateDevice(
|
||||||
|
IN USHORT LogDev)
|
||||||
{
|
{
|
||||||
WriteLogicalDeviceNumber(LogDev);
|
WriteLogicalDeviceNumber(LogDev);
|
||||||
WriteByte(ISAPNP_ACTIVATE, 0);
|
WriteByte(ISAPNP_ACTIVATE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadIoBase(PUCHAR ReadDataPort, USHORT Index)
|
ReadIoBase(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN USHORT Index)
|
||||||
{
|
{
|
||||||
return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
|
return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadIrqNo(PUCHAR ReadDataPort, USHORT Index)
|
ReadIrqNo(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN USHORT Index)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index));
|
return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -173,348 +194,365 @@ inline
|
||||||
VOID
|
VOID
|
||||||
HwDelay(VOID)
|
HwDelay(VOID)
|
||||||
{
|
{
|
||||||
KeStallExecutionProcessor(1000);
|
KeStallExecutionProcessor(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
inline
|
inline
|
||||||
UCHAR
|
UCHAR
|
||||||
NextLFSR(UCHAR Lfsr, UCHAR InputBit)
|
NextLFSR(
|
||||||
|
IN UCHAR Lfsr,
|
||||||
|
IN UCHAR InputBit)
|
||||||
{
|
{
|
||||||
UCHAR NextLfsr = Lfsr >> 1;
|
UCHAR NextLfsr = Lfsr >> 1;
|
||||||
|
|
||||||
NextLfsr |= (((Lfsr ^ NextLfsr) ^ InputBit)) << 7;
|
NextLfsr |= (((Lfsr ^ NextLfsr) ^ InputBit)) << 7;
|
||||||
|
|
||||||
return NextLfsr;
|
return NextLfsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
SendKey(VOID)
|
SendKey(VOID)
|
||||||
{
|
{
|
||||||
UCHAR i, Lfsr;
|
UCHAR i, Lfsr;
|
||||||
|
|
||||||
HwDelay();
|
HwDelay();
|
||||||
WriteAddress(0x00);
|
WriteAddress(0x00);
|
||||||
WriteAddress(0x00);
|
WriteAddress(0x00);
|
||||||
|
|
||||||
Lfsr = ISAPNP_LFSR_SEED;
|
Lfsr = ISAPNP_LFSR_SEED;
|
||||||
for (i = 0; i < 32; i++)
|
for (i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
WriteAddress(Lfsr);
|
WriteAddress(Lfsr);
|
||||||
Lfsr = NextLFSR(Lfsr, 0);
|
Lfsr = NextLFSR(Lfsr, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
USHORT
|
USHORT
|
||||||
PeekByte(PUCHAR ReadDataPort)
|
PeekByte(
|
||||||
|
IN PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
if (ReadStatus(ReadDataPort) & 0x01)
|
if (ReadStatus(ReadDataPort) & 0x01)
|
||||||
return ReadResourceData(ReadDataPort);
|
return ReadResourceData(ReadDataPort);
|
||||||
|
|
||||||
HwDelay();
|
HwDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
Peek(PUCHAR ReadDataPort, PVOID Buffer, ULONG Length)
|
Peek(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN OUT PVOID Buffer,
|
||||||
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
USHORT i, byte;
|
USHORT i, Byte;
|
||||||
|
|
||||||
for (i = 0; i < Length; i++)
|
for (i = 0; i < Length; i++)
|
||||||
{
|
{
|
||||||
byte = PeekByte(ReadDataPort);
|
Byte = PeekByte(ReadDataPort);
|
||||||
if (Buffer)
|
if (Buffer)
|
||||||
*((PUCHAR)Buffer + i) = byte;
|
*((PUCHAR)Buffer + i) = Byte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
USHORT
|
USHORT
|
||||||
IsaPnpChecksum(PISAPNP_IDENTIFIER Identifier)
|
IsaPnpChecksum(
|
||||||
|
IN PISAPNP_IDENTIFIER Identifier)
|
||||||
{
|
{
|
||||||
UCHAR i, j, Lfsr, Byte;
|
UCHAR i, j, Lfsr, Byte;
|
||||||
|
|
||||||
Lfsr = ISAPNP_LFSR_SEED;
|
Lfsr = ISAPNP_LFSR_SEED;
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
|
||||||
Byte = *(((PUCHAR)Identifier) + i);
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
{
|
{
|
||||||
Lfsr = NextLFSR(Lfsr, Byte);
|
Byte = *(((PUCHAR)Identifier) + i);
|
||||||
Byte >>= 1;
|
for (j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
Lfsr = NextLFSR(Lfsr, Byte);
|
||||||
|
Byte >>= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return Lfsr;
|
return Lfsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
FindTag(PUCHAR ReadDataPort, USHORT WantedTag, PVOID Buffer, ULONG Length)
|
FindTag(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN USHORT WantedTag,
|
||||||
|
IN OUT PVOID Buffer,
|
||||||
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
USHORT Tag, TagLen;
|
USHORT Tag, TagLen;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
|
||||||
Tag = PeekByte(ReadDataPort);
|
|
||||||
if (ISAPNP_IS_SMALL_TAG(Tag))
|
|
||||||
{
|
{
|
||||||
TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
|
Tag = PeekByte(ReadDataPort);
|
||||||
Tag = ISAPNP_SMALL_TAG_NAME(Tag);
|
if (ISAPNP_IS_SMALL_TAG(Tag))
|
||||||
}
|
{
|
||||||
else
|
TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
|
||||||
{
|
Tag = ISAPNP_SMALL_TAG_NAME(Tag);
|
||||||
TagLen = PeekByte(ReadDataPort) + (PeekByte(ReadDataPort) << 8);
|
}
|
||||||
Tag = ISAPNP_LARGE_TAG_NAME(Tag);
|
else
|
||||||
}
|
{
|
||||||
|
TagLen = PeekByte(ReadDataPort) + (PeekByte(ReadDataPort) << 8);
|
||||||
|
Tag = ISAPNP_LARGE_TAG_NAME(Tag);
|
||||||
|
}
|
||||||
|
|
||||||
if (Tag == WantedTag)
|
if (Tag == WantedTag)
|
||||||
{
|
{
|
||||||
if (Length > TagLen)
|
if (Length > TagLen)
|
||||||
Length = TagLen;
|
Length = TagLen;
|
||||||
|
|
||||||
Peek(ReadDataPort, Buffer, Length);
|
Peek(ReadDataPort, Buffer, Length);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Peek(ReadDataPort, NULL, TagLen);
|
Peek(ReadDataPort, NULL, TagLen);
|
||||||
}
|
}
|
||||||
} while (Tag != ISAPNP_TAG_END);
|
} while (Tag != ISAPNP_TAG_END);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
FindLogDevId(PUCHAR ReadDataPort, USHORT LogDev, PISAPNP_LOGDEVID LogDeviceId)
|
FindLogDevId(
|
||||||
|
IN PUCHAR ReadDataPort,
|
||||||
|
IN USHORT LogDev,
|
||||||
|
IN OUT PISAPNP_LOGDEVID LogDeviceId)
|
||||||
{
|
{
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
for (i = 0; i <= LogDev; i++)
|
for (i = 0; i <= LogDev; i++)
|
||||||
{
|
{
|
||||||
if (!FindTag(ReadDataPort, ISAPNP_TAG_LOGDEVID, LogDeviceId, sizeof(*LogDeviceId)))
|
if (!FindTag(ReadDataPort, ISAPNP_TAG_LOGDEVID, LogDeviceId, sizeof(*LogDeviceId)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
INT
|
INT
|
||||||
TryIsolate(PUCHAR ReadDataPort)
|
TryIsolate(
|
||||||
|
IN PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
ISAPNP_IDENTIFIER Identifier;
|
ISAPNP_IDENTIFIER Identifier;
|
||||||
USHORT i, j;
|
USHORT i, j;
|
||||||
BOOLEAN Seen55aa, SeenLife;
|
BOOLEAN Seen55aa, SeenLife;
|
||||||
INT Csn = 0;
|
INT Csn = 0;
|
||||||
USHORT Byte, Data;
|
USHORT Byte, Data;
|
||||||
|
|
||||||
DPRINT("Setting read data port: 0x%p\n", ReadDataPort);
|
DPRINT("Setting read data port: 0x%p\n", ReadDataPort);
|
||||||
|
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
SendKey();
|
SendKey();
|
||||||
|
|
||||||
ResetCsn();
|
ResetCsn();
|
||||||
HwDelay();
|
HwDelay();
|
||||||
HwDelay();
|
|
||||||
|
|
||||||
WaitForKey();
|
|
||||||
SendKey();
|
|
||||||
Wake(0x00);
|
|
||||||
|
|
||||||
SetReadDataPort(ReadDataPort);
|
|
||||||
HwDelay();
|
|
||||||
|
|
||||||
while (TRUE)
|
|
||||||
{
|
|
||||||
EnterIsolationState();
|
|
||||||
HwDelay();
|
|
||||||
|
|
||||||
RtlZeroMemory(&Identifier, sizeof(Identifier));
|
|
||||||
|
|
||||||
Seen55aa = SeenLife = FALSE;
|
|
||||||
for (i = 0; i < 9; i++)
|
|
||||||
{
|
|
||||||
Byte = 0;
|
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
Data = ReadData(ReadDataPort);
|
|
||||||
HwDelay();
|
|
||||||
Data = ((Data << 8) | ReadData(ReadDataPort));
|
|
||||||
HwDelay();
|
|
||||||
Byte >>= 1;
|
|
||||||
|
|
||||||
if (Data != 0xFFFF)
|
|
||||||
{
|
|
||||||
SeenLife = TRUE;
|
|
||||||
if (Data == 0x55AA)
|
|
||||||
{
|
|
||||||
Byte |= 0x80;
|
|
||||||
Seen55aa = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*(((PUCHAR)&Identifier) + i) = Byte;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Seen55aa)
|
|
||||||
{
|
|
||||||
if (Csn)
|
|
||||||
{
|
|
||||||
DPRINT("Found no more cards\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SeenLife)
|
|
||||||
{
|
|
||||||
DPRINT("Saw life but no cards, trying new read port\n");
|
|
||||||
Csn = -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINT("Saw no sign of life, abandoning isolation\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Identifier.Checksum != IsaPnpChecksum(&Identifier))
|
|
||||||
{
|
|
||||||
DPRINT("Bad checksum, trying next read data port\n");
|
|
||||||
Csn = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Csn++;
|
|
||||||
|
|
||||||
WriteCsn(Csn);
|
|
||||||
HwDelay();
|
HwDelay();
|
||||||
|
|
||||||
|
WaitForKey();
|
||||||
|
SendKey();
|
||||||
Wake(0x00);
|
Wake(0x00);
|
||||||
|
|
||||||
|
SetReadDataPort(ReadDataPort);
|
||||||
HwDelay();
|
HwDelay();
|
||||||
}
|
|
||||||
|
|
||||||
WaitForKey();
|
while (TRUE)
|
||||||
|
{
|
||||||
|
EnterIsolationState();
|
||||||
|
HwDelay();
|
||||||
|
|
||||||
if (Csn > 0)
|
RtlZeroMemory(&Identifier, sizeof(Identifier));
|
||||||
{
|
|
||||||
DPRINT("Found %d cards at read port 0x%p\n", Csn, ReadDataPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Csn;
|
Seen55aa = SeenLife = FALSE;
|
||||||
|
for (i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
Byte = 0;
|
||||||
|
for (j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
Data = ReadData(ReadDataPort);
|
||||||
|
HwDelay();
|
||||||
|
Data = ((Data << 8) | ReadData(ReadDataPort));
|
||||||
|
HwDelay();
|
||||||
|
Byte >>= 1;
|
||||||
|
|
||||||
|
if (Data != 0xFFFF)
|
||||||
|
{
|
||||||
|
SeenLife = TRUE;
|
||||||
|
if (Data == 0x55AA)
|
||||||
|
{
|
||||||
|
Byte |= 0x80;
|
||||||
|
Seen55aa = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*(((PUCHAR)&Identifier) + i) = Byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Seen55aa)
|
||||||
|
{
|
||||||
|
if (Csn)
|
||||||
|
{
|
||||||
|
DPRINT("Found no more cards\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (SeenLife)
|
||||||
|
{
|
||||||
|
DPRINT("Saw life but no cards, trying new read port\n");
|
||||||
|
Csn = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT("Saw no sign of life, abandoning isolation\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Identifier.Checksum != IsaPnpChecksum(&Identifier))
|
||||||
|
{
|
||||||
|
DPRINT("Bad checksum, trying next read data port\n");
|
||||||
|
Csn = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Csn++;
|
||||||
|
|
||||||
|
WriteCsn(Csn);
|
||||||
|
HwDelay();
|
||||||
|
|
||||||
|
Wake(0x00);
|
||||||
|
HwDelay();
|
||||||
|
}
|
||||||
|
|
||||||
|
WaitForKey();
|
||||||
|
|
||||||
|
if (Csn > 0)
|
||||||
|
{
|
||||||
|
DPRINT("Found %d cards at read port 0x%p\n", Csn, ReadDataPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Csn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
PUCHAR
|
PUCHAR
|
||||||
Isolate(VOID)
|
Isolate(VOID)
|
||||||
{
|
{
|
||||||
PUCHAR ReadPort;
|
PUCHAR ReadPort;
|
||||||
|
|
||||||
for (ReadPort = (PUCHAR)ISAPNP_READ_PORT_START;
|
for (ReadPort = (PUCHAR)ISAPNP_READ_PORT_START;
|
||||||
(ULONG_PTR)ReadPort <= ISAPNP_READ_PORT_MAX;
|
(ULONG_PTR)ReadPort <= ISAPNP_READ_PORT_MAX;
|
||||||
ReadPort += ISAPNP_READ_PORT_STEP)
|
ReadPort += ISAPNP_READ_PORT_STEP)
|
||||||
{
|
{
|
||||||
/* Avoid the NE2000 probe space */
|
/* Avoid the NE2000 probe space */
|
||||||
if ((ULONG_PTR)ReadPort >= 0x280 &&
|
if ((ULONG_PTR)ReadPort >= 0x280 &&
|
||||||
(ULONG_PTR)ReadPort <= 0x380)
|
(ULONG_PTR)ReadPort <= 0x380)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (TryIsolate(ReadPort) > 0)
|
if (TryIsolate(ReadPort) > 0)
|
||||||
return ReadPort;
|
return ReadPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DeviceActivation(PISAPNP_LOGICAL_DEVICE IsaDevice,
|
DeviceActivation(
|
||||||
BOOLEAN Activate)
|
IN PISAPNP_LOGICAL_DEVICE IsaDevice,
|
||||||
|
IN BOOLEAN Activate)
|
||||||
{
|
{
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
SendKey();
|
SendKey();
|
||||||
Wake(IsaDevice->CSN);
|
Wake(IsaDevice->CSN);
|
||||||
|
|
||||||
if (Activate)
|
if (Activate)
|
||||||
ActivateDevice(IsaDevice->LDN);
|
ActivateDevice(IsaDevice->LDN);
|
||||||
else
|
else
|
||||||
DeactivateDevice(IsaDevice->LDN);
|
DeactivateDevice(IsaDevice->LDN);
|
||||||
|
|
||||||
HwDelay();
|
HwDelay();
|
||||||
|
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
ProbeIsaPnpBus(PISAPNP_FDO_EXTENSION FdoExt)
|
ProbeIsaPnpBus(
|
||||||
|
IN PISAPNP_FDO_EXTENSION FdoExt)
|
||||||
{
|
{
|
||||||
PISAPNP_LOGICAL_DEVICE LogDevice;
|
PISAPNP_LOGICAL_DEVICE LogDevice;
|
||||||
ISAPNP_IDENTIFIER Identifier;
|
ISAPNP_IDENTIFIER Identifier;
|
||||||
ISAPNP_LOGDEVID LogDevId;
|
ISAPNP_LOGDEVID LogDevId;
|
||||||
USHORT Csn;
|
USHORT Csn;
|
||||||
USHORT LogDev;
|
USHORT LogDev;
|
||||||
|
|
||||||
ASSERT(FdoExt->ReadDataPort);
|
ASSERT(FdoExt->ReadDataPort);
|
||||||
|
|
||||||
for (Csn = 1; Csn <= 0xFF; Csn++)
|
for (Csn = 1; Csn <= 0xFF; Csn++)
|
||||||
{
|
|
||||||
for (LogDev = 0; LogDev <= 0xFF; LogDev++)
|
|
||||||
{
|
{
|
||||||
LogDevice = ExAllocatePool(NonPagedPool, sizeof(ISAPNP_LOGICAL_DEVICE));
|
for (LogDev = 0; LogDev <= 0xFF; LogDev++)
|
||||||
if (!LogDevice)
|
{
|
||||||
return STATUS_NO_MEMORY;
|
LogDevice = ExAllocatePool(NonPagedPool, sizeof(ISAPNP_LOGICAL_DEVICE));
|
||||||
|
if (!LogDevice)
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
|
||||||
RtlZeroMemory(LogDevice, sizeof(ISAPNP_LOGICAL_DEVICE));
|
RtlZeroMemory(LogDevice, sizeof(ISAPNP_LOGICAL_DEVICE));
|
||||||
|
|
||||||
LogDevice->CSN = Csn;
|
LogDevice->CSN = Csn;
|
||||||
LogDevice->LDN = LogDev;
|
LogDevice->LDN = LogDev;
|
||||||
|
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
SendKey();
|
SendKey();
|
||||||
Wake(Csn);
|
Wake(Csn);
|
||||||
|
|
||||||
Peek(FdoExt->ReadDataPort, &Identifier, sizeof(Identifier));
|
Peek(FdoExt->ReadDataPort, &Identifier, sizeof(Identifier));
|
||||||
|
|
||||||
if (Identifier.VendorId & 0x80)
|
if (Identifier.VendorId & 0x80)
|
||||||
{
|
{
|
||||||
ExFreePool(LogDevice);
|
ExFreePool(LogDevice);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FindLogDevId(FdoExt->ReadDataPort, LogDev, &LogDevId))
|
if (!FindLogDevId(FdoExt->ReadDataPort, LogDev, &LogDevId))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
WriteLogicalDeviceNumber(LogDev);
|
WriteLogicalDeviceNumber(LogDev);
|
||||||
|
|
||||||
LogDevice->VendorId[0] = ((LogDevId.VendorId >> 2) & 0x1f) + 'A' - 1,
|
LogDevice->VendorId[0] = ((LogDevId.VendorId >> 2) & 0x1f) + 'A' - 1,
|
||||||
LogDevice->VendorId[1] = (((LogDevId.VendorId & 0x3) << 3) | ((LogDevId.VendorId >> 13) & 0x7)) + 'A' - 1,
|
LogDevice->VendorId[1] = (((LogDevId.VendorId & 0x3) << 3) | ((LogDevId.VendorId >> 13) & 0x7)) + 'A' - 1,
|
||||||
LogDevice->VendorId[2] = ((LogDevId.VendorId >> 8) & 0x1f) + 'A' - 1,
|
LogDevice->VendorId[2] = ((LogDevId.VendorId >> 8) & 0x1f) + 'A' - 1,
|
||||||
LogDevice->ProdId = RtlUshortByteSwap(LogDevId.ProdId);
|
LogDevice->ProdId = RtlUshortByteSwap(LogDevId.ProdId);
|
||||||
LogDevice->SerialNumber = Identifier.Serial;
|
LogDevice->SerialNumber = Identifier.Serial;
|
||||||
LogDevice->IoAddr = ReadIoBase(FdoExt->ReadDataPort, 0);
|
LogDevice->IoAddr = ReadIoBase(FdoExt->ReadDataPort, 0);
|
||||||
LogDevice->IrqNo = ReadIrqNo(FdoExt->ReadDataPort, 0);
|
LogDevice->IrqNo = ReadIrqNo(FdoExt->ReadDataPort, 0);
|
||||||
|
|
||||||
DPRINT1("Detected ISA PnP device - VID: '%3s' PID: 0x%x SN: 0x%08x IoBase: 0x%x IRQ:0x%x\n",
|
DPRINT1("Detected ISA PnP device - VID: '%3s' PID: 0x%x SN: 0x%08x IoBase: 0x%x IRQ:0x%x\n",
|
||||||
LogDevice->VendorId, LogDevice->ProdId, LogDevice->SerialNumber, LogDevice->IoAddr, LogDevice->IrqNo);
|
LogDevice->VendorId, LogDevice->ProdId, LogDevice->SerialNumber, LogDevice->IoAddr, LogDevice->IrqNo);
|
||||||
|
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
|
|
||||||
InsertTailList(&FdoExt->DeviceListHead, &LogDevice->ListEntry);
|
InsertTailList(&FdoExt->DeviceListHead, &LogDevice->ListEntry);
|
||||||
FdoExt->DeviceCount++;
|
FdoExt->DeviceCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -522,16 +560,16 @@ NTAPI
|
||||||
IsaHwDetectReadDataPort(
|
IsaHwDetectReadDataPort(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt)
|
IN PISAPNP_FDO_EXTENSION FdoExt)
|
||||||
{
|
{
|
||||||
FdoExt->ReadDataPort = Isolate();
|
FdoExt->ReadDataPort = Isolate();
|
||||||
if (!FdoExt->ReadDataPort)
|
if (!FdoExt->ReadDataPort)
|
||||||
{
|
{
|
||||||
DPRINT1("No read data port found\n");
|
DPRINT1("No read data port found\n");
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("Detected read data port at 0x%p\n", FdoExt->ReadDataPort);
|
DPRINT1("Detected read data port at 0x%p\n", FdoExt->ReadDataPort);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -548,18 +586,18 @@ IsaHwActivateDevice(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwDeactivateDevice(
|
IsaHwDeactivateDevice(
|
||||||
IN PISAPNP_LOGICAL_DEVICE LogicalDevice)
|
IN PISAPNP_LOGICAL_DEVICE LogicalDevice)
|
||||||
{
|
{
|
||||||
DeviceActivation(LogicalDevice,
|
DeviceActivation(LogicalDevice,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwFillDeviceList(
|
IsaHwFillDeviceList(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt)
|
IN PISAPNP_FDO_EXTENSION FdoExt)
|
||||||
{
|
{
|
||||||
return ProbeIsaPnpBus(FdoExt);
|
return ProbeIsaPnpBus(FdoExt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,42 +16,41 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
ForwardIrpCompletion(
|
ForwardIrpCompletion(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PVOID Context)
|
IN PVOID Context)
|
||||||
{
|
{
|
||||||
|
UNREFERENCED_PARAMETER(DeviceObject);
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(DeviceObject);
|
if (Irp->PendingReturned)
|
||||||
|
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
||||||
|
|
||||||
if (Irp->PendingReturned)
|
return STATUS_MORE_PROCESSING_REQUIRED;
|
||||||
KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
|
|
||||||
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaForwardIrpSynchronous(
|
IsaForwardIrpSynchronous(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||||
IoCopyCurrentIrpStackLocationToNext(Irp);
|
IoCopyCurrentIrpStackLocationToNext(Irp);
|
||||||
|
|
||||||
IoSetCompletionRoutine(Irp, ForwardIrpCompletion, &Event, TRUE, TRUE, TRUE);
|
IoSetCompletionRoutine(Irp, ForwardIrpCompletion, &Event, TRUE, TRUE, TRUE);
|
||||||
|
|
||||||
Status = IoCallDriver(FdoExt->Ldo, Irp);
|
Status = IoCallDriver(FdoExt->Ldo, Irp);
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
Status = KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH IsaCreateClose;
|
static DRIVER_DISPATCH IsaCreateClose;
|
||||||
|
@ -60,17 +59,17 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaCreateClose(
|
IsaCreateClose(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = FILE_OPENED;
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
|
|
||||||
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH IsaIoctl;
|
static DRIVER_DISPATCH IsaIoctl;
|
||||||
|
@ -79,26 +78,26 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaIoctl(
|
IsaIoctl(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
||||||
|
|
||||||
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
|
switch (IrpSp->Parameters.DeviceIoControl.IoControlCode)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
DPRINT1("Unknown ioctl code: %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
DPRINT1("Unknown ioctl code: %x\n", IrpSp->Parameters.DeviceIoControl.IoControlCode);
|
||||||
Status = STATUS_NOT_SUPPORTED;
|
Status = STATUS_NOT_SUPPORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH IsaReadWrite;
|
static DRIVER_DISPATCH IsaReadWrite;
|
||||||
|
@ -107,62 +106,62 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaReadWrite(
|
IsaReadWrite(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
||||||
|
|
||||||
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
|
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return STATUS_NOT_SUPPORTED;
|
return STATUS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaAddDevice(
|
IsaAddDevice(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PDEVICE_OBJECT PhysicalDeviceObject)
|
IN PDEVICE_OBJECT PhysicalDeviceObject)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT Fdo;
|
PDEVICE_OBJECT Fdo;
|
||||||
PISAPNP_FDO_EXTENSION FdoExt;
|
PISAPNP_FDO_EXTENSION FdoExt;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("%s(%p, %p)\n", __FUNCTION__, DriverObject, PhysicalDeviceObject);
|
DPRINT("%s(%p, %p)\n", __FUNCTION__, DriverObject, PhysicalDeviceObject);
|
||||||
|
|
||||||
Status = IoCreateDevice(DriverObject,
|
Status = IoCreateDevice(DriverObject,
|
||||||
sizeof(*FdoExt),
|
sizeof(*FdoExt),
|
||||||
NULL,
|
NULL,
|
||||||
FILE_DEVICE_BUS_EXTENDER,
|
FILE_DEVICE_BUS_EXTENDER,
|
||||||
FILE_DEVICE_SECURE_OPEN,
|
FILE_DEVICE_SECURE_OPEN,
|
||||||
TRUE,
|
TRUE,
|
||||||
&Fdo);
|
&Fdo);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed to create FDO (0x%x)\n", Status);
|
DPRINT1("Failed to create FDO (0x%x)\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
FdoExt = Fdo->DeviceExtension;
|
FdoExt = Fdo->DeviceExtension;
|
||||||
RtlZeroMemory(FdoExt, sizeof(*FdoExt));
|
RtlZeroMemory(FdoExt, sizeof(*FdoExt));
|
||||||
|
|
||||||
FdoExt->Common.Self = Fdo;
|
FdoExt->Common.Self = Fdo;
|
||||||
FdoExt->Common.IsFdo = TRUE;
|
FdoExt->Common.IsFdo = TRUE;
|
||||||
FdoExt->Common.State = dsStopped;
|
FdoExt->Common.State = dsStopped;
|
||||||
FdoExt->DriverObject = DriverObject;
|
FdoExt->DriverObject = DriverObject;
|
||||||
FdoExt->Pdo = PhysicalDeviceObject;
|
FdoExt->Pdo = PhysicalDeviceObject;
|
||||||
FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo,
|
FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo,
|
||||||
PhysicalDeviceObject);
|
PhysicalDeviceObject);
|
||||||
|
|
||||||
InitializeListHead(&FdoExt->DeviceListHead);
|
InitializeListHead(&FdoExt->DeviceListHead);
|
||||||
KeInitializeSpinLock(&FdoExt->Lock);
|
KeInitializeSpinLock(&FdoExt->Lock);
|
||||||
|
|
||||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DRIVER_DISPATCH IsaPnp;
|
static DRIVER_DISPATCH IsaPnp;
|
||||||
|
@ -171,45 +170,45 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnp(
|
IsaPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
IN PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
|
PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
|
||||||
|
|
||||||
if (DevExt->IsFdo)
|
if (DevExt->IsFdo)
|
||||||
{
|
{
|
||||||
return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt,
|
return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt,
|
||||||
Irp,
|
Irp,
|
||||||
IrpSp);
|
IrpSp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt,
|
return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt,
|
||||||
Irp,
|
Irp,
|
||||||
IrpSp);
|
IrpSp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
DriverEntry(
|
DriverEntry(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PUNICODE_STRING RegistryPath)
|
IN PUNICODE_STRING RegistryPath)
|
||||||
{
|
{
|
||||||
DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
|
DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
|
||||||
|
|
||||||
DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaCreateClose;
|
DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaCreateClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaCreateClose;
|
DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaCreateClose;
|
||||||
DriverObject->MajorFunction[IRP_MJ_READ] = IsaReadWrite;
|
DriverObject->MajorFunction[IRP_MJ_READ] = IsaReadWrite;
|
||||||
DriverObject->MajorFunction[IRP_MJ_WRITE] = IsaReadWrite;
|
DriverObject->MajorFunction[IRP_MJ_WRITE] = IsaReadWrite;
|
||||||
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaIoctl;
|
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaIoctl;
|
||||||
DriverObject->MajorFunction[IRP_MJ_PNP] = IsaPnp;
|
DriverObject->MajorFunction[IRP_MJ_PNP] = IsaPnp;
|
||||||
DriverObject->DriverExtension->AddDevice = IsaAddDevice;
|
DriverObject->DriverExtension->AddDevice = IsaAddDevice;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -11,42 +11,42 @@ extern "C" {
|
||||||
#define TAG_ISAPNP 'PNPI'
|
#define TAG_ISAPNP 'PNPI'
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
dsStopped,
|
dsStopped,
|
||||||
dsStarted
|
dsStarted
|
||||||
} ISAPNP_DEVICE_STATE;
|
} ISAPNP_DEVICE_STATE;
|
||||||
|
|
||||||
typedef struct _ISAPNP_LOGICAL_DEVICE {
|
typedef struct _ISAPNP_LOGICAL_DEVICE {
|
||||||
PDEVICE_OBJECT Pdo;
|
PDEVICE_OBJECT Pdo;
|
||||||
UCHAR VendorId[3];
|
UCHAR VendorId[3];
|
||||||
USHORT ProdId;
|
USHORT ProdId;
|
||||||
ULONG SerialNumber;
|
ULONG SerialNumber;
|
||||||
USHORT IoAddr;
|
USHORT IoAddr;
|
||||||
UCHAR IrqNo;
|
UCHAR IrqNo;
|
||||||
UCHAR CSN;
|
UCHAR CSN;
|
||||||
UCHAR LDN;
|
UCHAR LDN;
|
||||||
LIST_ENTRY ListEntry;
|
LIST_ENTRY ListEntry;
|
||||||
} ISAPNP_LOGICAL_DEVICE, *PISAPNP_LOGICAL_DEVICE;
|
} ISAPNP_LOGICAL_DEVICE, *PISAPNP_LOGICAL_DEVICE;
|
||||||
|
|
||||||
typedef struct _ISAPNP_COMMON_EXTENSION {
|
typedef struct _ISAPNP_COMMON_EXTENSION {
|
||||||
PDEVICE_OBJECT Self;
|
PDEVICE_OBJECT Self;
|
||||||
BOOLEAN IsFdo;
|
BOOLEAN IsFdo;
|
||||||
ISAPNP_DEVICE_STATE State;
|
ISAPNP_DEVICE_STATE State;
|
||||||
} ISAPNP_COMMON_EXTENSION, *PISAPNP_COMMON_EXTENSION;
|
} ISAPNP_COMMON_EXTENSION, *PISAPNP_COMMON_EXTENSION;
|
||||||
|
|
||||||
typedef struct _ISAPNP_FDO_EXTENSION {
|
typedef struct _ISAPNP_FDO_EXTENSION {
|
||||||
ISAPNP_COMMON_EXTENSION Common;
|
ISAPNP_COMMON_EXTENSION Common;
|
||||||
PDEVICE_OBJECT Ldo;
|
PDEVICE_OBJECT Ldo;
|
||||||
PDEVICE_OBJECT Pdo;
|
PDEVICE_OBJECT Pdo;
|
||||||
LIST_ENTRY DeviceListHead;
|
LIST_ENTRY DeviceListHead;
|
||||||
ULONG DeviceCount;
|
ULONG DeviceCount;
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
PUCHAR ReadDataPort;
|
PUCHAR ReadDataPort;
|
||||||
KSPIN_LOCK Lock;
|
KSPIN_LOCK Lock;
|
||||||
} ISAPNP_FDO_EXTENSION, *PISAPNP_FDO_EXTENSION;
|
} ISAPNP_FDO_EXTENSION, *PISAPNP_FDO_EXTENSION;
|
||||||
|
|
||||||
typedef struct _ISAPNP_PDO_EXTENSION {
|
typedef struct _ISAPNP_PDO_EXTENSION {
|
||||||
ISAPNP_COMMON_EXTENSION Common;
|
ISAPNP_COMMON_EXTENSION Common;
|
||||||
PISAPNP_LOGICAL_DEVICE IsaPnpDevice;
|
PISAPNP_LOGICAL_DEVICE IsaPnpDevice;
|
||||||
} ISAPNP_PDO_EXTENSION, *PISAPNP_PDO_EXTENSION;
|
} ISAPNP_PDO_EXTENSION, *PISAPNP_PDO_EXTENSION;
|
||||||
|
|
||||||
/* isapnp.c */
|
/* isapnp.c */
|
||||||
|
@ -56,51 +56,51 @@ DRIVER_INITIALIZE DriverEntry;
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
DriverEntry(
|
DriverEntry(
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
IN PUNICODE_STRING RegistryPath);
|
IN PUNICODE_STRING RegistryPath);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaForwardIrpSynchronous(
|
IsaForwardIrpSynchronous(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp);
|
IN PIRP Irp);
|
||||||
|
|
||||||
/* fdo.c */
|
/* fdo.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoPnp(
|
IsaFdoPnp(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
IN PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp);
|
IN PIO_STACK_LOCATION IrpSp);
|
||||||
|
|
||||||
/* pdo.c */
|
/* pdo.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoPnp(
|
IsaPdoPnp(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoDeviceExtension,
|
IN PISAPNP_PDO_EXTENSION PdoDeviceExtension,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp);
|
IN PIO_STACK_LOCATION IrpSp);
|
||||||
|
|
||||||
/* hardware.c */
|
/* hardware.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwDetectReadDataPort(
|
IsaHwDetectReadDataPort(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt);
|
IN PISAPNP_FDO_EXTENSION FdoExt);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwFillDeviceList(
|
IsaHwFillDeviceList(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt);
|
IN PISAPNP_FDO_EXTENSION FdoExt);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwDeactivateDevice(
|
IsaHwDeactivateDevice(
|
||||||
IN PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
IN PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwActivateDevice(
|
IsaHwActivateDevice(
|
||||||
IN PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
IN PISAPNP_LOGICAL_DEVICE LogicalDevice);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,22 +83,22 @@ extern "C" {
|
||||||
#define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100
|
#define ISAPNP_TAG_PSEUDO_NEWBOARD 0x100
|
||||||
|
|
||||||
typedef struct _ISAPNP_IDENTIFIER {
|
typedef struct _ISAPNP_IDENTIFIER {
|
||||||
USHORT VendorId;
|
USHORT VendorId;
|
||||||
USHORT ProdId;
|
USHORT ProdId;
|
||||||
ULONG Serial;
|
ULONG Serial;
|
||||||
UCHAR Checksum;
|
UCHAR Checksum;
|
||||||
} ISAPNP_IDENTIFIER, *PISAPNP_IDENTIFIER;
|
} ISAPNP_IDENTIFIER, *PISAPNP_IDENTIFIER;
|
||||||
|
|
||||||
typedef struct _ISAPNP_LOGDEVID {
|
typedef struct _ISAPNP_LOGDEVID {
|
||||||
USHORT VendorId;
|
USHORT VendorId;
|
||||||
USHORT ProdId;
|
USHORT ProdId;
|
||||||
USHORT Flags;
|
USHORT Flags;
|
||||||
} ISAPNP_LOGDEVID, *PISAPNP_LOGDEVID;
|
} ISAPNP_LOGDEVID, *PISAPNP_LOGDEVID;
|
||||||
|
|
||||||
typedef struct _ISAPNP_DEVICEID {
|
typedef struct _ISAPNP_DEVICEID {
|
||||||
CHAR* Name;
|
CHAR* Name;
|
||||||
USHORT VendorId;
|
USHORT VendorId;
|
||||||
USHORT ProdId;
|
USHORT ProdId;
|
||||||
} ISAPNP_DEVICEID, *PISAPNP_DEVICEID;
|
} ISAPNP_DEVICEID, *PISAPNP_DEVICEID;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -13,184 +13,184 @@
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryDeviceRelations(
|
IsaPdoQueryDeviceRelations(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
IN PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PDEVICE_RELATIONS DeviceRelations;
|
PDEVICE_RELATIONS DeviceRelations;
|
||||||
|
|
||||||
if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
|
if (IrpSp->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
|
||||||
return Irp->IoStatus.Status;
|
return Irp->IoStatus.Status;
|
||||||
|
|
||||||
DeviceRelations = ExAllocatePool(PagedPool, sizeof(*DeviceRelations));
|
DeviceRelations = ExAllocatePool(PagedPool, sizeof(*DeviceRelations));
|
||||||
if (!DeviceRelations)
|
if (!DeviceRelations)
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
DeviceRelations->Count = 1;
|
DeviceRelations->Count = 1;
|
||||||
DeviceRelations->Objects[0] = PdoExt->Common.Self;
|
DeviceRelations->Objects[0] = PdoExt->Common.Self;
|
||||||
ObReferenceObject(PdoExt->Common.Self);
|
ObReferenceObject(PdoExt->Common.Self);
|
||||||
|
|
||||||
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
|
Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryCapabilities(
|
IsaPdoQueryCapabilities(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
IN PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PDEVICE_CAPABILITIES DeviceCapabilities;
|
PDEVICE_CAPABILITIES DeviceCapabilities;
|
||||||
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
||||||
|
|
||||||
DeviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
|
DeviceCapabilities = IrpSp->Parameters.DeviceCapabilities.Capabilities;
|
||||||
if (DeviceCapabilities->Version != 1)
|
if (DeviceCapabilities->Version != 1)
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
DeviceCapabilities->UniqueID = LogDev->SerialNumber != 0xffffffff;
|
DeviceCapabilities->UniqueID = LogDev->SerialNumber != 0xffffffff;
|
||||||
DeviceCapabilities->Address = LogDev->CSN;
|
DeviceCapabilities->Address = LogDev->CSN;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryId(
|
IsaPdoQueryId(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
IN PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
||||||
WCHAR Temp[256];
|
WCHAR Temp[256];
|
||||||
PWCHAR Buffer, End;
|
PWCHAR Buffer, End;
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
switch (IrpSp->Parameters.QueryId.IdType)
|
switch (IrpSp->Parameters.QueryId.IdType)
|
||||||
{
|
|
||||||
case BusQueryDeviceID:
|
|
||||||
{
|
{
|
||||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
|
case BusQueryDeviceID:
|
||||||
Status = RtlStringCbPrintfExW(Temp, sizeof(Temp),
|
{
|
||||||
&End,
|
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryDeviceID\n");
|
||||||
NULL, 0,
|
Status = RtlStringCbPrintfExW(Temp, sizeof(Temp),
|
||||||
L"ISAPNP\\%3S%04X",
|
&End,
|
||||||
LogDev->VendorId,
|
NULL, 0,
|
||||||
LogDev->ProdId);
|
L"ISAPNP\\%3S%04X",
|
||||||
if (!NT_SUCCESS(Status))
|
LogDev->VendorId,
|
||||||
return Status;
|
LogDev->ProdId);
|
||||||
Length = End - Temp;
|
if (!NT_SUCCESS(Status))
|
||||||
Temp[Length++] = UNICODE_NULL;
|
return Status;
|
||||||
break;
|
Length = End - Temp;
|
||||||
|
Temp[Length++] = UNICODE_NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case BusQueryHardwareIDs:
|
||||||
|
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
|
||||||
|
Status = RtlStringCbPrintfExW(Temp, sizeof(Temp),
|
||||||
|
&End,
|
||||||
|
NULL, 0,
|
||||||
|
L"ISAPNP\\%3S%04X",
|
||||||
|
LogDev->VendorId,
|
||||||
|
LogDev->ProdId);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
Length = End - Temp;
|
||||||
|
Temp[Length++] = UNICODE_NULL;
|
||||||
|
Status = RtlStringCbPrintfExW(Temp + Length, sizeof(Temp) - Length,
|
||||||
|
&End,
|
||||||
|
NULL, 0,
|
||||||
|
L"*%3S%04X",
|
||||||
|
LogDev->VendorId,
|
||||||
|
LogDev->ProdId);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
Length = End - Temp;
|
||||||
|
Temp[Length++] = UNICODE_NULL;
|
||||||
|
Temp[Length++] = UNICODE_NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BusQueryInstanceID:
|
||||||
|
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
|
||||||
|
Status = RtlStringCbPrintfExW(Temp, sizeof(Temp),
|
||||||
|
&End,
|
||||||
|
NULL, 0,
|
||||||
|
L"%X",
|
||||||
|
LogDev->SerialNumber);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
return Status;
|
||||||
|
Length = End - Temp;
|
||||||
|
Temp[Length++] = UNICODE_NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n",
|
||||||
|
IrpSp->Parameters.QueryId.IdType);
|
||||||
|
return Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BusQueryHardwareIDs:
|
Buffer = ExAllocatePool(PagedPool, Length * sizeof(WCHAR));
|
||||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryHardwareIDs\n");
|
if (!Buffer)
|
||||||
Status = RtlStringCbPrintfExW(Temp, sizeof(Temp),
|
return STATUS_NO_MEMORY;
|
||||||
&End,
|
|
||||||
NULL, 0,
|
|
||||||
L"ISAPNP\\%3S%04X",
|
|
||||||
LogDev->VendorId,
|
|
||||||
LogDev->ProdId);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
return Status;
|
|
||||||
Length = End - Temp;
|
|
||||||
Temp[Length++] = UNICODE_NULL;
|
|
||||||
Status = RtlStringCbPrintfExW(Temp + Length, sizeof(Temp) - Length,
|
|
||||||
&End,
|
|
||||||
NULL, 0,
|
|
||||||
L"*%3S%04X",
|
|
||||||
LogDev->VendorId,
|
|
||||||
LogDev->ProdId);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
return Status;
|
|
||||||
Length = End - Temp;
|
|
||||||
Temp[Length++] = UNICODE_NULL;
|
|
||||||
Temp[Length++] = UNICODE_NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BusQueryInstanceID:
|
RtlCopyMemory(Buffer, Temp, Length * sizeof(WCHAR));
|
||||||
DPRINT("IRP_MJ_PNP / IRP_MN_QUERY_ID / BusQueryInstanceID\n");
|
Irp->IoStatus.Information = (ULONG_PTR)Buffer;
|
||||||
Status = RtlStringCbPrintfExW(Temp, sizeof(Temp),
|
return STATUS_SUCCESS;
|
||||||
&End,
|
|
||||||
NULL, 0,
|
|
||||||
L"%X",
|
|
||||||
LogDev->SerialNumber);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
return Status;
|
|
||||||
Length = End - Temp;
|
|
||||||
Temp[Length++] = UNICODE_NULL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
DPRINT1("IRP_MJ_PNP / IRP_MN_QUERY_ID / unknown query id type 0x%lx\n",
|
|
||||||
IrpSp->Parameters.QueryId.IdType);
|
|
||||||
return Irp->IoStatus.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
Buffer = ExAllocatePool(PagedPool, Length * sizeof(WCHAR));
|
|
||||||
if (!Buffer)
|
|
||||||
return STATUS_NO_MEMORY;
|
|
||||||
|
|
||||||
RtlCopyMemory(Buffer, Temp, Length * sizeof(WCHAR));
|
|
||||||
Irp->IoStatus.Information = (ULONG_PTR)Buffer;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoPnp(
|
IsaPdoPnp(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
IN PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
IN PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
IN PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = Irp->IoStatus.Status;
|
NTSTATUS Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
switch (IrpSp->MinorFunction)
|
switch (IrpSp->MinorFunction)
|
||||||
{
|
{
|
||||||
case IRP_MN_START_DEVICE:
|
case IRP_MN_START_DEVICE:
|
||||||
Status = IsaHwActivateDevice(PdoExt->IsaPnpDevice);
|
Status = IsaHwActivateDevice(PdoExt->IsaPnpDevice);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
PdoExt->Common.State = dsStarted;
|
PdoExt->Common.State = dsStarted;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_STOP_DEVICE:
|
case IRP_MN_STOP_DEVICE:
|
||||||
Status = IsaHwDeactivateDevice(PdoExt->IsaPnpDevice);
|
Status = IsaHwDeactivateDevice(PdoExt->IsaPnpDevice);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
PdoExt->Common.State = dsStopped;
|
PdoExt->Common.State = dsStopped;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
case IRP_MN_QUERY_DEVICE_RELATIONS:
|
||||||
Status = IsaPdoQueryDeviceRelations(PdoExt, Irp, IrpSp);
|
Status = IsaPdoQueryDeviceRelations(PdoExt, Irp, IrpSp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_CAPABILITIES:
|
case IRP_MN_QUERY_CAPABILITIES:
|
||||||
Status = IsaPdoQueryCapabilities(PdoExt, Irp, IrpSp);
|
Status = IsaPdoQueryCapabilities(PdoExt, Irp, IrpSp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_RESOURCES:
|
case IRP_MN_QUERY_RESOURCES:
|
||||||
DPRINT1("IRP_MN_QUERY_RESOURCES is UNIMPLEMENTED!\n");
|
DPRINT1("IRP_MN_QUERY_RESOURCES is UNIMPLEMENTED!\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
case IRP_MN_QUERY_RESOURCE_REQUIREMENTS:
|
||||||
DPRINT1("IRP_MN_QUERY_RESOURCE_REQUIREMENTS is UNIMPLEMENTED!\n");
|
DPRINT1("IRP_MN_QUERY_RESOURCE_REQUIREMENTS is UNIMPLEMENTED!\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_ID:
|
case IRP_MN_QUERY_ID:
|
||||||
Status = IsaPdoQueryId(PdoExt, Irp, IrpSp);
|
Status = IsaPdoQueryId(PdoExt, Irp, IrpSp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
|
DPRINT1("Unknown PnP code: %x\n", IrpSp->MinorFunction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue