1 | /* $NetBSD: disklabel_gpt.h,v 1.12 2013/11/24 08:17:50 jnemeth Exp $ */ |
2 | |
3 | /* |
4 | * Copyright (c) 2002 Marcel Moolenaar |
5 | * All rights reserved. |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions |
9 | * are met: |
10 | * |
11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the |
15 | * documentation and/or other materials provided with the distribution. |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | * |
28 | * $FreeBSD: src/sys/sys/gpt.h,v 1.7 2004/08/02 18:46:52 marcel Exp $ |
29 | */ |
30 | |
31 | #ifndef _SYS_DISKLABEL_GPT_H_ |
32 | #define _SYS_DISKLABEL_GPT_H_ |
33 | |
34 | /* |
35 | * Definitions for the EFI GUID Partition Table disk partitioning scheme. |
36 | * |
37 | * NOTE: As EFI is an Intel specification, all fields are stored in |
38 | * little-endian byte-order. |
39 | */ |
40 | |
41 | /* |
42 | * GUID Partition Table Header |
43 | */ |
44 | struct gpt_hdr { |
45 | int8_t hdr_sig[8]; /* identifies GUID Partition Table */ |
46 | uint32_t hdr_revision; /* GPT specification revsion */ |
47 | uint32_t hdr_size; /* size of GPT Header */ |
48 | uint32_t hdr_crc_self; /* CRC32 of GPT Header */ |
49 | uint32_t hdr__rsvd0; /* must be zero */ |
50 | uint64_t hdr_lba_self; /* LBA that contains this Header */ |
51 | uint64_t hdr_lba_alt; /* LBA of backup GPT Header */ |
52 | uint64_t hdr_lba_start; /* first LBA usable for partitions */ |
53 | uint64_t hdr_lba_end; /* last LBA usable for partitions */ |
54 | uint8_t hdr_guid[16]; /* GUID to identify the disk */ |
55 | uint64_t hdr_lba_table; /* first LBA of GPE array */ |
56 | uint32_t hdr_entries; /* number of entries in GPE array */ |
57 | uint32_t hdr_entsz; /* size of each GPE */ |
58 | uint32_t hdr_crc_table; /* CRC32 of GPE array */ |
59 | /* |
60 | * The remainder of the block that contains the GPT Header |
61 | * is reserved by EFI for future GPT Header expansion, and |
62 | * must be zero. |
63 | */ |
64 | }; |
65 | |
66 | #define GPT_HDR_SIG "EFI PART" |
67 | #define GPT_HDR_REVISION 0x00010000 /* 1.0 */ |
68 | |
69 | #define GPT_HDR_BLKNO 1 |
70 | |
71 | #define GPT_HDR_SIZE 0x5c |
72 | |
73 | /* |
74 | * GUID Partition Entry |
75 | */ |
76 | struct gpt_ent { |
77 | uint8_t ent_type[16]; /* partition type GUID */ |
78 | uint8_t ent_guid[16]; /* unique partition GUID */ |
79 | uint64_t ent_lba_start; /* start of partition */ |
80 | uint64_t ent_lba_end; /* end of partition */ |
81 | uint64_t ent_attr; /* partition attributes */ |
82 | uint16_t ent_name[36]; /* partition name in UNICODE-16 */ |
83 | }; |
84 | |
85 | #define GPT_ENT_ATTR_REQUIRED_PARTITION (1ULL << 0) |
86 | /* required for platform to function */ |
87 | #define GPT_ENT_ATTR_NO_BLOCK_IO_PROTOCOL (1ULL << 1) |
88 | /* UEFI won't recognize file system */ |
89 | #define GPT_ENT_ATTR_LEGACY_BIOS_BOOTABLE (1ULL << 2) |
90 | /* legacy BIOS boot partition */ |
91 | /* The following three entries are from FreeBSD. */ |
92 | #define GPT_ENT_ATTR_BOOTME (1ULL << 59) |
93 | /* indicates a bootable partition */ |
94 | #define GPT_ENT_ATTR_BOOTONCE (1ULL << 58) |
95 | /* attempt to boot this partition only once */ |
96 | #define GPT_ENT_ATTR_BOOTFAILED (1ULL << 57) |
97 | /* partition that was marked bootonce but failed to boot */ |
98 | |
99 | /* |
100 | * Partition types defined by the EFI specification: |
101 | * |
102 | * GPT_ENT_TYPE_UNUSED Unused Entry |
103 | * GPT_ENT_TYPE_EFI EFI System Partition |
104 | * GPT_ENT_TYPE_MBR Partition containing legacy MBR |
105 | */ |
106 | #define GPT_ENT_TYPE_UNUSED \ |
107 | {0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}} |
108 | #define GPT_ENT_TYPE_EFI \ |
109 | {0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}} |
110 | #define GPT_ENT_TYPE_MBR \ |
111 | {0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}} |
112 | |
113 | /* |
114 | * Partition types defined by other operating systems. |
115 | */ |
116 | #define GPT_ENT_TYPE_NETBSD_SWAP \ |
117 | {0x49f48d32,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} |
118 | #define GPT_ENT_TYPE_NETBSD_FFS \ |
119 | {0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} |
120 | #define GPT_ENT_TYPE_NETBSD_LFS \ |
121 | {0x49f48d82,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} |
122 | #define GPT_ENT_TYPE_NETBSD_RAIDFRAME \ |
123 | {0x49f48daa,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} |
124 | #define GPT_ENT_TYPE_NETBSD_CCD \ |
125 | {0x2db519c4,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} |
126 | #define GPT_ENT_TYPE_NETBSD_CGD \ |
127 | {0x2db519ec,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}} |
128 | |
129 | #define GPT_ENT_TYPE_FREEBSD \ |
130 | {0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} |
131 | #define GPT_ENT_TYPE_FREEBSD_SWAP \ |
132 | {0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} |
133 | #define GPT_ENT_TYPE_FREEBSD_UFS \ |
134 | {0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} |
135 | #define GPT_ENT_TYPE_FREEBSD_VINUM \ |
136 | {0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} |
137 | #define GPT_ENT_TYPE_FREEBSD_ZFS \ |
138 | {0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} |
139 | /* |
140 | * The following are unused but documented here to avoid reuse. |
141 | * |
142 | * GPT_ENT_TYPE_FREEBSD_UFS2 \ |
143 | * {0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}} |
144 | */ |
145 | |
146 | #define GPT_ENT_TYPE_MS_RESERVED \ |
147 | {0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}} |
148 | #define GPT_ENT_TYPE_MS_BASIC_DATA \ |
149 | {0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}} |
150 | #define GPT_ENT_TYPE_MS_LDM_METADATA \ |
151 | {0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}} |
152 | #define GPT_ENT_TYPE_MS_LDM_DATA \ |
153 | {0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,{0x33,0x11,0x71,0x4a,0x69,0xad}} |
154 | |
155 | /* |
156 | * Linux originally used GPT_ENT_TYPE_MS_BASIC_DATA in place of |
157 | * GPT_ENT_TYPE_LINUX_DATA. |
158 | */ |
159 | #define GPT_ENT_TYPE_LINUX_DATA \ |
160 | {0x0fc63daf,0x8483,0x4772,0x8e,0x79,{0x3d,0x69,0xd8,0x47,0x7d,0xe4}} |
161 | #define GPT_ENT_TYPE_LINUX_RAID \ |
162 | {0xa19d880f,0x05fc,0x4d3b,0xa0,0x06,{0x74,0x3f,0x0f,0x84,0x91,0x1e}} |
163 | #define GPT_ENT_TYPE_LINUX_SWAP \ |
164 | {0x0657fd6d,0xa4ab,0x43c4,0x84,0xe5,{0x09,0x33,0xc8,0x4b,0x4f,0x4f}} |
165 | #define GPT_ENT_TYPE_LINUX_LVM \ |
166 | {0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}} |
167 | |
168 | #define GPT_ENT_TYPE_APPLE_HFS \ |
169 | {0x48465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} |
170 | #define GPT_ENT_TYPE_APPLE_UFS \ |
171 | {0x55465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}} |
172 | |
173 | /* |
174 | * Used by GRUB 2. |
175 | */ |
176 | #define GPT_ENT_TYPE_BIOS \ |
177 | {0x21686148,0x6449,0x6e6f,0x74,0x4e,{0x65,0x65,0x64,0x45,0x46,0x49}} |
178 | |
179 | #endif /* _SYS_DISKLABEL_GPT_H_ */ |
180 | |