summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/include/rtems/rtems/object.h
blob: 2652915462b0963f252784b00e0c58cd276878ad (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
/**
 * @file rtems/rtems/object.h
 *
 * @defgroup ClassicClassInfo Object Class Information
 *
 * @ingroup ClassicRTEMS
 * @brief Classic API interfaces to Object Services
 *
 * This include file defines Classic API interfaces to Object Services.
 */

/* COPYRIGHT (c) 1989-2013.
 * On-Line Applications Research Corporation (OAR).
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#ifndef _RTEMS_RTEMS_OBJECT_H
#define _RTEMS_RTEMS_OBJECT_H

#include <stdint.h>
#include <rtems/score/object.h>
#include <rtems/rtems/status.h>
#include <rtems/rtems/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 *  @defgroup ClassicClassInfo Object Class Information
 *
 *  @ingroup ClassicRTEMS
 *
 *  This encapsulates functionality related to the Classic API Object
 *  Class Services.
 */
/**@{*/

/**
 *  This structure is used to return information to the application
 *  about the objects configured for a specific API/Class combination.
 */
typedef struct {
  /** This field is the minimum valid object Id for this class. */
  rtems_id  minimum_id;
  /** This field is the maximum valid object Id for this class. */
  rtems_id  maximum_id;
  /** This field is the number of object instances configured for this class. */
  uint32_t  maximum;
  /** This field indicates if the class is configured for auto-extend. */
  bool      auto_extend;
  /** This field is the number of currently unallocated objects. */
  uint32_t  unallocated;
} rtems_object_api_class_information;

/**
 * @brief Build Object Id
 *
 * This function returns an object id composed of the
 * specified @a api, @a class, @a node,
 * and @a index.
 *
 * @param[in] _api indicates the api to use for the Id
 * @param[in] _class indicates the class to use for the Id
 * @param[in] _node indicates the node to use for the Id
 * @param[in] _index indicates the index to use for the Id
 *
 * @retval This method returns an object Id built from the
 *         specified values.
 *
 * @note A body is also provided.
 */
#define rtems_build_id( _api, _class, _node, _index ) \
  _Objects_Build_id( _api, _class, _node, _index )

/**
 * @brief Build Thirty-Two Bit Object Name
 *
 * RTEMS Object Helper -- Build an Object Id
 *
 * This function returns an object name composed of the four characters
 * C1, C2, C3, and C4.
 *
 * @param[in] _C1 is the first character of the name
 * @param[in] _C2 is the second character of the name
 * @param[in] _C3 is the third character of the name
 * @param[in] _C4 is the fourth character of the name
 *
 * @note This must be implemented as a macro for use in
 *       Configuration Tables. A body is also provided.
 *
 */
#define rtems_build_name( _C1, _C2, _C3, _C4 ) \
  _Objects_Build_name( _C1, _C2, _C3, _C4 )

/**
 * @brief Obtain Name of Object
 *
 * This directive returns the name associated with the specified
 * object ID.
 *
 * @param[in] id is the Id of the object to obtain the name of.
 * @param[out] name will be set to the name of the object
 *
 * @note The object must be have a name of the 32-bit form.
 *
 * @retval @a *name will contain user defined object name
 * @retval @a RTEMS_SUCCESSFUL - if successful
 * @retval error code - if unsuccessful
 */
rtems_status_code rtems_object_get_classic_name(
  rtems_id      id,
  rtems_name   *name
);

/**
 * @brief Obtain Object Name as String
 *
 * This directive returns the name associated with the specified
 * object ID.
 *
 * @param[in] id is the Id of the object to obtain the name of
 * @param[in] length is the length of the output name buffer
 * @param[out] name will be set to the name of the object
 *
 * @retval @a *name will contain user defined object name
 * @retval @a name - if successful
 * @retval @a NULL - if unsuccessful
 */
char *rtems_object_get_name(
  rtems_id       id,
  size_t         length,
  char          *name
);

/**
 * @brief Set Name of Object
 *
 * This method allows the caller to set the name of an
 * object. This can be used to set the name of objects
 * which do not have a naming scheme per their API.
 *
 * RTEMS Object Helper -- Set Name of Object as String
 *
 * @param[in] id is the Id of the object to obtain the name of
 * @param[out] name will be set to the name of the object
 *
 * @retval @a *name will contain user defined object name
 * @retval @a RTEMS_SUCCESSFUL - if successful
 * @retval error code - if unsuccessful
 */
rtems_status_code rtems_object_set_name(
  rtems_id       id,
  const char    *name
);

/**
 * @brief Get API Portion of Object Id
 *
 * RTEMS Object Helper -- Extract API From Id
 *
 * This function returns the API portion of the Id.
 *
 * @param[in] _id is the Id of the object to obtain the API from
 *
 * @retval This method returns the API portion of the provided
 *         @a _id.
 *
 * @note This method does NOT validate the @a _id provided.
 *
 * @note A body is also provided.
 */
#define rtems_object_id_get_api( _id ) \
  _Objects_Get_API( _id )

/**
 * @brief Get Class Portion of Object Id
 *
 * This function returns the class portion of the @a _id ID.
 *
 * @param[in] _id is the Id of the object to obtain the class from
 *
 * @retval This method returns the class portion of the provided
 *         @a _id.
 *
 * @note This method does NOT validate the @a _id provided.
 *
 * @note A body is also provided.
 */
#define rtems_object_id_get_class( _id ) \
  _Objects_Get_class( _id )

/**
 * @brief Get Node Portion of Object Id
 *
 * This function returns the node portion of the ID.
 *
 * @param[in] _id is the Id of the object to obtain the node from
 *
 * @retval This method returns the node portion of the provided
 *          @a _id.
 *
 * @note This method does NOT validate the @a _id provided.
 *
 * @note A body is also provided.
 */
#define rtems_object_id_get_node( _id ) \
  _Objects_Get_node( _id )

/**
 * @brief Get Index Portion of Object Id
 *
 * This function returns the index portion of the ID.
 *
 * @param[in] _id is the Id of the object to obtain the index from
 *
 * @retval This method returns the index portion of the provided
 *         @a _id.
 *
 * @note This method does NOT validate the @a _id provided.
 *
 * @note A body is also provided.
 */
#define rtems_object_id_get_index( _id ) \
  _Objects_Get_index( _id )

/**
 * @brief Get Lowest Valid API Index
 *
 * This method returns the lowest valid value for the API
 * portion of an RTEMS object Id.
 *
 * @retval This method returns the least valid value for
 *         the API portion of an RTEMS object Id.
 *
 * @note A body is also provided.
 */
#define rtems_object_id_api_minimum() \
  OBJECTS_INTERNAL_API

/**
 * @brief Get Highest Valid API Index
 *
 * This method returns the highest valid value for the API
 * portion of an RTEMS object Id.
 *
 * @retval This method returns the greatest valid value for
 *         the API portion of an RTEMS object Id.
 *
 * @note A body is also provided.
 */
#define rtems_object_id_api_maximum() \
  OBJECTS_APIS_LAST

/**
 * @brief Get Lowest Valid Class Value
 *
 * This method returns the lowest valid value Class for the
 * specified @a api. Each API supports a different number
 * of object classes.
 *
 * @param[in] api is the API to obtain the minimum class of
 *
 * @retval This method returns the least valid value for
 *         class number for the specified @a api.
 * RTEMS Object Helper -- Get Least Valid Class for an API
 */
int rtems_object_api_minimum_class(
  int api
);

/**
 * @brief Get Highest Valid Class Value
 *
 * This method returns the highest valid value Class for the
 * specified @a api. Each API supports a different number
 * of object classes.
 *
 * @param[in] api is the API to obtain the maximum class of
 *
 * @retval This method returns the greatet valid value for
 *         class number for the specified @a api.
 */
int rtems_object_api_maximum_class(
  int api
);


/**
 * @brief Get Highest Valid Class Value
 *
 * This method returns the lowest valid value Class for the
 * specified @a api. Each API supports a different number
 * of object classes.
 *
 * @param[in] api is the API to obtain the maximum class of
 *
 * @retval This method returns the least valid value for
 *         class number for the specified @a api.
 */
int rtems_object_id_api_maximum_class(
  int api
);

/**
 * @brief Get API Name
 *
 * This method returns a string containing the name of the
 * specified @a api.
 *
 * @param[in] api is the API to obtain the name of
 *
 * @retval If successful, this method returns the name of
 *         the specified @a api. Otherwise, it returns
 *         the string "BAD API"
 */
const char *rtems_object_get_api_name(
  int api
);

/**
 * @brief Get Class Name
 *
 * This method returns a string containing the name of the
 * @a class from the specified @a api.
 *
 * @param[in] the_api is the API for the class
 * @param[in] the_class is the class to obtain the name of
 *
 * @retval If successful, this method returns the name of
 *         the specified @a class. Otherwise, it returns
 *         the string "BAD CLASS"
 */
const char *rtems_object_get_api_class_name(
  int the_api,
  int the_class
);

/**
 * @brief Get Class Information
 *
 * This method returns a string containing the name of the
 * @a the_class from the specified @a api.
 *
 * @param[in] the_api is the API for the class
 * @param[in] the_class is the class to obtain information about
 * @param[in] info points to the information structure to fill in
 *
 * @retval If successful, this method returns the name of
 *         RTEMS_SUCCESSFUL with @a *info filled in. Otherwise,
 *         a status is returned to indicate the error.
 *
 */
rtems_status_code rtems_object_get_class_information(
  int                                 the_api,
  int                                 the_class,
  rtems_object_api_class_information *info
);

#ifdef __cplusplus
}
#endif

/**@}*/

#endif
/* end of include file */