1N/A/*
1N/A * GRUB -- GRand Unified Bootloader
1N/A * Copyright (C) 2001 Free Software Foundation, Inc.
1N/A *
1N/A * This program is free software; you can redistribute it and/or modify
1N/A * it under the terms of the GNU General Public License as published by
1N/A * the Free Software Foundation; either version 2 of the License, or
1N/A * (at your option) any later version.
1N/A *
1N/A * This program is distributed in the hope that it will be useful,
1N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
1N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1N/A * GNU General Public License for more details.
1N/A *
1N/A * You should have received a copy of the GNU General Public License
1N/A * along with this program; if not, write to the Free Software
1N/A * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1N/A */
1N/A
1N/A
1N/A/*
1N/A * Defines for the FAT BIOS Parameter Block (embedded in the first block
1N/A * of the partition.
1N/A */
1N/A
1N/Atypedef __signed__ char __s8;
1N/Atypedef unsigned char __u8;
1N/Atypedef __signed__ short __s16;
1N/Atypedef unsigned short __u16;
1N/Atypedef __signed__ int __s32;
1N/Atypedef unsigned int __u32;
1N/A
1N/A/* Note that some shorts are not aligned, and must therefore
1N/A * be declared as array of two bytes.
1N/A */
1N/Astruct fat_bpb {
1N/A __s8 ignored[3]; /* Boot strap short or near jump */
1N/A __s8 system_id[8]; /* Name - can be used to special case
1N/A partition manager volumes */
1N/A __u8 bytes_per_sect[2]; /* bytes per logical sector */
1N/A __u8 sects_per_clust;/* sectors/cluster */
1N/A __u8 reserved_sects[2]; /* reserved sectors */
1N/A __u8 num_fats; /* number of FATs */
1N/A __u8 dir_entries[2]; /* root directory entries */
1N/A __u8 short_sectors[2]; /* number of sectors */
1N/A __u8 media; /* media code (unused) */
1N/A __u16 fat_length; /* sectors/FAT */
1N/A __u16 secs_track; /* sectors per track */
1N/A __u16 heads; /* number of heads */
1N/A __u32 hidden; /* hidden sectors (unused) */
1N/A __u32 long_sectors; /* number of sectors (if short_sectors == 0) */
1N/A
1N/A /* The following fields are only used by FAT32 */
1N/A __u32 fat32_length; /* sectors/FAT */
1N/A __u16 flags; /* bit 8: fat mirroring, low 4: active fat */
1N/A __u8 version[2]; /* major, minor filesystem version */
1N/A __u32 root_cluster; /* first cluster in root directory */
1N/A __u16 info_sector; /* filesystem info sector */
1N/A __u16 backup_boot; /* backup boot sector */
1N/A __u16 reserved2[6]; /* Unused */
1N/A};
1N/A
1N/A#define FAT_CVT_U16(bytarr) (* (__u16*)(bytarr))
1N/A
1N/A/*
1N/A * Defines how to differentiate a 12-bit and 16-bit FAT.
1N/A */
1N/A
1N/A#define FAT_MAX_12BIT_CLUST 4087 /* 4085 + 2 */
1N/A
1N/A/*
1N/A * Defines for the file "attribute" byte
1N/A */
1N/A
1N/A#define FAT_ATTRIB_OK_MASK 0x37
1N/A#define FAT_ATTRIB_NOT_OK_MASK 0xC8
1N/A#define FAT_ATTRIB_DIR 0x10
1N/A#define FAT_ATTRIB_LONGNAME 0x0F
1N/A
1N/A/*
1N/A * Defines for FAT directory entries
1N/A */
1N/A
1N/A#define FAT_DIRENTRY_LENGTH 32
1N/A
1N/A#define FAT_DIRENTRY_ATTRIB(entry) \
1N/A (*((unsigned char *) (entry+11)))
1N/A#define FAT_DIRENTRY_VALID(entry) \
1N/A ( ((*((unsigned char *) entry)) != 0) \
1N/A && ((*((unsigned char *) entry)) != 0xE5) \
1N/A && !(FAT_DIRENTRY_ATTRIB(entry) & FAT_ATTRIB_NOT_OK_MASK) )
1N/A#define FAT_DIRENTRY_FIRST_CLUSTER(entry) \
1N/A ((*((unsigned short *) (entry+26)))+(*((unsigned short *) (entry+20)) << 16))
1N/A#define FAT_DIRENTRY_FILELENGTH(entry) \
1N/A (*((unsigned long *) (entry+28)))
1N/A
1N/A#define FAT_LONGDIR_ID(entry) \
1N/A (*((unsigned char *) (entry)))
1N/A#define FAT_LONGDIR_ALIASCHECKSUM(entry) \
1N/A (*((unsigned char *) (entry+13)))