xref: /reactos/sdk/include/ndk/halfuncs.h (revision 32d615fc)
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 CODE_SEG("INIT")
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 CODE_SEG("INIT")
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 #ifdef _M_AMD64
196 
197 NTHALAPI
198 VOID
199 NTAPI
200 HalSendNMI(
201     _In_ KAFFINITY TargetSet);
202 
203 NTHALAPI
204 VOID
205 NTAPI
206 HalSendSoftwareInterrupt(
207     _In_ KAFFINITY TargetSet,
208     _In_ KIRQL Irql);
209 
210 #endif // _M_AMD64
211 
212 NTHALAPI
213 VOID
214 NTAPI
215 HalRequestIpi(
216     _In_ KAFFINITY TargetSet
217 );
218 
219 NTHALAPI
220 VOID
221 NTAPI
222 HalHandleNMI(
223     PVOID NmiInfo
224 );
225 
226 NTHALAPI
227 UCHAR
228 FASTCALL
229 HalSystemVectorDispatchEntry(
230     _In_ ULONG Vector,
231     _Out_ PKINTERRUPT_ROUTINE **FlatDispatch,
232     _Out_ PKINTERRUPT_ROUTINE *NoConnection
233 );
234 
235 //
236 // Bus Functions
237 //
238 NTHALAPI
239 NTSTATUS
240 NTAPI
241 HalAdjustResourceList(
242     _Inout_ PIO_RESOURCE_REQUIREMENTS_LIST *pResourceList
243 );
244 
245 //
246 // Environment Functions
247 //
248 #ifdef _ARC_
249 NTHALAPI
250 ARC_STATUS
251 NTAPI
252 HalSetEnvironmentVariable(
253     _In_ PCH Name,
254     _In_ PCH Value
255 );
256 
257 NTHALAPI
258 ARC_STATUS
259 NTAPI
260 HalGetEnvironmentVariable(
261     _In_ PCH Variable,
262     _In_ USHORT Length,
263     _Out_ PCH Buffer
264 );
265 #endif
266 
267 //
268 // Profiling Functions
269 //
270 VOID
271 NTAPI
272 HalStartProfileInterrupt(
273     _In_ KPROFILE_SOURCE ProfileSource
274 );
275 
276 NTHALAPI
277 VOID
278 NTAPI
279 HalStopProfileInterrupt(
280     _In_ KPROFILE_SOURCE ProfileSource
281 );
282 
283 NTHALAPI
284 ULONG_PTR
285 NTAPI
286 HalSetProfileInterval(
287     _In_ ULONG_PTR Interval
288 );
289 
290 //
291 // Time Functions
292 //
293 NTHALAPI
294 BOOLEAN
295 NTAPI
296 HalQueryRealTimeClock(
297     _In_ PTIME_FIELDS RtcTime
298 );
299 
300 NTHALAPI
301 BOOLEAN
302 NTAPI
303 HalSetRealTimeClock(
304     _In_ PTIME_FIELDS RtcTime
305 );
306 
307 NTHALAPI
308 ULONG
309 NTAPI
310 HalSetTimeIncrement(
311     _In_ ULONG Increment
312 );
313 
314 
315 //
316 // BIOS call API
317 //
318 NTSTATUS
319 NTAPI
320 x86BiosAllocateBuffer(
321     _In_ ULONG *Size,
322     _In_ USHORT *Segment,
323     _In_ USHORT *Offset);
324 
325 NTSTATUS
326 NTAPI
327 x86BiosFreeBuffer(
328     _In_ USHORT Segment,
329     _In_ USHORT Offset);
330 
331 NTSTATUS
332 NTAPI
333 x86BiosReadMemory(
334     _In_ USHORT Segment,
335     _In_ USHORT Offset,
336     _Out_writes_bytes_(Size) PVOID Buffer,
337     _In_ ULONG Size);
338 
339 NTSTATUS
340 NTAPI
341 x86BiosWriteMemory(
342     _In_ USHORT Segment,
343     _In_ USHORT Offset,
344     _In_reads_bytes_(Size) PVOID Buffer,
345     _In_ ULONG Size);
346 
347 BOOLEAN
348 NTAPI
349 x86BiosCall(
350     _In_ ULONG InterruptNumber,
351     _Inout_ PX86_BIOS_REGISTERS Registers);
352 
353 #endif // NTOS_MODE_USER
354 #endif // _HALFUNCS_H
355