ReactOS 0.4.16-dev-334-g4d9f67c
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
 

Functions

VOID NTAPI PciArbiterDestructor (IN PPCI_ARBITER_INSTANCE Arbiter)
 
NTSTATUS NTAPI PciInitializeArbiters (IN PPCI_FDO_EXTENSION FdoExtension)
 
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.

Function Documentation

◆ PciArbiterDestructor()

VOID NTAPI PciArbiterDestructor ( IN PPCI_ARBITER_INSTANCE  Arbiter)

Definition at line 30 of file arb_comn.c.

31{
33 /* This function is not yet implemented */
35 while (TRUE);
36}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325

Referenced by PciInitializeArbiters().

◆ PciInitializeArbiterRanges()

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

Definition at line 128 of file arb_comn.c.

130{
132 //CM_RESOURCE_TYPE DesiredType;
134 PCI_SIGNATURE ArbiterType;
135
137
138 /* Arbiters should not already be initialized */
139 if (DeviceExtension->ArbitersInitialized)
140 {
141 /* Duplicated start request, fail initialization */
142 DPRINT1("PCI Warning hot start FDOx %p, resource ranges not checked.\n", DeviceExtension);
144 }
145
146 /* Check for non-root FDO */
147 if (!PCI_IS_ROOT_FDO(DeviceExtension))
148 {
149 /* Grab the PDO */
150 PdoExtension = (PPCI_PDO_EXTENSION)DeviceExtension->PhysicalDeviceObject->DeviceExtension;
152
153 /* Check if this is a subtractive bus */
154 if (PdoExtension->Dependent.type1.SubtractiveDecode)
155 {
156 /* There is nothing to do regarding arbitration of resources */
157 DPRINT1("PCI Skipping arbiter initialization for subtractive bridge FDOX %p\n", DeviceExtension);
158 return STATUS_SUCCESS;
159 }
160 }
161
162 /* Loop all arbiters */
163 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_Memory; ArbiterType++)
164 {
165 /* Pick correct resource type for each arbiter */
166 if (ArbiterType == PciArb_Io)
167 {
168 /* I/O Port */
169 //DesiredType = CmResourceTypePort;
170 }
171 else if (ArbiterType == PciArb_Memory)
172 {
173 /* Device RAM */
174 //DesiredType = CmResourceTypeMemory;
175 }
176 else
177 {
178 /* Ignore anything else */
179 continue;
180 }
181
182 /* Find an arbiter of this type */
183 Instance = PciFindNextSecondaryExtension(&DeviceExtension->SecondaryExtension,
184 ArbiterType);
185 if (Instance)
186 {
187 /*
188 * Now we should initialize it, not yet implemented because Arb
189 * library isn't yet implemented, not even the headers.
190 */
192 //while (TRUE);
193 }
194 else
195 {
196 /* The arbiter was not found, this is an error! */
197 DPRINT1("PCI - FDO ext 0x%p %s arbiter (REQUIRED) is missing.\n",
198 DeviceExtension,
199 PciArbiterNames[ArbiterType - PciArb_Io]);
200 }
201 }
202
203 /* Arbiters are now initialized */
204 DeviceExtension->ArbitersInitialized = TRUE;
205 return STATUS_SUCCESS;
206}
PCHAR PciArbiterNames[]
Definition: arb_comn.c:18
#define DPRINT1
Definition: precomp.h:8
PPCI_SECONDARY_EXTENSION NTAPI PciFindNextSecondaryExtension(IN PSINGLE_LIST_ENTRY ListHead, IN PCI_SIGNATURE ExtensionType)
Definition: utils.c:584
enum _PCI_SIGNATURE PCI_SIGNATURE
struct _PCI_PDO_EXTENSION * PPCI_PDO_EXTENSION
#define PCI_IS_ROOT_FDO(x)
Definition: pci.h:32
#define ASSERT_PDO(x)
Definition: pci.h:38
@ PciArb_Io
Definition: pci.h:96
@ PciArb_Memory
Definition: pci.h:97
@ PdoExtension
Definition: precomp.h:49
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
_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 40 of file arb_comn.c.

41{
42 PPCI_INTERFACE CurrentInterface, *Interfaces;
44 PPCI_ARBITER_INSTANCE ArbiterInterface;
46 PCI_SIGNATURE ArbiterType;
48
49 /* Loop all the arbiters */
50 for (ArbiterType = PciArb_Io; ArbiterType <= PciArb_BusNumber; ArbiterType++)
51 {
52 /* Check if this is the extension for the Root PCI Bus */
54 {
55 /* Get the PDO extension */
56 PdoExtension = FdoExtension->PhysicalDeviceObject->DeviceExtension;
58
59 /* Skip this bus if it does subtractive decode */
60 if (PdoExtension->Dependent.type1.SubtractiveDecode)
61 {
62 DPRINT1("PCI Not creating arbiters for subtractive bus %u\n",
63 PdoExtension->Dependent.type1.SubtractiveDecode);
64 continue;
65 }
66 }
67
68 /* Query all the registered arbiter interfaces */
69 Interfaces = PciInterfaces;
70 while (*Interfaces)
71 {
72 /* Find the one that matches the arbiter currently being setup */
73 CurrentInterface = *Interfaces;
74 if (CurrentInterface->Signature == ArbiterType) break;
75 Interfaces++;
76 }
77
78 /* Check if the required arbiter was not found in the list */
79 if (!*Interfaces)
80 {
81 /* Skip this arbiter and try the next one */
82 DPRINT1("PCI - FDO ext 0x%p no %s arbiter.\n",
84 PciArbiterNames[ArbiterType - PciArb_Io]);
85 continue;
86 }
87
88 /* An arbiter was found, allocate an instance for it */
90 ArbiterInterface = ExAllocatePoolWithTag(PagedPool,
93 if (!ArbiterInterface) break;
94
95 /* Setup the instance */
96 ArbiterInterface->BusFdoExtension = FdoExtension;
97 ArbiterInterface->Interface = CurrentInterface;
98 swprintf(ArbiterInterface->InstanceName,
99 L"PCI %S (b=%02x)",
100 PciArbiterNames[ArbiterType - PciArb_Io],
101 FdoExtension->BaseBus);
102
103 /* Call the interface initializer for it */
104 Status = CurrentInterface->Initializer(ArbiterInterface);
105 if (!NT_SUCCESS(Status)) break;
106
107 /* Link it with this FDO */
108 PcipLinkSecondaryExtension(&FdoExtension->SecondaryExtension,
109 &FdoExtension->SecondaryExtLock,
110 &ArbiterInterface->Header,
111 ArbiterType,
113
114 /* This arbiter is now initialized, move to the next one */
115 DPRINT1("PCI - FDO ext 0x%p %S arbiter initialized (context 0x%p).\n",
117 L"ARBITER HEADER MISSING", //ArbiterInterface->CommonInstance.Name,
118 ArbiterInterface);
120 }
121
122 /* Return to caller */
123 return Status;
124}
VOID NTAPI PciArbiterDestructor(IN PPCI_ARBITER_INSTANCE Arbiter)
Definition: arb_comn.c:30
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define swprintf
Definition: precomp.h:40
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 PCI_POOL_TAG
Definition: pci.h:27
#define ASSERT_FDO(x)
Definition: pci.h:37
@ PciArb_BusNumber
Definition: pci.h:99
@ FdoExtension
Definition: precomp.h:48
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
Status
Definition: gdiplustypes.h:25
PPCI_INTERFACE PciInterfaces[]
Definition: intrface.c:18
#define L(x)
Definition: ntvdm.h:50
PPCI_FDO_EXTENSION BusFdoExtension
Definition: pci.h:405
PCI_SECONDARY_EXTENSION Header
Definition: pci.h:403
WCHAR InstanceName[24]
Definition: pci.h:406
PPCI_INTERFACE Interface
Definition: pci.h:404
PCI_SIGNATURE Signature
Definition: pci.h:383
PCI_INTERFACE_INITIALIZER Initializer
Definition: pci.h:385
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by PciAddDevice().

Variable Documentation

◆ PciArbiterNames

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

Definition at line 18 of file arb_comn.c.

Referenced by PciInitializeArbiterRanges(), and PciInitializeArbiters().