ReactOS  0.4.15-dev-3163-gf17c2c0
bushndlr.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for bushndlr.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PARRAY NTAPI HalpAllocateArray (IN ULONG ArraySize)
 
VOID NTAPI HalpGrowArray (IN PARRAY *CurrentArray, IN PARRAY *NewArray)
 
PBUS_HANDLER FASTCALL HalpLookupHandler (IN PARRAY Array, IN ULONG Type, IN ULONG Number, IN BOOLEAN AddReference)
 
ULONG NTAPI HalpNoBusData (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
NTSTATUS NTAPI HalpNoAdjustResourceList (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList)
 
NTSTATUS NTAPI HalpNoAssignSlotResources (IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
 
VOID FASTCALL HaliReferenceBusHandler (IN PBUS_HANDLER Handler)
 
VOID FASTCALL HaliDereferenceBusHandler (IN PBUS_HANDLER Handler)
 
PBUS_HANDLER FASTCALL HaliHandlerForBus (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
 
PBUS_HANDLER FASTCALL HaliHandlerForConfigSpace (IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber)
 
PBUS_HANDLER FASTCALL HaliReferenceHandlerForBus (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
 
PBUS_HANDLER FASTCALL HaliReferenceHandlerForConfigSpace (IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber)
 
PBUS_HANDLER NTAPI HalpContextToBusHandler (IN ULONG_PTR ContextValue)
 
NTSTATUS NTAPI HaliRegisterBusHandler (IN INTERFACE_TYPE InterfaceType, IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber, IN INTERFACE_TYPE ParentBusType, IN ULONG ParentBusNumber, IN ULONG ExtraData, IN PINSTALL_BUS_HANDLER InstallCallback, OUT PBUS_HANDLER *ReturnedBusHandler)
 
VOID NTAPI HalpInitBusHandler (VOID)
 

Variables

KSPIN_LOCK HalpBusDatabaseSpinLock
 
KEVENT HalpBusDatabaseEvent
 
LIST_ENTRY HalpAllBusHandlers
 
PARRAY HalpBusTable
 
PARRAY HalpConfigTable
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file bushndlr.c.

Function Documentation

◆ HaliDereferenceBusHandler()

VOID FASTCALL HaliDereferenceBusHandler ( IN PBUS_HANDLER  Handler)

Definition at line 158 of file bushndlr.c.

159 {
160  PHAL_BUS_HANDLER Bus;
161 
162  /* Find and dereference the bus handler */
164  Bus->ReferenceCount--;
165  ASSERT(Bus->ReferenceCount != 0);
166 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define ASSERT(a)
Definition: mode.c:44
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
ULONG ReferenceCount
Definition: bus.h:273

Referenced by HalpInitBusHandler().

◆ HaliHandlerForBus()

PBUS_HANDLER FASTCALL HaliHandlerForBus ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber 
)

Definition at line 170 of file bushndlr.c.

172 {
173  /* Lookup the interface in the bus table */
175 }
#define FALSE
Definition: types.h:117
PARRAY HalpBusTable
Definition: bushndlr.c:20
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
PBUS_HANDLER FASTCALL HalpLookupHandler(IN PARRAY Array, IN ULONG Type, IN ULONG Number, IN BOOLEAN AddReference)
Definition: bushndlr.c:76
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:461

Referenced by HaliRegisterBusHandler(), and HalpInitBusHandler().

◆ HaliHandlerForConfigSpace()

PBUS_HANDLER FASTCALL HaliHandlerForConfigSpace ( IN BUS_DATA_TYPE  ConfigType,
IN ULONG  BusNumber 
)

Definition at line 179 of file bushndlr.c.

181 {
182  /* Lookup the configuration in the configuration table */
183  return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, FALSE);
184 }
PARRAY HalpConfigTable
Definition: bushndlr.c:21
#define FALSE
Definition: types.h:117
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
PBUS_HANDLER FASTCALL HalpLookupHandler(IN PARRAY Array, IN ULONG Type, IN ULONG Number, IN BOOLEAN AddReference)
Definition: bushndlr.c:76

Referenced by HalpInitBusHandler().

◆ HaliReferenceBusHandler()

VOID FASTCALL HaliReferenceBusHandler ( IN PBUS_HANDLER  Handler)

Definition at line 147 of file bushndlr.c.

148 {
149  PHAL_BUS_HANDLER Bus;
150 
151  /* Find and reference the bus handler */
153  Bus->ReferenceCount++;
154 }
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
ULONG ReferenceCount
Definition: bus.h:273

Referenced by HalpInitBusHandler().

◆ HaliReferenceHandlerForBus()

PBUS_HANDLER FASTCALL HaliReferenceHandlerForBus ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber 
)

Definition at line 188 of file bushndlr.c.

190 {
191  /* Lookup the interface in the bus table, and reference the handler */
193 }
#define TRUE
Definition: types.h:120
PARRAY HalpBusTable
Definition: bushndlr.c:20
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
PBUS_HANDLER FASTCALL HalpLookupHandler(IN PARRAY Array, IN ULONG Type, IN ULONG Number, IN BOOLEAN AddReference)
Definition: bushndlr.c:76
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:461

Referenced by HaliRegisterBusHandler(), and HalpInitBusHandler().

◆ HaliReferenceHandlerForConfigSpace()

PBUS_HANDLER FASTCALL HaliReferenceHandlerForConfigSpace ( IN BUS_DATA_TYPE  ConfigType,
IN ULONG  BusNumber 
)

Definition at line 197 of file bushndlr.c.

199 {
200  /* Lookup the configuration in the configuration table and add a reference */
201  return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, TRUE);
202 }
#define TRUE
Definition: types.h:120
PARRAY HalpConfigTable
Definition: bushndlr.c:21
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
PBUS_HANDLER FASTCALL HalpLookupHandler(IN PARRAY Array, IN ULONG Type, IN ULONG Number, IN BOOLEAN AddReference)
Definition: bushndlr.c:76

Referenced by HalGetBusDataByOffset(), and HalSetBusDataByOffset().

◆ HaliRegisterBusHandler()

NTSTATUS NTAPI HaliRegisterBusHandler ( IN INTERFACE_TYPE  InterfaceType,
IN BUS_DATA_TYPE  ConfigType,
IN ULONG  BusNumber,
IN INTERFACE_TYPE  ParentBusType,
IN ULONG  ParentBusNumber,
IN ULONG  ExtraData,
IN PINSTALL_BUS_HANDLER  InstallCallback,
OUT PBUS_HANDLER ReturnedBusHandler 
)

Definition at line 242 of file bushndlr.c.

250 {
251  PHAL_BUS_HANDLER Bus, OldHandler = NULL;
252  PHAL_BUS_HANDLER* BusEntry;
253  //PVOID CodeHandle;
254  PARRAY InterfaceArray, InterfaceBusNumberArray, ConfigArray, ConfigBusNumberArray;
255  PBUS_HANDLER ParentHandler;
256  KIRQL OldIrql;
258 
259  /* Make sure we have a valid handler */
261  (ConfigType != ConfigurationSpaceUndefined));
262 
263  /* Allocate the bus handler */
265  sizeof(HAL_BUS_HANDLER) + ExtraData,
267  if (!Bus) return STATUS_INSUFFICIENT_RESOURCES;
268 
269  /* Return the handler */
270  *ReturnedBusHandler = &Bus->Handler;
271 
272  /* FIXME: Fix the kernel first. Don't page us out */
273  //CodeHandle = MmLockPagableDataSection(&HaliRegisterBusHandler);
274 
275  /* Synchronize with anyone else */
277  WrExecutive,
278  KernelMode,
279  FALSE,
280  NULL);
281 
282  /* Check for unknown/root bus */
283  if (BusNumber == -1)
284  {
285  /* We must have an interface */
287 
288  /* Find the right bus */
289  BusNumber = 0;
291  }
292 
293  /* Allocate arrays for the handler */
294  InterfaceArray = HalpAllocateArray(InterfaceType);
295  InterfaceBusNumberArray = HalpAllocateArray(BusNumber);
296  ConfigArray = HalpAllocateArray(ConfigType);
297  ConfigBusNumberArray = HalpAllocateArray(BusNumber);
298 
299  /* Only proceed if all allocations succeeded */
300  if ((InterfaceArray) && (InterfaceBusNumberArray) && (ConfigArray) && (ConfigBusNumberArray))
301  {
302  /* Find the parent handler if any */
303  ParentHandler = HaliReferenceHandlerForBus(ParentBusType, ParentBusNumber);
304 
305  /* Initialize the handler */
306  RtlZeroMemory(Bus, sizeof(HAL_BUS_HANDLER) + ExtraData);
307  Bus->ReferenceCount = 1;
308 
309  /* Fill out bus data */
310  Bus->Handler.BusNumber = BusNumber;
312  Bus->Handler.ConfigurationType = ConfigType;
313  Bus->Handler.ParentHandler = ParentHandler;
314 
315  /* Fill out dummy handlers */
320 
321  /* Make space for extra data */
322  if (ExtraData) Bus->Handler.BusData = Bus + 1;
323 
324  /* Check for a parent handler */
325  if (ParentHandler)
326  {
327  /* Inherit the parent routines */
328  Bus->Handler.GetBusData = ParentHandler->GetBusData;
329  Bus->Handler.SetBusData = ParentHandler->SetBusData;
330  Bus->Handler.AdjustResourceList = ParentHandler->AdjustResourceList;
331  Bus->Handler.AssignSlotResources = ParentHandler->AssignSlotResources;
332  Bus->Handler.TranslateBusAddress = ParentHandler->TranslateBusAddress;
333  Bus->Handler.GetInterruptVector = ParentHandler->GetInterruptVector;
334  }
335 
336  /* We don't support this yet */
338 
339  /* Lock the buses */
341 
342  /* Make space for the interface */
343  HalpGrowArray(&HalpBusTable, &InterfaceArray);
344 
345  /* Check if we really have an interface */
347  {
348  /* Make space for the association */
350  &InterfaceBusNumberArray);
351 
352  /* Get the bus handler pointer */
353  BusEntry = (PHAL_BUS_HANDLER*)&((PARRAY)HalpBusTable->Element[InterfaceType])->Element[BusNumber];
354 
355  /* Check if there was already a handler there, and set the new one */
356  if (*BusEntry) OldHandler = *BusEntry;
357  *BusEntry = Bus;
358  }
359 
360  /* Now add a space for the configuration space */
361  HalpGrowArray(&HalpConfigTable, &ConfigArray);
362 
363  /* Check if we really have one */
364  if (ConfigType != ConfigurationSpaceUndefined)
365  {
366  /* Make space for this association */
368  &ConfigBusNumberArray);
369 
370  /* Get the bus handler pointer */
371  BusEntry = (PHAL_BUS_HANDLER*)&((PARRAY)HalpConfigTable->Element[ConfigType])->Element[BusNumber];
372  if (*BusEntry)
373  {
374  /* Get the old entry, but make sure it's the same we had before */
375  ASSERT((OldHandler == NULL) || (OldHandler == *BusEntry));
376  OldHandler = *BusEntry;
377  }
378 
379  /* Set the new entry */
380  *BusEntry = Bus;
381  }
382 
383  /* Link the adapter */
385 
386  /* Remove the old linkage */
387  Bus = OldHandler;
388  if (Bus) RemoveEntryList(&Bus->AllHandlers);
389 
390  /* Release the lock */
393  }
394  else
395  {
396  /* Fail */
398  }
399 
400  /* Signal the event */
402 
403  /* FIXME: Fix the kernel first. Re-page the function */
404  //MmUnlockPagableImageSection(CodeHandle);
405 
406  /* Free all allocations */
407  if (Bus) ExFreePoolWithTag(Bus, TAG_BUS_HANDLER);
408  if (InterfaceArray) ExFreePoolWithTag(InterfaceArray, TAG_BUS_HANDLER);
409  if (InterfaceBusNumberArray) ExFreePoolWithTag(InterfaceBusNumberArray, TAG_BUS_HANDLER);
410  if (ConfigArray) ExFreePoolWithTag(ConfigArray, TAG_BUS_HANDLER);
411  if (ConfigBusNumberArray) ExFreePoolWithTag(ConfigBusNumberArray, TAG_BUS_HANDLER);
412 
413  /* And we're done */
414  return Status;
415 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BUS_DATA_TYPE ConfigurationType
Definition: haltypes.h:225
PARRAY NTAPI HalpAllocateArray(IN ULONG ArraySize)
Definition: bushndlr.c:27
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI KeAcquireSpinLock(PKSPIN_LOCK SpinLock, PKIRQL OldIrql)
Definition: spinlock.c:50
#define InsertTailList(ListHead, Entry)
PARRAY HalpConfigTable
Definition: bushndlr.c:21
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
PBUS_HANDLER FASTCALL HaliHandlerForBus(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: bushndlr.c:170
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
ULONG NTAPI HalpNoBusData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: bushndlr.c:108
#define TAG_BUS_HANDLER
Definition: hal.h:62
PARRAY HalpBusTable
Definition: bushndlr.c:20
struct _BUS_HANDLER * ParentHandler
Definition: haltypes.h:228
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
KIRQL OldIrql
Definition: mm.h:1502
Status
Definition: gdiplustypes.h:24
ULONG BusNumber
Definition: haltypes.h:226
#define ASSERT(a)
Definition: mode.c:44
PTRANSLATEBUSADDRESS TranslateBusAddress
Definition: haltypes.h:238
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
PASSIGNSLOTRESOURCES AssignSlotResources
Definition: haltypes.h:236
NTSTATUS NTAPI HalpNoAssignSlotResources(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName OPTIONAL, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject OPTIONAL, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
Definition: bushndlr.c:132
NTSTATUS NTAPI HalpNoAdjustResourceList(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList)
Definition: bushndlr.c:122
KSPIN_LOCK HalpBusDatabaseSpinLock
Definition: bushndlr.c:17
BUS_HANDLER Handler
Definition: bus.h:274
PVOID Element[ANYSIZE_ARRAY]
Definition: bus.h:267
LIST_ENTRY HalpAllBusHandlers
Definition: bushndlr.c:19
PGETSETBUSDATA SetBusData
Definition: haltypes.h:234
PGETINTERRUPTVECTOR GetInterruptVector
Definition: haltypes.h:237
KEVENT HalpBusDatabaseEvent
Definition: bushndlr.c:18
#define NULL
Definition: types.h:112
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
Definition: shimeng.h:15
INTERFACE_TYPE InterfaceType
Definition: haltypes.h:224
PBUS_HANDLER FASTCALL HaliReferenceHandlerForBus(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: bushndlr.c:188
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PGETSETBUSDATA GetBusData
Definition: haltypes.h:233
PADJUSTRESOURCELIST AdjustResourceList
Definition: haltypes.h:235
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI HalpGrowArray(IN PARRAY *CurrentArray, IN PARRAY *NewArray)
Definition: bushndlr.c:50
LIST_ENTRY AllHandlers
Definition: bus.h:272
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ULONG ReferenceCount
Definition: bus.h:273
PVOID BusData
Definition: haltypes.h:229
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:461

Referenced by HalpInitBusHandler().

◆ HalpAllocateArray()

PARRAY NTAPI HalpAllocateArray ( IN ULONG  ArraySize)

Definition at line 27 of file bushndlr.c.

28 {
29  PARRAY Array;
30  ULONG Size;
31 
32  /* Compute array size */
33  if (ArraySize == MAXULONG) ArraySize = 0;
34  Size = ArraySize * sizeof(PARRAY) + sizeof(ARRAY);
35 
36  /* Allocate the array */
38  Size,
40  if (!Array) KeBugCheckEx(HAL_MEMORY_ALLOCATION, Size, 0, (ULONG_PTR)__FILE__, __LINE__);
41 
42  /* Initialize it */
43  Array->ArraySize = ArraySize;
44  RtlZeroMemory(Array->Element, sizeof(PVOID) * (ArraySize + 1));
45  return Array;
46 }
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
uint32_t ULONG_PTR
Definition: typedefs.h:65
struct _ARRAY * PARRAY
#define TAG_BUS_HANDLER
Definition: hal.h:62
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define MAXULONG
Definition: typedefs.h:251
ULONG ArraySize
Definition: bus.h:266
PVOID Element[ANYSIZE_ARRAY]
Definition: bus.h:267
Definition: shimeng.h:15
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by HaliRegisterBusHandler(), and HalpInitBusHandler().

◆ HalpContextToBusHandler()

PBUS_HANDLER NTAPI HalpContextToBusHandler ( IN ULONG_PTR  ContextValue)

Definition at line 206 of file bushndlr.c.

207 {
208  PLIST_ENTRY NextEntry;
209  PHAL_BUS_HANDLER BusHandler, ThisHandler;
210 
211  /* Start lookup */
212  NextEntry = HalpAllBusHandlers.Flink;
213  ThisHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers);
214  if (ContextValue)
215  {
216  /* If the list is empty, quit */
217  if (IsListEmpty(&HalpAllBusHandlers)) return NULL;
218 
219  /* Otherwise, scan the list */
220  BusHandler = CONTAINING_RECORD(ContextValue, HAL_BUS_HANDLER, Handler);
221  do
222  {
223  /* Check if we've reached the right one */
224  ThisHandler = CONTAINING_RECORD(NextEntry, HAL_BUS_HANDLER, AllHandlers);
225  if (ThisHandler == BusHandler) break;
226 
227  /* Try the next one */
228  NextEntry = NextEntry->Flink;
229  } while (NextEntry != &HalpAllBusHandlers);
230  }
231 
232  /* If we looped back to the end, we didn't find anything */
233  if (NextEntry == &HalpAllBusHandlers) return NULL;
234 
235  /* Otherwise return the handler */
236  return &ThisHandler->Handler;
237 }
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
Definition: typedefs.h:119
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
BUS_HANDLER Handler
Definition: bus.h:274
LIST_ENTRY HalpAllBusHandlers
Definition: bushndlr.c:19
#define NULL
Definition: types.h:112

Referenced by HaliFindBusAddressTranslation().

◆ HalpGrowArray()

VOID NTAPI HalpGrowArray ( IN PARRAY CurrentArray,
IN PARRAY NewArray 
)

Definition at line 50 of file bushndlr.c.

52 {
53  PVOID Tmp;
54 
55  /* Check if the current array doesn't exist yet, or if it's smaller than the new one */
56  if (!(*CurrentArray) || ((*NewArray)->ArraySize > (*CurrentArray)->ArraySize))
57  {
58  /* Does it exist (and can it fit?) */
59  if (*CurrentArray)
60  {
61  /* Copy the current array into the new one */
62  RtlCopyMemory(&(*NewArray)->Element,
63  &(*CurrentArray)->Element,
64  sizeof(PVOID) * ((*CurrentArray)->ArraySize + 1));
65  }
66 
67  /* Swap the pointers (XOR swap would be more l33t) */
68  Tmp = *CurrentArray;
69  *CurrentArray = *NewArray;
70  *NewArray = Tmp;
71  }
72 }
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by HaliRegisterBusHandler().

◆ HalpInitBusHandler()

VOID NTAPI HalpInitBusHandler ( VOID  )

Definition at line 420 of file bushndlr.c.

421 {
422  /* Setup the bus lock */
424 
425  /* Setup the bus event */
427 
428  /* Setup the bus configuration and bus table */
431 
432  /* Setup the bus list */
434 
435  /* Setup the HAL Dispatch routines */
436 #ifndef _MINIHAL_
443 #endif
445  HalPciTranslateBusAddress = HaliTranslateBusAddress; /* PCI Driver can override */
447 }
#define HalReferenceHandlerForBus
Definition: haltypes.h:286
#define HalRegisterBusHandler
Definition: halfuncs.h:38
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41
#define TRUE
Definition: types.h:120
PARRAY NTAPI HalpAllocateArray(IN ULONG ArraySize)
Definition: bushndlr.c:27
PARRAY HalpConfigTable
Definition: bushndlr.c:21
#define HalDereferenceBusHandler
Definition: haltypes.h:288
PBUS_HANDLER FASTCALL HaliHandlerForBus(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: bushndlr.c:170
BOOLEAN NTAPI HaliFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
Definition: bussupp.c:1307
PBUS_HANDLER FASTCALL HaliHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber)
Definition: bushndlr.c:179
BOOLEAN NTAPI HaliTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: bussupp.c:1381
VOID FASTCALL HaliDereferenceBusHandler(IN PBUS_HANDLER Handler)
Definition: bushndlr.c:158
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:238
PARRAY HalpBusTable
Definition: bushndlr.c:20
NTSTATUS NTAPI HaliRegisterBusHandler(IN INTERFACE_TYPE InterfaceType, IN BUS_DATA_TYPE ConfigType, IN ULONG BusNumber, IN INTERFACE_TYPE ParentBusType, IN ULONG ParentBusNumber, IN ULONG ExtraData, IN PINSTALL_BUS_HANDLER InstallCallback, OUT PBUS_HANDLER *ReturnedBusHandler)
Definition: bushndlr.c:242
#define HalHandlerForConfigSpace
Definition: halfuncs.h:36
NTSTATUS NTAPI HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, IN PUNICODE_STRING DriverClassName, IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT DeviceObject, IN INTERFACE_TYPE BusType, IN ULONG BusNumber, IN ULONG SlotNumber, IN OUT PCM_RESOURCE_LIST *AllocatedResources)
Definition: busemul.c:45
KSPIN_LOCK HalpBusDatabaseSpinLock
Definition: bushndlr.c:17
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define HalFindBusAddressTranslation
Definition: halfuncs.h:44
LIST_ENTRY HalpAllBusHandlers
Definition: bushndlr.c:19
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
KEVENT HalpBusDatabaseEvent
Definition: bushndlr.c:18
VOID FASTCALL HaliReferenceBusHandler(IN PBUS_HANDLER Handler)
Definition: bushndlr.c:147
PBUS_HANDLER FASTCALL HaliReferenceHandlerForBus(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber)
Definition: bushndlr.c:188
#define HalPciAssignSlotResources
Definition: halfuncs.h:42
#define HalHandlerForBus
Definition: halfuncs.h:35
#define HalReferenceBusHandler
Definition: haltypes.h:287

Referenced by HalpRegisterInternalBusHandlers(), and LoadBootDeviceDriver().

◆ HalpLookupHandler()

PBUS_HANDLER FASTCALL HalpLookupHandler ( IN PARRAY  Array,
IN ULONG  Type,
IN ULONG  Number,
IN BOOLEAN  AddReference 
)

Definition at line 76 of file bushndlr.c.

80 {
81  PHAL_BUS_HANDLER Bus;
83 
84  /* Make sure the entry exists */
85  if (Array->ArraySize >= Type)
86  {
87  /* Retrieve it */
88  Array = Array->Element[Type];
89 
90  /* Make sure the entry array exists */
91  if ((Array) && (Array->ArraySize >= Number))
92  {
93  /* Retrieve the bus and its handler */
94  Bus = Array->Element[Number];
95  Handler = &Bus->Handler;
96 
97  /* Reference the handler if needed */
98  if (AddReference) Bus->ReferenceCount++;
99  }
100  }
101 
102  /* Return the handler */
103  return Handler;
104 }
Type
Definition: Type.h:6
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:668
BUS_HANDLER Handler
Definition: bus.h:274
#define NULL
Definition: types.h:112
ULONG ReferenceCount
Definition: bus.h:273

Referenced by HaliHandlerForBus(), HaliHandlerForConfigSpace(), HaliReferenceHandlerForBus(), and HaliReferenceHandlerForConfigSpace().

◆ HalpNoAdjustResourceList()

NTSTATUS NTAPI HalpNoAdjustResourceList ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN OUT PIO_RESOURCE_REQUIREMENTS_LIST pResourceList 
)

Definition at line 122 of file bushndlr.c.

125 {
126  DPRINT1("STUB Adjustment\n");
127  return STATUS_UNSUCCESSFUL;
128 }
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define DPRINT1
Definition: precomp.h:8

Referenced by HaliRegisterBusHandler().

◆ HalpNoAssignSlotResources()

NTSTATUS NTAPI HalpNoAssignSlotResources ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN PUNICODE_STRING  RegistryPath,
IN PUNICODE_STRING DriverClassName  OPTIONAL,
IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT DeviceObject  OPTIONAL,
IN ULONG  SlotNumber,
IN OUT PCM_RESOURCE_LIST AllocatedResources 
)

Definition at line 132 of file bushndlr.c.

140 {
141  DPRINT1("STUB Assignment\n");
142  return STATUS_NOT_SUPPORTED;
143 }
return STATUS_NOT_SUPPORTED
#define DPRINT1
Definition: precomp.h:8

Referenced by HaliRegisterBusHandler().

◆ HalpNoBusData()

ULONG NTAPI HalpNoBusData ( IN PBUS_HANDLER  BusHandler,
IN PBUS_HANDLER  RootHandler,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 108 of file bushndlr.c.

114 {
115  /* Not implemented */
116  DPRINT1("STUB GetSetBusData\n");
117  return 0;
118 }
#define DPRINT1
Definition: precomp.h:8

Referenced by HaliRegisterBusHandler(), and HalpRegisterInternalBusHandlers().

Variable Documentation

◆ HalpAllBusHandlers

◆ HalpBusDatabaseEvent

KEVENT HalpBusDatabaseEvent

Definition at line 18 of file bushndlr.c.

Referenced by HaliRegisterBusHandler(), and HalpInitBusHandler().

◆ HalpBusDatabaseSpinLock

KSPIN_LOCK HalpBusDatabaseSpinLock

Definition at line 17 of file bushndlr.c.

Referenced by HaliRegisterBusHandler(), and HalpInitBusHandler().

◆ HalpBusTable

◆ HalpConfigTable