ReactOS  0.4.15-dev-1018-g0695ecb
busemul.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: hal/halx86/acpi/busemul.c
5  * PURPOSE: ACPI HAL Bus Handler Emulation Code
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 /* GLOBALS ********************************************************************/
16 
17 /* PRIVATE FUNCTIONS **********************************************************/
18 
19 INIT_FUNCTION
20 VOID
21 NTAPI
23 {
24  /* Register PCI Device Functions */
27 
28  /* Register memory functions */
29 #ifndef _MINIHAL_
30 #if (NTDDI_VERSION >= NTDDI_VISTA)
33 #else
36 #endif
37 #endif
38 
39  /* Register ACPI stub */
41 }
42 
44 NTAPI
53 {
54  BUS_HANDLER BusHandler;
55  PAGED_CODE();
56 
57  /* Only PCI is supported */
58  if (BusType != PCIBus) return STATUS_NOT_IMPLEMENTED;
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,
71  SlotNumber,
73 }
74 
75 BOOLEAN
76 NTAPI
82 {
83  /* Translation is easy */
85  return TRUE;
86 }
87 
88 ULONG
89 NTAPI
93  OUT PKIRQL Irql,
95 {
98  *Affinity = 0xFFFFFFFF;
99  return Vector;
100 }
101 
102 BOOLEAN
103 NTAPI
108  IN BOOLEAN NextBus)
109 {
110  /* Make sure we have a context */
111  if (!Context) return FALSE;
112 
113  /* If we have data in the context, then this shouldn't be a new lookup */
114  if ((*Context != 0) && (NextBus != FALSE)) return FALSE;
115 
116  /* Return bus data */
118 
119  /* Set context value and return success */
120  *Context = 1;
121  return TRUE;
122 }
123 
124 /* PUBLIC FUNCTIONS **********************************************************/
125 
126 /*
127  * @implemented
128  */
129 NTSTATUS
130 NTAPI
132 {
133  /* Deprecated, return success */
134  return STATUS_SUCCESS;
135 }
136 
137 /*
138  * @implemented
139  */
140 NTSTATUS
141 NTAPI
150 {
151  /* Check the bus type */
152  if (BusType != PCIBus)
153  {
154  /* Call our internal handler */
157  DriverObject,
158  DeviceObject,
159  BusType,
160  BusNumber,
161  SlotNumber,
163  }
164  else
165  {
166  /* Call the PCI registered function */
169  DriverObject,
170  DeviceObject,
171  PCIBus,
172  BusNumber,
173  SlotNumber,
175  }
176 }
177 
178 /*
179  * @implemented
180  */
181 ULONG
182 NTAPI
186  IN PVOID Buffer,
187  IN ULONG Length)
188 {
189  /* Call the extended function */
190  return HalGetBusDataByOffset(BusDataType,
191  BusNumber,
192  SlotNumber,
193  Buffer,
194  0,
195  Length);
196 }
197 
198 /*
199  * @implemented
200  */
201 ULONG
202 NTAPI
206  IN PVOID Buffer,
207  IN ULONG Offset,
208  IN ULONG Length)
209 {
210  BUS_HANDLER BusHandler;
211 
212  /* Look as the bus type */
213  if (BusDataType == Cmos)
214  {
215  /* Call CMOS Function */
217  }
218  else if (BusDataType == EisaConfiguration)
219  {
220  /* FIXME: TODO */
221  ASSERT(FALSE);
222  }
223  else if ((BusDataType == PCIConfiguration) &&
226  {
227  /* Setup fake PCI Bus handler */
228  RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
229  BusHandler.BusNumber = BusNumber;
230 
231  /* Call PCI function */
232  return HalpGetPCIData(&BusHandler,
233  &BusHandler,
234  SlotNumber,
235  Buffer,
236  Offset,
237  Length);
238  }
239 
240  /* Invalid bus */
241  return 0;
242 }
243 
244 /*
245  * @implemented
246  */
247 ULONG
248 NTAPI
253  OUT PKIRQL Irql,
255 {
256  /* Call the system bus translator */
260  Irql,
261  Affinity);
262 }
263 
264 /*
265  * @implemented
266  */
267 ULONG
268 NTAPI
272  IN PVOID Buffer,
273  IN ULONG Length)
274 {
275  /* Call the extended function */
276  return HalSetBusDataByOffset(BusDataType,
277  BusNumber,
278  SlotNumber,
279  Buffer,
280  0,
281  Length);
282 }
283 
284 /*
285  * @implemented
286  */
287 ULONG
288 NTAPI
292  IN PVOID Buffer,
293  IN ULONG Offset,
294  IN ULONG Length)
295 {
296  BUS_HANDLER BusHandler;
297 
298  /* Look as the bus type */
299  if (BusDataType == Cmos)
300  {
301  /* Call CMOS Function */
303  }
304  else if ((BusDataType == PCIConfiguration) && (HalpPCIConfigInitialized))
305  {
306  /* Setup fake PCI Bus handler */
307  RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER));
308  BusHandler.BusNumber = BusNumber;
309 
310  /* Call PCI function */
311  return HalpSetPCIData(&BusHandler,
312  &BusHandler,
313  SlotNumber,
314  Buffer,
315  Offset,
316  Length);
317  }
318 
319  /* Invalid bus */
320  return 0;
321 }
322 
323 /*
324  * @implemented
325  */
326 BOOLEAN
327 NTAPI
333 {
334  /* Look as the bus type */
335  if (InterfaceType == PCIBus)
336  {
337  /* Call the PCI registered function */
339  BusNumber,
340  BusAddress,
341  AddressSpace,
343  }
344  else
345  {
346  /* Translation is easy */
348  return TRUE;
349  }
350 }
351 
352 /* EOF */
PVOID NTAPI HalpMapPhysicalMemory64Vista(IN PHYSICAL_ADDRESS PhysicalAddress, IN PFN_COUNT PageCount, IN BOOLEAN FlushCurrentTLB)
Definition: memory.c:156
_In_ ULONG _In_ ULONG BusInterruptLevel
Definition: halfuncs.h:170
#define IN
Definition: typedefs.h:39
#define HalPciTranslateBusAddress
Definition: halfuncs.h:41
BOOLEAN NTAPI HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: busemul.c:328
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
_In_ ULONG _In_ PHYSICAL_ADDRESS BusAddress
Definition: iofuncs.h:2268
VOID NTAPI HalpCheckPowerButton(VOID)
Definition: misc.c:20
enum _INTERFACE_TYPE INTERFACE_TYPE
BOOLEAN HalpPCIConfigInitialized
Definition: pci.c:17
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define KdUnmapVirtualAddress
Definition: halfuncs.h:53
_Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PDEVICE_OBJECT _Inout_opt_ PCM_RESOURCE_LIST * AllocatedResources
Definition: ndis.h:4640
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE BusType
Definition: halfuncs.h:156
#define TRUE
Definition: types.h:120
enum _BUS_DATA_TYPE BUS_DATA_TYPE
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG AddressSpace
Definition: iofuncs.h:2268
LONG NTSTATUS
Definition: precomp.h:26
ULONG HalpMinPciBus
Definition: pci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG BusInterruptVector
Definition: halfuncs.h:170
ULONG NTAPI HalpGetCmosData(IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
Definition: cmos.c:47
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2268
_Out_ PKIRQL Irql
Definition: csq.h:179
_In_opt_ PUNICODE_STRING DriverClassName
Definition: halfuncs.h:156
INIT_FUNCTION VOID NTAPI HalpRegisterKdSupportFunctions(VOID)
Definition: busemul.c:22
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:289
NTSTATUS NTAPI HalpSetupPciDeviceForDebugging(IN PVOID LoaderBlock, IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
Definition: pci.c:473
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
ULONG NTAPI HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
Definition: busemul.c:90
#define FALSE
Definition: types.h:117
PVOID NTAPI HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress, IN ULONG NumberPage)
Definition: misc.c:28
VOID NTAPI HalpUnmapVirtualAddressVista(IN PVOID VirtualAddress, IN PFN_COUNT PageCount, IN BOOLEAN FlushCurrentTLB)
Definition: memory.c:227
BOOLEAN NTAPI HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress, IN OUT PULONG_PTR Context, IN BOOLEAN NextBus)
Definition: busemul.c:104
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:203
KAFFINITY * PKAFFINITY
Definition: basetsd.h:197
unsigned char BOOLEAN
ULONG NTAPI HalSetBusData(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
Definition: busemul.c:269
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
Definition: bufpool.h:45
#define VECTOR2IRQL(vector)
Definition: halirq.h:26
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
BOOLEAN NTAPI HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PHYSICAL_ADDRESS BusAddress, IN OUT PULONG AddressSpace, OUT PPHYSICAL_ADDRESS TranslatedAddress)
Definition: busemul.c:77
_In_z_ PWSTR RegistryPath
Definition: classp.h:1930
NTSTATUS NTAPI HalAdjustResourceList(IN OUT PIO_RESOURCE_REQUIREMENTS_LIST *pRequirementsList)
Definition: busemul.c:131
ULONG NTAPI HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN ULONG BusInterruptLevel, IN ULONG BusInterruptVector, OUT PKIRQL Irql, OUT PKAFFINITY Affinity)
Definition: busemul.c:249
ULONG BusNumber
Definition: haltypes.h:226
Definition: miniport.h:89
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:170
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG _In_ ULONG SlotNumber
Definition: halfuncs.h:156
unsigned char UCHAR
Definition: xmlstorage.h:181
#define KdMapPhysicalMemory64
Definition: halfuncs.h:52
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
VOID NTAPI HalpUnmapVirtualAddress(IN PVOID VirtualAddress, IN ULONG NumberPages)
Definition: misc.c:39
ULONG HalpMaxPciBus
Definition: pci.c:18
#define KdSetupPciDeviceForDebugging
Definition: halfuncs.h:47
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
ULONG NTAPI HalpGetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER Slot, IN PUCHAR Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pci.c:338
ULONG NTAPI HalpSetPCIData(IN PBUS_HANDLER BusHandler, IN PBUS_HANDLER RootHandler, IN PCI_SLOT_NUMBER Slot, IN PUCHAR Buffer, IN ULONG Offset, IN ULONG Length)
Definition: pci.c:409
NTSTATUS NTAPI HalpReleasePciDeviceForDebugging(IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
Definition: pci.c:482
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1569
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID _In_opt_ PKSPIN_LOCK _In_ ULONG Vector
Definition: iofuncs.h:798
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: pci.c:490
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: busemul.c:142
unsigned int * PULONG
Definition: retypes.h:1
#define KdCheckPowerButton
Definition: halfuncs.h:50
#define OUT
Definition: typedefs.h:40
#define KdReleasePciDeviceforDebugging
Definition: halfuncs.h:48
unsigned int ULONG
Definition: retypes.h:1
#define HalPciAssignSlotResources
Definition: halfuncs.h:42
uint32_t * PULONG_PTR
Definition: typedefs.h:65
BUS_HANDLER HalpFakePciBusHandler
Definition: pci.c:91
#define IRQ2VECTOR(irq)
Definition: halirq.h:27
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG NTAPI HalpSetCmosData(IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
Definition: cmos.c:99
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG NTAPI HalGetBusData(IN BUS_DATA_TYPE BusDataType, IN ULONG BusNumber, IN ULONG SlotNumber, IN PVOID Buffer, IN ULONG Length)
Definition: busemul.c:183
#define PAGED_CODE()