fat.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009 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_FAT_H
  19. #define GRUB_FAT_H 1
  20. #include <grub/types.h>
  21. struct grub_fat_bpb
  22. {
  23. grub_uint8_t jmp_boot[3];
  24. grub_uint8_t oem_name[8];
  25. grub_uint16_t bytes_per_sector;
  26. grub_uint8_t sectors_per_cluster;
  27. grub_uint16_t num_reserved_sectors;
  28. grub_uint8_t num_fats; /* 0x10 */
  29. grub_uint16_t num_root_entries;
  30. grub_uint16_t num_total_sectors_16;
  31. grub_uint8_t media; /* 0x15 */
  32. grub_uint16_t sectors_per_fat_16;
  33. grub_uint16_t sectors_per_track; /* 0x18 */
  34. grub_uint16_t num_heads; /* 0x1A */
  35. grub_uint32_t num_hidden_sectors; /* 0x1C */
  36. grub_uint32_t num_total_sectors_32; /* 0x20 */
  37. union
  38. {
  39. struct
  40. {
  41. grub_uint8_t num_ph_drive;
  42. grub_uint8_t reserved;
  43. grub_uint8_t boot_sig;
  44. grub_uint32_t num_serial;
  45. grub_uint8_t label[11];
  46. grub_uint8_t fstype[8];
  47. } GRUB_PACKED fat12_or_fat16;
  48. struct
  49. {
  50. grub_uint32_t sectors_per_fat_32;
  51. grub_uint16_t extended_flags;
  52. grub_uint16_t fs_version;
  53. grub_uint32_t root_cluster;
  54. grub_uint16_t fs_info;
  55. grub_uint16_t backup_boot_sector;
  56. grub_uint8_t reserved[12];
  57. grub_uint8_t num_ph_drive;
  58. grub_uint8_t reserved1;
  59. grub_uint8_t boot_sig;
  60. grub_uint32_t num_serial;
  61. grub_uint8_t label[11];
  62. grub_uint8_t fstype[8];
  63. } GRUB_PACKED fat32;
  64. } GRUB_PACKED version_specific;
  65. } GRUB_PACKED;
  66. #ifdef GRUB_UTIL
  67. #include <grub/disk.h>
  68. grub_disk_addr_t
  69. grub_fat_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn);
  70. #endif
  71. #endif