Max OS 0.3
Loading...
Searching...
No Matches
msdos.h
Go to the documentation of this file.
1
9#ifndef MAXOS_FILESYSTEM_PARTITION_MSDOS_H
10#define MAXOS_FILESYSTEM_PARTITION_MSDOS_H
11
12#include <cstdint>
13#include <drivers/disk/disk.h>
16#include <filesystem/vfs.h>
17
18
19namespace MaxOS::filesystem::partition {
20
22 enum class PartitionType {
23 EMPTY, // 0x00
24 FAT12, // 0x01
25 XENIX_ROOT, // 0x02
26 XENIX_USR, // 0x03
27 FAT16, // 0x04
28 EXTENDED, // 0x05
29 FAT16_32MB, // 0x06
30 NTFS, // 0x07
31 QNX_QNY, // 0x08
32 AIX_DATA, // 0x09
33 OS2_BOOT_MANAGER, // 0x0A
34 FAT32, // 0x0B
35 FAT32_LBA, // 0x0C
36 UNUSED_1, // 0x0D
37 FAT16_LBA, // 0x0E
38 EXTENDED_LBA, // 0x0F
39 OPUS, // 0x10
40 FAT12_HIDDEN, // 0x11
41 COMPAQ, // 0x12
42 UNUSED_2, // 0x13
43 FAT16_HIDDEN, // 0x14
44 UNUSED_3, // 0x15
45 FAT16_32MB_HIDDEN, // 0x16
46 IFS_HIDDEN, // 0x17
47 AST_SMART_SLEEP, // 0x18
48 UNUSED_4, // 0x19
49 UNUSED_5, // 0x1A
50 FAT32_HIDDEN, // 0x1B
51 FAT32_LBA_HIDDEN, // 0x1C
52 UNUSED_6, // 0x1D
53 FAT16_LBA_HIDDEN, // 0x1E
54
55 UNUSED_7, // 0x1F
56 UNUSED_8, // 0x20
57 RESERVED_1, // 0x21
58 UNUSED_10, // 0x22
59 RESERVED_2, // 0x23
60 NEC_DOS, // 0x24
61 UNUSED_11, // 0x25
62 RESERVED_3, // 0x26
63
64 // 0x27 - 0x30: unassigned
65 UNUSED_12, // 0x27
66 UNUSED_13, // 0x28
67 UNUSED_14, // 0x29
68 UNUSED_15, // 0x2A
69 UNUSED_16, // 0x2B
70 UNUSED_17, // 0x2C
71 UNUSED_18, // 0x2D
72 UNUSED_19, // 0x2E
73 UNUSED_20, // 0x2F
74 UNUSED_21, // 0x30
75
76 RESERVED_4, // 0x31
77 NOS, // 0x32
78 RESERVED_5, // 0x33
79 RESERVED_6, // 0x34
80 JFS, // 0x35
81 RESERVED_7, // 0x36
82 UNUSED_22, // 0x37
83 THEOS_3_2, // 0x38
84 PLAN9, // 0x39
85 THEOS_4_4GB, // 0x3A
86 THEOS_4_EXTENDED, // 0x3B
87 PARTITIONMAGIC_RECOVERY, // 0x3C
88 HIDDEN_NETWARE, // 0x3D
89 UNUSED_23, // 0x3E
90 UNUSED_24, // 0x3F
91
92 VENIX, // 0x40
93 LINUX_MINIX, // 0x41
94 LINUX_SWAP, // 0x42
95 LINUX_NATIVE, // 0x43
96 GOBACK, // 0x44
97 BOOT_US, // 0x45
98 EUMEL_ELAN_46, // 0x46
99 EUMEL_ELAN_47, // 0x47
100 EUMEL_ELAN_48, // 0x48
101 UNUSED_25, // 0x49
102 ADAOS, // 0x4A
103 UNUSED_26, // 0x4B
104 OBERON, // 0x4C
105 QNX4, // 0x4D
106 QNX4_SECOND, // 0x4E
107 QNX4_THIRD, // 0x4F
108
109 ONTRACK_DM, // 0x50
110 ONTRACK_DM_RW, // 0x51
111 CPM, // 0x52
112 DISK_MANAGER_AUX3, // 0x53
113 DISK_MANAGER_DDO, // 0x54
114 EZ_DRIVE, // 0x55
115 GOLDEN_BOW, // 0x56
116 DRIVE_PRO, // 0x57
117
118 UNUSED_27, // 0x58
119 UNUSED_28, // 0x59
120 UNUSED_29, // 0x5A
121 UNUSED_30, // 0x5B
122 PRIAM_EDISK, // 0x5C
123 UNUSED_31, // 0x5D
124 UNUSED_32, // 0x5E
125 UNUSED_33, // 0x5F
126
127 UNUSED_34, // 0x60
128 SPEEDSTOR, // 0x61
129 UNUSED_35, // 0x62
130 UNIX, // 0x63
131 PC_ARMOUR, // 0x64
132 NOVELL_NETWARE386, // 0x65
133 NOVELL_SMS, // 0x66
134 NOVELL, // 0x67
135 NOVELL_OLD, // 0x68
136 NOVELL_NETWARE_NSS, // 0x69
137
138 UNUSED_36, // 0x6A
139 UNUSED_37, // 0x6B
140 UNUSED_38, // 0x6C
141 UNUSED_39, // 0x6D
142 UNUSED_40, // 0x6E
143 UNUSED_41, // 0x6F
144
145 DISKSECURE, // 0x70
146 RESERVED_8, // 0x71
147 UNUSED_42, // 0x72
148 RESERVED_9, // 0x73
149 SCRAMDISK, // 0x74
150 IBM_PCIX, // 0x75
151 RESERVED_10, // 0x76
152 M2FS, // 0x77
153 XOSL_FS, // 0x78
154 UNUSED_43, // 0x79
155 UNUSED_44, // 0x7A
156 UNUSED_45, // 0x7B
157 UNUSED_46, // 0x7C
158 UNUSED_47, // 0x7D
159 UNUSED_48, // 0x7E
160 UNUSED_49, // 0x7F
161
162 MINIX, // 0x80
163 MINIX2, // 0x81
164 LINUX_SWAP_ALT, // 0x82
165 LINUX_EXT2, // 0x83
166 HIBERNATION, // 0x84
167 LINUX_EXTENDED, // 0x85
168 LINUX_RAID, // 0x86
169 NTFS_VOLUME_SET, // 0x87
170 UNUSED_50, // 0x88
171 UNUSED_51, // 0x89
172 LINUX_KERNEL, // 0x8A
173 FAULT_TOLERANT_FAT32, // 0x8B
174 FT_FAT32_LBA, // 0x8C
175 FREEFDISK_FAT12, // 0x8D
176 LINUX_LVM, // 0x8E
177 UNUSED_52, // 0x8F
178 FREEFDISK_FAT16, // 0x90
179 FREEFDISK_EXTENDED, // 0x91
180 FREEFDISK_FAT16_LARGE, // 0x92
181 HIDDEN_LINUX_NATIVE, // 0x93
182 AMOEBA_BAD_BLOCK, // 0x94
183 MIT_EXOPC, // 0x95
184 UNUSED_53, // 0x96
185 FREEFDISK_FAT32, // 0x97
186 FREEFDISK_FAT32_LBA, // 0x98
187 DCE376, // 0x99
188 FREEFDISK_FAT16_LBA, // 0x9A
189 FREEFDISK_EXTENDED_LBA,// 0x9B
190
191 UNUSED_54, // 0x9C
192 UNUSED_55, // 0x9D
193 UNUSED_56, // 0x9E
194
195 BSD_OS, // 0x9F
196 LAPTOP_HIBERNATION, // 0xA0
197 HP_VOLUME_EXPANSION, // 0xA1
198 UNUSED_57, // 0xA2
199 RESERVED_11, // 0xA3
200 RESERVED_12, // 0xA4
201 BSD_386, // 0xA5
202 OPENBSD, // 0xA6
203 NEXTSTEP, // 0xA7
204 MAC_OS_X, // 0xA8
205 NETBSD, // 0xA9
206 OLIVETTI_SERVICE, // 0xAA
207 MAC_OS_X_BOOT, // 0xAB
208 UNUSED_58, // 0xAC
209 UNUSED_59, // 0xAD
210 SHAGOS, // 0xAE
211 SHAGOS_SWAP, // 0xAF
212 BOOTSTAR, // 0xB0
213
214 RESERVED_13, // 0xB1
215 UNUSED_60, // 0xB2
216 RESERVED_14, // 0xB3
217 RESERVED_15, // 0xB4
218 UNUSED_61, // 0xB5
219 RESERVED_16, // 0xB6
220
221 BSDI_BSD386_FS, // 0xB7
222 BSDI_BSD386_SWAP, // 0xB8
223 UNUSED_62, // 0xB9
224 UNUSED_63, // 0xBA
225 BOOT_WIZARD_HIDDEN, // 0xBB
226 UNUSED_64, // 0xBC
227 UNUSED_65, // 0xBD
228 SOLARIS8_BOOT, // 0xBE
229 UNUSED_66, // 0xBF
230 CTOS, // 0xC0
231 DRDOS_FAT12, // 0xC1
232 RESERVED_17, // 0xC2
233 HIDDEN_LINUX_SWAP, // 0xC3
234 DRDOS_FAT16, // 0xC4
235 DRDOS_EXTENDED, // 0xC5
236 DRDOS_FAT16_LARGE, // 0xC6
237 NTFS_CORRUPT, // 0xC7
238
239 UNUSED_67, // 0xC8
240 UNUSED_68, // 0xC9
241 UNUSED_69, // 0xCA
242
243 DRDOS_FAT32, // 0xCB
244 DRDOS_FAT32_LBA, // 0xCC
245 CTOS_MEMDUMP, // 0xCD
246 DRDOS_FAT16_LBA, // 0xCE
247 UNUSED_70, // 0xCF
248 REAL32_SECURE_BIG, // 0xD0
249 OLD_MULTIUSER_DOS_FAT12,// 0xD1
250 UNUSED_71, // 0xD2
251 UNUSED_72, // 0xD3
252 OLD_MULTIUSER_DOS_FAT16,// 0xD4
253 OLD_MULTIUSER_DOS_EXTENDED,// 0xD5
254 OLD_MULTIUSER_DOS_FAT16_LARGE,// 0xD6
255 UNUSED_73, // 0xD7
256 CPM86, // 0xD8
257 UNUSED_74, // 0xD9
258 NON_FS_DATA, // 0xDA
259 DIGITAL_RESEARCH_CPM, // 0xDB
260 UNUSED_75, // 0xDC
261 HIDDEN_CTOS_MEMDUMP, // 0xDD
262 DELL_POWEREDGE, // 0xDE
263 DGUX, // 0xDF
264 STM_AVFS, // 0xE0
265 SPEEDSTOR_FAT_EXTENDED,// 0xE1
266 UNUSED_76, // 0xE2
267 SPEEDSTOR_RO, // 0xE3
268 SPEEDSTOR_EXTENDED, // 0xE4
269 TANDY_DOS, // 0xE5
270
271 RESERVED_18, // 0xE6
272 UNUSED_77, // 0xE7
273 UNUSED_78, // 0xE8
274 UNUSED_79, // 0xE9
275
276 BEFS, // 0xEA
277 SPRYTIX, // 0xEB
278 EFI_PROTECTIVE, // 0xEE
279 EFI_SYSTEM, // 0xEF
280 LINUX_PA_RISC, // 0xF0
281 SPEEDSTOR_2, // 0xF1
282 DOS_3_3_SECONDARY, // 0xF2
283 RESERVED_19, // 0xF3
284 SPEEDSTOR_LARGE, // 0xF4
285 PROLOGUE_MULTI, // 0xF5
286 RESERVED_20, // 0xF6
287 UNUSED_80, // 0xF7
288 UNUSED_81, // 0xF8
289 UNUSED_82, // 0xF9
290 BOCHS, // 0xFA
291 VMFS, // 0xFB
292 VMWARE_SWAP, // 0xFC
293 LINUX_RAID_AUTO, // 0xFD
294 NT_HIDDEN, // 0xFE
295 XENIX_BAD_BLOCK // 0xFF
296 };
297
305 typedef struct PACKED PartitionTableEntry {
306
307 uint8_t bootable;
308
309 uint8_t start_head;
310 uint8_t start_sector : 6;
311 uint16_t start_cylinder : 10;
312
313 uint8_t type;
314
315 uint8_t end_head;
316 uint8_t end_sector : 6;
317 uint16_t end_cylinder : 10;
318
319 uint32_t start_LBA;
320 uint32_t length;
321
322 } partition_table_entry_t;
323
331 typedef struct PACKED MasterBootRecord {
332
333 uint8_t bootloader[440];
334 uint32_t disk_signature;
335 uint16_t unused;
336
337 PartitionTableEntry primary_partition[4];
338
339 uint16_t magic;
340
341 } master_boot_record_t;
342
343
351 public:
352 static void mount_partitions(drivers::disk::Disk* disk);
353 };
354}
355
356
357#endif //MAXOS_FILESYSTEM_PARTITION_MSDOS_H
Generic Disk, handles the reading and writing of data to the hard drive.
Definition disk.h:24
Handles mounting of partitions documented in an MSDOS partition table.
Definition msdos.h:350
static void mount_partitions(drivers::disk::Disk *disk)
read the partition table of a given hard disk
Definition msdos.cpp:23
Defines a generic Disk driver for reading and writing data to disk drives.
Defines structures and enums for the Extended 2 (ext2) filesystem format and relevant Filesystem,...
Defines structures and constants for the File Allocation Table 32 (FAT32) filesystem format and the r...
PartitionType
Credit: http://www.osdever.net/documents/pdf/partitiontypes.pdf.
Definition msdos.h:22
Stores information about the master boot record.
Definition msdos.h:331
uint16_t magic
The magic number that identifies this as a valid MBR (0xAA55)
Definition msdos.h:339
uint32_t disk_signature
Unique disk signature (optional)
Definition msdos.h:334
uint16_t unused
Reserved (usually zero)
Definition msdos.h:335
Stores information about a partition.
Definition msdos.h:305
uint8_t end_head
The last head of the partition.
Definition msdos.h:315
uint8_t start_head
The starting head of the partition.
Definition msdos.h:309
uint32_t start_LBA
The starting LBA of the partition.
Definition msdos.h:319
uint16_t start_cylinder
The starting cylinder of the partition.
Definition msdos.h:311
uint8_t start_sector
The first sector of the partition.
Definition msdos.h:310
uint8_t bootable
Is this partition bootable? (0x80 = bootable, 0x00 = not bootable)
Definition msdos.h:307
uint16_t end_cylinder
The last cylinder of the partition.
Definition msdos.h:317
uint32_t length
The length of the partition in sectors.
Definition msdos.h:320
uint8_t end_sector
The last sector of the partition.
Definition msdos.h:316
uint8_t type
The partition type (see PartitionType enum)
Definition msdos.h:313
Defines a Virtual File System (VFS) class for managing multiple filesystems and providing a unified i...