ReactOS 0.4.17-dev-1190-g4c812f4
arb_comn.c File Reference
#include <pci.h>
#include <debug.h>
Include dependency graph for arb_comn.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define PCI_RANGE_FIXED_PLACEMENT   0x04
 

Functions

NTSTATUS NTAPI PciArbiter_PreprocessEntry (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
 Sets the range attributes of one arbitration entry before the engine looks for a placement for it.
 
BOOLEAN NTAPI PciArbiter_FindSuitableRange (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
 Searches for a placement, remembering on the range whether it came from a fixed alternative.
 
BOOLEAN NTAPI PciArbiter_OverrideConflict (_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE State)
 Lets a fixed requirement overlap ranges its own device was given by other fixed requirements.
 
VOID NTAPI PciArbiter_Reference (_In_ PVOID Context)
 
VOID NTAPI PciArbiter_Dereference (_In_ PVOID Context)
 
NTSTATUS NTAPI PciArbiterConstructor (_In_ PPCI_FDO_EXTENSION FdoExtension, _In_ PCI_SIGNATURE ArbiterType, _Out_ PARBITER_INTERFACE Interface)
 
VOID NTAPI PciArbiterDestructor (IN PPCI_ARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI PciInitializeArbiters (IN PPCI_FDO_EXTENSION FdoExtension)
 
static PCM_RESOURCE_LIST NTAPI PciCollectForwardedRanges (_In_ PPCI_PDO_EXTENSION BridgeExtension)
 Builds a resource list of the ranges a PCI-to-PCI bridge forwards to its secondary bus.
 
static BOOLEAN NTAPI PciHasRangeOfType (_In_ PCM_RESOURCE_LIST RangeList, _In_ UCHAR Type)
 Tells whether a resource list holds any range of one resource type.
 
NTSTATUS NTAPI PciInitializeArbiterRanges (IN PPCI_FDO_EXTENSION DeviceExtension, IN PCM_RESOURCE_LIST Resources)
 

Variables

PCHAR PciArbiterNames []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file arb_comn.c.

◆ PCI_RANGE_FIXED_PLACEMENT

#define PCI_RANGE_FIXED_PLACEMENT   0x04

Definition at line 19 of file arb_comn.c.

Function Documentation

◆ PciArbiter_Dereference()

VOID NTAPI PciArbiter_Dereference ( _In_ PVOID  Context)

Definition at line 191 of file arb_comn.c.

192{
194
196}
struct _ARBITER_INSTANCE * PARBITER_INSTANCE
Definition: arbiter.h:110
#define InterlockedDecrement
Definition: armddk.h:52
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
ULONG ReferenceCount
Definition: arbiter.h:306
int32_t * PLONG
Definition: typedefs.h:58

Referenced by PciArbiterConstructor().

◆ PciArbiter_FindSuitableRange()

BOOLEAN NTAPI PciArbiter_FindSuitableRange ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  State 
)

Searches for a placement, remembering on the range whether it came from a fixed alternative.

Parameters
[in]ArbiterThe arbiter instance placing the entry.
[in,out]StateThe allocation state of the entry.
Returns
TRUE if a placement was found, FALSE otherwise.

Definition at line 97 of file arb_comn.c.

100{
101 PAGED_CODE();
102
103 State->RangeAttributes &= (UCHAR)~PCI_RANGE_FIXED_PLACEMENT;
104 if (State->CurrentAlternative &&
105 (State->CurrentAlternative->Flags & ARBITER_ALTERNATIVE_FLAG_FIXED))
106 {
107 State->RangeAttributes |= PCI_RANGE_FIXED_PLACEMENT;
108 }
109
110 return ArbiterLibFindSuitableRange(Arbiter, State);
111}
#define PAGED_CODE()
#define PCI_RANGE_FIXED_PLACEMENT
Definition: arb_comn.c:19
BOOLEAN NTAPI ArbiterLibFindSuitableRange(_In_ PARBITER_INSTANCE Arbiter, _Inout_ PARBITER_ALLOCATION_STATE ArbState)
Finds a free range of the current candidate window in the arbiter's tentative allocation list.
Definition: range.c:717
#define ARBITER_ALTERNATIVE_FLAG_FIXED
Definition: arbiter.h:32
unsigned char UCHAR
Definition: typedefs.h:53

Referenced by ario_Initializer(), and armem_Initializer().

◆ PciArbiter_OverrideConflict()

BOOLEAN NTAPI PciArbiter_OverrideConflict ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  State 
)

Lets a fixed requirement overlap ranges its own device was given by other fixed requirements.

Parameters
[in]ArbiterThe arbiter instance placing the entry.
[in,out]StateThe allocation state of the entry. On success Start and End receive the requested window.
Returns
TRUE if every conflicting range is a fixed placement of the same device, FALSE otherwise.
Remarks
A resized BAR that landed on top of another BAR's firmware address is a movable placement, so the fixed BAR fails and the resized one has to back off to another alternative.

Definition at line 136 of file arb_comn.c.

139{
141 PRTL_RANGE Range;
142 BOOLEAN Overridden = FALSE;
143
144 PAGED_CODE();
145
146 if (!State->Entry ||
147 !State->CurrentAlternative ||
148 !(State->CurrentAlternative->Flags & ARBITER_ALTERNATIVE_FLAG_FIXED))
149 {
150 return FALSE;
151 }
152
153 if (!NT_SUCCESS(RtlGetFirstRange(Arbiter->PossibleAllocation, &Iterator, &Range)))
154 return FALSE;
155
156 while (Range)
157 {
158 if ((Range->Start <= State->CurrentMaximum) &&
159 (Range->End >= State->CurrentMinimum) &&
160 !(Range->Attributes & State->RangeAvailableAttributes))
161 {
162 if ((Range->Owner != State->Entry->PhysicalDeviceObject) ||
164 {
165 return FALSE;
166 }
167
168 Overridden = TRUE;
169 State->Start = State->CurrentMinimum;
170 State->End = State->CurrentMaximum;
171 }
172
173 if (!NT_SUCCESS(RtlGetNextRange(&Iterator, &Range, TRUE)))
174 break;
175 }
176
177 return Overridden;
178}
unsigned char BOOLEAN
Definition: actypes.h:127
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
NTSYSAPI NTSTATUS NTAPI RtlGetNextRange(_Inout_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range, _In_ BOOLEAN MoveForwards)
NTSYSAPI NTSTATUS NTAPI RtlGetFirstRange(_In_ PRTL_RANGE_LIST RangeList, _Out_ PRTL_RANGE_LIST_ITERATOR Iterator, _Outptr_ PRTL_RANGE *Range)
ULONGLONG End
Definition: rtltypes.h:1517
ULONGLONG Start
Definition: rtltypes.h:1516
UCHAR Attributes
Definition: rtltypes.h:1520
PVOID Owner
Definition: rtltypes.h:1519
_In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR Iterator
Definition: wdfchildlist.h:656

Referenced by ario_Initializer(), and armem_Initializer().

◆ PciArbiter_PreprocessEntry()

NTSTATUS NTAPI PciArbiter_PreprocessEntry ( _In_ PARBITER_INSTANCE  Arbiter,
_Inout_ PARBITER_ALLOCATION_STATE  State 
)

Sets the range attributes of one arbitration entry before the engine looks for a placement for it.

Parameters
[in]ArbiterThe arbiter instance placing the entry.
[in,out]StateThe allocation state of the entry.
Returns
STATUS_SUCCESS.
Remarks
Boot configs and legacy claims treat boot reservations as free. Positive decode ports ignore ISA alias ranges.

Definition at line 51 of file arb_comn.c.

54{
56
58
59 PAGED_CODE();
60
61 if (!State->Entry)
62 return STATUS_SUCCESS;
63
64 if ((State->Entry->Flags & ARBITER_FLAG_BOOT_CONFIG) ||
65 (State->Entry->RequestSource == ArbiterRequestLegacyReported) ||
66 (State->Entry->RequestSource == ArbiterRequestLegacyAssigned))
67 {
68 State->RangeAvailableAttributes |= ARBITER_RANGE_BOOT_ALLOCATED;
69 }
70
71 /* CurrentAlternative is not set yet, use the first alternative */
72 Descriptor = State->Alternatives ? State->Alternatives->Descriptor : NULL;
73 if (Descriptor &&
74 (Descriptor->Type == CmResourceTypePort) &&
76 State->RangeAvailableAttributes |= ARBITER_RANGE_PORT_ALIAS;
77
78 return STATUS_SUCCESS;
79}
#define ARBITER_RANGE_PORT_ALIAS
Definition: arbiter.h:55
#define ARBITER_RANGE_BOOT_ALLOCATED
Definition: arbiter.h:53
#define NULL
Definition: types.h:112
#define CM_RESOURCE_PORT_POSITIVE_DECODE
Definition: cmtypes.h:113
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define CmResourceTypePort
Definition: restypes.h:104
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ ArbiterRequestLegacyAssigned
Definition: iotypes.h:4632
@ ArbiterRequestLegacyReported
Definition: iotypes.h:4630
#define ARBITER_FLAG_BOOT_CONFIG
Definition: iotypes.h:4644

Referenced by arbusno_Initializer(), ario_Initializer(), and armem_Initializer().

◆ PciArbiter_Reference()

VOID NTAPI PciArbiter_Reference ( _In_ PVOID  Context)

Definition at line 182 of file arb_comn.c.

183{
185
187}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by PciArbiterConstructor().

◆ PciArbiterConstructor()

NTSTATUS NTAPI PciArbiterConstructor ( _In_ PPCI_FDO_EXTENSION  FdoExtension,
_In_ PCI_SIGNATURE  ArbiterType,
_Out_ PARBITER_INTERFACE  Interface 
)

Definition at line 200 of file arb_comn.c.

203{
204 PPCI_ARBITER_INSTANCE Arbiter;
205 PAGED_CODE();
206
207 if (!FdoExtension->ArbitersInitialized) return STATUS_NOT_SUPPORTED;
208
209 /* Find the instance this bus built for the requested resource type */
211 SecondaryExtension.Next,
212 ArbiterType);
213 if (!Arbiter)
214 {
215 DPRINT1("PCIX - FDO ext 0x%p has no %s arbiter to hand out.\n",
217 PciArbiterNames[ArbiterType - PciArb_Io]);
219 }
220
221 Interface->Size = sizeof(ARBITER_INTERFACE);
223 Interface->Context = &Arbiter->CommonInstance;
224 Interface->InterfaceReference = PciArbiter_Reference;
225 Interface->InterfaceDereference = PciArbiter_Dereference;
226 Interface->ArbiterHandler = ArbiterLibHandler;
227 Interface->Flags = 0;
228 return STATUS_SUCCESS;
229}
VOID NTAPI PciArbiter_Reference(_In_ PVOID Context)
Definition: arb_comn.c:182
PCHAR PciArbiterNames[]
Definition: arb_comn.c:21
VOID NTAPI PciArbiter_Dereference(_In_ PVOID Context)
Definition: arb_comn.c:191
NTSTATUS NTAPI ArbiterLibHandler(_In_ PVOID Context, _In_ ARBITER_ACTION Action, _Inout_ PARBITER_PARAMETERS Parameters)
The single ARBITER_ACTION dispatcher every exported ARBITER_INTERFACE points its ArbiterHandler at; C...
Definition: handler.c:164
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define ARBITER_INTERFACE_VERSION
Definition: pci.h:111
PPCI_SECONDARY_EXTENSION NTAPI PciFindNextSecondaryExtension(IN PSINGLE_LIST_ENTRY ListHead, IN PCI_SIGNATURE ExtensionType)
Definition: utils.c:584
@ PciArb_Io
Definition: pci.h:135
@ FdoExtension
Definition: precomp.h:60
ARBITER_INSTANCE CommonInstance
Definition: pci.h:472
void * PVOID
Definition: typedefs.h:50
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
struct _ARBITER_INTERFACE ARBITER_INTERFACE

Referenced by arbusno_Constructor(), ario_Constructor(), and armem_Constructor().

◆ PciArbiterDestructor()

VOID NTAPI PciArbiterDestructor ( IN PPCI_ARBITER_INSTANCE  Arbiter)

Definition at line 233 of file arb_comn.c.

234{
235 PAGED_CODE();
236
237 ArbiterLibDeleteInstance(&Arbiter->CommonInstance);
238}
VOID NTAPI ArbiterLibDeleteInstance(_In_ PARBITER_INSTANCE Arbiter)
Definition: arbiter.c:22

Referenced by PciInitializeArbiters().

◆ PciCollectForwardedRanges()

static PCM_RESOURCE_LIST NTAPI PciCollectForwardedRanges ( _In_ PPCI_PDO_EXTENSION  BridgeExtension)
static

Builds a resource list of the ranges a PCI-to-PCI bridge forwards to its secondary bus.

Parameters
[in]BridgeExtensionThe PDO extension of a positive decode bridge.
Returns
The open windows and, with the VGA enable set, the legacy video ranges. NULL if out of memory.

Definition at line 343 of file arb_comn.c.

345{
347 PCM_RESOURCE_LIST RangeList;
348 SIZE_T Size;
349 ULONG Index;
350
351 PAGED_CODE();
352
353 /* Room for the I/O, memory and prefetchable windows plus three VGA ranges */
354 Size = sizeof(*RangeList) + (5 * sizeof(*Descriptor));
356 if (!RangeList)
357 return NULL;
358
359 RtlZeroMemory(RangeList, Size);
360 RangeList->Count = 1;
361 RangeList->List[0].InterfaceType = PCIBus;
362 RangeList->List[0].BusNumber = BridgeExtension->Dependent.type1.SecondaryBus;
363 RangeList->List[0].PartialResourceList.Version = 1;
364 RangeList->List[0].PartialResourceList.Revision = 1;
367
368 /* The windows follow the BARs, a closed one was saved as a null descriptor */
369 if (BridgeExtension->Resources)
370 {
372 {
373 Window = &BridgeExtension->Resources->Current[Index];
374 if ((Window->Type == CmResourceTypeNull) || !Window->u.Generic.Length)
375 continue;
376
377 *Descriptor = *Window;
378 Descriptor++;
379 }
380 }
381
382 if (BridgeExtension->Dependent.type1.VgaBitSet)
383 {
386 Descriptor->u.Memory.Start.QuadPart = 0xA0000;
387 Descriptor->u.Memory.Length = 0x20000;
388 Descriptor++;
389
392 Descriptor->u.Port.Start.QuadPart = 0x3B0;
393 Descriptor->u.Port.Length = 0xC;
394 Descriptor++;
395
398 Descriptor->u.Port.Start.QuadPart = 0x3C0;
399 Descriptor->u.Port.Length = 0x20;
400 Descriptor++;
401 }
402
403 RangeList->List[0].PartialResourceList.Count = (ULONG)(Descriptor - First);
404 return RangeList;
405}
WCHAR First[]
Definition: FormatMessage.c:11
#define PCI_POOL_TAG
Definition: pci.h:27
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define CM_RESOURCE_MEMORY_READ_WRITE
Definition: cmtypes.h:121
#define CM_RESOURCE_PORT_10_BIT_DECODE
Definition: cmtypes.h:110
#define CmResourceTypeNull
Definition: restypes.h:103
#define CmResourceTypeMemory
Definition: restypes.h:106
@ PCIBus
Definition: restypes.h:127
Definition: window.c:29
CM_PARTIAL_RESOURCE_LIST PartialResourceList
Definition: restypes.h:145
INTERFACE_TYPE InterfaceType
Definition: restypes.h:143
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
CM_FULL_RESOURCE_DESCRIPTOR List[1]
Definition: restypes.h:150
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
#define PCI_TYPE1_ADDRESSES
Definition: iotypes.h:3516

Referenced by PciInitializeArbiterRanges().

◆ PciHasRangeOfType()

static BOOLEAN NTAPI PciHasRangeOfType ( _In_ PCM_RESOURCE_LIST  RangeList,
_In_ UCHAR  Type 
)
static

Tells whether a resource list holds any range of one resource type.

Parameters
[in]RangeListA resource list with a single full descriptor.
[in]TypeThe CmResourceType to look for.
Returns
TRUE if at least one descriptor of that type is present. A large memory range counts as memory.

Definition at line 423 of file arb_comn.c.

426{
427 PCM_PARTIAL_RESOURCE_LIST PartialList;
428 UCHAR RangeType;
429 ULONG Index;
430
431 PartialList = &RangeList->List[0].PartialResourceList;
432 for (Index = 0; Index < PartialList->Count; Index++)
433 {
434 RangeType = PartialList->PartialDescriptors[Index].Type;
435 if ((RangeType == Type) ||
436 ((RangeType == CmResourceTypeMemoryLarge) && (Type == CmResourceTypeMemory)))
437 {
438 return TRUE;
439 }
440 }
441
442 return FALSE;
443}
Type
Definition: Type.h:7
#define CmResourceTypeMemoryLarge
Definition: cmtypes.h:231

Referenced by PciInitializeArbiterRanges().

◆ PciInitializeArbiterRanges()

NTSTATUS NTAPI PciInitializeArbiterRanges ( IN PPCI_FDO_EXTENSION  DeviceExtension,
IN PCM_RESOURCE_LIST  Resources 
)

Definition at line 447 of file arb_comn.c.

449{
452 PCM_RESOURCE_LIST Ranges;
453 PCI_SIGNATURE ArbiterType;
455
456 /* Arbiters should not already be initialized */
457 if (DeviceExtension->ArbitersInitialized)
458 {
459 /* Duplicated start request, fail initialization */
460 DPRINT1("PCIX - Warning hot start FDOx %p, resource ranges not checked.\n", DeviceExtension);
462 }
463
464 /* A root bus decodes the ranges it was started with */
465 Ranges = Resources;
466
467 /* Check for non-root FDO */
468 if (!PCI_IS_ROOT_FDO(DeviceExtension))
469 {
470 /* Grab the PDO */
471 PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension->PhysicalDeviceObject->DeviceExtension;
473
474 /* Check if this is a subtractive bus */
475 if (PdoExtension->Dependent.type1.SubtractiveDecode)
476 {
477 /* There is nothing to do regarding arbitration of resources */
478 DPRINT1("PCIX - Skipping arbiter initialization for subtractive bridge FDOX %p\n", DeviceExtension);
479 return STATUS_SUCCESS;
480 }
481
482 /* The start resources hold the bridge's own BARs, the bus only gets what it forwards */
484 if (!Ranges)
486 }
487
488 /* Loop the arbiters that hand out the ranges a bus decodes */
489 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++)
490 {
491 /* Find an arbiter of this type */
492 Instance = (PVOID)PciFindNextSecondaryExtension(DeviceExtension->
493 SecondaryExtension.Next,
494 ArbiterType);
495 if (Instance)
496 {
497 /* The decoded ranges bound what the arbiter may hand out */
498 Status = Instance->CommonInstance.StartArbiter(&Instance->CommonInstance,
499 Ranges);
500 if (!NT_SUCCESS(Status))
501 {
502 DPRINT1("PCIX - FDO ext 0x%p %s arbiter failed to start: %X\n",
503 DeviceExtension,
504 PciArbiterNames[ArbiterType - PciArb_Io],
505 Status);
506 goto Exit;
507 }
508
509 /* An empty seed leaves everything open, but a bridge without the range forwards none */
510 if (!PCI_IS_ROOT_FDO(DeviceExtension) &&
511 !PciHasRangeOfType(Ranges, (UCHAR)Instance->CommonInstance.ResourceType))
512 {
513 ArbiterLibReserveRange(&Instance->CommonInstance,
514 0,
516 NULL,
517 FALSE);
518 }
519 }
520 else
521 {
522 /* The arbiter was not found, this is an error! */
523 DPRINT1("PCIX - FDO ext 0x%p %s arbiter (REQUIRED) is missing.\n",
524 DeviceExtension,
525 PciArbiterNames[ArbiterType - PciArb_Io]);
526 }
527 }
528
529 /* Arbiters are now initialized */
530 DeviceExtension->ArbitersInitialized = TRUE;
532
533Exit:
534 if (Ranges != Resources)
536
537 return Status;
538}
static PCM_RESOURCE_LIST NTAPI PciCollectForwardedRanges(_In_ PPCI_PDO_EXTENSION BridgeExtension)
Builds a resource list of the ranges a PCI-to-PCI bridge forwards to its secondary bus.
Definition: arb_comn.c:343
static BOOLEAN NTAPI PciHasRangeOfType(_In_ PCM_RESOURCE_LIST RangeList, _In_ UCHAR Type)
Tells whether a resource list holds any range of one resource type.
Definition: arb_comn.c:423
#define ARBITER_MAXIMUM_ADDRESS
Definition: arbiter.h:13
VOID NTAPI ArbiterLibReserveRange(_In_ PARBITER_INSTANCE Arbiter, _In_ ULONGLONG Start, _In_ ULONGLONG End, _In_opt_ PVOID Owner, _In_ BOOLEAN Shared)
Commits a single [Start, End] range into the arbiter as an ordinary allocation owned by Owner.
Definition: handler.c:533
LONG NTSTATUS
Definition: precomp.h:26
enum _PCI_SIGNATURE PCI_SIGNATURE
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:42
#define ASSERT_PDO(x)
Definition: pci.h:48
@ PciArb_Memory
Definition: pci.h:136
@ PdoExtension
Definition: precomp.h:61
Status
Definition: gdiplustypes.h:24
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static void Exit(void)
Definition: sock.c:1330
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_WMI_INSTANCE_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_opt_ WDFWMIINSTANCE * Instance
Definition: wdfwmi.h:481

Referenced by PciFdoIrpStartDevice().

◆ PciInitializeArbiters()

NTSTATUS NTAPI PciInitializeArbiters ( IN PPCI_FDO_EXTENSION  FdoExtension)

Definition at line 242 of file arb_comn.c.

243{
244 PPCI_INTERFACE CurrentInterface, *Interfaces;
246 PPCI_ARBITER_INSTANCE ArbiterInterface;
248 PCI_SIGNATURE ArbiterType;
250
251 /* A bus that ends up needing no arbiter at all is not a failure */
253
254 /* A subtractive bus has no arbiters of its own, requests fall through to the parent's */
256 {
257 /* Get the PDO extension */
258 PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension;
260
261 if (PdoExtension->Dependent.type1.SubtractiveDecode)
262 {
263 DPRINT1("PCIX - Not creating arbiters for subtractive bus 0x%x\n",
264 FdoExtension->BaseBus);
265 return STATUS_SUCCESS;
266 }
267 }
268
269 /* Loop all the arbiters */
270 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_BusNumber; ArbiterType++)
271 {
272 /* Query all the registered arbiter interfaces */
273 Interfaces = PciInterfaces;
274 while (*Interfaces)
275 {
276 /* Find the one that matches the arbiter currently being setup */
277 CurrentInterface = *Interfaces;
278 if (CurrentInterface->Signature == ArbiterType) break;
279 Interfaces++;
280 }
281
282 /* Check if the required arbiter was not found in the list */
283 if (!*Interfaces)
284 {
285 /* Skip this arbiter and try the next one */
286 DPRINT1("PCIX - FDO ext 0x%p no %s arbiter.\n",
288 PciArbiterNames[ArbiterType - PciArb_Io]);
289 continue;
290 }
291
292 /* An arbiter was found, allocate an instance for it */
294 ArbiterInterface = ExAllocatePoolWithTag(PagedPool,
295 sizeof(PCI_ARBITER_INSTANCE),
297 if (!ArbiterInterface) break;
298
299 /* Setup the instance */
300 ArbiterInterface->BusFdoExtension = FdoExtension;
301 ArbiterInterface->Interface = CurrentInterface;
302 _swprintf(ArbiterInterface->InstanceName,
303 L"PCI %S (b=%02x)",
304 PciArbiterNames[ArbiterType - PciArb_Io],
305 FdoExtension->BaseBus);
306
307 /* Call the interface initializer for it */
308 Status = CurrentInterface->Initializer(ArbiterInterface);
309 if (!NT_SUCCESS(Status)) break;
310
311 /* Link it with this FDO */
312 PcipLinkSecondaryExtension(&FdoExtension->SecondaryExtension,
313 &FdoExtension->SecondaryExtLock,
314 &ArbiterInterface->Header,
315 ArbiterType,
317
318 /* This arbiter is now initialized, move to the next one */
319 DPRINT1("PCIX - FDO ext 0x%p %S arbiter initialized (context 0x%p).\n",
321 L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name,
322 ArbiterInterface);
324 }
325
326 /* Return to caller */
327 return Status;
328}
VOID NTAPI PciArbiterDestructor(IN PPCI_ARBITER_INSTANCE Arbiter)
Definition: arb_comn.c:233
#define L(x)
Definition: resources.c:13
VOID NTAPI PcipLinkSecondaryExtension(IN PSINGLE_LIST_ENTRY List, IN PVOID Lock, IN PPCI_SECONDARY_EXTENSION SecondaryExtension, IN PCI_SIGNATURE ExtensionType, IN PVOID Destructor)
Definition: utils.c:459
#define ASSERT_FDO(x)
Definition: pci.h:47
@ PciArb_BusNumber
Definition: pci.h:138
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
#define _swprintf(buf, format,...)
Definition: sprintf.c:56
PPCI_FDO_EXTENSION BusFdoExtension
Definition: pci.h:470
PCI_SECONDARY_EXTENSION Header
Definition: pci.h:468
WCHAR InstanceName[24]
Definition: pci.h:471
PPCI_INTERFACE Interface
Definition: pci.h:469
PCI_SIGNATURE Signature
Definition: pci.h:448
PCI_INTERFACE_INITIALIZER Initializer
Definition: pci.h:450

Referenced by PciAddDevice().

Variable Documentation

◆ PciArbiterNames

PCHAR PciArbiterNames[]
Initial value:
=
{
"I/O Port",
"Memory",
"Interrupt",
"Bus Number"
}

Definition at line 21 of file arb_comn.c.

Referenced by PciArbiterConstructor(), PciInitializeArbiterRanges(), and PciInitializeArbiters().