msdos_partition.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 1999,2000,2001,2002,2004,2007 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 MSDOS_PARTITION_H
  19. #define MSDOS_PARTITION_H 1
  20. #include <stdint.h>
  21. /* The signature. */
  22. #define MSDOS_PARTITION_SIGNATURE ((0xaa << 8) | 0x55)
  23. /* This is not a flag actually, but used as if it were a flag. */
  24. #define MSDOS_PARTITION_TYPE_HIDDEN_FLAG 0x10
  25. /* The partition entry. */
  26. struct msdos_partition_entry
  27. {
  28. /* If active, 0x80, otherwise, 0x00. */
  29. uint8_t flag;
  30. /* The head of the start. */
  31. uint8_t start_head;
  32. /* (S | ((C >> 2) & 0xC0)) where S is the sector of the start and C
  33. is the cylinder of the start. Note that S is counted from one. */
  34. uint8_t start_sector;
  35. /* (C & 0xFF) where C is the cylinder of the start. */
  36. uint8_t start_cylinder;
  37. /* The partition type. */
  38. uint8_t type;
  39. /* The end versions of start_head, start_sector and start_cylinder,
  40. respectively. */
  41. uint8_t end_head;
  42. uint8_t end_sector;
  43. uint8_t end_cylinder;
  44. /* The start sector. Note that this is counted from zero. */
  45. uint32_t start;
  46. /* The length in sector units. */
  47. uint32_t length;
  48. } __attribute__ ((packed));
  49. /* The structure of MBR. */
  50. struct msdos_partition_mbr
  51. {
  52. /* The code area (actually, including BPB). */
  53. uint8_t code[446];
  54. /* Four partition entries. */
  55. struct msdos_partition_entry entries[4];
  56. /* The signature 0xaa55. */
  57. uint16_t signature;
  58. } __attribute__ ((packed));
  59. #endif