[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 */
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 NTSTATUS
75 NTAPI
76 xHalGetInterruptTranslator(IN INTERFACE_TYPE ParentInterfaceType,
77 IN ULONG ParentBusNumber,
78 IN INTERFACE_TYPE BridgeInterfaceType,
79 IN USHORT Size,
80 IN USHORT Version,
81 OUT PTRANSLATOR_INTERFACE Translator,
82 OUT PULONG BridgeBusNumber);
83
84
85 //
86 // Various offsets in the boot record
87 //
88 #define PARTITION_TABLE_OFFSET (0x1BE / 2)
89 #define BOOT_SIGNATURE_OFFSET ((0x200 / 2) - 1)
90 #define BOOT_RECORD_RESERVED 0x1BC
91 #define BOOT_RECORD_SIGNATURE 0xAA55
92 #define NUM_PARTITION_TABLE_ENTRIES 4
93
94 //
95 // Helper Macros
96 //
97 #define GET_STARTING_SECTOR(p) \
98 ((ULONG)(p->StartingSectorLsb0) + \
99 (ULONG)(p->StartingSectorLsb1 << 8 ) + \
100 (ULONG)(p->StartingSectorMsb0 << 16) + \
101 (ULONG)(p->StartingSectorMsb1 << 24))
102
103 #define GET_ENDING_S_OF_CHS(p) \
104 ((UCHAR)(p->EndingCylinderLsb & 0x3F))
105
106 #define GET_PARTITION_LENGTH(p) \
107 ((ULONG)(p->PartitionLengthLsb0) + \
108 (ULONG)(p->PartitionLengthLsb1 << 8) + \
109 (ULONG)(p->PartitionLengthMsb0 << 16) + \
110 (ULONG)(p->PartitionLengthMsb1 << 24))
111
112 //
113 // Structure describing a partition
114 //
115 typedef struct _PARTITION_DESCRIPTOR
116 {
117 UCHAR ActiveFlag;
118 UCHAR StartingTrack;
119 UCHAR StartingCylinderLsb;
120 UCHAR StartingCylinderMsb;
121 UCHAR PartitionType;
122 UCHAR EndingTrack;
123 UCHAR EndingCylinderLsb;
124 UCHAR EndingCylinderMsb;
125 UCHAR StartingSectorLsb0;
126 UCHAR StartingSectorLsb1;
127 UCHAR StartingSectorMsb0;
128 UCHAR StartingSectorMsb1;
129 UCHAR PartitionLengthLsb0;
130 UCHAR PartitionLengthLsb1;
131 UCHAR PartitionLengthMsb0;
132 UCHAR PartitionLengthMsb1;
133 } PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
134
135 //
136 // Structure describing a boot sector
137 //
138 typedef struct _BOOT_SECTOR_INFO
139 {
140 UCHAR JumpByte[1];
141 UCHAR Ignore1[2];
142 UCHAR OemData[8];
143 UCHAR BytesPerSector[2];
144 UCHAR Ignore2[6];
145 UCHAR NumberOfSectors[2];
146 UCHAR MediaByte[1];
147 UCHAR Ignore3[2];
148 UCHAR SectorsPerTrack[2];
149 UCHAR NumberOfHeads[2];
150 } BOOT_SECTOR_INFO, *PBOOT_SECTOR_INFO;
151
152 //
153 // Partition Table and Disk Layout
154 //
155 typedef struct _PARTITION_TABLE
156 {
157 PARTITION_INFORMATION PartitionEntry[4];
158 } PARTITION_TABLE, *PPARTITION_TABLE;
159
160 typedef struct _DISK_LAYOUT
161 {
162 ULONG TableCount;
163 ULONG Signature;
164 PARTITION_TABLE PartitionTable[1];
165 } DISK_LAYOUT, *PDISK_LAYOUT;
166
167 //
168 // Partition Table Entry
169 //
170 typedef struct _PTE
171 {
172 UCHAR ActiveFlag;
173 UCHAR StartingTrack;
174 USHORT StartingCylinder;
175 UCHAR PartitionType;
176 UCHAR EndingTrack;
177 USHORT EndingCylinder;
178 ULONG StartingSector;
179 ULONG PartitionLength;
180 } PTE, *PPTE;