efi.h 4.4 KB

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