The real, definitive, Visual C++ support branch. Accept no substitutes
[reactos.git] / 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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 #ifndef __PARTLIST_H__
27 #define __PARTLIST_H__
28
29 /* We have to define it there, because it is not in the MS DDK */
30 #define PARTITION_EXT2 0x83
31
32 typedef enum _FORMATSTATE
33 {
34 Unformatted,
35 UnformattedOrDamaged,
36 UnknownFormat,
37 Preformatted,
38 Formatted
39 } FORMATSTATE, *PFORMATSTATE;
40
41
42 typedef struct _PARTENTRY
43 {
44 LIST_ENTRY ListEntry;
45
46 CHAR DriveLetter;
47 CHAR VolumeLabel[17];
48 CHAR FileSystemName[9];
49
50 /* Partition is unused disk space */
51 BOOLEAN Unpartitioned;
52
53 /* Partition is new. Table does not exist on disk yet */
54 BOOLEAN New;
55
56 /* Partition was created automatically. */
57 BOOLEAN AutoCreate;
58
59 FORMATSTATE FormatState;
60
61 /*
62 * Raw offset and length of the unpartitioned disk space.
63 * Includes the leading, not yet existing, partition table.
64 */
65 ULONGLONG UnpartitionedOffset;
66 ULONGLONG UnpartitionedLength;
67
68 PARTITION_INFORMATION PartInfo[4];
69
70 } PARTENTRY, *PPARTENTRY;
71
72
73 typedef struct _BIOSDISKENTRY
74 {
75 LIST_ENTRY ListEntry;
76 ULONG DiskNumber;
77 ULONG Signature;
78 ULONG Checksum;
79 BOOLEAN Recognized;
80 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry;
81 CM_INT13_DRIVE_PARAMETER Int13DiskData;
82 } BIOSDISKENTRY, *PBIOSDISKENTRY;
83
84
85 typedef struct _DISKENTRY
86 {
87 LIST_ENTRY ListEntry;
88
89 ULONGLONG Cylinders;
90 ULONGLONG TracksPerCylinder;
91 ULONGLONG SectorsPerTrack;
92 ULONGLONG BytesPerSector;
93
94 ULONGLONG DiskSize;
95 ULONGLONG CylinderSize;
96 ULONGLONG TrackSize;
97
98 BOOLEAN BiosFound;
99 ULONG BiosDiskNumber;
100 ULONG Signature;
101 ULONG Checksum;
102
103 ULONG DiskNumber;
104 USHORT Port;
105 USHORT Bus;
106 USHORT Id;
107
108 /* Has the partition list been modified? */
109 BOOLEAN Modified;
110
111 BOOLEAN NewDisk;
112
113 UNICODE_STRING DriverName;
114
115 LIST_ENTRY PartListHead;
116
117 } DISKENTRY, *PDISKENTRY;
118
119
120 typedef struct _PARTLIST
121 {
122 SHORT Left;
123 SHORT Top;
124 SHORT Right;
125 SHORT Bottom;
126
127 SHORT Line;
128 SHORT Offset;
129
130 ULONG TopDisk;
131 ULONG TopPartition;
132
133 PDISKENTRY CurrentDisk;
134 PPARTENTRY CurrentPartition;
135
136 PDISKENTRY ActiveBootDisk;
137 PPARTENTRY ActiveBootPartition;
138
139 LIST_ENTRY DiskListHead;
140 LIST_ENTRY BiosDiskListHead;
141
142 } PARTLIST, *PPARTLIST;
143
144 #define PARTITION_TBL_SIZE 4
145
146 #include <pshpack1.h>
147
148 typedef struct _PARTITION
149 {
150 unsigned char BootFlags; /* bootable? 0=no, 128=yes */
151 unsigned char StartingHead; /* beginning head number */
152 unsigned char StartingSector; /* beginning sector number */
153 unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */
154 unsigned char PartitionType; /* Operating System type indicator code */
155 unsigned char EndingHead; /* ending head number */
156 unsigned char EndingSector; /* ending sector number */
157 unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */
158 unsigned int StartingBlock; /* first sector relative to start of disk */
159 unsigned int SectorCount; /* number of sectors in partition */
160 } PARTITION, *PPARTITION;
161
162 typedef struct _PARTITION_SECTOR
163 {
164 UCHAR BootCode[440]; /* 0x000 */
165 ULONG Signature; /* 0x1B8 */
166 UCHAR Reserved[2]; /* 0x1BC */
167 PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */
168 USHORT Magic; /* 0x1FE */
169 } PARTITION_SECTOR, *PPARTITION_SECTOR;
170
171 #include <poppack.h>
172
173 typedef struct
174 {
175 LIST_ENTRY ListEntry;
176 ULONG DiskNumber;
177 ULONG Idendifier;
178 ULONG Signature;
179 } BIOS_DISK, *PBIOS_DISK;
180
181 PPARTLIST
182 CreatePartitionList (SHORT Left,
183 SHORT Top,
184 SHORT Right,
185 SHORT Bottom);
186
187 VOID
188 DestroyPartitionList (PPARTLIST List);
189
190 VOID
191 DrawPartitionList (PPARTLIST List);
192
193 DWORD
194 SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber);
195
196 BOOL
197 SetMountedDeviceValues(PPARTLIST List);
198
199 VOID
200 ScrollDownPartitionList (PPARTLIST List);
201
202 VOID
203 ScrollUpPartitionList (PPARTLIST List);
204
205 VOID
206 CreateNewPartition (PPARTLIST List,
207 ULONGLONG PartitionSize,
208 BOOLEAN AutoCreate);
209
210 VOID
211 DeleteCurrentPartition (PPARTLIST List);
212
213 VOID
214 CheckActiveBootPartition (PPARTLIST List);
215
216 BOOLEAN
217 CheckForLinuxFdiskPartitions (PPARTLIST List);
218
219 BOOLEAN
220 WritePartitionsToDisk (PPARTLIST List);
221
222 #endif /* __PARTLIST_H__ */
223
224 /* EOF */