Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_fat.h

    r991f645 rd260a95  
    2929/** @addtogroup fs
    3030 * @{
    31  */ 
     31 */
    3232
    3333#ifndef FAT_FAT_FAT_H_
     
    4040#define FAT1            0
    4141
    42 #define FAT_CLST_RES0   0x0000
    43 #define FAT_CLST_RES1   0x0001
    44 #define FAT_CLST_FIRST  0x0002
    45 #define FAT_CLST_BAD    0xfff7
    46 #define FAT_CLST_LAST1  0xfff8
    47 #define FAT_CLST_LAST8  0xffff
     42#define FAT_CLST_RES0     0x0000
     43#define FAT_CLST_RES1     0x0001
     44#define FAT_CLST_FIRST    0x0002
     45
     46#define FAT12_CLST_BAD    0x0ff7
     47#define FAT12_CLST_LAST1  0x0ff8
     48#define FAT12_CLST_LAST8  0x0fff
     49#define FAT16_CLST_BAD    0xfff7
     50#define FAT16_CLST_LAST1  0xfff8
     51#define FAT16_CLST_LAST8  0xffff
     52
     53#define FAT12_CLST_MAX    4085
     54#define FAT16_CLST_MAX    65525
    4855
    4956/* internally used to mark root directory's parent */
     
    5158/* internally used to mark root directory */
    5259#define FAT_CLST_ROOT           FAT_CLST_RES1
     60
     61/*
     62 * Convenience macros for computing some frequently used values from the
     63 * primitive boot sector members.
     64 */
     65#define RDS(bs)   ((sizeof(fat_dentry_t) * RDE((bs))) / BPS((bs))) + \
     66                   (((sizeof(fat_dentry_t) * RDE((bs))) % BPS((bs))) != 0)
     67#define SSA(bs)   (RSCNT((bs)) + FATCNT((bs)) * SF((bs)) + RDS(bs))
     68#define DS(bs)    (TS(bs) - SSA(bs))
     69#define CC(bs)    (DS(bs) / SPC(bs))
     70
     71#define FAT_IS_FAT12(bs)        (CC(bs) < FAT12_CLST_MAX)
     72#define FAT_IS_FAT16(bs) \
     73    ((CC(bs) >= FAT12_CLST_MAX) && (CC(bs) < FAT16_CLST_MAX))
     74
     75#define FAT_CLST_LAST1(bs) \
     76    (FAT_IS_FAT12(bs) ? FAT12_CLST_LAST1 : FAT16_CLST_LAST1)
     77#define FAT_CLST_LAST8(bs) \
     78    (FAT_IS_FAT12(bs) ? FAT12_CLST_LAST8 : FAT16_CLST_LAST8)
     79#define FAT_CLST_BAD(bs) \
     80    (FAT_IS_FAT12(bs) ? FAT12_CLST_BAD : FAT16_CLST_BAD)
    5381
    5482/* forward declarations */
Note: See TracChangeset for help on using the changeset viewer.