ReactOS 0.4.15-dev-5666-gc548b97
hardware.c File Reference
#include "isapnp.h"
#include <debug.h>
Include dependency graph for hardware.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Enumerations

enum  DEPEDENT_FUNCTION_STATE { dfNotStarted , dfStarted , dfDone }
 

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 VOID PeekCached (_In_reads_bytes_(Length) PUCHAR ResourceData, _Out_writes_bytes_all_(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)
 
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 WriteResources (_In_ PUCHAR ReadDataPort, _In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ PCM_PARTIAL_RESOURCE_LIST PartialResourceList)
 
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)
 
 _IRQL_requires_max_ (DISPATCH_LEVEL)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file hardware.c.

Enumeration Type Documentation

◆ DEPEDENT_FUNCTION_STATE

Enumerator
dfNotStarted 
dfStarted 
dfDone 

Definition at line 19 of file hardware.c.

20{
23 dfDone
DEPEDENT_FUNCTION_STATE
Definition: hardware.c:20
@ dfDone
Definition: hardware.c:23
@ dfStarted
Definition: hardware.c:22
@ dfNotStarted
Definition: hardware.c:21

Function Documentation

◆ _IRQL_requires_max_()

_IRQL_requires_max_ ( DISPATCH_LEVEL  )

Definition at line 1705 of file hardware.c.

1709{
1710 SendKey();
1712}
static VOID SendKey(VOID)
Definition: hardware.c:332
static VOID Wake(_In_ UCHAR Csn)
Definition: hardware.c:149
_In_ PISAPNP_LOGICAL_DEVICE LogicalDevice
Definition: isapnp.h:399

◆ _Requires_lock_held_()

_Requires_lock_held_ ( FdoExt->  DeviceSyncEvent)

Definition at line 1460 of file hardware.c.

1465{
1466 PISAPNP_LOGICAL_DEVICE LogDevice;
1467 UCHAR Csn;
1469 PUCHAR ResourceData;
1470
1471 PAGED_CODE();
1472 ASSERT(FdoExt->ReadDataPort);
1473
1474 DPRINT("%s for read port 0x%p\n", __FUNCTION__, FdoExt->ReadDataPort);
1475
1477 if (!ResourceData)
1478 {
1479 DPRINT1("Failed to allocate memory for cache data\n");
1481 }
1482
1483 for (Entry = FdoExt->DeviceListHead.Flink;
1484 Entry != &FdoExt->DeviceListHead;
1485 Entry = Entry->Flink)
1486 {
1487 LogDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1488
1489 LogDevice->Flags &= ~ISAPNP_PRESENT;
1490 }
1491
1492 for (Csn = 1; Csn <= FdoExt->Cards; Csn++)
1493 {
1495 UCHAR TempId[3], LogDev;
1497 USHORT MaxLogDev;
1498
1499 Wake(Csn);
1500
1501 Peek(FdoExt->ReadDataPort, &Identifier, sizeof(Identifier));
1502
1503 IsaPnpExtractAscii(TempId, Identifier.VendorId);
1504 Identifier.ProdId = RtlUshortByteSwap(Identifier.ProdId);
1505
1506 Status = ReadTags(FdoExt->ReadDataPort, ResourceData, ISAPNP_MAX_RESOURCEDATA, &MaxLogDev);
1507 if (!NT_SUCCESS(Status))
1508 {
1509 DPRINT1("Failed to read tags with status 0x%08lx, CSN %u\n", Status, Csn);
1510 continue;
1511 }
1512
1513 DPRINT("Detected ISA PnP device - VID: '%.3s' PID: 0x%04x SN: 0x%08lX\n",
1514 TempId, Identifier.ProdId, Identifier.Serial);
1515
1516 for (LogDev = 0; LogDev < MaxLogDev; LogDev++)
1517 {
1518 BOOLEAN IsAlreadyEnumerated = FALSE;
1519
1520 for (Entry = FdoExt->DeviceListHead.Flink;
1521 Entry != &FdoExt->DeviceListHead;
1522 Entry = Entry->Flink)
1523 {
1524 LogDevice = CONTAINING_RECORD(Entry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1525
1526 /* This logical device has already been enumerated */
1527 if ((LogDevice->SerialNumber == Identifier.Serial) &&
1528 (RtlCompareMemory(LogDevice->VendorId, TempId, 3) == 3) &&
1529 (LogDevice->ProdId == Identifier.ProdId) &&
1530 (LogDevice->LDN == LogDev))
1531 {
1532 LogDevice->Flags |= ISAPNP_PRESENT;
1533
1534 /* Assign a new CSN */
1535 LogDevice->CSN = Csn;
1536
1537 if (LogDevice->Pdo)
1538 {
1540
1541 if (PdoExt->Common.State == dsStarted)
1542 ActivateDevice(FdoExt->ReadDataPort, LogDev);
1543 }
1544
1545 DPRINT("Skip CSN %u, LDN %u\n", LogDevice->CSN, LogDevice->LDN);
1546 IsAlreadyEnumerated = TRUE;
1547 break;
1548 }
1549 }
1550
1551 if (IsAlreadyEnumerated)
1552 continue;
1553
1554 LogDevice = ExAllocatePoolZero(NonPagedPool, sizeof(ISAPNP_LOGICAL_DEVICE), TAG_ISAPNP);
1555 if (!LogDevice)
1556 {
1557 DPRINT1("Failed to allocate logical device!\n");
1558 goto Deactivate;
1559 }
1560
1562
1563 LogDevice->CSN = Csn;
1564 LogDevice->LDN = LogDev;
1565
1566 Status = ParseTags(ResourceData, LogDev, LogDevice);
1567 if (!NT_SUCCESS(Status))
1568 {
1569 DPRINT1("Failed to parse tags with status 0x%08lx, CSN %u, LDN %u\n",
1570 Status, LogDevice->CSN, LogDevice->LDN);
1571 FreeLogicalDevice(LogDevice);
1572 goto Deactivate;
1573 }
1574
1575 if (!ReadCurrentResources(FdoExt->ReadDataPort, LogDevice))
1576 DPRINT("Unable to read boot resources\n");
1577
1578 IsaPnpExtractAscii(LogDevice->VendorId, Identifier.VendorId);
1579 LogDevice->ProdId = Identifier.ProdId;
1580 LogDevice->SerialNumber = Identifier.Serial;
1581
1582 if (MaxLogDev > 1)
1583 LogDevice->Flags |= ISAPNP_HAS_MULTIPLE_LOGDEVS;
1584
1585 LogDevice->Flags |= ISAPNP_PRESENT;
1586
1587 InsertTailList(&FdoExt->DeviceListHead, &LogDevice->DeviceLink);
1588 FdoExt->DeviceCount++;
1589
1590 /* Now we wait for the start device IRP */
1591Deactivate:
1592 DeactivateDevice(LogDev);
1593 }
1594 }
1595
1596 ExFreePoolWithTag(ResourceData, TAG_ISAPNP);
1597
1598 return STATUS_SUCCESS;
1599}
#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:32
static NTSTATUS ParseTags(_In_ PUCHAR ResourceData, _In_ USHORT LogDevToParse, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:555
static VOID Peek(_In_ PUCHAR ReadDataPort, _Out_writes_bytes_all_opt_(Length) PVOID Buffer, _In_ USHORT Length)
Definition: hardware.c:371
static VOID ActivateDevice(_In_ PUCHAR ReadDataPort, _In_ UCHAR LogDev)
Definition: hardware.c:194
static VOID FreeLogicalDevice(_In_ __drv_freesMem(Mem) PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:523
static VOID DeactivateDevice(_In_ UCHAR LogDev)
Definition: hardware.c:209
static VOID IsaPnpExtractAscii(_Out_writes_all_(3) PUCHAR Buffer, _In_ USHORT CompressedData)
Definition: hardware.c:435
static NTSTATUS ReadTags(_In_ PUCHAR ReadDataPort, _Out_writes_(ISAPNP_MAX_RESOURCEDATA) PUCHAR Buffer, _In_ ULONG MaxLength, _Out_ PUSHORT MaxLogDev)
Definition: hardware.c:449
static BOOLEAN ReadCurrentResources(_In_ PUCHAR ReadDataPort, _Inout_ PISAPNP_LOGICAL_DEVICE LogDevice)
Definition: hardware.c:1105
#define __FUNCTION__
Definition: types.h:112
#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:24
#define ISAPNP_HAS_MULTIPLE_LOGDEVS
Indicates if the parent card has multiple logical devices.
Definition: isapnp.h:135
@ dsStarted
Definition: isapnp.h:35
#define ISAPNP_MAX_RESOURCEDATA
Maximum size of resource data structure supported by the driver.
Definition: isapnp.h:27
#define ISAPNP_PRESENT
Cleared when the device is physically removed.
Definition: isapnp.h:134
unsigned char * PUCHAR
Definition: retypes.h:3
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
base of all file and directory entries
Definition: entries.h:83
PVOID DeviceExtension
Definition: env_spec_w32.h:418
LIST_ENTRY CompatibleIdList
Definition: isapnp.h:122
PDEVICE_OBJECT Pdo
Definition: isapnp.h:103
LIST_ENTRY DeviceLink
Definition: isapnp.h:138
Definition: typedefs.h:120
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#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:3197
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ ActivateDevice()

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

Definition at line 194 of file hardware.c.

197{
199
201 ReadByte(ReadDataPort, ISAPNP_IORANGECHECK) & ~2);
202
204}
static VOID WriteByte(_In_ UCHAR Address, _In_ UCHAR Value)
Definition: hardware.c:56
static UCHAR ReadByte(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:91
static VOID WriteLogicalDeviceNumber(_In_ UCHAR LogDev)
Definition: hardware.c:185
#define ISAPNP_IORANGECHECK
Definition: isapnphw.h:34
#define ISAPNP_ACTIVATE
Definition: isapnphw.h:33

Referenced by _Requires_lock_held_().

◆ DeactivateDevice()

static VOID DeactivateDevice ( _In_ UCHAR  LogDev)
inlinestatic

Definition at line 209 of file hardware.c.

211{
214}

Referenced by _Requires_lock_held_().

◆ EnterIsolationState()

static VOID EnterIsolationState ( VOID  )
inlinestatic

Definition at line 133 of file hardware.c.

134{
136}
static VOID WriteAddress(_In_ UCHAR Address)
Definition: hardware.c:29
#define ISAPNP_SERIALISOLATION
Definition: isapnphw.h:25

Referenced by IsaHwTryReadDataPort().

◆ FreeLogicalDevice()

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

Definition at line 523 of file hardware.c.

525{
527
528 PAGED_CODE();
529
530 if (LogDevice->FriendlyName)
531 ExFreePoolWithTag(LogDevice->FriendlyName, TAG_ISAPNP);
532
533 if (LogDevice->Alternatives)
534 ExFreePoolWithTag(LogDevice->Alternatives, TAG_ISAPNP);
535
536 Entry = LogDevice->CompatibleIdList.Flink;
537 while (Entry != &LogDevice->CompatibleIdList)
538 {
539 PISAPNP_COMPATIBLE_ID_ENTRY CompatibleId =
541
542 RemoveEntryList(&CompatibleId->IdLink);
543
544 Entry = Entry->Flink;
545
546 ExFreePoolWithTag(CompatibleId, TAG_ISAPNP);
547 }
548
549 ExFreePoolWithTag(LogDevice, TAG_ISAPNP);
550}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
Definition: isapnp.h:77
LIST_ENTRY IdLink
Definition: isapnp.h:80

Referenced by _Requires_lock_held_().

◆ IsaHwConfigureDevice()

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

Definition at line 1603 of file hardware.c.

1607{
1608 UCHAR i,
1609 NumberOfIo = 0,
1610 NumberOfIrq = 0,
1611 NumberOfDma = 0,
1612 NumberOfMemory = 0;
1613
1614 PAGED_CODE();
1615
1616 if (!Resources)
1618
1619 /* Validate the resource list */
1620 for (i = 0; i < Resources->List[0].PartialResourceList.Count; i++)
1621 {
1623 &Resources->List[0].PartialResourceList.PartialDescriptors[i];
1624
1625 switch (Descriptor->Type)
1626 {
1627 case CmResourceTypePort:
1628 {
1629 if (++NumberOfIo > RTL_NUMBER_OF(LogicalDevice->Io))
1631
1633 0,
1634 Descriptor->u.Port.Start.LowPart,
1635 Descriptor->u.Port.Start.LowPart +
1636 Descriptor->u.Port.Length - 1,
1637 NULL,
1638 NULL,
1639 NULL))
1640 {
1642 }
1643
1644 break;
1645 }
1646
1648 {
1649 if (++NumberOfIrq > RTL_NUMBER_OF(LogicalDevice->Irq))
1651
1652 if (!FindIrqDescriptor(LogicalDevice, Descriptor->u.Interrupt.Level, NULL))
1654
1655 break;
1656 }
1657
1658 case CmResourceTypeDma:
1659 {
1660 if (++NumberOfDma > RTL_NUMBER_OF(LogicalDevice->Dma))
1662
1665
1666 break;
1667 }
1668
1670 {
1671 BOOLEAN Memory32;
1672
1673 if (++NumberOfMemory > RTL_NUMBER_OF(LogicalDevice->MemRange))
1675
1677 Descriptor->u.Memory.Start.LowPart,
1678 Descriptor->u.Memory.Start.LowPart +
1679 Descriptor->u.Memory.Length - 1,
1680 &Memory32,
1681 NULL,
1682 NULL))
1683 {
1685 }
1686
1687 if (!Memory32 && (Descriptor->u.Memory.Start.LowPart & 0xFF))
1689
1690 break;
1691 }
1692
1693 default:
1694 break;
1695 }
1696 }
1697
1698 WriteResources(FdoExt->ReadDataPort, LogicalDevice, &Resources->List[0].PartialResourceList);
1699
1701
1702 return STATUS_SUCCESS;
1703}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:81
#define NULL
Definition: types.h:112
static VOID WriteResources(_In_ PUCHAR ReadDataPort, _In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ PCM_PARTIAL_RESOURCE_LIST PartialResourceList)
Definition: hardware.c:1194
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_ PBOOLEAN Memory32, _Out_opt_ PUCHAR Information, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:695
BOOLEAN FindIrqDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG Vector, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:583
BOOLEAN FindIoDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_opt_ ULONG Base, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information, _Out_opt_ PULONG Length, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:518
BOOLEAN FindDmaDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG Channel, _Out_opt_ PUCHAR WriteOrder)
Definition: isapnp.c:639
#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
ISAPNP_IO Io[8]
Definition: isapnp.h:126
ISAPNP_DMA Dma[2]
Definition: isapnp.h:128
ISAPNP_MEMRANGE MemRange[4]
Definition: isapnp.h:129
ISAPNP_IRQ Irq[2]
Definition: isapnp.h:127
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342

Referenced by IsaPdoPnp().

◆ IsaHwTryReadDataPort()

UCHAR IsaHwTryReadDataPort ( _In_ PUCHAR  ReadDataPort)

Definition at line 1362 of file hardware.c.

1364{
1365 ULONG NumberOfRead = 0;
1366 UCHAR Csn = 0;
1367
1368 PAGED_CODE();
1369
1370 DPRINT("Setting read data port: 0x%p\n", ReadDataPort);
1371
1372 SendKey();
1373
1377
1378 SendKey();
1379
1380 Wake(0x00);
1382
1383 SetReadDataPort(ReadDataPort);
1384
1385 Wake(0x00);
1386
1387 while (TRUE)
1388 {
1390 UCHAR i, j;
1391 BOOLEAN Seen55aa = FALSE;
1392
1395
1397
1398 for (i = 0; i < sizeof(Identifier); i++)
1399 {
1400 UCHAR Byte = 0;
1401
1402 for (j = 0; j < RTL_BITS_OF(Byte); j++)
1403 {
1404 USHORT Data;
1405
1406 Data = ReadData(ReadDataPort) << 8;
1408 Data |= ReadData(ReadDataPort);
1410
1411 Byte >>= 1;
1412
1413 if (Data == 0x55AA)
1414 {
1415 Byte |= 0x80;
1416 Seen55aa = TRUE;
1417 }
1418 }
1419
1420 ((PUCHAR)&Identifier)[i] = Byte;
1421 }
1422
1423 ++NumberOfRead;
1424
1425 if (Identifier.Checksum != 0x00 &&
1426 Identifier.Checksum != IsaPnpChecksum(&Identifier))
1427 {
1428 DPRINT("Bad checksum\n");
1429 break;
1430 }
1431
1432 if (!Seen55aa)
1433 {
1434 DPRINT("Saw no sign of life\n");
1435 break;
1436 }
1437
1438 Csn++;
1439
1440 WriteCsn(Csn);
1442
1443 Wake(0x00);
1444 }
1445
1446 Wake(0x00);
1447
1448 if (NumberOfRead == 1)
1449 {
1450 DPRINT("Trying next read data port\n");
1451 return 0;
1452 }
1453 else
1454 {
1455 DPRINT("Found %u cards at read port 0x%p\n", Csn, ReadDataPort);
1456 return Csn;
1457 }
1458}
@ ReadData
Definition: amstream.idl:63
unsigned char Byte
Definition: zlib.h:37
static VOID SetReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:124
static VOID WriteCsn(_In_ UCHAR Csn)
Definition: hardware.c:176
static VOID EnterIsolationState(VOID)
Definition: hardware.c:133
static UCHAR IsaPnpChecksum(_In_ PISAPNP_IDENTIFIER Identifier)
Definition: hardware.c:410
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:54
#define ISAPNP_CONFIGCONTROL
Definition: isapnphw.h:26
#define ISAPNP_CONFIG_RESET_CSN
Definition: isapnphw.h:55
unsigned int ULONG
Definition: retypes.h:1
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:668
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by IsaPdoStartReadPort(), and IsaPnpFillDeviceRelations().

◆ IsaPnpChecksum()

static UCHAR IsaPnpChecksum ( _In_ PISAPNP_IDENTIFIER  Identifier)
static

Definition at line 410 of file hardware.c.

412{
413 UCHAR i, j, Lfsr;
414
415 PAGED_CODE();
416
417 Lfsr = ISAPNP_LFSR_SEED;
418 for (i = 0; i < FIELD_OFFSET(ISAPNP_IDENTIFIER, Checksum); i++)
419 {
421
422 for (j = 0; j < RTL_BITS_OF(Byte); j++)
423 {
424 Lfsr = NextLFSR(Lfsr, Byte);
425 Byte >>= 1;
426 }
427 }
428
429 return Lfsr;
430}
static UCHAR NextLFSR(_In_ UCHAR Lfsr, _In_ UCHAR InputBit)
Definition: hardware.c:319
#define ISAPNP_LFSR_SEED
Definition: isapnphw.h:57
#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 435 of file hardware.c.

438{
439 PAGED_CODE();
440
441 Buffer[0] = ((CompressedData >> 2) & 0x1F) + 'A' - 1;
442 Buffer[1] = (((CompressedData & 0x3) << 3) | ((CompressedData >> 13) & 0x7)) + 'A' - 1;
443 Buffer[2] = ((CompressedData >> 8) & 0x1F) + 'A' - 1;
444}
Definition: bufpool.h:45

Referenced by _Requires_lock_held_(), and ParseTags().

◆ NextLFSR()

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

Definition at line 319 of file hardware.c.

322{
323 UCHAR NextLfsr = Lfsr >> 1;
324
325 NextLfsr |= (((Lfsr ^ NextLfsr) ^ InputBit)) << 7;
326
327 return NextLfsr;
328}

Referenced by IsaPnpChecksum(), and SendKey().

◆ ParseTags()

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

Definition at line 555 of file hardware.c.

559{
560 USHORT LogDev;
562 PUCHAR IdStrPos = NULL;
563 USHORT IdStrLen = 0;
564 UCHAR NumberOfIo = 0,
565 NumberOfIrq = 0,
566 NumberOfDma = 0,
567 NumberOfMemRange = 0,
568 NumberOfMemRange32 = 0,
569 NumberOfDepedentSet = 0;
570
571 PAGED_CODE();
572
573 DPRINT("%s for CSN %u, LDN %u\n", __FUNCTION__, LogDevice->CSN, LogDevice->LDN);
574
575 LogDev = LogDevToParse + 1;
576
577 while (TRUE)
578 {
579 UCHAR Tag;
580 USHORT TagLen;
581
582 Tag = *ResourceData++;
583
585 {
586 TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
588 }
589 else
590 {
591 TagLen = *ResourceData++;
592 TagLen += *ResourceData++ << 8;
593
595 }
596
597 switch (Tag)
598 {
600 {
601 ISAPNP_LOGDEVID Temp;
602
603 --LogDev;
604
605 if (LogDev != 0 ||
606 (TagLen > sizeof(ISAPNP_LOGDEVID) ||
607 TagLen < (sizeof(ISAPNP_LOGDEVID) - 1)))
608 {
609 goto SkipTag;
610 }
611
612 PeekCached(ResourceData, &Temp, TagLen);
613 ResourceData += TagLen;
614
615 DPRINT("Found tag 0x%X (len %u)\n"
616 " VendorId 0x%04X\n"
617 " ProdId 0x%04X\n",
618 Tag, TagLen,
619 Temp.VendorId,
620 Temp.ProdId);
621
622 IsaPnpExtractAscii(LogDevice->LogVendorId, Temp.VendorId);
623 LogDevice->LogProdId = RtlUshortByteSwap(Temp.ProdId);
624
625 break;
626 }
627
629 {
630 ISAPNP_COMPATID Temp;
631 PISAPNP_COMPATIBLE_ID_ENTRY CompatibleId;
632
633 if (LogDev != 0 || TagLen != sizeof(ISAPNP_COMPATID))
634 goto SkipTag;
635
636 CompatibleId = ExAllocatePoolWithTag(PagedPool,
638 TAG_ISAPNP);
639 if (!CompatibleId)
641
642 PeekCached(ResourceData, &Temp, TagLen);
643 ResourceData += TagLen;
644
645 DPRINT("Found tag 0x%X (len %u)\n"
646 " VendorId 0x%04X\n"
647 " ProdId 0x%04X\n",
648 Tag, TagLen,
649 Temp.VendorId,
650 Temp.ProdId);
651
652 IsaPnpExtractAscii(CompatibleId->VendorId, Temp.VendorId);
653 CompatibleId->ProdId = RtlUshortByteSwap(Temp.ProdId);
654
655 InsertTailList(&LogDevice->CompatibleIdList, &CompatibleId->IdLink);
656
657 break;
658 }
659
660 case ISAPNP_TAG_IRQ:
661 {
663
664 if (LogDev != 0 ||
665 (TagLen > sizeof(ISAPNP_IRQ_DESCRIPTION) ||
666 TagLen < (sizeof(ISAPNP_IRQ_DESCRIPTION) - 1)) ||
667 NumberOfIrq >= RTL_NUMBER_OF(LogDevice->Irq))
668 {
669 goto SkipTag;
670 }
671
672 if (DfState == dfStarted)
673 {
674 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
675 goto SkipTag;
676
677 Description = &LogDevice->Alternatives->Irq[NumberOfDepedentSet];
678 }
679 else
680 {
681 Description = &LogDevice->Irq[NumberOfIrq].Description;
682
683 LogDevice->Irq[NumberOfIrq].Index = NumberOfIrq;
684 ++NumberOfIrq;
685 }
686
687 PeekCached(ResourceData, Description, TagLen);
688 ResourceData += TagLen;
689
690 if (TagLen == (sizeof(ISAPNP_IRQ_DESCRIPTION) - 1))
691 Description->Information = 0x01;
692
693 DPRINT("Found tag 0x%X (len %u)\n"
694 " Mask 0x%X\n"
695 " Information 0x%X\n",
696 Tag, TagLen,
697 Description->Mask,
698 Description->Information);
699
700 break;
701 }
702
703 case ISAPNP_TAG_DMA:
704 {
706
707 if (LogDev != 0 || TagLen != sizeof(ISAPNP_DMA_DESCRIPTION) ||
708 NumberOfDma >= RTL_NUMBER_OF(LogDevice->Dma))
709 {
710 goto SkipTag;
711 }
712
713 if (DfState == dfStarted)
714 {
715 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
716 goto SkipTag;
717
718 Description = &LogDevice->Alternatives->Dma[NumberOfDepedentSet];
719 }
720 else
721 {
722 Description = &LogDevice->Dma[NumberOfDma].Description;
723
724 LogDevice->Dma[NumberOfDma].Index = NumberOfDma;
725 ++NumberOfDma;
726 }
727
728 PeekCached(ResourceData, Description, TagLen);
729 ResourceData += TagLen;
730
731 DPRINT("Found tag 0x%X (len %u)\n"
732 " Mask 0x%X\n"
733 " Information 0x%X\n",
734 Tag, TagLen,
735 Description->Mask,
736 Description->Information);
737
738 break;
739 }
740
742 {
743 if (LogDev != 0 || TagLen > 1 ||
744 NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
745 {
746 goto SkipTag;
747 }
748
749 if (DfState == dfNotStarted)
750 {
751 LogDevice->Alternatives = ExAllocatePoolZero(PagedPool,
752 sizeof(ISAPNP_ALTERNATIVES),
753 TAG_ISAPNP);
754 if (!LogDevice->Alternatives)
756
757 DfState = dfStarted;
758 }
759 else if (DfState == dfStarted)
760 {
761 ++NumberOfDepedentSet;
762 }
763 else
764 {
765 goto SkipTag;
766 }
767
768 ++LogDevice->Alternatives->Count;
769
770 if (TagLen != 1)
771 {
772 LogDevice->Alternatives->Priority[NumberOfDepedentSet] = 1;
773 }
774 else
775 {
776 PeekCached(ResourceData,
777 &LogDevice->Alternatives->Priority[NumberOfDepedentSet],
778 TagLen);
779 ResourceData += TagLen;
780 }
781
782 DPRINT("*** Start depedent set %u, priority %u ***\n",
783 NumberOfDepedentSet,
784 LogDevice->Alternatives->Priority[NumberOfDepedentSet]);
785
786 break;
787 }
788
790 {
791 if (LogDev != 0 || DfState != dfStarted)
792 goto SkipTag;
793
794 DfState = dfDone;
795
796 ResourceData += TagLen;
797
798 if (HasIoAlternatives(LogDevice->Alternatives))
799 LogDevice->Alternatives->IoIndex = NumberOfIo++;
800 if (HasIrqAlternatives(LogDevice->Alternatives))
801 LogDevice->Alternatives->IrqIndex = NumberOfIrq++;
802 if (HasDmaAlternatives(LogDevice->Alternatives))
803 LogDevice->Alternatives->DmaIndex = NumberOfDma++;
804 if (HasMemoryAlternatives(LogDevice->Alternatives))
805 LogDevice->Alternatives->MemRangeIndex = NumberOfMemRange++;
806 if (HasMemory32Alternatives(LogDevice->Alternatives))
807 LogDevice->Alternatives->MemRange32Index = NumberOfMemRange32++;
808
809 DPRINT("*** End of depedent set ***\n");
810
811 break;
812 }
813
815 {
817
818 if (LogDev != 0 || TagLen != sizeof(ISAPNP_IO_DESCRIPTION) ||
819 NumberOfIo >= RTL_NUMBER_OF(LogDevice->Io))
820 {
821 goto SkipTag;
822 }
823
824 if (DfState == dfStarted)
825 {
826 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
827 goto SkipTag;
828
829 Description = &LogDevice->Alternatives->Io[NumberOfDepedentSet];
830 }
831 else
832 {
833 Description = &LogDevice->Io[NumberOfIo].Description;
834
835 LogDevice->Io[NumberOfIo].Index = NumberOfIo;
836 ++NumberOfIo;
837 }
838
839 PeekCached(ResourceData, Description, TagLen);
840 ResourceData += TagLen;
841
842 DPRINT("Found tag 0x%X (len %u)\n"
843 " Information 0x%X\n"
844 " Minimum 0x%X\n"
845 " Maximum 0x%X\n"
846 " Alignment 0x%X\n"
847 " Length 0x%X\n",
848 Tag, TagLen,
849 Description->Information,
850 Description->Minimum,
851 Description->Maximum,
852 Description->Alignment,
853 Description->Length);
854
855 break;
856 }
857
859 {
862
863 if (LogDev != 0 || TagLen != sizeof(ISAPNP_FIXED_IO_DESCRIPTION) ||
864 NumberOfIo >= RTL_NUMBER_OF(LogDevice->Io))
865 {
866 goto SkipTag;
867 }
868
869 if (DfState == dfStarted)
870 {
871 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
872 goto SkipTag;
873
874 Description = &LogDevice->Alternatives->Io[NumberOfDepedentSet];
875 }
876 else
877 {
878 Description = &LogDevice->Io[NumberOfIo].Description;
879
880 LogDevice->Io[NumberOfIo].Index = NumberOfIo;
881 ++NumberOfIo;
882 }
883
884 PeekCached(ResourceData, &Temp, TagLen);
885 ResourceData += TagLen;
886
887 Description->Information = 0;
888 Description->Minimum =
889 Description->Maximum = Temp.IoBase;
890 Description->Alignment = 1;
891 Description->Length = Temp.Length;
892
893 DPRINT("Found tag 0x%X (len %u)\n"
894 " IoBase 0x%X\n"
895 " Length 0x%X\n",
896 Tag, TagLen,
897 Temp.IoBase,
898 Temp.Length);
899
900 break;
901 }
902
903 case ISAPNP_TAG_END:
904 {
905 if (IdStrPos)
906 {
907 PSTR End;
908
909 LogDevice->FriendlyName = ExAllocatePoolWithTag(PagedPool,
910 IdStrLen + sizeof(ANSI_NULL),
911 TAG_ISAPNP);
912 if (!LogDevice->FriendlyName)
914
915 PeekCached(IdStrPos, LogDevice->FriendlyName, IdStrLen);
916
917 End = LogDevice->FriendlyName + IdStrLen - 1;
918 while (End > LogDevice->FriendlyName && *End == ' ')
919 {
920 --End;
921 }
922 *++End = ANSI_NULL;
923 }
924
925 return STATUS_SUCCESS;
926 }
927
929 {
931
932 if (LogDev != 0 || TagLen != sizeof(ISAPNP_MEMRANGE_DESCRIPTION) ||
933 NumberOfMemRange >= RTL_NUMBER_OF(LogDevice->MemRange))
934 {
935 goto SkipTag;
936 }
937
938 if (DfState == dfStarted)
939 {
940 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
941 goto SkipTag;
942
943 Description = &LogDevice->Alternatives->MemRange[NumberOfDepedentSet];
944 }
945 else
946 {
947 Description = &LogDevice->MemRange[NumberOfMemRange].Description;
948
949 LogDevice->MemRange[NumberOfMemRange].Index = NumberOfMemRange;
950 ++NumberOfMemRange;
951 }
952
953 PeekCached(ResourceData, Description, TagLen);
954 ResourceData += TagLen;
955
956 DPRINT("Found tag 0x%X (len %u)\n"
957 " Information 0x%X\n"
958 " Minimum 0x%X\n"
959 " Maximum 0x%X\n"
960 " Alignment 0x%X\n"
961 " Length 0x%X\n",
962 Tag, TagLen,
963 Description->Information,
964 Description->Minimum,
965 Description->Maximum,
966 Description->Alignment,
967 Description->Length);
968
969 break;
970 }
971
973 {
974 /* If logical device identifier is not supplied, use card identifier */
975 if (LogDev == LogDevToParse + 1 || LogDev == 0)
976 {
977 IdStrPos = ResourceData;
978 IdStrLen = TagLen;
979
980 ResourceData += TagLen;
981
982 DPRINT("Found tag 0x%X (len %u)\n"
983 " '%.*s'\n",
984 Tag, TagLen,
985 IdStrLen,
986 IdStrPos);
987 }
988 else
989 {
990 goto SkipTag;
991 }
992
993 break;
994 }
995
997 {
999
1000 if (LogDev != 0 || TagLen != sizeof(ISAPNP_MEMRANGE32_DESCRIPTION) ||
1001 NumberOfMemRange32 >= RTL_NUMBER_OF(LogDevice->MemRange32))
1002 {
1003 goto SkipTag;
1004 }
1005
1006 if (DfState == dfStarted)
1007 {
1008 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
1009 goto SkipTag;
1010
1011 Description = &LogDevice->Alternatives->MemRange32[NumberOfDepedentSet];
1012 }
1013 else
1014 {
1015 Description = &LogDevice->MemRange32[NumberOfMemRange32].Description;
1016
1017 LogDevice->MemRange32[NumberOfMemRange32].Index = NumberOfMemRange32;
1018 ++NumberOfMemRange32;
1019 }
1020
1021 PeekCached(ResourceData, Description, TagLen);
1022 ResourceData += TagLen;
1023
1024 DPRINT("Found tag 0x%X (len %u)\n"
1025 " Information 0x%X\n"
1026 " Minimum 0x%08lX\n"
1027 " Maximum 0x%08lX\n"
1028 " Alignment 0x%08lX\n"
1029 " Length 0x%08lX\n",
1030 Tag, TagLen,
1031 Description->Information,
1032 Description->Minimum,
1033 Description->Maximum,
1034 Description->Alignment,
1035 Description->Length);
1036
1037 break;
1038 }
1039
1041 {
1044
1045 if (LogDev != 0 || TagLen != sizeof(ISAPNP_FIXEDMEMRANGE_DESCRIPTION) ||
1046 NumberOfMemRange32 >= RTL_NUMBER_OF(LogDevice->MemRange32))
1047 {
1048 goto SkipTag;
1049 }
1050
1051 if (DfState == dfStarted)
1052 {
1053 if (NumberOfDepedentSet >= ISAPNP_MAX_ALTERNATIVES)
1054 goto SkipTag;
1055
1056 Description = &LogDevice->Alternatives->MemRange32[NumberOfDepedentSet];
1057 }
1058 else
1059 {
1060 Description = &LogDevice->MemRange32[NumberOfMemRange32].Description;
1061
1062 LogDevice->MemRange32[NumberOfMemRange32].Index = NumberOfMemRange32;
1063 ++NumberOfMemRange32;
1064 }
1065
1066 PeekCached(ResourceData, &Temp, TagLen);
1067 ResourceData += TagLen;
1068
1069 Description->Information = Temp.Information;
1070 Description->Minimum =
1071 Description->Maximum = Temp.MemoryBase;
1072 Description->Alignment = 1;
1073 Description->Length = Temp.Length;
1074
1075 DPRINT("Found tag 0x%X (len %u)\n"
1076 " Information 0x%X\n"
1077 " MemoryBase 0x%08lX\n"
1078 " Length 0x%08lX\n",
1079 Tag, TagLen,
1080 Temp.Information,
1081 Temp.MemoryBase,
1082 Temp.Length);
1083
1084 break;
1085 }
1086
1087SkipTag:
1088 default:
1089 {
1090 if (LogDev == 0)
1091 DPRINT("Found unknown tag 0x%X (len %u)\n", Tag, TagLen);
1092
1093 /* We don't want to read informations on this
1094 * logical device, or we don't know the tag. */
1095 ResourceData += TagLen;
1096 break;
1097 }
1098 }
1099 }
1100}
static const WCHAR Description[]
Definition: oid.c:1266
static VOID PeekCached(_In_reads_bytes_(Length) PUCHAR ResourceData, _Out_writes_bytes_all_(Length) PVOID Buffer, _In_ USHORT Length)
Definition: hardware.c:392
#define ISAPNP_MAX_ALTERNATIVES
Maximum number of Start DF tags supported by the driver.
Definition: isapnp.h:30
FORCEINLINE BOOLEAN HasDmaAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:258
FORCEINLINE BOOLEAN HasMemory32Alternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:274
FORCEINLINE BOOLEAN HasMemoryAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:266
FORCEINLINE BOOLEAN HasIoAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:242
FORCEINLINE BOOLEAN HasIrqAlternatives(_In_ PISAPNP_ALTERNATIVES Alternatives)
Definition: isapnp.h:250
#define ISAPNP_TAG_FIXEDIO
Definition: isapnphw.h:70
#define ISAPNP_TAG_ANSISTR
Definition: isapnphw.h:78
#define ISAPNP_TAG_STARTDEP
Definition: isapnphw.h:67
#define ISAPNP_TAG_MEMRANGE
Definition: isapnphw.h:75
#define ISAPNP_TAG_MEM32RANGE
Definition: isapnphw.h:80
#define ISAPNP_TAG_DMA
Definition: isapnphw.h:66
#define ISAPNP_SMALL_TAG_NAME(t)
Definition: isapnphw.h:60
#define ISAPNP_TAG_IRQ
Definition: isapnphw.h:65
#define ISAPNP_TAG_COMPATDEVID
Definition: isapnphw.h:64
#define ISAPNP_SMALL_TAG_LEN(t)
Definition: isapnphw.h:61
#define ISAPNP_TAG_ENDDEP
Definition: isapnphw.h:68
#define ISAPNP_LARGE_TAG_NAME(t)
Definition: isapnphw.h:74
#define ISAPNP_IS_SMALL_TAG(t)
Definition: isapnphw.h:59
#define ISAPNP_TAG_LOGDEVID
Definition: isapnphw.h:63
#define ISAPNP_TAG_END
Definition: isapnphw.h:71
#define ISAPNP_TAG_FIXEDMEM32RANGE
Definition: isapnphw.h:81
#define ISAPNP_TAG_IOPORT
Definition: isapnphw.h:69
signed char * PSTR
Definition: retypes.h:7
#define ANSI_NULL
UCHAR VendorId[3]
Definition: isapnp.h:78
USHORT ProdId
Definition: isapnp.h:79
USHORT VendorId
Definition: isapnphw.h:105
USHORT VendorId
Definition: isapnphw.h:98
USHORT ProdId
Definition: isapnphw.h:99
_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 371 of file hardware.c.

375{
376 USHORT i;
377
378 PAGED_CODE();
379
380 for (i = 0; i < Length; i++)
381 {
382 UCHAR Byte = PeekByte(ReadDataPort);
383
384 if (Buffer)
385 ((PUCHAR)Buffer)[i] = Byte;
386 }
387}
static UCHAR PeekByte(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:350
_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 350 of file hardware.c.

352{
353 UCHAR i;
354
355 PAGED_CODE();
356
357 for (i = 0; i < 20; i++)
358 {
359 if (ReadStatus(ReadDataPort) & 0x01)
360 return ReadResourceData(ReadDataPort);
361
363 }
364
365 return 0xFF;
366}
static UCHAR ReadStatus(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:167
static UCHAR ReadResourceData(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:158

Referenced by COMMAND_PROTOTYPE(), Peek(), and ReadTags().

◆ PeekCached()

static VOID PeekCached ( _In_reads_bytes_(Length) PUCHAR  ResourceData,
_Out_writes_bytes_all_(Length) PVOID  Buffer,
_In_ USHORT  Length 
)
static

Definition at line 392 of file hardware.c.

396{
397 PUCHAR Dest = Buffer;
398
399 PAGED_CODE();
400
401 while (Length--)
402 {
403 *Dest++ = *ResourceData++;
404 }
405}

Referenced by ParseTags().

◆ ReadByte()

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

Definition at line 91 of file hardware.c.

94{
96 return ReadData(ReadDataPort);
97}
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 1105 of file hardware.c.

1108{
1109 UCHAR i;
1110
1111 PAGED_CODE();
1112
1113 DPRINT("%s for CSN %u, LDN %u\n", __FUNCTION__, LogDevice->CSN, LogDevice->LDN);
1114
1115 WriteLogicalDeviceNumber(LogDevice->LDN);
1116
1117 /* If the device is not activated by BIOS we just report a NULL resource list */
1118 if (!(ReadByte(ReadDataPort, ISAPNP_ACTIVATE) & 1))
1119 {
1120 LogDevice->Flags &= ~ISAPNP_HAS_RESOURCES;
1121 return FALSE;
1122 }
1123
1124 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Io); i++)
1125 {
1126 LogDevice->Io[i].CurrentBase = ReadIoBase(ReadDataPort, i);
1127
1128 /* Skip empty descriptors */
1129 if (!LogDevice->Io[i].CurrentBase)
1130 break;
1131 }
1132 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Irq); i++)
1133 {
1134 LogDevice->Irq[i].CurrentNo = ReadIrqNo(ReadDataPort, i);
1135
1136 if (!LogDevice->Irq[i].CurrentNo)
1137 break;
1138
1139 LogDevice->Irq[i].CurrentType = ReadIrqType(ReadDataPort, i);
1140 }
1141 for (i = 0; i < RTL_NUMBER_OF(LogDevice->Dma); i++)
1142 {
1143 LogDevice->Dma[i].CurrentChannel = ReadDmaChannel(ReadDataPort, i);
1144
1145 if (LogDevice->Dma[i].CurrentChannel == 4)
1146 break;
1147 }
1148 for (i = 0; i < RTL_NUMBER_OF(LogDevice->MemRange); i++)
1149 {
1150 LogDevice->MemRange[i].CurrentBase = ReadMemoryBase(ReadDataPort, i) << 8;
1151
1152 if (!LogDevice->MemRange[i].CurrentBase)
1153 break;
1154
1155 LogDevice->MemRange[i].CurrentLength = ReadMemoryLimit(ReadDataPort, i) << 8;
1156
1157 if (ReadMemoryControl(ReadDataPort, i) & MEMORY_UPPER_LIMIT)
1158 {
1159 LogDevice->MemRange[i].CurrentLength -= LogDevice->MemRange[i].CurrentBase;
1160 }
1161 else
1162 {
1163 LogDevice->MemRange[i].CurrentLength =
1164 RANGE_LENGTH_TO_LENGTH(LogDevice->MemRange[i].CurrentLength);
1165 }
1166 }
1167 for (i = 0; i < RTL_NUMBER_OF(LogDevice->MemRange32); i++)
1168 {
1169 LogDevice->MemRange32[i].CurrentBase = ReadMemoryBase32(ReadDataPort, i);
1170
1171 if (!LogDevice->MemRange32[i].CurrentBase)
1172 break;
1173
1174 LogDevice->MemRange32[i].CurrentLength = ReadMemoryLimit32(ReadDataPort, i);
1175
1176 if (ReadMemoryControl32(ReadDataPort, i) & MEMORY_UPPER_LIMIT)
1177 {
1178 LogDevice->MemRange32[i].CurrentLength -= LogDevice->MemRange32[i].CurrentBase;
1179 }
1180 else
1181 {
1182 LogDevice->MemRange32[i].CurrentLength =
1183 RANGE_LENGTH_TO_LENGTH(LogDevice->MemRange32[i].CurrentLength);
1184 }
1185 }
1186
1187 LogDevice->Flags |= ISAPNP_HAS_RESOURCES;
1188 return TRUE;
1189}
static USHORT ReadMemoryLimit(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:279
static USHORT ReadIoBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:219
static UCHAR ReadIrqType(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:239
static UCHAR ReadIrqNo(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:229
static UCHAR ReadMemoryControl(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:269
static ULONG ReadMemoryBase32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:289
static UCHAR ReadMemoryControl32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:299
static ULONG ReadMemoryLimit32(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:309
static USHORT ReadMemoryBase(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:259
static UCHAR ReadDmaChannel(_In_ PUCHAR ReadDataPort, _In_ UCHAR Index)
Definition: hardware.c:249
#define ISAPNP_HAS_RESOURCES
Cleared when the device has no boot resources.
Definition: isapnp.h:136
#define RANGE_LENGTH_TO_LENGTH(RangeLength)
Definition: isapnphw.h:83
#define MEMORY_UPPER_LIMIT
Definition: isapnphw.h:38

Referenced by _Requires_lock_held_().

◆ ReadData()

static UCHAR ReadData ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 47 of file hardware.c.

49{
50 return READ_PORT_UCHAR(ReadDataPort);
51}
#define READ_PORT_UCHAR(p)
Definition: pc98vid.h:22

◆ ReadDmaChannel()

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

Definition at line 249 of file hardware.c.

252{
253 return ReadByte(ReadDataPort, ISAPNP_DMACHANNEL(Index)) & 0x07;
254}
#define ISAPNP_DMACHANNEL(n)
Definition: isapnphw.h:48
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by ReadCurrentResources().

◆ ReadDoubleWord()

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

Definition at line 113 of file hardware.c.

116{
117 return ((ReadWord(ReadDataPort, Address) << 8) |
118 (ReadWord(ReadDataPort, Address + 2)));
119}
static USHORT ReadWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:102

Referenced by ReadMemoryBase32(), and ReadMemoryLimit32().

◆ ReadIoBase()

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

Definition at line 219 of file hardware.c.

222{
223 return ReadWord(ReadDataPort, ISAPNP_IOBASE(Index));
224}
#define ISAPNP_IOBASE(n)
Definition: isapnphw.h:43

Referenced by ReadCurrentResources().

◆ ReadIrqNo()

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

Definition at line 229 of file hardware.c.

232{
233 return ReadByte(ReadDataPort, ISAPNP_IRQNO(Index)) & 0x0F;
234}
#define ISAPNP_IRQNO(n)
Definition: isapnphw.h:44

Referenced by ReadCurrentResources().

◆ ReadIrqType()

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

Definition at line 239 of file hardware.c.

242{
243 return ReadByte(ReadDataPort, ISAPNP_IRQTYPE(Index));
244}
#define ISAPNP_IRQTYPE(n)
Definition: isapnphw.h:45

Referenced by ReadCurrentResources().

◆ ReadMemoryBase()

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

Definition at line 259 of file hardware.c.

262{
263 return ReadWord(ReadDataPort, ISAPNP_MEMBASE(Index));
264}
#define ISAPNP_MEMBASE(n)
Definition: isapnphw.h:36

Referenced by ReadCurrentResources().

◆ ReadMemoryBase32()

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

Definition at line 289 of file hardware.c.

292{
293 return ReadDoubleWord(ReadDataPort, ISAPNP_MEMBASE32(Index));
294}
static ULONG ReadDoubleWord(_In_ PUCHAR ReadDataPort, _In_ UCHAR Address)
Definition: hardware.c:113
#define ISAPNP_MEMBASE32(n)
Definition: isapnphw.h:49

Referenced by ReadCurrentResources().

◆ ReadMemoryControl()

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

Definition at line 269 of file hardware.c.

272{
273 return ReadByte(ReadDataPort, ISAPNP_MEMCONTROL(Index));
274}
#define ISAPNP_MEMCONTROL(n)
Definition: isapnphw.h:37

Referenced by ReadCurrentResources(), and WriteResources().

◆ ReadMemoryControl32()

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

Definition at line 299 of file hardware.c.

302{
303 return ReadByte(ReadDataPort, ISAPNP_MEMCONTROL32(Index));
304}
#define ISAPNP_MEMCONTROL32(n)
Definition: isapnphw.h:50

Referenced by ReadCurrentResources(), and WriteResources().

◆ ReadMemoryLimit()

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

Definition at line 279 of file hardware.c.

282{
283 return ReadWord(ReadDataPort, ISAPNP_MEMLIMIT(Index));
284}
#define ISAPNP_MEMLIMIT(n)
Definition: isapnphw.h:42

Referenced by ReadCurrentResources().

◆ ReadMemoryLimit32()

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

Definition at line 309 of file hardware.c.

312{
313 return ReadDoubleWord(ReadDataPort, ISAPNP_MEMLIMIT32(Index));
314}
#define ISAPNP_MEMLIMIT32(n)
Definition: isapnphw.h:51

Referenced by ReadCurrentResources().

◆ ReadResourceData()

static UCHAR ReadResourceData ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 158 of file hardware.c.

160{
161 return ReadByte(ReadDataPort, ISAPNP_RESOURCEDATA);
162}
#define ISAPNP_RESOURCEDATA
Definition: isapnphw.h:28

Referenced by PeekByte().

◆ ReadStatus()

static UCHAR ReadStatus ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 167 of file hardware.c.

169{
170 return ReadByte(ReadDataPort, ISAPNP_STATUS);
171}
#define ISAPNP_STATUS
Definition: isapnphw.h:29

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 
)
static

Definition at line 449 of file hardware.c.

454{
455 PAGED_CODE();
456
457 *MaxLogDev = 0;
458
459 while (TRUE)
460 {
461 UCHAR Tag;
462 USHORT TagLen;
463
464 if (MaxLength < 1)
466
467 Tag = PeekByte(ReadDataPort);
468 if (Tag == 0)
469 {
470 DPRINT("Invalid tag\n");
472 }
473 *Buffer++ = Tag;
474 --MaxLength;
475
477 {
478 TagLen = ISAPNP_SMALL_TAG_LEN(Tag);
480 }
481 else
482 {
483 UCHAR Temp[2];
484
485 if (MaxLength < sizeof(Temp))
487
488 Peek(ReadDataPort, &Temp, sizeof(Temp));
489 *Buffer++ = Temp[0];
490 *Buffer++ = Temp[1];
491 MaxLength -= sizeof(Temp);
492
493 TagLen = Temp[0] + (Temp[1] << 8);
495 }
496
497 if (Tag == 0xFF && TagLen == 0xFFFF)
498 {
499 DPRINT("Invalid tag\n");
501 }
502
503 if (TagLen > MaxLength)
505
506 Peek(ReadDataPort, Buffer, TagLen);
507 MaxLength -= TagLen;
508 Buffer += TagLen;
509
511 (*MaxLogDev)++;
512
513 if (Tag == ISAPNP_TAG_END)
514 break;
515 }
516
517 return STATUS_SUCCESS;
518}
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66

Referenced by _Requires_lock_held_().

◆ ReadWord()

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

Definition at line 102 of file hardware.c.

105{
106 return ((ReadByte(ReadDataPort, Address) << 8) |
107 (ReadByte(ReadDataPort, Address + 1)));
108}

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

◆ SendKey()

static VOID SendKey ( VOID  )
static

Definition at line 332 of file hardware.c.

333{
334 UCHAR i, Lfsr;
335
336 WriteAddress(0x00);
337 WriteAddress(0x00);
338
339 Lfsr = ISAPNP_LFSR_SEED;
340 for (i = 0; i < 32; i++)
341 {
342 WriteAddress(Lfsr);
343 Lfsr = NextLFSR(Lfsr, 0);
344 }
345}

Referenced by _IRQL_requires_max_(), and IsaHwTryReadDataPort().

◆ SetReadDataPort()

static VOID SetReadDataPort ( _In_ PUCHAR  ReadDataPort)
inlinestatic

Definition at line 124 of file hardware.c.

126{
127 WriteByte(ISAPNP_READPORT, (UCHAR)((ULONG_PTR)ReadDataPort >> 2));
128}
#define ISAPNP_READPORT
Definition: isapnphw.h:24
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by IsaHwTryReadDataPort().

◆ WaitForKey()

static VOID WaitForKey ( VOID  )
inlinestatic

Definition at line 141 of file hardware.c.

◆ Wake()

static VOID Wake ( _In_ UCHAR  Csn)
inlinestatic

◆ WriteAddress()

static VOID WriteAddress ( _In_ UCHAR  Address)
inlinestatic

Definition at line 29 of file hardware.c.

31{
33}
#define ISAPNP_ADDRESS
Definition: isapnphw.h:20
#define WRITE_PORT_UCHAR(p, d)
Definition: pc98vid.h:21

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

◆ WriteByte()

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

Definition at line 56 of file hardware.c.

59{
62}
static VOID WriteData(_In_ UCHAR Data)
Definition: hardware.c:38
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by ActivateDevice(), DeactivateDevice(), IsaHwTryReadDataPort(), SetReadDataPort(), WaitForKey(), Wake(), WriteCsn(), WriteLogicalDeviceNumber(), and WriteResources().

◆ WriteCsn()

static VOID WriteCsn ( _In_ UCHAR  Csn)
inlinestatic

Definition at line 176 of file hardware.c.

178{
180}
#define ISAPNP_CARDSELECTNUMBER
Definition: isapnphw.h:30

Referenced by IsaHwTryReadDataPort().

◆ WriteData()

static VOID WriteData ( _In_ UCHAR  Data)
inlinestatic

Definition at line 38 of file hardware.c.

40{
42}
#define ISAPNP_WRITE_DATA
Definition: isapnphw.h:21

Referenced by DECLARE_INTERFACE_(), WriteByte(), and WriteWord().

◆ WriteDoubleWord()

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

Definition at line 80 of file hardware.c.

83{
85 WriteWord(Address, Value >> 16);
86}
static VOID WriteWord(_In_ UCHAR Address, _In_ USHORT Value)
Definition: hardware.c:67

Referenced by WriteResources().

◆ WriteLogicalDeviceNumber()

static VOID WriteLogicalDeviceNumber ( _In_ UCHAR  LogDev)
inlinestatic

Definition at line 185 of file hardware.c.

187{
189}
#define ISAPNP_LOGICALDEVICENUMBER
Definition: isapnphw.h:31

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

◆ WriteResources()

static VOID WriteResources ( _In_ PUCHAR  ReadDataPort,
_In_ PISAPNP_LOGICAL_DEVICE  LogDevice,
_In_ PCM_PARTIAL_RESOURCE_LIST  PartialResourceList 
)
static

Definition at line 1194 of file hardware.c.

1198{
1199 UCHAR i,
1200 NumberOfIo = 0,
1201 NumberOfIrq = 0,
1202 NumberOfDma = 0,
1203 NumberOfMemory = 0,
1204 NumberOfMemory32 = 0;
1205
1206 PAGED_CODE();
1207
1208 WriteLogicalDeviceNumber(LogDevice->LDN);
1209
1210 for (i = 0; i < PartialResourceList->Count; i++)
1211 {
1212 PCM_PARTIAL_RESOURCE_DESCRIPTOR Descriptor = &PartialResourceList->PartialDescriptors[i];
1213 UCHAR Index;
1214
1215 switch (Descriptor->Type)
1216 {
1217 case CmResourceTypePort:
1218 {
1219 (VOID)FindIoDescriptor(LogDevice,
1220 0,
1221 Descriptor->u.Port.Start.LowPart,
1222 Descriptor->u.Port.Start.LowPart +
1223 Descriptor->u.Port.Length - 1,
1224 NULL,
1225 NULL,
1226 &Index);
1227
1228 WriteWord(ISAPNP_IOBASE(Index), (USHORT)Descriptor->u.Port.Start.LowPart);
1229
1230 ++NumberOfIo;
1231 break;
1232 }
1233
1235 {
1236 (VOID)FindIrqDescriptor(LogDevice, Descriptor->u.Interrupt.Level, &Index);
1237
1238 WriteByte(ISAPNP_IRQNO(Index), (UCHAR)Descriptor->u.Interrupt.Level);
1242
1243 ++NumberOfIrq;
1244 break;
1245 }
1246
1247 case CmResourceTypeDma:
1248 {
1249 (VOID)FindDmaDescriptor(LogDevice, Descriptor->u.Dma.Channel, &Index);
1250
1252
1253 ++NumberOfDma;
1254 break;
1255 }
1256
1258 {
1259 BOOLEAN Memory32;
1261 UCHAR MemoryControl = MEMORY_USE_8_BIT_DECODER;
1262
1263 (VOID)FindMemoryDescriptor(LogDevice,
1264 Descriptor->u.Memory.Start.LowPart,
1265 Descriptor->u.Memory.Start.LowPart +
1266 Descriptor->u.Memory.Length - 1,
1267 &Memory32,
1268 &Information,
1269 &Index);
1270
1271 if (!Memory32)
1272 {
1274 MemoryControl = MEMORY_USE_16_BIT_DECODER;
1275
1277 (USHORT)(Descriptor->u.Memory.Start.LowPart >> 8));
1278
1279 if (ReadMemoryControl(ReadDataPort, Index) & MEMORY_UPPER_LIMIT)
1280 {
1282 MemoryControl | MEMORY_UPPER_LIMIT);
1284 (USHORT)((Descriptor->u.Memory.Start.LowPart +
1285 Descriptor->u.Memory.Length) >> 8));
1286 }
1287 else
1288 {
1289 WriteByte(ISAPNP_MEMCONTROL(Index), MemoryControl);
1292 u.Memory.Length) >> 8));
1293 }
1294
1295 ++NumberOfMemory;
1296 }
1297 else
1298 {
1300 Descriptor->u.Memory.Start.LowPart);
1301
1303 MemoryControl = MEMORY_USE_32_BIT_DECODER;
1305 MemoryControl = MEMORY_USE_16_BIT_DECODER;
1306
1307 if (ReadMemoryControl32(ReadDataPort, Index) & MEMORY_UPPER_LIMIT)
1308 {
1310 MemoryControl | MEMORY_UPPER_LIMIT);
1312 Descriptor->u.Memory.Start.LowPart +
1313 Descriptor->u.Memory.Length);
1314 }
1315 else
1316 {
1317 WriteByte(ISAPNP_MEMCONTROL32(Index), MemoryControl);
1319 LENGTH_TO_RANGE_LENGTH(Descriptor->u.Memory.Length));
1320 }
1321
1322 ++NumberOfMemory32;
1323 }
1324
1325 break;
1326 }
1327
1328 default:
1329 break;
1330 }
1331 }
1332
1333 for (i = NumberOfIo; i < RTL_NUMBER_OF(LogDevice->Io); i++)
1334 {
1336 }
1337 for (i = NumberOfIrq; i < RTL_NUMBER_OF(LogDevice->Irq); i++)
1338 {
1341 }
1342 for (i = NumberOfDma; i < RTL_NUMBER_OF(LogDevice->Dma); i++)
1343 {
1345 }
1346 for (i = NumberOfMemory; i < RTL_NUMBER_OF(LogDevice->MemRange); i++)
1347 {
1351 }
1352 for (i = NumberOfMemory32; i < RTL_NUMBER_OF(LogDevice->MemRange32); i++)
1353 {
1357 }
1358}
#define VOID
Definition: acefi.h:82
static VOID WriteDoubleWord(_In_ UCHAR Address, _In_ ULONG Value)
Definition: hardware.c:80
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 * u
Definition: glfuncs.h:240
#define IRQTYPE_LOW_LEVEL
Definition: isapnphw.h:46
#define MEMORY_USE_32_BIT_DECODER
Definition: isapnphw.h:41
#define MEMORY_USE_8_BIT_DECODER
Definition: isapnphw.h:39
#define MEMORY_USE_16_BIT_DECODER
Definition: isapnphw.h:40
#define IRQTYPE_HIGH_EDGE
Definition: isapnphw.h:47
#define LENGTH_TO_RANGE_LENGTH(Length)
Definition: isapnphw.h:84
#define MEMRANGE_16_BIT_MEMORY_MASK
Definition: isapnphw.h:76
#define MEMRANGE_32_BIT_MEMORY_ONLY
Definition: isapnphw.h:77
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by IsaHwConfigureDevice().

◆ WriteWord()

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

Definition at line 67 of file hardware.c.

70{
74 WriteData(Value >> 8);
75}

Referenced by WriteDoubleWord(), and WriteResources().