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