source: rtems/cpukit/include/rtems/io.h @ 6abdd89

Last change on this file since 6abdd89 was 6abdd89, checked in by Sebastian Huber <sebastian.huber@…>, on 06/14/21 at 07:57:51

Use a common phrase for pointer parameters

Mention the type of the pointer in the parameter description. Use the
more general term "object" instead of "variable".

Update #3993.

  • Property mode set to 100644
File size: 15.1 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://www.rtems.org/bugs.html
44 *
45 * For information on updating and regenerating please refer to the How-To
46 * section in the Software Requirements Engineering chapter of the
47 * RTEMS Software Engineering manual.  The manual is provided as a part of
48 * a release.  For development sources please refer to the online
49 * documentation at:
50 *
51 * https://docs.rtems.org
52 */
53
54/* Generated from spec:/rtems/io/if/header */
55
56#ifndef _RTEMS_IO_H
57#define _RTEMS_IO_H
58
59#include <stdint.h>
60#include <rtems/rtems/status.h>
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66/* Generated from spec:/rtems/io/if/group */
67
68/**
69 * @defgroup RTEMSAPIClassicIO I/O Manager
70 *
71 * @ingroup RTEMSAPIClassic
72 *
73 * @brief The Input/Output (I/O) Manager provides a well-defined mechanism for
74 *   accessing device drivers and a structured methodology for organizing
75 *   device drivers.
76 */
77
78/* Generated from spec:/rtems/io/if/device-driver */
79
80/**
81 * @ingroup RTEMSAPIClassicIO
82 *
83 * @brief This type shall be used in device driver entry declarations and
84 *   definitions.
85 *
86 * @par Notes
87 * Device driver entries return an #rtems_status_code status code. This type
88 * definition helps to document device driver entries in the source code.
89 */
90typedef rtems_status_code rtems_device_driver;
91
92/* Generated from spec:/rtems/io/if/device-major-number */
93
94/**
95 * @ingroup RTEMSAPIClassicIO
96 *
97 * @brief This integer type represents the major number of devices.
98 *
99 * @par Notes
100 * The major number of a device is determined by rtems_io_register_driver() and
101 * the application configuration (see #CONFIGURE_MAXIMUM_DRIVERS) .
102 */
103typedef uint32_t rtems_device_major_number;
104
105/* Generated from spec:/rtems/io/if/device-minor-number */
106
107/**
108 * @ingroup RTEMSAPIClassicIO
109 *
110 * @brief This integer type represents the minor number of devices.
111 *
112 * @par Notes
113 * The minor number of devices is managed by the device driver.
114 */
115typedef uint32_t rtems_device_minor_number;
116
117/* Generated from spec:/rtems/io/if/device-driver-entry */
118
119/**
120 * @ingroup RTEMSAPIClassicIO
121 *
122 * @brief Device driver entries shall have this type.
123 */
124typedef rtems_device_driver ( *rtems_device_driver_entry )(
125  rtems_device_major_number,
126  rtems_device_minor_number,
127  void *
128);
129
130/* Generated from spec:/rtems/io/if/driver-address-table */
131
132/**
133 * @ingroup RTEMSAPIClassicIO
134 *
135 * @brief This structure contains the device driver entries.
136 *
137 * This structure is used to register a device driver via
138 * rtems_io_register_driver().
139 */
140typedef struct {
141  /**
142   * @brief This member is the device driver initialization entry.
143   *
144   * This entry is called by rtems_io_initialize().
145   */
146  rtems_device_driver_entry initialization_entry;
147
148  /**
149   * @brief This member is the device driver open entry.
150   *
151   * This entry is called by rtems_io_open().
152   */
153  rtems_device_driver_entry open_entry;
154
155  /**
156   * @brief This member is the device driver close entry.
157   *
158   * This entry is called by rtems_io_close().
159   */
160  rtems_device_driver_entry close_entry;
161
162  /**
163   * @brief This member is the device driver read entry.
164   *
165   * This entry is called by rtems_io_read().
166   */
167  rtems_device_driver_entry read_entry;
168
169  /**
170   * @brief This member is the device driver write entry.
171   *
172   * This entry is called by rtems_io_write().
173   */
174  rtems_device_driver_entry write_entry;
175
176  /**
177   * @brief This member is the device driver control entry.
178   *
179   * This entry is called by rtems_io_control().
180   */
181  rtems_device_driver_entry control_entry;
182} rtems_driver_address_table;
183
184/* Generated from spec:/rtems/io/if/register-driver */
185
186/**
187 * @ingroup RTEMSAPIClassicIO
188 *
189 * @brief Registers and initializes the device with the specified device driver
190 *   address table and device major number in the Device Driver Table.
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 an
198 *   ::rtems_device_major_number object.  When the directive call is
199 *   successful, the device major number of the registered device will be
200 *   stored in this object.
201 *
202 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
203 *
204 * @retval ::RTEMS_INVALID_ADDRESS The device major number of the device was
205 *   NULL.
206 *
207 * @retval ::RTEMS_INVALID_ADDRESS The device driver address table was empty.
208 *
209 * @retval ::RTEMS_INVALID_NUMBER The device major number of the device was out
210 *   of range, see #CONFIGURE_MAXIMUM_DRIVERS.
211 *
212 * @retval ::RTEMS_TOO_MANY The system was unable to obtain a device major
213 *   number.
214 *
215 * @retval ::RTEMS_RESOURCE_IN_USE The device major number was already in use.
216 *
217 * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt
218 *   context.
219 *
220 * @return Other status codes may be returned by rtems_io_initialize().
221 *
222 * @par Notes
223 * @parblock
224 * If the device major number equals zero a device major number will be
225 * obtained.  The device major number of the registered driver will be
226 * returned.
227 *
228 * After a successful registration, the rtems_io_initialize() directive will be
229 * called to initialize the device.
230 * @endparblock
231 */
232rtems_status_code rtems_io_register_driver(
233  rtems_device_major_number         major,
234  const rtems_driver_address_table *driver_table,
235  rtems_device_major_number        *registered_major
236);
237
238/* Generated from spec:/rtems/io/if/unregister-driver */
239
240/**
241 * @ingroup RTEMSAPIClassicIO
242 *
243 * @brief Removes a device driver specified by the device major number from the
244 *   Device Driver Table.
245 *
246 * @param major is the major number of the device.
247 *
248 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
249 *
250 * @retval ::RTEMS_UNSATISFIED The device major number was invalid.
251 *
252 * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt
253 *   context.
254 *
255 * @par Notes
256 * Currently no specific checks are made and the driver is not closed.
257 */
258rtems_status_code rtems_io_unregister_driver(
259  rtems_device_major_number major
260);
261
262/* Generated from spec:/rtems/io/if/initialize */
263
264/**
265 * @ingroup RTEMSAPIClassicIO
266 *
267 * @brief Initializes the device specified by the device major and minor
268 *   numbers.
269 *
270 * @param major is the major number of the device.
271 *
272 * @param minor is the minor number of the device.
273 *
274 * @param argument is the argument passed to the device driver initialization
275 *   entry.
276 *
277 * This directive calls the device driver initialization entry registered in
278 * the Device Driver Table for the specified device major number.
279 *
280 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
281 *
282 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
283 *
284 * @return Other status codes may be returned by the device driver
285 *   initialization entry.
286 *
287 * @par Notes
288 * @parblock
289 * This directive is automatically invoked for each device driver defined by
290 * the application configuration during the system initialization and via the
291 * rtems_io_register_driver() directive.
292 *
293 * A device driver initialization entry is responsible for initializing all
294 * hardware and data structures associated with a device.  If necessary, it can
295 * allocate memory to be used during other operations.
296 * @endparblock
297 */
298rtems_status_code rtems_io_initialize(
299  rtems_device_major_number major,
300  rtems_device_minor_number minor,
301  void                     *argument
302);
303
304/* Generated from spec:/rtems/io/if/register-name */
305
306/**
307 * @ingroup RTEMSAPIClassicIO
308 *
309 * @brief Registers the device specified by the device major and minor numbers
310 *   in the file system under the specified name.
311 *
312 * @param device_name is the device name in the file system.
313 *
314 * @param major is the device major number.
315 *
316 * @param minor is the device minor number.
317 *
318 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
319 *
320 * @retval ::RTEMS_TOO_MANY The name was already in use or other errors
321 *   occurred.
322 *
323 * @par Notes
324 * The device is registered as a character device.
325 */
326rtems_status_code rtems_io_register_name(
327  const char               *device_name,
328  rtems_device_major_number major,
329  rtems_device_minor_number minor
330);
331
332/* Generated from spec:/rtems/io/if/open */
333
334/**
335 * @ingroup RTEMSAPIClassicIO
336 *
337 * @brief Opens the device specified by the device major and minor numbers.
338 *
339 * @param major is the major number of the device.
340 *
341 * @param minor is the minor number of the device.
342 *
343 * @param argument is the argument passed to the device driver close entry.
344 *
345 * This directive calls the device driver open entry registered in the Device
346 * Driver Table for the specified device major number.
347 *
348 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
349 *
350 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
351 *
352 * @return Other status codes may be returned by the device driver open entry.
353 *
354 * @par Notes
355 * The open entry point is commonly used by device drivers to provide exclusive
356 * access to a device.
357 */
358rtems_status_code rtems_io_open(
359  rtems_device_major_number major,
360  rtems_device_minor_number minor,
361  void                     *argument
362);
363
364/* Generated from spec:/rtems/io/if/close */
365
366/**
367 * @ingroup RTEMSAPIClassicIO
368 *
369 * @brief Closes the device specified by the device major and minor numbers.
370 *
371 * @param major is the major number of the device.
372 *
373 * @param minor is the minor number of the device.
374 *
375 * @param argument is the argument passed to the device driver close entry.
376 *
377 * This directive calls the device driver close entry registered in the Device
378 * Driver Table for the specified device major number.
379 *
380 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
381 *
382 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
383 *
384 * @return Other status codes may be returned by the device driver close entry.
385 *
386 * @par Notes
387 * The close entry point is commonly used by device drivers to relinquish
388 * exclusive access to a device.
389 */
390rtems_status_code rtems_io_close(
391  rtems_device_major_number major,
392  rtems_device_minor_number minor,
393  void                     *argument
394);
395
396/* Generated from spec:/rtems/io/if/read */
397
398/**
399 * @ingroup RTEMSAPIClassicIO
400 *
401 * @brief Reads from the device specified by the device major and minor
402 *   numbers.
403 *
404 * @param major is the major number of the device.
405 *
406 * @param minor is the minor number of the device.
407 *
408 * @param argument is the argument passed to the device driver read entry.
409 *
410 * This directive calls the device driver read entry registered in the Device
411 * Driver Table for the specified device major number.
412 *
413 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
414 *
415 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
416 *
417 * @return Other status codes may be returned by the device driver read entry.
418 *
419 * @par Notes
420 * Read operations typically require a buffer address as part of the argument
421 * parameter block.  The contents of this buffer will be replaced with data
422 * from the device.
423 */
424rtems_status_code rtems_io_read(
425  rtems_device_major_number major,
426  rtems_device_minor_number minor,
427  void                     *argument
428);
429
430/* Generated from spec:/rtems/io/if/write */
431
432/**
433 * @ingroup RTEMSAPIClassicIO
434 *
435 * @brief Writes to the device specified by the device major and minor numbers.
436 *
437 * @param major is the major number of the device.
438 *
439 * @param minor is the minor number of the device.
440 *
441 * @param argument is the argument passed to the device driver write entry.
442 *
443 * This directive calls the device driver write entry registered in the Device
444 * Driver Table for the specified device major number.
445 *
446 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
447 *
448 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
449 *
450 * @return Other status codes may be returned by the device driver write entry.
451 *
452 * @par Notes
453 * Write operations typically require a buffer address as part of the argument
454 * parameter block.  The contents of this buffer will be sent to the device.
455 */
456rtems_status_code rtems_io_write(
457  rtems_device_major_number major,
458  rtems_device_minor_number minor,
459  void                     *argument
460);
461
462/* Generated from spec:/rtems/io/if/control */
463
464/**
465 * @ingroup RTEMSAPIClassicIO
466 *
467 * @brief Controls the device specified by the device major and minor numbers.
468 *
469 * @param major is the major number of the device.
470 *
471 * @param minor is the minor number of the device.
472 *
473 * @param argument is the argument passed to the device driver I/O control
474 *   entry.
475 *
476 * This directive calls the device driver I/O control entry registered in the
477 * Device Driver Table for the specified device major number.
478 *
479 * @retval ::RTEMS_SUCCESSFUL The requested operation was successful.
480 *
481 * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid.
482 *
483 * @return Other status codes may be returned by the device driver I/O control
484 *   entry.
485 *
486 * @par Notes
487 * The exact functionality of the driver entry called by this directive is
488 * driver dependent.  It should not be assumed that the control entries of two
489 * device drivers are compatible.  For example, an RS-232 driver I/O control
490 * operation may change the baud of a serial line, while an I/O control
491 * operation for a floppy disk driver may cause a seek operation.
492 */
493rtems_status_code rtems_io_control(
494  rtems_device_major_number major,
495  rtems_device_minor_number minor,
496  void                     *argument
497);
498
499#ifdef __cplusplus
500}
501#endif
502
503#endif /* _RTEMS_IO_H */
Note: See TracBrowser for help on using the repository browser.