18#pragma warning(disable:28138)
322 UCHAR NextLfsr = Lfsr >> 1;
324 NextLfsr |= (((Lfsr ^ NextLfsr) ^ InputBit)) << 7;
342 for (
i = 0;
i < 32;
i++)
359 for (
i = 0;
i < 20;
i++)
425 Buffer[0] = ((CompressedData >> 2) & 0x1F) +
'A' - 1;
426 Buffer[1] = (((CompressedData & 0x3) << 3) | ((CompressedData >> 13) & 0x7)) +
'A' - 1;
427 Buffer[2] = ((CompressedData >> 8) & 0x1F) +
'A' - 1;
445 *MaxTagsPerDevice = 0;
456 DPRINT(
"Too small tag\n");
478 if (MaxLength <
sizeof(Temp))
480 DPRINT(
"Too small tag\n");
484 Peek(ReadDataPort, &Temp,
sizeof(Temp));
487 MaxLength -=
sizeof(Temp);
489 TagLen = Temp[0] + (Temp[1] << 8);
493 if (
Tag == 0xFF && TagLen == 0xFFFF)
499 if (TagLen > MaxLength)
501 DPRINT(
"Too large resource data structure\n");
512 *MaxTagsPerDevice =
max(*MaxTagsPerDevice, TagCount);
519 *MaxTagsPerDevice =
max(*MaxTagsPerDevice, TagCount);
537 if (LogDevice->FriendlyName)
540 if (LogDevice->Resources)
543 Entry = LogDevice->CompatibleIdList.Flink;
544 while (
Entry != &LogDevice->CompatibleIdList)
577 LogDev = LogDevToParse + 1;
584 Tag = *ResourceData++;
593 TagLen = *ResourceData++;
594 TagLen += *ResourceData++ << 8;
615 ResourceData += TagLen;
617 DPRINT(
"Found tag 0x%X (len %u)\n"
645 ResourceData += TagLen;
647 DPRINT(
"Found tag 0x%X (len %u)\n"
681 ResourceData += TagLen;
686 DPRINT(
"Found tag 0x%X (len %u)\n"
688 " Information 0x%X\n",
714 ResourceData += TagLen;
716 DPRINT(
"Found tag 0x%X (len %u)\n"
718 " Information 0x%X\n",
756 ResourceData += TagLen;
759 DPRINT(
"*** Start dependent set, priority %u ***\n",
775 ResourceData += TagLen;
777 DPRINT(
"*** End of dependent set ***\n");
800 ResourceData += TagLen;
802 DPRINT(
"Found tag 0x%X (len %u)\n"
803 " Information 0x%X\n"
837 ResourceData += TagLen;
840 Temp.
IoBase &= ((1 << 10) - 1);
848 DPRINT(
"Found tag 0x%X (len %u)\n"
867 if (!LogDevice->FriendlyName)
872 End = LogDevice->FriendlyName + IdStrLen - 1;
873 while (End > LogDevice->FriendlyName && *End ==
' ')
906 ResourceData += TagLen;
908 DPRINT(
"Found tag 0x%X (len %u)\n"
909 " Information 0x%X\n"
927 if (LogDev == LogDevToParse + 1 || LogDev == 0)
929 IdStrPos = ResourceData;
932 ResourceData += TagLen;
934 DPRINT(
"Found tag 0x%X (len %u)\n"
969 ResourceData += TagLen;
971 DPRINT(
"Found tag 0x%X (len %u)\n"
972 " Information 0x%X\n"
975 " Alignment 0x%08lX\n"
1009 ResourceData += TagLen;
1017 DPRINT(
"Found tag 0x%X (len %u)\n"
1018 " Information 0x%X\n"
1019 " MemoryBase 0x%08lX\n"
1020 " Length 0x%08lX\n",
1033 DPRINT(
"Found unknown tag 0x%X (len %u)\n",
Tag, TagLen);
1037 ResourceData += TagLen;
1062 LogDevice->Flags &= ~ISAPNP_HAS_RESOURCES;
1068 LogDevice->Io[
i].CurrentBase =
ReadIoBase(ReadDataPort,
i);
1071 if (!LogDevice->Io[
i].CurrentBase)
1076 LogDevice->Irq[
i].CurrentNo =
ReadIrqNo(ReadDataPort,
i);
1078 if (!LogDevice->Irq[
i].CurrentNo)
1081 LogDevice->Irq[
i].CurrentType =
ReadIrqType(ReadDataPort,
i);
1094 if (!LogDevice->MemRange[
i].CurrentBase)
1101 LogDevice->MemRange[
i].CurrentLength -= LogDevice->MemRange[
i].CurrentBase;
1105 LogDevice->MemRange[
i].CurrentLength =
1113 if (!LogDevice->MemRange32[
i].CurrentBase)
1120 LogDevice->MemRange32[
i].CurrentLength -= LogDevice->MemRange32[
i].CurrentBase;
1124 LogDevice->MemRange32[
i].CurrentLength =
1193 UCHAR MemoryControl;
1201 if (
Descriptor->u.Memory.Start.LowPart & 0xFF)
1256 ULONG NumberOfRead = 0;
1261 DPRINT(
"Setting read data port: 0x%p\n", ReadDataPort);
1319 DPRINT(
"Bad checksum\n");
1325 DPRINT(
"Saw no sign of life\n");
1339 if (NumberOfRead == 1)
1341 DPRINT(
"Trying next read data port\n");
1346 DPRINT(
"Found %u cards at read port 0x%p\n", Csn, ReadDataPort);
1363 ASSERT(FdoExt->ReadDataPort);
1370 DPRINT1(
"Failed to allocate memory for cache data\n");
1374 for (
Entry = FdoExt->DeviceListHead.Flink;
1375 Entry != &FdoExt->DeviceListHead;
1380 LogDevice->
Flags &= ~ISAPNP_PRESENT;
1383 for (Csn = 1; Csn <= FdoExt->Cards; Csn++)
1386 UCHAR TempId[3], LogDev;
1388 ULONG MaxTagsPerDevice;
1405 DPRINT1(
"Failed to read tags with status 0x%08lx, CSN %u\n",
Status, Csn);
1409 DPRINT(
"Detected ISA PnP device - VID: '%.3s' PID: 0x%04x SN: 0x%08lX\n",
1412 for (LogDev = 0; LogDev < MaxLogDev; LogDev++)
1417 for (
Entry = FdoExt->DeviceListHead.Flink;
1418 Entry != &FdoExt->DeviceListHead;
1427 (LogDevice->
LDN == LogDev))
1432 LogDevice->
CSN = Csn;
1442 DPRINT(
"Skip CSN %u, LDN %u\n", LogDevice->
CSN, LogDevice->
LDN);
1443 IsAlreadyEnumerated =
TRUE;
1449 if (IsAlreadyEnumerated)
1455 DPRINT1(
"Failed to allocate logical device!\n");
1461 LogDevice->
CSN = Csn;
1462 LogDevice->
LDN = LogDev;
1469 DPRINT1(
"Failed to allocate the resources array\n");
1477 DPRINT1(
"Failed to parse tags with status 0x%08lx, CSN %u, LDN %u\n",
1484 DPRINT(
"Unable to read boot resources\n");
1496 FdoExt->DeviceCount++;
1517 UCHAR NumberOfIo = 0,
1521 NumberOfMemory32 = 0;
1530 for (
i = 0;
i <
Resources->List[0].PartialResourceList.Count;
i++)
1533 &
Resources->List[0].PartialResourceList.PartialDescriptors[
i];
1570 if ((NumberOfMemory + NumberOfMemory32) >=
RTL_NUMBER_OF(LogicalDevice->MemRange))
1590 Index = NumberOfMemory32++;
1592 Index = NumberOfMemory++;
1630 for (
i = NumberOfMemory32;
i <
RTL_NUMBER_OF(LogicalDevice->MemRange32);
i++)
1650 Wake(LogicalDevice->CSN);
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
#define _Requires_lock_held_(lock)
#define NT_SUCCESS(StatCode)
static const WCHAR Description[]
static VOID WriteDoubleWord(_In_ UCHAR Address, _In_ ULONG Value)
static ULONG ReadDoubleWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
static VOID SetReadDataPort(_In_ PUCHAR ReadDataPort)
VOID IsaHwWakeDevice(_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
static VOID SendKey(VOID)
static NTSTATUS ParseTags(_In_ PUCHAR ResourceData, _In_ USHORT LogDevToParse, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
static USHORT ReadMemoryLimit(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static USHORT ReadIoBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static UCHAR ReadIrqType(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static USHORT ReadWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
static VOID Peek(_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
static VOID IsaProgramIrqSelect(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
static VOID WriteCsn(_In_ UCHAR Csn)
static VOID ActivateDevice(_In_ PUCHAR ReadDataPort, _In_ UCHAR LogDev)
VOID IsaHwWaitForKey(VOID)
static UCHAR ReadIrqNo(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static VOID IsaProgramDmaSelect(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
static VOID FreeLogicalDevice(_In_ __drv_freesMem(Mem) PISAPNP_LOGICAL_DEVICE LogDevice)
static VOID WriteByte(_In_ UCHAR Address, _In_ UCHAR Value)
static UCHAR ReadMemoryControl(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
VOID IsaHwDeactivateDevice(_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
static UCHAR ReadByte(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
static VOID EnterIsolationState(VOID)
UCHAR IsaHwTryReadDataPort(_In_ PUCHAR ReadDataPort)
static ULONG ReadMemoryBase32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
static VOID IsaProgramIoDecoder(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
static UCHAR NextLFSR(_In_ UCHAR Lfsr, _In_ UCHAR InputBit)
static VOID DeactivateDevice(_In_ UCHAR LogDev)
static VOID WriteLogicalDeviceNumber(_In_ UCHAR LogDev)
static UCHAR ReadMemoryControl32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static VOID WriteAddress(_In_ UCHAR Address)
static VOID Wake(_In_ UCHAR Csn)
static UCHAR ReadResourceData(_In_ PUCHAR ReadDataPort)
static VOID WriteWord(_In_ UCHAR Address, _In_ USHORT Value)
static ULONG ReadMemoryLimit32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static NTSTATUS IsaProgramMemoryDecoder(_In_ PUCHAR ReadDataPort, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ BOOLEAN IsMemory32, _In_ UCHAR Information, _In_ UCHAR Index)
static VOID IsaPnpExtractAscii(_Out_writes_all_(3) PUCHAR Buffer, _In_ USHORT CompressedData)
static USHORT ReadMemoryBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static UCHAR ReadDmaChannel(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
static VOID WaitForKey(VOID)
static NTSTATUS ReadTags(_In_ PUCHAR ReadDataPort, _Out_writes_(ISAPNP_MAX_RESOURCEDATA) PUCHAR Buffer, _In_ ULONG MaxLength, _Out_ PUSHORT MaxLogDev, _Out_ PULONG MaxTagsPerDevice)
NTSTATUS IsaHwConfigureDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice, _In_ PCM_RESOURCE_LIST Resources)
static UCHAR PeekByte(_In_ PUCHAR ReadDataPort)
VOID IsaHwActivateDevice(_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
static UCHAR IsaPnpChecksum(_In_ PISAPNP_IDENTIFIER Identifier)
static BOOLEAN ReadCurrentResources(_In_ PUCHAR ReadDataPort, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
static VOID WriteData(_In_ UCHAR Data)
#define __drv_freesMem(kind)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define RtlCompareMemory(s1, s2, l)
#define InitializeListHead(ListHead)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
#define CmResourceTypeMemory
#define CmResourceTypeDma
#define CmResourceTypePort
#define CmResourceTypeInterrupt
BOOLEAN FindMemoryDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information)
#define ISAPNP_MEMBASE32(n)
#define ISAPNP_TAG_FIXEDIO
#define RANGE_LENGTH_TO_LENGTH(RangeLength)
#define ISAPNP_TAG_ANSISTR
#define ISAPNP_IORANGECHECK
#define ISAPNP_MEMCONTROL32(n)
#define ISAPNP_TAG_STARTDEP
#define IRQTYPE_LOW_LEVEL
#define ISAPNP_MEMLIMIT(n)
#define ISAPNP_LOGICALDEVICENUMBER
#define MEMORY_USE_32_BIT_DECODER
#define ISAPNP_MEMLIMIT32(n)
#define ISAPNP_SERIALISOLATION
#define ISAPNP_DMACHANNEL(n)
#define ISAPNP_TAG_MEMRANGE
#define ISAPNP_TAG_MEM32RANGE
#define MEMORY_USE_8_BIT_DECODER
#define ISAPNP_MEMBASE(n)
#define ISAPNP_RESOURCEDATA
#define ISAPNP_SMALL_TAG_NAME(t)
#define MEMORY_USE_16_BIT_DECODER
#define ISAPNP_TAG_COMPATDEVID
#define MEMORY_UPPER_LIMIT
#define ISAPNP_MEMCONTROL(n)
#define ISAPNP_SMALL_TAG_LEN(t)
#define ISAPNP_TAG_ENDDEP
#define ISAPNP_IRQTYPE(n)
#define IRQTYPE_HIGH_EDGE
#define ISAPNP_LARGE_TAG_NAME(t)
#define LENGTH_TO_RANGE_LENGTH(Length)
#define ISAPNP_CARDSELECTNUMBER
#define ISAPNP_IS_SMALL_TAG(t)
#define ISAPNP_TAG_LOGDEVID
#define ISAPNP_WRITE_DATA
#define MEMRANGE_16_BIT_MEMORY_MASK
#define ISAPNP_CONFIG_WAIT_FOR_KEY
#define ISAPNP_CONFIGCONTROL
#define ISAPNP_TAG_FIXEDMEM32RANGE
#define ISAPNP_CONFIG_RESET_CSN
#define MEMRANGE_32_BIT_MEMORY_ONLY
#define ISAPNP_TAG_IOPORT
#define ISAPNP_RESOURCE_TYPE_MEMRANGE
ISAPNP_DEPENDENT_FUNCTION_STATE
#define ISAPNP_HAS_MULTIPLE_LOGDEVS
#define ISAPNP_HAS_MEM32_DECODER
#define ISAPNP_RESOURCE_TYPE_END
#define ISAPNP_RESOURCE_TYPE_IRQ
#define ISAPNP_HAS_MEM24_DECODER
#define ISAPNP_MAX_RESOURCEDATA
Maximum size of resource data structure supported by the driver.
#define ISAPNP_RESOURCE_TYPE_IO
#define ISAPNP_RESOURCE_TYPE_START_DEPENDENT
#define ISAPNP_RESOURCE_TYPE_MEMRANGE32
#define ISAPNP_RESOURCE_TYPE_END_DEPENDENT
#define ISAPNP_RESOURCE_TYPE_DMA
#define ISAPNP_HAS_RESOURCES
#define ExFreePoolWithTag(_P, _T)
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
#define KeStallExecutionProcessor(MicroSeconds)
#define _Out_writes_all_(size)
#define _Out_writes_(size)
#define _Out_writes_bytes_all_opt_(size)
#define CM_RESOURCE_INTERRUPT_LATCHED
#define RTL_BITS_OF(sizeOfArg)
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define STATUS_INVALID_PARAMETER_4
#define STATUS_INVALID_PARAMETER_2
#define STATUS_RESOURCE_DATA_NOT_FOUND
#define STATUS_INVALID_PARAMETER_1
#define STATUS_INVALID_PARAMETER_3
#define READ_PORT_UCHAR(p)
#define WRITE_PORT_UCHAR(p, d)
#define STATUS_BUFFER_OVERFLOW
base of all file and directory entries
LIST_ENTRY CompatibleIdList
PISAPNP_RESOURCE Resources
COMMON_DEVICE_EXTENSION Common
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
#define RtlUshortByteSwap(_x)