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 |
---|
63 | extern "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 | */ |
---|
90 | typedef 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 | */ |
---|
103 | typedef 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 | */ |
---|
115 | typedef 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 | */ |
---|
124 | typedef 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 | */ |
---|
140 | typedef 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 a device major number |
---|
198 | * variable. When the directive call is successful, the device major number |
---|
199 | * of the registered device will be stored in this variable. |
---|
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 | * |
---|
221 | * @par Notes |
---|
222 | * @parblock |
---|
223 | * If the device major number equals zero a device major number will be |
---|
224 | * obtained. The device major number of the registered driver will be |
---|
225 | * returned. |
---|
226 | * |
---|
227 | * After a successful registration, the rtems_io_initialize() directive will be |
---|
228 | * called to initialize the device. |
---|
229 | * @endparblock |
---|
230 | */ |
---|
231 | rtems_status_code rtems_io_register_driver( |
---|
232 | rtems_device_major_number major, |
---|
233 | const rtems_driver_address_table *driver_table, |
---|
234 | rtems_device_major_number *registered_major |
---|
235 | ); |
---|
236 | |
---|
237 | /* Generated from spec:/rtems/io/if/unregister-driver */ |
---|
238 | |
---|
239 | /** |
---|
240 | * @ingroup RTEMSAPIClassicIO |
---|
241 | * |
---|
242 | * @brief Removes a device driver specified by the device major number from the |
---|
243 | * Device Driver Table. |
---|
244 | * |
---|
245 | * @param major is the major number of the device. |
---|
246 | * |
---|
247 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
248 | * |
---|
249 | * @retval ::RTEMS_UNSATISFIED The device major number was invalid. |
---|
250 | * |
---|
251 | * @retval ::RTEMS_CALLED_FROM_ISR The directive was called from interrupt |
---|
252 | * context. |
---|
253 | * |
---|
254 | * @par Notes |
---|
255 | * Currently no specific checks are made and the driver is not closed. |
---|
256 | */ |
---|
257 | rtems_status_code rtems_io_unregister_driver( |
---|
258 | rtems_device_major_number major |
---|
259 | ); |
---|
260 | |
---|
261 | /* Generated from spec:/rtems/io/if/initialize */ |
---|
262 | |
---|
263 | /** |
---|
264 | * @ingroup RTEMSAPIClassicIO |
---|
265 | * |
---|
266 | * @brief Initializes the device specified by the device major and minor |
---|
267 | * numbers. |
---|
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 | * This directive calls the device driver initialization entry registered in |
---|
277 | * the Device Driver Table for the specified device major number. |
---|
278 | * |
---|
279 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
280 | * |
---|
281 | * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid. |
---|
282 | * |
---|
283 | * @return Other status codes may be returned by the device driver |
---|
284 | * initialization entry. |
---|
285 | * |
---|
286 | * @par Notes |
---|
287 | * @parblock |
---|
288 | * This directive is automatically invoked for each device driver defined by |
---|
289 | * the application configuration during the system initialization and via the |
---|
290 | * rtems_io_register_driver() directive. |
---|
291 | * |
---|
292 | * A device driver initialization entry is responsible for initializing all |
---|
293 | * hardware and data structures associated with a device. If necessary, it can |
---|
294 | * allocate memory to be used during other operations. |
---|
295 | * @endparblock |
---|
296 | */ |
---|
297 | rtems_status_code rtems_io_initialize( |
---|
298 | rtems_device_major_number major, |
---|
299 | rtems_device_minor_number minor, |
---|
300 | void *argument |
---|
301 | ); |
---|
302 | |
---|
303 | /* Generated from spec:/rtems/io/if/register-name */ |
---|
304 | |
---|
305 | /** |
---|
306 | * @ingroup RTEMSAPIClassicIO |
---|
307 | * |
---|
308 | * @brief Registers the device specified by the device major and minor numbers |
---|
309 | * in the file system under the specified name. |
---|
310 | * |
---|
311 | * @param device_name is the device name in the file system. |
---|
312 | * |
---|
313 | * @param major is the device major number. |
---|
314 | * |
---|
315 | * @param minor is the device minor number. |
---|
316 | * |
---|
317 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
318 | * |
---|
319 | * @retval ::RTEMS_TOO_MANY The name was already in use or other errors |
---|
320 | * occurred. |
---|
321 | * |
---|
322 | * @par Notes |
---|
323 | * The device is registered as a character device. |
---|
324 | */ |
---|
325 | rtems_status_code rtems_io_register_name( |
---|
326 | const char *device_name, |
---|
327 | rtems_device_major_number major, |
---|
328 | rtems_device_minor_number minor |
---|
329 | ); |
---|
330 | |
---|
331 | /* Generated from spec:/rtems/io/if/open */ |
---|
332 | |
---|
333 | /** |
---|
334 | * @ingroup RTEMSAPIClassicIO |
---|
335 | * |
---|
336 | * @brief Opens the device specified by the device major and minor numbers. |
---|
337 | * |
---|
338 | * @param major is the major number of the device. |
---|
339 | * |
---|
340 | * @param minor is the minor number of the device. |
---|
341 | * |
---|
342 | * @param argument is the argument passed to the device driver close entry. |
---|
343 | * |
---|
344 | * This directive calls the device driver open entry registered in the Device |
---|
345 | * Driver Table for the specified device major number. |
---|
346 | * |
---|
347 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
348 | * |
---|
349 | * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid. |
---|
350 | * |
---|
351 | * @return Other status codes may be returned by the device driver open entry. |
---|
352 | * |
---|
353 | * @par Notes |
---|
354 | * The open entry point is commonly used by device drivers to provide exclusive |
---|
355 | * access to a device. |
---|
356 | */ |
---|
357 | rtems_status_code rtems_io_open( |
---|
358 | rtems_device_major_number major, |
---|
359 | rtems_device_minor_number minor, |
---|
360 | void *argument |
---|
361 | ); |
---|
362 | |
---|
363 | /* Generated from spec:/rtems/io/if/close */ |
---|
364 | |
---|
365 | /** |
---|
366 | * @ingroup RTEMSAPIClassicIO |
---|
367 | * |
---|
368 | * @brief Closes the device specified by the device major and minor numbers. |
---|
369 | * |
---|
370 | * @param major is the major number of the device. |
---|
371 | * |
---|
372 | * @param minor is the minor number of the device. |
---|
373 | * |
---|
374 | * @param argument is the argument passed to the device driver close entry. |
---|
375 | * |
---|
376 | * This directive calls the device driver close entry registered in the Device |
---|
377 | * Driver Table for the specified device major number. |
---|
378 | * |
---|
379 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
380 | * |
---|
381 | * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid. |
---|
382 | * |
---|
383 | * @return Other status codes may be returned by the device driver close entry. |
---|
384 | * |
---|
385 | * @par Notes |
---|
386 | * The close entry point is commonly used by device drivers to relinquish |
---|
387 | * exclusive access to a device. |
---|
388 | */ |
---|
389 | rtems_status_code rtems_io_close( |
---|
390 | rtems_device_major_number major, |
---|
391 | rtems_device_minor_number minor, |
---|
392 | void *argument |
---|
393 | ); |
---|
394 | |
---|
395 | /* Generated from spec:/rtems/io/if/read */ |
---|
396 | |
---|
397 | /** |
---|
398 | * @ingroup RTEMSAPIClassicIO |
---|
399 | * |
---|
400 | * @brief Reads from the device specified by the device major and minor |
---|
401 | * numbers. |
---|
402 | * |
---|
403 | * @param major is the major number of the device. |
---|
404 | * |
---|
405 | * @param minor is the minor number of the device. |
---|
406 | * |
---|
407 | * @param argument is the argument passed to the device driver read entry. |
---|
408 | * |
---|
409 | * This directive calls the device driver read entry registered in the Device |
---|
410 | * Driver Table for the specified device major number. |
---|
411 | * |
---|
412 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
413 | * |
---|
414 | * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid. |
---|
415 | * |
---|
416 | * @return Other status codes may be returned by the device driver read entry. |
---|
417 | * |
---|
418 | * @par Notes |
---|
419 | * Read operations typically require a buffer address as part of the argument |
---|
420 | * parameter block. The contents of this buffer will be replaced with data |
---|
421 | * from the device. |
---|
422 | */ |
---|
423 | rtems_status_code rtems_io_read( |
---|
424 | rtems_device_major_number major, |
---|
425 | rtems_device_minor_number minor, |
---|
426 | void *argument |
---|
427 | ); |
---|
428 | |
---|
429 | /* Generated from spec:/rtems/io/if/write */ |
---|
430 | |
---|
431 | /** |
---|
432 | * @ingroup RTEMSAPIClassicIO |
---|
433 | * |
---|
434 | * @brief Writes to the device specified by the device major and minor numbers. |
---|
435 | * |
---|
436 | * @param major is the major number of the device. |
---|
437 | * |
---|
438 | * @param minor is the minor number of the device. |
---|
439 | * |
---|
440 | * @param argument is the argument passed to the device driver write entry. |
---|
441 | * |
---|
442 | * This directive calls the device driver write entry registered in the Device |
---|
443 | * Driver Table for the specified device major number. |
---|
444 | * |
---|
445 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
446 | * |
---|
447 | * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid. |
---|
448 | * |
---|
449 | * @return Other status codes may be returned by the device driver write entry. |
---|
450 | * |
---|
451 | * @par Notes |
---|
452 | * Write operations typically require a buffer address as part of the argument |
---|
453 | * parameter block. The contents of this buffer will be sent to the device. |
---|
454 | */ |
---|
455 | rtems_status_code rtems_io_write( |
---|
456 | rtems_device_major_number major, |
---|
457 | rtems_device_minor_number minor, |
---|
458 | void *argument |
---|
459 | ); |
---|
460 | |
---|
461 | /* Generated from spec:/rtems/io/if/control */ |
---|
462 | |
---|
463 | /** |
---|
464 | * @ingroup RTEMSAPIClassicIO |
---|
465 | * |
---|
466 | * @brief Controls the device specified by the device major and minor numbers. |
---|
467 | * |
---|
468 | * @param major is the major number of the device. |
---|
469 | * |
---|
470 | * @param minor is the minor number of the device. |
---|
471 | * |
---|
472 | * @param argument is the argument passed to the device driver I/O control |
---|
473 | * entry. |
---|
474 | * |
---|
475 | * This directive calls the device driver I/O control entry registered in the |
---|
476 | * Device Driver Table for the specified device major number. |
---|
477 | * |
---|
478 | * @retval ::RTEMS_SUCCESSFUL The requested operation was successful. |
---|
479 | * |
---|
480 | * @retval ::RTEMS_INVALID_NUMBER The device major number was invalid. |
---|
481 | * |
---|
482 | * @return Other status codes may be returned by the device driver I/O control |
---|
483 | * entry. |
---|
484 | * |
---|
485 | * @par Notes |
---|
486 | * The exact functionality of the driver entry called by this directive is |
---|
487 | * driver dependent. It should not be assumed that the control entries of two |
---|
488 | * device drivers are compatible. For example, an RS-232 driver I/O control |
---|
489 | * operation may change the baud of a serial line, while an I/O control |
---|
490 | * operation for a floppy disk driver may cause a seek operation. |
---|
491 | */ |
---|
492 | rtems_status_code rtems_io_control( |
---|
493 | rtems_device_major_number major, |
---|
494 | rtems_device_minor_number minor, |
---|
495 | void *argument |
---|
496 | ); |
---|
497 | |
---|
498 | #ifdef __cplusplus |
---|
499 | } |
---|
500 | #endif |
---|
501 | |
---|
502 | #endif /* _RTEMS_IO_H */ |
---|