##// END OF EJS Templates
Generic lib clean target bug fixed
Generic lib clean target bug fixed

File last commit:

r12:cc0fb1c881c0 default
r17:24654bf85fa1 default
Show More
fat32.h
139 lines | 3.9 KiB | text/x-c | CLexer
/*------------------------------------------------------------------------------
-- This file is a part of the libuc, microcontroler library
-- Copyright (C) 2012, Alexis Jeandet
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------
-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@gmail.com
-------------------------------------------------------------------------------*/
#ifndef FAT32_H
#define FAT32_H
#include <mbr.h>
#include <fs.h>
#include <ucdirent.h>
/*BPB (Boot Sector) Offsets */
#define BS_jmpBootoff 0
#define BS_OEMNameoff 3
#define BPB_BytsPerSecoff 11
#define BPB_SecPerClusoff 13
#define BPB_RsvdSecCntoff 14
#define BPB_NumFATsoff 16
#define BPB_RootEntCntoff 17
#define BPB_TotSec16off 19
#define BPB_Mediaoff 21
#define BPB_FATSz16off 22
#define BPB_SecPerTrkoff 24
#define BPB_NumHeadsoff 26
#define BPB_HiddSecoff 28
#define BPB_TotSec32off 32
/*FAT16*/
#define BS_DrvNumFAT16off 36
#define BS_Reserved1FAT16off 37
#define BS_BootSigFAT16off 38
#define BS_VolIDFAT16off 39
#define BS_VolLabFAT16off 43
#define BS_FilSysTypeFAT16off 54
/*FAT32*/
#define BPB_FATSz32off 36
#define BPB_ExtFlagsoff 40
#define BPB_FSVeroff 42
#define BPB_RootClusoff 44
#define BPB_FSInfooff 48
#define BPB_BkBootSecoff 50
#define BPB_Reservedoff 52
#define BS_DrvNumFAT32off 64
#define BS_Reserved1FAT32off 65
#define BS_BootSigFAT32off 66
#define BS_VolIDFAT32off 67
#define BS_VolLabFAT32off 71
#define BS_FilSysTypeFAT32off 82
#define DIR_Nameoff 0
#define DIR_Attroff 0xb
#define DIR_FstClusHIoff 0x14
#define DIR_FstClusLOoff 0x1A
#define DIR_FileSizeoff 0x1c
#define DIR_CrtTimeTenthoff 13
#define DIR_CrtTimeoff 14
#define DIR_CrtDateoff 16
#define DIR_LstAccDateoff 18
#define DIR_WrtTimeoff 22
#define DIR_WrtDateoff 24
#define FATBadpart 1
#define FATBabArg 2
#define FATReadErr 3
#define FATnoErr 0
struct FAT32part_str
{
unsigned short BPB_BytsPerSec;
unsigned short BPB_RsvdSecCnt;
unsigned int BPB_FATSz32;
unsigned int BPB_RootClus;
unsigned int fat_begin_lba;
unsigned int cluster_begin_lba;
unsigned char BPB_SecPerClus;
unsigned char BPB_NumFATs;
dikpartition* part;
};
typedef volatile struct FAT32part_str FAT32fs;
#define clusterlba(fs,cluster_number) ((unsigned int)fs->cluster_begin_lba + (((unsigned int)cluster_number) - (2)) * (unsigned int)fs->BPB_SecPerClus)
#define fat32clusterinfatsect(fs,cluster_number) ((((unsigned int)(cluster_number))>>6) + fs->fat_begin_lba)
#define fat32clusterinfatoff(cluster_number) (((cluster_number)&0x3F)*4)
#define fat32sectorlbatoclusternum(fs,sectorlba) ((((((unsigned int)sectorlba & (-1^(fs->BPB_SecPerClus-1))))-((unsigned int)fs->cluster_begin_lba))/(unsigned int)fs->BPB_SecPerClus)+(2))
extern int fat32open(FAT32fs* fs,dikpartition* part);
extern int fat32mkdirent(FAT32fs* fs,ucdirent* dirent);
extern int fat32getrootfirstent(ucdirent* entry);
extern int fat32nextdirent(ucdirent* entry);
extern int fat32nextsectorlba(FAT32fs* fs,unsigned int lastsector_lba,unsigned int* nextsector_lba);
extern unsigned int fat32getdirentlba(ucdirent* entry);
#endif