blob: cd5e12b9b7a5865d145a0cddf1b8212e8d11fe72 [file] [log] [blame]
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
* Defines EFI related structure. See more details in EFI 2.3 spec.
* To download EFI standard, please visit UEFI homepage:
#include "sysincludes.h"
#define GPT_HEADER_REVISION 0x00010000
/* The first 3 numbers should be stored in network-endian format
* according to the GUID RFC. The UEFI spec appendix A claims they
* should be stored in little-endian format. But they need to be
* _displayed_ in network-endian format, which is also how they're
* documented in the specs.
* Since what we have here are little-endian constants, they're
* byte-swapped from the normal display order. */
#define GPT_ENT_TYPE_EFI \
#define UUID_NODE_LEN 6
#define GUID_SIZE 16
/* GUID definition.
* Defined in appendix A of EFI standard.
typedef struct {
union {
struct {
uint32_t time_low;
uint16_t time_mid;
uint16_t time_high_and_version;
uint8_t clock_seq_high_and_reserved;
uint8_t clock_seq_low;
uint8_t node[UUID_NODE_LEN];
} Uuid;
uint8_t raw[GUID_SIZE];
} u;
} __attribute__((packed)) Guid;
/* Some constant values */
extern const Guid guid_unused;
extern const Guid guid_chromeos_kernel;
/* GPT header defines how many partitions exist on a drive and sectors managed.
* For every drive device, there are 2 headers, primary and secondary.
* Most of fields are duplicated except my_lba and entries_lba.
* You may find more details in chapter 5 of EFI standard.
typedef struct {
char signature[8];
uint32_t revision;
uint32_t size;
uint32_t header_crc32;
uint32_t reserved_zero;
uint64_t my_lba;
uint64_t alternate_lba;
uint64_t first_usable_lba;
uint64_t last_usable_lba;
Guid disk_uuid;
uint64_t entries_lba;
uint32_t number_of_entries;
uint32_t size_of_entry;
uint32_t entries_crc32;
/* Remainder of sector is reserved and should be 0 */
} __attribute__((packed)) GptHeader;
/* GPT partition entry defines the starting and ending LBAs of a partition.
* It also contains the unique GUID, type, and attribute bits.
* You may find more details in chapter 5 of EFI standard.
typedef struct {
Guid type;
Guid unique;
uint64_t starting_lba;
uint64_t ending_lba;
union {
struct {
uint64_t : 48;
uint16_t gpt_att : 16;
} __attribute__((packed)) fields;
uint64_t whole;
} attrs;
uint16_t name[36]; /* UTF-16 encoded partition name */
/* Remainder of entry is reserved and should be 0 */
} __attribute__((packed)) GptEntry;