Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenbusemul.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS HAL 00003 * LICENSE: BSD - See COPYING.ARM in the top level directory 00004 * FILE: hal/halx86/generic/acpi/busemul.c 00005 * PURPOSE: ACPI HAL Bus Handler Emulation Code 00006 * PROGRAMMERS: ReactOS Portable Systems Group 00007 */ 00008 00009 /* INCLUDES *******************************************************************/ 00010 00011 #include <hal.h> 00012 #define NDEBUG 00013 #include <debug.h> 00014 00015 /* GLOBALS ********************************************************************/ 00016 00017 /* PRIVATE FUNCTIONS **********************************************************/ 00018 00019 VOID 00020 NTAPI 00021 HalpRegisterKdSupportFunctions(VOID) 00022 { 00023 /* Register PCI Device Functions */ 00024 KdSetupPciDeviceForDebugging = HalpSetupPciDeviceForDebugging; 00025 KdReleasePciDeviceforDebugging = HalpReleasePciDeviceForDebugging; 00026 00027 /* Register memory functions */ 00028 #ifndef _MINIHAL_ 00029 KdMapPhysicalMemory64 = HalpMapPhysicalMemory64; 00030 KdUnmapVirtualAddress = HalpUnmapVirtualAddress; 00031 #endif 00032 00033 /* Register ACPI stub */ 00034 KdCheckPowerButton = HalpCheckPowerButton; 00035 } 00036 00037 NTSTATUS 00038 NTAPI 00039 HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, 00040 IN PUNICODE_STRING DriverClassName, 00041 IN PDRIVER_OBJECT DriverObject, 00042 IN PDEVICE_OBJECT DeviceObject, 00043 IN INTERFACE_TYPE BusType, 00044 IN ULONG BusNumber, 00045 IN ULONG SlotNumber, 00046 IN OUT PCM_RESOURCE_LIST *AllocatedResources) 00047 { 00048 BUS_HANDLER BusHandler; 00049 PAGED_CODE(); 00050 00051 /* Only PCI is supported */ 00052 if (BusType != PCIBus) return STATUS_NOT_IMPLEMENTED; 00053 00054 /* Setup fake PCI Bus handler */ 00055 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER)); 00056 BusHandler.BusNumber = BusNumber; 00057 00058 /* Call the PCI function */ 00059 return HalpAssignPCISlotResources(&BusHandler, 00060 &BusHandler, 00061 RegistryPath, 00062 DriverClassName, 00063 DriverObject, 00064 DeviceObject, 00065 SlotNumber, 00066 AllocatedResources); 00067 } 00068 00069 BOOLEAN 00070 NTAPI 00071 HalpTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, 00072 IN ULONG BusNumber, 00073 IN PHYSICAL_ADDRESS BusAddress, 00074 IN OUT PULONG AddressSpace, 00075 OUT PPHYSICAL_ADDRESS TranslatedAddress) 00076 { 00077 /* Translation is easy */ 00078 TranslatedAddress->QuadPart = BusAddress.QuadPart; 00079 return TRUE; 00080 } 00081 00082 ULONG 00083 NTAPI 00084 HalpGetSystemInterruptVector_Acpi(IN ULONG BusNumber, 00085 IN ULONG BusInterruptLevel, 00086 IN ULONG BusInterruptVector, 00087 OUT PKIRQL Irql, 00088 OUT PKAFFINITY Affinity) 00089 { 00090 UCHAR Vector = IRQ2VECTOR((UCHAR)BusInterruptLevel); 00091 *Irql = VECTOR2IRQL(Vector); 00092 *Affinity = 0xFFFFFFFF; 00093 return Vector; 00094 } 00095 00096 BOOLEAN 00097 NTAPI 00098 HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, 00099 IN OUT PULONG AddressSpace, 00100 OUT PPHYSICAL_ADDRESS TranslatedAddress, 00101 IN OUT PULONG_PTR Context, 00102 IN BOOLEAN NextBus) 00103 { 00104 /* Make sure we have a context */ 00105 if (!Context) return FALSE; 00106 00107 /* If we have data in the context, then this shouldn't be a new lookup */ 00108 if ((*Context) && (NextBus == TRUE)) return FALSE; 00109 00110 /* Return bus data */ 00111 TranslatedAddress->QuadPart = BusAddress.QuadPart; 00112 00113 /* Set context value and return success */ 00114 *Context = 1; 00115 return TRUE; 00116 } 00117 00118 /* PUBLIC FUNCTIONS **********************************************************/ 00119 00120 /* 00121 * @implemented 00122 */ 00123 NTSTATUS 00124 NTAPI 00125 HalAdjustResourceList(IN OUT PIO_RESOURCE_REQUIREMENTS_LIST* pRequirementsList) 00126 { 00127 /* Deprecated, return success */ 00128 return STATUS_SUCCESS; 00129 } 00130 00131 /* 00132 * @implemented 00133 */ 00134 NTSTATUS 00135 NTAPI 00136 HalAssignSlotResources(IN PUNICODE_STRING RegistryPath, 00137 IN PUNICODE_STRING DriverClassName, 00138 IN PDRIVER_OBJECT DriverObject, 00139 IN PDEVICE_OBJECT DeviceObject, 00140 IN INTERFACE_TYPE BusType, 00141 IN ULONG BusNumber, 00142 IN ULONG SlotNumber, 00143 IN OUT PCM_RESOURCE_LIST *AllocatedResources) 00144 { 00145 /* Check the bus type */ 00146 if (BusType != PCIBus) 00147 { 00148 /* Call our internal handler */ 00149 return HalpAssignSlotResources(RegistryPath, 00150 DriverClassName, 00151 DriverObject, 00152 DeviceObject, 00153 BusType, 00154 BusNumber, 00155 SlotNumber, 00156 AllocatedResources); 00157 } 00158 else 00159 { 00160 /* Call the PCI registered function */ 00161 return HalPciAssignSlotResources(RegistryPath, 00162 DriverClassName, 00163 DriverObject, 00164 DeviceObject, 00165 PCIBus, 00166 BusNumber, 00167 SlotNumber, 00168 AllocatedResources); 00169 } 00170 } 00171 00172 /* 00173 * @implemented 00174 */ 00175 ULONG 00176 NTAPI 00177 HalGetBusData(IN BUS_DATA_TYPE BusDataType, 00178 IN ULONG BusNumber, 00179 IN ULONG SlotNumber, 00180 IN PVOID Buffer, 00181 IN ULONG Length) 00182 { 00183 /* Call the extended function */ 00184 return HalGetBusDataByOffset(BusDataType, 00185 BusNumber, 00186 SlotNumber, 00187 Buffer, 00188 0, 00189 Length); 00190 } 00191 00192 /* 00193 * @implemented 00194 */ 00195 ULONG 00196 NTAPI 00197 HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, 00198 IN ULONG BusNumber, 00199 IN ULONG SlotNumber, 00200 IN PVOID Buffer, 00201 IN ULONG Offset, 00202 IN ULONG Length) 00203 { 00204 BUS_HANDLER BusHandler; 00205 00206 /* Look as the bus type */ 00207 if (BusDataType == Cmos) 00208 { 00209 /* Call CMOS Function */ 00210 return HalpGetCmosData(0, SlotNumber, Buffer, Length); 00211 } 00212 else if (BusDataType == EisaConfiguration) 00213 { 00214 /* FIXME: TODO */ 00215 ASSERT(FALSE); 00216 } 00217 else if ((BusDataType == PCIConfiguration) && 00218 (HalpPCIConfigInitialized) && 00219 ((BusNumber >= HalpMinPciBus) && (BusNumber <= HalpMaxPciBus))) 00220 { 00221 /* Setup fake PCI Bus handler */ 00222 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER)); 00223 BusHandler.BusNumber = BusNumber; 00224 00225 /* Call PCI function */ 00226 return HalpGetPCIData(&BusHandler, 00227 &BusHandler, 00228 *(PPCI_SLOT_NUMBER)&SlotNumber, 00229 Buffer, 00230 Offset, 00231 Length); 00232 } 00233 00234 /* Invalid bus */ 00235 return 0; 00236 } 00237 00238 /* 00239 * @implemented 00240 */ 00241 ULONG 00242 NTAPI 00243 HalGetInterruptVector(IN INTERFACE_TYPE InterfaceType, 00244 IN ULONG BusNumber, 00245 IN ULONG BusInterruptLevel, 00246 IN ULONG BusInterruptVector, 00247 OUT PKIRQL Irql, 00248 OUT PKAFFINITY Affinity) 00249 { 00250 /* Call the system bus translator */ 00251 return HalpGetSystemInterruptVector_Acpi(BusNumber, 00252 BusInterruptLevel, 00253 BusInterruptVector, 00254 Irql, 00255 Affinity); 00256 } 00257 00258 /* 00259 * @implemented 00260 */ 00261 ULONG 00262 NTAPI 00263 HalSetBusData(IN BUS_DATA_TYPE BusDataType, 00264 IN ULONG BusNumber, 00265 IN ULONG SlotNumber, 00266 IN PVOID Buffer, 00267 IN ULONG Length) 00268 { 00269 /* Call the extended function */ 00270 return HalSetBusDataByOffset(BusDataType, 00271 BusNumber, 00272 SlotNumber, 00273 Buffer, 00274 0, 00275 Length); 00276 } 00277 00278 /* 00279 * @implemented 00280 */ 00281 ULONG 00282 NTAPI 00283 HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, 00284 IN ULONG BusNumber, 00285 IN ULONG SlotNumber, 00286 IN PVOID Buffer, 00287 IN ULONG Offset, 00288 IN ULONG Length) 00289 { 00290 BUS_HANDLER BusHandler; 00291 00292 /* Look as the bus type */ 00293 if (BusDataType == Cmos) 00294 { 00295 /* Call CMOS Function */ 00296 return HalpSetCmosData(0, SlotNumber, Buffer, Length); 00297 } 00298 else if ((BusDataType == PCIConfiguration) && (HalpPCIConfigInitialized)) 00299 { 00300 /* Setup fake PCI Bus handler */ 00301 RtlCopyMemory(&BusHandler, &HalpFakePciBusHandler, sizeof(BUS_HANDLER)); 00302 BusHandler.BusNumber = BusNumber; 00303 00304 /* Call PCI function */ 00305 return HalpSetPCIData(&BusHandler, 00306 &BusHandler, 00307 *(PPCI_SLOT_NUMBER)&SlotNumber, 00308 Buffer, 00309 Offset, 00310 Length); 00311 } 00312 00313 /* Invalid bus */ 00314 return 0; 00315 } 00316 00317 /* 00318 * @implemented 00319 */ 00320 BOOLEAN 00321 NTAPI 00322 HalTranslateBusAddress(IN INTERFACE_TYPE InterfaceType, 00323 IN ULONG BusNumber, 00324 IN PHYSICAL_ADDRESS BusAddress, 00325 IN OUT PULONG AddressSpace, 00326 OUT PPHYSICAL_ADDRESS TranslatedAddress) 00327 { 00328 /* Look as the bus type */ 00329 if (InterfaceType == PCIBus) 00330 { 00331 /* Call the PCI registered function */ 00332 return HalPciTranslateBusAddress(PCIBus, 00333 BusNumber, 00334 BusAddress, 00335 AddressSpace, 00336 TranslatedAddress); 00337 } 00338 else 00339 { 00340 /* Translation is easy */ 00341 TranslatedAddress->QuadPart = BusAddress.QuadPart; 00342 return TRUE; 00343 } 00344 } 00345 00346 /* EOF */ Generated on Sat May 26 2012 04:27:22 for ReactOS by
1.7.6.1
|