[HEADERS]
[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 */
8
9 #pragma once
10
11 //
12 // Default implementations of HAL dispatch table
13 //
14 VOID
15 FASTCALL
16 xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
17 IN ULONG SectorSize,
18 IN ULONG MbrTypeIdentifier,
19 OUT PVOID *MbrBuffer);
20
21 VOID
22 FASTCALL
23 xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
24 IN PSTRING NtDeviceName,
25 OUT PUCHAR NtSystemPath,
26 OUT PSTRING NtSystemPathString);
27
28 NTSTATUS
29 FASTCALL
30 xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject,
31 IN ULONG SectorSize,
32 IN BOOLEAN ReturnRecognizedPartitions,
33 IN OUT PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
34
35 NTSTATUS
36 FASTCALL
37 xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
38 IN ULONG SectorSize,
39 IN ULONG PartitionNumber,
40 IN ULONG PartitionType);
41
42 NTSTATUS
43 FASTCALL
44 xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
45 IN ULONG SectorSize,
46 IN ULONG SectorsPerTrack,
47 IN ULONG NumberOfHeads,
48 IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer);
49
50 VOID
51 NTAPI
52 xHalHaltSystem(
53 VOID
54 );
55
56 VOID
57 NTAPI
58 xHalEndOfBoot(
59 VOID
60 );
61
62 VOID
63 NTAPI
64 xHalSetWakeEnable(
65 IN BOOLEAN Enable
66 );
67
68 UCHAR
69 NTAPI
70 xHalVectorToIDTEntry(
71 IN ULONG Vector
72 );
73
74
75 //
76 // Various offsets in the boot record
77 //
78 #define PARTITION_TABLE_OFFSET (0x1BE / 2)
79 #define BOOT_SIGNATURE_OFFSET ((0x200 / 2) - 1)
80 #define BOOT_RECORD_RESERVED 0x1BC
81 #define BOOT_RECORD_SIGNATURE 0xAA55
82 #define NUM_PARTITION_TABLE_ENTRIES 4
83
84 //
85 // Helper Macros
86 //
87 #define GET_STARTING_SECTOR(p) \
88 ((ULONG)(p->StartingSectorLsb0) + \
89 (ULONG)(p->StartingSectorLsb1 << 8 ) + \
90 (ULONG)(p->StartingSectorMsb0 << 16) + \
91 (ULONG)(p->StartingSectorMsb1 << 24))
92
93 #define GET_ENDING_S_OF_CHS(p) \
94 ((UCHAR)(p->EndingCylinderLsb & 0x3F))
95
96 #define GET_PARTITION_LENGTH(p) \
97 ((ULONG)(p->PartitionLengthLsb0) + \
98 (ULONG)(p->PartitionLengthLsb1 << 8) + \
99 (ULONG)(p->PartitionLengthMsb0 << 16) + \
100 (ULONG)(p->PartitionLengthMsb1 << 24))
101
102 //
103 // Structure describing a partition
104 //
105 typedef struct _PARTITION_DESCRIPTOR
106 {
107 UCHAR ActiveFlag;
108 UCHAR StartingTrack;
109 UCHAR StartingCylinderLsb;
110 UCHAR StartingCylinderMsb;
111 UCHAR PartitionType;
112 UCHAR EndingTrack;
113 UCHAR EndingCylinderLsb;
114 UCHAR EndingCylinderMsb;
115 UCHAR StartingSectorLsb0;
116 UCHAR StartingSectorLsb1;
117 UCHAR StartingSectorMsb0;
118 UCHAR StartingSectorMsb1;
119 UCHAR PartitionLengthLsb0;
120 UCHAR PartitionLengthLsb1;
121 UCHAR PartitionLengthMsb0;
122 UCHAR PartitionLengthMsb1;
123 } PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
124
125 //
126 // Structure describing a boot sector
127 //
128 typedef struct _BOOT_SECTOR_INFO
129 {
130 UCHAR JumpByte[1];
131 UCHAR Ignore1[2];
132 UCHAR OemData[8];
133 UCHAR BytesPerSector[2];
134 UCHAR Ignore2[6];
135 UCHAR NumberOfSectors[2];
136 UCHAR MediaByte[1];
137 UCHAR Ignore3[2];
138 UCHAR SectorsPerTrack[2];
139 UCHAR NumberOfHeads[2];
140 } BOOT_SECTOR_INFO, *PBOOT_SECTOR_INFO;
141
142 //
143 // Partition Table and Disk Layout
144 //
145 typedef struct _PARTITION_TABLE
146 {
147 PARTITION_INFORMATION PartitionEntry[4];
148 } PARTITION_TABLE, *PPARTITION_TABLE;
149
150 typedef struct _DISK_LAYOUT
151 {
152 ULONG TableCount;
153 ULONG Signature;
154 PARTITION_TABLE PartitionTable[1];
155 } DISK_LAYOUT, *PDISK_LAYOUT;
156
157 //
158 // Partition Table Entry
159 //
160 typedef struct _PTE
161 {
162 UCHAR ActiveFlag;
163 UCHAR StartingTrack;
164 USHORT StartingCylinder;
165 UCHAR PartitionType;
166 UCHAR EndingTrack;
167 USHORT EndingCylinder;
168 ULONG StartingSector;
169 ULONG PartitionLength;
170 } PTE, *PPTE;