blob: cd5e12b9b7a5865d145a0cddf1b8212e8d11fe72 [file] [log] [blame]
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -07001/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 *
5 * Defines EFI related structure. See more details in EFI 2.3 spec.
6 *
7 * To download EFI standard, please visit UEFI homepage:
8 * http://www.uefi.org/
9 */
10#ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_
11#define VBOOT_REFERENCE_CGPTLIB_GPT_H_
12
Randall Spanglerf3029052010-06-16 13:42:58 -070013#include "sysincludes.h"
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070014
15#define GPT_HEADER_SIGNATURE "EFI PART"
16#define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE)
17#define GPT_HEADER_REVISION 0x00010000
18
Randall Spangler3dcf9dc2010-06-02 12:46:17 -070019/* The first 3 numbers should be stored in network-endian format
20 * according to the GUID RFC. The UEFI spec appendix A claims they
21 * should be stored in little-endian format. But they need to be
22 * _displayed_ in network-endian format, which is also how they're
23 * documented in the specs.
24 *
25 * Since what we have here are little-endian constants, they're
26 * byte-swapped from the normal display order. */
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070027#define GPT_ENT_TYPE_UNUSED \
Louis Yung-Chieh Lo49fa8e52010-04-30 16:10:48 -070028 {{{0x00000000,0x0000,0x0000,0x00,0x00,{0x00,0x00,0x00,0x00,0x00,0x00}}}}
Randall Spangler3dcf9dc2010-06-02 12:46:17 -070029#define GPT_ENT_TYPE_EFI \
Randall Spangler40226c02010-06-02 15:01:03 -070030 {{{0xc12a7328,0xf81f,0x11d2,0xba,0x4b,{0x00,0xa0,0xc9,0x3e,0xc9,0x3b}}}}
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070031#define GPT_ENT_TYPE_CHROMEOS_KERNEL \
Randall Spangler40226c02010-06-02 15:01:03 -070032 {{{0xfe3a2a5d,0x4f32,0x41a7,0xb7,0x25,{0xac,0xcc,0x32,0x85,0xa3,0x09}}}}
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070033#define GPT_ENT_TYPE_CHROMEOS_ROOTFS \
Randall Spangler40226c02010-06-02 15:01:03 -070034 {{{0x3cb8e202,0x3b7e,0x47dd,0x8a,0x3c,{0x7f,0xf2,0xa1,0x3c,0xfc,0xec}}}}
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070035#define GPT_ENT_TYPE_CHROMEOS_RESERVED \
Randall Spangler40226c02010-06-02 15:01:03 -070036 {{{0x2e0a753d,0x9e48,0x43b0,0x83,0x37,{0xb1,0x51,0x92,0xcb,0x1b,0x5e}}}}
Bill Richardson77d26e52010-06-04 12:26:42 -070037#define GPT_ENT_TYPE_LINUX_DATA \
38 {{{0xebd0a0a2,0xb9e5,0x4433,0x87,0xc0,{0x68,0xb6,0xb7,0x26,0x99,0xc7}}}}
Randall Spangler40226c02010-06-02 15:01:03 -070039
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070040
41#define UUID_NODE_LEN 6
42#define GUID_SIZE 16
43
44/* GUID definition.
45 * Defined in appendix A of EFI standard.
46 */
47typedef struct {
48 union {
49 struct {
50 uint32_t time_low;
51 uint16_t time_mid;
52 uint16_t time_high_and_version;
53 uint8_t clock_seq_high_and_reserved;
54 uint8_t clock_seq_low;
55 uint8_t node[UUID_NODE_LEN];
56 } Uuid;
57 uint8_t raw[GUID_SIZE];
Louis Yung-Chieh Lo49fa8e52010-04-30 16:10:48 -070058 } u;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070059} __attribute__((packed)) Guid;
60
Bill Richardson77d26e52010-06-04 12:26:42 -070061/* Some constant values */
62extern const Guid guid_unused;
63extern const Guid guid_chromeos_kernel;
64
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070065/* GPT header defines how many partitions exist on a drive and sectors managed.
66 * For every drive device, there are 2 headers, primary and secondary.
67 * Most of fields are duplicated except my_lba and entries_lba.
68 *
69 * You may find more details in chapter 5 of EFI standard.
70 */
71typedef struct {
72 char signature[8];
73 uint32_t revision;
74 uint32_t size;
75 uint32_t header_crc32;
Bill Richardsonf1372d92010-06-11 09:15:55 -070076 uint32_t reserved_zero;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070077 uint64_t my_lba;
78 uint64_t alternate_lba;
79 uint64_t first_usable_lba;
80 uint64_t last_usable_lba;
81 Guid disk_uuid;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070082 uint64_t entries_lba;
83 uint32_t number_of_entries;
84 uint32_t size_of_entry;
85 uint32_t entries_crc32;
Randall Spanglerd0dae7a2010-06-21 18:25:31 -070086 /* Remainder of sector is reserved and should be 0 */
Bill Richardson962483c2010-06-15 21:07:18 -070087} __attribute__((packed)) GptHeader;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -070088
89/* GPT partition entry defines the starting and ending LBAs of a partition.
90 * It also contains the unique GUID, type, and attribute bits.
91 *
92 * You may find more details in chapter 5 of EFI standard.
93 */
94typedef struct {
95 Guid type;
96 Guid unique;
97 uint64_t starting_lba;
98 uint64_t ending_lba;
vbendebf7a45cc2010-06-21 08:44:16 -070099 union {
100 struct {
101 uint64_t : 48;
102 uint16_t gpt_att : 16;
103 } __attribute__((packed)) fields;
104 uint64_t whole;
105 } attrs;
Bill Richardsonf1372d92010-06-11 09:15:55 -0700106 uint16_t name[36]; /* UTF-16 encoded partition name */
Randall Spanglerd0dae7a2010-06-21 18:25:31 -0700107 /* Remainder of entry is reserved and should be 0 */
Bill Richardson962483c2010-06-15 21:07:18 -0700108} __attribute__((packed)) GptEntry;
Louis Yung-Chieh Lo37f6b552010-04-22 21:22:22 -0700109
110#endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */