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
9 /* INCLUDES *******************************************************************/
15 /* GLOBALS ********************************************************************/
17 /* PRIVATE FUNCTIONS **********************************************************/
22 HalpRegisterKdSupportFunctions(VOID
)
24 /* Register PCI Device Functions */
25 KdSetupPciDeviceForDebugging
= HalpSetupPciDeviceForDebugging
;
26 KdReleasePciDeviceforDebugging
= HalpReleasePciDeviceForDebugging
;
28 /* Register memory functions */
30 #if (NTDDI_VERSION >= NTDDI_VISTA)
31 KdMapPhysicalMemory64
= HalpMapPhysicalMemory64Vista
;
32 KdUnmapVirtualAddress
= HalpUnmapVirtualAddressVista
;
34 KdMapPhysicalMemory64
= HalpMapPhysicalMemory64
;
35 KdUnmapVirtualAddress
= HalpUnmapVirtualAddress
;
39 /* Register ACPI stub */
40 KdCheckPowerButton
= HalpCheckPowerButton
;
45 HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath
,
46 IN PUNICODE_STRING DriverClassName
,
47 IN PDRIVER_OBJECT DriverObject
,
48 IN PDEVICE_OBJECT DeviceObject
,
49 IN INTERFACE_TYPE BusType
,
52 IN OUT PCM_RESOURCE_LIST
*AllocatedResources
)
54 BUS_HANDLER BusHandler
;
57 /* Only PCI is supported */
58 if (BusType
!= PCIBus
) return STATUS_NOT_IMPLEMENTED
;
60 /* Setup fake PCI Bus handler */
61 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
62 BusHandler
.BusNumber
= BusNumber
;
64 /* Call the PCI function */
65 return HalpAssignPCISlotResources(&BusHandler
,
77 HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType
,
79 IN PHYSICAL_ADDRESS BusAddress
,
80 IN OUT PULONG AddressSpace
,
81 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
83 /* Translation is easy */
84 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;
90 HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber
,
91 IN ULONG BusInterruptLevel
,
92 IN ULONG BusInterruptVector
,
94 OUT PKAFFINITY Affinity
)
96 UCHAR Vector
= IRQ2VECTOR((UCHAR
)BusInterruptLevel
);
97 *Irql
= VECTOR2IRQL(Vector
);
98 *Affinity
= 0xFFFFFFFF;
104 HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress
,
105 IN OUT PULONG AddressSpace
,
106 OUT PPHYSICAL_ADDRESS TranslatedAddress
,
107 IN OUT PULONG_PTR Context
,
110 /* Make sure we have a context */
111 if (!Context
) return FALSE
;
113 /* If we have data in the context, then this shouldn't be a new lookup */
114 if ((*Context
!= 0) && (NextBus
!= FALSE
)) return FALSE
;
116 /* Return bus data */
117 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;
119 /* Set context value and return success */
124 /* PUBLIC FUNCTIONS **********************************************************/
131 HalAdjustResourceList(IN OUT PIO_RESOURCE_REQUIREMENTS_LIST
* pRequirementsList
)
133 /* Deprecated, return success */
134 return STATUS_SUCCESS
;
142 HalAssignSlotResources(IN PUNICODE_STRING RegistryPath
,
143 IN PUNICODE_STRING DriverClassName
,
144 IN PDRIVER_OBJECT DriverObject
,
145 IN PDEVICE_OBJECT DeviceObject
,
146 IN INTERFACE_TYPE BusType
,
149 IN OUT PCM_RESOURCE_LIST
*AllocatedResources
)
151 /* Check the bus type */
152 if (BusType
!= PCIBus
)
154 /* Call our internal handler */
155 return HalpAssignSlotResources(RegistryPath
,
166 /* Call the PCI registered function */
167 return HalPciAssignSlotResources(RegistryPath
,
183 HalGetBusData(IN BUS_DATA_TYPE BusDataType
,
189 /* Call the extended function */
190 return HalGetBusDataByOffset(BusDataType
,
203 HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType
,
210 BUS_HANDLER BusHandler
;
212 /* Look as the bus type */
213 if (BusDataType
== Cmos
)
215 /* Call CMOS Function */
216 return HalpGetCmosData(0, SlotNumber
, Buffer
, Length
);
218 else if (BusDataType
== EisaConfiguration
)
223 else if ((BusDataType
== PCIConfiguration
) &&
224 (HalpPCIConfigInitialized
) &&
225 ((BusNumber
>= HalpMinPciBus
) && (BusNumber
<= HalpMaxPciBus
)))
227 /* Setup fake PCI Bus handler */
228 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
229 BusHandler
.BusNumber
= BusNumber
;
231 /* Call PCI function */
232 return HalpGetPCIData(&BusHandler
,
249 HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType
,
251 IN ULONG BusInterruptLevel
,
252 IN ULONG BusInterruptVector
,
254 OUT PKAFFINITY Affinity
)
256 /* Call the system bus translator */
257 return HalpGetSystemInterruptVector_Acpi(BusNumber
,
269 HalSetBusData(IN BUS_DATA_TYPE BusDataType
,
275 /* Call the extended function */
276 return HalSetBusDataByOffset(BusDataType
,
289 HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType
,
296 BUS_HANDLER BusHandler
;
298 /* Look as the bus type */
299 if (BusDataType
== Cmos
)
301 /* Call CMOS Function */
302 return HalpSetCmosData(0, SlotNumber
, Buffer
, Length
);
304 else if ((BusDataType
== PCIConfiguration
) && (HalpPCIConfigInitialized
))
306 /* Setup fake PCI Bus handler */
307 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
308 BusHandler
.BusNumber
= BusNumber
;
310 /* Call PCI function */
311 return HalpSetPCIData(&BusHandler
,
328 HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType
,
330 IN PHYSICAL_ADDRESS BusAddress
,
331 IN OUT PULONG AddressSpace
,
332 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
334 /* Look as the bus type */
335 if (InterfaceType
== PCIBus
)
337 /* Call the PCI registered function */
338 return HalPciTranslateBusAddress(PCIBus
,
346 /* Translation is easy */
347 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;