From 04e29829b64a64a405125595dc371bd731766c68 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 5 Aug 2010 10:30:37 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2114 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 133 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 os/kernel/include/chfiles.h (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h new file mode 100644 index 000000000..ecd03fd04 --- /dev/null +++ b/os/kernel/include/chfiles.h @@ -0,0 +1,133 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 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 chfiles.h + * @brief Data files. + * @details This header defines abstract interfaces useful to access generic + * data files in a standardized way. + * + * @addtogroup data_files + * @details This module define an abstract interface for generic data files. + * Note that no code is present, data files are just abstract + * interface-like structures, you should look at the systems as to + * a set of abstract C++ classes (even if written in C). This system + * has the advantage to make the access to streams independent + * from the implementation logic.
+ * The data files interface can be used as base class for high level + * object types such as an API for a File System implementation. + * @{ + */ + +#ifndef _CHFILES_H_ +#define _CHFILES_H_ + +/** + * @brief Error code from the file stream methods. + */ +#define FILE_ERROR 0xFFFFFFFFUL + +/** + * @brief File offset type. + */ +typedef uint32_t fileoffset_t; + +/** + * @brief BaseFileStream specific methods. + */ +#define _base_file_stream_methods \ + _base_sequential_stream_methods \ + /* File close method.*/ \ + uint32_t (*close)(void *instance); \ + /* Get last error code method.*/ \ + int (*geterror)(void *instance); \ + /* File get size method.*/ \ + fileoffset_t (*getsize)(void *instance); \ + /* File get current position method.*/ \ + fileoffset_t (*getposition)(void *instance); \ + /* File seek method.*/ \ + fileoffset_t (*lseek)(void *instance, fileoffset_t offset); + +/** + * @brief @p BaseFileStream specific data. + * @note It is empty because @p BaseFileStream is only an interface + * without implementation. + */ +#define _base_file_stream_data \ + _base_sequential_stream_data + +/** + * @brief @p BaseFileStream virtual methods table. + */ +struct BaseFilelStreamVMT { + _base_file_stream_methods +}; + +/** + * @extends BaseSequentialStream + * + * @brief Base file stream class. + * @details This class represents a generic file data stream. + */ +typedef struct { + /** @brief Virtual Methods Table.*/ + const struct FileStreamVMT *vmt; + _base_file_stream_data +} BaseFileStream; + +/** + * @brief Base file Stream close. + * @details The function closes a file stream. + * + * @param[in] ip pointer to a @p BaseFileStream or derived class + */ +#define chFileStreamClose(ip) ((ip)->vmt->close(ip)) + +/** + * @brief Returns an implementation dependent error code. + * + * @param[in] ip pointer to a @p BaseFileStream or derived class + */ +#define chFileStreamGetError ((ip)->vmt->geterror(ip)) + +/** + * @brief Returns the current file size. + * + * @param[in] ip pointer to a @p BaseFileStream or derived class + */ +#define chFileStreamGetSize ((ip)->vmt->getposition(ip)) + +/** + * @brief Returns the current file pointer position. + * + * @param[in] ip pointer to a @p BaseFileStream or derived class + */ +#define chFileStreamGetPosition ((ip)->vmt->getposition(ip)) + +/** + * @brief Moves the file current pointer to an absolute position. + * + * @param[in] ip pointer to a @p BaseFileStream or derived class + * @param[in] offset new absolute position + */ +#define chFileStreamSeek ((ip)->vmt->lseek(ip, offset)) + +#endif /* _CHFILES_H_ */ + +/** @} */ -- cgit v1.2.3 From 0672a430f7581bd6e325ab18e49346beb6b1bb9d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 18 Sep 2010 10:28:03 +0000 Subject: Files related documentation fixes. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2182 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index ecd03fd04..3053419d9 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -24,12 +24,12 @@ * data files in a standardized way. * * @addtogroup data_files - * @details This module define an abstract interface for generic data files. - * Note that no code is present, data files are just abstract - * interface-like structures, you should look at the systems as to - * a set of abstract C++ classes (even if written in C). This system - * has the advantage to make the access to streams independent - * from the implementation logic.
+ * @details This module define an abstract interface for generic data files by + * extending the @p BaseSequentialStream interface. Note that no code + * is present, data files are just abstract interface-like structures, + * you should look at the systems as to a set of abstract C++ classes + * (even if written in C). This system has the advantage to make the + * access to streams independent from the implementation logic.
* The data files interface can be used as base class for high level * object types such as an API for a File System implementation. * @{ -- cgit v1.2.3 From 07351222e6d0b6b3dcd4f50ecb18bc09e7402d1c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 21 Sep 2010 10:22:06 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2184 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 3053419d9..dbe5e0567 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -96,6 +96,8 @@ typedef struct { * @details The function closes a file stream. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * + * @api */ #define chFileStreamClose(ip) ((ip)->vmt->close(ip)) @@ -103,6 +105,8 @@ typedef struct { * @brief Returns an implementation dependent error code. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * + * @api */ #define chFileStreamGetError ((ip)->vmt->geterror(ip)) @@ -110,6 +114,8 @@ typedef struct { * @brief Returns the current file size. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * + * @api */ #define chFileStreamGetSize ((ip)->vmt->getposition(ip)) @@ -117,6 +123,8 @@ typedef struct { * @brief Returns the current file pointer position. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * + * @api */ #define chFileStreamGetPosition ((ip)->vmt->getposition(ip)) @@ -125,6 +133,8 @@ typedef struct { * * @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] offset new absolute position + * + * @api */ #define chFileStreamSeek ((ip)->vmt->lseek(ip, offset)) -- cgit v1.2.3 From e7e79a6ccb4f3e320b2b8b7bad1b14d65218641d Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 18 Mar 2011 18:38:08 +0000 Subject: License updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2827 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index dbe5e0567..ff3f8274e 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -1,5 +1,6 @@ /* - ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio. + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From c9be79def630f153b0b2d28e905939c15743f989 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 23 Aug 2011 10:09:08 +0000 Subject: Kernel documentation fixes and improvements. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3251 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index ff3f8274e..69a63965e 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -74,6 +74,8 @@ typedef uint32_t fileoffset_t; _base_sequential_stream_data /** + * @extends BaseSequentialStreamVMT + * * @brief @p BaseFileStream virtual methods table. */ struct BaseFilelStreamVMT { @@ -92,6 +94,10 @@ typedef struct { _base_file_stream_data } BaseFileStream; +/** + * @name Macro Functions (BaseFileStream) + * @{ + */ /** * @brief Base file Stream close. * @details The function closes a file stream. @@ -138,6 +144,7 @@ typedef struct { * @api */ #define chFileStreamSeek ((ip)->vmt->lseek(ip, offset)) +/** @} */ #endif /* _CHFILES_H_ */ -- cgit v1.2.3 From de5dcbba856524599a8f06d3a9bdbf1b01db44c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 21 Jan 2012 14:29:42 +0000 Subject: License text updated with new year. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3846 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 69a63965e..7bbb1a14a 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -1,6 +1,6 @@ /* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, - 2011 Giovanni Di Sirio. + 2011,2012 Giovanni Di Sirio. This file is part of ChibiOS/RT. -- cgit v1.2.3 From faeafd8a6c57ae830d2f30b601323ed0ad24ff6b Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 1 Feb 2012 18:01:50 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3899 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 7bbb1a14a..25eaec5db 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -78,7 +78,7 @@ typedef uint32_t fileoffset_t; * * @brief @p BaseFileStream virtual methods table. */ -struct BaseFilelStreamVMT { +struct BaseFileStreamVMT { _base_file_stream_methods }; @@ -90,7 +90,7 @@ struct BaseFilelStreamVMT { */ typedef struct { /** @brief Virtual Methods Table.*/ - const struct FileStreamVMT *vmt; + const struct BaseFileStreamVMT *vmt; _base_file_stream_data } BaseFileStream; -- cgit v1.2.3 From aef4a4f4a815b58aaf1ba4288d1e58aafc589500 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 1 Feb 2012 19:43:05 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3902 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 25eaec5db..4c63690cc 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -39,10 +39,15 @@ #ifndef _CHFILES_H_ #define _CHFILES_H_ +/** + * @brief No error return code. + */ +#define FILE_OK 0 + /** * @brief Error code from the file stream methods. */ -#define FILE_ERROR 0xFFFFFFFFUL +#define FILE_ERROR 0xFFFFFFFFUL /** * @brief File offset type. @@ -63,7 +68,7 @@ typedef uint32_t fileoffset_t; /* File get current position method.*/ \ fileoffset_t (*getposition)(void *instance); \ /* File seek method.*/ \ - fileoffset_t (*lseek)(void *instance, fileoffset_t offset); + uint32_t (*lseek)(void *instance, fileoffset_t offset); /** * @brief @p BaseFileStream specific data. @@ -103,6 +108,9 @@ typedef struct { * @details The function closes a file stream. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * @return The operation status. + * @retval FILE_OK no error. + * @retval FILE_ERROR operation failed. * * @api */ @@ -112,38 +120,44 @@ typedef struct { * @brief Returns an implementation dependent error code. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * @return Implementation dependent error code. * * @api */ -#define chFileStreamGetError ((ip)->vmt->geterror(ip)) +#define chFileStreamGetError(ip) ((ip)->vmt->geterror(ip)) /** * @brief Returns the current file size. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * @return The file size. * * @api */ -#define chFileStreamGetSize ((ip)->vmt->getposition(ip)) +#define chFileStreamGetSize(ip) ((ip)->vmt->getposition(ip)) /** * @brief Returns the current file pointer position. * * @param[in] ip pointer to a @p BaseFileStream or derived class + * @return The current position inside the file. * * @api */ -#define chFileStreamGetPosition ((ip)->vmt->getposition(ip)) +#define chFileStreamGetPosition(ip) ((ip)->vmt->getposition(ip)) /** * @brief Moves the file current pointer to an absolute position. * * @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] offset new absolute position + * @return The operation status. + * @retval FILE_OK no error. + * @retval FILE_ERROR operation failed. * * @api */ -#define chFileStreamSeek ((ip)->vmt->lseek(ip, offset)) +#define chFileStreamSeek(ip) ((ip)->vmt->lseek(ip, offset)) /** @} */ #endif /* _CHFILES_H_ */ -- cgit v1.2.3 From c216fe762bf2cabfcaef6c860881c4ce7227a8d2 Mon Sep 17 00:00:00 2001 From: barthess Date: Wed, 1 Feb 2012 20:09:52 +0000 Subject: Fixed minor error in lseek wrapper. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3903 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 4c63690cc..4d2192eec 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -157,7 +157,7 @@ typedef struct { * * @api */ -#define chFileStreamSeek(ip) ((ip)->vmt->lseek(ip, offset)) +#define chFileStreamSeek(ip, offset) ((ip)->vmt->lseek(ip, offset)) /** @} */ #endif /* _CHFILES_H_ */ -- cgit v1.2.3 From 7ea2ed1e47ae76ff81dbbe1e9494cf7eca6fb561 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 28 Oct 2012 07:17:38 +0000 Subject: Fixed bug 3579660. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4781 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/kernel/include/chfiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 4d2192eec..03313d13a 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -134,7 +134,7 @@ typedef struct { * * @api */ -#define chFileStreamGetSize(ip) ((ip)->vmt->getposition(ip)) +#define chFileStreamGetSize(ip) ((ip)->vmt->getsize(ip)) /** * @brief Returns the current file pointer position. -- 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/kernel/include/chfiles.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/kernel/include/chfiles.h') diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h index 03313d13a..ad2974ad8 100644 --- a/os/kernel/include/chfiles.h +++ b/os/kernel/include/chfiles.h @@ -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