From 20c4c2941955bc2f0f812d558405b054cac12042 Mon Sep 17 00:00:00 2001 From: batt Date: Mon, 5 Jul 2010 22:20:11 +0000 Subject: [PATCH] Update to latest KBlock low level API. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3998 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/io/kblock_file.c | 22 +++++----------------- bertos/io/kblock_ram.c | 25 ++++++------------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/bertos/io/kblock_file.c b/bertos/io/kblock_file.c index 69e9e12c..ae680815 100644 --- a/bertos/io/kblock_file.c +++ b/bertos/io/kblock_file.c @@ -88,15 +88,6 @@ static int kblockfile_writeBlock(struct KBlock *b, block_idx_t index, const void return (fwrite(f->b.priv.buf, 1, b->blk_size, f->fp) == b->blk_size) ? 0 : EOF; } -static int kblockfile_readBlock(struct KBlock *b, block_idx_t index, void *buf) -{ - KBlockFile *f = KBLOCKFILE_CAST(b); - ASSERT(buf); - ASSERT(index < b->blk_cnt); - fseek(f->fp, index * b->blk_size, SEEK_SET); - return (fread(f->b.priv.buf, 1, b->blk_size, f->fp) == b->blk_size) ? 0 : EOF; -} - static int kblockfile_error(struct KBlock *b) { KBlockFile *f = KBLOCKFILE_CAST(b); @@ -123,14 +114,12 @@ static int kblockfile_close(struct KBlock *b) static const KBlockVTable kblockfile_hwbuffered_vt = { .readDirect = kblockfile_readDirect, + .readBuf = kblockfile_readBuf, .writeBuf = kblockfile_writeBuf, .load = kblockfile_load, .store = kblockfile_store, - .readBlock = kblock_swReadBlock, - .writeBlock = kblock_swWriteBlock, - .error = kblockfile_error, .clearerr = kblockfile_claererr, .close = kblockfile_close, @@ -138,15 +127,14 @@ static const KBlockVTable kblockfile_hwbuffered_vt = static const KBlockVTable kblockfile_swbuffered_vt = { - .readDirect = kblock_swReadDirect, + .readDirect = kblockfile_readDirect, + .writeBlock =kblockfile_writeBlock, + .readBuf = kblock_swReadBuf, .writeBuf = kblock_swWriteBuf, .load = kblock_swLoad, .store = kblock_swStore, - .readBlock = kblockfile_readBlock, - .writeBlock =kblockfile_writeBlock, - .error = kblockfile_error, .clearerr = kblockfile_claererr, .close = kblockfile_close, @@ -154,7 +142,7 @@ static const KBlockVTable kblockfile_swbuffered_vt = static const KBlockVTable kblockfile_unbuffered_vt = { - .readBlock = kblockfile_readBlock, + .readDirect = kblockfile_readDirect, .writeBlock =kblockfile_writeBlock, .error = kblockfile_error, diff --git a/bertos/io/kblock_ram.c b/bertos/io/kblock_ram.c index 3af08b80..eff9675f 100644 --- a/bertos/io/kblock_ram.c +++ b/bertos/io/kblock_ram.c @@ -85,16 +85,6 @@ static int kblockram_writeBlock(struct KBlock *b, block_idx_t index, const void return 0; } -static int kblockram_readBlock(struct KBlock *b, block_idx_t index, void *buf) -{ - KBlockRam *r = KBLOCKRAM_CAST(b); - ASSERT(buf); - ASSERT(index < b->blk_cnt); - - memcpy(buf, r->membuf + index * r->b.blk_size, r->b.blk_size); - return 0; -} - static int kblockram_dummy(UNUSED_ARG(struct KBlock *,b)) { return 0; @@ -103,14 +93,12 @@ static int kblockram_dummy(UNUSED_ARG(struct KBlock *,b)) static const KBlockVTable kblockram_hwbuffered_vt = { .readDirect = kblockram_readDirect, + .readBuf = kblockram_readBuf, .writeBuf = kblockram_writeBuf, .load = kblockram_load, .store = kblockram_store, - .readBlock = kblock_swReadBlock, - .writeBlock = kblock_swWriteBlock, - .error = kblockram_dummy, .clearerr = kblockram_dummy, .close = kblockram_dummy, @@ -119,15 +107,14 @@ static const KBlockVTable kblockram_hwbuffered_vt = static const KBlockVTable kblockram_swbuffered_vt = { - .readDirect = kblock_swReadDirect, + .readDirect = kblockram_readDirect, + .writeBlock = kblockram_writeBlock, + .readBuf = kblock_swReadBuf, .writeBuf = kblock_swWriteBuf, .load = kblock_swLoad, .store = kblock_swStore, - - .readBlock = kblockram_readBlock, - .writeBlock = kblockram_writeBlock, - + .error = kblockram_dummy, .clearerr = kblockram_dummy, .close = kblockram_dummy, @@ -135,7 +122,7 @@ static const KBlockVTable kblockram_swbuffered_vt = static const KBlockVTable kblockram_unbuffered_vt = { - .readBlock = kblockram_readBlock, + .readDirect = kblockram_readDirect, .writeBlock = kblockram_writeBlock, .error = kblockram_dummy, -- 2.25.1