Added optional block-level caching

This adds caching of the most recent read/program blocks, allowing
support of devices that don't have byte-level read+writes, along
with reduced device access on devices that do support byte-level
read+writes.

Note: The current implementation is a bit eager to drop caches where
it simplifies the cache layer. This layer is already complex enough.

Note: It may be worthwhile to add a compile switch for caching to
reduce code size, note sure.

Note: This does add a dependency on malloc, which could have a porting
layer, but I'm just using the functions from stdlib for now. These can be
overwritten with noops if the user controls the system, and keeps things
simple for now.
This commit is contained in:
Christopher Haster
2017-04-22 13:30:40 -05:00
parent 789286a257
commit 7050922623
4 changed files with 220 additions and 24 deletions

View File

@@ -55,11 +55,11 @@ lfs_size_t rsize;
uintmax_t res;
#ifndef LFS_READ_SIZE
#define LFS_READ_SIZE 1
#define LFS_READ_SIZE 64
#endif
#ifndef LFS_PROG_SIZE
#define LFS_PROG_SIZE 1
#define LFS_PROG_SIZE 64
#endif
#ifndef LFS_BLOCK_SIZE