748da07527ea34bd38631261c829966528b0cbb6
[reactos.git] / reactos / base / setup / usetup / partlist.h
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2002, 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /* COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS text-mode setup
21 * FILE: base/setup/usetup/partlist.h
22 * PURPOSE: Partition list functions
23 * PROGRAMMER: Eric Kohl
24 */
25
26 #pragma once
27
28 typedef enum _FORMATSTATE
29 {
30 Unformatted,
31 UnformattedOrDamaged,
32 UnknownFormat,
33 Preformatted,
34 Formatted
35 } FORMATSTATE, *PFORMATSTATE;
36
37 typedef enum _FORMATMACHINESTATE
38 {
39 Start,
40 FormatSystemPartition,
41 FormatInstallPartition,
42 FormatOtherPartition,
43 FormatDone,
44 CheckSystemPartition,
45 CheckInstallPartition,
46 CheckOtherPartition,
47 CheckDone
48 } FORMATMACHINESTATE, *PFORMATMACHINESTATE;
49
50 typedef struct _PARTENTRY
51 {
52 LIST_ENTRY ListEntry;
53
54 struct _DISKENTRY *DiskEntry;
55
56 ULARGE_INTEGER StartSector;
57 ULARGE_INTEGER SectorCount;
58
59 BOOLEAN BootIndicator;
60 UCHAR PartitionType;
61 ULONG HiddenSectors;
62 ULONG PartitionNumber;
63 ULONG PartitionIndex;
64
65 CHAR DriveLetter;
66 CHAR VolumeLabel[17];
67 CHAR FileSystemName[9];
68
69 BOOLEAN LogicalPartition;
70
71 /* Partition is partitioned disk space */
72 BOOLEAN IsPartitioned;
73
74 /* Partition is new, table does not exist on disk yet */
75 BOOLEAN New;
76
77 /* Partition was created automatically */
78 BOOLEAN AutoCreate;
79
80 FORMATSTATE FormatState;
81
82 /* Partition must be checked */
83 BOOLEAN NeedsCheck;
84
85 struct _FILE_SYSTEM_ITEM *FileSystem;
86 } PARTENTRY, *PPARTENTRY;
87
88
89 typedef struct _BIOSDISKENTRY
90 {
91 LIST_ENTRY ListEntry;
92 ULONG DiskNumber;
93 ULONG Signature;
94 ULONG Checksum;
95 BOOLEAN Recognized;
96 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
97 CM_INT13_DRIVE_PARAMETER Int13DiskData;
98 } BIOSDISKENTRY, *PBIOSDISKENTRY;
99
100
101 typedef struct _DISKENTRY
102 {
103 LIST_ENTRY ListEntry;
104
105 ULONGLONG Cylinders;
106 ULONG TracksPerCylinder;
107 ULONG SectorsPerTrack;
108 ULONG BytesPerSector;
109
110 ULARGE_INTEGER SectorCount;
111 ULONG SectorAlignment;
112 ULONG CylinderAlignment;
113
114 BOOLEAN BiosFound;
115 ULONG BiosDiskNumber;
116 // ULONG Signature;
117 // ULONG Checksum;
118
119 ULONG DiskNumber;
120 USHORT Port;
121 USHORT Bus;
122 USHORT Id;
123
124 /* Has the partition list been modified? */
125 BOOLEAN Dirty;
126
127 BOOLEAN NewDisk;
128 BOOLEAN NoMbr; /* MBR is absent */
129
130 UNICODE_STRING DriverName;
131
132 PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
133
134 PPARTENTRY ExtendedPartition;
135
136 LIST_ENTRY PrimaryPartListHead;
137 LIST_ENTRY LogicalPartListHead;
138
139 } DISKENTRY, *PDISKENTRY;
140
141
142 typedef struct _PARTLIST
143 {
144 SHORT Left;
145 SHORT Top;
146 SHORT Right;
147 SHORT Bottom;
148
149 SHORT Line;
150 SHORT Offset;
151
152 PDISKENTRY CurrentDisk;
153 PPARTENTRY CurrentPartition;
154
155 /* The system disk and partition where the boot manager resides */
156 PDISKENTRY SystemDisk;
157 PPARTENTRY SystemPartition;
158
159 PDISKENTRY TempDisk;
160 PPARTENTRY TempPartition;
161 FORMATMACHINESTATE FormatState;
162
163 LIST_ENTRY DiskListHead;
164 LIST_ENTRY BiosDiskListHead;
165
166 } PARTLIST, *PPARTLIST;
167
168 #define PARTITION_TBL_SIZE 4
169
170 #include <pshpack1.h>
171
172 typedef struct _PARTITION
173 {
174 unsigned char BootFlags; /* bootable? 0=no, 128=yes */
175 unsigned char StartingHead; /* beginning head number */
176 unsigned char StartingSector; /* beginning sector number */
177 unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
178 unsigned char PartitionType; /* Operating System type indicator code */
179 unsigned char EndingHead; /* ending head number */
180 unsigned char EndingSector; /* ending sector number */
181 unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
182 unsigned int StartingBlock; /* first sector relative to start of disk */
183 unsigned int SectorCount; /* number of sectors in partition */
184 } PARTITION, *PPARTITION;
185
186 typedef struct _PARTITION_SECTOR
187 {
188 UCHAR BootCode[440]; /* 0x000 */
189 ULONG Signature; /* 0x1B8 */
190 UCHAR Reserved[2]; /* 0x1BC */
191 PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
192 USHORT Magic; /* 0x1FE */
193 } PARTITION_SECTOR, *PPARTITION_SECTOR;
194
195 #include <poppack.h>
196
197 typedef struct
198 {
199 LIST_ENTRY ListEntry;
200 ULONG DiskNumber;
201 ULONG Idendifier;
202 ULONG Signature;
203 } BIOS_DISK, *PBIOS_DISK;
204
205 PPARTLIST
206 CreatePartitionList(
207 SHORT Left,
208 SHORT Top,
209 SHORT Right,
210 SHORT Bottom);
211
212 VOID
213 DestroyPartitionList(
214 PPARTLIST List);
215
216 VOID
217 DrawPartitionList(
218 PPARTLIST List);
219
220 DWORD
221 SelectPartition(
222 PPARTLIST List,
223 ULONG DiskNumber,
224 ULONG PartitionNumber);
225
226 BOOL
227 SetMountedDeviceValues(
228 PPARTLIST List);
229
230 BOOL
231 ScrollDownPartitionList(
232 PPARTLIST List);
233
234 BOOL
235 ScrollUpPartitionList(
236 PPARTLIST List);
237
238 VOID
239 CreatePrimaryPartition(
240 PPARTLIST List,
241 ULONGLONG SectorCount,
242 BOOLEAN AutoCreate);
243
244 VOID
245 CreateExtendedPartition(
246 PPARTLIST List,
247 ULONGLONG SectorCount);
248
249 VOID
250 CreateLogicalPartition(
251 PPARTLIST List,
252 ULONGLONG SectorCount,
253 BOOLEAN AutoCreate);
254
255 VOID
256 DeleteCurrentPartition(
257 PPARTLIST List);
258
259 VOID
260 CheckActiveSystemPartition(
261 PPARTLIST List);
262
263 BOOLEAN
264 WritePartitionsToDisk(
265 PPARTLIST List);
266
267 ULONG
268 PrimaryPartitionCreationChecks(
269 IN PPARTLIST List);
270
271 ULONG
272 ExtendedPartitionCreationChecks(
273 IN PPARTLIST List);
274
275 ULONG
276 LogicalPartitionCreationChecks(
277 IN PPARTLIST List);
278
279 BOOL
280 GetNextUnformattedPartition(
281 IN PPARTLIST List,
282 OUT PDISKENTRY *pDiskEntry,
283 OUT PPARTENTRY *pPartEntry);
284
285 BOOL
286 GetNextUncheckedPartition(
287 IN PPARTLIST List,
288 OUT PDISKENTRY *pDiskEntry,
289 OUT PPARTENTRY *pPartEntry);
290
291 VOID
292 GetPartTypeStringFromPartitionType(
293 UCHAR partitionType,
294 PCHAR strPartType,
295 DWORD cchPartType);
296
297 /* EOF */