- Move from using include guards to pragma once.
[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 UCHAR
57 NTAPI
58 xHalVectorToIDTEntry(
59 IN ULONG Vector
60 );
61
62
63 //
64 // Various offsets in the boot record
65 //
66 #define PARTITION_TABLE_OFFSET (0x1BE / 2)
67 #define BOOT_SIGNATURE_OFFSET ((0x200 / 2) - 1)
68 #define BOOT_RECORD_RESERVED 0x1BC
69 #define BOOT_RECORD_SIGNATURE 0xAA55
70 #define NUM_PARTITION_TABLE_ENTRIES 4
71
72 //
73 // Helper Macros
74 //
75 #define GET_STARTING_SECTOR(p) \
76 ((ULONG)(p->StartingSectorLsb0) + \
77 (ULONG)(p->StartingSectorLsb1 << 8 ) + \
78 (ULONG)(p->StartingSectorMsb0 << 16) + \
79 (ULONG)(p->StartingSectorMsb1 << 24))
80
81 #define GET_ENDING_S_OF_CHS(p) \
82 ((UCHAR)(p->EndingCylinderLsb & 0x3F))
83
84 #define GET_PARTITION_LENGTH(p) \
85 ((ULONG)(p->PartitionLengthLsb0) + \
86 (ULONG)(p->PartitionLengthLsb1 << 8) + \
87 (ULONG)(p->PartitionLengthMsb0 << 16) + \
88 (ULONG)(p->PartitionLengthMsb1 << 24))
89
90 //
91 // Structure describing a partition
92 //
93 typedef struct _PARTITION_DESCRIPTOR
94 {
95 UCHAR ActiveFlag;
96 UCHAR StartingTrack;
97 UCHAR StartingCylinderLsb;
98 UCHAR StartingCylinderMsb;
99 UCHAR PartitionType;
100 UCHAR EndingTrack;
101 UCHAR EndingCylinderLsb;
102 UCHAR EndingCylinderMsb;
103 UCHAR StartingSectorLsb0;
104 UCHAR StartingSectorLsb1;
105 UCHAR StartingSectorMsb0;
106 UCHAR StartingSectorMsb1;
107 UCHAR PartitionLengthLsb0;
108 UCHAR PartitionLengthLsb1;
109 UCHAR PartitionLengthMsb0;
110 UCHAR PartitionLengthMsb1;
111 } PARTITION_DESCRIPTOR, *PPARTITION_DESCRIPTOR;
112
113 //
114 // Structure describing a boot sector
115 //
116 typedef struct _BOOT_SECTOR_INFO
117 {
118 UCHAR JumpByte[1];
119 UCHAR Ignore1[2];
120 UCHAR OemData[8];
121 UCHAR BytesPerSector[2];
122 UCHAR Ignore2[6];
123 UCHAR NumberOfSectors[2];
124 UCHAR MediaByte[1];
125 UCHAR Ignore3[2];
126 UCHAR SectorsPerTrack[2];
127 UCHAR NumberOfHeads[2];
128 } BOOT_SECTOR_INFO, *PBOOT_SECTOR_INFO;
129
130 //
131 // Partition Table and Disk Layout
132 //
133 typedef struct _PARTITION_TABLE
134 {
135 PARTITION_INFORMATION PartitionEntry[4];
136 } PARTITION_TABLE, *PPARTITION_TABLE;
137
138 typedef struct _DISK_LAYOUT
139 {
140 ULONG TableCount;
141 ULONG Signature;
142 PARTITION_TABLE PartitionTable[1];
143 } DISK_LAYOUT, *PDISK_LAYOUT;
144
145 //
146 // Partition Table Entry
147 //
148 typedef struct _PTE
149 {
150 UCHAR ActiveFlag;
151 UCHAR StartingTrack;
152 USHORT StartingCylinder;
153 UCHAR PartitionType;
154 UCHAR EndingTrack;
155 USHORT EndingCylinder;
156 ULONG StartingSector;
157 ULONG PartitionLength;
158 } PTE, *PPTE;