[USETUP]
[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 LogicalPartition;
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 PPARTENTRY ExtendedPartition;
121
122 LIST_ENTRY PrimaryPartListHead;
123 LIST_ENTRY LogicalPartListHead;
124
125 } DISKENTRY, *PDISKENTRY;
126
127
128 typedef struct _PARTLIST
129 {
130 SHORT Left;
131 SHORT Top;
132 SHORT Right;
133 SHORT Bottom;
134
135 SHORT Line;
136 SHORT Offset;
137
138 ULONG TopDisk;
139 ULONG TopPartition;
140
141 PDISKENTRY CurrentDisk;
142 PPARTENTRY CurrentPartition;
143
144 PDISKENTRY ActiveBootDisk;
145 PPARTENTRY ActiveBootPartition;
146
147 LIST_ENTRY DiskListHead;
148 LIST_ENTRY BiosDiskListHead;
149
150 } PARTLIST, *PPARTLIST;
151
152 #define PARTITION_TBL_SIZE 4
153
154 #include <pshpack1.h>
155
156 typedef struct _PARTITION
157 {
158 unsigned char BootFlags; /* bootable? 0=no, 128=yes */
159 unsigned char StartingHead; /* beginning head number */
160 unsigned char StartingSector; /* beginning sector number */
161 unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
162 unsigned char PartitionType; /* Operating System type indicator code */
163 unsigned char EndingHead; /* ending head number */
164 unsigned char EndingSector; /* ending sector number */
165 unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
166 unsigned int StartingBlock; /* first sector relative to start of disk */
167 unsigned int SectorCount; /* number of sectors in partition */
168 } PARTITION, *PPARTITION;
169
170 typedef struct _PARTITION_SECTOR
171 {
172 UCHAR BootCode[440]; /* 0x000 */
173 ULONG Signature; /* 0x1B8 */
174 UCHAR Reserved[2]; /* 0x1BC */
175 PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
176 USHORT Magic; /* 0x1FE */
177 } PARTITION_SECTOR, *PPARTITION_SECTOR;
178
179 #include <poppack.h>
180
181 typedef struct
182 {
183 LIST_ENTRY ListEntry;
184 ULONG DiskNumber;
185 ULONG Idendifier;
186 ULONG Signature;
187 } BIOS_DISK, *PBIOS_DISK;
188
189 PPARTLIST
190 CreatePartitionList(
191 SHORT Left,
192 SHORT Top,
193 SHORT Right,
194 SHORT Bottom);
195
196 VOID
197 DestroyPartitionList(
198 PPARTLIST List);
199
200 VOID
201 DrawPartitionList(
202 PPARTLIST List);
203
204 DWORD
205 SelectPartition(
206 PPARTLIST List,
207 ULONG DiskNumber,
208 ULONG PartitionNumber);
209
210 BOOL
211 SetMountedDeviceValues(
212 PPARTLIST List);
213
214 VOID
215 ScrollDownPartitionList(
216 PPARTLIST List);
217
218 VOID
219 ScrollUpPartitionList(
220 PPARTLIST List);
221
222 VOID
223 CreatePrimaryPartition(
224 PPARTLIST List,
225 ULONGLONG PartitionSize,
226 BOOLEAN AutoCreate);
227
228 VOID
229 CreateExtendedPartition(
230 PPARTLIST List,
231 ULONGLONG PartitionSize);
232
233 VOID
234 DeleteCurrentPartition(
235 PPARTLIST List);
236
237 VOID
238 CheckActiveBootPartition(
239 PPARTLIST List);
240
241 BOOLEAN
242 CheckForLinuxFdiskPartitions(
243 PPARTLIST List);
244
245 BOOLEAN
246 WritePartitionsToDisk(
247 PPARTLIST List);
248
249 ULONG
250 PrimaryPartitionCreationChecks(
251 IN PPARTLIST List);
252
253 ULONG
254 ExtendedPartitionCreationChecks(
255 IN PPARTLIST List);
256
257 /* EOF */