mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[ISAPNP] Code formatting
- Add SAL2 annotations.
- Use RTL_NUMBER_OF macro in kernel mode.
- Use better function/member names.
- Less hardcoded values.
- Add license information. See commit
d9face83c6
for details.
No functional changes.
This commit is contained in:
parent
ba77a09c04
commit
8f44930f91
6 changed files with 311 additions and 262 deletions
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS ISA PnP Bus driver
|
* PROJECT: ReactOS ISA PnP Bus driver
|
||||||
* FILE: fdo.c
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: FDO-specific code
|
* PURPOSE: FDO-specific code
|
||||||
* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
||||||
* Hervé Poussineau
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <isapnp.h>
|
#include "isapnp.h"
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -14,9 +14,9 @@
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoStartDevice(
|
IsaFdoStartDevice(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
UNREFERENCED_PARAMETER(Irp);
|
UNREFERENCED_PARAMETER(Irp);
|
||||||
UNREFERENCED_PARAMETER(IrpSp);
|
UNREFERENCED_PARAMETER(IrpSp);
|
||||||
|
@ -29,9 +29,9 @@ IsaFdoStartDevice(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoQueryDeviceRelations(
|
IsaFdoQueryDeviceRelations(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
if (IrpSp->Parameters.QueryDeviceRelations.Type != BusRelations)
|
||||||
return Irp->IoStatus.Status;
|
return Irp->IoStatus.Status;
|
||||||
|
@ -42,9 +42,9 @@ IsaFdoQueryDeviceRelations(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoPnp(
|
IsaFdoPnp(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = Irp->IoStatus.Status;
|
NTSTATUS Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS ISA PnP Bus driver
|
* PROJECT: ReactOS ISA PnP Bus driver
|
||||||
* FILE: hardware.c
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: Hardware support code
|
* PURPOSE: Hardware support code
|
||||||
* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
||||||
* Hervé Poussineau
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <isapnp.h>
|
#include "isapnp.h"
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -15,7 +15,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteAddress(
|
WriteAddress(
|
||||||
IN USHORT Address)
|
_In_ USHORT Address)
|
||||||
{
|
{
|
||||||
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_ADDRESS, Address);
|
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_ADDRESS, Address);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteData(
|
WriteData(
|
||||||
IN USHORT Data)
|
_In_ USHORT Data)
|
||||||
{
|
{
|
||||||
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_WRITE_DATA, Data);
|
WRITE_PORT_UCHAR((PUCHAR)ISAPNP_WRITE_DATA, Data);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ static
|
||||||
inline
|
inline
|
||||||
UCHAR
|
UCHAR
|
||||||
ReadData(
|
ReadData(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return READ_PORT_UCHAR(ReadDataPort);
|
return READ_PORT_UCHAR(ReadDataPort);
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteByte(
|
WriteByte(
|
||||||
IN USHORT Address,
|
_In_ USHORT Address,
|
||||||
IN USHORT Value)
|
_In_ USHORT Value)
|
||||||
{
|
{
|
||||||
WriteAddress(Address);
|
WriteAddress(Address);
|
||||||
WriteData(Value);
|
WriteData(Value);
|
||||||
|
@ -53,8 +53,8 @@ static
|
||||||
inline
|
inline
|
||||||
UCHAR
|
UCHAR
|
||||||
ReadByte(
|
ReadByte(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT Address)
|
_In_ USHORT Address)
|
||||||
{
|
{
|
||||||
WriteAddress(Address);
|
WriteAddress(Address);
|
||||||
return ReadData(ReadDataPort);
|
return ReadData(ReadDataPort);
|
||||||
|
@ -64,8 +64,8 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadWord(
|
ReadWord(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT Address)
|
_In_ USHORT Address)
|
||||||
{
|
{
|
||||||
return ((ReadByte(ReadDataPort, Address) << 8) |
|
return ((ReadByte(ReadDataPort, Address) << 8) |
|
||||||
(ReadByte(ReadDataPort, Address + 1)));
|
(ReadByte(ReadDataPort, Address + 1)));
|
||||||
|
@ -75,7 +75,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
SetReadDataPort(
|
SetReadDataPort(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_READPORT, ((ULONG_PTR)ReadDataPort >> 2));
|
WriteByte(ISAPNP_READPORT, ((ULONG_PTR)ReadDataPort >> 2));
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
Wake(
|
Wake(
|
||||||
IN USHORT Csn)
|
_In_ USHORT Csn)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_WAKE, Csn);
|
WriteByte(ISAPNP_WAKE, Csn);
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadResourceData(
|
ReadResourceData(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
|
return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadStatus(
|
ReadStatus(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_STATUS);
|
return ReadByte(ReadDataPort, ISAPNP_STATUS);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteCsn(
|
WriteCsn(
|
||||||
IN USHORT Csn)
|
_In_ USHORT Csn)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_CARDSELECTNUMBER, Csn);
|
WriteByte(ISAPNP_CARDSELECTNUMBER, Csn);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
WriteLogicalDeviceNumber(
|
WriteLogicalDeviceNumber(
|
||||||
IN USHORT LogDev)
|
_In_ USHORT LogDev)
|
||||||
{
|
{
|
||||||
WriteByte(ISAPNP_LOGICALDEVICENUMBER, LogDev);
|
WriteByte(ISAPNP_LOGICALDEVICENUMBER, LogDev);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
ActivateDevice(
|
ActivateDevice(
|
||||||
IN USHORT LogDev)
|
_In_ USHORT LogDev)
|
||||||
{
|
{
|
||||||
WriteLogicalDeviceNumber(LogDev);
|
WriteLogicalDeviceNumber(LogDev);
|
||||||
WriteByte(ISAPNP_ACTIVATE, 1);
|
WriteByte(ISAPNP_ACTIVATE, 1);
|
||||||
|
@ -163,7 +163,7 @@ static
|
||||||
inline
|
inline
|
||||||
VOID
|
VOID
|
||||||
DeactivateDevice(
|
DeactivateDevice(
|
||||||
IN USHORT LogDev)
|
_In_ USHORT LogDev)
|
||||||
{
|
{
|
||||||
WriteLogicalDeviceNumber(LogDev);
|
WriteLogicalDeviceNumber(LogDev);
|
||||||
WriteByte(ISAPNP_ACTIVATE, 0);
|
WriteByte(ISAPNP_ACTIVATE, 0);
|
||||||
|
@ -173,8 +173,8 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadIoBase(
|
ReadIoBase(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT Index)
|
_In_ USHORT Index)
|
||||||
{
|
{
|
||||||
return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
|
return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadIrqNo(
|
ReadIrqNo(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT Index)
|
_In_ USHORT Index)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index));
|
return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index));
|
||||||
}
|
}
|
||||||
|
@ -193,8 +193,8 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadIrqType(
|
ReadIrqType(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT Index)
|
_In_ USHORT Index)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_IRQTYPE(Index));
|
return ReadByte(ReadDataPort, ISAPNP_IRQTYPE(Index));
|
||||||
}
|
}
|
||||||
|
@ -203,8 +203,8 @@ static
|
||||||
inline
|
inline
|
||||||
USHORT
|
USHORT
|
||||||
ReadDmaChannel(
|
ReadDmaChannel(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT Index)
|
_In_ USHORT Index)
|
||||||
{
|
{
|
||||||
return ReadByte(ReadDataPort, ISAPNP_DMACHANNEL(Index));
|
return ReadByte(ReadDataPort, ISAPNP_DMACHANNEL(Index));
|
||||||
}
|
}
|
||||||
|
@ -221,8 +221,8 @@ static
|
||||||
inline
|
inline
|
||||||
UCHAR
|
UCHAR
|
||||||
NextLFSR(
|
NextLFSR(
|
||||||
IN UCHAR Lfsr,
|
_In_ UCHAR Lfsr,
|
||||||
IN UCHAR InputBit)
|
_In_ UCHAR InputBit)
|
||||||
{
|
{
|
||||||
UCHAR NextLfsr = Lfsr >> 1;
|
UCHAR NextLfsr = Lfsr >> 1;
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ SendKey(VOID)
|
||||||
static
|
static
|
||||||
USHORT
|
USHORT
|
||||||
PeekByte(
|
PeekByte(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
|
@ -270,9 +270,9 @@ PeekByte(
|
||||||
static
|
static
|
||||||
VOID
|
VOID
|
||||||
Peek(
|
Peek(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN OUT PVOID Buffer,
|
_Out_writes_bytes_all_opt_(Length) PVOID Buffer,
|
||||||
IN ULONG Length)
|
_In_ ULONG Length)
|
||||||
{
|
{
|
||||||
USHORT i, Byte;
|
USHORT i, Byte;
|
||||||
|
|
||||||
|
@ -280,22 +280,23 @@ Peek(
|
||||||
{
|
{
|
||||||
Byte = PeekByte(ReadDataPort);
|
Byte = PeekByte(ReadDataPort);
|
||||||
if (Buffer)
|
if (Buffer)
|
||||||
*((PUCHAR)Buffer + i) = Byte;
|
((PUCHAR)Buffer)[i] = Byte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
USHORT
|
USHORT
|
||||||
IsaPnpChecksum(
|
IsaPnpChecksum(
|
||||||
IN PISAPNP_IDENTIFIER Identifier)
|
_In_ PISAPNP_IDENTIFIER Identifier)
|
||||||
{
|
{
|
||||||
UCHAR i, j, Lfsr, Byte;
|
UCHAR i, j, Lfsr;
|
||||||
|
|
||||||
Lfsr = ISAPNP_LFSR_SEED;
|
Lfsr = ISAPNP_LFSR_SEED;
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < FIELD_OFFSET(ISAPNP_IDENTIFIER, Checksum); i++)
|
||||||
{
|
{
|
||||||
Byte = *(((PUCHAR)Identifier) + i);
|
UCHAR Byte = ((PUCHAR)Identifier)[i];
|
||||||
for (j = 0; j < 8; j++)
|
|
||||||
|
for (j = 0; j < RTL_BITS_OF(Byte); j++)
|
||||||
{
|
{
|
||||||
Lfsr = NextLFSR(Lfsr, Byte);
|
Lfsr = NextLFSR(Lfsr, Byte);
|
||||||
Byte >>= 1;
|
Byte >>= 1;
|
||||||
|
@ -308,9 +309,9 @@ IsaPnpChecksum(
|
||||||
static
|
static
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
ReadTags(
|
ReadTags(
|
||||||
IN PUCHAR ReadDataPort,
|
_In_ PUCHAR ReadDataPort,
|
||||||
IN USHORT LogDev,
|
_In_ USHORT LogDev,
|
||||||
IN OUT PISAPNP_LOGICAL_DEVICE LogDevice)
|
_Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
|
||||||
{
|
{
|
||||||
BOOLEAN res = FALSE;
|
BOOLEAN res = FALSE;
|
||||||
PVOID Buffer;
|
PVOID Buffer;
|
||||||
|
@ -392,7 +393,7 @@ ReadTags(
|
||||||
static
|
static
|
||||||
INT
|
INT
|
||||||
TryIsolate(
|
TryIsolate(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
ISAPNP_IDENTIFIER Identifier;
|
ISAPNP_IDENTIFIER Identifier;
|
||||||
USHORT i, j;
|
USHORT i, j;
|
||||||
|
@ -497,8 +498,8 @@ TryIsolate(
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
DeviceActivation(
|
DeviceActivation(
|
||||||
IN PISAPNP_LOGICAL_DEVICE IsaDevice,
|
_In_ PISAPNP_LOGICAL_DEVICE IsaDevice,
|
||||||
IN BOOLEAN Activate)
|
_In_ BOOLEAN Activate)
|
||||||
{
|
{
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
SendKey();
|
SendKey();
|
||||||
|
@ -516,7 +517,7 @@ DeviceActivation(
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
ProbeIsaPnpBus(
|
ProbeIsaPnpBus(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt)
|
_In_ PISAPNP_FDO_EXTENSION FdoExt)
|
||||||
{
|
{
|
||||||
PISAPNP_LOGICAL_DEVICE LogDevice;
|
PISAPNP_LOGICAL_DEVICE LogDevice;
|
||||||
ISAPNP_IDENTIFIER Identifier;
|
ISAPNP_IDENTIFIER Identifier;
|
||||||
|
@ -578,7 +579,7 @@ ProbeIsaPnpBus(
|
||||||
|
|
||||||
WaitForKey();
|
WaitForKey();
|
||||||
|
|
||||||
InsertTailList(&FdoExt->DeviceListHead, &LogDevice->ListEntry);
|
InsertTailList(&FdoExt->DeviceListHead, &LogDevice->DeviceLink);
|
||||||
FdoExt->DeviceCount++;
|
FdoExt->DeviceCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,7 +590,7 @@ ProbeIsaPnpBus(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwTryReadDataPort(
|
IsaHwTryReadDataPort(
|
||||||
IN PUCHAR ReadDataPort)
|
_In_ PUCHAR ReadDataPort)
|
||||||
{
|
{
|
||||||
return TryIsolate(ReadDataPort) > 0 ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
|
return TryIsolate(ReadDataPort) > 0 ? STATUS_SUCCESS : STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
|
@ -597,7 +598,7 @@ IsaHwTryReadDataPort(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwActivateDevice(
|
IsaHwActivateDevice(
|
||||||
IN PISAPNP_LOGICAL_DEVICE LogicalDevice)
|
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
|
||||||
{
|
{
|
||||||
DeviceActivation(LogicalDevice,
|
DeviceActivation(LogicalDevice,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
@ -608,7 +609,7 @@ IsaHwActivateDevice(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwDeactivateDevice(
|
IsaHwDeactivateDevice(
|
||||||
IN PISAPNP_LOGICAL_DEVICE LogicalDevice)
|
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
|
||||||
{
|
{
|
||||||
DeviceActivation(LogicalDevice,
|
DeviceActivation(LogicalDevice,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
@ -619,7 +620,7 @@ IsaHwDeactivateDevice(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwFillDeviceList(
|
IsaHwFillDeviceList(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt)
|
_In_ PISAPNP_FDO_EXTENSION FdoExt)
|
||||||
{
|
{
|
||||||
return ProbeIsaPnpBus(FdoExt);
|
return ProbeIsaPnpBus(FdoExt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS ISA PnP Bus driver
|
* PROJECT: ReactOS ISA PnP Bus driver
|
||||||
* FILE: isapnp.c
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: Driver entry
|
* PURPOSE: Driver entry
|
||||||
* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
||||||
* Hervé Poussineau
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <isapnp.h>
|
#include "isapnp.h"
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -140,14 +140,14 @@ IsaFdoCreateDeviceIDs(
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoCreateRequirements(
|
IsaPnpCreateLogicalDeviceRequirements(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt)
|
_In_ PISAPNP_PDO_EXTENSION PdoExt)
|
||||||
{
|
{
|
||||||
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
||||||
RTL_BITMAP IrqBitmap[ARRAYSIZE(LogDev->Irq)];
|
RTL_BITMAP IrqBitmap[RTL_NUMBER_OF(LogDev->Irq)];
|
||||||
RTL_BITMAP DmaBitmap[ARRAYSIZE(LogDev->Dma)];
|
RTL_BITMAP DmaBitmap[RTL_NUMBER_OF(LogDev->Dma)];
|
||||||
ULONG IrqData[ARRAYSIZE(LogDev->Irq)];
|
ULONG IrqData[RTL_NUMBER_OF(LogDev->Irq)];
|
||||||
ULONG DmaData[ARRAYSIZE(LogDev->Dma)];
|
ULONG DmaData[RTL_NUMBER_OF(LogDev->Dma)];
|
||||||
ULONG ResourceCount = 0;
|
ULONG ResourceCount = 0;
|
||||||
ULONG ListSize, i, j;
|
ULONG ListSize, i, j;
|
||||||
BOOLEAN FirstIrq = TRUE, FirstDma = TRUE;
|
BOOLEAN FirstIrq = TRUE, FirstDma = TRUE;
|
||||||
|
@ -155,19 +155,22 @@ IsaFdoCreateRequirements(
|
||||||
PIO_RESOURCE_DESCRIPTOR Descriptor;
|
PIO_RESOURCE_DESCRIPTOR Descriptor;
|
||||||
|
|
||||||
/* Count number of requirements */
|
/* Count number of requirements */
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Io); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Io); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Io[i].Description.Length)
|
if (!LogDev->Io[i].Description.Length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ResourceCount++;
|
ResourceCount++;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Irq); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Irq[i].Description.Mask)
|
if (!LogDev->Irq[i].Description.Mask)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
IrqData[i] = LogDev->Irq[i].Description.Mask;
|
IrqData[i] = LogDev->Irq[i].Description.Mask;
|
||||||
RtlInitializeBitMap(&IrqBitmap[i], &IrqData[i], 16);
|
RtlInitializeBitMap(&IrqBitmap[i], &IrqData[i], 16);
|
||||||
ResourceCount += RtlNumberOfSetBits(&IrqBitmap[i]);
|
ResourceCount += RtlNumberOfSetBits(&IrqBitmap[i]);
|
||||||
|
|
||||||
if (LogDev->Irq[i].Description.Information & 0x4)
|
if (LogDev->Irq[i].Description.Information & 0x4)
|
||||||
{
|
{
|
||||||
/* Add room for level sensitive */
|
/* Add room for level sensitive */
|
||||||
|
@ -176,10 +179,11 @@ IsaFdoCreateRequirements(
|
||||||
}
|
}
|
||||||
if (ResourceCount == 0)
|
if (ResourceCount == 0)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Irq); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Dma[i].Description.Mask)
|
if (!LogDev->Dma[i].Description.Mask)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DmaData[i] = LogDev->Dma[i].Description.Mask;
|
DmaData[i] = LogDev->Dma[i].Description.Mask;
|
||||||
RtlInitializeBitMap(&DmaBitmap[i], &DmaData[i], 8);
|
RtlInitializeBitMap(&DmaBitmap[i], &DmaData[i], 8);
|
||||||
ResourceCount += RtlNumberOfSetBits(&DmaBitmap[i]);
|
ResourceCount += RtlNumberOfSetBits(&DmaBitmap[i]);
|
||||||
|
@ -187,7 +191,7 @@ IsaFdoCreateRequirements(
|
||||||
|
|
||||||
/* Allocate memory to store requirements */
|
/* Allocate memory to store requirements */
|
||||||
ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST)
|
ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST)
|
||||||
+ ResourceCount * sizeof(IO_RESOURCE_DESCRIPTOR);
|
+ ResourceCount * sizeof(IO_RESOURCE_DESCRIPTOR);
|
||||||
RequirementsList = ExAllocatePool(PagedPool, ListSize);
|
RequirementsList = ExAllocatePool(PagedPool, ListSize);
|
||||||
if (!RequirementsList)
|
if (!RequirementsList)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
@ -203,15 +207,17 @@ IsaFdoCreateRequirements(
|
||||||
|
|
||||||
/* Store requirements */
|
/* Store requirements */
|
||||||
Descriptor = RequirementsList->List[0].Descriptors;
|
Descriptor = RequirementsList->List[0].Descriptors;
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Io); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Io); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Io[i].Description.Length)
|
if (!LogDev->Io[i].Description.Length)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DPRINT("Device.Io[%d].Information = 0x%02x\n", i, LogDev->Io[i].Description.Information);
|
DPRINT("Device.Io[%d].Information = 0x%02x\n", i, LogDev->Io[i].Description.Information);
|
||||||
DPRINT("Device.Io[%d].Minimum = 0x%02x\n", i, LogDev->Io[i].Description.Minimum);
|
DPRINT("Device.Io[%d].Minimum = 0x%02x\n", i, LogDev->Io[i].Description.Minimum);
|
||||||
DPRINT("Device.Io[%d].Maximum = 0x%02x\n", i, LogDev->Io[i].Description.Maximum);
|
DPRINT("Device.Io[%d].Maximum = 0x%02x\n", i, LogDev->Io[i].Description.Maximum);
|
||||||
DPRINT("Device.Io[%d].Alignment = 0x%02x\n", i, LogDev->Io[i].Description.Alignment);
|
DPRINT("Device.Io[%d].Alignment = 0x%02x\n", i, LogDev->Io[i].Description.Alignment);
|
||||||
DPRINT("Device.Io[%d].Length = 0x%02x\n", i, LogDev->Io[i].Description.Length);
|
DPRINT("Device.Io[%d].Length = 0x%02x\n", i, LogDev->Io[i].Description.Length);
|
||||||
|
|
||||||
Descriptor->Type = CmResourceTypePort;
|
Descriptor->Type = CmResourceTypePort;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
if (LogDev->Io[i].Description.Information & 0x1)
|
if (LogDev->Io[i].Description.Information & 0x1)
|
||||||
|
@ -221,19 +227,23 @@ IsaFdoCreateRequirements(
|
||||||
Descriptor->u.Port.Length = LogDev->Io[i].Description.Length;
|
Descriptor->u.Port.Length = LogDev->Io[i].Description.Length;
|
||||||
Descriptor->u.Port.Alignment = LogDev->Io[i].Description.Alignment;
|
Descriptor->u.Port.Alignment = LogDev->Io[i].Description.Alignment;
|
||||||
Descriptor->u.Port.MinimumAddress.LowPart = LogDev->Io[i].Description.Minimum;
|
Descriptor->u.Port.MinimumAddress.LowPart = LogDev->Io[i].Description.Minimum;
|
||||||
Descriptor->u.Port.MaximumAddress.LowPart = LogDev->Io[i].Description.Maximum + LogDev->Io[i].Description.Length - 1;
|
Descriptor->u.Port.MaximumAddress.LowPart =
|
||||||
|
LogDev->Io[i].Description.Maximum + LogDev->Io[i].Description.Length - 1;
|
||||||
Descriptor++;
|
Descriptor++;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Irq); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Irq[i].Description.Mask)
|
if (!LogDev->Irq[i].Description.Mask)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DPRINT("Device.Irq[%d].Mask = 0x%02x\n", i, LogDev->Irq[i].Description.Mask);
|
DPRINT("Device.Irq[%d].Mask = 0x%02x\n", i, LogDev->Irq[i].Description.Mask);
|
||||||
DPRINT("Device.Irq[%d].Information = 0x%02x\n", i, LogDev->Irq[i].Description.Information);
|
DPRINT("Device.Irq[%d].Information = 0x%02x\n", i, LogDev->Irq[i].Description.Information);
|
||||||
|
|
||||||
for (j = 0; j < 15; j++)
|
for (j = 0; j < 15; j++)
|
||||||
{
|
{
|
||||||
if (!RtlCheckBit(&IrqBitmap[i], j))
|
if (!RtlCheckBit(&IrqBitmap[i], j))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FirstIrq)
|
if (FirstIrq)
|
||||||
FirstIrq = FALSE;
|
FirstIrq = FALSE;
|
||||||
else
|
else
|
||||||
|
@ -242,6 +252,7 @@ IsaFdoCreateRequirements(
|
||||||
Descriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
|
Descriptor->Flags = CM_RESOURCE_INTERRUPT_LATCHED;
|
||||||
Descriptor->u.Interrupt.MinimumVector = Descriptor->u.Interrupt.MaximumVector = j;
|
Descriptor->u.Interrupt.MinimumVector = Descriptor->u.Interrupt.MaximumVector = j;
|
||||||
Descriptor++;
|
Descriptor++;
|
||||||
|
|
||||||
if (LogDev->Irq[i].Description.Information & 0x4)
|
if (LogDev->Irq[i].Description.Information & 0x4)
|
||||||
{
|
{
|
||||||
/* Level interrupt */
|
/* Level interrupt */
|
||||||
|
@ -253,16 +264,19 @@ IsaFdoCreateRequirements(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Dma); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Dma); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Dma[i].Description.Mask)
|
if (!LogDev->Dma[i].Description.Mask)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
DPRINT("Device.Dma[%d].Mask = 0x%02x\n", i, LogDev->Dma[i].Description.Mask);
|
DPRINT("Device.Dma[%d].Mask = 0x%02x\n", i, LogDev->Dma[i].Description.Mask);
|
||||||
DPRINT("Device.Dma[%d].Information = 0x%02x\n", i, LogDev->Dma[i].Description.Information);
|
DPRINT("Device.Dma[%d].Information = 0x%02x\n", i, LogDev->Dma[i].Description.Information);
|
||||||
|
|
||||||
for (j = 0; j < 8; j++)
|
for (j = 0; j < 8; j++)
|
||||||
{
|
{
|
||||||
if (!RtlCheckBit(&DmaBitmap[i], j))
|
if (!RtlCheckBit(&DmaBitmap[i], j))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FirstDma)
|
if (FirstDma)
|
||||||
FirstDma = FALSE;
|
FirstDma = FALSE;
|
||||||
else
|
else
|
||||||
|
@ -296,8 +310,8 @@ IsaFdoCreateRequirements(
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaFdoCreateResources(
|
IsaPnpCreateLogicalDeviceResources(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt)
|
_In_ PISAPNP_PDO_EXTENSION PdoExt)
|
||||||
{
|
{
|
||||||
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
|
||||||
ULONG ResourceCount = 0;
|
ULONG ResourceCount = 0;
|
||||||
|
@ -306,21 +320,21 @@ IsaFdoCreateResources(
|
||||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
|
PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
|
||||||
|
|
||||||
/* Count number of required resources */
|
/* Count number of required resources */
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Io); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Io); i++)
|
||||||
{
|
{
|
||||||
if (LogDev->Io[i].CurrentBase)
|
if (LogDev->Io[i].CurrentBase)
|
||||||
ResourceCount++;
|
ResourceCount++;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Irq); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
|
||||||
{
|
{
|
||||||
if (LogDev->Irq[i].CurrentNo)
|
if (LogDev->Irq[i].CurrentNo)
|
||||||
ResourceCount++;
|
ResourceCount++;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Dma); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Dma); i++)
|
||||||
{
|
{
|
||||||
if (LogDev->Dma[i].CurrentChannel != 4)
|
if (LogDev->Dma[i].CurrentChannel != 4)
|
||||||
ResourceCount++;
|
ResourceCount++;
|
||||||
|
@ -332,7 +346,7 @@ IsaFdoCreateResources(
|
||||||
|
|
||||||
/* Allocate memory to store resources */
|
/* Allocate memory to store resources */
|
||||||
ListSize = sizeof(CM_RESOURCE_LIST)
|
ListSize = sizeof(CM_RESOURCE_LIST)
|
||||||
+ (ResourceCount - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
+ (ResourceCount - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
||||||
ResourceList = ExAllocatePool(PagedPool, ListSize);
|
ResourceList = ExAllocatePool(PagedPool, ListSize);
|
||||||
if (!ResourceList)
|
if (!ResourceList)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
@ -346,10 +360,11 @@ IsaFdoCreateResources(
|
||||||
|
|
||||||
/* Store resources */
|
/* Store resources */
|
||||||
ResourceCount = 0;
|
ResourceCount = 0;
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Io); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Io); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Io[i].CurrentBase)
|
if (!LogDev->Io[i].CurrentBase)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
|
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
|
||||||
Descriptor->Type = CmResourceTypePort;
|
Descriptor->Type = CmResourceTypePort;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
|
@ -360,10 +375,11 @@ IsaFdoCreateResources(
|
||||||
Descriptor->u.Port.Length = LogDev->Io[i].Description.Length;
|
Descriptor->u.Port.Length = LogDev->Io[i].Description.Length;
|
||||||
Descriptor->u.Port.Start.LowPart = LogDev->Io[i].CurrentBase;
|
Descriptor->u.Port.Start.LowPart = LogDev->Io[i].CurrentBase;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Irq); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
|
||||||
{
|
{
|
||||||
if (!LogDev->Irq[i].CurrentNo)
|
if (!LogDev->Irq[i].CurrentNo)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
|
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
|
||||||
Descriptor->Type = CmResourceTypeInterrupt;
|
Descriptor->Type = CmResourceTypeInterrupt;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
|
@ -375,10 +391,11 @@ IsaFdoCreateResources(
|
||||||
Descriptor->u.Interrupt.Vector = LogDev->Irq[i].CurrentNo;
|
Descriptor->u.Interrupt.Vector = LogDev->Irq[i].CurrentNo;
|
||||||
Descriptor->u.Interrupt.Affinity = -1;
|
Descriptor->u.Interrupt.Affinity = -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAYSIZE(LogDev->Dma); i++)
|
for (i = 0; i < RTL_NUMBER_OF(LogDev->Dma); i++)
|
||||||
{
|
{
|
||||||
if (LogDev->Dma[i].CurrentChannel == 4)
|
if (LogDev->Dma[i].CurrentChannel == 4)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
|
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
|
||||||
Descriptor->Type = CmResourceTypeDma;
|
Descriptor->Type = CmResourceTypeDma;
|
||||||
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
|
||||||
|
@ -409,9 +426,9 @@ IsaFdoCreateResources(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnpFillDeviceRelations(
|
IsaPnpFillDeviceRelations(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN BOOLEAN IncludeDataPort)
|
_In_ BOOLEAN IncludeDataPort)
|
||||||
{
|
{
|
||||||
PISAPNP_PDO_EXTENSION PdoExt;
|
PISAPNP_PDO_EXTENSION PdoExt;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
@ -429,63 +446,63 @@ IsaPnpFillDeviceRelations(
|
||||||
|
|
||||||
if (IncludeDataPort)
|
if (IncludeDataPort)
|
||||||
{
|
{
|
||||||
DeviceRelations->Objects[i++] = FdoExt->DataPortPdo;
|
DeviceRelations->Objects[i++] = FdoExt->ReadPortPdo;
|
||||||
ObReferenceObject(FdoExt->DataPortPdo);
|
ObReferenceObject(FdoExt->ReadPortPdo);
|
||||||
}
|
}
|
||||||
|
|
||||||
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, DeviceLink);
|
||||||
|
|
||||||
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 = 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;
|
||||||
PdoExt->FdoExt = FdoExt;
|
PdoExt->FdoExt = FdoExt;
|
||||||
|
|
||||||
Status = IsaFdoCreateDeviceIDs(PdoExt);
|
Status = IsaFdoCreateDeviceIDs(PdoExt);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
Status = IsaFdoCreateRequirements(PdoExt);
|
Status = IsaPnpCreateLogicalDeviceRequirements(PdoExt);
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
Status = IsaFdoCreateResources(PdoExt);
|
Status = IsaPnpCreateLogicalDeviceResources(PdoExt);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
IoDeleteDevice(IsaDevice->Pdo);
|
IoDeleteDevice(IsaDevice->Pdo);
|
||||||
IsaDevice->Pdo = NULL;
|
IsaDevice->Pdo = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviceRelations->Objects[i++] = IsaDevice->Pdo;
|
DeviceRelations->Objects[i++] = IsaDevice->Pdo;
|
||||||
|
|
||||||
ObReferenceObject(IsaDevice->Pdo);
|
ObReferenceObject(IsaDevice->Pdo);
|
||||||
|
|
||||||
CurrentEntry = CurrentEntry->Flink;
|
CurrentEntry = CurrentEntry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceRelations->Count = i;
|
DeviceRelations->Count = i;
|
||||||
|
@ -495,7 +512,6 @@ IsaPnpFillDeviceRelations(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static IO_COMPLETION_ROUTINE ForwardIrpCompletion;
|
static IO_COMPLETION_ROUTINE ForwardIrpCompletion;
|
||||||
|
|
||||||
static
|
static
|
||||||
|
@ -539,14 +555,16 @@ IsaForwardIrpSynchronous(
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Dispatch_type_(IRP_MJ_CREATE)
|
||||||
|
_Dispatch_type_(IRP_MJ_CLOSE)
|
||||||
static DRIVER_DISPATCH IsaCreateClose;
|
static DRIVER_DISPATCH IsaCreateClose;
|
||||||
|
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaCreateClose(
|
IsaCreateClose(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
_Inout_ PIRP Irp)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||||
Irp->IoStatus.Information = FILE_OPENED;
|
Irp->IoStatus.Information = FILE_OPENED;
|
||||||
|
@ -609,15 +627,16 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnpCreateReadPortDORequirements(
|
IsaPnpCreateReadPortDORequirements(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt)
|
_In_ PISAPNP_PDO_EXTENSION PdoExt)
|
||||||
{
|
{
|
||||||
USHORT Ports[] = { ISAPNP_WRITE_DATA, ISAPNP_ADDRESS, 0x274, 0x3e4, 0x204, 0x2e4, 0x354, 0x2f4 };
|
|
||||||
ULONG ListSize, i;
|
ULONG ListSize, i;
|
||||||
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
|
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
|
||||||
PIO_RESOURCE_DESCRIPTOR Descriptor;
|
PIO_RESOURCE_DESCRIPTOR Descriptor;
|
||||||
|
const ULONG Ports[] = { ISAPNP_WRITE_DATA, ISAPNP_ADDRESS,
|
||||||
|
0x274, 0x3E4, 0x204, 0x2E4, 0x354, 0x2F4 };
|
||||||
|
|
||||||
ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST)
|
ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST)
|
||||||
+ 2 * ARRAYSIZE(Ports) * sizeof(IO_RESOURCE_DESCRIPTOR);
|
+ 2 * RTL_NUMBER_OF(Ports) * sizeof(IO_RESOURCE_DESCRIPTOR);
|
||||||
RequirementsList = ExAllocatePool(PagedPool, ListSize);
|
RequirementsList = ExAllocatePool(PagedPool, ListSize);
|
||||||
if (!RequirementsList)
|
if (!RequirementsList)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
@ -628,9 +647,9 @@ IsaPnpCreateReadPortDORequirements(
|
||||||
|
|
||||||
RequirementsList->List[0].Version = 1;
|
RequirementsList->List[0].Version = 1;
|
||||||
RequirementsList->List[0].Revision = 1;
|
RequirementsList->List[0].Revision = 1;
|
||||||
RequirementsList->List[0].Count = 2 * ARRAYSIZE(Ports);
|
RequirementsList->List[0].Count = 2 * RTL_NUMBER_OF(Ports);
|
||||||
|
|
||||||
for (i = 0; i < 2 * ARRAYSIZE(Ports); i += 2)
|
for (i = 0; i < 2 * RTL_NUMBER_OF(Ports); i += 2)
|
||||||
{
|
{
|
||||||
Descriptor = &RequirementsList->List[0].Descriptors[i];
|
Descriptor = &RequirementsList->List[0].Descriptors[i];
|
||||||
|
|
||||||
|
@ -659,15 +678,15 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnpCreateReadPortDOResources(
|
IsaPnpCreateReadPortDOResources(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt)
|
_In_ PISAPNP_PDO_EXTENSION PdoExt)
|
||||||
{
|
{
|
||||||
USHORT Ports[] = { ISAPNP_WRITE_DATA, ISAPNP_ADDRESS };
|
const USHORT Ports[] = { ISAPNP_WRITE_DATA, ISAPNP_ADDRESS };
|
||||||
ULONG ListSize, i;
|
ULONG ListSize, i;
|
||||||
PCM_RESOURCE_LIST ResourceList;
|
PCM_RESOURCE_LIST ResourceList;
|
||||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
|
PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor;
|
||||||
|
|
||||||
ListSize = sizeof(CM_RESOURCE_LIST)
|
ListSize = sizeof(CM_RESOURCE_LIST) +
|
||||||
+ (ARRAYSIZE(Ports) - 1) * sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
|
sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR) * (RTL_NUMBER_OF(Ports) - 1);
|
||||||
ResourceList = ExAllocatePool(PagedPool, ListSize);
|
ResourceList = ExAllocatePool(PagedPool, ListSize);
|
||||||
if (!ResourceList)
|
if (!ResourceList)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
@ -677,9 +696,9 @@ IsaPnpCreateReadPortDOResources(
|
||||||
ResourceList->List[0].InterfaceType = Internal;
|
ResourceList->List[0].InterfaceType = Internal;
|
||||||
ResourceList->List[0].PartialResourceList.Version = 1;
|
ResourceList->List[0].PartialResourceList.Version = 1;
|
||||||
ResourceList->List[0].PartialResourceList.Revision = 1;
|
ResourceList->List[0].PartialResourceList.Revision = 1;
|
||||||
ResourceList->List[0].PartialResourceList.Count = 2;
|
ResourceList->List[0].PartialResourceList.Count = RTL_NUMBER_OF(Ports);
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(Ports); i++)
|
for (i = 0; i < RTL_NUMBER_OF(Ports); i++)
|
||||||
{
|
{
|
||||||
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
|
Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
|
||||||
Descriptor->Type = CmResourceTypePort;
|
Descriptor->Type = CmResourceTypePort;
|
||||||
|
@ -697,28 +716,30 @@ IsaPnpCreateReadPortDOResources(
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnpCreateReadPortDO(PISAPNP_FDO_EXTENSION FdoExt)
|
IsaPnpCreateReadPortDO(
|
||||||
|
_In_ PISAPNP_FDO_EXTENSION FdoExt)
|
||||||
{
|
{
|
||||||
UNICODE_STRING DeviceID = RTL_CONSTANT_STRING(L"ISAPNP\\ReadDataPort\0");
|
UNICODE_STRING DeviceID = RTL_CONSTANT_STRING(L"ISAPNP\\ReadDataPort\0");
|
||||||
UNICODE_STRING HardwareIDs = RTL_CONSTANT_STRING(L"ISAPNP\\ReadDataPort\0\0");
|
UNICODE_STRING HardwareIDs = RTL_CONSTANT_STRING(L"ISAPNP\\ReadDataPort\0\0");
|
||||||
UNICODE_STRING CompatibleIDs = RTL_CONSTANT_STRING(L"\0\0");
|
UNICODE_STRING CompatibleIDs = RTL_CONSTANT_STRING(L"\0\0");
|
||||||
UNICODE_STRING InstanceID = RTL_CONSTANT_STRING(L"0\0");
|
UNICODE_STRING InstanceID = RTL_CONSTANT_STRING(L"0\0");
|
||||||
PISAPNP_PDO_EXTENSION PdoExt;
|
PISAPNP_PDO_EXTENSION PdoExt;
|
||||||
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
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_DEVICE_SECURE_OPEN,
|
||||||
FALSE,
|
FALSE,
|
||||||
&FdoExt->DataPortPdo);
|
&FdoExt->ReadPortPdo);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
PdoExt = (PISAPNP_PDO_EXTENSION)FdoExt->DataPortPdo->DeviceExtension;
|
|
||||||
|
PdoExt = FdoExt->ReadPortPdo->DeviceExtension;
|
||||||
RtlZeroMemory(PdoExt, sizeof(ISAPNP_PDO_EXTENSION));
|
RtlZeroMemory(PdoExt, sizeof(ISAPNP_PDO_EXTENSION));
|
||||||
PdoExt->Common.IsFdo = FALSE;
|
PdoExt->Common.IsFdo = FALSE;
|
||||||
PdoExt->Common.Self = FdoExt->DataPortPdo;
|
PdoExt->Common.Self = FdoExt->ReadPortPdo;
|
||||||
PdoExt->Common.State = dsStopped;
|
PdoExt->Common.State = dsStopped;
|
||||||
PdoExt->FdoExt = FdoExt;
|
PdoExt->FdoExt = FdoExt;
|
||||||
|
|
||||||
|
@ -761,8 +782,8 @@ 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;
|
||||||
|
@ -779,7 +800,7 @@ IsaAddDevice(
|
||||||
&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%08lx)\n", Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,17 +823,19 @@ IsaAddDevice(
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
FdoExt->DataPortPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
FdoExt->ReadPortPdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Dispatch_type_(IRP_MJ_POWER)
|
||||||
DRIVER_DISPATCH IsaPower;
|
DRIVER_DISPATCH IsaPower;
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPower(
|
IsaPower(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
_Inout_ PIRP Irp)
|
||||||
{
|
{
|
||||||
PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
|
PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -829,14 +852,15 @@ IsaPower(
|
||||||
return PoCallDriver(((PISAPNP_FDO_EXTENSION)DevExt)->Ldo, Irp);
|
return PoCallDriver(((PISAPNP_FDO_EXTENSION)DevExt)->Ldo, Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_Dispatch_type_(IRP_MJ_PNP)
|
||||||
static DRIVER_DISPATCH IsaPnp;
|
static DRIVER_DISPATCH IsaPnp;
|
||||||
|
|
||||||
static
|
static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnp(
|
IsaPnp(
|
||||||
IN PDEVICE_OBJECT DeviceObject,
|
_In_ PDEVICE_OBJECT DeviceObject,
|
||||||
IN PIRP Irp)
|
_Inout_ 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;
|
||||||
|
@ -844,24 +868,16 @@ IsaPnp(
|
||||||
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, Irp, IrpSp);
|
||||||
return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt,
|
|
||||||
Irp,
|
|
||||||
IrpSp);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt, Irp, IrpSp);
|
||||||
return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt,
|
|
||||||
Irp,
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS ISA PnP Bus driver
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: Common header file
|
||||||
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
||||||
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _ISAPNP_PCH_
|
#ifndef _ISAPNP_PCH_
|
||||||
#define _ISAPNP_PCH_
|
#define _ISAPNP_PCH_
|
||||||
|
|
||||||
#include <wdm.h>
|
#include <wdm.h>
|
||||||
#include <ntstrsafe.h>
|
#include <ntstrsafe.h>
|
||||||
#include <isapnphw.h>
|
#include "isapnphw.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -11,28 +19,33 @@ 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_IO {
|
typedef struct _ISAPNP_IO
|
||||||
|
{
|
||||||
USHORT CurrentBase;
|
USHORT CurrentBase;
|
||||||
ISAPNP_IO_DESCRIPTION Description;
|
ISAPNP_IO_DESCRIPTION Description;
|
||||||
} ISAPNP_IO, PISAPNP_IO;
|
} ISAPNP_IO, *PISAPNP_IO;
|
||||||
|
|
||||||
typedef struct _ISAPNP_IRQ {
|
typedef struct _ISAPNP_IRQ
|
||||||
|
{
|
||||||
UCHAR CurrentNo;
|
UCHAR CurrentNo;
|
||||||
UCHAR CurrentType;
|
UCHAR CurrentType;
|
||||||
ISAPNP_IRQ_DESCRIPTION Description;
|
ISAPNP_IRQ_DESCRIPTION Description;
|
||||||
} ISAPNP_IRQ, *PISAPNP_IRQ;
|
} ISAPNP_IRQ, *PISAPNP_IRQ;
|
||||||
|
|
||||||
typedef struct _ISAPNP_DMA {
|
typedef struct _ISAPNP_DMA
|
||||||
|
{
|
||||||
UCHAR CurrentChannel;
|
UCHAR CurrentChannel;
|
||||||
ISAPNP_DMA_DESCRIPTION Description;
|
ISAPNP_DMA_DESCRIPTION Description;
|
||||||
} ISAPNP_DMA, *PISAPNP_DMA;
|
} ISAPNP_DMA, *PISAPNP_DMA;
|
||||||
|
|
||||||
typedef struct _ISAPNP_LOGICAL_DEVICE {
|
typedef struct _ISAPNP_LOGICAL_DEVICE
|
||||||
|
{
|
||||||
PDEVICE_OBJECT Pdo;
|
PDEVICE_OBJECT Pdo;
|
||||||
ISAPNP_LOGDEVID LogDevId;
|
ISAPNP_LOGDEVID LogDevId;
|
||||||
UCHAR VendorId[3];
|
UCHAR VendorId[3];
|
||||||
|
@ -43,20 +56,22 @@ typedef struct _ISAPNP_LOGICAL_DEVICE {
|
||||||
ISAPNP_DMA Dma[2];
|
ISAPNP_DMA Dma[2];
|
||||||
UCHAR CSN;
|
UCHAR CSN;
|
||||||
UCHAR LDN;
|
UCHAR LDN;
|
||||||
LIST_ENTRY ListEntry;
|
LIST_ENTRY DeviceLink;
|
||||||
} 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;
|
||||||
PDEVICE_OBJECT DataPortPdo;
|
PDEVICE_OBJECT ReadPortPdo;
|
||||||
LIST_ENTRY DeviceListHead;
|
LIST_ENTRY DeviceListHead;
|
||||||
ULONG DeviceCount;
|
ULONG DeviceCount;
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
@ -64,7 +79,8 @@ typedef struct _ISAPNP_FDO_EXTENSION {
|
||||||
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;
|
||||||
PISAPNP_FDO_EXTENSION FdoExt;
|
PISAPNP_FDO_EXTENSION FdoExt;
|
||||||
|
@ -92,60 +108,54 @@ IsaPnpDuplicateUnicodeString(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPnpFillDeviceRelations(
|
IsaPnpFillDeviceRelations(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN BOOLEAN IncludeDataPort);
|
_In_ BOOLEAN IncludeDataPort);
|
||||||
|
|
||||||
DRIVER_INITIALIZE DriverEntry;
|
DRIVER_INITIALIZE DriverEntry;
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
DriverEntry(
|
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
|
||||||
IN PUNICODE_STRING RegistryPath);
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaForwardIrpSynchronous(
|
IsaForwardIrpSynchronous(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIRP Irp);
|
_Inout_ 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,
|
_Inout_ 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,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp);
|
_In_ PIO_STACK_LOCATION IrpSp);
|
||||||
|
|
||||||
/* hardware.c */
|
/* hardware.c */
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaHwTryReadDataPort(
|
IsaHwTryReadDataPort(
|
||||||
IN PUCHAR ReadDataPort);
|
_In_ PUCHAR ReadDataPort);
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS ISA PnP Bus driver
|
||||||
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
|
* PURPOSE: Hardware definitions
|
||||||
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
||||||
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -83,20 +91,23 @@ extern "C" {
|
||||||
#define ISAPNP_TAG_RSVDLONGF 0xFF
|
#define ISAPNP_TAG_RSVDLONGF 0xFF
|
||||||
#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;
|
||||||
|
@ -104,23 +115,26 @@ typedef struct _ISAPNP_DEVICEID {
|
||||||
|
|
||||||
#include <pshpack1.h>
|
#include <pshpack1.h>
|
||||||
|
|
||||||
typedef struct _ISAPNP_IO_DESCRIPTION {
|
typedef struct _ISAPNP_IO_DESCRIPTION
|
||||||
|
{
|
||||||
UCHAR Information;
|
UCHAR Information;
|
||||||
USHORT Minimum;
|
USHORT Minimum;
|
||||||
USHORT Maximum;
|
USHORT Maximum;
|
||||||
UCHAR Alignment;
|
UCHAR Alignment;
|
||||||
UCHAR Length;
|
UCHAR Length;
|
||||||
} ISAPNP_IO_DESCRIPTION;
|
} ISAPNP_IO_DESCRIPTION, *PISAPNP_IO_DESCRIPTION;
|
||||||
|
|
||||||
typedef struct _ISAPNP_IRQ_DESCRIPTION {
|
typedef struct _ISAPNP_IRQ_DESCRIPTION
|
||||||
|
{
|
||||||
USHORT Mask;
|
USHORT Mask;
|
||||||
UCHAR Information;
|
UCHAR Information;
|
||||||
} ISAPNP_IRQ_DESCRIPTION;
|
} ISAPNP_IRQ_DESCRIPTION, *PISAPNP_IRQ_DESCRIPTION;
|
||||||
|
|
||||||
typedef struct _ISAPNP_DMA_DESCRIPTION {
|
typedef struct _ISAPNP_DMA_DESCRIPTION
|
||||||
|
{
|
||||||
UCHAR Mask;
|
UCHAR Mask;
|
||||||
UCHAR Information;
|
UCHAR Information;
|
||||||
} ISAPNP_DMA_DESCRIPTION;
|
} ISAPNP_DMA_DESCRIPTION, *PISAPNP_DMA_DESCRIPTION;
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS ISA PnP Bus driver
|
* PROJECT: ReactOS ISA PnP Bus driver
|
||||||
* FILE: pdo.c
|
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||||
* PURPOSE: PDO-specific code
|
* PURPOSE: PDO-specific code
|
||||||
* PROGRAMMERS: Cameron Gutman (cameron.gutman@reactos.org)
|
* COPYRIGHT: Copyright 2010 Cameron Gutman <cameron.gutman@reactos.org>
|
||||||
* Hervé Poussineau
|
* Copyright 2020 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <isapnp.h>
|
#include "isapnp.h"
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -14,14 +14,14 @@
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryDeviceRelations(
|
IsaPdoQueryDeviceRelations(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PDEVICE_RELATIONS DeviceRelations;
|
PDEVICE_RELATIONS DeviceRelations;
|
||||||
|
|
||||||
if (IrpSp->Parameters.QueryDeviceRelations.Type == RemovalRelations &&
|
if (IrpSp->Parameters.QueryDeviceRelations.Type == RemovalRelations &&
|
||||||
PdoExt->Common.Self == PdoExt->FdoExt->DataPortPdo)
|
PdoExt->Common.Self == PdoExt->FdoExt->ReadPortPdo)
|
||||||
{
|
{
|
||||||
return IsaPnpFillDeviceRelations(PdoExt->FdoExt, Irp, FALSE);
|
return IsaPnpFillDeviceRelations(PdoExt->FdoExt, Irp, FALSE);
|
||||||
}
|
}
|
||||||
|
@ -38,16 +38,15 @@ IsaPdoQueryDeviceRelations(
|
||||||
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,
|
_Inout_ 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;
|
||||||
|
@ -79,9 +78,9 @@ IsaPdoQueryCapabilities(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryPnpDeviceState(
|
IsaPdoQueryPnpDeviceState(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
|
Irp->IoStatus.Information |= PNP_DEVICE_NOT_DISABLEABLE;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -90,9 +89,9 @@ IsaPdoQueryPnpDeviceState(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryId(
|
IsaPdoQueryId(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PUNICODE_STRING Source;
|
PUNICODE_STRING Source;
|
||||||
PWCHAR Buffer;
|
PWCHAR Buffer;
|
||||||
|
@ -140,9 +139,9 @@ IsaPdoQueryId(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryResources(
|
IsaPdoQueryResources(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
ULONG ListSize;
|
ULONG ListSize;
|
||||||
PCM_RESOURCE_LIST ResourceList;
|
PCM_RESOURCE_LIST ResourceList;
|
||||||
|
@ -163,9 +162,9 @@ IsaPdoQueryResources(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoQueryResourceRequirements(
|
IsaPdoQueryResourceRequirements(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
ULONG ListSize;
|
ULONG ListSize;
|
||||||
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
|
PIO_RESOURCE_REQUIREMENTS_LIST RequirementsList;
|
||||||
|
@ -187,8 +186,8 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoStartReadPort(
|
IsaPdoStartReadPort(
|
||||||
IN PISAPNP_FDO_EXTENSION FdoExt,
|
_In_ PISAPNP_FDO_EXTENSION FdoExt,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
PCM_RESOURCE_LIST ResourceList = IrpSp->Parameters.StartDevice.AllocatedResources;
|
PCM_RESOURCE_LIST ResourceList = IrpSp->Parameters.StartDevice.AllocatedResources;
|
||||||
NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
|
NTSTATUS Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
@ -197,24 +196,32 @@ IsaPdoStartReadPort(
|
||||||
|
|
||||||
if (!ResourceList || ResourceList->Count != 1)
|
if (!ResourceList || ResourceList->Count != 1)
|
||||||
{
|
{
|
||||||
DPRINT1("No resource list (%p) or bad count (%d)\n", ResourceList, ResourceList ? ResourceList->Count : 0);
|
DPRINT1("No resource list (%p) or bad count (%d)\n",
|
||||||
|
ResourceList, ResourceList ? ResourceList->Count : 0);
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
if (ResourceList->List[0].PartialResourceList.Version != 1
|
|
||||||
|| ResourceList->List[0].PartialResourceList.Revision != 1)
|
if (ResourceList->List[0].PartialResourceList.Version != 1 ||
|
||||||
|
ResourceList->List[0].PartialResourceList.Revision != 1)
|
||||||
{
|
{
|
||||||
DPRINT1("Bad resource list version (%d.%d)\n", ResourceList->List[0].PartialResourceList.Version, ResourceList->List[0].PartialResourceList.Revision);
|
DPRINT1("Bad resource list version (%u.%u)\n",
|
||||||
|
ResourceList->List[0].PartialResourceList.Version,
|
||||||
|
ResourceList->List[0].PartialResourceList.Revision);
|
||||||
return STATUS_REVISION_MISMATCH;
|
return STATUS_REVISION_MISMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++)
|
for (i = 0; i < ResourceList->List[0].PartialResourceList.Count; i++)
|
||||||
{
|
{
|
||||||
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
|
PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor =
|
||||||
if (PartialDescriptor->Type == CmResourceTypePort && PartialDescriptor->u.Port.Length > 1 && !FdoExt->ReadDataPort)
|
&ResourceList->List[0].PartialResourceList.PartialDescriptors[i];
|
||||||
|
|
||||||
|
if (PartialDescriptor->Type == CmResourceTypePort &&
|
||||||
|
PartialDescriptor->u.Port.Length > 1 && !FdoExt->ReadDataPort)
|
||||||
{
|
{
|
||||||
PUCHAR ReadDataPort = ULongToPtr(PartialDescriptor->u.Port.Start.u.LowPart + 3);
|
PUCHAR ReadDataPort = ULongToPtr(PartialDescriptor->u.Port.Start.u.LowPart + 3);
|
||||||
if (NT_SUCCESS(IsaHwTryReadDataPort(ReadDataPort)))
|
if (NT_SUCCESS(IsaHwTryReadDataPort(ReadDataPort)))
|
||||||
{
|
{
|
||||||
/* we detected some ISAPNP cards */
|
/* We detected some ISAPNP cards */
|
||||||
FdoExt->ReadDataPort = ReadDataPort;
|
FdoExt->ReadDataPort = ReadDataPort;
|
||||||
KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
|
KeAcquireSpinLock(&FdoExt->Lock, &OldIrql);
|
||||||
Status = IsaHwFillDeviceList(FdoExt);
|
Status = IsaHwFillDeviceList(FdoExt);
|
||||||
|
@ -222,16 +229,17 @@ IsaPdoStartReadPort(
|
||||||
if (FdoExt->DeviceCount > 0)
|
if (FdoExt->DeviceCount > 0)
|
||||||
{
|
{
|
||||||
IoInvalidateDeviceRelations(FdoExt->Pdo, BusRelations);
|
IoInvalidateDeviceRelations(FdoExt->Pdo, BusRelations);
|
||||||
IoInvalidateDeviceRelations(FdoExt->DataPortPdo, RemovalRelations);
|
IoInvalidateDeviceRelations(FdoExt->ReadPortPdo, RemovalRelations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* mark read data port as started, even if no card has been detected */
|
/* Mark read data port as started, even if no card has been detected */
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,8 +247,8 @@ static
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoOnRepeaterComplete(
|
IsaPdoOnRepeaterComplete(
|
||||||
IN PDEVICE_OBJECT Tdo,
|
PDEVICE_OBJECT Tdo,
|
||||||
IN PIRP SubIrp,
|
PIRP SubIrp,
|
||||||
PVOID NeedsVote)
|
PVOID NeedsVote)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION SubStack = IoGetCurrentIrpStackLocation(SubIrp);
|
PIO_STACK_LOCATION SubStack = IoGetCurrentIrpStackLocation(SubIrp);
|
||||||
|
@ -267,13 +275,12 @@ IsaPdoOnRepeaterComplete(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoRepeatRequest(
|
IsaPdoRepeatRequest(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_In_ PIRP Irp,
|
||||||
IN BOOLEAN NeedsVote)
|
_In_ BOOLEAN NeedsVote)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT Fdo = PdoExt->FdoExt->Common.Self;
|
PDEVICE_OBJECT Fdo = PdoExt->FdoExt->Common.Self;
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
PDEVICE_OBJECT Tdo = IoGetAttachedDeviceReference(Fdo);
|
PDEVICE_OBJECT Tdo = IoGetAttachedDeviceReference(Fdo);
|
||||||
PIRP SubIrp = IoAllocateIrp(Tdo->StackSize + 1, FALSE);
|
PIRP SubIrp = IoAllocateIrp(Tdo->StackSize + 1, FALSE);
|
||||||
PIO_STACK_LOCATION SubStack = IoGetNextIrpStackLocation(SubIrp);
|
PIO_STACK_LOCATION SubStack = IoGetNextIrpStackLocation(SubIrp);
|
||||||
|
@ -290,15 +297,16 @@ IsaPdoRepeatRequest(
|
||||||
SubIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
SubIrp->IoStatus.Status = STATUS_NOT_SUPPORTED;
|
||||||
IoMarkIrpPending(Irp);
|
IoMarkIrpPending(Irp);
|
||||||
IoCallDriver(Tdo, SubIrp);
|
IoCallDriver(Tdo, SubIrp);
|
||||||
|
|
||||||
return STATUS_PENDING;
|
return STATUS_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
IsaPdoPnp(
|
IsaPdoPnp(
|
||||||
IN PISAPNP_PDO_EXTENSION PdoExt,
|
_In_ PISAPNP_PDO_EXTENSION PdoExt,
|
||||||
IN PIRP Irp,
|
_Inout_ PIRP Irp,
|
||||||
IN PIO_STACK_LOCATION IrpSp)
|
_In_ PIO_STACK_LOCATION IrpSp)
|
||||||
{
|
{
|
||||||
NTSTATUS Status = Irp->IoStatus.Status;
|
NTSTATUS Status = Irp->IoStatus.Status;
|
||||||
|
|
||||||
|
@ -333,7 +341,7 @@ IsaPdoPnp(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IRP_MN_QUERY_PNP_DEVICE_STATE:
|
case IRP_MN_QUERY_PNP_DEVICE_STATE:
|
||||||
if (PdoExt->Common.Self == PdoExt->FdoExt->DataPortPdo)
|
if (PdoExt->Common.Self == PdoExt->FdoExt->ReadPortPdo)
|
||||||
Status = IsaPdoQueryPnpDeviceState(PdoExt, Irp, IrpSp);
|
Status = IsaPdoQueryPnpDeviceState(PdoExt, Irp, IrpSp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue