2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2004,2007 Free Software Foundation, Inc.
5 * GRUB 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 3 of the License, or
8 * (at your option) any later version.
10 * GRUB 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.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_PC_PARTITION_HEADER
20 #define GRUB_PC_PARTITION_HEADER 1
22 #include <grub/symbol.h>
23 #include <grub/types.h>
25 #include <grub/disk.h>
26 #include <grub/partition.h>
29 #define GRUB_PC_PARTITION_SIGNATURE 0xaa55
31 /* This is not a flag actually, but used as if it were a flag. */
32 #define GRUB_PC_PARTITION_TYPE_HIDDEN_FLAG 0x10
34 /* DOS partition types. */
35 #define GRUB_PC_PARTITION_TYPE_NONE 0
36 #define GRUB_PC_PARTITION_TYPE_FAT12 1
37 #define GRUB_PC_PARTITION_TYPE_FAT16_LT32M 4
38 #define GRUB_PC_PARTITION_TYPE_EXTENDED 5
39 #define GRUB_PC_PARTITION_TYPE_FAT16_GT32M 6
40 #define GRUB_PC_PARTITION_TYPE_NTFS 7
41 #define GRUB_PC_PARTITION_TYPE_FAT32 0xb
42 #define GRUB_PC_PARTITION_TYPE_FAT32_LBA 0xc
43 #define GRUB_PC_PARTITION_TYPE_FAT16_LBA 0xe
44 #define GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED 0xf
45 #define GRUB_PC_PARTITION_TYPE_PLAN9 0x39
46 #define GRUB_PC_PARTITION_TYPE_LDM 0x42
47 #define GRUB_PC_PARTITION_TYPE_EZD 0x55
48 #define GRUB_PC_PARTITION_TYPE_MINIX 0x80
49 #define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81
50 #define GRUB_PC_PARTITION_TYPE_LINUX_SWAP 0x82
51 #define GRUB_PC_PARTITION_TYPE_EXT2FS 0x83
52 #define GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED 0x85
53 #define GRUB_PC_PARTITION_TYPE_VSTAFS 0x9e
54 #define GRUB_PC_PARTITION_TYPE_FREEBSD 0xa5
55 #define GRUB_PC_PARTITION_TYPE_OPENBSD 0xa6
56 #define GRUB_PC_PARTITION_TYPE_NETBSD 0xa9
57 #define GRUB_PC_PARTITION_TYPE_HFS 0xaf
58 #define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee
59 #define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd
61 /* The partition entry. */
62 struct grub_msdos_partition_entry
64 /* If active, 0x80, otherwise, 0x00. */
67 /* The head of the start. */
68 grub_uint8_t start_head
;
70 /* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
71 is the cylinder of the start. Note that S is counted from one. */
72 grub_uint8_t start_sector
;
74 /* (C & 0xFF) where C is the cylinder of the start. */
75 grub_uint8_t start_cylinder
;
77 /* The partition type. */
80 /* The end versions of start_head, start_sector and start_cylinder,
82 grub_uint8_t end_head
;
83 grub_uint8_t end_sector
;
84 grub_uint8_t end_cylinder
;
86 /* The start sector. Note that this is counted from zero. */
89 /* The length in sector units. */
93 /* The structure of MBR. */
94 struct grub_msdos_partition_mbr
96 /* The code area (actually, including BPB). */
97 grub_uint8_t code
[446];
99 /* Four partition entries. */
100 struct grub_msdos_partition_entry entries
[4];
102 /* The signature 0xaa55. */
103 grub_uint16_t signature
;
109 grub_msdos_partition_is_empty (int type
)
111 return (type
== GRUB_PC_PARTITION_TYPE_NONE
);
115 grub_msdos_partition_is_extended (int type
)
117 return (type
== GRUB_PC_PARTITION_TYPE_EXTENDED
118 || type
== GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED
119 || type
== GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED
);
123 grub_partition_msdos_iterate (grub_disk_t disk
,
124 grub_partition_iterate_hook_t hook
,
127 #endif /* ! GRUB_PC_PARTITION_HEADER */