ReactOS 0.4.16-dev-319-g6cf4263
hardware.c File Reference
#include "isapnp.h"
#include <debug.h>
Include dependency graph for hardware.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID WriteAddress (_In_ UCHAR Address)
 
static VOID WriteData (_In_ UCHAR Data)
 
static UCHAR ReadData (_In_ PUCHAR ReadDataPort)
 
static VOID WriteByte (_In_ UCHAR Address, _In_ UCHAR Value)
 
static VOID WriteWord (_In_ UCHAR Address, _In_ USHORT Value)
 
static VOID WriteDoubleWord (_In_ UCHAR Address, _In_ ULONG Value)
 
static UCHAR ReadByte (_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
 
static USHORT ReadWord (_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
 
static ULONG ReadDoubleWord (_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
 
static VOID SetReadDataPort (_In_ PUCHAR ReadDataPort)
 
static VOID EnterIsolationState (VOID)
 
static VOID WaitForKey (VOID)
 
static VOID Wake (_In_ UCHAR Csn)
 
static UCHAR ReadResourceData (_In_ PUCHAR ReadDataPort)
 
static UCHAR ReadStatus (_In_ PUCHAR ReadDataPort)
 
static VOID WriteCsn (_In_ UCHAR Csn)
 
static VOID WriteLogicalDeviceNumber (_In_ UCHAR LogDev)
 
static VOID ActivateDevice (_In_ PUCHAR ReadDataPort, _In_ UCHAR LogDev)
 
static VOID DeactivateDevice (_In_ UCHAR LogDev)
 
static USHORT ReadIoBase (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static UCHAR ReadIrqNo (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static UCHAR ReadIrqType (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static UCHAR ReadDmaChannel (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static USHORT ReadMemoryBase (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static UCHAR ReadMemoryControl (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static USHORT ReadMemoryLimit (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static ULONG ReadMemoryBase32 (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static UCHAR ReadMemoryControl32 (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static ULONG ReadMemoryLimit32 (_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
 
static UCHAR NextLFSR (_In_ UCHAR Lfsr, _In_ UCHAR InputBit)
 
static VOID SendKey (VOID)
 
static UCHAR PeekByte (_In_ PUCHAR ReadDataPort)
 
static VOID Peek (_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
 
static UCHAR IsaPnpChecksum (_In_ PISAPNP_IDENTIFIER Identifier)
 
static VOID IsaPnpExtractAscii (_Out_writes_all_(3) PUCHAR Buffer, _In_ USHORT CompressedData)
 
static NTSTATUS ReadTags (_In_ PUCHAR ReadDataPort, _Out_writes_(ISAPNP_MAX_RESOURCEDATA) PUCHAR Buffer, _In_ ULONG MaxLength, _Out_ PUSHORT MaxLogDev, _Out_ PULONG MaxTagsPerDevice)
 
static VOID FreeLogicalDevice (_In_ __drv_freesMem(Mem) PISAPNP_LOGICAL_DEVICE LogDevice)
 
static NTSTATUS ParseTags (_In_ PUCHAR ResourceData, _In_ USHORT LogDevToParse, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
 
static BOOLEAN ReadCurrentResources (_In_ PUCHAR ReadDataPort, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
 
static VOID IsaProgramIoDecoder (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
 
static VOID IsaProgramIrqSelect (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
 
static VOID IsaProgramDmaSelect (_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
 
static NTSTATUS IsaProgramMemoryDecoder (_In_ PUCHAR ReadDataPort, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ BOOLEAN IsMemory32, _In_ UCHAR Information, _In_ UCHAR Index)
 
UCHAR IsaHwTryReadDataPort (_In_ PUCHAR ReadDataPort)
 
 _Requires_lock_held_ (FdoExt->DeviceSyncEvent) NTSTATUS IsaHwFillDeviceList(_In_ PISAPNP_FDO_EXTENSION FdoExt)
 
NTSTATUS IsaHwConfigureDevice (_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice, _In_ PCM_RESOURCE_LIST Resources)
 
VOID IsaHwWakeDevice (_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
 
VOID IsaHwActivateDevice (_In_ PISAPNP_FDO_EXTENSION FdoExt, _In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
 
VOID IsaHwDeactivateDevice (_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice)
 
VOID IsaHwWaitForKey (VOID)
 

Variables

ULONG IsaConfigPorts [2]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file hardware.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( FdoExt->  DeviceSyncEvent)

Definition at line 1357 of file hardware.c.

1362{
1363 PISAPNP_LOGICAL_DEVICE LogDevice;
1364 UCHAR Csn;
1366 PUCHAR ResourceData;
1367
1368 PAGED_CODE();
1369 ASSERT(FdoExt->ReadDataPort);
1370
1371 DPRINT("%s for read port 0x%p\n", __FUNCTION__, FdoExt->ReadDataPort);
1372
1374 if (!ResourceData)
1375 {
1376 DPRINT1("Failed to allocate memory for cache data\n");
1378 }
1379
1380 for (Entry = FdoExt->DeviceListHead.Flink;
1381 Entry != &FdoExt->DeviceListHead;
1382 Entry = Entry->Flink)
1383 {
1384 LogDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1385
1386 LogDevice->Flags &= ~ISAPNP_PRESENT;
1387 }
1388
1389 for (Csn = 1; Csn <= FdoExt->Cards; Csn++)
1390 {
1392 UCHAR TempId[3], LogDev;
1394 ULONG MaxTagsPerDevice;
1395 USHORT MaxLogDev;
1396
1397 Wake(Csn);
1398
1399 Peek(FdoExt->ReadDataPort, &Identifier, sizeof(Identifier));
1400
1401 IsaPnpExtractAscii(TempId, Identifier.VendorId);
1402 Identifier.ProdId = RtlUshortByteSwap(Identifier.ProdId);
1403
1404 Status = ReadTags(FdoExt->ReadDataPort,
1405 ResourceData,
1407 &MaxLogDev,
1408 &MaxTagsPerDevice);
1409 if (!NT_SUCCESS(Status))
1410 {
1411 DPRINT1("Failed to read tags with status 0x%08lx, CSN %u\n", Status, Csn);
1412 continue;
1413 }
1414
1415 DPRINT("Detected ISA PnP device - VID: '%.3s' PID: 0x%04x SN: 0x%08lX\n",
1416 TempId, Identifier.ProdId, Identifier.Serial);
1417
1418 for (LogDev = 0; LogDev < MaxLogDev; LogDev++)
1419 {
1420 BOOLEAN IsAlreadyEnumerated = FALSE;
1421
1422#ifndef UNIT_TEST
1423 for (Entry = FdoExt->DeviceListHead.Flink;
1424 Entry != &FdoExt->DeviceListHead;
1425 Entry = Entry->Flink)
1426 {
1427 LogDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1428
1429 /* This logical device has already been enumerated */
1430 if ((LogDevice->SerialNumber == Identifier.Serial) &&
1431 (RtlCompareMemory(LogDevice->VendorId, TempId, 3) == 3) &&
1432 (LogDevice->ProdId == Identifier.ProdId) &&
1433 (LogDevice->LDN == LogDev))
1434 {
1435 LogDevice->Flags |= ISAPNP_PRESENT;
1436
1437 /* Assign a new CSN */
1438 LogDevice->CSN = Csn;
1439
1440 if (LogDevice->Pdo)
1441 {
1443
1444 if (PdoExt->Common.State == dsStarted)
1445 ActivateDevice(FdoExt->ReadDataPort, LogDev);
1446 }
1447
1448 DPRINT("Skip CSN %u, LDN %u\n", LogDevice->CSN, LogDevice->LDN);
1449 IsAlreadyEnumerated = TRUE;
1450 break;
1451 }
1452 }
1453#endif /* UNIT_TEST */
1454
1455 if (IsAlreadyEnumerated)
1456 continue;
1457
1459 if (!LogDevice)
1460 {
1461 DPRINT1("Failed to allocate logical device!\n");
1462 goto Deactivate;
1463 }
1464
1466
1467 LogDevice->CSN = Csn;
1468 LogDevice->LDN = LogDev;
1469
1471 MaxTagsPerDevice * sizeof(ISAPNP_RESOURCE),
1472 TAG_ISAPNP);
1473 if (!LogDevice->Resources)
1474 {
1475 DPRINT1("Failed to allocate the resources array\n");
1476 FreeLogicalDevice(LogDevice);
1477 goto Deactivate;
1478 }
1479
1480 Status = ParseTags(ResourceData, LogDev, LogDevice);
1481 if (!NT_SUCCESS(Status))
1482 {
1483 DPRINT1("Failed to parse tags with status 0x%08lx, CSN %u, LDN %u\n",
1484 Status, LogDevice->CSN, LogDevice->LDN);
1485 FreeLogicalDevice(LogDevice);
1486 goto Deactivate;
1487 }
1488
1489 if (!ReadCurrentResources(FdoExt->ReadDataPort, LogDevice))
1490 DPRINT("Unable to read boot resources\n");
1491
1492 IsaPnpExtractAscii(LogDevice->VendorId, Identifier.VendorId);
1493 LogDevice->ProdId = Identifier.ProdId;
1494 LogDevice->SerialNumber = Identifier.Serial;
1495
1496 if (MaxLogDev > 1)
1497 LogDevice->Flags |= ISAPNP_HAS_MULTIPLE_LOGDEVS;
1498
1499 LogDevice->Flags |= ISAPNP_PRESENT;
1500
1501 InsertTailList(&FdoExt->DeviceListHead, &LogDevice->DeviceLink);
1502 FdoExt->DeviceCount++;
1503
1504 /* Now we wait for the start device IRP */
1505Deactivate:
1506 DeactivateDevice(LogDev);
1507 }
1508 }
1509
1510 ExFreePoolWithTag(ResourceData, TAG_ISAPNP);
1511
1512 return STATUS_SUCCESS;
1513}
#define PAGED_CODE()
unsigned char BOOLEAN
@ Identifier
Definition: asmpp.cpp:95
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static NTSTATUS ParseTags(_In_ PUCHAR ResourceData, _In_ USHORT LogDevToParse, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:568
static VOID Peek(_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
Definition: hardware.c:379
static VOID ActivateDevice(_In_ PUCHAR ReadDataPort, _In_ UCHAR LogDev)
Definition: hardware.c:199
static VOID FreeLogicalDevice(_In_ __drv_freesMem(Mem) PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:536
static VOID DeactivateDevice(_In_ UCHAR LogDev)
Definition: hardware.c:214
static VOID Wake(_In_ UCHAR Csn)
Definition: hardware.c:154
static VOID IsaPnpExtractAscii(_Out_writes_all_(3) PUCHAR Buffer, _In_ USHORT CompressedData)
Definition: hardware.c:425
static NTSTATUS ReadTags(_In_ PUCHAR ReadDataPort, _Out_writes_(ISAPNP_MAX_RESOURCEDATA) PUCHAR Buffer, _In_ ULONG MaxLength, _Out_ PUSHORT MaxLogDev, _Out_ PULONG MaxTagsPerDevice)
Definition: hardware.c:439
static BOOLEAN ReadCurrentResources(_In_ PUCHAR ReadDataPort, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:1053
#define __FUNCTION__
Definition: types.h:116
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
#define TAG_ISAPNP
Definition: isapnp.h:26
@ dsStarted
Definition: isapnp.h:31
#define ISAPNP_HAS_MULTIPLE_LOGDEVS
Definition: isapnpres.h:99
#define ISAPNP_MAX_RESOURCEDATA
Maximum size of resource data structure supported by the driver.
Definition: isapnpres.h:12
#define ISAPNP_PRESENT
Definition: isapnpres.h:96
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY CompatibleIdList
Definition: isapnpres.h:129
PDEVICE_OBJECT Pdo
Definition: isapnpres.h:92
PISAPNP_RESOURCE Resources
Definition: isapnpres.h:127
LIST_ENTRY DeviceLink
Definition: isapnpres.h:91
Definition: typedefs.h:120
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133
#define RtlUshortByteSwap(_x)
Definition: rtlfuncs.h:3214
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ ActivateDevice()

static VOID ActivateDevice ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  LogDev 
)
inlinestatic

Definition at line 199 of file hardware.c.

202{
204
206 ReadByte(ReadDataPort, ISAPNP_IORANGECHECK) & ~2);
207
209}
static VOID WriteByte(_In_ UCHAR Address, _In_ UCHAR Value)
Definition: hardware.c:59
static UCHAR ReadByte(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:94
static VOID WriteLogicalDeviceNumber(_In_ UCHAR LogDev)
Definition: hardware.c:190
#define ISAPNP_IORANGECHECK
Definition: isapnphw.h:32
#define ISAPNP_ACTIVATE
Definition: isapnphw.h:31

Referenced by _Requires_lock_held_(), and IsaHwActivateDevice().

◆ DeactivateDevice()

static VOID DeactivateDevice ( _In_ UCHAR  LogDev)
inlinestatic

Definition at line 214 of file hardware.c.

216{
219}

Referenced by _Requires_lock_held_(), and IsaHwDeactivateDevice().

◆ EnterIsolationState()

static VOID EnterIsolationState ( VOID  )
inlinestatic

Definition at line 138 of file hardware.c.

139{
141}
static VOID WriteAddress(_In_ UCHAR Address)
Definition: hardware.c:32
#define ISAPNP_SERIALISOLATION
Definition: isapnphw.h:23

Referenced by IsaHwTryReadDataPort().

◆ FreeLogicalDevice()

static VOID FreeLogicalDevice ( _In_ __drv_freesMem(Mem) PISAPNP_LOGICAL_DEVICE  LogDevice)
static

Definition at line 536 of file hardware.c.

538{
540
541 PAGED_CODE();
542
543 if (LogDevice->FriendlyName)
544 ExFreePoolWithTag(LogDevice->FriendlyName, TAG_ISAPNP);
545
546 if (LogDevice->Resources)
547 ExFreePoolWithTag(LogDevice->Resources, TAG_ISAPNP);
548
549 Entry = LogDevice->CompatibleIdList.Flink;
550 while (Entry != &LogDevice->CompatibleIdList)
551 {
552 PISAPNP_COMPATIBLE_ID_ENTRY CompatibleId =
554
555 RemoveEntryList(&CompatibleId->IdLink);
556
557 Entry = Entry->Flink;
558
559 ExFreePoolWithTag(CompatibleId, TAG_ISAPNP);
560 }
561
562 ExFreePoolWithTag(LogDevice, TAG_ISAPNP);
563}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
Definition: isapnpres.h:53
LIST_ENTRY IdLink
Definition: isapnpres.h:56

Referenced by _Requires_lock_held_().

◆ IsaHwActivateDevice()

VOID IsaHwActivateDevice ( _In_ PISAPNP_FDO_EXTENSION  FdoExt,
_In_ PISAPNP_LOGICAL_DEVICE  LogicalDevice 
)

Definition at line 1661 of file hardware.c.

1664{
1665 PAGED_CODE();
1666
1667 ActivateDevice(FdoExt->ReadDataPort, LogicalDevice->LDN);
1668}

Referenced by DrvTestResources(), and IsaPdoPnp().

◆ IsaHwConfigureDevice()

NTSTATUS IsaHwConfigureDevice ( _In_ PISAPNP_FDO_EXTENSION  FdoExt,
_In_ PISAPNP_LOGICAL_DEVICE  LogicalDevice,
_In_ PCM_RESOURCE_LIST  Resources 
)

Definition at line 1517 of file hardware.c.

1521{
1522 ULONG i;
1523 UCHAR NumberOfIo = 0,
1524 NumberOfIrq = 0,
1525 NumberOfDma = 0,
1526 NumberOfMemory = 0,
1527 NumberOfMemory32 = 0;
1528
1529 PAGED_CODE();
1530
1531 if (!Resources)
1533
1534 WriteLogicalDeviceNumber(LogicalDevice->LDN);
1535
1536 for (i = 0; i < Resources->List[0].PartialResourceList.Count; i++)
1537 {
1539 &Resources->List[0].PartialResourceList.PartialDescriptors[i];
1540
1541 switch (Descriptor->Type)
1542 {
1543 case CmResourceTypePort:
1544 {
1545 if (NumberOfIo >= RTL_NUMBER_OF(LogicalDevice->Io))
1547
1548 IsaProgramIoDecoder(Descriptor, NumberOfIo++);
1549 break;
1550 }
1551
1553 {
1554 if (NumberOfIrq >= RTL_NUMBER_OF(LogicalDevice->Irq))
1556
1557 IsaProgramIrqSelect(Descriptor, NumberOfIrq++);
1558 break;
1559 }
1560
1561 case CmResourceTypeDma:
1562 {
1563 if (NumberOfDma >= RTL_NUMBER_OF(LogicalDevice->Dma))
1565
1566 IsaProgramDmaSelect(Descriptor, NumberOfDma++);
1567 break;
1568 }
1569
1571 {
1572 BOOLEAN IsMemory32;
1575
1576 if ((NumberOfMemory + NumberOfMemory32) >= RTL_NUMBER_OF(LogicalDevice->MemRange))
1578
1579 /*
1580 * The PNP ROM provides an information byte for each memory descriptor
1581 * which is then used to program the memory control register.
1582 */
1583 if (!FindMemoryDescriptor(LogicalDevice,
1584 Descriptor->u.Memory.Start.LowPart,
1585 Descriptor->u.Memory.Start.LowPart +
1586 Descriptor->u.Memory.Length - 1,
1587 &Information))
1588 {
1590 }
1591
1592 /* We can have a 24- or 32-bit memory decoder, but not both */
1593 IsMemory32 = !!(LogicalDevice->Flags & ISAPNP_HAS_MEM32_DECODER);
1594
1595 if (IsMemory32)
1596 Index = NumberOfMemory32++;
1597 else
1598 Index = NumberOfMemory++;
1599
1600 Status = IsaProgramMemoryDecoder(FdoExt->ReadDataPort,
1601 Descriptor,
1602 IsMemory32,
1604 Index);
1605 if (!NT_SUCCESS(Status))
1606 return Status;
1607
1608 break;
1609 }
1610
1611 default:
1612 break;
1613 }
1614 }
1615
1616 /* Disable the unclaimed device resources */
1617 for (i = NumberOfIo; i < RTL_NUMBER_OF(LogicalDevice->Io); i++)
1618 {
1620 }
1621 for (i = NumberOfIrq; i < RTL_NUMBER_OF(LogicalDevice->Irq); i++)
1622 {
1625 }
1626 for (i = NumberOfDma; i < RTL_NUMBER_OF(LogicalDevice->Dma); i++)
1627 {
1629 }
1630 for (i = NumberOfMemory; i < RTL_NUMBER_OF(LogicalDevice->MemRange); i++)
1631 {
1635 }
1636 for (i = NumberOfMemory32; i < RTL_NUMBER_OF(LogicalDevice->MemRange32); i++)
1637 {
1641 }
1642
1644
1645 return STATUS_SUCCESS;
1646}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
static VOID WriteDoubleWord(_In_ UCHAR Address, _In_ ULONG Value)
Definition: hardware.c:83
static VOID IsaProgramIrqSelect(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
Definition: hardware.c:1156
static VOID IsaProgramDmaSelect(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
Definition: hardware.c:1178
static VOID IsaProgramIoDecoder(_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ UCHAR Index)
Definition: hardware.c:1142
static VOID WriteWord(_In_ UCHAR Address, _In_ USHORT Value)
Definition: hardware.c:72
static NTSTATUS IsaProgramMemoryDecoder(_In_ PUCHAR ReadDataPort, _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor, _In_ BOOLEAN IsMemory32, _In_ UCHAR Information, _In_ UCHAR Index)
Definition: hardware.c:1192
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
Definition: glfuncs.h:248
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
BOOLEAN FindMemoryDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information)
Definition: isapnp.c:562
#define ISAPNP_MEMBASE32(n)
Definition: isapnphw.h:48
#define ISAPNP_MEMCONTROL32(n)
Definition: isapnphw.h:49
#define ISAPNP_MEMLIMIT(n)
Definition: isapnphw.h:40
#define ISAPNP_MEMLIMIT32(n)
Definition: isapnphw.h:50
#define ISAPNP_DMACHANNEL(n)
Definition: isapnphw.h:46
#define ISAPNP_MEMBASE(n)
Definition: isapnphw.h:34
#define ISAPNP_MEMCONTROL(n)
Definition: isapnphw.h:35
#define ISAPNP_IRQTYPE(n)
Definition: isapnphw.h:43
#define ISAPNP_IRQNO(n)
Definition: isapnphw.h:42
#define DMACHANNEL_NONE
Definition: isapnphw.h:47
#define ISAPNP_IOBASE(n)
Definition: isapnphw.h:41
#define ISAPNP_HAS_MEM32_DECODER
Definition: isapnpres.h:108
#define KeStallExecutionProcessor(MicroSeconds)
Definition: precomp.h:27
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:478
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476
#define STATUS_RESOURCE_DATA_NOT_FOUND
Definition: ntstatus.h:373
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define STATUS_INVALID_PARAMETER_3
Definition: ntstatus.h:477
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by DrvTestResources(), and IsaPdoPnp().

◆ IsaHwDeactivateDevice()

VOID IsaHwDeactivateDevice ( _In_ PISAPNP_LOGICAL_DEVICE  LogicalDevice)

Definition at line 1673 of file hardware.c.

1675{
1676 PAGED_CODE();
1677
1678 DeactivateDevice(LogicalDevice->LDN);
1679}

Referenced by IsaPdoPnp(), and IsaPdoRemoveDevice().

◆ IsaHwTryReadDataPort()

UCHAR IsaHwTryReadDataPort ( _In_ PUCHAR  ReadDataPort)

Definition at line 1259 of file hardware.c.

1261{
1262 ULONG NumberOfRead = 0;
1263 UCHAR Csn = 0;
1264
1265 PAGED_CODE();
1266
1267 DPRINT("Setting read data port: 0x%p\n", ReadDataPort);
1268
1269 SendKey();
1270
1274
1275 SendKey();
1276
1277 Wake(0x00);
1279
1280 SetReadDataPort(ReadDataPort);
1281
1282 Wake(0x00);
1283
1284 while (TRUE)
1285 {
1287 UCHAR i, j;
1288 BOOLEAN Seen55aa = FALSE;
1289
1292
1294
1295 for (i = 0; i < sizeof(Identifier); i++)
1296 {
1297 UCHAR Byte = 0;
1298
1299 for (j = 0; j < RTL_BITS_OF(Byte); j++)
1300 {
1301 USHORT Data;
1302
1303 Data = ReadData(ReadDataPort) << 8;
1305 Data |= ReadData(ReadDataPort);
1307
1308 Byte >>= 1;
1309
1310 if (Data == 0x55AA)
1311 {
1312 Byte |= 0x80;
1313 Seen55aa = TRUE;
1314 }
1315 }
1316
1317 ((PUCHAR)&Identifier)[i] = Byte;
1318 }
1319
1320 ++NumberOfRead;
1321
1322 if (Identifier.Checksum != 0x00 &&
1323 Identifier.Checksum != IsaPnpChecksum(&Identifier))
1324 {
1325 DPRINT("Bad checksum\n");
1326 break;
1327 }
1328
1329 if (!Seen55aa)
1330 {
1331 DPRINT("Saw no sign of life\n");
1332 break;
1333 }
1334
1335 Csn++;
1336
1337 WriteCsn(Csn);
1339
1340 Wake(0x00);
1341 }
1342
1343 Wake(0x00);
1344
1345 if (NumberOfRead == 1)
1346 {
1347 DPRINT("Trying next read data port\n");
1348 return 0;
1349 }
1350 else
1351 {
1352 DPRINT("Found %u cards at read port 0x%p\n", Csn, ReadDataPort);
1353 return Csn;
1354 }
1355}
@ ReadData
Definition: amstream.idl:63
unsigned char Byte
Definition: zlib.h:37
static VOID SetReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:129
static VOID SendKey(VOID)
Definition: hardware.c:338
static VOID WriteCsn(_In_ UCHAR Csn)
Definition: hardware.c:181
static VOID EnterIsolationState(VOID)
Definition: hardware.c:138
static UCHAR IsaPnpChecksum(_In_ PISAPNP_IDENTIFIER Identifier)
Definition: hardware.c:400
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
Definition: glfuncs.h:250
#define ISAPNP_CONFIG_WAIT_FOR_KEY
Definition: isapnphw.h:53
#define ISAPNP_CONFIGCONTROL
Definition: isapnphw.h:24
#define ISAPNP_CONFIG_RESET_CSN
Definition: isapnphw.h:54
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:676
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by DrvTestIsolation(), IsaPdoStartReadPort(), and IsaPnpFillDeviceRelations().

◆ IsaHwWaitForKey()

VOID IsaHwWaitForKey ( VOID  )

Definition at line 1684 of file hardware.c.

1685{
1686 PAGED_CODE();
1687
1688 WaitForKey();
1689}
static VOID WaitForKey(VOID)
Definition: hardware.c:146

Referenced by DrvTestIsolation(), DrvTestResources(), IsaPdoPnp(), IsaPdoRemoveDevice(), IsaPdoStartReadPort(), and IsaPnpFillDeviceRelations().

◆ IsaHwWakeDevice()

VOID IsaHwWakeDevice ( _In_ PISAPNP_LOGICAL_DEVICE  LogicalDevice)

Definition at line 1650 of file hardware.c.

1652{
1653 PAGED_CODE();
1654
1655 SendKey();
1656 Wake(LogicalDevice->CSN);
1657}

Referenced by DrvTestResources(), IsaPdoPnp(), and IsaPdoRemoveDevice().

◆ IsaPnpChecksum()

static UCHAR IsaPnpChecksum ( _In_ PISAPNP_IDENTIFIER  Identifier)
static

Definition at line 400 of file hardware.c.

402{
403 UCHAR i, j, Lfsr;
404
405 PAGED_CODE();
406
407 Lfsr = ISAPNP_LFSR_SEED;
408 for (i = 0; i < FIELD_OFFSET(ISAPNP_IDENTIFIER, Checksum); i++)
409 {
411
412 for (j = 0; j < RTL_BITS_OF(Byte); j++)
413 {
414 Lfsr = NextLFSR(Lfsr, Byte);
415 Byte >>= 1;
416 }
417 }
418
419 return Lfsr;
420}
static UCHAR NextLFSR(_In_ UCHAR Lfsr, _In_ UCHAR InputBit)
Definition: hardware.c:324
#define ISAPNP_LFSR_SEED
Definition: isapnphw.h:56
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

Referenced by IsaHwTryReadDataPort().

◆ IsaPnpExtractAscii()

static VOID IsaPnpExtractAscii ( _Out_writes_all_(3) PUCHAR  Buffer,
_In_ USHORT  CompressedData 
)
static

Definition at line 425 of file hardware.c.

428{
429 PAGED_CODE();
430
431 Buffer[0] = ((CompressedData >> 2) & 0x1F) + 'A' - 1;
432 Buffer[1] = (((CompressedData & 0x3) << 3) | ((CompressedData >> 13) & 0x7)) + 'A' - 1;
433 Buffer[2] = ((CompressedData >> 8) & 0x1F) + 'A' - 1;
434}
Definition: bufpool.h:45

Referenced by _Requires_lock_held_(), and ParseTags().

◆ IsaProgramDmaSelect()

static VOID IsaProgramDmaSelect ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Descriptor,
_In_ UCHAR  Index 
)
static

Definition at line 1178 of file hardware.c.

1181{
1182 PAGED_CODE();
1183
1184 ASSERT(Descriptor->u.Dma.Channel <= 7);
1185
1186 WriteByte(ISAPNP_DMACHANNEL(Index), Descriptor->u.Dma.Channel);
1187}

Referenced by IsaHwConfigureDevice().

◆ IsaProgramIoDecoder()

static VOID IsaProgramIoDecoder ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Descriptor,
_In_ UCHAR  Index 
)
static

Definition at line 1142 of file hardware.c.

1145{
1146 PAGED_CODE();
1147
1148 ASSERT(Descriptor->u.Port.Start.QuadPart <= 0xFFFF);
1149
1150 WriteWord(ISAPNP_IOBASE(Index), Descriptor->u.Port.Start.LowPart);
1151}

Referenced by IsaHwConfigureDevice().

◆ IsaProgramIrqSelect()

static VOID IsaProgramIrqSelect ( _In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Descriptor,
_In_ UCHAR  Index 
)
static

Definition at line 1156 of file hardware.c.

1159{
1160 UCHAR TypeSelect;
1161
1162 PAGED_CODE();
1163
1164 ASSERT(Descriptor->u.Interrupt.Level <= 15);
1165
1167 TypeSelect = IRQTYPE_HIGH_EDGE;
1168 else
1169 TypeSelect = IRQTYPE_LOW_LEVEL;
1170
1171 WriteByte(ISAPNP_IRQNO(Index), Descriptor->u.Interrupt.Level);
1172 WriteByte(ISAPNP_IRQTYPE(Index), TypeSelect);
1173}
#define IRQTYPE_LOW_LEVEL
Definition: isapnphw.h:44
#define IRQTYPE_HIGH_EDGE
Definition: isapnphw.h:45
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144

Referenced by IsaHwConfigureDevice().

◆ IsaProgramMemoryDecoder()

static NTSTATUS IsaProgramMemoryDecoder ( _In_ PUCHAR  ReadDataPort,
_In_ PCM_PARTIAL_RESOURCE_DESCRIPTOR  Descriptor,
_In_ BOOLEAN  IsMemory32,
_In_ UCHAR  Information,
_In_ UCHAR  Index 
)
static

Definition at line 1192 of file hardware.c.

1198{
1199 UCHAR MemoryControl;
1200 ULONG LengthLimit;
1201
1202 PAGED_CODE();
1203
1204 if (!IsMemory32)
1205 {
1206 /* The 24-bit memory address decoder always considers bits 0:7 to be zeros */
1207 if (Descriptor->u.Memory.Start.LowPart & 0xFF)
1209
1211 MemoryControl = MEMORY_USE_16_BIT_DECODER;
1212 else
1213 MemoryControl = MEMORY_USE_8_BIT_DECODER;
1214
1215 if (ReadMemoryControl(ReadDataPort, Index) & MEMORY_UPPER_LIMIT)
1216 {
1217 MemoryControl |= MEMORY_UPPER_LIMIT;
1218 LengthLimit = Descriptor->u.Memory.Start.LowPart + Descriptor->u.Memory.Length;
1219 }
1220 else
1221 {
1222 LengthLimit = LENGTH_TO_RANGE_LENGTH(Descriptor->u.Memory.Length);
1223 }
1224 LengthLimit >>= 8;
1225
1226 WriteWord(ISAPNP_MEMBASE(Index), Descriptor->u.Memory.Start.LowPart >> 8);
1227 WriteByte(ISAPNP_MEMCONTROL(Index), MemoryControl);
1228 WriteWord(ISAPNP_MEMLIMIT(Index), LengthLimit);
1229 }
1230 else
1231 {
1233 MemoryControl = MEMORY_USE_32_BIT_DECODER;
1235 MemoryControl = MEMORY_USE_16_BIT_DECODER;
1236 else
1237 MemoryControl = MEMORY_USE_8_BIT_DECODER;
1238
1239 if (ReadMemoryControl32(ReadDataPort, Index) & MEMORY_UPPER_LIMIT)
1240 {
1241 MemoryControl |= MEMORY_UPPER_LIMIT;
1242 LengthLimit = Descriptor->u.Memory.Start.LowPart + Descriptor->u.Memory.Length;
1243 }
1244 else
1245 {
1246 LengthLimit = LENGTH_TO_RANGE_LENGTH(Descriptor->u.Memory.Length);
1247 }
1248
1249 WriteDoubleWord(ISAPNP_MEMBASE32(Index), Descriptor->u.Memory.Start.LowPart);
1250 WriteByte(ISAPNP_MEMCONTROL32(Index), MemoryControl);
1252 }
1253
1254 return STATUS_SUCCESS;
1255}
static UCHAR ReadMemoryControl(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:274
static UCHAR ReadMemoryControl32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:304
#define MEMORY_USE_32_BIT_DECODER
Definition: isapnphw.h:39
#define MEMORY_USE_8_BIT_DECODER
Definition: isapnphw.h:37
#define MEMORY_USE_16_BIT_DECODER
Definition: isapnphw.h:38
#define MEMORY_UPPER_LIMIT
Definition: isapnphw.h:36
#define LENGTH_TO_RANGE_LENGTH(Length)
Definition: isapnphw.h:83
#define MEMRANGE_16_BIT_MEMORY_MASK
Definition: isapnphw.h:75
#define MEMRANGE_32_BIT_MEMORY_ONLY
Definition: isapnphw.h:76
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by IsaHwConfigureDevice().

◆ NextLFSR()

static UCHAR NextLFSR ( _In_ UCHAR  Lfsr,
_In_ UCHAR  InputBit 
)
inlinestatic

Definition at line 324 of file hardware.c.

327{
328 UCHAR NextLfsr = Lfsr >> 1;
329
330 NextLfsr |= (((Lfsr ^ NextLfsr) ^ InputBit)) << 7;
331
332 return NextLfsr;
333}

Referenced by IsaPnpChecksum(), and SendKey().

◆ ParseTags()

static NTSTATUS ParseTags ( _In_ PUCHAR  ResourceData,
_In_ USHORT  LogDevToParse,
_Inout_ PISAPNP_LOGICAL_DEVICE  LogDevice 
)
static

Definition at line 568 of file hardware.c.

572{
573 USHORT LogDev;
575 PISAPNP_RESOURCE Resource = LogDevice->Resources;
576 PUCHAR IdStrPos = NULL;
577 USHORT IdStrLen = 0;
578
579 PAGED_CODE();
580
581 DPRINT("%s for CSN %u, LDN %u\n", __FUNCTION__, LogDevice->CSN, LogDevice->LDN);
582
583 LogDev = LogDevToParse + 1;
584
585 while (TRUE)
586 {
587 UCHAR Tag;
588 USHORT TagLen;
589
590 Tag = *ResourceData++;
591
593 {
594 TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
596 }
597 else
598 {
599 TagLen = *ResourceData++;
600 TagLen += *ResourceData++ << 8;
601
603 }
604
605 switch (Tag)
606 {
608 {
609 ISAPNP_LOGDEVID Temp;
610
611 --LogDev;
612
613 if (LogDev != 0 ||
614 (TagLen > sizeof(ISAPNP_LOGDEVID) ||
615 TagLen < (sizeof(ISAPNP_LOGDEVID) - 1)))
616 {
617 goto SkipTag;
618 }
619
620 RtlCopyMemory(&Temp, ResourceData, TagLen);
621 ResourceData += TagLen;
622
623 DPRINT("Found tag 0x%X (len %u)\n"
624 " VendorId 0x%04X\n"
625 " ProdId 0x%04X\n",
626 Tag, TagLen,
627 Temp.VendorId,
628 Temp.ProdId);
629
630 IsaPnpExtractAscii(LogDevice->LogVendorId, Temp.VendorId);
631 LogDevice->LogProdId = RtlUshortByteSwap(Temp.ProdId);
632
633 break;
634 }
635
637 {
638 ISAPNP_COMPATID Temp;
639 PISAPNP_COMPATIBLE_ID_ENTRY CompatibleId;
640
641 if (LogDev != 0 || TagLen != sizeof(ISAPNP_COMPATID))
642 goto SkipTag;
643
644 CompatibleId = ExAllocatePoolWithTag(PagedPool,
646 TAG_ISAPNP);
647 if (!CompatibleId)
649
650 RtlCopyMemory(&Temp, ResourceData, TagLen);
651 ResourceData += TagLen;
652
653 DPRINT("Found tag 0x%X (len %u)\n"
654 " VendorId 0x%04X\n"
655 " ProdId 0x%04X\n",
656 Tag, TagLen,
657 Temp.VendorId,
658 Temp.ProdId);
659
660 IsaPnpExtractAscii(CompatibleId->VendorId, Temp.VendorId);
661 CompatibleId->ProdId = RtlUshortByteSwap(Temp.ProdId);
662
663 InsertTailList(&LogDevice->CompatibleIdList, &CompatibleId->IdLink);
664
665 break;
666 }
667
668 case ISAPNP_TAG_IRQ:
669 {
671
672 if (LogDev != 0)
673 goto SkipTag;
674
675 if (TagLen > sizeof(ISAPNP_IRQ_DESCRIPTION) ||
676 TagLen < (sizeof(ISAPNP_IRQ_DESCRIPTION) - 1))
677 {
678 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_IRQ);
679 return STATUS_UNSUCCESSFUL;
680 }
681
683 Description = &Resource->IrqDescription;
684 ++Resource;
685
686 RtlCopyMemory(Description, ResourceData, TagLen);
687 ResourceData += TagLen;
688
689 if (TagLen == (sizeof(ISAPNP_IRQ_DESCRIPTION) - 1))
690 Description->Information = 0x01;
691
692 DPRINT("Found tag 0x%X (len %u)\n"
693 " Mask 0x%X\n"
694 " Information 0x%X\n",
695 Tag, TagLen,
696 Description->Mask,
697 Description->Information);
698
699 break;
700 }
701
702 case ISAPNP_TAG_DMA:
703 {
705
706 if (LogDev != 0)
707 goto SkipTag;
708
709 if (TagLen != sizeof(ISAPNP_DMA_DESCRIPTION))
710 {
711 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_DMA);
712 return STATUS_UNSUCCESSFUL;
713 }
714
716 Description = &Resource->DmaDescription;
717 ++Resource;
718
719 RtlCopyMemory(Description, ResourceData, TagLen);
720 ResourceData += TagLen;
721
722 DPRINT("Found tag 0x%X (len %u)\n"
723 " Mask 0x%X\n"
724 " Information 0x%X\n",
725 Tag, TagLen,
726 Description->Mask,
727 Description->Information);
728
729 break;
730 }
731
733 {
734 if (LogDev != 0)
735 goto SkipTag;
736
737 if (TagLen > 1)
738 {
739 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_STARTDEP);
740 return STATUS_UNSUCCESSFUL;
741 }
742
743 if (DfState == dfNotStarted)
744 {
745 DfState = dfStarted;
746 }
747 else if (DfState != dfStarted)
748 {
749 goto SkipTag;
750 }
751
753 ++Resource;
754
755 if (TagLen != 1)
756 {
757 Resource->Priority = 1;
758 }
759 else
760 {
761 RtlCopyMemory(&Resource->Priority, ResourceData, TagLen);
762 ResourceData += TagLen;
763 }
764
765 DPRINT("*** Start dependent set, priority %u ***\n",
766 Resource->Priority);
767
768 break;
769 }
770
772 {
773 if (LogDev != 0 || DfState != dfStarted)
774 goto SkipTag;
775
777 ++Resource;
778
779 DfState = dfDone;
780
781 ResourceData += TagLen;
782
783 DPRINT("*** End of dependent set ***\n");
784
785 break;
786 }
787
789 {
791
792 if (LogDev != 0)
793 goto SkipTag;
794
795 if (TagLen != sizeof(ISAPNP_IO_DESCRIPTION))
796 {
797 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_IOPORT);
798 return STATUS_UNSUCCESSFUL;
799 }
800
802 Description = &Resource->IoDescription;
803 ++Resource;
804
805 RtlCopyMemory(Description, ResourceData, TagLen);
806 ResourceData += TagLen;
807
808 DPRINT("Found tag 0x%X (len %u)\n"
809 " Information 0x%X\n"
810 " Minimum 0x%X\n"
811 " Maximum 0x%X\n"
812 " Alignment 0x%X\n"
813 " Length 0x%X\n",
814 Tag, TagLen,
815 Description->Information,
816 Description->Minimum,
817 Description->Maximum,
818 Description->Alignment,
819 Description->Length);
820
821 break;
822 }
823
825 {
828
829 if (LogDev != 0)
830 goto SkipTag;
831
832 if (TagLen != sizeof(ISAPNP_FIXED_IO_DESCRIPTION))
833 {
834 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_FIXEDIO);
835 return STATUS_UNSUCCESSFUL;
836 }
837
839 Description = &Resource->IoDescription;
840 ++Resource;
841
842 RtlCopyMemory(&Temp, ResourceData, TagLen);
843 ResourceData += TagLen;
844
845 /* Save the address bits [0:9] */
846 Temp.IoBase &= ((1 << 10) - 1);
847
848 Description->Information = 0;
849 Description->Minimum =
850 Description->Maximum = Temp.IoBase;
851 Description->Alignment = 1;
852 Description->Length = Temp.Length;
853
854 DPRINT("Found tag 0x%X (len %u)\n"
855 " IoBase 0x%X\n"
856 " Length 0x%X\n",
857 Tag, TagLen,
858 Temp.IoBase,
859 Temp.Length);
860
861 break;
862 }
863
864 case ISAPNP_TAG_END:
865 {
866 if (IdStrPos)
867 {
868 PSTR End;
869
870 LogDevice->FriendlyName = ExAllocatePoolWithTag(PagedPool,
871 IdStrLen + sizeof(ANSI_NULL),
872 TAG_ISAPNP);
873 if (!LogDevice->FriendlyName)
875
876 RtlCopyMemory(LogDevice->FriendlyName, IdStrPos, IdStrLen);
877
878 End = LogDevice->FriendlyName + IdStrLen - 1;
879 while (End > LogDevice->FriendlyName && *End == ' ')
880 {
881 --End;
882 }
883 *++End = ANSI_NULL;
884 }
885
887
888 return STATUS_SUCCESS;
889 }
890
892 {
894
895 if (LogDev != 0)
896 goto SkipTag;
897
898 if (TagLen != sizeof(ISAPNP_MEMRANGE_DESCRIPTION))
899 {
900 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_MEMRANGE);
901 return STATUS_UNSUCCESSFUL;
902 }
903
904 LogDevice->Flags |= ISAPNP_HAS_MEM24_DECODER;
905 ASSERT(!(LogDevice->Flags & ISAPNP_HAS_MEM32_DECODER));
906
908 Description = &Resource->MemRangeDescription;
909 ++Resource;
910
911 RtlCopyMemory(Description, ResourceData, TagLen);
912 ResourceData += TagLen;
913
914 DPRINT("Found tag 0x%X (len %u)\n"
915 " Information 0x%X\n"
916 " Minimum 0x%X\n"
917 " Maximum 0x%X\n"
918 " Alignment 0x%X\n"
919 " Length 0x%X\n",
920 Tag, TagLen,
921 Description->Information,
922 Description->Minimum,
923 Description->Maximum,
924 Description->Alignment,
925 Description->Length);
926
927 break;
928 }
929
931 {
932 /* If logical device identifier is not supplied, use card identifier */
933 if (LogDev == LogDevToParse + 1 || LogDev == 0)
934 {
935 IdStrPos = ResourceData;
936 IdStrLen = TagLen;
937
938 ResourceData += TagLen;
939
940 DPRINT("Found tag 0x%X (len %u)\n"
941 " '%.*s'\n",
942 Tag, TagLen,
943 IdStrLen,
944 IdStrPos);
945 }
946 else
947 {
948 goto SkipTag;
949 }
950
951 break;
952 }
953
955 {
957
958 if (LogDev != 0)
959 goto SkipTag;
960
961 if (TagLen != sizeof(ISAPNP_MEMRANGE32_DESCRIPTION))
962 {
963 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_MEM32RANGE);
964 return STATUS_UNSUCCESSFUL;
965 }
966
967 LogDevice->Flags |= ISAPNP_HAS_MEM32_DECODER;
968 ASSERT(!(LogDevice->Flags & ISAPNP_HAS_MEM24_DECODER));
969
971 Description = &Resource->MemRange32Description;
972 ++Resource;
973
974 RtlCopyMemory(Description, ResourceData, TagLen);
975 ResourceData += TagLen;
976
977 DPRINT("Found tag 0x%X (len %u)\n"
978 " Information 0x%X\n"
979 " Minimum 0x%08lX\n"
980 " Maximum 0x%08lX\n"
981 " Alignment 0x%08lX\n"
982 " Length 0x%08lX\n",
983 Tag, TagLen,
984 Description->Information,
985 Description->Minimum,
986 Description->Maximum,
987 Description->Alignment,
988 Description->Length);
989
990 break;
991 }
992
994 {
997
998 if (LogDev != 0)
999 goto SkipTag;
1000
1001 if (TagLen != sizeof(ISAPNP_FIXEDMEMRANGE_DESCRIPTION))
1002 {
1003 DPRINT1("Invalid tag %x\n", ISAPNP_TAG_FIXEDMEM32RANGE);
1004 return STATUS_UNSUCCESSFUL;
1005 }
1006
1007 LogDevice->Flags |= ISAPNP_HAS_MEM32_DECODER;
1008 ASSERT(!(LogDevice->Flags & ISAPNP_HAS_MEM24_DECODER));
1009
1011 Description = &Resource->MemRange32Description;
1012 ++Resource;
1013
1014 RtlCopyMemory(&Temp, ResourceData, TagLen);
1015 ResourceData += TagLen;
1016
1017 Description->Information = Temp.Information;
1018 Description->Minimum =
1019 Description->Maximum = Temp.MemoryBase;
1020 Description->Alignment = 1;
1021 Description->Length = Temp.Length;
1022
1023 DPRINT("Found tag 0x%X (len %u)\n"
1024 " Information 0x%X\n"
1025 " MemoryBase 0x%08lX\n"
1026 " Length 0x%08lX\n",
1027 Tag, TagLen,
1028 Temp.Information,
1029 Temp.MemoryBase,
1030 Temp.Length);
1031
1032 break;
1033 }
1034
1035SkipTag:
1036 default:
1037 {
1038 if (LogDev == 0)
1039 DPRINT("Found unknown tag 0x%X (len %u)\n", Tag, TagLen);
1040
1041 /* We don't want to read informations on this
1042 * logical device, or we don't know the tag. */
1043 ResourceData += TagLen;
1044 break;
1045 }
1046 }
1047 }
1048}
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define NULL
Definition: types.h:112
static const WCHAR Description[]
Definition: oid.c:1266
#define ISAPNP_TAG_FIXEDIO
Definition: isapnphw.h:69
#define ISAPNP_TAG_ANSISTR
Definition: isapnphw.h:77
#define ISAPNP_TAG_STARTDEP
Definition: isapnphw.h:66
#define ISAPNP_TAG_MEMRANGE
Definition: isapnphw.h:74
#define ISAPNP_TAG_MEM32RANGE
Definition: isapnphw.h:79
#define ISAPNP_TAG_DMA
Definition: isapnphw.h:65
#define ISAPNP_SMALL_TAG_NAME(t)
Definition: isapnphw.h:59
#define ISAPNP_TAG_IRQ
Definition: isapnphw.h:64
#define ISAPNP_TAG_COMPATDEVID
Definition: isapnphw.h:63
#define ISAPNP_SMALL_TAG_LEN(t)
Definition: isapnphw.h:60
#define ISAPNP_TAG_ENDDEP
Definition: isapnphw.h:67
#define ISAPNP_LARGE_TAG_NAME(t)
Definition: isapnphw.h:73
#define ISAPNP_IS_SMALL_TAG(t)
Definition: isapnphw.h:58
#define ISAPNP_TAG_LOGDEVID
Definition: isapnphw.h:62
#define ISAPNP_TAG_END
Definition: isapnphw.h:70
#define ISAPNP_TAG_FIXEDMEM32RANGE
Definition: isapnphw.h:80
#define ISAPNP_TAG_IOPORT
Definition: isapnphw.h:68
#define ISAPNP_RESOURCE_TYPE_MEMRANGE
Definition: isapnpres.h:73
ISAPNP_DEPENDENT_FUNCTION_STATE
Definition: isapnpres.h:60
@ dfDone
Definition: isapnpres.h:63
@ dfStarted
Definition: isapnpres.h:62
@ dfNotStarted
Definition: isapnpres.h:61
#define ISAPNP_RESOURCE_TYPE_END
Definition: isapnpres.h:69
#define ISAPNP_RESOURCE_TYPE_IRQ
Definition: isapnpres.h:71
#define ISAPNP_HAS_MEM24_DECODER
Definition: isapnpres.h:105
#define ISAPNP_RESOURCE_TYPE_IO
Definition: isapnpres.h:70
#define ISAPNP_RESOURCE_TYPE_START_DEPENDENT
Definition: isapnpres.h:75
#define ISAPNP_RESOURCE_TYPE_MEMRANGE32
Definition: isapnpres.h:74
#define ISAPNP_RESOURCE_TYPE_END_DEPENDENT
Definition: isapnpres.h:76
#define ISAPNP_RESOURCE_TYPE_DMA
Definition: isapnpres.h:72
#define ANSI_NULL
UCHAR VendorId[3]
Definition: isapnpres.h:54
USHORT ProdId
Definition: isapnpres.h:55
USHORT VendorId
Definition: isapnphw.h:104
USHORT VendorId
Definition: isapnphw.h:97
USHORT ProdId
Definition: isapnphw.h:98
char * PSTR
Definition: typedefs.h:51
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065

Referenced by _Requires_lock_held_().

◆ Peek()

static VOID Peek ( _In_ PUCHAR  ReadDataPort,
_Out_writes_bytes_all_opt_(Length) PVOID  Buffer,
_In_ USHORT  Length 
)
static

Definition at line 379 of file hardware.c.

383{
384 USHORT i;
385
386 PAGED_CODE();
387
388 for (i = 0; i < Length; i++)
389 {
390 UCHAR Byte = PeekByte(ReadDataPort);
391
392 if (Buffer)
393 ((PUCHAR)Buffer)[i] = Byte;
394 }
395}
static UCHAR PeekByte(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:358
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by _Requires_lock_held_(), NpReadDataQueue(), and ReadTags().

◆ PeekByte()

static UCHAR PeekByte ( _In_ PUCHAR  ReadDataPort)
static

Definition at line 358 of file hardware.c.

360{
361 UCHAR i;
362
363 PAGED_CODE();
364
365 for (i = 0; i < 20; i++)
366 {
367 if (ReadStatus(ReadDataPort) & 0x01)
368 return ReadResourceData(ReadDataPort);
369
371 }
372
373 return 0xFF;
374}
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:172
static UCHAR ReadResourceData(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:163

Referenced by Peek(), and ReadTags().

◆ ReadByte()

static UCHAR ReadByte ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Address 
)
static

Definition at line 94 of file hardware.c.

97{
98 PAGED_CODE();
99
101 return ReadData(ReadDataPort);
102}
static WCHAR Address[46]
Definition: ping.c:68

Referenced by ActivateDevice(), ReadCurrentResources(), ReadDmaChannel(), ReadIrqNo(), ReadIrqType(), ReadMemoryControl(), ReadMemoryControl32(), ReadResourceData(), ReadStatus(), and ReadWord().

◆ ReadCurrentResources()

static BOOLEAN ReadCurrentResources ( _In_ PUCHAR  ReadDataPort,
_Inout_ PISAPNP_LOGICAL_DEVICE  LogDevice 
)
static

Definition at line 1053 of file hardware.c.

1056{
1057 UCHAR i;
1058
1059 PAGED_CODE();
1060
1061 DPRINT("%s for CSN %u, LDN %u\n", __FUNCTION__, LogDevice->CSN, LogDevice->LDN);
1062
1063 WriteLogicalDeviceNumber(LogDevice->LDN);
1064
1065 /* If the device is not activated by BIOS then the device has no boot resources */
1066 if (!(ReadByte(ReadDataPort, ISAPNP_ACTIVATE) & 1))
1067 {
1068 LogDevice->Flags &= ~ISAPNP_HAS_RESOURCES;
1069 return FALSE;
1070 }
1071
1072 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Io); i++)
1073 {
1074 LogDevice->Io[i].CurrentBase = ReadIoBase(ReadDataPort, i);
1075
1076 /* Skip empty descriptors */
1077 if (!LogDevice->Io[i].CurrentBase)
1078 break;
1079 }
1080 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Irq); i++)
1081 {
1082 LogDevice->Irq[i].CurrentNo = ReadIrqNo(ReadDataPort, i);
1083
1084 if (!LogDevice->Irq[i].CurrentNo)
1085 break;
1086
1087 LogDevice->Irq[i].CurrentType = ReadIrqType(ReadDataPort, i);
1088 }
1089 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Dma); i++)
1090 {
1091 LogDevice->Dma[i].CurrentChannel = ReadDmaChannel(ReadDataPort, i);
1092
1093 if (LogDevice->Dma[i].CurrentChannel == DMACHANNEL_NONE)
1094 break;
1095 }
1096 for (i = 0; i < RTL_NUMBER_OF(LogDevice->MemRange); i++)
1097 {
1098 LogDevice->MemRange[i].CurrentBase = ReadMemoryBase(ReadDataPort, i) << 8;
1099
1100 if (!LogDevice->MemRange[i].CurrentBase)
1101 break;
1102
1103 LogDevice->MemRange[i].CurrentLength = ReadMemoryLimit(ReadDataPort, i) << 8;
1104
1105 if (ReadMemoryControl(ReadDataPort, i) & MEMORY_UPPER_LIMIT)
1106 {
1107 LogDevice->MemRange[i].CurrentLength -= LogDevice->MemRange[i].CurrentBase;
1108 }
1109 else
1110 {
1111 LogDevice->MemRange[i].CurrentLength =
1112 RANGE_LENGTH_TO_LENGTH(LogDevice->MemRange[i].CurrentLength);
1113 }
1114 }
1115 for (i = 0; i < RTL_NUMBER_OF(LogDevice->MemRange32); i++)
1116 {
1117 LogDevice->MemRange32[i].CurrentBase = ReadMemoryBase32(ReadDataPort, i);
1118
1119 if (!LogDevice->MemRange32[i].CurrentBase)
1120 break;
1121
1122 LogDevice->MemRange32[i].CurrentLength = ReadMemoryLimit32(ReadDataPort, i);
1123
1124 if (ReadMemoryControl32(ReadDataPort, i) & MEMORY_UPPER_LIMIT)
1125 {
1126 LogDevice->MemRange32[i].CurrentLength -= LogDevice->MemRange32[i].CurrentBase;
1127 }
1128 else
1129 {
1130 LogDevice->MemRange32[i].CurrentLength =
1131 RANGE_LENGTH_TO_LENGTH(LogDevice->MemRange32[i].CurrentLength);
1132 }
1133 }
1134
1135 LogDevice->Flags |= ISAPNP_HAS_RESOURCES;
1136 return TRUE;
1137}
static USHORT ReadMemoryLimit(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:284
static USHORT ReadIoBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:224
static UCHAR ReadIrqType(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:244
static UCHAR ReadIrqNo(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:234
static ULONG ReadMemoryBase32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:294
static ULONG ReadMemoryLimit32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:314
static USHORT ReadMemoryBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:264
static UCHAR ReadDmaChannel(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:254
#define RANGE_LENGTH_TO_LENGTH(RangeLength)
Definition: isapnphw.h:82
#define ISAPNP_HAS_RESOURCES
Definition: isapnpres.h:102

Referenced by _Requires_lock_held_().

◆ ReadData()

static UCHAR ReadData ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 50 of file hardware.c.

52{
53 return READ_PORT_UCHAR(ReadDataPort);
54}
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22

◆ ReadDmaChannel()

static UCHAR ReadDmaChannel ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 254 of file hardware.c.

257{
258 return ReadByte(ReadDataPort, ISAPNP_DMACHANNEL(Index)) & 0x07;
259}

Referenced by ReadCurrentResources().

◆ ReadDoubleWord()

static ULONG ReadDoubleWord ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Address 
)
inlinestatic

Definition at line 118 of file hardware.c.

121{
122 return ((ReadWord(ReadDataPort, Address) << 16) |
123 (ReadWord(ReadDataPort, Address + 2)));
124}
static USHORT ReadWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:107

Referenced by ReadMemoryBase32(), and ReadMemoryLimit32().

◆ ReadIoBase()

static USHORT ReadIoBase ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 224 of file hardware.c.

227{
228 return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
229}

Referenced by ReadCurrentResources().

◆ ReadIrqNo()

static UCHAR ReadIrqNo ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 234 of file hardware.c.

237{
238 return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index)) & 0x0F;
239}

Referenced by ReadCurrentResources().

◆ ReadIrqType()

static UCHAR ReadIrqType ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 244 of file hardware.c.

247{
248 return ReadByte(ReadDataPort, ISAPNP_IRQTYPE(Index));
249}

Referenced by ReadCurrentResources().

◆ ReadMemoryBase()

static USHORT ReadMemoryBase ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 264 of file hardware.c.

267{
268 return ReadWord(ReadDataPort, ISAPNP_MEMBASE(Index));
269}

Referenced by ReadCurrentResources().

◆ ReadMemoryBase32()

static ULONG ReadMemoryBase32 ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 294 of file hardware.c.

297{
298 return ReadDoubleWord(ReadDataPort, ISAPNP_MEMBASE32(Index));
299}
static ULONG ReadDoubleWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:118

Referenced by ReadCurrentResources().

◆ ReadMemoryControl()

static UCHAR ReadMemoryControl ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 274 of file hardware.c.

277{
278 return ReadByte(ReadDataPort, ISAPNP_MEMCONTROL(Index));
279}

Referenced by IsaProgramMemoryDecoder(), and ReadCurrentResources().

◆ ReadMemoryControl32()

static UCHAR ReadMemoryControl32 ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 304 of file hardware.c.

307{
308 return ReadByte(ReadDataPort, ISAPNP_MEMCONTROL32(Index));
309}

Referenced by IsaProgramMemoryDecoder(), and ReadCurrentResources().

◆ ReadMemoryLimit()

static USHORT ReadMemoryLimit ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 284 of file hardware.c.

287{
288 return ReadWord(ReadDataPort, ISAPNP_MEMLIMIT(Index));
289}

Referenced by ReadCurrentResources().

◆ ReadMemoryLimit32()

static ULONG ReadMemoryLimit32 ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Index 
)
inlinestatic

Definition at line 314 of file hardware.c.

317{
318 return ReadDoubleWord(ReadDataPort, ISAPNP_MEMLIMIT32(Index));
319}

Referenced by ReadCurrentResources().

◆ ReadResourceData()

static UCHAR ReadResourceData ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 163 of file hardware.c.

165{
166 return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
167}
#define ISAPNP_RESOURCEDATA
Definition: isapnphw.h:26

Referenced by PeekByte().

◆ ReadStatus()

static UCHAR ReadStatus ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 172 of file hardware.c.

174{
175 return ReadByte(ReadDataPort, ISAPNP_STATUS);
176}
#define ISAPNP_STATUS
Definition: isapnphw.h:27

Referenced by MiSimpleRead(), PeekByte(), PitLatchChannelCount(), and PitReadData().

◆ ReadTags()

static NTSTATUS ReadTags ( _In_ PUCHAR  ReadDataPort,
_Out_writes_(ISAPNP_MAX_RESOURCEDATA) PUCHAR  Buffer,
_In_ ULONG  MaxLength,
_Out_ PUSHORT  MaxLogDev,
_Out_ PULONG  MaxTagsPerDevice 
)
static

Definition at line 439 of file hardware.c.

445{
446 ULONG TagCount = 0;
447
448 PAGED_CODE();
449
450 *MaxLogDev = 0;
451 *MaxTagsPerDevice = 0;
452
453 while (TRUE)
454 {
455 UCHAR Tag;
456 USHORT TagLen;
457
458 ++TagCount;
459
460 if (MaxLength < 1)
461 {
462 DPRINT("Too small tag\n");
464 }
465
466 Tag = PeekByte(ReadDataPort);
467 if (Tag == 0)
468 {
469 DPRINT("Invalid tag\n");
471 }
472 *Buffer++ = Tag;
473 --MaxLength;
474
476 {
477 TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
479 }
480 else
481 {
482 UCHAR Temp[2];
483
484 if (MaxLength < sizeof(Temp))
485 {
486 DPRINT("Too small tag\n");
488 }
489
490 Peek(ReadDataPort, &Temp, sizeof(Temp));
491 *Buffer++ = Temp[0];
492 *Buffer++ = Temp[1];
493 MaxLength -= sizeof(Temp);
494
495 TagLen = Temp[0] + (Temp[1] << 8);
497 }
498
499 if (Tag == 0xFF && TagLen == 0xFFFF)
500 {
501 DPRINT("Invalid tag\n");
503 }
504
505 if (TagLen > MaxLength)
506 {
507 DPRINT("Too large resource data structure\n");
509 }
510
511 Peek(ReadDataPort, Buffer, TagLen);
512 MaxLength -= TagLen;
513 Buffer += TagLen;
514
516 {
517 /* Attempt to guess the allocation size based on the tags available */
518 *MaxTagsPerDevice = max(*MaxTagsPerDevice, TagCount);
519 TagCount = 0;
520
521 (*MaxLogDev)++;
522 }
523 else if (Tag == ISAPNP_TAG_END)
524 {
525 *MaxTagsPerDevice = max(*MaxTagsPerDevice, TagCount);
526 break;
527 }
528 }
529
530 return STATUS_SUCCESS;
531}
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define max(a, b)
Definition: svc.c:63

Referenced by _Requires_lock_held_().

◆ ReadWord()

static USHORT ReadWord ( _In_ PUCHAR  ReadDataPort,
_In_ UCHAR  Address 
)
inlinestatic

Definition at line 107 of file hardware.c.

110{
111 return ((ReadByte(ReadDataPort, Address) << 8) |
112 (ReadByte(ReadDataPort, Address + 1)));
113}

Referenced by ReadDoubleWord(), ReadIoBase(), ReadMemoryBase(), and ReadMemoryLimit().

◆ SendKey()

static VOID SendKey ( VOID  )
static

Definition at line 338 of file hardware.c.

339{
340 UCHAR i, Lfsr;
341
342 PAGED_CODE();
343
344 WriteAddress(0x00);
345 WriteAddress(0x00);
346
347 Lfsr = ISAPNP_LFSR_SEED;
348 for (i = 0; i < 32; i++)
349 {
350 WriteAddress(Lfsr);
351 Lfsr = NextLFSR(Lfsr, 0);
352 }
353}

Referenced by IsaHwTryReadDataPort(), and IsaHwWakeDevice().

◆ SetReadDataPort()

static VOID SetReadDataPort ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 129 of file hardware.c.

131{
132 WriteByte(ISAPNP_READPORT, (UCHAR)((ULONG_PTR)ReadDataPort >> 2));
133}
#define ISAPNP_READPORT
Definition: isapnphw.h:22
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by IsaHwTryReadDataPort().

◆ WaitForKey()

static VOID WaitForKey ( VOID  )
inlinestatic

Definition at line 146 of file hardware.c.

Referenced by IsaHwWaitForKey().

◆ Wake()

static VOID Wake ( _In_ UCHAR  Csn)
inlinestatic

◆ WriteAddress()

static VOID WriteAddress ( _In_ UCHAR  Address)
inlinestatic

Definition at line 32 of file hardware.c.

34{
36}
ULONG IsaConfigPorts[2]
Definition: hardware.c:23
#define UlongToPtr(u)
Definition: config.h:106
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21

Referenced by EnterIsolationState(), ReadByte(), SendKey(), and WriteByte().

◆ WriteByte()

static VOID WriteByte ( _In_ UCHAR  Address,
_In_ UCHAR  Value 
)
static

Definition at line 59 of file hardware.c.

62{
63 PAGED_CODE();
64
67}
static VOID WriteData(_In_ UCHAR Data)
Definition: hardware.c:41
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by ActivateDevice(), DeactivateDevice(), IsaHwConfigureDevice(), IsaHwTryReadDataPort(), IsaProgramDmaSelect(), IsaProgramIrqSelect(), IsaProgramMemoryDecoder(), SetReadDataPort(), WaitForKey(), Wake(), WriteCsn(), WriteLogicalDeviceNumber(), and WriteWord().

◆ WriteCsn()

static VOID WriteCsn ( _In_ UCHAR  Csn)
inlinestatic

Definition at line 181 of file hardware.c.

183{
185}
#define ISAPNP_CARDSELECTNUMBER
Definition: isapnphw.h:28

Referenced by IsaHwTryReadDataPort().

◆ WriteData()

static VOID WriteData ( _In_ UCHAR  Data)
inlinestatic

Definition at line 41 of file hardware.c.

Referenced by DECLARE_INTERFACE_(), and WriteByte().

◆ WriteDoubleWord()

static VOID WriteDoubleWord ( _In_ UCHAR  Address,
_In_ ULONG  Value 
)
inlinestatic

Definition at line 83 of file hardware.c.

86{
88 WriteWord(Address, Value >> 16);
89}

Referenced by IsaHwConfigureDevice(), and IsaProgramMemoryDecoder().

◆ WriteLogicalDeviceNumber()

static VOID WriteLogicalDeviceNumber ( _In_ UCHAR  LogDev)
inlinestatic

Definition at line 190 of file hardware.c.

192{
194}
#define ISAPNP_LOGICALDEVICENUMBER
Definition: isapnphw.h:29

Referenced by ActivateDevice(), DeactivateDevice(), IsaHwConfigureDevice(), and ReadCurrentResources().

◆ WriteWord()

static VOID WriteWord ( _In_ UCHAR  Address,
_In_ USHORT  Value 
)
inlinestatic

Variable Documentation

◆ IsaConfigPorts

ULONG IsaConfigPorts[2]
Initial value:
=
{
}
#define ISAPNP_ADDRESS_PCAT
Definition: isapnphw.h:16
#define ISAPNP_WRITE_DATA_PCAT
Definition: isapnphw.h:17

Definition at line 23 of file hardware.c.

Referenced by DriverEntry(), IsaPnpCreateReadPortDORequirements(), IsaPnpCreateReadPortDOResources(), WriteAddress(), and WriteData().