X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=fs%2Fbattfs.h;h=14728a8d2b199f82c36054fa9237bbdb1bc5904a;hb=b87fa132f9a185053847b7b91ae8a6247e2d5621;hp=455b21ce0c20c1a6e4bd521a5281936e6a714048;hpb=cdb8d4971e88e20148e080df14e99726c4d413b3;p=bertos.git diff --git a/fs/battfs.h b/fs/battfs.h index 455b21ce..14728a8d 100644 --- a/fs/battfs.h +++ b/fs/battfs.h @@ -75,15 +75,21 @@ typedef struct BattFsPageHeader */ fcs_t fcs; } BattFsPageHeader; +/* Ensure structure has no padding added */ +STATIC_ASSERT(sizeof(BattFsPageHeader) == 12); + + +/** + * Mark for valid pages. + * Simply set to 1 all field bits. + */ +#define MARK_PAGE_VALID ((1 << (CPU_BITS_PER_CHAR * sizeof(mark_t))) - 1) /** * Max number of files. */ #define BATTFS_MAX_FILES (1 << (CPU_BITS_PER_CHAR * sizeof(inode_t))) -/* Ensure structure has no padding added */ -STATIC_ASSERT(sizeof(BattFsPageHeader) == 12); - /* Fwd decl */ struct BattFsSuper; @@ -92,6 +98,11 @@ struct BattFsSuper; */ typedef uint16_t pgcnt_t; +/** + * Sentinel used to keep trace of unset pages in disk->pag_array. + */ +#define PAGE_UNSET_SENTINEL ((1 << (CPU_BITS_PER_CHAR * sizeof(pgcnt_t))) - 1) + /** * Type interface for disk init function. * \return true if all is ok, false otherwise. @@ -153,7 +164,10 @@ typedef struct BattFsSuper * Is used by the filesystem to represent * the entire disk in memory. */ - pgcnt_t *page_array; + pgcnt_t *page_array; + + mark_t min_free; ///< Lowest sequence number of free page + mark_t max_free; ///< Highest sequence number of free page disk_size_t disk_size; ///< Size of the disk, in bytes (page_count * page_size). disk_size_t free_bytes; ///< Free space on the disk.