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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#define GUID_TYPE_EMPTY MAKE_GUID(0,0,0,0,0)
#define GUID_TYPE_SYSTEM MAKE_GUID(C12A7328,F81F,11D2,BA4B,00A0C93EC93B)
#define GUID_TYPE_LINUX_EXT3 MAKE_GUID(EBD0A0A2,B9E5,4433,87C0,68B6B72699C7)
#define GUID_TYPE_LINUX_SWAP MAKE_GUID(0657FD6D,A4AB,43C4,84E5,0933C84B4F4F)
#define GUID_TYPE_APPLE_HFS MAKE_GUID(48465300,0000,11AA,AA11,00306543ECAC)
#define GPT_ENTRY_FLAG_SYSTEM 1
typedef struct
{
GUID type;
GUID label;
uint64_t start;
uint64_t end;
uint64_t flags;
uint8_t name[72];
} PACKED GPT_entry;
#define GPT_HEADER_SIGNATURE "EFI PART"
#define GPT_HEADER_REVISION_EFI10 0x00010000
typedef struct
{
uint8_t signature[8];
uint32_t revision;
uint32_t header_size;
uint32_t header_crc;
uint8_t reserved[20];
uint64_t my_lba;
uint64_t alternate_lba;
uint64_t first_usable_lba;
uint64_t last_usable_lba;
GUID disk_guid;
uint64_t partition_entry_lba;
uint32_t n_partition_entries;
uint32_t partition_entry_size;
uint32_t partition_entry_crc;
} PACKED GPT_header;
#define MBR_PARTITION_TYPE_EFI 0xee
#define MBR_PARTITION_BOOTABLE 0x80
typedef struct
{
uint8_t head;
uint8_t sector;
uint8_t track;
} PACKED CHS;
typedef struct
{
uint8_t bootable;
CHS chs_start;
uint8_t system;
CHS chs_end;
uint32_t start;
uint32_t size;
} PACKED MBR_entry;
typedef struct
{
uint8_t boot_code[440];
uint8_t uid[4];
uint8_t reserved[2];
MBR_entry entry[4];
uint8_t signature[2];
} PACKED MBR;
|