4 Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch@dell.com>
6 EFI GUID Partition Table handling
7 Per Intel EFI Specification v1.02
8 http://developer.intel.com/technology/efi/efi.htm
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
33 #define EFI_PMBR_OSTYPE_EFI 0xEF
34 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
35 #define MSDOS_MBR_SIGNATURE 0xaa55
36 #define GPT_BLOCK_SIZE 512
38 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
39 #define GPT_HEADER_REVISION_V1_02 0x00010200
40 #define GPT_HEADER_REVISION_V1_00 0x00010000
41 #define GPT_HEADER_REVISION_V0_99 0x00009900
42 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
44 typedef struct _gpt_header {
48 uint32_t header_crc32;
51 uint64_t alternate_lba;
52 uint64_t first_usable_lba;
53 uint64_t last_usable_lba;
55 uint64_t partition_entry_lba;
56 uint32_t num_partition_entries;
57 uint32_t sizeof_partition_entry;
58 uint32_t partition_entry_array_crc32;
59 uint8_t reserved2[GPT_BLOCK_SIZE - 92];
60 } __attribute__ ((packed)) gpt_header;
62 typedef struct _gpt_entry_attributes {
63 uint64_t required_to_function:1;
65 uint64_t type_guid_specific:16;
66 } __attribute__ ((packed)) gpt_entry_attributes;
68 typedef struct _gpt_entry {
69 efi_guid_t partition_type_guid;
70 efi_guid_t unique_partition_guid;
71 uint64_t starting_lba;
73 gpt_entry_attributes attributes;
74 efi_char16_t partition_name[72 / sizeof(efi_char16_t)];
75 } __attribute__ ((packed)) gpt_entry;
79 These values are only defaults. The actual on-disk structures
80 may define different sizes, so use those unless creating a new GPT disk!
83 #define GPT_DEFAULT_RESERVED_PARTITION_ENTRY_ARRAY_SIZE 16384
85 Number of actual partition entries should be calculated
88 #define GPT_DEFAULT_RESERVED_PARTITION_ENTRIES \
89 (GPT_DEFAULT_RESERVED_PARTITION_ENTRY_ARRAY_SIZE / \
93 /* Protected Master Boot Record & Legacy MBR share same structure */
94 /* Needs to be packed because the u16s force misalignment. */
96 typedef struct _legacy_mbr {
97 uint8_t bootcode[440];
98 uint32_t unique_mbr_signature;
100 struct partition partition[4];
102 } __attribute__ ((packed)) legacy_mbr;
105 #define EFI_GPT_PRIMARY_PARTITION_TABLE_LBA 1
108 int read_gpt_pt (int fd, struct slice all, struct slice *sp, int ns);
114 * Overrides for Emacs so that we follow Linus's tabbing style.
115 * Emacs will notice this stuff at the end of the file and automatically
116 * adjust the settings for this buffer only. This must remain at the end
118 * ---------------------------------------------------------------------------
121 * c-brace-imaginary-offset: 0
123 * c-argdecl-indent: 4
125 * c-continued-statement-offset: 4
126 * c-continued-brace-offset: 0
127 * indent-tabs-mode: nil