summaryrefslogtreecommitdiffstats
path: root/c-user/io/directives.rst
blob: d3098cb386c915ce9b8a946f22e185c0507b7d92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
.. SPDX-License-Identifier: CC-BY-SA-4.0

.. Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)

Directives
==========

This section details the I/O manager's directives.  A subsection is dedicated
to each of this manager's directives and describes the calling sequence,
related constants, usage, and status codes.

.. raw:: latex

   \clearpage

.. index:: register a device driver
.. index:: rtems_io_register_driver

.. _rtems_io_register_driver:

IO_REGISTER_DRIVER - Register a device driver
---------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_register_driver(
            rtems_device_major_number   major,
            rtems_driver_address_table *driver_table,
            rtems_device_major_number  *registered_major
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully registered
     * - ``RTEMS_INVALID_ADDRESS``
       - invalid registered major pointer
     * - ``RTEMS_INVALID_ADDRESS``
       - invalid driver table
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number
     * - ``RTEMS_TOO_MANY``
       - no available major device table slot
     * - ``RTEMS_RESOURCE_IN_USE``
       - major device number entry in use

DESCRIPTION:
    This directive attempts to add a new device driver to the Device Driver
    Table. The user can specify a specific major device number via the
    directive's ``major`` parameter, or let the registration routine find the
    next available major device number by specifing a major number of
    ``0``. The selected major device number is returned via the
    ``registered_major`` directive parameter. The directive automatically
    allocation major device numbers from the highest value down.

    This directive automatically invokes the ``IO_INITIALIZE`` directive if the
    driver address table has an initialization and open entry.

    The directive returns ``RTEMS_TOO_MANY`` if Device Driver Table is full,
    and ``RTEMS_RESOURCE_IN_USE`` if a specific major device number is
    requested and it is already in use.

NOTES:
    The Device Driver Table size is specified in the Configuration Table
    condiguration. This needs to be set to maximum size the application
    requires.

.. raw:: latex

   \clearpage

.. index:: unregister a device driver
.. index:: rtems_io_unregister_driver

.. _rtems_io_unregister_driver:

IO_UNREGISTER_DRIVER - Unregister a device driver
-------------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_unregister_driver(
            rtems_device_major_number   major
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully registered
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive removes a device driver from the Device Driver Table.

NOTES:
    Currently no specific checks are made and the driver is not closed.

.. raw:: latex

   \clearpage

.. index:: initialize a device driver
.. index:: rtems_io_initialize

.. _rtems_io_initialize:

IO_INITIALIZE - Initialize a device driver
------------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_initialize(
            rtems_device_major_number  major,
            rtems_device_minor_number  minor,
            void                      *argument
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive calls the device driver initialization routine specified in
    the Device Driver Table for this major number. This directive is
    automatically invoked for each device driver when multitasking is initiated
    via the initialize_executive directive.

    A device driver initialization module is responsible for initializing all
    hardware and data structures associated with a device. If necessary, it can
    allocate memory to be used during other operations.

NOTES:
    This directive may or may not cause the calling task to be preempted.  This
    is dependent on the device driver being initialized.

.. raw:: latex

   \clearpage

.. index:: register device
.. index:: rtems_io_register_name

.. _rtems_io_register_name:

IO_REGISTER_NAME - Register a device
------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_register_name(
            const char                *name,
            rtems_device_major_number  major,
            rtems_device_minor_number  minor
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_TOO_MANY``
       - too many devices registered

DESCRIPTION:
    This directive associates name with the specified major/minor number pair.

NOTES:
    This directive will not cause the calling task to be preempted.

.. raw:: latex

   \clearpage

.. index:: lookup device major and minor number
.. index:: rtems_io_lookup_name

.. _rtems_io_lookup_name:

IO_LOOKUP_NAME - Lookup a device
--------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_lookup_name(
            const char          *name,
            rtems_driver_name_t *device_info
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_UNSATISFIED``
       - name not registered

DESCRIPTION:
    This directive returns the major/minor number pair associated with the
    given device name in ``device_info``.

NOTES:
    This directive will not cause the calling task to be preempted.

.. raw:: latex

   \clearpage

.. index:: open a devive
.. index:: rtems_io_open

.. _rtems_io_open:

IO_OPEN - Open a device
-----------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_open(
            rtems_device_major_number  major,
            rtems_device_minor_number  minor,
            void                      *argument
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive calls the device driver open routine specified in the Device
    Driver Table for this major number.  The open entry point is commonly used
    by device drivers to provide exclusive access to a device.

NOTES:
    This directive may or may not cause the calling task to be preempted.  This
    is dependent on the device driver being invoked.

.. raw:: latex

   \clearpage

.. index:: close a device
.. index:: rtems_io_close

.. _rtems_io_close:

IO_CLOSE - Close a device
-------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_close(
            rtems_device_major_number  major,
            rtems_device_minor_number  minor,
            void                      *argument
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive calls the device driver close routine specified in the
    Device Driver Table for this major number.  The close entry point is
    commonly used by device drivers to relinquish exclusive access to a device.

NOTES:
    This directive may or may not cause the calling task to be preempted.  This
    is dependent on the device driver being invoked.

.. raw:: latex

   \clearpage

.. index:: read from a device
.. index:: rtems_io_read

.. _rtems_io_read:

IO_READ - Read from a device
----------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_read(
            rtems_device_major_number  major,
            rtems_device_minor_number  minor,
            void                      *argument
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive calls the device driver read routine specified in the Device
    Driver Table for this major number.  Read operations typically require a
    buffer address as part of the argument parameter block.  The contents of
    this buffer will be replaced with data from the device.

NOTES:
    This directive may or may not cause the calling task to be preempted.  This
    is dependent on the device driver being invoked.

.. raw:: latex

   \clearpage

.. index:: write to a device
.. index:: rtems_io_write

.. _rtems_io_write:

IO_WRITE - Write to a device
----------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_write(
            rtems_device_major_number  major,
            rtems_device_minor_number  minor,
            void                      *argument
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive calls the device driver write routine specified in the
    Device Driver Table for this major number.  Write operations typically
    require a buffer address as part of the argument parameter block.  The
    contents of this buffer will be sent to the device.

NOTES:
    This directive may or may not cause the calling task to be preempted.  This
    is dependent on the device driver being invoked.

.. raw:: latex

   \clearpage

.. index:: special device services
.. index:: IO Control
.. index:: rtems_io_control

.. _rtems_io_control:

IO_CONTROL - Special device services
------------------------------------

CALLING SEQUENCE:
    .. code-block:: c

        rtems_status_code rtems_io_control(
            rtems_device_major_number  major,
            rtems_device_minor_number  minor,
            void                      *argument
        );

DIRECTIVE STATUS CODES:
    .. list-table::
     :class: rtems-table

     * - ``RTEMS_SUCCESSFUL``
       - successfully initialized
     * - ``RTEMS_INVALID_NUMBER``
       - invalid major device number

DESCRIPTION:
    This directive calls the device driver I/O control routine specified in the
    Device Driver Table for this major number.  The exact functionality of the
    driver entry called by this directive is driver dependent.  It should not
    be assumed that the control entries of two device drivers are compatible.
    For example, an RS-232 driver I/O control operation may change the baud
    rate of a serial line, while an I/O control operation for a floppy disk
    driver may cause a seek operation.

NOTES:
    This directive may or may not cause the calling task to be preempted.  This
    is dependent on the device driver being invoked.