Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/emubd
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2017-02-27 03:05:27 +0300
committerChristopher Haster <chaster@utexas.edu>2017-02-27 03:05:27 +0300
commit160299d35c65381c2ebcb7662d8dacf18120cb5f (patch)
treed4b79e56e1cb31e801091755d930355ccfa0f375 /emubd
parent02156cb47d64b2a4b3281271305b8a2a63c660ea (diff)
Initial commit of progress, minimal formatting niave free list
Diffstat (limited to 'emubd')
-rw-r--r--emubd/lfs_emubd.c13
-rw-r--r--emubd/lfs_emubd.h13
2 files changed, 24 insertions, 2 deletions
diff --git a/emubd/lfs_emubd.c b/emubd/lfs_emubd.c
index 73730f1..98a3af5 100644
--- a/emubd/lfs_emubd.c
+++ b/emubd/lfs_emubd.c
@@ -18,6 +18,7 @@
// Block device emulated on existing filesystem
lfs_error_t lfs_emubd_create(lfs_emubd_t *emu, const char *path) {
memset(&emu->info, 0, sizeof(emu->info));
+ memset(&emu->stats, 0, sizeof(emu->stats));
// Allocate buffer for creating children files
size_t pathlen = strlen(path);
@@ -64,8 +65,8 @@ lfs_error_t lfs_emubd_read(lfs_emubd_t *emu, uint8_t *buffer,
return -EINVAL;
}
- // Default to some arbitrary value for debugging
- memset(buffer, 0xcc, size);
+ // Zero out buffer for debugging
+ memset(buffer, 0, size);
// Iterate over blocks until enough data is read
while (size > 0) {
@@ -100,6 +101,7 @@ lfs_error_t lfs_emubd_read(lfs_emubd_t *emu, uint8_t *buffer,
off = 0;
}
+ emu->stats.read_count += 1;
return 0;
}
@@ -148,6 +150,7 @@ lfs_error_t lfs_emubd_write(lfs_emubd_t *emu, const uint8_t *buffer,
off = 0;
}
+ emu->stats.write_count += 1;
return 0;
}
@@ -175,6 +178,7 @@ lfs_error_t lfs_emubd_erase(lfs_emubd_t *emu,
off = 0;
}
+ emu->stats.erase_count += 1;
return 0;
}
@@ -188,6 +192,11 @@ lfs_error_t lfs_emubd_info(lfs_emubd_t *emu, struct lfs_bd_info *info) {
return 0;
}
+lfs_error_t lfs_emubd_stats(lfs_emubd_t *emu, struct lfs_bd_stats *stats) {
+ *stats = emu->stats;
+ return 0;
+}
+
// Wrappers for void*s
static lfs_error_t lfs_emubd_bd_read(void *bd, uint8_t *buffer,
diff --git a/emubd/lfs_emubd.h b/emubd/lfs_emubd.h
index 1304628..323601d 100644
--- a/emubd/lfs_emubd.h
+++ b/emubd/lfs_emubd.h
@@ -11,11 +11,19 @@
#include "lfs_bd.h"
+// Stats for debugging and optimization
+struct lfs_bd_stats {
+ lfs_lword_t read_count;
+ lfs_lword_t write_count;
+ lfs_lword_t erase_count;
+};
+
// The emu bd state
typedef struct lfs_emubd {
char *path;
char *child;
struct lfs_bd_info info;
+ struct lfs_bd_stats stats;
} lfs_emubd_t;
@@ -50,6 +58,11 @@ lfs_error_t lfs_emubd_sync(lfs_emubd_t *bd);
// Any unknown information may be left unmodified
lfs_error_t lfs_emubd_info(lfs_emubd_t *bd, struct lfs_bd_info *info);
+// Get stats of operations on the block device
+//
+// Used for debugging and optimizations
+lfs_error_t lfs_emubd_stats(lfs_emubd_t *bd, struct lfs_bd_stats *stats);
+
// Block device operations
extern const struct lfs_bd_ops lfs_emubd_ops;