ReactOS 0.4.17-dev-923-g4c9a150
busemul.c File Reference
#include <hal.h>
#include <debug.h>
Include dependency graph for busemul.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI HalpRegisterKdSupportFunctions (VOID)
 
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)
 
BOOLEAN NTAPI HalpTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 
BOOLEAN NTAPI HalpFindBusAddressTranslation (IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
 
NTSTATUS NTAPI HalAdjustResourceList (IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pRequirementsList)
 
NTSTATUS NTAPI HalAssignSlotResources (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)
 
ULONG NTAPI HalGetBusData (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
ULONG NTAPI HalGetBusDataByOffset (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
ULONG NTAPI HalGetInterruptVector (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
 
ULONG NTAPI HalSetBusData (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
 
ULONG NTAPI HalSetBusDataByOffset (IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
 
BOOLEAN NTAPI HalTranslateBusAddress (IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file busemul.c.

Function Documentation

◆ HalAdjustResourceList()

NTSTATUS NTAPI HalAdjustResourceList ( IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *  pRequirementsList)

Definition at line 118 of file busemul.c.

119{
120 /* Deprecated, return success */
121 return STATUS_SUCCESS;
122}
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ HalAssignSlotResources()

NTSTATUS NTAPI HalAssignSlotResources ( 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 at line 130 of file busemul.c.

138{
139 /* Check the bus type */
140 if (BusType != PCIBus)
141 {
142 /* Call our internal handler */
147 BusType,
148 BusNumber,
151 }
152 else
153 {
154 /* Call the PCI registered function */
159 PCIBus,
160 BusNumber,
163 }
164}
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
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4643
#define HalPciAssignSlotResources
Definition: halfuncs.h:42
_In_ ULONG BusNumber
Definition: pciidex.h:65
@ PCIBus
Definition: restypes.h:127
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
_In_ WDFIORESREQLIST _In_ ULONG SlotNumber
Definition: wdfresource.h:68
_In_opt_ PUNICODE_STRING DriverClassName
Definition: halfuncs.h:156
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:159

◆ HalGetBusData()

ULONG NTAPI HalGetBusData ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 171 of file busemul.c.

176{
177 /* Call the extended function */
178 return HalGetBusDataByOffset(BusDataType,
179 BusNumber,
181 Buffer,
182 0,
183 Length);
184}
ULONG NTAPI HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: busemul.c:191
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

◆ HalGetBusDataByOffset()

ULONG NTAPI HalGetBusDataByOffset ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 191 of file busemul.c.

197{
198 BUS_HANDLER BusHandler;
199
200 /* Look as the bus type */
201 if (BusDataType == Cmos)
202 {
203 /* Call CMOS Function */
205 }
206 else if (BusDataType == EisaConfiguration)
207 {
208 /* FIXME: TODO */
209 ASSERT(FALSE);
210 }
211 else if ((BusDataType == PCIConfiguration) &&
214 {
215 /* Setup fake PCI Bus handler */
216 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
217 BusHandler.BusNumber = BusNumber;
218
219 /* Call PCI function */
220 return HalpGetPCIData(&BusHandler,
221 &BusHandler,
223 Buffer,
224 Offset,
225 Length);
226 }
227
228 /* Invalid bus */
229 return 0;
230}
ULONG HalpMaxPciBus
Definition: bus.h:655
const BUS_HANDLER HalpFakePciBusHandler
Definition: pcibus.c:94
BOOLEAN HalpPCIConfigInitialized
Definition: pcibus.c:20
ULONG HalpMinPciBus
Definition: pcibus.c:21
ULONG NTAPI HalpGetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:507
#define FALSE
Definition: types.h:117
ULONG NTAPI HalpGetCmosData(_In_ ULONG BusNumber, _In_ ULONG SlotNumber, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
Definition: cmos.c:49
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
@ EisaConfiguration
Definition: miniport.h:90
@ Cmos
Definition: miniport.h:89
@ PCIConfiguration
Definition: miniport.h:93
ULONG BusNumber
Definition: haltypes.h:1994
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

Referenced by HalGetBusData().

◆ HalGetInterruptVector()

ULONG NTAPI HalGetInterruptVector ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN ULONG  BusInterruptLevel,
IN ULONG  BusInterruptVector,
OUT PKIRQL  Irql,
OUT PKAFFINITY  Affinity 
)

Definition at line 238 of file busemul.c.

244{
245 /* Call the system bus translator */
248 Irql,
249 Affinity);
250}
ULONG NTAPI HalpGetRootInterruptVector(_In_ ULONG BusInterruptLevel, _In_ ULONG BusInterruptVector, _Out_ PKIRQL OutIrql, _Out_ PKAFFINITY OutAffinity)
Definition: apic.c:401
_Out_ PKIRQL Irql
Definition: csq.h:179
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:171
_In_ ULONG _In_ ULONG _In_ ULONG BusInterruptVector
Definition: halfuncs.h:172
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174

◆ HalpAssignSlotResources()

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 at line 45 of file busemul.c.

53{
54 BUS_HANDLER BusHandler;
55 PAGED_CODE();
56
57 /* Only PCI is supported */
59
60 /* Setup fake PCI Bus handler */
61 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
62 BusHandler.BusNumber = BusNumber;
63
64 /* Call the PCI function */
65 return HalpAssignPCISlotResources(&BusHandler,
66 &BusHandler,
73}
#define PAGED_CODE()
NTSTATUS NTAPI HalpAssignPCISlotResources(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 Slot, IN OUT PCM_RESOURCE_LIST *pAllocatedResources)
Definition: pcibus.c:798
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42

Referenced by HalAssignSlotResources(), HalpInitBusHandler(), and HalpInitNonBusHandler().

◆ HalpFindBusAddressTranslation()

BOOLEAN NTAPI HalpFindBusAddressTranslation ( IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress,
IN OUT PULONG_PTR  Context,
IN BOOLEAN  NextBus 
)

Definition at line 90 of file busemul.c.

95{
96 /* Make sure we have a context */
97 if (!Context) return FALSE;
98
99 /* If we have data in the context, then this shouldn't be a new lookup */
100 if ((*Context != 0) && (NextBus != FALSE)) return FALSE;
101
102 /* Return bus data */
104
105 /* Set context value and return success */
106 *Context = 1;
107 return TRUE;
108}
#define TRUE
Definition: types.h:120
_In_ PVOID Context
Definition: storport.h:2269
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
Definition: iofuncs.h:2273
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275

Referenced by HalpInitNonBusHandler().

◆ HalpRegisterKdSupportFunctions()

VOID NTAPI HalpRegisterKdSupportFunctions ( VOID  )

Definition at line 23 of file busemul.c.

24{
25 /* Register PCI Device Functions */
28
29 /* Register memory functions */
30#if (NTDDI_VERSION >= NTDDI_VISTA)
33#else
36#endif
37
38 /* Register ACPI stub */
40}
PVOID NTAPI HalpMapPhysicalMemory64Vista(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount, IN BOOLEAN FlushCurrentTLB)
Definition: memory.c:156
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN PFN_COUNT PageCount)
Definition: memory.c:148
VOID NTAPI HalpUnmapVirtualAddressVista(IN PVOID VirtualAddress, IN PFN_COUNT PageCount, IN BOOLEAN FlushCurrentTLB)
Definition: memory.c:227
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount)
Definition: memory.c:140
VOID NTAPI HalpCheckPowerButton(VOID)
Definition: misc.c:146
NTSTATUS NTAPI HalpReleasePciDeviceForDebugging(_Inout_ PDEBUG_DEVICE_DESCRIPTOR PciDevice)
Releases the PCI device MMIO mappings previously allocated with HalpSetupPciDeviceForDebugging().
Definition: kdpci.c:421
NTSTATUS NTAPI HalpSetupPciDeviceForDebugging(_In_opt_ PVOID LoaderBlock, _Inout_ PDEBUG_DEVICE_DESCRIPTOR PciDevice)
Finds and fully initializes the PCI device associated with the supplied debug device descriptor.
Definition: kdpci.c:483
#define KdUnmapVirtualAddress
Definition: halfuncs.h:56
#define KdMapPhysicalMemory64
Definition: halfuncs.h:55
#define KdSetupPciDeviceForDebugging
Definition: halfuncs.h:50
#define KdReleasePciDeviceforDebugging
Definition: halfuncs.h:51
#define KdCheckPowerButton
Definition: halfuncs.h:53

Referenced by HalInitializeProcessor().

◆ HalpTranslateBusAddress()

BOOLEAN NTAPI HalpTranslateBusAddress ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 77 of file busemul.c.

82{
83 /* Translation is easy */
85 return TRUE;
86}

Referenced by HalpInitNonBusHandler().

◆ HalSetBusData()

ULONG NTAPI HalSetBusData ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Length 
)

Definition at line 258 of file busemul.c.

263{
264 /* Call the extended function */
265 return HalSetBusDataByOffset(BusDataType,
266 BusNumber,
268 Buffer,
269 0,
270 Length);
271}
ULONG NTAPI HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: busemul.c:278

◆ HalSetBusDataByOffset()

ULONG NTAPI HalSetBusDataByOffset ( IN BUS_DATA_TYPE  BusDataType,
IN ULONG  BusNumber,
IN ULONG  SlotNumber,
IN PVOID  Buffer,
IN ULONG  Offset,
IN ULONG  Length 
)

Definition at line 278 of file busemul.c.

284{
285 BUS_HANDLER BusHandler;
286
287 /* Look as the bus type */
288 if (BusDataType == Cmos)
289 {
290 /* Call CMOS Function */
292 }
293 else if ((BusDataType == PCIConfiguration) && (HalpPCIConfigInitialized))
294 {
295 /* Setup fake PCI Bus handler */
296 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
297 BusHandler.BusNumber = BusNumber;
298
299 /* Call PCI function */
300 return HalpSetPCIData(&BusHandler,
301 &BusHandler,
303 Buffer,
304 Offset,
305 Length);
306 }
307
308 /* Invalid bus */
309 return 0;
310}
ULONG NTAPI HalpSetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootBusHandler, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pcibus.c:587
ULONG NTAPI HalpSetCmosData(_In_ ULONG BusNumber, _In_ ULONG SlotNumber, _In_reads_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
Definition: cmos.c:104

Referenced by HalSetBusData().

◆ HalTranslateBusAddress()

BOOLEAN NTAPI HalTranslateBusAddress ( IN INTERFACE_TYPE  InterfaceType,
IN ULONG  BusNumber,
IN PHYSICAL_ADDRESS  BusAddress,
IN OUT PULONG  AddressSpace,
OUT PPHYSICAL_ADDRESS  TranslatedAddress 
)

Definition at line 317 of file busemul.c.

322{
323 /* Look as the bus type */
324 if (InterfaceType == PCIBus)
325 {
326 /* Call the PCI registered function */
328 BusNumber,
332 }
333 else
334 {
335 /* Translation is easy */
337 return TRUE;
338 }
339}
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID InterfaceType
Definition: wdffdo.h:463
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2274