From 78ba83720d538ac0c32b04bb672101f0cc9bfb14 Mon Sep 17 00:00:00 2001 From: batt Date: Fri, 7 Nov 2008 22:05:40 +0000 Subject: [PATCH] Add battfs config file; add shuffle for free blocks. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1911 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cfg/cfg_battfs.h | 56 +++++++++++++++++++++++++++++++++++++++++ bertos/fs/battfs.c | 18 +++++++------ 2 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 bertos/cfg/cfg_battfs.h diff --git a/bertos/cfg/cfg_battfs.h b/bertos/cfg/cfg_battfs.h new file mode 100644 index 00000000..95102364 --- /dev/null +++ b/bertos/cfg/cfg_battfs.h @@ -0,0 +1,56 @@ +/** + * \file + * + * + * \brief Configuration file for BattFS module. + * + * \version $Id: cfg_adc.h 1603 2008-08-10 17:18:44Z bernie $ + * \author Daniele Basile + */ + +#ifndef CFG_BATTFS_H +#define CFG_BATTFS_H + +/// Module logging level. +#define BATTFS_LOG_LEVEL LOG_LVL_INFO + +/// Module logging format. +#define BATTFS_LOG_FORMAT LOG_FMT_VERBOSE + +/** + * Set to 1 to enable free page shuffling: this + * increase memories life but makes debugging + * more difficult due to its unrepeteable state. + */ +#define CONFIG_BATTFS_SHUFFLE_FREE_PAGES 0 + + +#endif /* BATTFS */ diff --git a/bertos/fs/battfs.c b/bertos/fs/battfs.c index 2410f42d..1ea39c50 100644 --- a/bertos/fs/battfs.c +++ b/bertos/fs/battfs.c @@ -39,14 +39,14 @@ */ #include "battfs.h" - +#include "cfg/cfg_battfs.h" #include #include /* MIN, MAX */ #include #include /* cpu_to_xx */ -#define LOG_LEVEL LOG_LVL_INFO -#define LOG_FORMAT LOG_FMT_VERBOSE +#define LOG_LEVEL BATTFS_LOG_LEVEL +#define LOG_FORMAT BATTFS_LOG_FORMAT #include #include /* memset, memmove */ @@ -490,10 +490,14 @@ bool battfs_mount(struct BattFsSuper *disk) #if LOG_LEVEL >= LOG_LVL_INFO dumpPageArray(disk); #endif - #warning TODO: shuffle free blocks - //#if LOG_LEVEL > LOG_LVL_INFO - // dumpPageArray(disk); - //#endif + #if CONFIG_BATTFS_SHUFFLE_FREE_PAGES + SHUFFLE(&disk->page_array[disk->free_page_start], disk->page_count - disk->free_page_start); + + LOG_INFO("Page array after shuffle:\n"); + #if LOG_LEVEL >= LOG_LVL_INFO + dumpPageArray(disk); + #endif + #endif /* Init list for opened files. */ LIST_INIT(&disk->file_opened_list); return true; -- 2.25.1