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 **********************************************************/
21 HalpRegisterKdSupportFunctions(VOID
)
23 /* Register PCI Device Functions */
24 KdSetupPciDeviceForDebugging
= HalpSetupPciDeviceForDebugging
;
25 KdReleasePciDeviceforDebugging
= HalpReleasePciDeviceForDebugging
;
27 /* Register memory functions */
29 #if (NTDDI_VERSION >= NTDDI_VISTA)
30 KdMapPhysicalMemory64
= HalpMapPhysicalMemory64Vista
;
31 KdUnmapVirtualAddress
= HalpUnmapVirtualAddressVista
;
33 KdMapPhysicalMemory64
= HalpMapPhysicalMemory64
;
34 KdUnmapVirtualAddress
= HalpUnmapVirtualAddress
;
38 /* Register ACPI stub */
39 KdCheckPowerButton
= HalpCheckPowerButton
;
44 HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath
,
45 IN PUNICODE_STRING DriverClassName
,
46 IN PDRIVER_OBJECT DriverObject
,
47 IN PDEVICE_OBJECT DeviceObject
,
48 IN INTERFACE_TYPE BusType
,
51 IN OUT PCM_RESOURCE_LIST
*AllocatedResources
)
53 BUS_HANDLER BusHandler
;
56 /* Only PCI is supported */
57 if (BusType
!= PCIBus
) return STATUS_NOT_IMPLEMENTED
;
59 /* Setup fake PCI Bus handler */
60 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
61 BusHandler
.BusNumber
= BusNumber
;
63 /* Call the PCI function */
64 return HalpAssignPCISlotResources(&BusHandler
,
76 HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType
,
78 IN PHYSICAL_ADDRESS BusAddress
,
79 IN OUT PULONG AddressSpace
,
80 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
82 /* Translation is easy */
83 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;
89 HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber
,
90 IN ULONG BusInterruptLevel
,
91 IN ULONG BusInterruptVector
,
93 OUT PKAFFINITY Affinity
)
95 UCHAR Vector
= IRQ2VECTOR((UCHAR
)BusInterruptLevel
);
96 *Irql
= VECTOR2IRQL(Vector
);
97 *Affinity
= 0xFFFFFFFF;
103 HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress
,
104 IN OUT PULONG AddressSpace
,
105 OUT PPHYSICAL_ADDRESS TranslatedAddress
,
106 IN OUT PULONG_PTR Context
,
109 /* Make sure we have a context */
110 if (!Context
) return FALSE
;
112 /* If we have data in the context, then this shouldn't be a new lookup */
113 if ((*Context
!= 0) && (NextBus
!= FALSE
)) return FALSE
;
115 /* Return bus data */
116 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;
118 /* Set context value and return success */
123 /* PUBLIC FUNCTIONS **********************************************************/
130 HalAdjustResourceList(IN OUT PIO_RESOURCE_REQUIREMENTS_LIST
* pRequirementsList
)
132 /* Deprecated, return success */
133 return STATUS_SUCCESS
;
141 HalAssignSlotResources(IN PUNICODE_STRING RegistryPath
,
142 IN PUNICODE_STRING DriverClassName
,
143 IN PDRIVER_OBJECT DriverObject
,
144 IN PDEVICE_OBJECT DeviceObject
,
145 IN INTERFACE_TYPE BusType
,
148 IN OUT PCM_RESOURCE_LIST
*AllocatedResources
)
150 /* Check the bus type */
151 if (BusType
!= PCIBus
)
153 /* Call our internal handler */
154 return HalpAssignSlotResources(RegistryPath
,
165 /* Call the PCI registered function */
166 return HalPciAssignSlotResources(RegistryPath
,
182 HalGetBusData(IN BUS_DATA_TYPE BusDataType
,
188 /* Call the extended function */
189 return HalGetBusDataByOffset(BusDataType
,
202 HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType
,
209 BUS_HANDLER BusHandler
;
211 /* Look as the bus type */
212 if (BusDataType
== Cmos
)
214 /* Call CMOS Function */
215 return HalpGetCmosData(0, SlotNumber
, Buffer
, Length
);
217 else if (BusDataType
== EisaConfiguration
)
222 else if ((BusDataType
== PCIConfiguration
) &&
223 (HalpPCIConfigInitialized
) &&
224 ((BusNumber
>= HalpMinPciBus
) && (BusNumber
<= HalpMaxPciBus
)))
226 /* Setup fake PCI Bus handler */
227 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
228 BusHandler
.BusNumber
= BusNumber
;
230 /* Call PCI function */
231 return HalpGetPCIData(&BusHandler
,
248 HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType
,
250 IN ULONG BusInterruptLevel
,
251 IN ULONG BusInterruptVector
,
253 OUT PKAFFINITY Affinity
)
255 /* Call the system bus translator */
256 return HalpGetSystemInterruptVector_Acpi(BusNumber
,
268 HalSetBusData(IN BUS_DATA_TYPE BusDataType
,
274 /* Call the extended function */
275 return HalSetBusDataByOffset(BusDataType
,
288 HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType
,
295 BUS_HANDLER BusHandler
;
297 /* Look as the bus type */
298 if (BusDataType
== Cmos
)
300 /* Call CMOS Function */
301 return HalpSetCmosData(0, SlotNumber
, Buffer
, Length
);
303 else if ((BusDataType
== PCIConfiguration
) && (HalpPCIConfigInitialized
))
305 /* Setup fake PCI Bus handler */
306 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
307 BusHandler
.BusNumber
= BusNumber
;
309 /* Call PCI function */
310 return HalpSetPCIData(&BusHandler
,
327 HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType
,
329 IN PHYSICAL_ADDRESS BusAddress
,
330 IN OUT PULONG AddressSpace
,
331 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
333 /* Look as the bus type */
334 if (InterfaceType
== PCIBus
)
336 /* Call the PCI registered function */
337 return HalPciTranslateBusAddress(PCIBus
,
345 /* Translation is easy */
346 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;