1139825Simp/*-
297392Smarcel * Copyright (c) 2002 Marcel Moolenaar
397392Smarcel * All rights reserved.
497392Smarcel *
597392Smarcel * Redistribution and use in source and binary forms, with or without
697392Smarcel * modification, are permitted provided that the following conditions
797392Smarcel * are met:
897392Smarcel *
997392Smarcel * 1. Redistributions of source code must retain the above copyright
1097392Smarcel *    notice, this list of conditions and the following disclaimer.
1197392Smarcel * 2. Redistributions in binary form must reproduce the above copyright
1297392Smarcel *    notice, this list of conditions and the following disclaimer in the
1397392Smarcel *    documentation and/or other materials provided with the distribution.
1497392Smarcel *
1597392Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1697392Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1797392Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1897392Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1997392Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2097392Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2197392Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2297392Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2397392Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2497392Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2597392Smarcel *
2697392Smarcel * $FreeBSD$
2797392Smarcel */
2897392Smarcel
2997392Smarcel#ifndef _SYS_GPT_H_
3097392Smarcel#define	_SYS_GPT_H_
3197392Smarcel
32106739Smarcel#include <sys/uuid.h>
33106739Smarcel
3497392Smarcelstruct gpt_hdr {
3597392Smarcel	char		hdr_sig[8];
3697392Smarcel#define	GPT_HDR_SIG		"EFI PART"
3797392Smarcel	uint32_t	hdr_revision;
3897392Smarcel#define	GPT_HDR_REVISION	0x00010000
3997392Smarcel	uint32_t	hdr_size;
4097392Smarcel	uint32_t	hdr_crc_self;
4197392Smarcel	uint32_t	__reserved;
4297392Smarcel	uint64_t	hdr_lba_self;
4397392Smarcel	uint64_t	hdr_lba_alt;
4497392Smarcel	uint64_t	hdr_lba_start;
4597392Smarcel	uint64_t	hdr_lba_end;
4697392Smarcel	struct uuid	hdr_uuid;
4797392Smarcel	uint64_t	hdr_lba_table;
4897392Smarcel	uint32_t	hdr_entries;
4997392Smarcel	uint32_t	hdr_entsz;
5097392Smarcel	uint32_t	hdr_crc_table;
5197644Smarcel	/*
5297644Smarcel	 * The header as defined in the EFI spec is not a multiple of 8 bytes
5397644Smarcel	 * and given that the alignment requirement is on an 8 byte boundary,
5497644Smarcel	 * padding will happen. We make the padding explicit so that we can
5597644Smarcel	 * correct the value returned by sizeof() when we put the size of the
5697644Smarcel	 * header in field hdr_size, or otherwise use offsetof().
5797644Smarcel	 */
5897644Smarcel	uint32_t	padding;
5997537Smarcel};
6097392Smarcel
6197392Smarcelstruct gpt_ent {
6297392Smarcel	struct uuid	ent_type;
6397392Smarcel	struct uuid	ent_uuid;
6497392Smarcel	uint64_t	ent_lba_start;
6597392Smarcel	uint64_t	ent_lba_end;
6697392Smarcel	uint64_t	ent_attr;
6797392Smarcel#define	GPT_ENT_ATTR_PLATFORM		(1ULL << 0)
68213133Spjd#define	GPT_ENT_ATTR_BOOTME		(1ULL << 59)
69213133Spjd#define	GPT_ENT_ATTR_BOOTONCE		(1ULL << 58)
70213133Spjd#define	GPT_ENT_ATTR_BOOTFAILED		(1ULL << 57)
71150239Smarcel	uint16_t	ent_name[36];		/* UTF-16. */
7297392Smarcel};
7397392Smarcel
7497392Smarcel#define	GPT_ENT_TYPE_UNUSED		\
7597392Smarcel	{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}
7697392Smarcel#define	GPT_ENT_TYPE_EFI		\
7797392Smarcel	{0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}
7897392Smarcel#define	GPT_ENT_TYPE_MBR		\
7997392Smarcel	{0x024dee41,0x33e7,0x11d3,0x9d,0x69,{0x00,0x08,0xc7,0x81,0xf3,0x9f}}
8097392Smarcel#define	GPT_ENT_TYPE_FREEBSD		\
8197392Smarcel	{0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
82236023Smarcel#define	GPT_ENT_TYPE_FREEBSD_BOOT	\
83236023Smarcel	{0x83bd6b9d,0x7f41,0x11dc,0xbe,0x0b,{0x00,0x15,0x60,0xb8,0x4f,0x0f}}
84236023Smarcel#define	GPT_ENT_TYPE_FREEBSD_NANDFS	\
85236023Smarcel	{0x74ba7dd9,0xa689,0x11e1,0xbd,0x04,{0x00,0xe0,0x81,0x28,0x6a,0xcf}}
8697392Smarcel#define	GPT_ENT_TYPE_FREEBSD_SWAP	\
8797392Smarcel	{0x516e7cb5,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
8897392Smarcel#define	GPT_ENT_TYPE_FREEBSD_UFS	\
8997392Smarcel	{0x516e7cb6,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
9097392Smarcel#define	GPT_ENT_TYPE_FREEBSD_VINUM	\
9197392Smarcel	{0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
92172853Smarcel#define	GPT_ENT_TYPE_FREEBSD_ZFS	\
93172853Smarcel	{0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
94268256Snwhitehorn#define	GPT_ENT_TYPE_PREP_BOOT		\
95268256Snwhitehorn	{0x9e1a2d38,0xc612,0x4316,0xaa,0x26,{0x8b,0x49,0x52,0x1e,0x5a,0x8b}}
9697392Smarcel
97106390Smarcel/*
98133024Smarcel * The following are unused but documented here to avoid reuse.
99133024Smarcel *
100133024Smarcel * GPT_ENT_TYPE_FREEBSD_UFS2	\
101133024Smarcel *	{0x516e7cb7,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
102133024Smarcel */
103133024Smarcel
104133024Smarcel/*
105106390Smarcel * Foreign partition types that we're likely to encounter. Note that Linux
106106390Smarcel * apparently choose to share data partitions with MS. I don't what the
107172940Sjhb * advantage might be. I can see how sharing swap partitions is advantageous
108106390Smarcel * though.
109106390Smarcel */
110106390Smarcel#define	GPT_ENT_TYPE_MS_BASIC_DATA	\
111106390Smarcel	{0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}}
112292788Sallanjude#define	GPT_ENT_TYPE_MS_LDM_DATA	\
113292788Sallanjude	{0xaf9b60a0,0x1431,0x4f62,0xbc,0x68,{0x33,0x11,0x71,0x4a,0x69,0xad}}
114106390Smarcel#define	GPT_ENT_TYPE_MS_LDM_METADATA	\
115106390Smarcel	{0x5808c8aa,0x7e8f,0x42e0,0x85,0xd2,{0xe1,0xe9,0x04,0x34,0xcf,0xb3}}
116292788Sallanjude#define	GPT_ENT_TYPE_MS_RECOVERY	\
117292788Sallanjude	{0xde94bba4,0x06d1,0x4d40,0xa1,0x6a,{0xbf,0xd5,0x01,0x79,0xd6,0xac}}
118292788Sallanjude#define	GPT_ENT_TYPE_MS_RESERVED	\
119292788Sallanjude	{0xe3c9e316,0x0b5c,0x4db8,0x81,0x7d,{0xf9,0x2d,0xf0,0x02,0x15,0xae}}
120292788Sallanjude#define	GPT_ENT_TYPE_MS_SPACES	\
121292788Sallanjude	{0xe75caf8f,0xf680,0x4cee,0xaf,0xa3,{0xb0,0x01,0xe5,0x6e,0xfc,0x2d}}
122106390Smarcel
123268089Sae#define	GPT_ENT_TYPE_LINUX_DATA		\
124268089Sae	{0x0fc63daf,0x8483,0x4772,0x8e,0x79,{0x3d,0x69,0xd8,0x47,0x7d,0xe4}}
125106390Smarcel#define	GPT_ENT_TYPE_LINUX_RAID		\
126106390Smarcel	{0xa19d880f,0x05fc,0x4d3b,0xa0,0x06,{0x74,0x3f,0x0f,0x84,0x91,0x1e}}
127106390Smarcel#define	GPT_ENT_TYPE_LINUX_SWAP		\
128106390Smarcel	{0x0657fd6d,0xa4ab,0x43c4,0x84,0xe5,{0x09,0x33,0xc8,0x4b,0x4f,0x4f}}
129106390Smarcel#define	GPT_ENT_TYPE_LINUX_LVM		\
130106390Smarcel	{0xe6d6d379,0xf507,0x44c2,0xa2,0x3c,{0x23,0x8f,0x2a,0x3d,0xf9,0x28}}
131106390Smarcel
132234417Smarck#define	GPT_ENT_TYPE_VMFS		\
133234417Smarck	{0xaa31e02a,0x400f,0x11db,0x95,0x90,{0x00,0x0c,0x29,0x11,0xd1,0xb8}}
134234417Smarck#define	GPT_ENT_TYPE_VMKDIAG		\
135234417Smarck	{0x9d275380,0x40ad,0x11db,0xbf,0x97,{0x00,0x0c,0x29,0x11,0xd1,0xb8}}
136234417Smarck#define	GPT_ENT_TYPE_VMRESERVED		\
137234417Smarck	{0x9198effc,0x31c0,0x11db,0x8f,0x78,{0x00,0x0c,0x29,0x11,0xd1,0xb8}}
138259938Savatar#define	GPT_ENT_TYPE_VMVSANHDR		\
139259925Smarck	{0x381cfccc,0x7288,0x11e0,0x92,0xee,{0x00,0x0c,0x29,0x11,0xd0,0xb2}}
140234417Smarck
141200535Srpaulo#define	GPT_ENT_TYPE_APPLE_BOOT		\
142200535Srpaulo	{0x426F6F74,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
143159866Smarcel#define	GPT_ENT_TYPE_APPLE_HFS		\
144159866Smarcel	{0x48465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
145182796Srpaulo#define	GPT_ENT_TYPE_APPLE_UFS		\
146182796Srpaulo	{0x55465300,0x0000,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
147182796Srpaulo#define	GPT_ENT_TYPE_APPLE_ZFS		\
148182796Srpaulo	{0x6a898cc3,0x1dd2,0x11b2,0x99,0xa6,{0x08,0x00,0x20,0x73,0x66,0x31}}
149182796Srpaulo#define	GPT_ENT_TYPE_APPLE_RAID		\
150182796Srpaulo	{0x52414944,0x0000,0x11aa,0xaa,0x22,{0x00,0x30,0x65,0x43,0xec,0xac}}
151182796Srpaulo#define	GPT_ENT_TYPE_APPLE_RAID_OFFLINE	\
152182796Srpaulo	{0x52414944,0x5f4f,0x11aa,0xaa,0x22,{0x00,0x30,0x65,0x43,0xec,0xac}}
153200535Srpaulo#define GPT_ENT_TYPE_APPLE_LABEL	\
154200535Srpaulo    	{0x4C616265,0x6c00,0x11aa,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
155200535Srpaulo#define	GPT_ENT_TYPE_APPLE_TV_RECOVERY	\
156200535Srpaulo    	{0x5265636f,0x7665,0x11AA,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
157279935Sae#define	GPT_ENT_TYPE_APPLE_CORE_STORAGE	\
158279935Sae	{0x53746f72,0x6167,0x11AA,0xaa,0x11,{0x00,0x30,0x65,0x43,0xec,0xac}}
159159866Smarcel
160182796Srpaulo#define	GPT_ENT_TYPE_NETBSD_FFS		\
161182796Srpaulo	{0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
162182796Srpaulo#define	GPT_ENT_TYPE_NETBSD_LFS		\
163182796Srpaulo	{0x49f48d82,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
164182796Srpaulo#define	GPT_ENT_TYPE_NETBSD_SWAP	\
165182796Srpaulo	{0x49f48d32,0xb10e,0x11dc,0xB9,0x9B,{0x00,0x19,0xd1,0x87,0x96,0x48}}
166182796Srpaulo#define	GPT_ENT_TYPE_NETBSD_RAID	\
167182796Srpaulo	{0x49f48daa,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
168182796Srpaulo#define	GPT_ENT_TYPE_NETBSD_CCD		\
169182796Srpaulo	{0x2db519c4,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
170182796Srpaulo#define	GPT_ENT_TYPE_NETBSD_CGD		\
171182796Srpaulo	{0x2db519ec,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
172182796Srpaulo
173267355Sae#define GPT_ENT_TYPE_DRAGONFLY_LABEL32	\
174267355Sae	{0x9d087404,0x1ca5,0x11dc,0x88,0x17,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
175267355Sae#define GPT_ENT_TYPE_DRAGONFLY_SWAP	\
176267355Sae	{0x9d58fdbd,0x1ca5,0x11dc,0x88,0x17,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
177267355Sae#define GPT_ENT_TYPE_DRAGONFLY_UFS1	\
178267355Sae	{0x9d94ce7c,0x1ca5,0x11dc,0x88,0x17,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
179267355Sae#define GPT_ENT_TYPE_DRAGONFLY_VINUM	\
180267355Sae	{0x9dd4478f,0x1ca5,0x11dc,0x88,0x17,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
181267355Sae#define GPT_ENT_TYPE_DRAGONFLY_CCD	\
182267355Sae	{0xdbd5211b,0x1ca5,0x11dc,0x88,0x17,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
183267355Sae#define GPT_ENT_TYPE_DRAGONFLY_LABEL64	\
184267355Sae	{0x3d48ce54,0x1d16,0x11dc,0x86,0x96,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
185267355Sae#define GPT_ENT_TYPE_DRAGONFLY_LEGACY	\
186267355Sae	{0xbd215ab2,0x1d16,0x11dc,0x86,0x96,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
187267355Sae#define GPT_ENT_TYPE_DRAGONFLY_HAMMER	\
188267355Sae	{0x61dc63ac,0x6e38,0x11dc,0x85,0x13,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
189267355Sae#define GPT_ENT_TYPE_DRAGONFLY_HAMMER2	\
190267355Sae	{0x5cbb9ad1,0x862d,0x11dc,0xa9,0x4d,{0x01,0x30,0x1b,0xb8,0xa9,0xf5}}
191267355Sae
192292788Sallanjude#define GPT_ENT_TYPE_CHROMEOS_FIRMWARE	\
193292788Sallanjude	{0xcab6e88e,0xabf3,0x4102,0xa0,0x7a,{0xd4,0xbb,0x9b,0xe3,0xc1,0xd3}}
194292788Sallanjude#define GPT_ENT_TYPE_CHROMEOS_KERNEL	\
195292788Sallanjude	{0xfe3a2a5d,0x4f32,0x41a7,0xb7,0x25,{0xac,0xcc,0x32,0x85,0xa3,0x09}}
196292788Sallanjude#define GPT_ENT_TYPE_CHROMEOS_RESERVED	\
197292788Sallanjude	{0x2e0a753d,0x9e48,0x43b0,0x83,0x37,{0xb1,0x51,0x92,0xcb,0x1b,0x5e}}
198292788Sallanjude#define GPT_ENT_TYPE_CHROMEOS_ROOT	\
199292788Sallanjude	{0x3cb8e202,0x3b7e,0x47dd,0x8a,0x3c,{0x7f,0xf2,0xa1,0x3c,0xfc,0xec}}
200292788Sallanjude
201292788Sallanjude#define GPT_ENT_TYPE_OPENBSD_DATA	\
202292788Sallanjude	{0x824cc7a0,0x36a8,0x11e3,0x89,0x0a,{0x95,0x25,0x19,0xad,0x3f,0x61}}
203292788Sallanjude
204218014Sae/*
205218014Sae * Boot partition used by GRUB 2.
206218014Sae */
207218014Sae#define	GPT_ENT_TYPE_BIOS_BOOT		\
208218014Sae	{0x21686148,0x6449,0x6e6f,0x74,0x4e,{0x65,0x65,0x64,0x45,0x46,0x49}}
209218014Sae
21097392Smarcel#endif /* _SYS_GPT_H_ */
211