summaryrefslogtreecommitdiffstats
path: root/include/efi
diff options
context:
space:
mode:
Diffstat (limited to 'include/efi')
-rw-r--r--include/efi/debug_ll.h3
-rw-r--r--include/efi/device-path.h388
-rw-r--r--include/efi/efi-device.h6
-rw-r--r--include/efi/efi-payload.h (renamed from include/efi/efi.h)12
-rw-r--r--include/efi/efi-stdio.h100
-rw-r--r--include/efi/efi-util.h14
-rw-r--r--include/efi/partition.h119
7 files changed, 634 insertions, 8 deletions
diff --git a/include/efi/debug_ll.h b/include/efi/debug_ll.h
index 4ca72de312..279e8995f2 100644
--- a/include/efi/debug_ll.h
+++ b/include/efi/debug_ll.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __MACH_DEBUG_LL_H__
#define __MACH_DEBUG_LL_H__
@@ -5,7 +6,7 @@
#define EFI_DEBUG_CLEAR_MEMORY 0
#include <efi.h>
-#include <efi/efi.h>
+#include <efi/efi-payload.h>
static inline void PUTC_LL(char c)
{
diff --git a/include/efi/device-path.h b/include/efi/device-path.h
new file mode 100644
index 0000000000..f3af71465b
--- /dev/null
+++ b/include/efi/device-path.h
@@ -0,0 +1,388 @@
+#ifndef __EFI_DEVICE_PATH_H
+#define __EFI_DEVICE_PATH_H
+
+/*
+ * Hardware Device Path (UEFI 2.4 specification, version 2.4 § 9.3.2.)
+ */
+
+#define HARDWARE_DEVICE_PATH 0x01
+
+#define HW_PCI_DP 0x01
+struct pci_device_path {
+ struct efi_device_path header;
+ u8 Function;
+ u8 Device;
+};
+
+#define HW_PCCARD_DP 0x02
+struct pccard_device_path {
+ struct efi_device_path header;
+ u8 function_number;
+};
+
+#define HW_MEMMAP_DP 0x03
+struct memmap_device_path {
+ struct efi_device_path header;
+ u32 memory_type;
+ efi_physical_addr_t starting_address;
+ efi_physical_addr_t ending_address;
+};
+
+#define HW_VENDOR_DP 0x04
+struct vendor_device_path {
+ struct efi_device_path header;
+ efi_guid_t Guid;
+};
+
+struct unknown_device_vendor_device_path {
+ struct vendor_device_path device_path;
+ u8 legacy_drive_letter;
+};
+
+#define HW_CONTROLLER_DP 0x05
+struct controller_device_path {
+ struct efi_device_path header;
+ u32 Controller;
+};
+
+/*
+ * ACPI Device Path (UEFI 2.4 specification, version 2.4 § 9.3.3 and 9.3.4.)
+ */
+#define ACPI_DEVICE_PATH 0x02
+
+#define ACPI_DP 0x01
+struct acpi_hid_device_path {
+ struct efi_device_path header;
+ u32 HID;
+ u32 UID;
+};
+
+#define EXPANDED_ACPI_DP 0x02
+struct expanded_acpi_hid_device_path {
+ struct efi_device_path header;
+ u32 HID;
+ u32 UID;
+ u32 CID;
+ u8 hid_str[1];
+};
+
+#define ACPI_ADR_DP 3
+struct acpi_adr_device_path {
+ struct efi_device_path header;
+ u32 ADR;
+};
+
+/*
+ * EISA ID Macro
+ * EISA ID Definition 32-bits
+ * bits[15:0] - three character compressed ASCII EISA ID.
+ * bits[31:16] - binary number
+ * Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
+ */
+#define PNP_EISA_ID_CONST 0x41d0
+#define EISA_ID(_Name, _Num) ((u32) ((_Name) | (_Num) << 16))
+#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
+
+#define PNP_EISA_ID_MASK 0xffff
+#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16)
+
+/*
+ * Messaging Device Path (UEFI 2.4 specification, version 2.4 § 9.3.5.)
+ */
+#define MESSAGING_DEVICE_PATH 0x03
+
+#define MSG_ATAPI_DP 0x01
+struct atapi_device_path {
+ struct efi_device_path header;
+ u8 primary_secondary;
+ u8 slave_master;
+ u16 Lun;
+};
+
+#define MSG_SCSI_DP 0x02
+struct scsi_device_path {
+ struct efi_device_path header;
+ u16 Pun;
+ u16 Lun;
+};
+
+#define MSG_FIBRECHANNEL_DP 0x03
+struct fibrechannel_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 WWN;
+ u64 Lun;
+};
+
+/**
+ * Fibre Channel Ex sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.6.
+ */
+#define MSG_FIBRECHANNELEX_DP 21
+struct fibrechannelex_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u8 WWN[8]; /* World Wide Name */
+ u8 Lun[8]; /* Logical unit, T-10 SCSI Architecture Model 4 specification */
+};
+
+#define MSG_1394_DP 0x04
+struct f1394_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 Guid;
+};
+
+#define MSG_USB_DP 0x05
+struct usb_device_path {
+ struct efi_device_path header;
+ u8 Port;
+ u8 Endpoint;
+};
+
+/**
+ * SATA Device Path sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.6.
+ */
+#define MSG_SATA_DP 18
+struct sata_device_path {
+ struct efi_device_path header;
+ u16 HBAPort_number;
+ u16 port_multiplier_port_number;
+ u16 Lun; /* Logical Unit Number */
+};
+
+/**
+ * USB WWID Device Path sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.7.
+ */
+#define MSG_USB_WWID_DP 16
+struct usb_wwid_device_path {
+ struct efi_device_path header;
+ u16 interface_number;
+ u16 vendor_id;
+ u16 product_id;
+ s16 serial_number[1]; /* UTF-16 characters of the USB serial number */
+};
+
+/**
+ * Device Logical Unit sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.8.
+ */
+#define MSG_DEVICE_LOGICAL_UNIT_DP 17
+struct device_logical_unit_device_path {
+ struct efi_device_path header;
+ u8 Lun; /* Logical Unit Number */
+};
+
+#define MSG_USB_CLASS_DP 0x0_f
+struct usb_class_device_path {
+ struct efi_device_path header;
+ u16 vendor_id;
+ u16 product_id;
+ u8 device_class;
+ u8 device_subclass;
+ u8 device_protocol;
+};
+
+#define MSG_I2_o_DP 0x06
+struct i2_o_device_path {
+ struct efi_device_path header;
+ u32 Tid;
+};
+
+#define MSG_MAC_ADDR_DP 0x0b
+struct mac_addr_device_path {
+ struct efi_device_path header;
+ efi_mac_address mac_address;
+ u8 if_type;
+};
+
+#define MSG_IPv4_DP 0x0c
+struct ipv4_device_path {
+ struct efi_device_path header;
+ efi_ipv4_address local_ip_address;
+ efi_ipv4_address remote_ip_address;
+ u16 local_port;
+ u16 remote_port;
+ u16 Protocol;
+ bool static_ip_address;
+ /* new from UEFI version 2, code must check length field in header */
+ efi_ipv4_address gateway_ip_address;
+ efi_ipv4_address subnet_mask;
+};
+
+#define MSG_IPv6_DP 0x0d
+struct ipv6_device_path {
+ struct efi_device_path header;
+ efi_ipv6_address local_ip_address;
+ efi_ipv6_address remote_ip_address;
+ u16 local_port;
+ u16 remote_port;
+ u16 Protocol;
+ bool IPAddress_origin;
+ /* new from UEFI version 2, code must check length field in header */
+ u8 prefix_length;
+ efi_ipv6_address gateway_ip_address;
+};
+
+/**
+ * Device Logical Unit sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.5.8.
+ */
+#define MSG_VLAN_DP 20
+struct vlan_device_path {
+ struct efi_device_path header;
+ u16 vlan_id;
+};
+
+#define MSG_INFINIBAND_DP 0x09
+struct infiniband_device_path {
+ struct efi_device_path header;
+ u32 resource_flags;
+ efi_guid_t port_gid;
+ u64 service_id;
+ u64 target_port_id;
+ u64 device_id;
+};
+
+#define MSG_UART_DP 0x0e
+struct uart_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 baud_rate;
+ u8 data_bits;
+ u8 Parity;
+ u8 stop_bits;
+};
+
+#define MSG_VENDOR_DP 0x0a
+/* Use VENDOR_DEVICE_PATH struct */
+
+#define DEVICE_PATH_MESSAGING_PC_ANSI \
+ { 0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
+
+#define DEVICE_PATH_MESSAGING_VT_100 \
+ { 0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} }
+
+#define DEVICE_PATH_MESSAGING_VT_100_PLUS \
+ { 0x7baec70b , 0x57e0 , 0x4c76 , { 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 } }
+
+#define DEVICE_PATH_MESSAGING_VT_UTF8 \
+ { 0xad15a0d6 , 0x8bec , 0x4acf , { 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 } }
+
+#define EFI_PC_ANSI_GUID \
+ { 0xe0c14753 , 0xf9be , 0x11d2 , 0x9a , 0x0c , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d }
+
+#define EFI_VT_100_GUID \
+ { 0xdfa66065 , 0xb419 , 0x11d3 , 0x9a , 0x2d , 0x00 , 0x90 , 0x27 , 0x3f , 0xc1 , 0x4d }
+
+#define EFI_VT_100_PLUS_GUID \
+ { 0x7baec70b , 0x57e0 , 0x4c76 , 0x8e , 0x87 , 0x2f , 0x9e , 0x28 , 0x08 , 0x83 , 0x43 }
+
+#define EFI_VT_UTF8_GUID \
+ { 0xad15a0d6 , 0x8bec , 0x4acf , 0xa0 , 0x73 , 0xd0 , 0x1d , 0xe7 , 0x7e , 0x2d , 0x88 }
+
+/*
+ * Media Device Path (UEFI 2.4 specification, version 2.4 § 9.3.6.)
+ */
+#define MEDIA_DEVICE_PATH 0x04
+
+#define MEDIA_HARDDRIVE_DP 0x01
+struct harddrive_device_path {
+ struct efi_device_path header;
+ u32 partition_number;
+ u64 partition_start;
+ u64 partition_size;
+ u8 signature[16];
+ u8 mbr_type;
+ u8 signature_type;
+};
+
+#define MBR_TYPE_PCAT 0x01
+#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
+
+#define SIGNATURE_TYPE_MBR 0x01
+#define SIGNATURE_TYPE_GUID 0x02
+
+#define MEDIA_CDROM_DP 0x02
+struct cdrom_device_path {
+ struct efi_device_path header;
+ u32 boot_entry;
+ u64 partition_start;
+ u64 partition_size;
+};
+
+#define MEDIA_VENDOR_DP 0x03
+/* Use VENDOR_DEVICE_PATH struct */
+
+#define MEDIA_FILEPATH_DP 0x04
+struct filepath_device_path {
+ struct efi_device_path header;
+ s16 path_name[1];
+};
+
+#define SIZE_OF_FILEPATH_DEVICE_PATH offsetof(FILEPATH_DEVICE_PATH,path_name)
+
+#define MEDIA_PROTOCOL_DP 0x05
+struct media_protocol_device_path {
+ struct efi_device_path header;
+ efi_guid_t Protocol;
+};
+
+/**
+ * PIWG Firmware File sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.6.6.
+ */
+#define MEDIA_PIWG_FW_FILE_DP 6
+struct media_fw_vol_filepath_device_path {
+ struct efi_device_path header;
+ efi_guid_t fv_file_name;
+};
+
+/**
+ * PIWG Firmware Volume Device Path sub_type.
+ * UEFI 2.0 specification version 2.4 § 9.3.6.7.
+ */
+#define MEDIA_PIWG_FW_VOL_DP 7
+struct media_fw_vol_device_path {
+ struct efi_device_path header;
+ efi_guid_t fv_name;
+};
+
+/**
+ * Media relative offset range device path.
+ * UEFI 2.0 specification version 2.4 § 9.3.6.8.
+ */
+#define MEDIA_RELATIVE_OFFSET_RANGE_DP 8
+struct media_relative_offset_range_device_path {
+ struct efi_device_path header;
+ u32 Reserved;
+ u64 starting_offset;
+ u64 ending_offset;
+};
+
+/*
+ * BIOS Boot Specification Device Path (UEFI 2.4 specification, version 2.4 § 9.3.7.)
+ */
+#define BBS_DEVICE_PATH 0x05
+
+#define BBS_BBS_DP 0x01
+struct bbs_bbs_device_path {
+ struct efi_device_path header;
+ u16 device_type;
+ u16 status_flag;
+ s8 String[1];
+};
+
+/* device_type definitions - from BBS specification */
+#define BBS_TYPE_FLOPPY 0x01
+#define BBS_TYPE_HARDDRIVE 0x02
+#define BBS_TYPE_CDROM 0x03
+#define BBS_TYPE_PCMCIA 0x04
+#define BBS_TYPE_USB 0x05
+#define BBS_TYPE_EMBEDDED_NETWORK 0x06
+#define BBS_TYPE_DEV 0x80
+#define BBS_TYPE_UNKNOWN 0x_fF
+
+#endif /* __EFI_DEVICE_PATH_H */
diff --git a/include/efi/efi-device.h b/include/efi/efi-device.h
index 5ec59a8a2d..b9714ffb74 100644
--- a/include/efi/efi-device.h
+++ b/include/efi/efi-device.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __EFI_EFI_DEVICE_H
#define __EFI_EFI_DEVICE_H
@@ -15,6 +16,8 @@ struct efi_driver {
struct driver_d driver;
int (*probe)(struct efi_device *efidev);
void (*remove)(struct efi_device *efidev);
+ int (*dev_pause)(struct efi_device *efidev);
+ int (*dev_continue)(struct efi_device *efidev);
efi_guid_t guid;
};
@@ -45,6 +48,9 @@ int efi_connect_all(void);
void efi_register_devices(void);
struct efi_device *efi_get_bootsource(void);
+void efi_pause_devices(void);
+void efi_continue_devices(void);
+
static inline bool efi_device_has_guid(struct efi_device *efidev, efi_guid_t guid)
{
int i;
diff --git a/include/efi/efi.h b/include/efi/efi-payload.h
index 648afb9ec5..a2daff08bb 100644
--- a/include/efi/efi.h
+++ b/include/efi/efi-payload.h
@@ -1,17 +1,15 @@
-#ifndef __MACH_EFI_H
-#define __MACH_EFI_H
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __EFI_PAYLOAD_H
+#define __EFI_PAYLOAD_H
#include <efi.h>
-
-const char *efi_strerror(efi_status_t err);
+#include <efi/efi-util.h>
extern efi_system_table_t *efi_sys_table;
extern efi_handle_t efi_parent_image;
extern struct efi_device_path *efi_device_path;
extern efi_loaded_image_t *efi_loaded_image;
-int efi_errno(efi_status_t err);
-
void *efi_get_variable(char *name, efi_guid_t *vendor, int *var_size);
static inline void *efi_get_global_var(char *name, int *var_size)
@@ -23,4 +21,4 @@ int efi_set_variable(char *name, efi_guid_t *vendor, uint32_t attributes,
void *buf, unsigned long size);
int efi_set_variable_usec(char *name, efi_guid_t *vendor, uint64_t usec);
-#endif /* __MACH_EFI_H */
+#endif
diff --git a/include/efi/efi-stdio.h b/include/efi/efi-stdio.h
new file mode 100644
index 0000000000..66fb0afc36
--- /dev/null
+++ b/include/efi/efi-stdio.h
@@ -0,0 +1,100 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef EFI_STDIO_H_
+#define EFI_STDIO_H_
+
+#include <efi.h>
+
+struct efi_simple_text_input_ex_protocol;
+
+typedef efi_status_t (EFIAPI *efi_input_reset_ex)(
+ struct efi_simple_text_input_ex_protocol *this,
+ efi_bool_t extended_verification
+);
+
+struct efi_key_state {
+ u32 shift_state;
+ u8 toggle_state;
+};
+
+struct efi_key_data {
+ struct efi_input_key key;
+ struct efi_key_state state;
+};
+
+typedef efi_status_t (EFIAPI *efi_input_read_key_ex)(
+ struct efi_simple_text_input_ex_protocol *this,
+ struct efi_key_data *keydata
+);
+
+typedef efi_status_t (EFIAPI *efi_set_state)(
+ struct efi_simple_text_input_ex_protocol *this,
+ u8 *key_toggle_state
+);
+
+typedef efi_status_t (EFIAPI *efi_key_notify_function)(
+ struct efi_key_data *keydata
+);
+
+typedef efi_status_t (EFIAPI *efi_register_keystroke_notify)(
+ struct efi_simple_text_input_ex_protocol *this,
+ struct efi_key_data keydata,
+ efi_key_notify_function key_notification_function,
+ void **notify_handle
+);
+
+typedef efi_status_t (EFIAPI *efi_unregister_keystroke_notify)(
+ struct efi_simple_text_input_ex_protocol *this,
+ void *notification_handle
+);
+
+struct efi_simple_text_input_ex_protocol {
+ efi_input_reset_ex reset;
+ efi_input_read_key_ex read_key_stroke_ex;
+ void *wait_for_key_ex;
+ efi_set_state set_state;
+ efi_register_keystroke_notify register_key_notify;
+ efi_unregister_keystroke_notify unregister_key_notify;
+};
+
+#define EFI_SHIFT_STATE_VALID 0x80000000
+#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
+#define EFI_LEFT_CONTROL_PRESSED 0x00000008
+#define EFI_RIGHT_ALT_PRESSED 0x00000010
+#define EFI_LEFT_ALT_PRESSED 0x00000020
+
+#define EFI_CONTROL_PRESSED (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)
+#define EFI_ALT_PRESSED (EFI_RIGHT_ALT_PRESSED | EFI_LEFT_ALT_PRESSED)
+#define KEYPRESS(keys, scan, uni) ((((uint64_t)keys) << 32) | ((scan) << 16) | (uni))
+#define KEYCHAR(k) ((k) & 0xffff)
+#define CHAR_CTRL(c) ((c) - 'a' + 1)
+
+#define EFI_BLACK 0x00
+#define EFI_BLUE 0x01
+#define EFI_GREEN 0x02
+#define EFI_CYAN (EFI_BLUE | EFI_GREEN)
+#define EFI_RED 0x04
+#define EFI_MAGENTA (EFI_BLUE | EFI_RED)
+#define EFI_BROWN (EFI_GREEN | EFI_RED)
+#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED)
+#define EFI_BRIGHT 0x08
+#define EFI_DARKGRAY (EFI_BRIGHT)
+#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT)
+#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT)
+#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT)
+#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT)
+#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT)
+#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT)
+#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
+
+#define EFI_TEXT_ATTR(f,b) ((f) | ((b) << 4))
+
+#define EFI_BACKGROUND_BLACK 0x00
+#define EFI_BACKGROUND_BLUE 0x10
+#define EFI_BACKGROUND_GREEN 0x20
+#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
+#define EFI_BACKGROUND_RED 0x40
+#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
+#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
+#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
+
+#endif
diff --git a/include/efi/efi-util.h b/include/efi/efi-util.h
new file mode 100644
index 0000000000..78e352456a
--- /dev/null
+++ b/include/efi/efi-util.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __EFI_UTIL_H
+#define __EFI_UTIL_H
+
+#include <efi.h>
+
+const char *efi_strerror(efi_status_t err);
+int efi_errno(efi_status_t err);
+
+int __efivarfs_parse_filename(const char *filename, efi_guid_t *vendor,
+ s16 *name, size_t *namelen);
+int efivarfs_parse_filename(const char *filename, efi_guid_t *vendor, s16 **name);
+
+#endif
diff --git a/include/efi/partition.h b/include/efi/partition.h
new file mode 100644
index 0000000000..a9b10c1266
--- /dev/null
+++ b/include/efi/partition.h
@@ -0,0 +1,119 @@
+/************************************************************
+ * EFI GUID Partition Table
+ * Per Intel EFI Specification v1.02
+ * http://developer.intel.com/technology/efi/efi.htm
+ *
+ * By Matt Domsch <Matt_Domsch@dell.com> Fri Sep 22 22:15:56 CDT 2000
+ * Copyright 2000,2001 Dell Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ ************************************************************/
+
+#ifndef FS_PART_EFI_H_INCLUDED
+#define FS_PART_EFI_H_INCLUDED
+
+#include <efi.h>
+
+#define MSDOS_MBR_SIGNATURE 0xaa55
+#define EFI_PMBR_OSTYPE_EFI 0xEF
+#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
+
+#define GPT_BLOCK_SIZE 512
+#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
+#define GPT_HEADER_REVISION_V1 0x00010000
+#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
+
+#define PARTITION_SYSTEM_GUID \
+ EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
+ 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B)
+#define LEGACY_MBR_PARTITION_GUID \
+ EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
+ 0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
+#define PARTITION_MSFT_RESERVED_GUID \
+ EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
+ 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
+#define PARTITION_BASIC_DATA_GUID \
+ EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
+ 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
+#define PARTITION_LINUX_RAID_GUID \
+ EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
+ 0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
+#define PARTITION_LINUX_SWAP_GUID \
+ EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
+ 0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
+#define PARTITION_LINUX_LVM_GUID \
+ EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
+ 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
+
+/* based on linux/include/genhd.h */
+struct legacy_partition {
+ unsigned char boot_ind; /* 0x80 - active */
+ unsigned char head; /* starting head */
+ unsigned char sector; /* starting sector */
+ unsigned char cyl; /* starting cylinder */
+ unsigned char sys_ind; /* What partition type */
+ unsigned char end_head; /* end head */
+ unsigned char end_sector; /* end sector */
+ unsigned char end_cyl; /* end cylinder */
+ __le32 start_sect; /* starting sector counting from 0 */
+ __le32 nr_sects; /* nr of sectors in partition */
+} __attribute__ ((packed));
+
+/* based on linux/fs/partitions/efi.h */
+typedef struct _gpt_header {
+ __le64 signature;
+ __le32 revision;
+ __le32 header_size;
+ __le32 header_crc32;
+ __le32 reserved1;
+ __le64 my_lba;
+ __le64 alternate_lba;
+ __le64 first_usable_lba;
+ __le64 last_usable_lba;
+ efi_guid_t disk_guid;
+ __le64 partition_entry_lba;
+ __le32 num_partition_entries;
+ __le32 sizeof_partition_entry;
+ __le32 partition_entry_array_crc32;
+
+ /* The rest of the logical block is reserved by UEFI and must be zero.
+ * EFI standard handles this by:
+ *
+ * uint8_t reserved2[ BlockSize - 92 ];
+ */
+} __attribute__ ((packed)) gpt_header;
+
+typedef struct _gpt_entry_attributes {
+ u64 required_to_function:1;
+ u64 reserved:47;
+ u64 type_guid_specific:16;
+} __attribute__ ((packed)) gpt_entry_attributes;
+
+#define GPT_PARTNAME_MAX_SIZE (72 / sizeof (efi_char16_t))
+typedef struct _gpt_entry {
+ efi_guid_t partition_type_guid;
+ efi_guid_t unique_partition_guid;
+ __le64 starting_lba;
+ __le64 ending_lba;
+ gpt_entry_attributes attributes;
+ efi_char16_t partition_name[GPT_PARTNAME_MAX_SIZE];
+} __attribute__ ((packed)) gpt_entry;
+
+typedef struct _legacy_mbr {
+ u8 boot_code[440];
+ __le32 unique_mbr_signature;
+ __le16 unknown;
+ struct legacy_partition partition_record[4];
+ __le16 signature;
+} __attribute__ ((packed)) legacy_mbr;
+
+#endif /* _DISK_PART_EFI_H */