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, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #define EFI_PMBR_OSTYPE_EFI 0xEF
35 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
36 #define MSDOS_MBR_SIGNATURE 0xaa55
37 #define GPT_BLOCK_SIZE 512
39 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
40 #define GPT_HEADER_REVISION_V1_02 0x00010200
41 #define GPT_HEADER_REVISION_V1_00 0x00010000
42 #define GPT_HEADER_REVISION_V0_99 0x00009900
43 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
45 typedef struct _gpt_header {
49 uint32_t header_crc32;
52 uint64_t alternate_lba;
53 uint64_t first_usable_lba;
54 uint64_t last_usable_lba;
56 uint64_t partition_entry_lba;
57 uint32_t num_partition_entries;
58 uint32_t sizeof_partition_entry;
59 uint32_t partition_entry_array_crc32;
60 uint8_t reserved2[GPT_BLOCK_SIZE - 92];
61 } __attribute__ ((packed)) gpt_header;
63 typedef struct _gpt_entry_attributes {
64 uint64_t required_to_function:1;
66 uint64_t type_guid_specific:16;
67 } __attribute__ ((packed)) gpt_entry_attributes;
69 typedef struct _gpt_entry {
70 efi_guid_t partition_type_guid;
71 efi_guid_t unique_partition_guid;
72 uint64_t starting_lba;
74 gpt_entry_attributes attributes;
75 efi_char16_t partition_name[72 / sizeof(efi_char16_t)];
76 } __attribute__ ((packed)) gpt_entry;
80 These values are only defaults. The actual on-disk structures
81 may define different sizes, so use those unless creating a new GPT disk!
84 #define GPT_DEFAULT_RESERVED_PARTITION_ENTRY_ARRAY_SIZE 16384
86 Number of actual partition entries should be calculated
89 #define GPT_DEFAULT_RESERVED_PARTITION_ENTRIES \
90 (GPT_DEFAULT_RESERVED_PARTITION_ENTRY_ARRAY_SIZE / \
94 /* Protected Master Boot Record & Legacy MBR share same structure */
95 /* Needs to be packed because the u16s force misalignment. */
97 typedef struct _legacy_mbr {
98 uint8_t bootcode[440];
99 uint32_t unique_mbr_signature;
101 struct partition partition[4];
103 } __attribute__ ((packed)) legacy_mbr;
106 #define EFI_GPT_PRIMARY_PARTITION_TABLE_LBA 1
109 int read_gpt_pt (int fd, struct slice all, struct slice *sp, int ns);
115 * Overrides for Emacs so that we follow Linus's tabbing style.
116 * Emacs will notice this stuff at the end of the file and automatically
117 * adjust the settings for this buffer only. This must remain at the end
119 * ---------------------------------------------------------------------------
122 * c-brace-imaginary-offset: 0
124 * c-argdecl-indent: 4
126 * c-continued-statement-offset: 4
127 * c-continued-brace-offset: 0
128 * indent-tabs-mode: nil