xref: /reactos/ntoskrnl/include/internal/hal.h (revision 29615fee)
1 /*
2  * PROJECT:         ReactOS Kernel
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * FILE:            ntoskrnl/include/internal/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 DISK_SIGNATURE_OFFSET                       0x1B8
244 #define PARTITION_TABLE_OFFSET                      0x1BE
245 #define BOOT_SIGNATURE_OFFSET                       (0x200 - 2)
246 
247 #define BOOT_RECORD_SIGNATURE                       0xAA55
248 #define NUM_PARTITION_TABLE_ENTRIES                 4
249 
250 //
251 // Helper Macros
252 //
253 #define GET_STARTING_SECTOR(p)                      \
254     ((ULONG)(p->StartingSectorLsb0) +               \
255      (ULONG)(p->StartingSectorLsb1 << 8 ) +         \
256      (ULONG)(p->StartingSectorMsb0 << 16) +         \
257      (ULONG)(p->StartingSectorMsb1 << 24))
258 
259 #define GET_ENDING_S_OF_CHS(p)                      \
260     ((UCHAR)(p->EndingCylinderLsb & 0x3F))
261 
262 #define GET_PARTITION_LENGTH(p)                     \
263     ((ULONG)(p->PartitionLengthLsb0) +              \
264      (ULONG)(p->PartitionLengthLsb1 << 8) +         \
265      (ULONG)(p->PartitionLengthMsb0 << 16) +        \
266      (ULONG)(p->PartitionLengthMsb1 << 24))
267 
268 #define SET_PARTITION_LENGTH(p, l)                  \
269     p->PartitionLengthLsb0 = l & 0xFF;              \
270     p->PartitionLengthLsb1 = (l >> 8) & 0xFF;       \
271     p->PartitionLengthMsb0 = (l >> 16) & 0xFF;      \
272     p->PartitionLengthMsb1 = (l >> 24) & 0xFF
273 
274 //
275 // Structure describing a partition
276 //
277 typedef struct _PARTITION_DESCRIPTOR
278 {
279     UCHAR ActiveFlag;
280     UCHAR StartingTrack;
281     UCHAR StartingCylinderLsb;
282     UCHAR StartingCylinderMsb;
283     UCHAR PartitionType;
284     UCHAR EndingTrack;
285     UCHAR EndingCylinderLsb;
286     UCHAR EndingCylinderMsb;
287     UCHAR StartingSectorLsb0;
288     UCHAR StartingSectorLsb1;
289     UCHAR StartingSectorMsb0;
290     UCHAR StartingSectorMsb1;
291     UCHAR PartitionLengthLsb0;
292     UCHAR PartitionLengthLsb1;
293     UCHAR PartitionLengthMsb0;
294     UCHAR PartitionLengthMsb1;
295 } PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
296 
297 //
298 // Structure describing a boot sector
299 //
300 typedef struct _BOOT_SECTOR_INFO
301 {
302     UCHAR JumpByte[1];
303     UCHAR Ignore1[2];
304     UCHAR OemData[8];
305     UCHAR BytesPerSector[2];
306     UCHAR Ignore2[6];
307     UCHAR NumberOfSectors[2];
308     UCHAR MediaByte[1];
309     UCHAR Ignore3[2];
310     UCHAR SectorsPerTrack[2];
311     UCHAR NumberOfHeads[2];
312 } BOOT_SECTOR_INFO, *PBOOT_SECTOR_INFO;
313 
314 //
315 // Partition Table and Disk Layout
316 //
317 typedef struct _PARTITION_TABLE
318 {
319     PARTITION_INFORMATION PartitionEntry[4];
320 } PARTITION_TABLE, *PPARTITION_TABLE;
321 
322 typedef struct _DISK_LAYOUT
323 {
324     ULONG TableCount;
325     ULONG Signature;
326     PARTITION_TABLE PartitionTable[1];
327 } DISK_LAYOUT, *PDISK_LAYOUT;
328 
329 //
330 // Partition Table Entry
331 //
332 typedef struct _PTE
333 {
334     UCHAR ActiveFlag;
335     UCHAR StartingTrack;
336     USHORT StartingCylinder;
337     UCHAR PartitionType;
338     UCHAR EndingTrack;
339     USHORT EndingCylinder;
340     ULONG StartingSector;
341     ULONG PartitionLength;
342 } PTE, *PPTE;
343