Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:13

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSAPIClassicIO
0007  *
0008  * @brief This header file defines the IO Manager API.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2020 embedded brains GmbH & Co. KG
0013  * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 /*
0038  * This file is part of the RTEMS quality process and was automatically
0039  * generated.  If you find something that needs to be fixed or
0040  * worded better please post a report or patch to an RTEMS mailing list
0041  * or raise a bug report:
0042  *
0043  * https://www.rtems.org/bugs.html
0044  *
0045  * For information on updating and regenerating please refer to the How-To
0046  * section in the Software Requirements Engineering chapter of the
0047  * RTEMS Software Engineering manual.  The manual is provided as a part of
0048  * a release.  For development sources please refer to the online
0049  * documentation at:
0050  *
0051  * https://docs.rtems.org
0052  */
0053 
0054 /* Generated from spec:/rtems/io/if/header */
0055 
0056 #ifndef _RTEMS_IO_H
0057 #define _RTEMS_IO_H
0058 
0059 #include <stdint.h>
0060 #include <rtems/rtems/status.h>
0061 
0062 #ifdef __cplusplus
0063 extern "C" {
0064 #endif
0065 
0066 /* Generated from spec:/rtems/io/if/group */
0067 
0068 /**
0069  * @defgroup RTEMSAPIClassicIO I/O Manager
0070  *
0071  * @ingroup RTEMSAPIClassic
0072  *
0073  * @brief The Input/Output (I/O) Manager provides a well-defined mechanism for
0074  *   accessing device drivers and a structured methodology for organizing
0075  *   device drivers.
0076  */
0077 
0078 /* Generated from spec:/rtems/io/if/device-driver */
0079 
0080 /**
0081  * @ingroup RTEMSAPIClassicIO
0082  *
0083  * @brief This type shall be used in device driver entry declarations and
0084  *   definitions.
0085  *
0086  * @par Notes
0087  * Device driver entries return an #rtems_status_code status code. This type
0088  * definition helps to document device driver entries in the source code.
0089  */
0090 typedef rtems_status_code rtems_device_driver;
0091 
0092 /* Generated from spec:/rtems/io/if/device-major-number */
0093 
0094 /**
0095  * @ingroup RTEMSAPIClassicIO
0096  *
0097  * @brief This integer type represents the major number of devices.
0098  *
0099  * @par Notes
0100  * The major number of a device is determined by rtems_io_register_driver() and
0101  * the application configuration (see @ref CONFIGURE_MAXIMUM_DRIVERS) .
0102  */
0103 typedef uint32_t rtems_device_major_number;
0104 
0105 /* Generated from spec:/rtems/io/if/device-minor-number */
0106 
0107 /**
0108  * @ingroup RTEMSAPIClassicIO
0109  *
0110  * @brief This integer type represents the minor number of devices.
0111  *
0112  * @par Notes
0113  * The minor number of devices is managed by the device driver.
0114  */
0115 typedef uint32_t rtems_device_minor_number;
0116 
0117 /* Generated from spec:/rtems/io/if/device-driver-entry */
0118 
0119 /**
0120  * @ingroup RTEMSAPIClassicIO
0121  *
0122  * @brief Device driver entries shall have this type.
0123  */
0124 typedef rtems_device_driver ( *rtems_device_driver_entry )(
0125   rtems_device_major_number,
0126   rtems_device_minor_number,
0127   void *
0128 );
0129 
0130 /* Generated from spec:/rtems/io/if/driver-address-table */
0131 
0132 /**
0133  * @ingroup RTEMSAPIClassicIO
0134  *
0135  * @brief This structure contains the device driver entries.
0136  *
0137  * This structure is used to register a device driver via
0138  * rtems_io_register_driver().
0139  */
0140 typedef struct {
0141   /**
0142    * @brief This member is the device driver initialization entry.
0143    *
0144    * This entry is called by rtems_io_initialize().
0145    */
0146   rtems_device_driver_entry initialization_entry;
0147 
0148   /**
0149    * @brief This member is the device driver open entry.
0150    *
0151    * This entry is called by rtems_io_open().
0152    */
0153   rtems_device_driver_entry open_entry;
0154 
0155   /**
0156    * @brief This member is the device driver close entry.
0157    *
0158    * This entry is called by rtems_io_close().
0159    */
0160   rtems_device_driver_entry close_entry;
0161 
0162   /**
0163    * @brief This member is the device driver read entry.
0164    *
0165    * This entry is called by rtems_io_read().
0166    */
0167   rtems_device_driver_entry read_entry;
0168 
0169   /**
0170    * @brief This member is the device driver write entry.
0171    *
0172    * This entry is called by rtems_io_write().
0173    */
0174   rtems_device_driver_entry write_entry;
0175 
0176   /**
0177    * @brief This member is the device driver control entry.
0178    *
0179    * This entry is called by rtems_io_control().
0180    */
0181   rtems_device_driver_entry control_entry;
0182 } rtems_driver_address_table;
0183 
0184 /* Generated from spec:/rtems/io/if/register-driver */
0185 
0186 /**
0187  * @ingroup RTEMSAPIClassicIO
0188  *
0189  * @brief Registers and initializes the device with the specified device driver
0190  *   address table and device major number in the Device Driver Table.
0191  *
0192  * @param major is the device major number.  Use a value of zero to let the
0193  *   system obtain a device major number automatically.
0194  *
0195  * @param driver_table is the device driver address table.
0196  *
0197  * @param[out] registered_major is the pointer to an
0198  *   ::rtems_device_major_number object.  When the directive call is
0199  *   successful, the device major number of the registered device will be
0200  *   stored in this object.
0201  *
0202  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0203  *
0204  * @retval ::RTEMS_INVALID_ADDRESS The device major number of the device was
0205  *   NULL.
0206  *
0207  * @retval ::RTEMS_INVALID_ADDRESS The device driver address table was empty.
0208  *
0209  * @retval ::RTEMS_INVALID_NUMBER The device major number of the device was out
0210  *   of range, see @ref CONFIGURE_MAXIMUM_DRIVERS.
0211  *
0212  * @retval ::RTEMS_TOO_MANY The system was unable to obtain a device major
0213  *   number.
0214  *
0215  * @retval ::RTEMS_RESOURCE_IN_USE The device major number was already in use.
0216  *
0217  * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt
0218  *   context.
0219  *
0220  * @return Other status codes may be returned by rtems_io_initialize().
0221  *
0222  * @par Notes
0223  * @parblock
0224  * If the device major number equals zero a device major number will be
0225  * obtained.  The device major number of the registered driver will be
0226  * returned.
0227  *
0228  * After a successful registration, the rtems_io_initialize() directive will be
0229  * called to initialize the device.
0230  * @endparblock
0231  */
0232 rtems_status_code rtems_io_register_driver(
0233   rtems_device_major_number         major,
0234   const rtems_driver_address_table *driver_table,
0235   rtems_device_major_number        *registered_major
0236 );
0237 
0238 /* Generated from spec:/rtems/io/if/unregister-driver */
0239 
0240 /**
0241  * @ingroup RTEMSAPIClassicIO
0242  *
0243  * @brief Removes a device driver specified by the device major number from the
0244  *   Device Driver Table.
0245  *
0246  * @param major is the major number of the device.
0247  *
0248  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0249  *
0250  * @retval ::RTEMS_UNSATISFIED The device major number was invalid.
0251  *
0252  * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt
0253  *   context.
0254  *
0255  * @par Notes
0256  * Currently no specific checks are made and the driver is not closed.
0257  */
0258 rtems_status_code rtems_io_unregister_driver(
0259   rtems_device_major_number major
0260 );
0261 
0262 /* Generated from spec:/rtems/io/if/initialize */
0263 
0264 /**
0265  * @ingroup RTEMSAPIClassicIO
0266  *
0267  * @brief Initializes the device specified by the device major and minor
0268  *   numbers.
0269  *
0270  * @param major is the major number of the device.
0271  *
0272  * @param minor is the minor number of the device.
0273  *
0274  * @param argument is the argument passed to the device driver initialization
0275  *   entry.
0276  *
0277  * This directive calls the device driver initialization entry registered in
0278  * the Device Driver Table for the specified device major number.
0279  *
0280  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0281  *
0282  * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
0283  *
0284  * @return Other status codes may be returned by the device driver
0285  *   initialization entry.
0286  *
0287  * @par Notes
0288  * @parblock
0289  * This directive is automatically invoked for each device driver defined by
0290  * the application configuration during the system initialization and via the
0291  * rtems_io_register_driver() directive.
0292  *
0293  * A device driver initialization entry is responsible for initializing all
0294  * hardware and data structures associated with a device.  If necessary, it can
0295  * allocate memory to be used during other operations.
0296  * @endparblock
0297  */
0298 rtems_status_code rtems_io_initialize(
0299   rtems_device_major_number major,
0300   rtems_device_minor_number minor,
0301   void                     *argument
0302 );
0303 
0304 /* Generated from spec:/rtems/io/if/register-name */
0305 
0306 /**
0307  * @ingroup RTEMSAPIClassicIO
0308  *
0309  * @brief Registers the device specified by the device major and minor numbers
0310  *   in the file system under the specified name.
0311  *
0312  * @param device_name is the device name in the file system.
0313  *
0314  * @param major is the device major number.
0315  *
0316  * @param minor is the device minor number.
0317  *
0318  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0319  *
0320  * @retval ::RTEMS_TOO_MANY The name was already in use or other errors
0321  *   occurred.
0322  *
0323  * @par Notes
0324  * The device is registered as a character device.
0325  */
0326 rtems_status_code rtems_io_register_name(
0327   const char               *device_name,
0328   rtems_device_major_number major,
0329   rtems_device_minor_number minor
0330 );
0331 
0332 /* Generated from spec:/rtems/io/if/open */
0333 
0334 /**
0335  * @ingroup RTEMSAPIClassicIO
0336  *
0337  * @brief Opens the device specified by the device major and minor numbers.
0338  *
0339  * @param major is the major number of the device.
0340  *
0341  * @param minor is the minor number of the device.
0342  *
0343  * @param argument is the argument passed to the device driver close entry.
0344  *
0345  * This directive calls the device driver open entry registered in the Device
0346  * Driver Table for the specified device major number.
0347  *
0348  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0349  *
0350  * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
0351  *
0352  * @return Other status codes may be returned by the device driver open entry.
0353  *
0354  * @par Notes
0355  * The open entry point is commonly used by device drivers to provide exclusive
0356  * access to a device.
0357  */
0358 rtems_status_code rtems_io_open(
0359   rtems_device_major_number major,
0360   rtems_device_minor_number minor,
0361   void                     *argument
0362 );
0363 
0364 /* Generated from spec:/rtems/io/if/close */
0365 
0366 /**
0367  * @ingroup RTEMSAPIClassicIO
0368  *
0369  * @brief Closes the device specified by the device major and minor numbers.
0370  *
0371  * @param major is the major number of the device.
0372  *
0373  * @param minor is the minor number of the device.
0374  *
0375  * @param argument is the argument passed to the device driver close entry.
0376  *
0377  * This directive calls the device driver close entry registered in the Device
0378  * Driver Table for the specified device major number.
0379  *
0380  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0381  *
0382  * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
0383  *
0384  * @return Other status codes may be returned by the device driver close entry.
0385  *
0386  * @par Notes
0387  * The close entry point is commonly used by device drivers to relinquish
0388  * exclusive access to a device.
0389  */
0390 rtems_status_code rtems_io_close(
0391   rtems_device_major_number major,
0392   rtems_device_minor_number minor,
0393   void                     *argument
0394 );
0395 
0396 /* Generated from spec:/rtems/io/if/read */
0397 
0398 /**
0399  * @ingroup RTEMSAPIClassicIO
0400  *
0401  * @brief Reads from the device specified by the device major and minor
0402  *   numbers.
0403  *
0404  * @param major is the major number of the device.
0405  *
0406  * @param minor is the minor number of the device.
0407  *
0408  * @param argument is the argument passed to the device driver read entry.
0409  *
0410  * This directive calls the device driver read entry registered in the Device
0411  * Driver Table for the specified device major number.
0412  *
0413  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0414  *
0415  * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
0416  *
0417  * @return Other status codes may be returned by the device driver read entry.
0418  *
0419  * @par Notes
0420  * Read operations typically require a buffer address as part of the argument
0421  * parameter block.  The contents of this buffer will be replaced with data
0422  * from the device.
0423  */
0424 rtems_status_code rtems_io_read(
0425   rtems_device_major_number major,
0426   rtems_device_minor_number minor,
0427   void                     *argument
0428 );
0429 
0430 /* Generated from spec:/rtems/io/if/write */
0431 
0432 /**
0433  * @ingroup RTEMSAPIClassicIO
0434  *
0435  * @brief Writes to the device specified by the device major and minor numbers.
0436  *
0437  * @param major is the major number of the device.
0438  *
0439  * @param minor is the minor number of the device.
0440  *
0441  * @param argument is the argument passed to the device driver write entry.
0442  *
0443  * This directive calls the device driver write entry registered in the Device
0444  * Driver Table for the specified device major number.
0445  *
0446  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0447  *
0448  * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
0449  *
0450  * @return Other status codes may be returned by the device driver write entry.
0451  *
0452  * @par Notes
0453  * Write operations typically require a buffer address as part of the argument
0454  * parameter block.  The contents of this buffer will be sent to the device.
0455  */
0456 rtems_status_code rtems_io_write(
0457   rtems_device_major_number major,
0458   rtems_device_minor_number minor,
0459   void                     *argument
0460 );
0461 
0462 /* Generated from spec:/rtems/io/if/control */
0463 
0464 /**
0465  * @ingroup RTEMSAPIClassicIO
0466  *
0467  * @brief Controls the device specified by the device major and minor numbers.
0468  *
0469  * @param major is the major number of the device.
0470  *
0471  * @param minor is the minor number of the device.
0472  *
0473  * @param argument is the argument passed to the device driver I/O control
0474  *   entry.
0475  *
0476  * This directive calls the device driver I/O control entry registered in the
0477  * Device Driver Table for the specified device major number.
0478  *
0479  * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
0480  *
0481  * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
0482  *
0483  * @return Other status codes may be returned by the device driver I/O control
0484  *   entry.
0485  *
0486  * @par Notes
0487  * The exact functionality of the driver entry called by this directive is
0488  * driver dependent.  It should not be assumed that the control entries of two
0489  * device drivers are compatible.  For example, an RS-232 driver I/O control
0490  * operation may change the baud of a serial line, while an I/O control
0491  * operation for a floppy disk driver may cause a seek operation.
0492  */
0493 rtems_status_code rtems_io_control(
0494   rtems_device_major_number major,
0495   rtems_device_minor_number minor,
0496   void                     *argument
0497 );
0498 
0499 #ifdef __cplusplus
0500 }
0501 #endif
0502 
0503 #endif /* _RTEMS_IO_H */