From c3a772e2f27c09d287c524c7461f5e64bebe9ee5 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 28 May 2023 15:57:05 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@16272 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/xhal/codegen/hal_block_io.xml | 39 +++++++++ os/xhal/codegen/modules.xml | 2 + os/xhal/include/hal_block_io.h | 132 +++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 os/xhal/codegen/hal_block_io.xml create mode 100644 os/xhal/include/hal_block_io.h diff --git a/os/xhal/codegen/hal_block_io.xml b/os/xhal/codegen/hal_block_io.xml new file mode 100644 index 000000000..93e579857 --- /dev/null +++ b/os/xhal/codegen/hal_block_io.xml @@ -0,0 +1,39 @@ + + + Block devices interface. + + oop_base_interface.xml + + + + + Base block device interface. +
+ + + + + Removable media detection. + The media state. + If media not inserted. + If media is inserted. + + + + Returns the media write protection status. + The media state. + If media is writable. + If media is not writable. + + + +
+
+
+ + +
\ No newline at end of file diff --git a/os/xhal/codegen/modules.xml b/os/xhal/codegen/modules.xml index 74e01bb62..0df0c791f 100644 --- a/os/xhal/codegen/modules.xml +++ b/os/xhal/codegen/modules.xml @@ -2,6 +2,7 @@ + ]> @@ -13,6 +14,7 @@ &hal_base_driver; &hal_channels; + &hal_block_io; &hal_buffered_serial; &hal_sio; diff --git a/os/xhal/include/hal_block_io.h b/os/xhal/include/hal_block_io.h new file mode 100644 index 000000000..8e9b96664 --- /dev/null +++ b/os/xhal/include/hal_block_io.h @@ -0,0 +1,132 @@ +/* + ChibiOS - Copyright (C) 2006..2023 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file hal_block_io.h + * @brief Generated Block I/O header. + * @note This is a generated file, do not edit directly. + * + * @addtogroup HAL_BLOCK_IO + * @brief Block devices interface. + * @{ + */ + +#ifndef HAL_BLOCK_IO_H +#define HAL_BLOCK_IO_H + +/*===========================================================================*/ +/* Module constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module pre-compile time settings. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module macros. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Module data structures and types. */ +/*===========================================================================*/ + +/** + * @interface block_io_i + * @extends base_interface_i. + * + * @brief Base block device interface. + * @details This header defines an abstract interface useful to access + * generic I/O block devices in a standardized way. + * + * @name Interface @p block_io_i structures + * @{ + */ + +/** + * @brief Type of a block device interface. + */ +typedef struct block_io block_io_i; + +/** + * @brief Interface @p block_io_i virtual methods table. + */ +struct block_io_vmt { + /* Memory offset between this interface structure and begin of + the implementing class structure.*/ + size_t instance_offset; + /* From base_interface_i.*/ + /* From block_io_i.*/ + bool (*is_inserted)(void *ip); +}; + +/** + * @brief Structure representing a block device interface. + */ +struct block_io { + /** + * @brief Virtual Methods Table. + */ + const struct block_io_vmt *vmt; +}; +/** @} */ + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __cplusplus +} +#endif + +/*===========================================================================*/ +/* Module inline functions. */ +/*===========================================================================*/ + +/** + * @name Virtual methods of block_io_i + * @{ + */ +/** + * @memberof block_io_i + * @public + * + * @brief Removable media detection. + * + * @param[in,out] ip Pointer to a @p block_io_i instance. + * @return The media state. + * @retval false If media not inserted. + * @retval true If media is inserted. + * + * @api + */ +CC_FORCE_INLINE +static inline bool blkIsInserted(void *ip) { + block_io_i *self = (block_io_i *)ip; + + return self->vmt->is_inserted(ip); +} +/** @} */ + +#endif /* HAL_BLOCK_IO_H */ + +/** @} */