]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/include/spdk/gpt_spec.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / spdk / include / spdk / gpt_spec.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright (c) Intel Corporation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
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
16 * distribution.
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.
20 *
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.
32 */
33
34 /**
35 * \file
36 * GUID Partition Table (GPT) specification definitions
37 */
38
39 #ifndef SPDK_GPT_SPEC_H
40 #define SPDK_GPT_SPEC_H
41
42 #include <stdint.h>
43
44 #include "spdk/assert.h"
45
46 #pragma pack(push, 1)
47
48 #define SPDK_MBR_SIGNATURE 0xAA55
49
50 #define SPDK_MBR_OS_TYPE_GPT_PROTECTIVE 0xEE
51 #define SPDK_MBR_OS_TYPE_EFI_SYSTEM_PARTITION 0xEF
52
53 struct spdk_mbr_chs {
54 uint8_t head;
55 uint16_t sector : 6;
56 uint16_t cylinder : 10;
57 };
58 SPDK_STATIC_ASSERT(sizeof(struct spdk_mbr_chs) == 3, "size incorrect");
59
60 struct spdk_mbr_partition_entry {
61 uint8_t reserved : 7;
62 uint8_t bootable : 1;
63
64 struct spdk_mbr_chs start_chs;
65
66 uint8_t os_type;
67
68 struct spdk_mbr_chs end_chs;
69
70 uint32_t start_lba;
71 uint32_t size_lba;
72 };
73 SPDK_STATIC_ASSERT(sizeof(struct spdk_mbr_partition_entry) == 16, "size incorrect");
74
75 struct spdk_mbr {
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;
81 };
82 SPDK_STATIC_ASSERT(sizeof(struct spdk_mbr) == 512, "size incorrect");
83
84 #define SPDK_GPT_SIGNATURE "EFI PART"
85
86 #define SPDK_GPT_REVISION_1_0 0x00010000u
87
88 struct spdk_gpt_guid {
89 uint8_t raw[16];
90 };
91 SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_guid) == 16, "size incorrect");
92
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) \
102 }}
103
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)
107
108 struct spdk_gpt_header {
109 char gpt_signature[8];
110 uint32_t revision;
111 uint32_t header_size;
112 uint32_t header_crc32;
113 uint32_t reserved;
114 uint64_t my_lba;
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;
123 };
124 SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_header) == 92, "size incorrect");
125
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;
130 uint64_t ending_lba;
131 struct {
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;
137 } attr;
138 uint8_t partition_name[72];
139 };
140 SPDK_STATIC_ASSERT(sizeof(struct spdk_gpt_partition_entry) == 128, "size incorrect");
141
142 #pragma pack(pop)
143
144 #endif