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

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 _Guarded_by_ (BusSyncEvent)
 
static VOID IsaConvertIrqRequirement (_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_IRQ_DESCRIPTION Description, _In_ ULONG Vector, _In_ BOOLEAN FirstDescriptor)
 
static VOID IsaConvertDmaRequirement (_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_DMA_DESCRIPTION Description, _In_ ULONG Channel, _In_ BOOLEAN FirstDescriptor)
 
static VOID IsaConvertMemRangeRequirement (_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_MEMRANGE_DESCRIPTION Description)
 
static VOID IsaConvertMemRange32Requirement (_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_MEMRANGE32_DESCRIPTION Description)
 
static NTSTATUS IsaPnpCreateLogicalDeviceRequirements (_In_ PISAPNP_PDO_EXTENSION PdoExt)
 
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)
 
BOOLEAN FindIrqDescriptor (_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG Vector)
 
BOOLEAN FindDmaDescriptor (_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG Channel)
 
BOOLEAN FindMemoryDescriptor (_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information)
 
static NTSTATUS IsaPnpCreateLogicalDeviceResources (_In_ PISAPNP_PDO_EXTENSION PdoExt)
 
PIO_RESOURCE_REQUIREMENTS_LIST IsaPnpCreateReadPortDORequirements (_In_opt_ ULONG SelectedReadPort)
 
PCM_RESOURCE_LIST IsaPnpCreateReadPortDOResources (VOID)
 
static NTSTATUS IsaPnpCreateReadPortDO (_In_ PISAPNP_FDO_EXTENSION FdoExt)
 
VOID IsaPnpRemoveReadPortDO (_In_ PDEVICE_OBJECT Pdo)
 
NTSTATUS IsaPnpFillDeviceRelations (_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ BOOLEAN IncludeDataPort)
 
static CODE_SEG ("PAGE")
 
 _Dispatch_type_ (IRP_MJ_POWER)
 
 _Dispatch_type_ (IRP_MJ_PNP)
 
 _Dispatch_type_ (IRP_MJ_CREATE)
 
 _Dispatch_type_ (IRP_MJ_DEVICE_CONTROL)
 
NTSTATUS NTAPI DriverEntry (_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
 

Variables

KEVENT BusSyncEvent
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file isapnp.c.

Function Documentation

◆ _Dispatch_type_() [1/4]

_Dispatch_type_ ( IRP_MJ_CREATE  )

Definition at line 1353 of file isapnp.c.

1364{
1365 PAGED_CODE();
1366
1367 Irp->IoStatus.Status = STATUS_SUCCESS;
1368
1369 DPRINT("%s(%p, %p)\n", __FUNCTION__, DeviceObject, Irp);
1370
1372
1373 return STATUS_SUCCESS;
1374}
#define PAGED_CODE()
_In_ PIRP Irp
Definition: csq.h:116
#define __FUNCTION__
Definition: types.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:73
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ _Dispatch_type_() [2/4]

_Dispatch_type_ ( IRP_MJ_DEVICE_CONTROL  )

Definition at line 1376 of file isapnp.c.

1387{
1388 PISAPNP_COMMON_EXTENSION CommonExt = DeviceObject->DeviceExtension;
1389
1390 PAGED_CODE();
1391
1392 DPRINT("%s(%p, %p) Minor - %X\n", __FUNCTION__, DeviceObject, Irp,
1394
1395 if (CommonExt->Signature == IsaPnpBus)
1396 {
1398 return IoCallDriver(((PISAPNP_FDO_EXTENSION)CommonExt)->Ldo, Irp);
1399 }
1400 else
1401 {
1402 NTSTATUS Status = Irp->IoStatus.Status;
1403
1405 return Status;
1406 }
1407}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:25
@ IsaPnpBus
Definition: isapnp.h:36
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
ISAPNP_SIGNATURE Signature
Definition: isapnp.h:43
_In_ UCHAR _In_ UCHAR MinorFunction
Definition: wdfdevice.h:1699

◆ _Dispatch_type_() [3/4]

_Dispatch_type_ ( IRP_MJ_PNP  )

Definition at line 1331 of file isapnp.c.

1341{
1343 PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1344
1345 PAGED_CODE();
1346
1347 if (DevExt->Signature == IsaPnpBus)
1348 return IsaFdoPnp((PISAPNP_FDO_EXTENSION)DevExt, Irp, IrpSp);
1349 else
1350 return IsaPdoPnp((PISAPNP_PDO_EXTENSION)DevExt, Irp, IrpSp);
1351}
NTSTATUS IsaFdoPnp(_In_ PISAPNP_FDO_EXTENSION FdoExt, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: fdo.c:123
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
NTSTATUS IsaPdoPnp(_In_ PISAPNP_PDO_EXTENSION PdoDeviceExtension, _Inout_ PIRP Irp, _In_ PIO_STACK_LOCATION IrpSp)
Definition: pdo.c:867

◆ _Dispatch_type_() [4/4]

_Dispatch_type_ ( IRP_MJ_POWER  )

Definition at line 1293 of file isapnp.c.

1302{
1303 PISAPNP_COMMON_EXTENSION DevExt = DeviceObject->DeviceExtension;
1305
1306 if (DevExt->Signature != IsaPnpBus)
1307 {
1309 {
1310 case IRP_MN_SET_POWER:
1311 case IRP_MN_QUERY_POWER:
1313 Irp->IoStatus.Status = Status;
1314 break;
1315
1316 default:
1317 Status = Irp->IoStatus.Status;
1318 break;
1319 }
1320
1323 return Status;
1324 }
1325
1328 return PoCallDriver(((PISAPNP_FDO_EXTENSION)DevExt)->Ldo, Irp);
1329}
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER

◆ _Guarded_by_()

_Guarded_by_ ( BusSyncEvent  )

Definition at line 23 of file isapnp.c.

41{
42 PAGED_CODE();
43
47 if (Description->Information & 0x1)
49 else
51 Descriptor->u.Port.Length = Description->Length;
52 Descriptor->u.Port.Alignment = Description->Alignment;
53 Descriptor->u.Port.MinimumAddress.LowPart = Description->Minimum;
54 Descriptor->u.Port.MaximumAddress.LowPart = Description->Maximum +
55 Description->Length - 1;
56}
static const WCHAR Description[]
Definition: oid.c:1266
#define CmResourceTypePort
Definition: hwresource.cpp:123
#define CM_RESOURCE_PORT_IO
Definition: cmtypes.h:109
#define CM_RESOURCE_PORT_16_BIT_DECODE
Definition: cmtypes.h:112
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareDeviceExclusive
Definition: cmtypes.h:241

◆ CODE_SEG()

static CODE_SEG ( "PAGE"  )
static

Definition at line 1232 of file isapnp.c.

1241{
1243 PISAPNP_FDO_EXTENSION FdoExt;
1245 static ULONG BusNumber = 0;
1246
1247 PAGED_CODE();
1248
1250
1252 sizeof(*FdoExt),
1253 NULL,
1256 FALSE,
1257 &Fdo);
1258 if (!NT_SUCCESS(Status))
1259 {
1260 DPRINT1("Failed to create FDO (0x%08lx)\n", Status);
1261 return Status;
1262 }
1263
1264 FdoExt = Fdo->DeviceExtension;
1265 RtlZeroMemory(FdoExt, sizeof(*FdoExt));
1266
1267 FdoExt->Common.Self = Fdo;
1268 FdoExt->Common.Signature = IsaPnpBus;
1269 FdoExt->Common.State = dsStopped;
1270 FdoExt->DriverObject = DriverObject;
1271 FdoExt->BusNumber = BusNumber++;
1272 FdoExt->Pdo = PhysicalDeviceObject;
1275 if (!FdoExt->Ldo)
1276 {
1278 return STATUS_DEVICE_REMOVED;
1279 }
1280
1283
1284 IsaPnpAcquireBusDataLock();
1285 InsertTailList(&BusListHead, &FdoExt->BusLink);
1286 IsaPnpReleaseBusDataLock();
1287
1288 Fdo->Flags &= ~DO_DEVICE_INITIALIZING;
1289
1290 return STATUS_SUCCESS;
1291}
#define DPRINT1
Definition: precomp.h:8
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1157
#define FILE_DEVICE_SECURE_OPEN
Definition: cdrw_usr.h:46
#define STATUS_DEVICE_REMOVED
Definition: d3dkmdt.h:39
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define InsertTailList(ListHead, Entry)
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
@ dsStopped
Definition: isapnp.h:30
@ SynchronizationEvent
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define FILE_DEVICE_BUS_EXTENDER
Definition: winioctl.h:87
PDEVICE_OBJECT Self
Definition: isapnp.h:44
ISAPNP_DEVICE_STATE State
Definition: isapnp.h:45
PDRIVER_OBJECT DriverObject
Definition: isapnp.h:63
LIST_ENTRY DeviceListHead
Definition: precomp.h:82
PDEVICE_OBJECT Pdo
Definition: isapnp.h:52
LIST_ENTRY BusLink
Definition: isapnp.h:66
KEVENT DeviceSyncEvent
Definition: isapnp.h:55
ISAPNP_COMMON_EXTENSION Common
Definition: isapnp.h:50
PDEVICE_OBJECT Ldo
Definition: isapnp.h:51
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( _In_ PDRIVER_OBJECT  DriverObject,
_In_ PUNICODE_STRING  RegistryPath 
)

Definition at line 1412 of file isapnp.c.

1415{
1416 DPRINT("%s(%p, %wZ)\n", __FUNCTION__, DriverObject, RegistryPath);
1417
1418 if (IsNEC_98)
1419 {
1422 }
1423
1424 DriverObject->MajorFunction[IRP_MJ_CREATE] = IsaCreateClose;
1425 DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsaCreateClose;
1426 DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsaForwardOrIgnore;
1427 DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IsaForwardOrIgnore;
1428 DriverObject->MajorFunction[IRP_MJ_PNP] = IsaPnp;
1429 DriverObject->MajorFunction[IRP_MJ_POWER] = IsaPower;
1430 DriverObject->DriverExtension->AddDevice = IsaAddDevice;
1431
1432 /* FIXME: Fix SDK headers */
1433#if 0
1435#endif
1436
1438 InitializeListHead(&BusListHead);
1439
1440 /* FIXME: Fix SDK headers */
1441#if 0
1443#endif
1444
1445 return STATUS_SUCCESS;
1446}
#define IRP_MJ_PNP
Definition: cdrw_usr.h:52
#define _No_competing_thread_begin_
#define _No_competing_thread_end_
ULONG IsaConfigPorts[2]
Definition: hardware.c:23
KEVENT BusSyncEvent
Definition: isapnp.c:21
#define ISAPNP_ADDRESS_PC98
Definition: isapnphw.h:19
#define ISAPNP_WRITE_DATA_PC98
Definition: isapnphw.h:20
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
#define IRP_MJ_SYSTEM_CONTROL
#define IRP_MJ_POWER
#define IsNEC_98
Definition: ketypes.h:911

◆ FindDmaDescriptor()

BOOLEAN FindDmaDescriptor ( _In_ PISAPNP_LOGICAL_DEVICE  LogDevice,
_In_ ULONG  Channel 
)

Definition at line 535 of file isapnp.c.

538{
540
541 PAGED_CODE();
542
543 Resource = LogDevice->Resources;
544 while (Resource->Type != ISAPNP_RESOURCE_TYPE_END)
545 {
547 {
549
550 if (Description->Mask & (1 << Channel))
551 return TRUE;
552 }
553
554 ++Resource;
555 }
556
557 return FALSE;
558}
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
#define ISAPNP_RESOURCE_TYPE_END
Definition: isapnpres.h:69
#define ISAPNP_RESOURCE_TYPE_DMA
Definition: isapnpres.h:72

◆ FindIoDescriptor()

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 
)

Definition at line 459 of file isapnp.c.

466{
468
469 PAGED_CODE();
470
471 Resource = LogDevice->Resources;
472 while (Resource->Type != ISAPNP_RESOURCE_TYPE_END)
473 {
475 {
477 BOOLEAN Match;
478
479 if (Base)
480 {
481 Match = (Base >= Description->Minimum) && (Base <= Description->Maximum);
482 }
483 else
484 {
485 Match = (RangeStart >= Description->Minimum) &&
486 (RangeEnd <= (ULONG)(Description->Maximum + Description->Length - 1));
487 }
488
489 if (Match)
490 {
491 if (Information)
492 *Information = Description->Information;
493 if (Length)
494 *Length = Description->Length;
495
496 return TRUE;
497 }
498 }
499
500 ++Resource;
501 }
502
503 return FALSE;
504}
unsigned char BOOLEAN
#define ISAPNP_RESOURCE_TYPE_IO
Definition: isapnpres.h:70
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2451
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by IsaPnpCreateLogicalDeviceResources().

◆ FindIrqDescriptor()

BOOLEAN FindIrqDescriptor ( _In_ PISAPNP_LOGICAL_DEVICE  LogDevice,
_In_ ULONG  Vector 
)

Definition at line 508 of file isapnp.c.

511{
513
514 PAGED_CODE();
515
516 Resource = LogDevice->Resources;
517 while (Resource->Type != ISAPNP_RESOURCE_TYPE_END)
518 {
520 {
522
523 if (Description->Mask & (1 << Vector))
524 return TRUE;
525 }
526
527 ++Resource;
528 }
529
530 return FALSE;
531}
#define ISAPNP_RESOURCE_TYPE_IRQ
Definition: isapnpres.h:71

◆ FindMemoryDescriptor()

BOOLEAN FindMemoryDescriptor ( _In_ PISAPNP_LOGICAL_DEVICE  LogDevice,
_In_ ULONG  RangeStart,
_In_ ULONG  RangeEnd,
_Out_opt_ PUCHAR  Information 
)

Definition at line 562 of file isapnp.c.

567{
569
570 PAGED_CODE();
571
572 Resource = LogDevice->Resources;
573 while (Resource->Type != ISAPNP_RESOURCE_TYPE_END)
574 {
575 switch (Resource->Type)
576 {
578 {
580
581 Description = &Resource->MemRangeDescription;
582
583 if ((RangeStart >= (ULONG)(Description->Minimum << 8)) &&
584 (RangeEnd <= (ULONG)((Description->Maximum << 8) +
585 (Description->Length << 8) - 1)))
586 {
587 if (Information)
588 *Information = Description->Information;
589
590 return TRUE;
591 }
592 break;
593 }
594
596 {
597 PISAPNP_MEMRANGE32_DESCRIPTION Description32;
598
599 Description32 = &Resource->MemRange32Description;
600
601 if ((RangeStart >= Description32->Minimum) &&
602 (RangeEnd <= (Description32->Maximum + Description32->Length - 1)))
603 {
604 if (Information)
605 *Information = Description32->Information;
606
607 return TRUE;
608 }
609 break;
610 }
611
612 default:
613 break;
614 }
615
616 ++Resource;
617 }
618
619 return FALSE;
620}
#define ISAPNP_RESOURCE_TYPE_MEMRANGE
Definition: isapnpres.h:73
#define ISAPNP_RESOURCE_TYPE_MEMRANGE32
Definition: isapnpres.h:74

Referenced by IsaHwConfigureDevice(), and IsaPnpCreateLogicalDeviceResources().

◆ IsaConvertDmaRequirement()

static VOID IsaConvertDmaRequirement ( _Out_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ PISAPNP_DMA_DESCRIPTION  Description,
_In_ ULONG  Channel,
_In_ BOOLEAN  FirstDescriptor 
)
static

Definition at line 89 of file isapnp.c.

94{
96
97 PAGED_CODE();
98
99 if (!FirstDescriptor)
102 Descriptor->ShareDisposition = CmResourceShareUndetermined;
103 Descriptor->Flags = CM_RESOURCE_DMA_8; /* Ignore information byte for compatibility */
104 Descriptor->u.Dma.MinimumChannel =
105 Descriptor->u.Dma.MaximumChannel = Channel;
106}
#define CmResourceTypeDma
Definition: hwresource.cpp:126
#define CM_RESOURCE_DMA_8
Definition: cmtypes.h:131
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
@ CmResourceShareUndetermined
Definition: cmtypes.h:240
#define IO_RESOURCE_ALTERNATIVE

◆ IsaConvertIrqRequirement()

static VOID IsaConvertIrqRequirement ( _Out_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ PISAPNP_IRQ_DESCRIPTION  Description,
_In_ ULONG  Vector,
_In_ BOOLEAN  FirstDescriptor 
)
static

Definition at line 61 of file isapnp.c.

66{
67 PAGED_CODE();
68
69 if (!FirstDescriptor)
72 if (Description->Information & 0xC)
73 {
75 Descriptor->ShareDisposition = CmResourceShareShared;
76 }
77 else
78 {
81 }
82 Descriptor->u.Interrupt.MinimumVector =
83 Descriptor->u.Interrupt.MaximumVector = Vector;
84}
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE
Definition: cmtypes.h:143
#define CM_RESOURCE_INTERRUPT_LATCHED
Definition: cmtypes.h:144
@ CmResourceShareShared
Definition: cmtypes.h:243

◆ IsaConvertMemRange32Requirement()

static VOID IsaConvertMemRange32Requirement ( _Out_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ PISAPNP_MEMRANGE32_DESCRIPTION  Description 
)
static

Definition at line 137 of file isapnp.c.

140{
141 PAGED_CODE();
142
144 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
146 if ((Description->Information & 0x40) || !(Description->Information & 0x01))
148 else
150 Descriptor->u.Memory.Length = Description->Length;
151 Descriptor->u.Memory.Alignment = Description->Alignment;
152 Descriptor->u.Memory.MinimumAddress.LowPart = Description->Minimum;
153 Descriptor->u.Memory.MaximumAddress.LowPart = Description->Maximum +
154 Description->Length - 1;
155}
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CM_RESOURCE_MEMORY_READ_ONLY
Definition: cmtypes.h:121
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:120
#define CM_RESOURCE_MEMORY_24
Definition: cmtypes.h:125

◆ IsaConvertMemRangeRequirement()

static VOID IsaConvertMemRangeRequirement ( _Out_ PIO_RESOURCE_DESCRIPTOR  Descriptor,
_In_ PISAPNP_MEMRANGE_DESCRIPTION  Description 
)
static

Definition at line 111 of file isapnp.c.

114{
115 PAGED_CODE();
116
118 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
120 if ((Description->Information & 0x40) || !(Description->Information & 0x01))
122 else
124 Descriptor->u.Memory.Length = Description->Length << 8;
125 if (Description->Alignment == 0)
126 Descriptor->u.Memory.Alignment = 0x10000;
127 else
128 Descriptor->u.Memory.Alignment = Description->Alignment;
129 Descriptor->u.Memory.MinimumAddress.LowPart = Description->Minimum << 8;
130 Descriptor->u.Memory.MaximumAddress.LowPart = (Description->Maximum << 8) +
131 (Description->Length << 8) - 1;
132}

◆ IsaPnpCreateLogicalDeviceRequirements()

static NTSTATUS IsaPnpCreateLogicalDeviceRequirements ( _In_ PISAPNP_PDO_EXTENSION  PdoExt)
static

Definition at line 189 of file isapnp.c.

191{
195 ULONG FirstFixedDescriptors, LastFixedDescriptors;
196 ULONG ResourceCount, AltListCount, ListSize, i;
197 BOOLEAN IsFirstAltList, IsFirstDescriptor;
198 PIO_RESOURCE_LIST AltList;
200
201 PAGED_CODE();
202
203 /* Count the number of requirements */
204 DfState = dfNotStarted;
205 FirstFixedDescriptors = 0;
206 LastFixedDescriptors = 0;
207 ResourceCount = 0;
208 AltListCount = 1;
209 Resource = PdoExt->IsaPnpDevice->Resources;
210 while (Resource->Type != ISAPNP_RESOURCE_TYPE_END)
211 {
212 switch (Resource->Type)
213 {
215 {
216 if (DfState == dfStarted)
217 ++AltListCount;
218
219 DfState = dfStarted;
220 break;
221 }
222
224 {
225 DfState = dfDone;
226 break;
227 }
228
231 {
232 RTL_BITMAP ResourceBitmap;
233 ULONG BitmapSize, BitmapBuffer, BitCount;
234
236 {
237 BitmapSize = RTL_BITS_OF(Resource->IrqDescription.Mask);
238 BitmapBuffer = Resource->IrqDescription.Mask;
239 }
240 else
241 {
242 BitmapSize = RTL_BITS_OF(Resource->DmaDescription.Mask);
243 BitmapBuffer = Resource->DmaDescription.Mask;
244 }
245 RtlInitializeBitMap(&ResourceBitmap, &BitmapBuffer, BitmapSize);
246
247 BitCount = RtlNumberOfSetBits(&ResourceBitmap);
248 switch (DfState)
249 {
250 case dfNotStarted:
251 FirstFixedDescriptors += BitCount;
252 break;
253
254 case dfStarted:
255 ResourceCount += BitCount;
256 break;
257
258 case dfDone:
259 LastFixedDescriptors += BitCount;
260 break;
261
263 }
264
265 break;
266 }
267
271 {
272 switch (DfState)
273 {
274 case dfNotStarted:
275 ++FirstFixedDescriptors;
276 break;
277
278 case dfStarted:
280 break;
281
282 case dfDone:
283 ++LastFixedDescriptors;
284 break;
285
287 }
288 break;
289 }
290
291 default:
292 ASSERT(FALSE);
294 break;
295 }
296
297 ++Resource;
298 }
299
300 /* This logical device has no resource requirements */
301 if ((ResourceCount == 0) && (FirstFixedDescriptors == 0) && (LastFixedDescriptors == 0))
302 return STATUS_SUCCESS;
303
304 /* Allocate memory to store requirements */
306 FIELD_OFFSET(IO_RESOURCE_LIST, Descriptors) * AltListCount +
308 sizeof(IO_RESOURCE_DESCRIPTOR) * AltListCount *
309 (FirstFixedDescriptors + LastFixedDescriptors);
311 if (!RequirementsList)
312 return STATUS_NO_MEMORY;
313
314 RequirementsList->ListSize = ListSize;
315 RequirementsList->InterfaceType = Isa;
316 RequirementsList->AlternativeLists = AltListCount;
317
318 RequirementsList->List[0].Version = 1;
319 RequirementsList->List[0].Revision = 1;
320
321 /* Store requirements */
322 IsFirstAltList = TRUE;
323 AltList = &RequirementsList->List[0];
325 Resource = PdoExt->IsaPnpDevice->Resources;
326 while (Resource->Type != ISAPNP_RESOURCE_TYPE_END)
327 {
328 switch (Resource->Type)
329 {
331 {
332 if (!IsFirstAltList)
333 {
334 /* Add room for the fixed descriptors */
335 AltList->Count += LastFixedDescriptors;
336
337 /* Move on to the next list */
338 AltList = (PIO_RESOURCE_LIST)(AltList->Descriptors + AltList->Count);
339 AltList->Version = 1;
340 AltList->Revision = 1;
341
342 /* Propagate the fixed resources to our new list */
343 RtlCopyMemory(&AltList->Descriptors,
344 RequirementsList->List[0].Descriptors,
345 sizeof(IO_RESOURCE_DESCRIPTOR) * FirstFixedDescriptors);
346 AltList->Count += FirstFixedDescriptors;
347
348 Descriptor = &AltList->Descriptors[FirstFixedDescriptors];
349 }
350
351 IsFirstAltList = FALSE;
352 break;
353 }
354
356 break;
357
359 {
360 IsaConvertIoRequirement(Descriptor++, &Resource->IoDescription);
361
362 ++AltList->Count;
363 break;
364 }
365
367 {
368 IsFirstDescriptor = TRUE;
369
370 for (i = 0; i < RTL_BITS_OF(Resource->IrqDescription.Mask); i++)
371 {
372 if (!(Resource->IrqDescription.Mask & (1 << i)))
373 continue;
374
376 &Resource->IrqDescription,
377 i,
378 IsFirstDescriptor);
379 ++AltList->Count;
380
381 IsFirstDescriptor = FALSE;
382 }
383
384 break;
385 }
386
388 {
389 IsFirstDescriptor = TRUE;
390
391 for (i = 0; i < RTL_BITS_OF(Resource->DmaDescription.Mask); i++)
392 {
393 if (!(Resource->DmaDescription.Mask & (1 << i)))
394 continue;
395
397 &Resource->DmaDescription,
398 i,
399 IsFirstDescriptor);
400 ++AltList->Count;
401
402 IsFirstDescriptor = FALSE;
403 }
404
405 break;
406 }
407
409 {
410 IsaConvertMemRangeRequirement(Descriptor++, &Resource->MemRangeDescription);
411
412 ++AltList->Count;
413 break;
414 }
415
417 {
418 IsaConvertMemRange32Requirement(Descriptor++, &Resource->MemRange32Description);
419
420 ++AltList->Count;
421 break;
422 }
423
424 default:
425 ASSERT(FALSE);
427 break;
428 }
429
430 ++Resource;
431 }
432
433 /* Append the fixed resources */
434 if (LastFixedDescriptors)
435 {
436 PIO_RESOURCE_LIST NextList = &RequirementsList->List[0];
437
438 /* Make the descriptor point to the fixed resources */
439 Descriptor -= LastFixedDescriptors;
440
441 /* Propagate the fixed resources onto previous lists */
442 AltListCount = RequirementsList->AlternativeLists - 1;
443 for (i = 0; i < AltListCount; i++)
444 {
445 RtlCopyMemory(&NextList->Descriptors[NextList->Count - LastFixedDescriptors],
447 sizeof(IO_RESOURCE_DESCRIPTOR) * LastFixedDescriptors);
448
449 NextList = (PIO_RESOURCE_LIST)(NextList->Descriptors + NextList->Count);
450 }
451 }
452
453 PdoExt->RequirementsList = RequirementsList;
454 return STATUS_SUCCESS;
455}
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define RtlNumberOfSetBits
Definition: dbgbitmap.h:343
#define PagedPool
Definition: env_spec_w32.h:308
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
static ULONG BitmapBuffer[(XMS_BLOCKS+31)/32]
Definition: himem.c:86
@ Isa
Definition: hwresource.cpp:138
static ULONG ResourceCount
Definition: inbv.c:50
static VOID IsaConvertIrqRequirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_IRQ_DESCRIPTION Description, _In_ ULONG Vector, _In_ BOOLEAN FirstDescriptor)
Definition: isapnp.c:61
static VOID IsaConvertMemRange32Requirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_MEMRANGE32_DESCRIPTION Description)
Definition: isapnp.c:137
static VOID IsaConvertMemRangeRequirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_MEMRANGE_DESCRIPTION Description)
Definition: isapnp.c:111
static VOID IsaConvertDmaRequirement(_Out_ PIO_RESOURCE_DESCRIPTOR Descriptor, _In_ PISAPNP_DMA_DESCRIPTION Description, _In_ ULONG Channel, _In_ BOOLEAN FirstDescriptor)
Definition: isapnp.c:89
#define TAG_ISAPNP
Definition: isapnp.h:26
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_START_DEPENDENT
Definition: isapnpres.h:75
#define ISAPNP_RESOURCE_TYPE_END_DEPENDENT
Definition: isapnpres.h:76
#define ASSERT(a)
Definition: mode.c:44
FORCEINLINE PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
#define UNREACHABLE
#define DEFAULT_UNREACHABLE
#define RTL_BITS_OF(sizeOfArg)
Definition: ntbasedef.h:668
struct _IO_RESOURCE_DESCRIPTOR IO_RESOURCE_DESCRIPTOR
IO_RESOURCE_DESCRIPTOR Descriptors[1]
Definition: iotypes.h:2737
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:133
_In_ WDFIORESREQLIST RequirementsList
Definition: wdfresource.h:65
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550
struct _IO_RESOURCE_LIST * PIO_RESOURCE_LIST

Referenced by DrvTestResources(), and IsaPnpFillDeviceRelations().

◆ IsaPnpCreateLogicalDeviceResources()

static NTSTATUS IsaPnpCreateLogicalDeviceResources ( _In_ PISAPNP_PDO_EXTENSION  PdoExt)
static

Definition at line 625 of file isapnp.c.

627{
628 PISAPNP_LOGICAL_DEVICE LogDev = PdoExt->IsaPnpDevice;
631 ULONG ListSize, i;
634
635 PAGED_CODE();
636
637 if (!(LogDev->Flags & ISAPNP_HAS_RESOURCES))
638 return STATUS_SUCCESS;
639
640 /* Count number of required resources */
641 for (i = 0; i < RTL_NUMBER_OF(LogDev->Io); i++)
642 {
643 if (LogDev->Io[i].CurrentBase)
645 else
646 break;
647 }
648 for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
649 {
650 if (LogDev->Irq[i].CurrentNo)
652 else
653 break;
654 }
655 for (i = 0; i < RTL_NUMBER_OF(LogDev->Dma); i++)
656 {
657 if (LogDev->Dma[i].CurrentChannel != DMACHANNEL_NONE)
659 else
660 break;
661 }
662 for (i = 0; i < RTL_NUMBER_OF(LogDev->MemRange); i++)
663 {
664 if (LogDev->MemRange[i].CurrentBase)
666 else
667 break;
668 }
669 for (i = 0; i < RTL_NUMBER_OF(LogDev->MemRange32); i++)
670 {
671 if (LogDev->MemRange32[i].CurrentBase)
673 else
674 break;
675 }
676 if (ResourceCount == 0)
677 return STATUS_SUCCESS;
678
679 /* Allocate memory to store resources */
680 ListSize = sizeof(CM_RESOURCE_LIST)
683 if (!ResourceList)
684 return STATUS_NO_MEMORY;
685
686 ResourceList->Count = 1;
687 ResourceList->List[0].InterfaceType = Isa;
688 ResourceList->List[0].PartialResourceList.Version = 1;
689 ResourceList->List[0].PartialResourceList.Revision = 1;
690 ResourceList->List[0].PartialResourceList.Count = ResourceCount;
691
692 /* Store resources */
693 ResourceCount = 0;
694 for (i = 0; i < RTL_NUMBER_OF(LogDev->Io); i++)
695 {
696 ULONG CurrentLength;
697
698 if (!LogDev->Io[i].CurrentBase)
699 break;
700
701 if (!FindIoDescriptor(LogDev,
702 LogDev->Io[i].CurrentBase,
703 0,
704 0,
706 &CurrentLength))
707 {
708 DPRINT1("I/O entry #%lu %x not found\n", i, LogDev->Io[i].CurrentBase);
709 goto InvalidBiosResources;
710 }
711
712 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
714 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
716 if (Information & 0x1)
718 else
720 Descriptor->u.Port.Length = CurrentLength;
721 Descriptor->u.Port.Start.LowPart = LogDev->Io[i].CurrentBase;
722 }
723 for (i = 0; i < RTL_NUMBER_OF(LogDev->Irq); i++)
724 {
725 if (!LogDev->Irq[i].CurrentNo)
726 break;
727
728 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
730 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
731 if (LogDev->Irq[i].CurrentType & 0x01)
733 else
735 Descriptor->u.Interrupt.Level = LogDev->Irq[i].CurrentNo;
736 Descriptor->u.Interrupt.Vector = LogDev->Irq[i].CurrentNo;
737 Descriptor->u.Interrupt.Affinity = (KAFFINITY)-1;
738 }
739 for (i = 0; i < RTL_NUMBER_OF(LogDev->Dma); i++)
740 {
741 if (LogDev->Dma[i].CurrentChannel == DMACHANNEL_NONE)
742 break;
743
744 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
746 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
747 Descriptor->Flags = CM_RESOURCE_DMA_8; /* Ignore information byte for compatibility */
748 Descriptor->u.Dma.Channel = LogDev->Dma[i].CurrentChannel;
749 }
750 for (i = 0; i < RTL_NUMBER_OF(LogDev->MemRange); i++)
751 {
752 if (!LogDev->MemRange[i].CurrentBase)
753 break;
754
755 if (!FindMemoryDescriptor(LogDev,
756 LogDev->MemRange[i].CurrentBase,
757 LogDev->MemRange[i].CurrentLength,
758 &Information))
759 {
760 DPRINT1("MEM entry #%lu %lx %lx not found\n",
761 i,
762 LogDev->MemRange[i].CurrentBase,
763 LogDev->MemRange[i].CurrentLength);
764 goto InvalidBiosResources;
765 }
766
767 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
769 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
771 if ((Information & 0x40) || !(Information & 0x01))
773 else
775 Descriptor->u.Memory.Length = LogDev->MemRange[i].CurrentLength;
776 Descriptor->u.Memory.Start.QuadPart = LogDev->MemRange[i].CurrentBase;
777 }
778 for (i = 0; i < RTL_NUMBER_OF(LogDev->MemRange32); i++)
779 {
780 if (!LogDev->MemRange32[i].CurrentBase)
781 break;
782
783 if (!FindMemoryDescriptor(LogDev,
784 LogDev->MemRange32[i].CurrentBase,
785 LogDev->MemRange32[i].CurrentLength,
786 &Information))
787 {
788 DPRINT1("MEM32 entry #%lu %lx %lx not found\n",
789 i,
790 LogDev->MemRange32[i].CurrentBase,
791 LogDev->MemRange32[i].CurrentLength);
792 goto InvalidBiosResources;
793 }
794
795 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[ResourceCount++];
797 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
799 if ((Information & 0x40) || !(Information & 0x01))
801 else
803 Descriptor->u.Memory.Length = LogDev->MemRange32[i].CurrentLength;
804 Descriptor->u.Memory.Start.QuadPart = LogDev->MemRange32[i].CurrentBase;
805 }
806
807 PdoExt->ResourceList = ResourceList;
808 PdoExt->ResourceListSize = ListSize;
809 return STATUS_SUCCESS;
810
811InvalidBiosResources:
812 DPRINT1("Invalid boot resources! (CSN %u, LDN %u)\n", LogDev->CSN, LogDev->LDN);
813
814 LogDev->Flags &= ~ISAPNP_HAS_RESOURCES;
816 return STATUS_SUCCESS;
817}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
ULONG_PTR KAFFINITY
Definition: compat.h:85
struct _CM_RESOURCE_LIST CM_RESOURCE_LIST
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR CM_PARTIAL_RESOURCE_DESCRIPTOR
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)
Definition: isapnp.c:459
BOOLEAN FindMemoryDescriptor(_In_ PISAPNP_LOGICAL_DEVICE LogDevice, _In_ ULONG RangeStart, _In_ ULONG RangeEnd, _Out_opt_ PUCHAR Information)
Definition: isapnp.c:562
#define DMACHANNEL_NONE
Definition: isapnphw.h:47
#define ISAPNP_HAS_RESOURCES
Definition: isapnpres.h:102
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
UCHAR CurrentChannel
Definition: isapnpres.h:31
USHORT CurrentBase
Definition: isapnpres.h:16
UCHAR CurrentType
Definition: isapnpres.h:24
UCHAR CurrentNo
Definition: isapnpres.h:23
ISAPNP_DMA Dma[2]
Definition: isapnpres.h:133
ISAPNP_MEMRANGE32 MemRange32[4]
Definition: isapnpres.h:135
ISAPNP_MEMRANGE MemRange[4]
Definition: isapnpres.h:134
ISAPNP_IRQ Irq[2]
Definition: isapnpres.h:132
ULONG CurrentLength
Definition: isapnpres.h:39
ULONG CurrentBase
Definition: isapnpres.h:38
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by DrvTestResources(), and IsaPnpFillDeviceRelations().

◆ IsaPnpCreateReadPortDO()

static NTSTATUS IsaPnpCreateReadPortDO ( _In_ PISAPNP_FDO_EXTENSION  FdoExt)
static

Definition at line 1007 of file isapnp.c.

1009{
1012
1013 PAGED_CODE();
1014 ASSERT(ReadPortCreated == FALSE);
1015
1016 DPRINT("Creating Read Port\n");
1017
1018 Status = IoCreateDevice(FdoExt->DriverObject,
1019 sizeof(ISAPNP_PDO_EXTENSION),
1020 NULL,
1023 FALSE,
1024 &FdoExt->ReadPortPdo);
1025 if (!NT_SUCCESS(Status))
1026 return Status;
1027
1028 PdoExt = FdoExt->ReadPortPdo->DeviceExtension;
1030 PdoExt->Common.Signature = IsaPnpReadDataPort;
1031 PdoExt->Common.Self = FdoExt->ReadPortPdo;
1032 PdoExt->Common.State = dsStopped;
1033 PdoExt->FdoExt = FdoExt;
1034
1035 FdoExt->ReadPortPdo->Flags &= ~DO_DEVICE_INITIALIZING;
1036
1037 return Status;
1038}
@ IsaPnpReadDataPort
Definition: isapnp.h:38
#define FILE_AUTOGENERATED_DEVICE_NAME
Definition: iotypes.h:138
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:49
PDEVICE_OBJECT Self
Definition: pciidex.h:60
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204

Referenced by IsaPnpFillDeviceRelations().

◆ IsaPnpCreateReadPortDORequirements()

PIO_RESOURCE_REQUIREMENTS_LIST IsaPnpCreateReadPortDORequirements ( _In_opt_ ULONG  SelectedReadPort)

Definition at line 821 of file isapnp.c.

823{
824 ULONG ResourceCount, ListSize, i;
827 const ULONG ReadPorts[] = { 0x274, 0x3E4, 0x204, 0x2E4, 0x354, 0x2F4 };
828
829 PAGED_CODE();
830
831 if (SelectedReadPort)
832 {
833 /*
834 * [IO descriptor: ISAPNP_WRITE_DATA, required]
835 * [IO descriptor: ISAPNP_WRITE_DATA, optional]
836 * [IO descriptor: ISAPNP_ADDRESS, required]
837 * [IO descriptor: ISAPNP_ADDRESS, optional]
838 * [IO descriptor: Selected Read Port, required]
839 * [IO descriptor: Read Port 1, optional]
840 * [IO descriptor: Read Port 2, optional]
841 * [...]
842 * [IO descriptor: Read Port X - 1, optional]
843 */
845 }
846 else
847 {
848 /*
849 * [IO descriptor: ISAPNP_WRITE_DATA, required]
850 * [IO descriptor: ISAPNP_WRITE_DATA, optional]
851 * [IO descriptor: ISAPNP_ADDRESS, required]
852 * [IO descriptor: ISAPNP_ADDRESS, optional]
853 * [IO descriptor: Read Port 1, required]
854 * [IO descriptor: Read Port 1, optional]
855 * [IO descriptor: Read Port 2, required]
856 * [IO descriptor: Read Port 2, optional]
857 * [...]
858 * [IO descriptor: Read Port X, required]
859 * [IO descriptor: Read Port X, optional]
860 */
862 }
863 ListSize = sizeof(IO_RESOURCE_REQUIREMENTS_LIST) +
866 if (!RequirementsList)
867 return NULL;
868
869 RequirementsList->ListSize = ListSize;
870 RequirementsList->AlternativeLists = 1;
871
872 RequirementsList->List[0].Version = 1;
873 RequirementsList->List[0].Revision = 1;
874 RequirementsList->List[0].Count = ResourceCount;
875
876 Descriptor = &RequirementsList->List[0].Descriptors[0];
877
878 /* Store the Data port and the Address port */
879 for (i = 0; i < RTL_NUMBER_OF(IsaConfigPorts) * 2; i++)
880 {
881 if ((i % 2) == 0)
882 {
883 /* Expected port */
885 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
887 Descriptor->u.Port.Length = 0x01;
888 Descriptor->u.Port.Alignment = 0x01;
889 Descriptor->u.Port.MinimumAddress.LowPart =
890 Descriptor->u.Port.MaximumAddress.LowPart = IsaConfigPorts[i / 2];
891 }
892 else
893 {
894 /* ... but mark it as optional */
897 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
899 Descriptor->u.Port.Alignment = 0x01;
900 }
901
902 Descriptor++;
903 }
904
905 /* Store the Read Ports */
906 if (SelectedReadPort)
907 {
908 BOOLEAN Selected = FALSE;
909
911
912 for (i = 0; i < RTL_NUMBER_OF(ReadPorts); i++)
913 {
914 if (ReadPorts[i] != SelectedReadPort)
916 else
917 Selected = TRUE;
919 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
921 Descriptor->u.Port.Length = 0x04;
922 Descriptor->u.Port.Alignment = 0x01;
923 Descriptor->u.Port.MinimumAddress.LowPart = ReadPorts[i];
924 Descriptor->u.Port.MaximumAddress.LowPart = ReadPorts[i] +
925 Descriptor->u.Port.Length - 1;
926
927 Descriptor++;
928 }
929
930 ASSERT(Selected == TRUE);
931 }
932 else
933 {
934 for (i = 0; i < RTL_NUMBER_OF(ReadPorts) * 2; i++)
935 {
936 if ((i % 2) == 0)
937 {
938 /* Expected port */
940 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
942 Descriptor->u.Port.Length = 0x04;
943 Descriptor->u.Port.Alignment = 0x01;
944 Descriptor->u.Port.MinimumAddress.LowPart = ReadPorts[i / 2];
945 Descriptor->u.Port.MaximumAddress.LowPart = ReadPorts[i / 2] +
946 Descriptor->u.Port.Length - 1;
947 }
948 else
949 {
950 /* ... but mark it as optional */
953 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
955 Descriptor->u.Port.Alignment = 0x01;
956 }
957
958 Descriptor++;
959 }
960 }
961
962 return RequirementsList;
963}
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
struct _IO_RESOURCE_REQUIREMENTS_LIST IO_RESOURCE_REQUIREMENTS_LIST

Referenced by DrvTestReadDataPortQueryResourcesRequirementsForEnum(), DrvTestReadDataPortQueryResourcesRequirementsForRebalance(), and IsaPdoQueryResourceRequirements().

◆ IsaPnpCreateReadPortDOResources()

PCM_RESOURCE_LIST IsaPnpCreateReadPortDOResources ( VOID  )

Definition at line 967 of file isapnp.c.

968{
969 ULONG ListSize, i;
972
973 PAGED_CODE();
974
975 ListSize = sizeof(CM_RESOURCE_LIST) +
978 if (!ResourceList)
979 return NULL;
980
981 ResourceList->Count = 1;
982 ResourceList->List[0].InterfaceType = Internal;
983 ResourceList->List[0].PartialResourceList.Version = 1;
984 ResourceList->List[0].PartialResourceList.Revision = 1;
985 ResourceList->List[0].PartialResourceList.Count = RTL_NUMBER_OF(IsaConfigPorts);
986
987 Descriptor = &ResourceList->List[0].PartialResourceList.PartialDescriptors[0];
988 for (i = 0; i < RTL_NUMBER_OF(IsaConfigPorts); i++)
989 {
991 Descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
993 Descriptor->u.Port.Length = 0x01;
994 Descriptor->u.Port.Start.LowPart = IsaConfigPorts[i];
995
996 Descriptor++;
997 }
998
999 return ResourceList;
1000}
@ Internal
Definition: hwresource.cpp:137

Referenced by DrvTestReadDataPortQueryResources(), and IsaPdoQueryResources().

◆ IsaPnpFillDeviceRelations()

NTSTATUS IsaPnpFillDeviceRelations ( _In_ PISAPNP_FDO_EXTENSION  FdoExt,
_Inout_ PIRP  Irp,
_In_ BOOLEAN  IncludeDataPort 
)

Definition at line 1054 of file isapnp.c.

1058{
1060 PLIST_ENTRY CurrentEntry;
1061 PISAPNP_LOGICAL_DEVICE IsaDevice;
1062 PDEVICE_RELATIONS DeviceRelations;
1063 ULONG PdoCount, i = 0;
1064
1065 PAGED_CODE();
1066
1067 IsaPnpAcquireBusDataLock();
1068
1069 /* Try to claim the Read Port for our FDO */
1070 if (!ReadPortCreated)
1071 {
1073 if (!NT_SUCCESS(Status))
1074 return Status;
1075
1076 ReadPortCreated = TRUE;
1077 }
1078
1079 IsaPnpReleaseBusDataLock();
1080
1081 /* Inactive ISA bus */
1082 if (!FdoExt->ReadPortPdo)
1083 IncludeDataPort = FALSE;
1084
1085 IsaPnpAcquireDeviceDataLock(FdoExt);
1086
1087 /* If called from the FDO dispatch routine && Active bus */
1088 if (IncludeDataPort && FdoExt->ReadPortPdo)
1089 {
1090 PISAPNP_PDO_EXTENSION ReadPortExt = FdoExt->ReadPortPdo->DeviceExtension;
1091
1092 if ((ReadPortExt->Flags & ISAPNP_READ_PORT_ALLOW_FDO_SCAN) &&
1093 !(ReadPortExt->Flags & ISAPNP_SCANNED_BY_READ_PORT))
1094 {
1095 DPRINT("Rescan ISA PnP bus\n");
1096
1097 /* Run the isolation protocol */
1098 FdoExt->Cards = IsaHwTryReadDataPort(FdoExt->ReadDataPort);
1099
1100 /* Card identification */
1101 if (FdoExt->Cards > 0)
1102 (VOID)IsaHwFillDeviceList(FdoExt);
1103
1105 }
1106
1107 ReadPortExt->Flags &= ~ISAPNP_SCANNED_BY_READ_PORT;
1108 }
1109
1110 PdoCount = FdoExt->DeviceCount;
1111 if (IncludeDataPort)
1112 ++PdoCount;
1113
1114 CurrentEntry = FdoExt->DeviceListHead.Flink;
1115 while (CurrentEntry != &FdoExt->DeviceListHead)
1116 {
1117 IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1118
1119 if (!(IsaDevice->Flags & ISAPNP_PRESENT))
1120 --PdoCount;
1121
1122 CurrentEntry = CurrentEntry->Flink;
1123 }
1124
1125 DeviceRelations = ExAllocatePoolWithTag(PagedPool,
1126 FIELD_OFFSET(DEVICE_RELATIONS, Objects[PdoCount]),
1127 TAG_ISAPNP);
1128 if (!DeviceRelations)
1129 {
1130 IsaPnpReleaseDeviceDataLock(FdoExt);
1131 return STATUS_NO_MEMORY;
1132 }
1133
1134 if (IncludeDataPort)
1135 {
1136 PISAPNP_PDO_EXTENSION ReadPortExt = FdoExt->ReadPortPdo->DeviceExtension;
1137
1138 DeviceRelations->Objects[i++] = FdoExt->ReadPortPdo;
1139 ObReferenceObject(FdoExt->ReadPortPdo);
1140
1141 /* The Read Port PDO can only be removed by FDO */
1142 ReadPortExt->Flags |= ISAPNP_ENUMERATED;
1143 }
1144
1145 CurrentEntry = FdoExt->DeviceListHead.Flink;
1146 while (CurrentEntry != &FdoExt->DeviceListHead)
1147 {
1149
1150 IsaDevice = CONTAINING_RECORD(CurrentEntry, ISAPNP_LOGICAL_DEVICE, DeviceLink);
1151
1152 if (!(IsaDevice->Flags & ISAPNP_PRESENT))
1153 goto SkipPdo;
1154
1155 if (!IsaDevice->Pdo)
1156 {
1157 Status = IoCreateDevice(FdoExt->DriverObject,
1158 sizeof(ISAPNP_PDO_EXTENSION),
1159 NULL,
1162 FALSE,
1163 &IsaDevice->Pdo);
1164 if (!NT_SUCCESS(Status))
1165 goto SkipPdo;
1166
1167 IsaDevice->Pdo->Flags &= ~DO_DEVICE_INITIALIZING;
1168 /* The power pagable flag is always unset */
1169
1170 PdoExt = IsaDevice->Pdo->DeviceExtension;
1171
1173 PdoExt->Common.Signature = IsaPnpLogicalDevice;
1174 PdoExt->Common.Self = IsaDevice->Pdo;
1175 PdoExt->Common.State = dsStopped;
1176 PdoExt->IsaPnpDevice = IsaDevice;
1177 PdoExt->FdoExt = FdoExt;
1178
1181 {
1182 if (PdoExt->RequirementsList)
1183 {
1184 ExFreePoolWithTag(PdoExt->RequirementsList, TAG_ISAPNP);
1185 PdoExt->RequirementsList = NULL;
1186 }
1187
1188 if (PdoExt->ResourceList)
1189 {
1190 ExFreePoolWithTag(PdoExt->ResourceList, TAG_ISAPNP);
1191 PdoExt->ResourceList = NULL;
1192 }
1193
1194 IoDeleteDevice(IsaDevice->Pdo);
1195 IsaDevice->Pdo = NULL;
1196 goto SkipPdo;
1197 }
1198 }
1199 else
1200 {
1201 PdoExt = IsaDevice->Pdo->DeviceExtension;
1202 }
1203 DeviceRelations->Objects[i++] = IsaDevice->Pdo;
1204 ObReferenceObject(IsaDevice->Pdo);
1205
1206 PdoExt->Flags |= ISAPNP_ENUMERATED;
1207
1208 CurrentEntry = CurrentEntry->Flink;
1209 continue;
1210
1211SkipPdo:
1212 if (IsaDevice->Pdo)
1213 {
1214 PdoExt = IsaDevice->Pdo->DeviceExtension;
1215
1216 if (PdoExt)
1217 PdoExt->Flags &= ~ISAPNP_ENUMERATED;
1218 }
1219
1220 CurrentEntry = CurrentEntry->Flink;
1221 }
1222
1223 IsaPnpReleaseDeviceDataLock(FdoExt);
1224
1225 DeviceRelations->Count = i;
1226
1227 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1228
1229 return Status;
1230}
#define VOID
Definition: acefi.h:82
VOID IsaHwWaitForKey(VOID)
Definition: hardware.c:1684
UCHAR IsaHwTryReadDataPort(_In_ PUCHAR ReadDataPort)
Definition: hardware.c:1259
#define ULONG_PTR
Definition: config.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static NTSTATUS IsaPnpCreateLogicalDeviceRequirements(_In_ PISAPNP_PDO_EXTENSION PdoExt)
Definition: isapnp.c:189
static NTSTATUS IsaPnpCreateLogicalDeviceResources(_In_ PISAPNP_PDO_EXTENSION PdoExt)
Definition: isapnp.c:625
static NTSTATUS IsaPnpCreateReadPortDO(_In_ PISAPNP_FDO_EXTENSION FdoExt)
Definition: isapnp.c:1007
#define ISAPNP_READ_PORT_ALLOW_FDO_SCAN
Allows the active FDO to scan the bus.
Definition: isapnp.h:77
@ IsaPnpLogicalDevice
Definition: isapnp.h:37
#define ISAPNP_SCANNED_BY_READ_PORT
The bus has been scanned by Read Port PDO.
Definition: isapnp.h:76
#define ISAPNP_ENUMERATED
Whether the device has been reported to the PnP manager.
Definition: isapnp.h:75
#define ISAPNP_PRESENT
Definition: isapnpres.h:96
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
PDEVICE_OBJECT Pdo
Definition: isapnpres.h:92
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by IsaFdoQueryBusRelations(), and IsaPdoQueryDeviceRelations().

◆ IsaPnpRemoveReadPortDO()

VOID IsaPnpRemoveReadPortDO ( _In_ PDEVICE_OBJECT  Pdo)

Definition at line 1042 of file isapnp.c.

1044{
1045 PAGED_CODE();
1046
1047 DPRINT("Removing Read Port\n");
1048
1050}
WDF_EXTERN_C_START typedef _Must_inspect_result_ _In_ WDFDRIVER _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT _In_opt_ PDEVICE_OBJECT Pdo
Definition: wdfminiport.h:72

Referenced by IsaFdoRemoveDevice(), and IsaReadPortRemoveDevice().

Variable Documentation

◆ BusSyncEvent

KEVENT BusSyncEvent

Definition at line 21 of file isapnp.c.

Referenced by _Releases_lock_(), _Requires_lock_not_held_(), and DriverEntry().