4a5aab7934652cfde20c6fb291e00c29170b8753
[grub.git] / include / grub / fat.h
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
19 #ifndef GRUB_FAT_H
20 #define GRUB_FAT_H      1
21
22 #include <grub/types.h>
23
24 struct grub_fat_bpb
25 {
26   grub_uint8_t jmp_boot[3];
27   grub_uint8_t oem_name[8];
28   grub_uint16_t bytes_per_sector;
29   grub_uint8_t sectors_per_cluster;
30   grub_uint16_t num_reserved_sectors;
31   grub_uint8_t num_fats;
32   /* 0x10 */
33   grub_uint16_t num_root_entries;
34   grub_uint16_t num_total_sectors_16;
35   grub_uint8_t media;
36   /*0 x15 */
37   grub_uint16_t sectors_per_fat_16;
38   grub_uint16_t sectors_per_track;
39   /*0 x19 */
40   grub_uint16_t num_heads;
41   /*0 x1b */
42   grub_uint32_t num_hidden_sectors;
43   /* 0x1f */
44   grub_uint32_t num_total_sectors_32;
45   union
46   {
47     struct
48     {
49       grub_uint8_t num_ph_drive;
50       grub_uint8_t reserved;
51       grub_uint8_t boot_sig;
52       grub_uint32_t num_serial;
53       grub_uint8_t label[11];
54       grub_uint8_t fstype[8];
55     } GRUB_PACKED fat12_or_fat16;
56     struct
57     {
58       grub_uint32_t sectors_per_fat_32;
59       grub_uint16_t extended_flags;
60       grub_uint16_t fs_version;
61       grub_uint32_t root_cluster;
62       grub_uint16_t fs_info;
63       grub_uint16_t backup_boot_sector;
64       grub_uint8_t reserved[12];
65       grub_uint8_t num_ph_drive;
66       grub_uint8_t reserved1;
67       grub_uint8_t boot_sig;
68       grub_uint32_t num_serial;
69       grub_uint8_t label[11];
70       grub_uint8_t fstype[8];
71     } GRUB_PACKED fat32;
72   } GRUB_PACKED version_specific;
73 } GRUB_PACKED;
74
75 #ifdef GRUB_UTIL
76 #include <grub/disk.h>
77
78 grub_disk_addr_t
79 grub_fat_get_cluster_sector (grub_disk_t disk, grub_uint64_t *sec_per_lcn);
80 #endif
81
82 #endif