1 /*++ NDK Version: 0098 2 3 Copyright (c) Alex Ionescu. All rights reserved. 4 5 Header Name: 6 7 halfuncs.h 8 9 Abstract: 10 11 Function definitions for the HAL. 12 13 Author: 14 15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006 16 17 --*/ 18 19 #ifndef _HALFUNCS_H 20 #define _HALFUNCS_H 21 22 // 23 // Dependencies 24 // 25 #include <umtypes.h> 26 #include <haltypes.h> 27 #include <ketypes.h> 28 #include <section_attribs.h> 29 30 #ifndef NTOS_MODE_USER 31 32 // 33 // Private HAL Callbacks 34 // 35 #define HalHandlerForBus HALPRIVATEDISPATCH->HalHandlerForBus 36 #define HalHandlerForConfigSpace HALPRIVATEDISPATCH->HalHandlerForConfigSpace 37 #define HalLocateHiberRanges HALPRIVATEDISPATCH->HalLocateHiberRanges 38 #define HalRegisterBusHandler HALPRIVATEDISPATCH->HalRegisterBusHandler 39 #define HalSetWakeEnable HALPRIVATEDISPATCH->HalSetWakeEnable 40 #define HalSetWakeAlarm HALPRIVATEDISPATCH->HalSetWakeAlarm 41 #define HalPciTranslateBusAddress HALPRIVATEDISPATCH->HalPciTranslateBusAddress 42 #define HalPciAssignSlotResources HALPRIVATEDISPATCH->HalPciAssignSlotResources 43 #define HalHaltSystem HALPRIVATEDISPATCH->HalHaltSystem 44 #define HalFindBusAddressTranslation HALPRIVATEDISPATCH->HalFindBusAddressTranslation 45 #define HalResetDisplay HALPRIVATEDISPATCH->HalResetDisplay 46 #define HalAllocateMapRegisters HALPRIVATEDISPATCH->HalAllocateMapRegisters 47 #define KdSetupPciDeviceForDebugging HALPRIVATEDISPATCH->KdSetupPciDeviceForDebugging 48 #define KdReleasePciDeviceforDebugging HALPRIVATEDISPATCH->KdReleasePciDeviceforDebugging 49 #define KdGetAcpiTablePhase0 HALPRIVATEDISPATCH->KdGetAcpiTablePhase0 50 #define KdCheckPowerButton HALPRIVATEDISPATCH->KdCheckPowerButton 51 #define HalVectorToIDTEntry HALPRIVATEDISPATCH->HalVectorToIDTEntry 52 #define KdMapPhysicalMemory64 HALPRIVATEDISPATCH->KdMapPhysicalMemory64 53 #define KdUnmapVirtualAddress HALPRIVATEDISPATCH->KdUnmapVirtualAddress 54 55 // 56 // Display Functions 57 // 58 NTHALAPI 59 VOID 60 NTAPI 61 HalDisplayString( 62 _In_ PCHAR String 63 ); 64 65 // 66 // Initialization Functions 67 // 68 NTHALAPI 69 BOOLEAN 70 NTAPI 71 HalAllProcessorsStarted( 72 VOID 73 ); 74 75 #ifdef _ARC_ 76 NTHALAPI 77 VOID 78 NTAPI 79 HalInitializeProcessor( 80 _In_ ULONG ProcessorNumber, 81 _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock 82 ); 83 84 INIT_FUNCTION 85 NTHALAPI 86 BOOLEAN 87 NTAPI 88 HalInitSystem( 89 _In_ ULONG BootPhase, 90 _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock 91 ); 92 93 NTHALAPI 94 BOOLEAN 95 NTAPI 96 HalStartNextProcessor( 97 _In_ struct _LOADER_PARAMETER_BLOCK *LoaderBlock, 98 _In_ PKPROCESSOR_STATE ProcessorState 99 ); 100 101 #endif 102 103 NTHALAPI 104 VOID 105 NTAPI 106 HalReturnToFirmware( 107 _In_ FIRMWARE_REENTRY Action 108 ); 109 110 // 111 // CPU Routines 112 // 113 NTHALAPI 114 VOID 115 NTAPI 116 HalProcessorIdle( 117 VOID 118 ); 119 120 // 121 // Interrupt Functions 122 // 123 NTHALAPI 124 BOOLEAN 125 NTAPI 126 HalBeginSystemInterrupt( 127 _In_ KIRQL Irql, 128 _In_ ULONG Vector, 129 _Out_ PKIRQL OldIrql 130 ); 131 132 VOID 133 FASTCALL 134 HalClearSoftwareInterrupt( 135 _In_ KIRQL Request 136 ); 137 138 NTHALAPI 139 VOID 140 NTAPI 141 HalDisableSystemInterrupt( 142 _In_ ULONG Vector, 143 _In_ KIRQL Irql 144 ); 145 146 NTHALAPI 147 BOOLEAN 148 NTAPI 149 HalEnableSystemInterrupt( 150 _In_ ULONG Vector, 151 _In_ KIRQL Irql, 152 _In_ KINTERRUPT_MODE InterruptMode 153 ); 154 155 #ifdef __REACTOS__ 156 NTHALAPI 157 VOID 158 NTAPI 159 HalEndSystemInterrupt( 160 _In_ KIRQL Irql, 161 _In_ PKTRAP_FRAME TrapFrame 162 ); 163 #else 164 NTHALAPI 165 VOID 166 NTAPI 167 HalEndSystemInterrupt( 168 _In_ KIRQL Irql, 169 _In_ UCHAR Vector 170 ); 171 #endif 172 173 #ifdef _ARM_ // FIXME: ndk/arm? armddk.h? 174 ULONG 175 HalGetInterruptSource( 176 VOID 177 ); 178 #endif 179 180 INIT_FUNCTION 181 NTHALAPI 182 VOID 183 NTAPI 184 HalReportResourceUsage( 185 VOID 186 ); 187 188 NTHALAPI 189 VOID 190 FASTCALL 191 HalRequestSoftwareInterrupt( 192 _In_ KIRQL SoftwareInterruptRequested 193 ); 194 195 NTHALAPI 196 VOID 197 NTAPI 198 HalRequestIpi( 199 _In_ KAFFINITY TargetSet 200 ); 201 202 NTHALAPI 203 VOID 204 NTAPI 205 HalHandleNMI( 206 PVOID NmiInfo 207 ); 208 209 NTHALAPI 210 UCHAR 211 FASTCALL 212 HalSystemVectorDispatchEntry( 213 _In_ ULONG Vector, 214 _Out_ PKINTERRUPT_ROUTINE **FlatDispatch, 215 _Out_ PKINTERRUPT_ROUTINE *NoConnection 216 ); 217 218 // 219 // Bus Functions 220 // 221 NTHALAPI 222 NTSTATUS 223 NTAPI 224 HalAdjustResourceList( 225 _Inout_ PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList 226 ); 227 228 // 229 // Environment Functions 230 // 231 #ifdef _ARC_ 232 NTHALAPI 233 ARC_STATUS 234 NTAPI 235 HalSetEnvironmentVariable( 236 _In_ PCH Name, 237 _In_ PCH Value 238 ); 239 240 NTHALAPI 241 ARC_STATUS 242 NTAPI 243 HalGetEnvironmentVariable( 244 _In_ PCH Variable, 245 _In_ USHORT Length, 246 _Out_ PCH Buffer 247 ); 248 #endif 249 250 // 251 // Profiling Functions 252 // 253 VOID 254 NTAPI 255 HalStartProfileInterrupt( 256 _In_ KPROFILE_SOURCE ProfileSource 257 ); 258 259 NTHALAPI 260 VOID 261 NTAPI 262 HalStopProfileInterrupt( 263 _In_ KPROFILE_SOURCE ProfileSource 264 ); 265 266 NTHALAPI 267 ULONG_PTR 268 NTAPI 269 HalSetProfileInterval( 270 _In_ ULONG_PTR Interval 271 ); 272 273 // 274 // Time Functions 275 // 276 NTHALAPI 277 BOOLEAN 278 NTAPI 279 HalQueryRealTimeClock( 280 _In_ PTIME_FIELDS RtcTime 281 ); 282 283 NTHALAPI 284 BOOLEAN 285 NTAPI 286 HalSetRealTimeClock( 287 _In_ PTIME_FIELDS RtcTime 288 ); 289 290 NTHALAPI 291 ULONG 292 NTAPI 293 HalSetTimeIncrement( 294 _In_ ULONG Increment 295 ); 296 297 298 // 299 // BIOS call API 300 // 301 #ifdef _M_AMD64 302 303 NTSTATUS 304 NTAPI 305 x86BiosAllocateBuffer( 306 _In_ ULONG *Size, 307 _In_ USHORT *Segment, 308 _In_ USHORT *Offset); 309 310 NTSTATUS 311 NTAPI 312 x86BiosFreeBuffer( 313 _In_ USHORT Segment, 314 _In_ USHORT Offset); 315 316 NTSTATUS 317 NTAPI 318 x86BiosReadMemory( 319 _In_ USHORT Segment, 320 _In_ USHORT Offset, 321 _Out_writes_bytes_(Size) PVOID Buffer, 322 _In_ ULONG Size); 323 324 NTSTATUS 325 NTAPI 326 x86BiosWriteMemory( 327 _In_ USHORT Segment, 328 _In_ USHORT Offset, 329 _In_reads_bytes_(Size) PVOID Buffer, 330 _In_ ULONG Size); 331 332 BOOLEAN 333 NTAPI 334 x86BiosCall( 335 _In_ ULONG InterruptNumber, 336 _Inout_ PX86_BIOS_REGISTERS Registers); 337 338 #endif // _M_AMD64 339 340 #endif // NTOS_MODE_USER 341 #endif // _HALFUNCS_H 342