[NTOSKRNL]
[reactos.git] / reactos / ntoskrnl / include / internal / hal.h
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/include/hal.h
5 * PURPOSE: Internal header for the I/O HAL Functions (Fstub)
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Pierre Schweitzer (pierre.schweitzer@reactos.org)
8 */
9
10 #pragma once
11
12 //
13 // Default implementations of HAL dispatch table
14 //
15 VOID
16 FASTCALL
17 xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
18 IN ULONG SectorSize,
19 IN ULONG MbrTypeIdentifier,
20 OUT PVOID *MbrBuffer);
21
22 VOID
23 FASTCALL
24 xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
25 IN PSTRING NtDeviceName,
26 OUT PUCHAR NtSystemPath,
27 OUT PSTRING NtSystemPathString);
28
29 NTSTATUS
30 FASTCALL
31 xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
32 IN ULONG SectorSize,
33 IN BOOLEAN ReturnRecognizedPartitions,
34 IN OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
35
36 NTSTATUS
37 FASTCALL
38 xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
39 IN ULONG SectorSize,
40 IN ULONG PartitionNumber,
41 IN ULONG PartitionType);
42
43 NTSTATUS
44 FASTCALL
45 xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
46 IN ULONG SectorSize,
47 IN ULONG SectorsPerTrack,
48 IN ULONG NumberOfHeads,
49 IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer);
50
51 VOID
52 NTAPI
53 xHalHaltSystem(
54 VOID
55 );
56
57 VOID
58 NTAPI
59 xHalEndOfBoot(
60 VOID
61 );
62
63 VOID
64 NTAPI
65 xHalSetWakeEnable(
66 IN BOOLEAN Enable
67 );
68
69 UCHAR
70 NTAPI
71 xHalVectorToIDTEntry(
72 IN ULONG Vector
73 );
74
75 NTSTATUS
76 NTAPI
77 xHalGetInterruptTranslator(
78 IN INTERFACE_TYPE ParentInterfaceType,
79 IN ULONG ParentBusNumber,
80 IN INTERFACE_TYPE BridgeInterfaceType,
81 IN USHORT Size,
82 IN USHORT Version,
83 OUT PTRANSLATOR_INTERFACE Translator,
84 OUT PULONG BridgeBusNumber
85 );
86
87 PBUS_HANDLER
88 FASTCALL
89 xHalHandlerForBus(
90 IN INTERFACE_TYPE InterfaceType,
91 IN ULONG BusNumber
92 );
93
94 VOID
95 FASTCALL
96 xHalReferenceHandler(
97 IN PBUS_HANDLER BusHandler
98 );
99
100 NTSTATUS
101 NTAPI
102 xHalInitPnpDriver(
103 VOID
104 );
105
106 NTSTATUS
107 NTAPI
108 xHalInitPowerManagement(
109 IN PPM_DISPATCH_TABLE PmDriverDispatchTable,
110 OUT PPM_DISPATCH_TABLE *PmHalDispatchTable
111 );
112
113 NTSTATUS
114 NTAPI
115 xHalStartMirroring(
116 VOID
117 );
118
119 NTSTATUS
120 NTAPI
121 xHalEndMirroring(
122 IN ULONG PassNumber
123 );
124
125 NTSTATUS
126 NTAPI
127 xHalMirrorPhysicalMemory(
128 IN PHYSICAL_ADDRESS PhysicalAddress,
129 IN LARGE_INTEGER NumberOfBytes
130 );
131
132 NTSTATUS
133 NTAPI
134 xHalQueryBusSlots(
135 IN PBUS_HANDLER BusHandler,
136 IN ULONG BufferSize,
137 OUT PULONG SlotNumbers,
138 OUT PULONG ReturnedLength
139 );
140
141 NTSTATUS
142 NTAPI
143 xHalSetSystemInformation(
144 IN HAL_SET_INFORMATION_CLASS InformationClass,
145 IN ULONG BufferSize,
146 IN PVOID Buffer
147 );
148
149 NTSTATUS
150 NTAPI
151 xHalQuerySystemInformation(
152 IN HAL_QUERY_INFORMATION_CLASS InformationClass,
153 IN ULONG BufferSize,
154 IN OUT PVOID Buffer,
155 OUT PULONG ReturnedLength
156 );
157
158 VOID
159 NTAPI
160 xHalLocateHiberRanges(
161 IN PVOID MemoryMap
162 );
163
164 NTSTATUS
165 NTAPI
166 xHalRegisterBusHandler(
167 IN INTERFACE_TYPE InterfaceType,
168 IN BUS_DATA_TYPE ConfigSpace,
169 IN ULONG BusNumber,
170 IN INTERFACE_TYPE ParentInterfaceType,
171 IN ULONG ParentBusNumber,
172 IN ULONG ContextSize,
173 IN PINSTALL_BUS_HANDLER InstallCallback,
174 OUT PBUS_HANDLER *BusHandler
175 );
176
177 VOID
178 NTAPI
179 xHalSetWakeAlarm(
180 IN ULONGLONG AlartTime,
181 IN PTIME_FIELDS TimeFields
182 );
183
184 BOOLEAN
185 NTAPI
186 xHalTranslateBusAddress(
187 IN INTERFACE_TYPE InterfaceType,
188 IN ULONG BusNumber,
189 IN PHYSICAL_ADDRESS BusAddress,
190 IN OUT PULONG AddressSpace,
191 OUT PPHYSICAL_ADDRESS TranslatedAddress
192 );
193
194 NTSTATUS
195 NTAPI
196 xHalAllocateMapRegisters(
197 IN PADAPTER_OBJECT AdapterObject,
198 IN ULONG Unknown,
199 IN ULONG Unknown2,
200 PMAP_REGISTER_ENTRY Registers
201 );
202
203 NTSTATUS
204 NTAPI
205 xKdSetupPciDeviceForDebugging(
206 IN PVOID LoaderBlock OPTIONAL,
207 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
208 );
209
210 NTSTATUS
211 NTAPI
212 xKdReleasePciDeviceForDebugging(
213 IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice
214 );
215
216 PVOID
217 NTAPI
218 xKdGetAcpiTablePhase(
219 IN struct _LOADER_PARAMETER_BLOCK *LoaderBlock,
220 IN ULONG Signature
221 );
222
223 PVOID
224 NTAPI
225 MatchAll(
226 IN PHYSICAL_ADDRESS PhysicalAddress,
227 IN ULONG NumberPages,
228 IN BOOLEAN FlushCurrentTLB
229 );
230
231 VOID
232 NTAPI
233 xKdUnmapVirtualAddress(
234 IN PVOID VirtualAddress,
235 IN ULONG NumberPages,
236 IN BOOLEAN FlushCurrentTLB
237 );
238
239
240 //
241 // Various offsets in the boot record
242 //
243 #define PARTITION_TABLE_OFFSET (0x1BE / 2)
244 #define BOOT_SIGNATURE_OFFSET ((0x200 / 2) - 1)
245 #define BOOT_RECORD_RESERVED 0x1BC
246 #define BOOT_RECORD_SIGNATURE 0xAA55
247 #define NUM_PARTITION_TABLE_ENTRIES 4
248
249 //
250 // Helper Macros
251 //
252 #define GET_STARTING_SECTOR(p) \
253 ((ULONG)(p->StartingSectorLsb0) + \
254 (ULONG)(p->StartingSectorLsb1 << 8 ) + \
255 (ULONG)(p->StartingSectorMsb0 << 16) + \
256 (ULONG)(p->StartingSectorMsb1 << 24))
257
258 #define GET_ENDING_S_OF_CHS(p) \
259 ((UCHAR)(p->EndingCylinderLsb & 0x3F))
260
261 #define GET_PARTITION_LENGTH(p) \
262 ((ULONG)(p->PartitionLengthLsb0) + \
263 (ULONG)(p->PartitionLengthLsb1 << 8) + \
264 (ULONG)(p->PartitionLengthMsb0 << 16) + \
265 (ULONG)(p->PartitionLengthMsb1 << 24))
266
267 //
268 // Structure describing a partition
269 //
270 typedef struct _PARTITION_DESCRIPTOR
271 {
272 UCHAR ActiveFlag;
273 UCHAR StartingTrack;
274 UCHAR StartingCylinderLsb;
275 UCHAR StartingCylinderMsb;
276 UCHAR PartitionType;
277 UCHAR EndingTrack;
278 UCHAR EndingCylinderLsb;
279 UCHAR EndingCylinderMsb;
280 UCHAR StartingSectorLsb0;
281 UCHAR StartingSectorLsb1;
282 UCHAR StartingSectorMsb0;
283 UCHAR StartingSectorMsb1;
284 UCHAR PartitionLengthLsb0;
285 UCHAR PartitionLengthLsb1;
286 UCHAR PartitionLengthMsb0;
287 UCHAR PartitionLengthMsb1;
288 } PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
289
290 //
291 // Structure describing a boot sector
292 //
293 typedef struct _BOOT_SECTOR_INFO
294 {
295 UCHAR JumpByte[1];
296 UCHAR Ignore1[2];
297 UCHAR OemData[8];
298 UCHAR BytesPerSector[2];
299 UCHAR Ignore2[6];
300 UCHAR NumberOfSectors[2];
301 UCHAR MediaByte[1];
302 UCHAR Ignore3[2];
303 UCHAR SectorsPerTrack[2];
304 UCHAR NumberOfHeads[2];
305 } BOOT_SECTOR_INFO, *PBOOT_SECTOR_INFO;
306
307 //
308 // Partition Table and Disk Layout
309 //
310 typedef struct _PARTITION_TABLE
311 {
312 PARTITION_INFORMATION PartitionEntry[4];
313 } PARTITION_TABLE, *PPARTITION_TABLE;
314
315 typedef struct _DISK_LAYOUT
316 {
317 ULONG TableCount;
318 ULONG Signature;
319 PARTITION_TABLE PartitionTable[1];
320 } DISK_LAYOUT, *PDISK_LAYOUT;
321
322 //
323 // Partition Table Entry
324 //
325 typedef struct _PTE
326 {
327 UCHAR ActiveFlag;
328 UCHAR StartingTrack;
329 USHORT StartingCylinder;
330 UCHAR PartitionType;
331 UCHAR EndingTrack;
332 USHORT EndingCylinder;
333 ULONG StartingSector;
334 ULONG PartitionLength;
335 } PTE, *PPTE;