From: asterix Date: Thu, 29 Nov 2007 16:07:00 +0000 (+0000) Subject: Paste. Fix test prototype. Remove unneeded code. Add header. X-Git-Tag: 1.0.0~227 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=a82360baa60dff252e976621c9e1f3ad38081f73;p=bertos.git Paste. Fix test prototype. Remove unneeded code. Add header. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1015 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/kern/kfile.c b/kern/kfile.c index 38f43802..2dad6e37 100644 --- a/kern/kfile.c +++ b/kern/kfile.c @@ -40,9 +40,10 @@ * */ -#include +#include +#include -#inclede +#include /** @@ -127,8 +128,17 @@ static bool kfile_rwTest(KFile *f, uint8_t *buf, size_t _size) /** * Test for program memory read/write. + * This function write and read \p test_buf long \p _size + * on \p fd handler. If you want not overwrite exist data + * you should pass an \p save_buf where test store exist data, + * otherwise su must pass NULL. + * + * \note some device (like flash memeory) not allow write on + * existing data, and so this test use ASSERT macro to warn you if + * you are writing on same fd.seek_pos. + * */ -bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t * save_buf_size) +bool kfile_test(uint8_t *test_buf, size_t _size , uint8_t *save_buf, size_t save_buf_size) { KFile fd; int32_t size = _size; @@ -142,14 +152,6 @@ bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t * save_bu */ int32_t len = size/2; - /* - * Fill in test buffer - */ - for (int i = 0; i < size; i++) - test_buf[i] = (i & 0xff); - - kprintf("Generated test string..\n"); - /* * Open fd handler */ @@ -180,7 +182,7 @@ bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t * save_bu /* * Test flash read/write to address 0..size */ - if (!Kfile_rwTest(&fd, test_buf, size)) + if (!kfile_rwTest(&fd, test_buf, size)) goto kfile_test_end; kprintf("Test 1: ok!\n"); @@ -223,7 +225,7 @@ bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t * save_bu /* * Test flash read/write to address FLASHEND/2 ... FLASHEND/2 + size */ - if (!Kfile_rwTest(&fd, test_buf, size)) + if (!kfile_rwTest(&fd, test_buf, size)) goto kfile_test_end; kprintf("Test 2: ok!\n"); @@ -268,7 +270,7 @@ bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t * save_bu /* * Test flash read/write to address (FLASHEND - size) ... FLASHEND */ - if (!Kfile_rwTest(&fd, test_buf, size)) + if (!kfile_rwTest(&fd, test_buf, size)) goto kfile_test_end; kprintf("Test 3: ok !\n"); @@ -296,4 +298,4 @@ kfile_test_end: return false; } -#endif /* CONFIG_TEST */ \ No newline at end of file +#endif /* CONFIG_TEST */ diff --git a/kern/kfile.h b/kern/kfile.h index d59f7fb9..44832da3 100644 --- a/kern/kfile.h +++ b/kern/kfile.h @@ -92,6 +92,6 @@ int32_t kfile_seek(struct _KFile *fd, kfile_off_t offset, KSeekMode whence); /* * Kfile test function */ -bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t * save_buf_size); +bool kfile_test(uint8_t *buf, size_t _size , uint8_t *save_buf, size_t save_buf_size); #endif /* MWARE_KFILE_H */