OLD | NEW |
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
4 * | 4 * |
5 * Defines EFI related structure. See more details in EFI 2.3 spec. | 5 * Defines EFI related structure. See more details in EFI 2.3 spec. |
6 * | 6 * |
7 * To download EFI standard, please visit UEFI homepage: | 7 * To download EFI standard, please visit UEFI homepage: |
8 * http://www.uefi.org/ | 8 * http://www.uefi.org/ |
9 */ | 9 */ |
10 #ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_ | 10 #ifndef VBOOT_REFERENCE_CGPTLIB_GPT_H_ |
11 #define VBOOT_REFERENCE_CGPTLIB_GPT_H_ | 11 #define VBOOT_REFERENCE_CGPTLIB_GPT_H_ |
12 | 12 |
13 #include "sysincludes.h" | 13 #include "sysincludes.h" |
14 | 14 |
| 15 PACK_START /* Support packing for MSVC */ |
| 16 |
15 #define GPT_HEADER_SIGNATURE "EFI PART" | 17 #define GPT_HEADER_SIGNATURE "EFI PART" |
16 #define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE) | 18 #define GPT_HEADER_SIGNATURE_SIZE sizeof(GPT_HEADER_SIGNATURE) |
17 #define GPT_HEADER_REVISION 0x00010000 | 19 #define GPT_HEADER_REVISION 0x00010000 |
18 | 20 |
19 /* The first 3 numbers should be stored in network-endian format | 21 /* The first 3 numbers should be stored in network-endian format |
20 * according to the GUID RFC. The UEFI spec appendix A claims they | 22 * 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 | 23 * should be stored in little-endian format. But they need to be |
22 * _displayed_ in network-endian format, which is also how they're | 24 * _displayed_ in network-endian format, which is also how they're |
23 * documented in the specs. | 25 * documented in the specs. |
24 * | 26 * |
(...skipping 26 matching lines...) Expand all Loading... |
51 uint16_t time_mid; | 53 uint16_t time_mid; |
52 uint16_t time_high_and_version; | 54 uint16_t time_high_and_version; |
53 uint8_t clock_seq_high_and_reserved; | 55 uint8_t clock_seq_high_and_reserved; |
54 uint8_t clock_seq_low; | 56 uint8_t clock_seq_low; |
55 uint8_t node[UUID_NODE_LEN]; | 57 uint8_t node[UUID_NODE_LEN]; |
56 } Uuid; | 58 } Uuid; |
57 uint8_t raw[GUID_SIZE]; | 59 uint8_t raw[GUID_SIZE]; |
58 } u; | 60 } u; |
59 } __attribute__((packed)) Guid; | 61 } __attribute__((packed)) Guid; |
60 | 62 |
| 63 #define GUID_EXPECTED_SIZE GUID_SIZE |
| 64 |
61 /* Some constant values */ | 65 /* Some constant values */ |
62 extern const Guid guid_unused; | 66 extern const Guid guid_unused; |
63 extern const Guid guid_chromeos_kernel; | 67 extern const Guid guid_chromeos_kernel; |
64 | 68 |
65 /* GPT header defines how many partitions exist on a drive and sectors managed. | 69 /* 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. | 70 * For every drive device, there are 2 headers, primary and secondary. |
67 * Most of fields are duplicated except my_lba and entries_lba. | 71 * Most of fields are duplicated except my_lba and entries_lba. |
68 * | 72 * |
69 * You may find more details in chapter 5 of EFI standard. | 73 * You may find more details in chapter 5 of EFI standard. |
70 */ | 74 */ |
71 typedef struct { | 75 typedef struct { |
72 char signature[8]; | 76 char signature[8]; |
73 uint32_t revision; | 77 uint32_t revision; |
74 uint32_t size; | 78 uint32_t size; |
75 uint32_t header_crc32; | 79 uint32_t header_crc32; |
76 uint32_t reserved_zero; | 80 uint32_t reserved_zero; |
77 uint64_t my_lba; | 81 uint64_t my_lba; |
78 uint64_t alternate_lba; | 82 uint64_t alternate_lba; |
79 uint64_t first_usable_lba; | 83 uint64_t first_usable_lba; |
80 uint64_t last_usable_lba; | 84 uint64_t last_usable_lba; |
81 Guid disk_uuid; | 85 Guid disk_uuid; |
82 uint64_t entries_lba; | 86 uint64_t entries_lba; |
83 uint32_t number_of_entries; | 87 uint32_t number_of_entries; |
84 uint32_t size_of_entry; | 88 uint32_t size_of_entry; |
85 uint32_t entries_crc32; | 89 uint32_t entries_crc32; |
86 /* Remainder of sector is reserved and should be 0 */ | 90 /* Remainder of sector is reserved and should be 0 */ |
87 } __attribute__((packed)) GptHeader; | 91 } __attribute__((packed)) GptHeader; |
88 | 92 |
| 93 #define GPTHEADER_EXPECTED_SIZE 92 |
| 94 |
89 /* GPT partition entry defines the starting and ending LBAs of a partition. | 95 /* GPT partition entry defines the starting and ending LBAs of a partition. |
90 * It also contains the unique GUID, type, and attribute bits. | 96 * It also contains the unique GUID, type, and attribute bits. |
91 * | 97 * |
92 * You may find more details in chapter 5 of EFI standard. | 98 * You may find more details in chapter 5 of EFI standard. |
93 */ | 99 */ |
94 typedef struct { | 100 typedef struct { |
95 Guid type; | 101 Guid type; |
96 Guid unique; | 102 Guid unique; |
97 uint64_t starting_lba; | 103 uint64_t starting_lba; |
98 uint64_t ending_lba; | 104 uint64_t ending_lba; |
99 union { | 105 union { |
100 struct { | 106 struct { |
101 uint64_t : 48; | 107 uint16_t reserved[3]; |
102 uint16_t gpt_att : 16; | 108 uint16_t gpt_att; |
103 } __attribute__((packed)) fields; | 109 } __attribute__((packed)) fields; |
104 uint64_t whole; | 110 uint64_t whole; |
105 } attrs; | 111 } attrs; |
106 uint16_t name[36]; /* UTF-16 encoded partition name */ | 112 uint16_t name[36]; /* UTF-16 encoded partition name */ |
107 /* Remainder of entry is reserved and should be 0 */ | 113 /* Remainder of entry is reserved and should be 0 */ |
108 } __attribute__((packed)) GptEntry; | 114 } __attribute__((packed)) GptEntry; |
109 | 115 |
| 116 #define GPTENTRY_EXPECTED_SIZE 128 |
| 117 |
| 118 PACK_STOP /* Support packing for MSVC */ |
| 119 |
110 #endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */ | 120 #endif /* VBOOT_REFERENCE_CGPTLIB_GPT_H_ */ |
OLD | NEW |