gpt_partition.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2002,2005,2006,2007,2008 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_GPT_PARTITION_HEADER
  19. #define GRUB_GPT_PARTITION_HEADER 1
  20. #include <grub/types.h>
  21. struct grub_gpt_part_type
  22. {
  23. grub_uint32_t data1;
  24. grub_uint16_t data2;
  25. grub_uint16_t data3;
  26. grub_uint8_t data4[8];
  27. } __attribute__ ((aligned(8)));
  28. typedef struct grub_gpt_part_type grub_gpt_part_type_t;
  29. #define GRUB_GPT_PARTITION_TYPE_EMPTY \
  30. { 0x0, 0x0, 0x0, \
  31. { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } \
  32. }
  33. #ifdef GRUB_CPU_WORDS_BIGENDIAN
  34. #define GRUB_GPT_PARTITION_TYPE_BIOS_BOOT \
  35. { 0x48616821, 0x4964, 0x6f6e, \
  36. { 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
  37. }
  38. #else
  39. #define GRUB_GPT_PARTITION_TYPE_BIOS_BOOT \
  40. { 0x21686148, 0x6449, 0x6e6f, \
  41. { 0x74, 0x4e, 0x65, 0x65, 0x64, 0x45, 0x46, 0x49 } \
  42. }
  43. #endif
  44. struct grub_gpt_header
  45. {
  46. grub_uint8_t magic[8];
  47. grub_uint32_t version;
  48. grub_uint32_t headersize;
  49. grub_uint32_t crc32;
  50. grub_uint32_t unused1;
  51. grub_uint64_t primary;
  52. grub_uint64_t backup;
  53. grub_uint64_t start;
  54. grub_uint64_t end;
  55. grub_uint8_t guid[16];
  56. grub_uint64_t partitions;
  57. grub_uint32_t maxpart;
  58. grub_uint32_t partentry_size;
  59. grub_uint32_t partentry_crc32;
  60. } __attribute__ ((packed));
  61. struct grub_gpt_partentry
  62. {
  63. grub_gpt_part_type_t type;
  64. grub_uint8_t guid[16];
  65. grub_uint64_t start;
  66. grub_uint64_t end;
  67. grub_uint64_t attrib;
  68. char name[72];
  69. } __attribute__ ((packed));
  70. #endif /* ! GRUB_GPT_PARTITION_HEADER */