3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: hal/halx86/generic/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 KdMapPhysicalMemory64
= HalpMapPhysicalMemory64
;
30 KdUnmapVirtualAddress
= HalpUnmapVirtualAddress
;
33 /* Register ACPI stub */
34 KdCheckPowerButton
= HalpCheckPowerButton
;
39 HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath
,
40 IN PUNICODE_STRING DriverClassName
,
41 IN PDRIVER_OBJECT DriverObject
,
42 IN PDEVICE_OBJECT DeviceObject
,
43 IN INTERFACE_TYPE BusType
,
46 IN OUT PCM_RESOURCE_LIST
*AllocatedResources
)
48 BUS_HANDLER BusHandler
;
51 /* Only PCI is supported */
52 if (BusType
!= PCIBus
) return STATUS_NOT_IMPLEMENTED
;
54 /* Setup fake PCI Bus handler */
55 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
56 BusHandler
.BusNumber
= BusNumber
;
58 /* Call the PCI function */
59 return HalpAssignPCISlotResources(&BusHandler
,
71 HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType
,
73 IN PHYSICAL_ADDRESS BusAddress
,
74 IN OUT PULONG AddressSpace
,
75 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
77 /* Translation is easy */
78 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;
84 HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber
,
85 IN ULONG BusInterruptLevel
,
86 IN ULONG BusInterruptVector
,
88 OUT PKAFFINITY Affinity
)
90 UCHAR Vector
= IRQ2VECTOR((UCHAR
)BusInterruptLevel
);
91 *Irql
= VECTOR2IRQL(Vector
);
92 *Affinity
= 0xFFFFFFFF;
98 HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress
,
99 IN OUT PULONG AddressSpace
,
100 OUT PPHYSICAL_ADDRESS TranslatedAddress
,
101 IN OUT PULONG_PTR Context
,
104 /* Make sure we have a context */
105 if (!Context
) return FALSE
;
107 /* If we have data in the context, then this shouldn't be a new lookup */
108 if ((*Context
) && (NextBus
== TRUE
)) return FALSE
;
110 /* Return bus data */
111 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;
113 /* Set context value and return success */
118 /* PUBLIC FUNCTIONS **********************************************************/
125 HalAdjustResourceList(IN OUT PIO_RESOURCE_REQUIREMENTS_LIST
* pRequirementsList
)
127 /* Deprecated, return success */
128 return STATUS_SUCCESS
;
136 HalAssignSlotResources(IN PUNICODE_STRING RegistryPath
,
137 IN PUNICODE_STRING DriverClassName
,
138 IN PDRIVER_OBJECT DriverObject
,
139 IN PDEVICE_OBJECT DeviceObject
,
140 IN INTERFACE_TYPE BusType
,
143 IN OUT PCM_RESOURCE_LIST
*AllocatedResources
)
145 /* Check the bus type */
146 if (BusType
!= PCIBus
)
148 /* Call our internal handler */
149 return HalpAssignSlotResources(RegistryPath
,
160 /* Call the PCI registered function */
161 return HalPciAssignSlotResources(RegistryPath
,
177 HalGetBusData(IN BUS_DATA_TYPE BusDataType
,
183 /* Call the extended function */
184 return HalGetBusDataByOffset(BusDataType
,
197 HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType
,
204 BUS_HANDLER BusHandler
;
206 /* Look as the bus type */
207 if (BusDataType
== Cmos
)
209 /* Call CMOS Function */
210 return HalpGetCmosData(0, SlotNumber
, Buffer
, Length
);
212 else if (BusDataType
== EisaConfiguration
)
217 else if ((BusDataType
== PCIConfiguration
) &&
218 (HalpPCIConfigInitialized
) &&
219 ((BusNumber
>= HalpMinPciBus
) && (BusNumber
<= HalpMaxPciBus
)))
221 /* Setup fake PCI Bus handler */
222 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
223 BusHandler
.BusNumber
= BusNumber
;
225 /* Call PCI function */
226 return HalpGetPCIData(&BusHandler
,
228 *(PPCI_SLOT_NUMBER
)&SlotNumber
,
243 HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType
,
245 IN ULONG BusInterruptLevel
,
246 IN ULONG BusInterruptVector
,
248 OUT PKAFFINITY Affinity
)
250 /* Call the system bus translator */
251 return HalpGetSystemInterruptVector_Acpi(BusNumber
,
263 HalSetBusData(IN BUS_DATA_TYPE BusDataType
,
269 /* Call the extended function */
270 return HalSetBusDataByOffset(BusDataType
,
283 HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType
,
290 BUS_HANDLER BusHandler
;
292 /* Look as the bus type */
293 if (BusDataType
== Cmos
)
295 /* Call CMOS Function */
296 return HalpSetCmosData(0, SlotNumber
, Buffer
, Length
);
298 else if ((BusDataType
== PCIConfiguration
) && (HalpPCIConfigInitialized
))
300 /* Setup fake PCI Bus handler */
301 RtlCopyMemory(&BusHandler
, &HalpFakePciBusHandler
, sizeof(BUS_HANDLER
));
302 BusHandler
.BusNumber
= BusNumber
;
304 /* Call PCI function */
305 return HalpSetPCIData(&BusHandler
,
307 *(PPCI_SLOT_NUMBER
)&SlotNumber
,
322 HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType
,
324 IN PHYSICAL_ADDRESS BusAddress
,
325 IN OUT PULONG AddressSpace
,
326 OUT PPHYSICAL_ADDRESS TranslatedAddress
)
328 /* Look as the bus type */
329 if (InterfaceType
== PCIBus
)
331 /* Call the PCI registered function */
332 return HalPciTranslateBusAddress(PCIBus
,
340 /* Translation is easy */
341 TranslatedAddress
->QuadPart
= BusAddress
.QuadPart
;