Linux Audio

Check our new training course

Loading...
v6.2
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/************************************************************
  3 * EFI GUID Partition Table
  4 * Per Intel EFI Specification v1.02
  5 * http://developer.intel.com/technology/efi/efi.htm
  6 *
  7 * By Matt Domsch <Matt_Domsch@dell.com>  Fri Sep 22 22:15:56 CDT 2000  
  8 *   Copyright 2000,2001 Dell Inc.
  9 ************************************************************/
 10
 11#ifndef FS_PART_EFI_H_INCLUDED
 12#define FS_PART_EFI_H_INCLUDED
 13
 14#include <linux/types.h>
 15#include <linux/fs.h>
 
 16#include <linux/kernel.h>
 17#include <linux/major.h>
 18#include <linux/string.h>
 19#include <linux/efi.h>
 20#include <linux/compiler.h>
 21
 22#define MSDOS_MBR_SIGNATURE 0xaa55
 23#define EFI_PMBR_OSTYPE_EFI 0xEF
 24#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
 25
 26#define GPT_MBR_PROTECTIVE  1
 27#define GPT_MBR_HYBRID      2
 28
 29#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
 30#define GPT_HEADER_REVISION_V1 0x00010000
 31#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
 32
 33#define PARTITION_SYSTEM_GUID \
 34    EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
 35              0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) 
 36#define LEGACY_MBR_PARTITION_GUID \
 37    EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
 38              0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
 39#define PARTITION_MSFT_RESERVED_GUID \
 40    EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
 41              0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
 42#define PARTITION_BASIC_DATA_GUID \
 43    EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
 44              0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
 45#define PARTITION_LINUX_RAID_GUID \
 46    EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
 47              0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
 48#define PARTITION_LINUX_SWAP_GUID \
 49    EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
 50              0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
 51#define PARTITION_LINUX_LVM_GUID \
 52    EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
 53              0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
 54
 55typedef struct _gpt_header {
 56	__le64 signature;
 57	__le32 revision;
 58	__le32 header_size;
 59	__le32 header_crc32;
 60	__le32 reserved1;
 61	__le64 my_lba;
 62	__le64 alternate_lba;
 63	__le64 first_usable_lba;
 64	__le64 last_usable_lba;
 65	efi_guid_t disk_guid;
 66	__le64 partition_entry_lba;
 67	__le32 num_partition_entries;
 68	__le32 sizeof_partition_entry;
 69	__le32 partition_entry_array_crc32;
 70
 71	/* The rest of the logical block is reserved by UEFI and must be zero.
 72	 * EFI standard handles this by:
 73	 *
 74	 * uint8_t		reserved2[ BlockSize - 92 ];
 75	 */
 76} __packed gpt_header;
 77
 78typedef struct _gpt_entry_attributes {
 79	u64 required_to_function:1;
 80	u64 reserved:47;
 81        u64 type_guid_specific:16;
 82} __packed gpt_entry_attributes;
 83
 84typedef struct _gpt_entry {
 85	efi_guid_t partition_type_guid;
 86	efi_guid_t unique_partition_guid;
 87	__le64 starting_lba;
 88	__le64 ending_lba;
 89	gpt_entry_attributes attributes;
 90	__le16 partition_name[72/sizeof(__le16)];
 91} __packed gpt_entry;
 92
 93typedef struct _gpt_mbr_record {
 94	u8	boot_indicator; /* unused by EFI, set to 0x80 for bootable */
 95	u8	start_head;     /* unused by EFI, pt start in CHS */
 96	u8	start_sector;   /* unused by EFI, pt start in CHS */
 97	u8	start_track;
 98	u8	os_type;        /* EFI and legacy non-EFI OS types */
 99	u8	end_head;       /* unused by EFI, pt end in CHS */
100	u8	end_sector;     /* unused by EFI, pt end in CHS */
101	u8	end_track;      /* unused by EFI, pt end in CHS */
102	__le32	starting_lba;   /* used by EFI - start addr of the on disk pt */
103	__le32	size_in_lba;    /* used by EFI - size of pt in LBA */
104} __packed gpt_mbr_record;
105
106
107typedef struct _legacy_mbr {
108	u8 boot_code[440];
109	__le32 unique_mbr_signature;
110	__le16 unknown;
111	gpt_mbr_record partition_record[4];
112	__le16 signature;
113} __packed legacy_mbr;
 
 
 
114
115#endif
v5.4
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/************************************************************
  3 * EFI GUID Partition Table
  4 * Per Intel EFI Specification v1.02
  5 * http://developer.intel.com/technology/efi/efi.htm
  6 *
  7 * By Matt Domsch <Matt_Domsch@dell.com>  Fri Sep 22 22:15:56 CDT 2000  
  8 *   Copyright 2000,2001 Dell Inc.
  9 ************************************************************/
 10
 11#ifndef FS_PART_EFI_H_INCLUDED
 12#define FS_PART_EFI_H_INCLUDED
 13
 14#include <linux/types.h>
 15#include <linux/fs.h>
 16#include <linux/genhd.h>
 17#include <linux/kernel.h>
 18#include <linux/major.h>
 19#include <linux/string.h>
 20#include <linux/efi.h>
 21#include <linux/compiler.h>
 22
 23#define MSDOS_MBR_SIGNATURE 0xaa55
 24#define EFI_PMBR_OSTYPE_EFI 0xEF
 25#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
 26
 27#define GPT_MBR_PROTECTIVE  1
 28#define GPT_MBR_HYBRID      2
 29
 30#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
 31#define GPT_HEADER_REVISION_V1 0x00010000
 32#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
 33
 34#define PARTITION_SYSTEM_GUID \
 35    EFI_GUID( 0xC12A7328, 0xF81F, 0x11d2, \
 36              0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B) 
 37#define LEGACY_MBR_PARTITION_GUID \
 38    EFI_GUID( 0x024DEE41, 0x33E7, 0x11d3, \
 39              0x9D, 0x69, 0x00, 0x08, 0xC7, 0x81, 0xF3, 0x9F)
 40#define PARTITION_MSFT_RESERVED_GUID \
 41    EFI_GUID( 0xE3C9E316, 0x0B5C, 0x4DB8, \
 42              0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE)
 43#define PARTITION_BASIC_DATA_GUID \
 44    EFI_GUID( 0xEBD0A0A2, 0xB9E5, 0x4433, \
 45              0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7)
 46#define PARTITION_LINUX_RAID_GUID \
 47    EFI_GUID( 0xa19d880f, 0x05fc, 0x4d3b, \
 48              0xa0, 0x06, 0x74, 0x3f, 0x0f, 0x84, 0x91, 0x1e)
 49#define PARTITION_LINUX_SWAP_GUID \
 50    EFI_GUID( 0x0657fd6d, 0xa4ab, 0x43c4, \
 51              0x84, 0xe5, 0x09, 0x33, 0xc8, 0x4b, 0x4f, 0x4f)
 52#define PARTITION_LINUX_LVM_GUID \
 53    EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
 54              0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
 55
 56typedef struct _gpt_header {
 57	__le64 signature;
 58	__le32 revision;
 59	__le32 header_size;
 60	__le32 header_crc32;
 61	__le32 reserved1;
 62	__le64 my_lba;
 63	__le64 alternate_lba;
 64	__le64 first_usable_lba;
 65	__le64 last_usable_lba;
 66	efi_guid_t disk_guid;
 67	__le64 partition_entry_lba;
 68	__le32 num_partition_entries;
 69	__le32 sizeof_partition_entry;
 70	__le32 partition_entry_array_crc32;
 71
 72	/* The rest of the logical block is reserved by UEFI and must be zero.
 73	 * EFI standard handles this by:
 74	 *
 75	 * uint8_t		reserved2[ BlockSize - 92 ];
 76	 */
 77} __packed gpt_header;
 78
 79typedef struct _gpt_entry_attributes {
 80	u64 required_to_function:1;
 81	u64 reserved:47;
 82        u64 type_guid_specific:16;
 83} __packed gpt_entry_attributes;
 84
 85typedef struct _gpt_entry {
 86	efi_guid_t partition_type_guid;
 87	efi_guid_t unique_partition_guid;
 88	__le64 starting_lba;
 89	__le64 ending_lba;
 90	gpt_entry_attributes attributes;
 91	efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
 92} __packed gpt_entry;
 93
 94typedef struct _gpt_mbr_record {
 95	u8	boot_indicator; /* unused by EFI, set to 0x80 for bootable */
 96	u8	start_head;     /* unused by EFI, pt start in CHS */
 97	u8	start_sector;   /* unused by EFI, pt start in CHS */
 98	u8	start_track;
 99	u8	os_type;        /* EFI and legacy non-EFI OS types */
100	u8	end_head;       /* unused by EFI, pt end in CHS */
101	u8	end_sector;     /* unused by EFI, pt end in CHS */
102	u8	end_track;      /* unused by EFI, pt end in CHS */
103	__le32	starting_lba;   /* used by EFI - start addr of the on disk pt */
104	__le32	size_in_lba;    /* used by EFI - size of pt in LBA */
105} __packed gpt_mbr_record;
106
107
108typedef struct _legacy_mbr {
109	u8 boot_code[440];
110	__le32 unique_mbr_signature;
111	__le16 unknown;
112	gpt_mbr_record partition_record[4];
113	__le16 signature;
114} __packed legacy_mbr;
115
116/* Functions */
117extern int efi_partition(struct parsed_partitions *state);
118
119#endif