xref: /reactos/base/setup/usetup/partlist.h (revision 5100859e)
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      * The original system disk and partition in case we are redefining them
160      * because we do not have write support on them.
161      * Please not that this is partly a HACK and MUST NEVER happen on
162      * architectures where real system partitions are mandatory (because then
163      * they are formatted in FAT FS and we support write operation on them).
164      */
165     PDISKENTRY OriginalSystemDisk;
166     PPARTENTRY OriginalSystemPartition;
167 
168     PDISKENTRY TempDisk;
169     PPARTENTRY TempPartition;
170     FORMATMACHINESTATE FormatState;
171 
172     LIST_ENTRY DiskListHead;
173     LIST_ENTRY BiosDiskListHead;
174 
175 } PARTLIST, *PPARTLIST;
176 
177 #define  PARTITION_TBL_SIZE 4
178 
179 #include <pshpack1.h>
180 
181 typedef struct _PARTITION
182 {
183     unsigned char   BootFlags;        /* bootable?  0=no, 128=yes  */
184     unsigned char   StartingHead;     /* beginning head number */
185     unsigned char   StartingSector;   /* beginning sector number */
186     unsigned char   StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
187     unsigned char   PartitionType;    /* Operating System type indicator code */
188     unsigned char   EndingHead;       /* ending head number */
189     unsigned char   EndingSector;     /* ending sector number */
190     unsigned char   EndingCylinder;   /* also a 10 bit nmbr, with same high 2 bit trick */
191     unsigned int  StartingBlock;      /* first sector relative to start of disk */
192     unsigned int  SectorCount;        /* number of sectors in partition */
193 } PARTITION, *PPARTITION;
194 
195 typedef struct _PARTITION_SECTOR
196 {
197     UCHAR BootCode[440];                     /* 0x000 */
198     ULONG Signature;                         /* 0x1B8 */
199     UCHAR Reserved[2];                       /* 0x1BC */
200     PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
201     USHORT Magic;                            /* 0x1FE */
202 } PARTITION_SECTOR, *PPARTITION_SECTOR;
203 
204 #include <poppack.h>
205 
206 typedef struct
207 {
208     LIST_ENTRY ListEntry;
209     ULONG DiskNumber;
210     ULONG Identifier;
211     ULONG Signature;
212 } BIOS_DISK, *PBIOS_DISK;
213 
214 PPARTLIST
215 CreatePartitionList(
216     SHORT Left,
217     SHORT Top,
218     SHORT Right,
219     SHORT Bottom);
220 
221 VOID
222 DestroyPartitionList(
223     PPARTLIST List);
224 
225 VOID
226 DrawPartitionList(
227     PPARTLIST List);
228 
229 DWORD
230 SelectPartition(
231     PPARTLIST List,
232     ULONG DiskNumber,
233     ULONG PartitionNumber);
234 
235 BOOL
236 SetMountedDeviceValues(
237     PPARTLIST List);
238 
239 BOOL
240 ScrollDownPartitionList(
241     PPARTLIST List);
242 
243 BOOL
244 ScrollUpPartitionList(
245     PPARTLIST List);
246 
247 VOID
248 CreatePrimaryPartition(
249     PPARTLIST List,
250     ULONGLONG SectorCount,
251     BOOLEAN AutoCreate);
252 
253 VOID
254 CreateExtendedPartition(
255     PPARTLIST List,
256     ULONGLONG SectorCount);
257 
258 VOID
259 CreateLogicalPartition(
260     PPARTLIST List,
261     ULONGLONG SectorCount,
262     BOOLEAN AutoCreate);
263 
264 VOID
265 DeleteCurrentPartition(
266     PPARTLIST List);
267 
268 VOID
269 CheckActiveSystemPartition(
270     IN PPARTLIST List,
271     IN PFILE_SYSTEM_LIST FileSystemList);
272 
273 BOOLEAN
274 WritePartitionsToDisk(
275     PPARTLIST List);
276 
277 ULONG
278 PrimaryPartitionCreationChecks(
279     IN PPARTLIST List);
280 
281 ULONG
282 ExtendedPartitionCreationChecks(
283     IN PPARTLIST List);
284 
285 ULONG
286 LogicalPartitionCreationChecks(
287     IN PPARTLIST List);
288 
289 BOOL
290 GetNextUnformattedPartition(
291     IN PPARTLIST List,
292     OUT PDISKENTRY *pDiskEntry,
293     OUT PPARTENTRY *pPartEntry);
294 
295 BOOL
296 GetNextUncheckedPartition(
297     IN PPARTLIST List,
298     OUT PDISKENTRY *pDiskEntry,
299     OUT PPARTENTRY *pPartEntry);
300 
301 VOID
302 GetPartTypeStringFromPartitionType(
303     UCHAR partitionType,
304     PCHAR strPartType,
305     DWORD cchPartType);
306 
307 /* EOF */
308