1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef FS_PART_EFI_H_INCLUDED
26#define FS_PART_EFI_H_INCLUDED
27
28#include <linux/types.h>
29#include <linux/fs.h>
30#include <linux/genhd.h>
31#include <linux/kernel.h>
32#include <linux/major.h>
33#include <linux/string.h>
34#include <linux/efi.h>
35#include <linux/compiler.h>
36
37#define MSDOS_MBR_SIGNATURE 0xaa55
38#define EFI_PMBR_OSTYPE_EFI 0xEF
39#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
40
41#define GPT_MBR_PROTECTIVE 1
42#define GPT_MBR_HYBRID 2
43
44#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
45#define GPT_HEADER_REVISION_V1 0x00010000
46#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
47
48#define PARTITION_SYSTEM_GUID \
49 EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
50 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B)
51#define LEGACY_MBR_PARTITION_GUID \
52 EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
53 0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
54#define PARTITION_MSFT_RESERVED_GUID \
55 EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
56 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
57#define PARTITION_BASIC_DATA_GUID \
58 EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
59 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
60#define PARTITION_LINUX_RAID_GUID \
61 EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
62 0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
63#define PARTITION_LINUX_SWAP_GUID \
64 EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
65 0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
66#define PARTITION_LINUX_LVM_GUID \
67 EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
68 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
69
70typedef struct _gpt_header {
71 __le64 signature;
72 __le32 revision;
73 __le32 header_size;
74 __le32 header_crc32;
75 __le32 reserved1;
76 __le64 my_lba;
77 __le64 alternate_lba;
78 __le64 first_usable_lba;
79 __le64 last_usable_lba;
80 efi_guid_t disk_guid;
81 __le64 partition_entry_lba;
82 __le32 num_partition_entries;
83 __le32 sizeof_partition_entry;
84 __le32 partition_entry_array_crc32;
85
86
87
88
89
90
91} __packed gpt_header;
92
93typedef struct _gpt_entry_attributes {
94 u64 required_to_function:1;
95 u64 reserved:47;
96 u64 type_guid_specific:16;
97} __packed gpt_entry_attributes;
98
99typedef struct _gpt_entry {
100 efi_guid_t partition_type_guid;
101 efi_guid_t unique_partition_guid;
102 __le64 starting_lba;
103 __le64 ending_lba;
104 gpt_entry_attributes attributes;
105 efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
106} __packed gpt_entry;
107
108typedef struct _gpt_mbr_record {
109 u8 boot_indicator;
110 u8 start_head;
111 u8 start_sector;
112 u8 start_track;
113 u8 os_type;
114 u8 end_head;
115 u8 end_sector;
116 u8 end_track;
117 __le32 starting_lba;
118 __le32 size_in_lba;
119} __packed gpt_mbr_record;
120
121
122typedef struct _legacy_mbr {
123 u8 boot_code[440];
124 __le32 unique_mbr_signature;
125 __le16 unknown;
126 gpt_mbr_record partition_record[4];
127 __le16 signature;
128} __packed legacy_mbr;
129
130
131extern int efi_partition(struct parsed_partitions *state);
132
133#endif
134