Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / msdos_partition.h
blob9c8ac3e8a8901bf627a44b9903e647eb0e90d2f4
1 /*
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>
24 #include <grub/err.h>
25 #include <grub/disk.h>
26 #include <grub/partition.h>
28 /* The signature. */
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_EZD 0x55
47 #define GRUB_PC_PARTITION_TYPE_MINIX 0x80
48 #define GRUB_PC_PARTITION_TYPE_LINUX_MINIX 0x81
49 #define GRUB_PC_PARTITION_TYPE_LINUX_SWAP 0x82
50 #define GRUB_PC_PARTITION_TYPE_EXT2FS 0x83
51 #define GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED 0x85
52 #define GRUB_PC_PARTITION_TYPE_VSTAFS 0x9e
53 #define GRUB_PC_PARTITION_TYPE_FREEBSD 0xa5
54 #define GRUB_PC_PARTITION_TYPE_OPENBSD 0xa6
55 #define GRUB_PC_PARTITION_TYPE_NETBSD 0xa9
56 #define GRUB_PC_PARTITION_TYPE_HFS 0xaf
57 #define GRUB_PC_PARTITION_TYPE_GPT_DISK 0xee
58 #define GRUB_PC_PARTITION_TYPE_LINUX_RAID 0xfd
60 /* The partition entry. */
61 struct grub_msdos_partition_entry
63 /* If active, 0x80, otherwise, 0x00. */
64 grub_uint8_t flag;
66 /* The head of the start. */
67 grub_uint8_t start_head;
69 /* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
70 is the cylinder of the start. Note that S is counted from one. */
71 grub_uint8_t start_sector;
73 /* (C & 0xFF) where C is the cylinder of the start. */
74 grub_uint8_t start_cylinder;
76 /* The partition type. */
77 grub_uint8_t type;
79 /* The end versions of start_head, start_sector and start_cylinder,
80 respectively. */
81 grub_uint8_t end_head;
82 grub_uint8_t end_sector;
83 grub_uint8_t end_cylinder;
85 /* The start sector. Note that this is counted from zero. */
86 grub_uint32_t start;
88 /* The length in sector units. */
89 grub_uint32_t length;
90 } __attribute__ ((packed));
92 /* The structure of MBR. */
93 struct grub_msdos_partition_mbr
95 /* The code area (actually, including BPB). */
96 grub_uint8_t code[446];
98 /* Four partition entries. */
99 struct grub_msdos_partition_entry entries[4];
101 /* The signature 0xaa55. */
102 grub_uint16_t signature;
103 } __attribute__ ((packed));
107 static inline int
108 grub_msdos_partition_is_empty (int type)
110 return (type == GRUB_PC_PARTITION_TYPE_NONE);
113 static inline int
114 grub_msdos_partition_is_extended (int type)
116 return (type == GRUB_PC_PARTITION_TYPE_EXTENDED
117 || type == GRUB_PC_PARTITION_TYPE_WIN95_EXTENDED
118 || type == GRUB_PC_PARTITION_TYPE_LINUX_EXTENDED);
121 grub_err_t
122 grub_partition_msdos_iterate (grub_disk_t disk,
123 int (*hook) (grub_disk_t disk,
124 const grub_partition_t partition));
126 #endif /* ! GRUB_PC_PARTITION_HEADER */