40022f4b80016ecb21f25f036f9bee266448689e
[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: subsys/system/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
41 typedef struct _PARTENTRY
42 {
43 LIST_ENTRY ListEntry;
44
45 struct _DISKENTRY *DiskEntry;
46
47 ULARGE_INTEGER StartSector;
48 ULARGE_INTEGER SectorCount;
49
50 BOOLEAN BootIndicator;
51 UCHAR PartitionType;
52 ULONG HiddenSectors;
53 ULONG PartitionNumber;
54 ULONG PartitionIndex;
55
56 CHAR DriveLetter;
57 CHAR VolumeLabel[17];
58 CHAR FileSystemName[9];
59
60 BOOLEAN ExtendedPartition;
61
62 /* Partition is partitioned disk space */
63 BOOLEAN IsPartitioned;
64
65 /* Partition is new. Table does not exist on disk yet */
66 BOOLEAN New;
67
68 /* Partition was created automatically. */
69 BOOLEAN AutoCreate;
70
71 FORMATSTATE FormatState;
72
73 } PARTENTRY, *PPARTENTRY;
74
75
76 typedef struct _BIOSDISKENTRY
77 {
78 LIST_ENTRY ListEntry;
79 ULONG DiskNumber;
80 ULONG Signature;
81 ULONG Checksum;
82 BOOLEAN Recognized;
83 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
84 CM_INT13_DRIVE_PARAMETER Int13DiskData;
85 } BIOSDISKENTRY, *PBIOSDISKENTRY;
86
87
88 typedef struct _DISKENTRY
89 {
90 LIST_ENTRY ListEntry;
91
92 ULONGLONG Cylinders;
93 ULONG TracksPerCylinder;
94 ULONG SectorsPerTrack;
95 ULONG BytesPerSector;
96
97 ULARGE_INTEGER SectorCount;
98 ULONG SectorAlignment;
99
100 BOOLEAN BiosFound;
101 ULONG BiosDiskNumber;
102 // ULONG Signature;
103 // ULONG Checksum;
104
105 ULONG DiskNumber;
106 USHORT Port;
107 USHORT Bus;
108 USHORT Id;
109
110 /* Has the partition list been modified? */
111 BOOLEAN Dirty;
112
113 BOOLEAN NewDisk;
114 BOOLEAN NoMbr; /* MBR is absent */
115
116 UNICODE_STRING DriverName;
117
118 PDRIVE_LAYOUT_INFORMATION LayoutBuffer;
119
120 LIST_ENTRY PrimaryPartListHead;
121 LIST_ENTRY ExtendedPartListHead;
122
123 } DISKENTRY, *PDISKENTRY;
124
125
126 typedef struct _PARTLIST
127 {
128 SHORT Left;
129 SHORT Top;
130 SHORT Right;
131 SHORT Bottom;
132
133 SHORT Line;
134 SHORT Offset;
135
136 ULONG TopDisk;
137 ULONG TopPartition;
138
139 PDISKENTRY CurrentDisk;
140 PPARTENTRY CurrentPartition;
141
142 PDISKENTRY ActiveBootDisk;
143 PPARTENTRY ActiveBootPartition;
144
145 LIST_ENTRY DiskListHead;
146 LIST_ENTRY BiosDiskListHead;
147
148 } PARTLIST, *PPARTLIST;
149
150 #define PARTITION_TBL_SIZE 4
151
152 #include <pshpack1.h>
153
154 typedef struct _PARTITION
155 {
156 unsigned char BootFlags; /* bootable? 0=no, 128=yes */
157 unsigned char StartingHead; /* beginning head number */
158 unsigned char StartingSector; /* beginning sector number */
159 unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
160 unsigned char PartitionType; /* Operating System type indicator code */
161 unsigned char EndingHead; /* ending head number */
162 unsigned char EndingSector; /* ending sector number */
163 unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
164 unsigned int StartingBlock; /* first sector relative to start of disk */
165 unsigned int SectorCount; /* number of sectors in partition */
166 } PARTITION, *PPARTITION;
167
168 typedef struct _PARTITION_SECTOR
169 {
170 UCHAR BootCode[440]; /* 0x000 */
171 ULONG Signature; /* 0x1B8 */
172 UCHAR Reserved[2]; /* 0x1BC */
173 PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
174 USHORT Magic; /* 0x1FE */
175 } PARTITION_SECTOR, *PPARTITION_SECTOR;
176
177 #include <poppack.h>
178
179 typedef struct
180 {
181 LIST_ENTRY ListEntry;
182 ULONG DiskNumber;
183 ULONG Idendifier;
184 ULONG Signature;
185 } BIOS_DISK, *PBIOS_DISK;
186
187 PPARTLIST
188 CreatePartitionList(
189 SHORT Left,
190 SHORT Top,
191 SHORT Right,
192 SHORT Bottom);
193
194 VOID
195 DestroyPartitionList(
196 PPARTLIST List);
197
198 VOID
199 DrawPartitionList(
200 PPARTLIST List);
201
202 DWORD
203 SelectPartition(
204 PPARTLIST List,
205 ULONG DiskNumber,
206 ULONG PartitionNumber);
207
208 BOOL
209 SetMountedDeviceValues(
210 PPARTLIST List);
211
212 VOID
213 ScrollDownPartitionList(
214 PPARTLIST List);
215
216 VOID
217 ScrollUpPartitionList(
218 PPARTLIST List);
219
220 VOID
221 CreatePrimaryPartition(
222 PPARTLIST List,
223 ULONGLONG PartitionSize,
224 BOOLEAN AutoCreate);
225
226 VOID
227 CreateExtendedPartition(
228 PPARTLIST List,
229 ULONGLONG PartitionSize);
230
231 VOID
232 DeleteCurrentPartition(
233 PPARTLIST List);
234
235 VOID
236 CheckActiveBootPartition(
237 PPARTLIST List);
238
239 BOOLEAN
240 CheckForLinuxFdiskPartitions(
241 PPARTLIST List);
242
243 BOOLEAN
244 WritePartitionsToDisk(
245 PPARTLIST List);
246
247 ULONG
248 PrimaryPartitionCreationChecks(
249 IN PPARTLIST List);
250
251 ULONG
252 ExtendedPartitionCreationChecks(
253 IN PPARTLIST List);
254
255 /* EOF */