4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * GUID Partition Table (GPT) specification definitions
39 #ifndef SPDK_GPT_SPEC_H
40 #define SPDK_GPT_SPEC_H
44 #include "spdk/assert.h"
48 #define SPDK_MBR_SIGNATURE 0xAA55
50 #define SPDK_MBR_OS_TYPE_GPT_PROTECTIVE 0xEE
51 #define SPDK_MBR_OS_TYPE_EFI_SYSTEM_PARTITION 0xEF
56 uint16_t cylinder
: 10;
58 SPDK_STATIC_ASSERT(sizeof(struct spdk_mbr_chs
) == 3, "size incorrect");
60 struct spdk_mbr_partition_entry
{
64 struct spdk_mbr_chs start_chs
;
68 struct spdk_mbr_chs end_chs
;
73 SPDK_STATIC_ASSERT(sizeof(struct spdk_mbr_partition_entry
) == 16, "size incorrect");
76 uint8_t boot_code
[440];
77 uint32_t disk_signature
;
78 uint16_t reserved_444
;
79 struct spdk_mbr_partition_entry partitions
[4];
80 uint16_t mbr_signature
;
82 SPDK_STATIC_ASSERT(sizeof(struct spdk_mbr
) == 512, "size incorrect");
84 #define SPDK_GPT_SIGNATURE "EFI PART"
86 #define SPDK_GPT_REVISION_1_0 0x00010000u
88 struct spdk_gpt_guid
{
91 SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_guid
) == 16, "size incorrect");
93 #define SPDK_GPT_GUID(a, b, c, d, e) \
94 (struct spdk_gpt_guid){{ \
95 (uint8_t)(a), (uint8_t)(((uint32_t)a) >> 8), \
96 (uint8_t)(((uint32_t)a) >> 16), (uint8_t)(((uint32_t)a >> 24)), \
97 (uint8_t)(b), (uint8_t)(((uint16_t)b) >> 8), \
98 (uint8_t)(c), (uint8_t)(((uint16_t)c) >> 8), \
99 (uint8_t)(((uint16_t)d) >> 8), (uint8_t)(d), \
100 (uint8_t)(((uint64_t)e) >> 40), (uint8_t)(((uint64_t)e) >> 32), (uint8_t)(((uint64_t)e) >> 24), \
101 (uint8_t)(((uint64_t)e) >> 16), (uint8_t)(((uint64_t)e) >> 8), (uint8_t)(e) \
104 #define SPDK_GPT_PART_TYPE_UNUSED SPDK_GPT_GUID(0x00000000, 0x0000, 0x0000, 0x0000, 0x000000000000)
105 #define SPDK_GPT_PART_TYPE_EFI_SYSTEM_PARTITION SPDK_GPT_GUID(0xC12A7328, 0xF81F, 0x11D2, 0xBA4B, 0x00A0C93EC93B)
106 #define SPDK_GPT_PART_TYPE_LEGACY_MBR SPDK_GPT_GUID(0x024DEE41, 0x33E7, 0x11D3, 0x9D69, 0x0008C781F39F)
108 struct spdk_gpt_header
{
109 char gpt_signature
[8];
111 uint32_t header_size
;
112 uint32_t header_crc32
;
115 uint64_t alternate_lba
;
116 uint64_t first_usable_lba
;
117 uint64_t last_usable_lba
;
118 struct spdk_gpt_guid disk_guid
;
119 uint64_t partition_entry_lba
;
120 uint32_t num_partition_entries
;
121 uint32_t size_of_partition_entry
;
122 uint32_t partition_entry_array_crc32
;
124 SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_header
) == 92, "size incorrect");
126 struct spdk_gpt_partition_entry
{
127 struct spdk_gpt_guid part_type_guid
;
128 struct spdk_gpt_guid unique_partition_guid
;
129 uint64_t starting_lba
;
132 uint64_t required
: 1;
133 uint64_t no_block_io_proto
: 1;
134 uint64_t legacy_bios_bootable
: 1;
135 uint64_t reserved_uefi
: 45;
136 uint64_t guid_specific
: 16;
138 uint8_t partition_name
[72];
140 SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_partition_entry
) == 128, "size incorrect");