source: rtems/cpukit/include/rtems/io.h @ ced13022

Last change on this file since ced13022 was ced13022, checked in by Sebastian Huber <sebastian.huber@…>, on 11/11/20 at 07:15:02

Improve automatically generated warning

  • Property mode set to 100644
File size: 14.7 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSAPIClassicIO
7 *
8 * @brief This header file defines the IO Manager API.
9 */
10
11/*
12 * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
13 * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 *    notice, this list of conditions and the following disclaimer in the
22 *    documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/*
38 * This file is part of the RTEMS quality process and was automatically
39 * generated.  If you find something that needs to be fixed or
40 * worded better please post a report or patch to an RTEMS mailing list
41 * or raise a bug report:
42 *
43 * https://docs.rtems.org/branches/master/user/support/bugs.html
44 *
45 * For information on updating and regenerating please refer to:
46 *
47 * https://docs.rtems.org/branches/master/eng/req/howto.html
48 */
49
50/* Generated from spec:/rtems/io/if/header */
51
52#ifndef _RTEMS_IO_H
53#define _RTEMS_IO_H
54
55#include <stdint.h>
56#include <rtems/rtems/status.h>
57
58#ifdef __cplusplus
59extern "C" {
60#endif
61
62/* Generated from spec:/rtems/io/if/group */
63
64/**
65 * @defgroup RTEMSAPIClassicIO I/O Manager
66 *
67 * @ingroup RTEMSAPIClassic
68 *
69 * @brief The Input/Output (I/O) Manager provides a well-defined mechanism for
70 *   accessing device drivers and a structured methodology for organizing
71 *   device drivers.
72 */
73
74/* Generated from spec:/rtems/io/if/device-driver */
75
76/**
77 * @ingroup RTEMSAPIClassicIO
78 *
79 * @brief This type shall be used in device driver entry declarations and
80 *   definitions.
81 *
82 * Device driver entries return an #rtems_status_code status code. This type
83 * definition helps to document device driver entries in the source code.
84 */
85typedef rtems_status_code rtems_device_driver;
86
87/* Generated from spec:/rtems/io/if/device-major-number */
88
89/**
90 * @ingroup RTEMSAPIClassicIO
91 *
92 * @brief This integer type represents the major number of devices.
93 *
94 * The major number of a device is determined by rtems_io_register_driver() and
95 * the application configuration (see #CONFIGURE_MAXIMUM_DRIVERS) .
96 */
97typedef uint32_t rtems_device_major_number;
98
99/* Generated from spec:/rtems/io/if/device-minor-number */
100
101/**
102 * @ingroup RTEMSAPIClassicIO
103 *
104 * @brief This integer type represents the minor number of devices.
105 *
106 * The minor number of devices is managed by the device driver.
107 */
108typedef uint32_t rtems_device_minor_number;
109
110/* Generated from spec:/rtems/io/if/device-driver-entry */
111
112/**
113 * @ingroup RTEMSAPIClassicIO
114 *
115 * @brief Device driver entries shall have this type.
116 */
117typedef rtems_device_driver ( *rtems_device_driver_entry )(
118  rtems_device_major_number,
119  rtems_device_minor_number,
120  void *
121);
122
123/* Generated from spec:/rtems/io/if/driver-address-table */
124
125/**
126 * @ingroup RTEMSAPIClassicIO
127 *
128 * @brief This structure contains the device driver entries.
129 *
130 * This structure is used to register a device driver via
131 * rtems_io_register_driver().
132 */
133typedef struct {
134  /**
135   * @brief This member is the device driver initialization entry.
136   *
137   * This entry is called by rtems_io_initialize().
138   */
139  rtems_device_driver_entry initialization_entry;
140
141  /**
142   * @brief This member is the device driver open entry.
143   *
144   * This entry is called by rtems_io_open().
145   */
146  rtems_device_driver_entry open_entry;
147
148  /**
149   * @brief This member is the device driver close entry.
150   *
151   * This entry is called by rtems_io_close().
152   */
153  rtems_device_driver_entry close_entry;
154
155  /**
156   * @brief This member is the device driver read entry.
157   *
158   * This entry is called by rtems_io_read().
159   */
160  rtems_device_driver_entry read_entry;
161
162  /**
163   * @brief This member is the device driver write entry.
164   *
165   * This entry is called by rtems_io_write().
166   */
167  rtems_device_driver_entry write_entry;
168
169  /**
170   * @brief This member is the device driver control entry.
171   *
172   * This entry is called by rtems_io_control().
173   */
174  rtems_device_driver_entry control_entry;
175} rtems_driver_address_table;
176
177/* Generated from spec:/rtems/io/if/register-driver */
178
179/**
180 * @ingroup RTEMSAPIClassicIO
181 *
182 * @brief Registers and initializes the device with the specified device driver
183 *   address table and device major number in the Device Driver Table.
184 *
185 * If the device major number equals zero a device major number will be
186 * obtained.  The device major number of the registered driver will be
187 * returned.
188 *
189 * After a successful registration, the rtems_io_initialize() directive will be
190 * called to initialize the device.
191 *
192 * @param major is the device major number.  Use a value of zero to let the
193 *   system obtain a device major number automatically.
194 *
195 * @param driver_table is the device driver address table.
196 *
197 * @param[out] registered_major is the pointer to a device major number
198 *   variable.  The device major number of the registered device will be stored
199 *   in this variable, in case of a successful operation.
200 *
201 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
202 *
203 * @retval ::RTEMS_INVALID_ADDRESS The device major number of the device was
204 *   NULL.
205 *
206 * @retval ::RTEMS_INVALID_ADDRESS The device driver address table was empty.
207 *
208 * @retval ::RTEMS_INVALID_NUMBER The device major number of the device was out
209 *   of range, see #CONFIGURE_MAXIMUM_DRIVERS.
210 *
211 * @retval ::RTEMS_TOO_MANY The system was unable to obtain a device major
212 *   number.
213 *
214 * @retval ::RTEMS_RESOURCE_IN_USE The device major number was already in use.
215 *
216 * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt
217 *   context.
218 *
219 * @return Other status codes may be returned by rtems_io_initialize().
220 */
221rtems_status_code rtems_io_register_driver(
222  rtems_device_major_number         major,
223  const rtems_driver_address_table *driver_table,
224  rtems_device_major_number        *registered_major
225);
226
227/* Generated from spec:/rtems/io/if/unregister-driver */
228
229/**
230 * @ingroup RTEMSAPIClassicIO
231 *
232 * @brief Removes a device driver specified by the device major number from the
233 *   Device Driver Table.
234 *
235 * Currently no specific checks are made and the driver is not closed.
236 *
237 * @param major is the major number of the device.
238 *
239 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
240 *
241 * @retval ::RTEMS_UNSATISFIED The device major number was invalid.
242 *
243 * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt
244 *   context.
245 */
246rtems_status_code rtems_io_unregister_driver(
247  rtems_device_major_number major
248);
249
250/* Generated from spec:/rtems/io/if/initialize */
251
252/**
253 * @ingroup RTEMSAPIClassicIO
254 *
255 * @brief Initializes the device specified by the device major and minor
256 *   numbers.
257 *
258 * This directive calls the device driver initialization entry registered in
259 * the Device Driver Table for the specified device major number.
260 *
261 * This directive is automatically invoked for each device driver defined by
262 * the application configuration during the system initialization and via the
263 * rtems_io_register_driver() directive.
264 *
265 * A device driver initialization entry is responsible for initializing all
266 * hardware and data structures associated with a device.  If necessary, it can
267 * allocate memory to be used during other operations.
268 *
269 * @param major is the major number of the device.
270 *
271 * @param minor is the minor number of the device.
272 *
273 * @param argument is the argument passed to the device driver initialization
274 *   entry.
275 *
276 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
277 *
278 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
279 *
280 * @return Other status codes may be returned by the device driver
281 *   initialization entry.
282 */
283rtems_status_code rtems_io_initialize(
284  rtems_device_major_number major,
285  rtems_device_minor_number minor,
286  void                     *argument
287);
288
289/* Generated from spec:/rtems/io/if/register-name */
290
291/**
292 * @ingroup RTEMSAPIClassicIO
293 *
294 * @brief Registers the device specified by the device major and minor numbers
295 *   in the file system under the specified name.
296 *
297 * The device is registered as a character device.
298 *
299 * @param device_name is the device name in the file system.
300 *
301 * @param major is the device major number.
302 *
303 * @param minor is the device minor number.
304 *
305 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
306 *
307 * @retval ::RTEMS_TOO_MANY The name was already in use or other errors
308 *   occurred.
309 */
310rtems_status_code rtems_io_register_name(
311  const char               *device_name,
312  rtems_device_major_number major,
313  rtems_device_minor_number minor
314);
315
316/* Generated from spec:/rtems/io/if/open */
317
318/**
319 * @ingroup RTEMSAPIClassicIO
320 *
321 * @brief Opens the device specified by the device major and minor numbers.
322 *
323 * This directive calls the device driver open entry registered in the Device
324 * Driver Table for the specified device major number.
325 *
326 * The open entry point is commonly used by device drivers to provide exclusive
327 * access to a device.
328 *
329 * @param major is the major number of the device.
330 *
331 * @param minor is the minor number of the device.
332 *
333 * @param argument is the argument passed to the device driver close entry.
334 *
335 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
336 *
337 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
338 *
339 * @return Other status codes may be returned by the device driver open entry.
340 */
341rtems_status_code rtems_io_open(
342  rtems_device_major_number major,
343  rtems_device_minor_number minor,
344  void                     *argument
345);
346
347/* Generated from spec:/rtems/io/if/close */
348
349/**
350 * @ingroup RTEMSAPIClassicIO
351 *
352 * @brief Closes the device specified by the device major and minor numbers.
353 *
354 * This directive calls the device driver close entry registered in the Device
355 * Driver Table for the specified device major number.
356 *
357 * The close entry point is commonly used by device drivers to relinquish
358 * exclusive access to a device.
359 *
360 * @param major is the major number of the device.
361 *
362 * @param minor is the minor number of the device.
363 *
364 * @param argument is the argument passed to the device driver close entry.
365 *
366 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
367 *
368 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
369 *
370 * @return Other status codes may be returned by the device driver close entry.
371 */
372rtems_status_code rtems_io_close(
373  rtems_device_major_number major,
374  rtems_device_minor_number minor,
375  void                     *argument
376);
377
378/* Generated from spec:/rtems/io/if/read */
379
380/**
381 * @ingroup RTEMSAPIClassicIO
382 *
383 * @brief Reads from the device specified by the device major and minor
384 *   numbers.
385 *
386 * This directive calls the device driver read entry registered in the Device
387 * Driver Table for the specified device major number.
388 *
389 * Read operations typically require a buffer address as part of the argument
390 * parameter block.  The contents of this buffer will be replaced with data
391 * from the device.
392 *
393 * @param major is the major number of the device.
394 *
395 * @param minor is the minor number of the device.
396 *
397 * @param argument is the argument passed to the device driver read entry.
398 *
399 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
400 *
401 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
402 *
403 * @return Other status codes may be returned by the device driver read entry.
404 */
405rtems_status_code rtems_io_read(
406  rtems_device_major_number major,
407  rtems_device_minor_number minor,
408  void                     *argument
409);
410
411/* Generated from spec:/rtems/io/if/write */
412
413/**
414 * @ingroup RTEMSAPIClassicIO
415 *
416 * @brief Writes to the device specified by the device major and minor numbers.
417 *
418 * This directive calls the device driver write entry registered in the Device
419 * Driver Table for the specified device major number.
420 *
421 * Write operations typically require a buffer address as part of the argument
422 * parameter block.  The contents of this buffer will be sent to the device.
423 *
424 * @param major is the major number of the device.
425 *
426 * @param minor is the minor number of the device.
427 *
428 * @param argument is the argument passed to the device driver write entry.
429 *
430 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
431 *
432 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
433 *
434 * @return Other status codes may be returned by the device driver write entry.
435 */
436rtems_status_code rtems_io_write(
437  rtems_device_major_number major,
438  rtems_device_minor_number minor,
439  void                     *argument
440);
441
442/* Generated from spec:/rtems/io/if/control */
443
444/**
445 * @ingroup RTEMSAPIClassicIO
446 *
447 * @brief Controls the device specified by the device major and minor numbers.
448 *
449 * This directive calls the device driver I/O control entry registered in the
450 * Device Driver Table for the specified device major number.
451 *
452 * The exact functionality of the driver entry called by this directive is
453 * driver dependent.  It should not be assumed that the control entries of two
454 * device drivers are compatible.  For example, an RS-232 driver I/O control
455 * operation may change the baud of a serial line, while an I/O control
456 * operation for a floppy disk driver may cause a seek operation.
457 *
458 * @param major is the major number of the device.
459 *
460 * @param minor is the minor number of the device.
461 *
462 * @param argument is the argument passed to the device driver I/O control
463 *   entry.
464 *
465 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
466 *
467 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
468 *
469 * @return Other status codes may be returned by the device driver I/O control
470 *   entry.
471 */
472rtems_status_code rtems_io_control(
473  rtems_device_major_number major,
474  rtems_device_minor_number minor,
475  void                     *argument
476);
477
478#ifdef __cplusplus
479}
480#endif
481
482#endif /* _RTEMS_IO_H */
Note: See TracBrowser for help on using the repository browser.