Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /************************************************************
0003  * EFI GUID Partition Table
0004  * Per Intel EFI Specification v1.02
0005  * http://developer.intel.com/technology/efi/efi.htm
0006  *
0007  * By Matt Domsch <Matt_Domsch@dell.com>  Fri Sep 22 22:15:56 CDT 2000  
0008  *   Copyright 2000,2001 Dell Inc.
0009  ************************************************************/
0010 
0011 #ifndef FS_PART_EFI_H_INCLUDED
0012 #define FS_PART_EFI_H_INCLUDED
0013 
0014 #include <linux/types.h>
0015 #include <linux/fs.h>
0016 #include <linux/kernel.h>
0017 #include <linux/major.h>
0018 #include <linux/string.h>
0019 #include <linux/efi.h>
0020 #include <linux/compiler.h>
0021 
0022 #define MSDOS_MBR_SIGNATURE 0xaa55
0023 #define EFI_PMBR_OSTYPE_EFI 0xEF
0024 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
0025 
0026 #define GPT_MBR_PROTECTIVE  1
0027 #define GPT_MBR_HYBRID      2
0028 
0029 #define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
0030 #define GPT_HEADER_REVISION_V1 0x00010000
0031 #define GPT_PRIMARY_PARTITION_TABLE_LBA 1
0032 
0033 #define PARTITION_SYSTEM_GUID \
0034     EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
0035               0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) 
0036 #define LEGACY_MBR_PARTITION_GUID \
0037     EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
0038               0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
0039 #define PARTITION_MSFT_RESERVED_GUID \
0040     EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
0041               0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
0042 #define PARTITION_BASIC_DATA_GUID \
0043     EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
0044               0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
0045 #define PARTITION_LINUX_RAID_GUID \
0046     EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
0047               0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
0048 #define PARTITION_LINUX_SWAP_GUID \
0049     EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
0050               0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
0051 #define PARTITION_LINUX_LVM_GUID \
0052     EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
0053               0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
0054 
0055 typedef struct _gpt_header {
0056     __le64 signature;
0057     __le32 revision;
0058     __le32 header_size;
0059     __le32 header_crc32;
0060     __le32 reserved1;
0061     __le64 my_lba;
0062     __le64 alternate_lba;
0063     __le64 first_usable_lba;
0064     __le64 last_usable_lba;
0065     efi_guid_t disk_guid;
0066     __le64 partition_entry_lba;
0067     __le32 num_partition_entries;
0068     __le32 sizeof_partition_entry;
0069     __le32 partition_entry_array_crc32;
0070 
0071     /* The rest of the logical block is reserved by UEFI and must be zero.
0072      * EFI standard handles this by:
0073      *
0074      * uint8_t      reserved2[ BlockSize - 92 ];
0075      */
0076 } __packed gpt_header;
0077 
0078 typedef struct _gpt_entry_attributes {
0079     u64 required_to_function:1;
0080     u64 reserved:47;
0081         u64 type_guid_specific:16;
0082 } __packed gpt_entry_attributes;
0083 
0084 typedef struct _gpt_entry {
0085     efi_guid_t partition_type_guid;
0086     efi_guid_t unique_partition_guid;
0087     __le64 starting_lba;
0088     __le64 ending_lba;
0089     gpt_entry_attributes attributes;
0090     __le16 partition_name[72/sizeof(__le16)];
0091 } __packed gpt_entry;
0092 
0093 typedef struct _gpt_mbr_record {
0094     u8  boot_indicator; /* unused by EFI, set to 0x80 for bootable */
0095     u8  start_head;     /* unused by EFI, pt start in CHS */
0096     u8  start_sector;   /* unused by EFI, pt start in CHS */
0097     u8  start_track;
0098     u8  os_type;        /* EFI and legacy non-EFI OS types */
0099     u8  end_head;       /* unused by EFI, pt end in CHS */
0100     u8  end_sector;     /* unused by EFI, pt end in CHS */
0101     u8  end_track;      /* unused by EFI, pt end in CHS */
0102     __le32  starting_lba;   /* used by EFI - start addr of the on disk pt */
0103     __le32  size_in_lba;    /* used by EFI - size of pt in LBA */
0104 } __packed gpt_mbr_record;
0105 
0106 
0107 typedef struct _legacy_mbr {
0108     u8 boot_code[440];
0109     __le32 unique_mbr_signature;
0110     __le16 unknown;
0111     gpt_mbr_record partition_record[4];
0112     __le16 signature;
0113 } __packed legacy_mbr;
0114 
0115 #endif