source: rtems-docs/c_user/object_services.rst @ 154f3dc6

4.115
Last change on this file since 154f3dc6 was 154f3dc6, checked in by Joel Sherrill <joel@…>, on 10/28/16 at 16:42:35

object_services.rst: Add _rtems_object_id_api_minimum_class and _rtems_object_id_api_maximum_class

  • Property mode set to 100644
File size: 18.8 KB
Line 
1.. comment SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. COMMENT: COPYRIGHT (c) 1988-2008.
4.. COMMENT: On-Line Applications Research Corporation (OAR).
5.. COMMENT: All rights reserved.
6
7Object Services
8###############
9
10.. index:: object manipulation
11
12Introduction
13============
14
15RTEMS provides a collection of services to assist in the management and usage
16of the objects created and utilized via other managers.  These services assist
17in the manipulation of RTEMS objects independent of the API used to create
18them.  The object related services provided by RTEMS are:
19
20- build_id
21
22- rtems_build_name_ - build object name from characters
23
24- rtems_object_get_classic_name_ - lookup name from Id
25
26- rtems_object_get_name_ - obtain object name as string
27
28- rtems_object_set_name_ - set object name
29
30- rtems_object_id_get_api_ - obtain API from Id
31
32- rtems_object_id_get_class_ - obtain class from Id
33
34- rtems_object_id_get_node_ - obtain node from Id
35
36- rtems_object_id_get_index_ - obtain index from Id
37
38- rtems_build_id_ - build object id from components
39
40- rtems_object_id_api_minimum_ - obtain minimum API value
41
42- rtems_object_id_api_maximum_ - obtain maximum API value
43
44- rtems_object_id_api_minimum_class_ - obtain minimum class value
45
46- rtems_object_id_api_maximum_class_ - obtain maximum class value
47
48- rtems_object_get_api_name_ - obtain API name
49
50- rtems_object_get_api_class_name_ - obtain class name
51
52- rtems_object_get_class_information_ - obtain class information
53
54Background
55==========
56
57APIs
58----
59
60RTEMS implements multiple APIs including an Internal API, the Classic API, and
61the POSIX API.  These APIs share the common foundation of SuperCore objects and
62thus share object management code. This includes a common scheme for object Ids
63and for managing object names whether those names be in the thirty-two bit form
64used by the Classic API or C strings.
65
66The object Id contains a field indicating the API that an object instance is
67associated with.  This field holds a numerically small non-zero integer.
68
69Object Classes
70--------------
71
72Each API consists of a collection of managers.  Each manager is responsible for
73instances of a particular object class.  Classic API Tasks and POSIX Mutexes
74example classes.
75
76The object Id contains a field indicating the class that an object instance is
77associated with.  This field holds a numerically small non-zero integer.  In
78all APIs, a class value of one is reserved for tasks or threads.
79
80Object Names
81------------
82
83Every RTEMS object which has an Id may also have a name associated with it.
84Depending on the API, names may be either thirty-two bit integers as in the
85Classic API or strings as in the POSIX API.
86
87Some objects have Ids but do not have a defined way to associate a name with
88them.  For example, POSIX threads have Ids but per POSIX do not have names. In
89RTEMS, objects not defined to have thirty-two bit names may have string names
90assigned to them via the ``rtems_object_set_name`` service.  The original
91impetus in providing this service was so the normally anonymous POSIX threads
92could have a user defined name in CPU Usage Reports.
93
94Operations
95==========
96
97Decomposing and Recomposing an Object Id
98----------------------------------------
99
100Services are provided to decompose an object Id into its subordinate
101components. The following services are used to do this:
102
103- ``rtems_object_id_get_api``
104
105- ``rtems_object_id_get_class``
106
107- ``rtems_object_id_get_node``
108
109- ``rtems_object_id_get_index``
110
111The following C language example illustrates the decomposition of an Id and
112printing the values.
113
114.. code-block:: c
115
116    void printObjectId(rtems_id id)
117    {
118        printf(
119            "API=%d Class=%d Node=%d Index=%d\n",
120            rtems_object_id_get_api(id),
121            rtems_object_id_get_class(id),
122            rtems_object_id_get_node(id),
123            rtems_object_id_get_index(id)
124        );
125    }
126
127This prints the components of the Ids as integers.
128
129It is also possible to construct an arbitrary Id using the ``rtems_build_id``
130service.  The following C language example illustrates how to construct the
131"next Id."
132
133.. code-block:: c
134
135    rtems_id nextObjectId(rtems_id id)
136    {
137        return rtems_build_id(
138                    rtems_object_id_get_api(id),
139                    rtems_object_id_get_class(id),
140                    rtems_object_id_get_node(id),
141                    rtems_object_id_get_index(id) + 1
142               );
143    }
144
145Note that this Id may not be valid in this
146system or associated with an allocated object.
147
148Printing an Object Id
149---------------------
150
151RTEMS also provides services to associate the API and Class portions of an
152Object Id with strings.  This allows the application developer to provide more
153information about an object in diagnostic messages.
154
155In the following C language example, an Id is decomposed into its constituent
156parts and "pretty-printed."
157
158.. code-block:: c
159
160    void prettyPrintObjectId(rtems_id id)
161    {
162        int tmpAPI, tmpClass;
163
164        tmpAPI   = rtems_object_id_get_api(id),
165        tmpClass = rtems_object_id_get_class(id),
166
167        printf(
168            "API=%s Class=%s Node=%d Index=%d\n",
169            rtems_object_get_api_name(tmpAPI),
170            rtems_object_get_api_class_name(tmpAPI, tmpClass),
171            rtems_object_id_get_node(id),
172            rtems_object_id_get_index(id)
173        );
174    }
175
176Directives
177==========
178
179.. _rtems_build_name:
180
181BUILD_NAME - Build object name from characters
182----------------------------------------------
183.. index:: build object name
184
185**CALLING SEQUENCE:**
186
187.. index:: rtems_build_name
188
189.. code-block:: c
190
191    rtems_name rtems_build_name(
192        uint8_t c1,
193        uint8_t c2,
194        uint8_t c3,
195        uint8_t c4
196    );
197
198**DIRECTIVE STATUS CODES**
199
200Returns a name constructed from the four characters.
201
202**DESCRIPTION:**
203
204This service takes the four characters provided as arguments and constructs a
205thirty-two bit object name with ``c1`` in the most significant byte and ``c4``
206in the least significant byte.
207
208**NOTES:**
209
210This directive is strictly local and does not impact task scheduling.
211
212.. _rtems_object_get_classic_name:
213
214OBJECT_GET_CLASSIC_NAME - Lookup name from id
215---------------------------------------------
216.. index:: get name from id
217.. index:: obtain name from id
218
219**CALLING SEQUENCE:**
220
221.. index:: rtems_object_get_classic_name
222
223.. code-block:: c
224
225    rtems_status_code rtems_object_get_classic_name(
226        rtems_id      id,
227        rtems_name   *name
228    );
229
230**DIRECTIVE STATUS CODES**
231
232.. list-table::
233 :class: rtems-table
234
235 * - ``RTEMS_SUCCESSFUL``
236   - name looked up successfully
237 * - ``RTEMS_INVALID_ADDRESS``
238   - invalid name pointer
239 * - ``RTEMS_INVALID_ID``
240   - invalid object id
241
242**DESCRIPTION:**
243
244This service looks up the name for the object ``id`` specified and, if found,
245places the result in ``*name``.
246
247**NOTES:**
248
249This directive is strictly local and does not impact task scheduling.
250
251.. _rtems_object_get_name:
252
253OBJECT_GET_NAME - Obtain object name as string
254----------------------------------------------
255.. index:: get object name as string
256.. index:: obtain object name as string
257
258**CALLING SEQUENCE:**
259
260.. index:: rtems_object_get_name
261
262.. code-block:: c
263
264    char* rtems_object_get_name(
265        rtems_id       id,
266        size_t         length,
267        char          *name
268    );
269
270**DIRECTIVE STATUS CODES**
271
272Returns a pointer to the name if successful or ``NULL`` otherwise.
273
274**DESCRIPTION:**
275
276This service looks up the name of the object specified by ``id`` and places it
277in the memory pointed to by ``name``.  Every attempt is made to return name as
278a printable string even if the object has the Classic API thirty-two bit style
279name.
280
281**NOTES:**
282
283This directive is strictly local and does not impact task scheduling.
284
285.. _rtems_object_set_name:
286
287OBJECT_SET_NAME - Set object name
288---------------------------------
289.. index:: set object name
290
291**CALLING SEQUENCE:**
292
293.. index:: rtems_object_set_name
294
295.. code-block:: c
296
297    rtems_status_code rtems_object_set_name(
298        rtems_id       id,
299        const char    *name
300    );
301
302**DIRECTIVE STATUS CODES**
303
304.. list-table::
305 :class: rtems-table
306
307 * - ``RTEMS_SUCCESSFUL``
308   - name looked up successfully
309 * - ``RTEMS_INVALID_ADDRESS``
310   - invalid name pointer
311 * - ``RTEMS_INVALID_ID``
312   - invalid object id
313
314**DESCRIPTION:**
315
316This service sets the name of ``id`` to that specified by the string located at
317``name``.
318
319**NOTES:**
320
321This directive is strictly local and does not impact task scheduling.
322
323If the object specified by ``id`` is of a class that has a string name, this
324method will free the existing name to the RTEMS Workspace and allocate enough
325memory from the RTEMS Workspace to make a copy of the string located at
326``name``.
327
328If the object specified by ``id`` is of a class that has a thirty-two bit
329integer style name, then the first four characters in ``*name`` will be used to
330construct the name.  name to the RTEMS Workspace and allocate enough memory
331from the RTEMS Workspace to make a copy of the string
332
333.. _rtems_object_id_get_api:
334
335OBJECT_ID_GET_API - Obtain API from Id
336--------------------------------------
337.. index:: obtain API from id
338
339**CALLING SEQUENCE:**
340
341.. index:: rtems_object_id_get_api
342
343.. code-block:: c
344
345    int rtems_object_id_get_api(
346        rtems_id id
347    );
348
349**DIRECTIVE STATUS CODES**
350
351Returns the API portion of the object Id.
352
353**DESCRIPTION:**
354
355This directive returns the API portion of the provided object ``id``.
356
357**NOTES:**
358
359This directive is strictly local and does not impact task scheduling.
360
361This directive does NOT validate the ``id`` provided.
362
363.. _rtems_object_id_get_class:
364
365OBJECT_ID_GET_CLASS - Obtain Class from Id
366------------------------------------------
367.. index:: obtain class from object id
368
369**CALLING SEQUENCE:**
370
371.. index:: rtems_object_id_get_class
372
373.. code-block:: c
374
375    int rtems_object_id_get_class(
376        rtems_id id
377    );
378
379**DIRECTIVE STATUS CODES**
380
381Returns the class portion of the object Id.
382
383**DESCRIPTION:**
384
385This directive returns the class portion of the provided object ``id``.
386
387**NOTES:**
388
389This directive is strictly local and does not impact task scheduling.
390
391This directive does NOT validate the ``id`` provided.
392
393.. _rtems_object_id_get_node:
394
395OBJECT_ID_GET_NODE - Obtain Node from Id
396----------------------------------------
397.. index:: obtain node from object id
398
399**CALLING SEQUENCE:**
400
401.. index:: rtems_object_id_get_node
402
403.. code-block:: c
404
405    int rtems_object_id_get_node(
406        rtems_id id
407    );
408
409**DIRECTIVE STATUS CODES**
410
411Returns the node portion of the object Id.
412
413**DESCRIPTION:**
414
415This directive returns the node portion of the provided object ``id``.
416
417**NOTES:**
418
419This directive is strictly local and does not impact task scheduling.
420
421This directive does NOT validate the ``id`` provided.
422
423.. _rtems_object_id_get_index:
424
425OBJECT_ID_GET_INDEX - Obtain Index from Id
426------------------------------------------
427.. index:: obtain index from object id
428
429**CALLING SEQUENCE:**
430
431.. index:: rtems_object_id_get_index
432
433.. code-block:: c
434
435    int rtems_object_id_get_index(
436        rtems_id id
437    );
438
439**DIRECTIVE STATUS CODES**
440
441Returns the index portion of the object Id.
442
443**DESCRIPTION:**
444
445This directive returns the index portion of the provided object ``id``.
446
447**NOTES:**
448
449This directive is strictly local and does not impact task scheduling.
450
451This directive does NOT validate the ``id`` provided.
452
453.. _rtems_build_id:
454
455BUILD_ID - Build Object Id From Components
456------------------------------------------
457.. index:: build object id from components
458
459**CALLING SEQUENCE:**
460
461.. index:: rtems_build_id
462
463.. code-block:: c
464
465    rtems_id rtems_build_id(
466        int the_api,
467        int the_class,
468        int the_node,
469        int the_index
470    );
471
472**DIRECTIVE STATUS CODES**
473
474Returns an object Id constructed from the provided arguments.
475
476**DESCRIPTION:**
477
478This service constructs an object Id from the provided ``the_api``,
479``the_class``, ``the_node``, and ``the_index``.
480
481**NOTES:**
482
483This directive is strictly local and does not impact task scheduling.
484
485This directive does NOT validate the arguments provided or the Object id
486returned.
487
488.. _rtems_object_id_api_minimum:
489
490OBJECT_ID_API_MINIMUM - Obtain Minimum API Value
491------------------------------------------------
492.. index:: obtain minimum API value
493
494**CALLING SEQUENCE:**
495
496.. index:: rtems_object_id_api_minimum
497
498.. code-block:: c
499
500    int rtems_object_id_api_minimum(void);
501
502**DIRECTIVE STATUS CODES**
503
504Returns the minimum valid for the API portion of an object Id.
505
506**DESCRIPTION:**
507
508This service returns the minimum valid for the API portion of an object Id.
509
510**NOTES:**
511
512This directive is strictly local and does not impact task scheduling.
513
514.. _rtems_object_id_api_maximum:
515
516OBJECT_ID_API_MAXIMUM - Obtain Maximum API Value
517------------------------------------------------
518.. index:: obtain maximum API value
519
520**CALLING SEQUENCE:**
521
522.. index:: rtems_object_id_api_maximum
523
524.. code-block:: c
525
526    int rtems_object_id_api_maximum(void);
527
528**DIRECTIVE STATUS CODES**
529
530Returns the maximum valid for the API portion of an object Id.
531
532**DESCRIPTION:**
533
534This service returns the maximum valid for the API portion of an object Id.
535
536**NOTES:**
537
538This directive is strictly local and does not impact task scheduling.
539
540.. _rtems_object_api_minimum_class:
541
542OBJECT_API_MINIMUM_CLASS - Obtain Minimum Class Value
543-----------------------------------------------------
544.. index:: obtain minimum class value
545
546**CALLING SEQUENCE:**
547
548.. index:: rtems_object_api_minimum_class
549
550.. code-block:: c
551
552    int rtems_object_api_minimum_class(
553        int api
554    );
555
556**DIRECTIVE STATUS CODES**
557
558If ``api`` is not valid, -1 is returned.
559
560If successful, this service returns the minimum valid for the class portion of
561an object Id for the specified ``api``.
562
563**DESCRIPTION:**
564
565This service returns the minimum valid for the class portion of an object Id
566for the specified ``api``.
567
568**NOTES:**
569
570This directive is strictly local and does not impact task scheduling.
571
572.. _rtems_object_api_maximum_class:
573
574OBJECT_API_MAXIMUM_CLASS - Obtain Maximum Class Value
575-----------------------------------------------------
576.. index:: obtain maximum class value
577
578**CALLING SEQUENCE:**
579
580.. index:: rtems_object_api_maximum_class
581
582.. code-block:: c
583
584    int rtems_object_api_maximum_class(
585        int api
586    );
587
588**DIRECTIVE STATUS CODES**
589
590If ``api`` is not valid, -1 is returned.
591
592If successful, this service returns the maximum valid for the class portion of
593an object Id for the specified ``api``.
594
595**DESCRIPTION:**
596
597This service returns the maximum valid for the class portion of an object Id
598for the specified ``api``.
599
600**NOTES:**
601
602This directive is strictly local and does not impact task scheduling.
603
604.. _rtems_object_id_api_minimum_class:
605
606OBJECT_ID_API_MINIMUM_CLASS - Obtain Minimum Class Value for an API
607-------------------------------------------------------------------
608.. index:: obtain minimum class value for an API
609
610**CALLING SEQUENCE:**
611
612.. index:: rtems_object_id_api_minimum_class
613
614.. code-block:: c
615
616    int rtems_object_get_id_api_minimum_class(
617        int api
618    );
619
620**DIRECTIVE STATUS CODES**
621
622If ``api`` is not valid, -1 is returned.
623
624If successful, this service returns the index corresponding to the first
625object class of the specified ``api``.
626
627**DESCRIPTION:**
628
629This service returns the index for the first object class associated with
630the specified ``api``.
631
632**NOTES:**
633
634This directive is strictly local and does not impact task scheduling.
635
636.. _rtems_object_id_api_maximum_class:
637
638OBJECT_ID_API_MAXIMUM_CLASS - Obtain Maximum Class Value for an API
639-------------------------------------------------------------------
640.. index:: obtain maximum class value for an API
641
642**CALLING SEQUENCE:**
643
644.. index:: rtems_object_id_api_maximum_class
645
646.. code-block:: c
647
648    int rtems_object_get_api_maximum_class(
649        int api
650    );
651
652**DIRECTIVE STATUS CODES**
653
654If ``api`` is not valid, -1 is returned.
655
656If successful, this service returns the index corresponding to the last
657object class of the specified ``api``.
658
659**DESCRIPTION:**
660
661This service returns the index for the last object class associated with
662the specified ``api``.
663
664**NOTES:**
665
666This directive is strictly local and does not impact task scheduling.
667
668.. _rtems_object_get_api_name:
669
670OBJECT_GET_API_NAME - Obtain API Name
671-------------------------------------
672.. index:: obtain API name
673
674**CALLING SEQUENCE:**
675
676.. index:: rtems_object_get_api_name
677
678.. code-block:: c
679
680    const char* rtems_object_get_api_name(
681        int api
682    );
683
684**DIRECTIVE STATUS CODES**
685
686If ``api`` is not valid, the string ``"BAD API"`` is returned.
687
688If successful, this service returns a pointer to a string containing the name
689of the specified ``api``.
690
691**DESCRIPTION:**
692
693This service returns the name of the specified ``api``.
694
695**NOTES:**
696
697This directive is strictly local and does not impact task scheduling.
698
699The string returned is from constant space.  Do not modify or free it.
700
701.. _rtems_object_get_api_class_name:
702
703OBJECT_GET_API_CLASS_NAME - Obtain Class Name
704---------------------------------------------
705.. index:: obtain class name
706
707**CALLING SEQUENCE:**
708
709.. index:: rtems_object_get_api_class_name
710
711.. code-block:: c
712
713    const char *rtems_object_get_api_class_name(
714        int the_api,
715        int the_class
716    );
717
718**DIRECTIVE STATUS CODES**
719
720If ``the_api`` is not valid, the string ``"BAD API"`` is returned.
721
722If ``the_class`` is not valid, the string ``"BAD CLASS"`` is returned.
723
724If successful, this service returns a pointer to a string containing the name
725of the specified ``the_api`` / ``the_class`` pair.
726
727**DESCRIPTION:**
728
729This service returns the name of the object class indicated by the specified
730``the_api`` and ``the_class``.
731
732**NOTES:**
733
734This directive is strictly local and does not impact task scheduling.
735
736The string returned is from constant space.  Do not modify or free it.
737
738.. _rtems_object_get_class_information:
739
740OBJECT_GET_CLASS_INFORMATION - Obtain Class Information
741-------------------------------------------------------
742.. index:: obtain class information
743
744**CALLING SEQUENCE:**
745
746.. index:: rtems_object_get_class_information
747
748.. code-block:: c
749
750    rtems_status_code rtems_object_get_class_information(
751        int                                 the_api,
752        int                                 the_class,
753        rtems_object_api_class_information *info
754    );
755
756**DIRECTIVE STATUS CODES**
757
758.. list-table::
759 :class: rtems-table
760
761 * - ``RTEMS_SUCCESSFUL``
762   - information obtained successfully
763 * - ``RTEMS_INVALID_ADDRESS``
764   - ``info`` is NULL
765 * - ``RTEMS_INVALID_NUMBER``
766   - invalid ``api`` or ``the_class``
767
768If successful, the structure located at ``info`` will be filled in with
769information about the specified ``api`` / ``the_class`` pairing.
770
771**DESCRIPTION:**
772
773This service returns information about the object class indicated by the
774specified ``api`` and ``the_class``. This structure is defined as follows:
775
776.. code-block:: c
777
778    typedef struct {
779        rtems_id  minimum_id;
780        rtems_id  maximum_id;
781        int       maximum;
782        bool      auto_extend;
783        int       unallocated;
784    } rtems_object_api_class_information;
785
786**NOTES:**
787
788This directive is strictly local and does not impact task scheduling.
Note: See TracBrowser for help on using the repository browser.