[SETUP][USETUP][WELCOME] Improve the FILE header section. Brought to you by Adam...
[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 /* We have to define it there, because it is not in the MS DDK */
29 #define PARTITION_EXT2 0x83
30
31 typedef enum _FORMATSTATE
32 {
33 Unformatted,
34 UnformattedOrDamaged,
35 UnknownFormat,
36 Preformatted,
37 Formatted
38 } FORMATSTATE, *PFORMATSTATE;
39
40 typedef enum _FORMATMACHINESTATE
41 {
42 Start,
43 FormatSystemPartition,
44 FormatInstallPartition,
45 FormatOtherPartition,
46 FormatDone,
47 CheckSystemPartition,
48 CheckInstallPartition,
49 CheckOtherPartition,
50 CheckDone
51 } FORMATMACHINESTATE, *PFORMATMACHINESTATE;
52
53 typedef struct _PARTENTRY
54 {
55 LIST_ENTRY ListEntry;
56
57 struct _DISKENTRY *DiskEntry;
58
59 ULARGE_INTEGER StartSector;
60 ULARGE_INTEGER SectorCount;
61
62 BOOLEAN BootIndicator;
63 UCHAR PartitionType;
64 ULONG HiddenSectors;
65 ULONG PartitionNumber;
66 ULONG PartitionIndex;
67
68 CHAR DriveLetter;
69 CHAR VolumeLabel[17];
70 CHAR FileSystemName[9];
71
72 BOOLEAN LogicalPartition;
73
74 /* Partition is partitioned disk space */
75 BOOLEAN IsPartitioned;
76
77 /* Partition is new. Table does not exist on disk yet */
78 BOOLEAN New;
79
80 /* Partition was created automatically. */
81 BOOLEAN AutoCreate;
82
83 FORMATSTATE FormatState;
84
85 /* Partition must be checked */
86 BOOLEAN NeedsCheck;
87
88 struct _FILE_SYSTEM_ITEM *FileSystem;
89 } PARTENTRY, *PPARTENTRY;
90
91
92 typedef struct _BIOSDISKENTRY
93 {
94 LIST_ENTRY ListEntry;
95 ULONG DiskNumber;
96 ULONG Signature;
97 ULONG Checksum;
98 BOOLEAN Recognized;
99 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
100 CM_INT13_DRIVE_PARAMETER Int13DiskData;
101 } BIOSDISKENTRY, *PBIOSDISKENTRY;
102
103
104 typedef struct _DISKENTRY
105 {
106 LIST_ENTRY ListEntry;
107
108 ULONGLONG Cylinders;
109 ULONG TracksPerCylinder;
110 ULONG SectorsPerTrack;
111 ULONG BytesPerSector;
112
113 ULARGE_INTEGER SectorCount;
114 ULONG SectorAlignment;
115 ULONG CylinderAlignment;
116
117 BOOLEAN BiosFound;
118 ULONG BiosDiskNumber;
119 // ULONG Signature;
120 // ULONG Checksum;
121
122 ULONG DiskNumber;
123 USHORT Port;
124 USHORT Bus;
125 USHORT Id;
126
127 /* Has the partition list been modified? */
128 BOOLEAN Dirty;
129
130 BOOLEAN NewDisk;
131 BOOLEAN NoMbr; /* MBR is absent */
132
133 UNICODE_STRING DriverName;
134
135 PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
136
137 PPARTENTRY ExtendedPartition;
138
139 LIST_ENTRY PrimaryPartListHead;
140 LIST_ENTRY LogicalPartListHead;
141
142 } DISKENTRY, *PDISKENTRY;
143
144
145 typedef struct _PARTLIST
146 {
147 SHORT Left;
148 SHORT Top;
149 SHORT Right;
150 SHORT Bottom;
151
152 SHORT Line;
153 SHORT Offset;
154
155 ULONG TopDisk;
156 ULONG TopPartition;
157
158 PDISKENTRY CurrentDisk;
159 PPARTENTRY CurrentPartition;
160
161 PDISKENTRY BootDisk;
162 PPARTENTRY BootPartition;
163
164 PDISKENTRY TempDisk;
165 PPARTENTRY TempPartition;
166 FORMATMACHINESTATE FormatState;
167
168 LIST_ENTRY DiskListHead;
169 LIST_ENTRY BiosDiskListHead;
170
171 } PARTLIST, *PPARTLIST;
172
173 #define PARTITION_TBL_SIZE 4
174
175 #include <pshpack1.h>
176
177 typedef struct _PARTITION
178 {
179 unsigned char BootFlags; /* bootable? 0=no, 128=yes */
180 unsigned char StartingHead; /* beginning head number */
181 unsigned char StartingSector; /* beginning sector number */
182 unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
183 unsigned char PartitionType; /* Operating System type indicator code */
184 unsigned char EndingHead; /* ending head number */
185 unsigned char EndingSector; /* ending sector number */
186 unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
187 unsigned int StartingBlock; /* first sector relative to start of disk */
188 unsigned int SectorCount; /* number of sectors in partition */
189 } PARTITION, *PPARTITION;
190
191 typedef struct _PARTITION_SECTOR
192 {
193 UCHAR BootCode[440]; /* 0x000 */
194 ULONG Signature; /* 0x1B8 */
195 UCHAR Reserved[2]; /* 0x1BC */
196 PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
197 USHORT Magic; /* 0x1FE */
198 } PARTITION_SECTOR, *PPARTITION_SECTOR;
199
200 #include <poppack.h>
201
202 typedef struct
203 {
204 LIST_ENTRY ListEntry;
205 ULONG DiskNumber;
206 ULONG Idendifier;
207 ULONG Signature;
208 } BIOS_DISK, *PBIOS_DISK;
209
210 PPARTLIST
211 CreatePartitionList(
212 SHORT Left,
213 SHORT Top,
214 SHORT Right,
215 SHORT Bottom);
216
217 VOID
218 DestroyPartitionList(
219 PPARTLIST List);
220
221 VOID
222 DrawPartitionList(
223 PPARTLIST List);
224
225 DWORD
226 SelectPartition(
227 PPARTLIST List,
228 ULONG DiskNumber,
229 ULONG PartitionNumber);
230
231 BOOL
232 SetMountedDeviceValues(
233 PPARTLIST List);
234
235 BOOL
236 ScrollDownPartitionList(
237 PPARTLIST List);
238
239 BOOL
240 ScrollUpPartitionList(
241 PPARTLIST List);
242
243 VOID
244 CreatePrimaryPartition(
245 PPARTLIST List,
246 ULONGLONG SectorCount,
247 BOOLEAN AutoCreate);
248
249 VOID
250 CreateExtendedPartition(
251 PPARTLIST List,
252 ULONGLONG SectorCount);
253
254 VOID
255 CreateLogicalPartition(
256 PPARTLIST List,
257 ULONGLONG SectorCount,
258 BOOLEAN AutoCreate);
259
260 VOID
261 DeleteCurrentPartition(
262 PPARTLIST List);
263
264 VOID
265 CheckActiveBootPartition(
266 PPARTLIST List);
267
268 BOOLEAN
269 WritePartitionsToDisk(
270 PPARTLIST List);
271
272 ULONG
273 PrimaryPartitionCreationChecks(
274 IN PPARTLIST List);
275
276 ULONG
277 ExtendedPartitionCreationChecks(
278 IN PPARTLIST List);
279
280 ULONG
281 LogicalPartitionCreationChecks(
282 IN PPARTLIST List);
283
284 BOOL
285 GetNextUnformattedPartition(
286 IN PPARTLIST List,
287 OUT PDISKENTRY *pDiskEntry,
288 OUT PPARTENTRY *pPartEntry);
289
290 BOOL
291 GetNextUncheckedPartition(
292 IN PPARTLIST List,
293 OUT PDISKENTRY *pDiskEntry,
294 OUT PPARTENTRY *pPartEntry);
295
296 /* EOF */