From b5da4b76b5810b41900432832f178280069d8d91 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 3 Jan 2013 16:17:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5027 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 os/fs/fatfs/fatfs_fsimpl.cpp (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp new file mode 100644 index 000000000..8c9fd73c7 --- /dev/null +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -0,0 +1,93 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file fs_fatfs_impl.cpp + * @brief FatFS file system wrapper. + * + * @addtogroup fs_fatfs_wrapper + * @{ + */ + +#include "ch.hpp" +#include "fs.hpp" +#include "fatfs_fsimpl.hpp" +#include "hal.h" + +#define MSG_TERMINATE (msg_t)0 + +#define ERR_OK (msg_t)0 +#define ERR_TERMINATING (msg_t)1 +#define ERR_UNKNOWN_MSG (msg_t)2 + +/** + * @brief FatFS wrapper-related classes and interfaces. + */ +namespace chibios_fatfs { + + /*------------------------------------------------------------------------* + * chibios_fatfs::FatFSWrapper::FatFSServerThread * + *------------------------------------------------------------------------*/ + FatFSWrapper::FatFSServerThread::FatFSServerThread(::BaseBlockDevice *blkdev) : + BaseStaticThread(), + blkdev(blkdev) { + + start(FATFS_THREAD_PRIORITY); + } + + FatFSWrapper::FatFSServerThread::~FatFSServerThread() { + + sendMessage(MSG_TERMINATE); + wait(); + } + + msg_t FatFSWrapper::FatFSServerThread::main() { + msg_t sts; + + /* Synchronous messages processing loop.*/ + while (true) { + ThreadReference tr = waitMessage(); + msg_t msg = tr.getMessage(); + switch (msg) { + case MSG_TERMINATE: + /* The server object is being destroyed, terminating.*/ + tr.releaseMessage(ERR_TERMINATING); + return 0; + default: + sts = ERR_UNKNOWN_MSG; + } + tr.releaseMessage(sts); + } + } + + /*------------------------------------------------------------------------* + * chibios_fatfs::FatFSWrapper * + *------------------------------------------------------------------------*/ + FatFSWrapper::FatFSWrapper(::BaseBlockDevice *blkdev) : server(blkdev) { + + server.start(FATFS_THREAD_PRIORITY); + } + + FatFSWrapper::~FatFSWrapper() { + + server.~FatFSServerThread(); + } +} + +/** @} */ -- cgit v1.2.3 From 66205faf65927f86cd1faa8d738e48551fff75e0 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Jan 2013 09:38:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5029 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 47 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp index 8c9fd73c7..e42c11e50 100644 --- a/os/fs/fatfs/fatfs_fsimpl.cpp +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -36,6 +36,9 @@ #define ERR_TERMINATING (msg_t)1 #define ERR_UNKNOWN_MSG (msg_t)2 +using namespace chibios_rt; +using namespace chibios_fs; + /** * @brief FatFS wrapper-related classes and interfaces. */ @@ -51,11 +54,11 @@ namespace chibios_fatfs { start(FATFS_THREAD_PRIORITY); } - FatFSWrapper::FatFSServerThread::~FatFSServerThread() { +/* FatFSWrapper::FatFSServerThread::~FatFSServerThread() { sendMessage(MSG_TERMINATE); wait(); - } + }*/ msg_t FatFSWrapper::FatFSServerThread::main() { msg_t sts; @@ -84,9 +87,47 @@ namespace chibios_fatfs { server.start(FATFS_THREAD_PRIORITY); } - FatFSWrapper::~FatFSWrapper() { +/* FatFSWrapper::~FatFSWrapper() { server.~FatFSServerThread(); + }*/ + + uint32_t FatFSWrapper::getAndClearLastError(void) { + + return 0; + } + + void FatFSWrapper::synchronize(void) { + + } + + void FatFSWrapper::remove(const char *fname) { + + (void)fname; + } + + BaseFileStreamInterface *FatFSWrapper::open(const char *fname) { + + (void)fname; + return NULL; + } + + BaseFileStreamInterface *FatFSWrapper::openForRead(const char *fname) { + + (void)fname; + return NULL; + } + + BaseFileStreamInterface *FatFSWrapper::openForWrite(const char *fname) { + + (void)fname; + return NULL; + } + + BaseFileStreamInterface *FatFSWrapper::create(const char *fname) { + + (void)fname; + return NULL; } } -- cgit v1.2.3 From 77f68f1c5b8f39a9146f5bd644867dde10b24c14 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Jan 2013 10:26:22 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5030 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp index e42c11e50..4fd071f00 100644 --- a/os/fs/fatfs/fatfs_fsimpl.cpp +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -47,9 +47,8 @@ namespace chibios_fatfs { /*------------------------------------------------------------------------* * chibios_fatfs::FatFSWrapper::FatFSServerThread * *------------------------------------------------------------------------*/ - FatFSWrapper::FatFSServerThread::FatFSServerThread(::BaseBlockDevice *blkdev) : - BaseStaticThread(), - blkdev(blkdev) { + FatFSWrapper::FatFSServerThread::FatFSServerThread(void) : + BaseStaticThread() { start(FATFS_THREAD_PRIORITY); } @@ -79,18 +78,28 @@ namespace chibios_fatfs { } } + void FatFSWrapper::FatFSServerThread::stop(void) { + + sendMessage(MSG_TERMINATE); + wait(); + } + /*------------------------------------------------------------------------* * chibios_fatfs::FatFSWrapper * *------------------------------------------------------------------------*/ - FatFSWrapper::FatFSWrapper(::BaseBlockDevice *blkdev) : server(blkdev) { + FatFSWrapper::FatFSWrapper(void) { + + } + + void FatFSWrapper::mount(void) { server.start(FATFS_THREAD_PRIORITY); } -/* FatFSWrapper::~FatFSWrapper() { + void FatFSWrapper::unmount(void) { - server.~FatFSServerThread(); - }*/ + server.stop(); + } uint32_t FatFSWrapper::getAndClearLastError(void) { -- cgit v1.2.3 From 2fa014a7be21c7d893fbbb2101c97c51971321b9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Jan 2013 12:45:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5031 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp index 4fd071f00..e63f71323 100644 --- a/os/fs/fatfs/fatfs_fsimpl.cpp +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -49,19 +49,13 @@ namespace chibios_fatfs { *------------------------------------------------------------------------*/ FatFSWrapper::FatFSServerThread::FatFSServerThread(void) : BaseStaticThread() { - - start(FATFS_THREAD_PRIORITY); } -/* FatFSWrapper::FatFSServerThread::~FatFSServerThread() { - - sendMessage(MSG_TERMINATE); - wait(); - }*/ - msg_t FatFSWrapper::FatFSServerThread::main() { msg_t sts; + setName("fatfs"); + /* Synchronous messages processing loop.*/ while (true) { ThreadReference tr = waitMessage(); -- cgit v1.2.3 From 6f470322d0241e1923bd1d83d66f291aff571658 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 4 Jan 2013 15:11:03 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5032 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 83 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 5 deletions(-) (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp index e63f71323..c10c1a89f 100644 --- a/os/fs/fatfs/fatfs_fsimpl.cpp +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -44,14 +44,82 @@ using namespace chibios_fs; */ namespace chibios_fatfs { + typedef struct { + uint32_t msg_code; + union { + struct { + + }; + } op; + } wmsg_t; + + /*------------------------------------------------------------------------* + * chibios_fatfs::FatFSFileWrapper * + *------------------------------------------------------------------------*/ + FatFSFileWrapper::FatFSFileWrapper(void) : fs(NULL) { + + } + + FatFSFileWrapper::FatFSFileWrapper(FatFSWrapper *fsref) : fs(fsref) { + + } + + size_t FatFSFileWrapper::write(const uint8_t *bp, size_t n) { + + return 0; + } + + size_t FatFSFileWrapper::read(uint8_t *bp, size_t n) { + + return 0; + } + + msg_t FatFSFileWrapper::put(uint8_t b) { + + return 0; + } + + msg_t FatFSFileWrapper::get(void) { + + return 0; + } + + uint32_t FatFSFileWrapper::getAndClearLastError(void) { + + return 0; + } + + fileoffset_t FatFSFileWrapper::getSize(void) { + + return 0; + } + + fileoffset_t FatFSFileWrapper::getPosition(void) { + + return 0; + } + + uint32_t FatFSFileWrapper::setPosition(fileoffset_t offset) { + + return 0; + } + + /*------------------------------------------------------------------------* + * chibios_fatfs::FatFSFilesPool * + *------------------------------------------------------------------------*/ + FatFSFilesPool::FatFSFilesPool(void) : MemoryPoolBuffer() { + + } + /*------------------------------------------------------------------------* - * chibios_fatfs::FatFSWrapper::FatFSServerThread * + * chibios_fatfs::FatFSServerThread * *------------------------------------------------------------------------*/ - FatFSWrapper::FatFSServerThread::FatFSServerThread(void) : + FatFSServerThread::FatFSServerThread(void) : BaseStaticThread() { } - msg_t FatFSWrapper::FatFSServerThread::main() { + msg_t FatFSServerThread::main() { msg_t sts; setName("fatfs"); @@ -72,14 +140,14 @@ namespace chibios_fatfs { } } - void FatFSWrapper::FatFSServerThread::stop(void) { + void FatFSServerThread::stop(void) { sendMessage(MSG_TERMINATE); wait(); } /*------------------------------------------------------------------------* - * chibios_fatfs::FatFSWrapper * + * chibios_fatfs::FatFSWrapper * *------------------------------------------------------------------------*/ FatFSWrapper::FatFSWrapper(void) { @@ -132,6 +200,11 @@ namespace chibios_fatfs { (void)fname; return NULL; } + + void FatFSWrapper::close(BaseFileStreamInterface *file) { + + (void)file; + } } /** @} */ -- cgit v1.2.3 From fe7aa77ae0686a8f42d2b7fdb86582de9e02b0d5 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 7 Jan 2013 09:53:34 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5038 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp index c10c1a89f..c2981aea4 100644 --- a/os/fs/fatfs/fatfs_fsimpl.cpp +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -107,8 +107,8 @@ namespace chibios_fatfs { /*------------------------------------------------------------------------* * chibios_fatfs::FatFSFilesPool * *------------------------------------------------------------------------*/ - FatFSFilesPool::FatFSFilesPool(void) : MemoryPoolBuffer() { + FatFSFilesPool::FatFSFilesPool(void) : ObjectsPool() { } -- cgit v1.2.3 From 184a71345c6a36a9a8664eda8fbcc3ea728267a8 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 2 Feb 2013 10:58:09 +0000 Subject: Updated license years. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5102 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/fs/fatfs/fatfs_fsimpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/fs/fatfs/fatfs_fsimpl.cpp') diff --git a/os/fs/fatfs/fatfs_fsimpl.cpp b/os/fs/fatfs/fatfs_fsimpl.cpp index c2981aea4..567c7544a 100644 --- a/os/fs/fatfs/fatfs_fsimpl.cpp +++ b/os/fs/fatfs/fatfs_fsimpl.cpp @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011,2012 Giovanni Di Sirio. + 2011,2012,2013 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3