[11874561] | 1 | /** |
---|
| 2 | * @file rtems/score/object.h |
---|
[9c191ee] | 3 | * |
---|
[1dbbc0c] | 4 | * @brief Constants and Structures Associated with the Object Handler |
---|
| 5 | * |
---|
[21242c2] | 6 | * This include file contains all the constants and structures associated |
---|
| 7 | * with the Object Handler. This Handler provides mechanisms which |
---|
| 8 | * can be used to initialize and manipulate all objects which have ids. |
---|
[9c191ee] | 9 | */ |
---|
| 10 | |
---|
| 11 | /* |
---|
[21242c2] | 12 | * COPYRIGHT (c) 1989-2011. |
---|
[ac7d5ef0] | 13 | * On-Line Applications Research Corporation (OAR). |
---|
| 14 | * |
---|
[98e4ebf5] | 15 | * The license and distribution terms for this file may be |
---|
| 16 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 17 | * http://www.rtems.org/license/LICENSE. |
---|
[ac7d5ef0] | 18 | */ |
---|
| 19 | |
---|
[092f142a] | 20 | #ifndef _RTEMS_SCORE_OBJECT_H |
---|
| 21 | #define _RTEMS_SCORE_OBJECT_H |
---|
[ac7d5ef0] | 22 | |
---|
[a2e3f33] | 23 | #include <rtems/score/basedefs.h> |
---|
[8237b2d] | 24 | #include <rtems/score/cpu.h> |
---|
[47988fb] | 25 | |
---|
[ac7d5ef0] | 26 | #ifdef __cplusplus |
---|
| 27 | extern "C" { |
---|
| 28 | #endif |
---|
| 29 | |
---|
[dea3eccb] | 30 | /** |
---|
| 31 | * @defgroup Score SuperCore |
---|
| 32 | * |
---|
| 33 | * @brief Provides services for all APIs. |
---|
| 34 | */ |
---|
[1dbbc0c] | 35 | /**@{*/ |
---|
[dea3eccb] | 36 | |
---|
[78623bce] | 37 | /** |
---|
| 38 | * @defgroup ScoreCPU CPU Architecture Support |
---|
| 39 | * |
---|
| 40 | * @ingroup Score |
---|
| 41 | * |
---|
| 42 | * @brief Provides CPU architecture dependent services. |
---|
| 43 | */ |
---|
[1dbbc0c] | 44 | /**@{*/ |
---|
[78623bce] | 45 | |
---|
[f7f1d77] | 46 | /** |
---|
| 47 | * @defgroup ScoreObject Object Handler |
---|
| 48 | * |
---|
| 49 | * @ingroup Score |
---|
| 50 | */ |
---|
[1dbbc0c] | 51 | /**@{*/ |
---|
[f7f1d77] | 52 | |
---|
[6a07436] | 53 | /** |
---|
[ac7d5ef0] | 54 | * The following type defines the control block used to manage |
---|
| 55 | * object names. |
---|
| 56 | */ |
---|
[ce19f1fa] | 57 | typedef union { |
---|
[7038271] | 58 | /** This is a pointer to a string name. */ |
---|
| 59 | const char *name_p; |
---|
[ce19f1fa] | 60 | /** This is the actual 32-bit "raw" integer name. */ |
---|
| 61 | uint32_t name_u32; |
---|
| 62 | } Objects_Name; |
---|
[3235ad9] | 63 | |
---|
[85b7605] | 64 | #if defined(RTEMS_USE_16_BIT_OBJECT) |
---|
[6a07436] | 65 | /** |
---|
[85b7605] | 66 | * The following type defines the control block used to manage |
---|
| 67 | * object IDs. The format is as follows (0=LSB): |
---|
| 68 | * |
---|
| 69 | * Bits 0 .. 7 = index (up to 254 objects of a type) |
---|
| 70 | * Bits 8 .. 10 = API (up to 7 API classes) |
---|
| 71 | * Bits 11 .. 15 = class (up to 31 object types per API) |
---|
| 72 | */ |
---|
| 73 | typedef uint16_t Objects_Id; |
---|
[6a07436] | 74 | |
---|
| 75 | /** |
---|
| 76 | * This type is used to store the maximum number of allowed objects |
---|
| 77 | * of each type. |
---|
| 78 | */ |
---|
[85b7605] | 79 | typedef uint8_t Objects_Maximum; |
---|
| 80 | |
---|
[0d15414e] | 81 | #define OBJECTS_INDEX_START_BIT 0U |
---|
| 82 | #define OBJECTS_API_START_BIT 8U |
---|
| 83 | #define OBJECTS_CLASS_START_BIT 11U |
---|
[85b7605] | 84 | |
---|
[0d15414e] | 85 | #define OBJECTS_INDEX_MASK (Objects_Id)0x00ffU |
---|
| 86 | #define OBJECTS_API_MASK (Objects_Id)0x0700U |
---|
| 87 | #define OBJECTS_CLASS_MASK (Objects_Id)0xF800U |
---|
[50269c46] | 88 | |
---|
[0d15414e] | 89 | #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x00ffU |
---|
| 90 | #define OBJECTS_API_VALID_BITS (Objects_Id)0x0007U |
---|
[50269c46] | 91 | /* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */ |
---|
[0d15414e] | 92 | #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x001fU |
---|
[50269c46] | 93 | |
---|
[0d15414e] | 94 | #define OBJECTS_UNLIMITED_OBJECTS 0x8000U |
---|
[85b7605] | 95 | |
---|
[6a07436] | 96 | #define OBJECTS_ID_INITIAL_INDEX (0) |
---|
| 97 | #define OBJECTS_ID_FINAL_INDEX (0xff) |
---|
| 98 | |
---|
[85b7605] | 99 | #else |
---|
[6a07436] | 100 | /** |
---|
[ac7d5ef0] | 101 | * The following type defines the control block used to manage |
---|
[95fbca1] | 102 | * object IDs. The format is as follows (0=LSB): |
---|
| 103 | * |
---|
[ef9505a9] | 104 | * Bits 0 .. 15 = index (up to 65535 objects of a type) |
---|
| 105 | * Bits 16 .. 23 = node (up to 255 nodes) |
---|
| 106 | * Bits 24 .. 26 = API (up to 7 API classes) |
---|
| 107 | * Bits 27 .. 31 = class (up to 31 object types per API) |
---|
[ac7d5ef0] | 108 | */ |
---|
[d6154c7] | 109 | typedef uint32_t Objects_Id; |
---|
[6a07436] | 110 | |
---|
| 111 | /** |
---|
| 112 | * This type is used to store the maximum number of allowed objects |
---|
| 113 | * of each type. |
---|
| 114 | */ |
---|
[85b7605] | 115 | typedef uint16_t Objects_Maximum; |
---|
[ac7d5ef0] | 116 | |
---|
[6a07436] | 117 | /** |
---|
| 118 | * This is the bit position of the starting bit of the index portion of |
---|
| 119 | * the object Id. |
---|
| 120 | */ |
---|
[0d15414e] | 121 | #define OBJECTS_INDEX_START_BIT 0U |
---|
[6a07436] | 122 | /** |
---|
| 123 | * This is the bit position of the starting bit of the node portion of |
---|
| 124 | * the object Id. |
---|
| 125 | */ |
---|
[0d15414e] | 126 | #define OBJECTS_NODE_START_BIT 16U |
---|
[6a07436] | 127 | |
---|
| 128 | /** |
---|
| 129 | * This is the bit position of the starting bit of the API portion of |
---|
| 130 | * the object Id. |
---|
| 131 | */ |
---|
[0d15414e] | 132 | #define OBJECTS_API_START_BIT 24U |
---|
[6a07436] | 133 | |
---|
| 134 | /** |
---|
| 135 | * This is the bit position of the starting bit of the class portion of |
---|
| 136 | * the object Id. |
---|
| 137 | */ |
---|
[0d15414e] | 138 | #define OBJECTS_CLASS_START_BIT 27U |
---|
[95fbca1] | 139 | |
---|
[6a07436] | 140 | /** |
---|
| 141 | * This mask is used to extract the index portion of an object Id. |
---|
| 142 | */ |
---|
[0d15414e] | 143 | #define OBJECTS_INDEX_MASK (Objects_Id)0x0000ffffU |
---|
[6a07436] | 144 | |
---|
| 145 | /** |
---|
| 146 | * This mask is used to extract the node portion of an object Id. |
---|
| 147 | */ |
---|
[0d15414e] | 148 | #define OBJECTS_NODE_MASK (Objects_Id)0x00ff0000U |
---|
[6a07436] | 149 | |
---|
| 150 | /** |
---|
| 151 | * This mask is used to extract the API portion of an object Id. |
---|
| 152 | */ |
---|
[0d15414e] | 153 | #define OBJECTS_API_MASK (Objects_Id)0x07000000U |
---|
[6a07436] | 154 | |
---|
| 155 | /** |
---|
| 156 | * This mask is used to extract the class portion of an object Id. |
---|
| 157 | */ |
---|
[0d15414e] | 158 | #define OBJECTS_CLASS_MASK (Objects_Id)0xf8000000U |
---|
[2728d9cf] | 159 | |
---|
[6a07436] | 160 | /** |
---|
| 161 | * This mask represents the bits that is used to ensure no extra bits |
---|
| 162 | * are set after shifting to extract the index portion of an object Id. |
---|
| 163 | */ |
---|
[0d15414e] | 164 | #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x0000ffffU |
---|
[6a07436] | 165 | |
---|
| 166 | /** |
---|
| 167 | * This mask represents the bits that is used to ensure no extra bits |
---|
| 168 | * are set after shifting to extract the node portion of an object Id. |
---|
| 169 | */ |
---|
[0d15414e] | 170 | #define OBJECTS_NODE_VALID_BITS (Objects_Id)0x000000ffU |
---|
[6a07436] | 171 | |
---|
| 172 | /** |
---|
| 173 | * This mask represents the bits that is used to ensure no extra bits |
---|
| 174 | * are set after shifting to extract the API portion of an object Id. |
---|
| 175 | */ |
---|
[0d15414e] | 176 | #define OBJECTS_API_VALID_BITS (Objects_Id)0x00000007U |
---|
[6a07436] | 177 | |
---|
| 178 | /** |
---|
| 179 | * This mask represents the bits that is used to ensure no extra bits |
---|
| 180 | * are set after shifting to extract the class portion of an object Id. |
---|
| 181 | */ |
---|
[0d15414e] | 182 | #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x0000001fU |
---|
[50269c46] | 183 | |
---|
[6a07436] | 184 | /** |
---|
[50269c46] | 185 | * Mask to enable unlimited objects. This is used in the configuration |
---|
| 186 | * table when specifying the number of configured objects. |
---|
| 187 | */ |
---|
[0d15414e] | 188 | #define OBJECTS_UNLIMITED_OBJECTS 0x80000000U |
---|
[50269c46] | 189 | |
---|
[6a07436] | 190 | /** |
---|
| 191 | * This is the lowest value for the index portion of an object Id. |
---|
| 192 | */ |
---|
| 193 | #define OBJECTS_ID_INITIAL_INDEX (0) |
---|
| 194 | |
---|
| 195 | /** |
---|
| 196 | * This is the highest value for the index portion of an object Id. |
---|
| 197 | */ |
---|
[0d15414e] | 198 | #define OBJECTS_ID_FINAL_INDEX (0xffffU) |
---|
[85b7605] | 199 | #endif |
---|
[95fbca1] | 200 | |
---|
[6a07436] | 201 | /** |
---|
[95fbca1] | 202 | * This enumerated type is used in the class field of the object ID. |
---|
| 203 | */ |
---|
| 204 | typedef enum { |
---|
[ef9505a9] | 205 | OBJECTS_NO_API = 0, |
---|
| 206 | OBJECTS_INTERNAL_API = 1, |
---|
| 207 | OBJECTS_CLASSIC_API = 2, |
---|
[b427a92] | 208 | OBJECTS_POSIX_API = 3, |
---|
| 209 | OBJECTS_FAKE_OBJECTS_API = 7 |
---|
[ef9505a9] | 210 | } Objects_APIs; |
---|
| 211 | |
---|
[f6efd0bf] | 212 | /** This macro is used to generically specify the last API index. */ |
---|
| 213 | #define OBJECTS_APIS_LAST OBJECTS_POSIX_API |
---|
| 214 | |
---|
[0868844e] | 215 | /** |
---|
| 216 | * No object can have this ID. |
---|
| 217 | */ |
---|
| 218 | #define OBJECTS_ID_NONE 0 |
---|
| 219 | |
---|
[6a07436] | 220 | /** |
---|
[ac7d5ef0] | 221 | * The following defines the constant which may be used |
---|
[ee710ef] | 222 | * to manipulate the calling task. |
---|
[ac7d5ef0] | 223 | */ |
---|
[95fbca1] | 224 | #define OBJECTS_ID_OF_SELF ((Objects_Id) 0) |
---|
[ac7d5ef0] | 225 | |
---|
[6a07436] | 226 | /** |
---|
| 227 | * The following constant is used to specify that a name to ID search |
---|
| 228 | * should search through all nodes. |
---|
[ac7d5ef0] | 229 | */ |
---|
[3a4ae6c] | 230 | #define OBJECTS_SEARCH_ALL_NODES 0 |
---|
[6a07436] | 231 | |
---|
| 232 | /** |
---|
| 233 | * The following constant is used to specify that a name to ID search |
---|
| 234 | * should search through all nodes except the current node. |
---|
| 235 | */ |
---|
[3a4ae6c] | 236 | #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE |
---|
[ac7d5ef0] | 237 | |
---|
[6a07436] | 238 | /** |
---|
| 239 | * The following constant is used to specify that a name to ID search |
---|
| 240 | * should search only on this node. |
---|
[b06e68ef] | 241 | */ |
---|
[6a07436] | 242 | #define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF |
---|
[b06e68ef] | 243 | |
---|
[6a07436] | 244 | /** |
---|
| 245 | * The following constant is used to specify that a name to ID search |
---|
| 246 | * is being asked for the ID of the currently executing task. |
---|
| 247 | */ |
---|
| 248 | #define OBJECTS_WHO_AM_I 0 |
---|
[b06e68ef] | 249 | |
---|
[6a07436] | 250 | /** |
---|
| 251 | * This macros calculates the lowest ID for the specified api, class, |
---|
| 252 | * and node. |
---|
| 253 | */ |
---|
[ef9505a9] | 254 | #define OBJECTS_ID_INITIAL(_api, _class, _node) \ |
---|
| 255 | _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX ) |
---|
[6a07436] | 256 | |
---|
| 257 | /** |
---|
| 258 | * This macro specifies the highest object ID value |
---|
| 259 | */ |
---|
[3a4ae6c] | 260 | #define OBJECTS_ID_FINAL ((Objects_Id)~0) |
---|
[b06e68ef] | 261 | |
---|
[6c06288] | 262 | /** |
---|
| 263 | * This macro is used to build a thirty-two bit style name from |
---|
[20f02c6] | 264 | * four characters. The most significant byte will be the |
---|
[18ca4e8] | 265 | * character @a _C1. |
---|
[6c06288] | 266 | * |
---|
| 267 | * @param[in] _C1 is the first character of the name |
---|
| 268 | * @param[in] _C2 is the second character of the name |
---|
| 269 | * @param[in] _C3 is the third character of the name |
---|
| 270 | * @param[in] _C4 is the fourth character of the name |
---|
| 271 | */ |
---|
| 272 | #define _Objects_Build_name( _C1, _C2, _C3, _C4 ) \ |
---|
| 273 | ( (uint32_t)(_C1) << 24 | \ |
---|
| 274 | (uint32_t)(_C2) << 16 | \ |
---|
| 275 | (uint32_t)(_C3) << 8 | \ |
---|
| 276 | (uint32_t)(_C4) ) |
---|
| 277 | |
---|
[6a07436] | 278 | /** |
---|
[a2e3f33] | 279 | * This function returns the API portion of the ID. |
---|
[6a07436] | 280 | * |
---|
[a2e3f33] | 281 | * @param[in] id is the object Id to be processed. |
---|
[6a07436] | 282 | * |
---|
[a2e3f33] | 283 | * @return This method returns an object Id constructed from the arguments. |
---|
[6a07436] | 284 | */ |
---|
[a2e3f33] | 285 | RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API( |
---|
| 286 | Objects_Id id |
---|
| 287 | ) |
---|
| 288 | { |
---|
| 289 | return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS); |
---|
| 290 | } |
---|
[e1bce86] | 291 | |
---|
[6c06288] | 292 | /** |
---|
[a2e3f33] | 293 | * This function returns the class portion of the ID. |
---|
[6c06288] | 294 | * |
---|
[a2e3f33] | 295 | * @param[in] id is the object Id to be processed |
---|
[6c06288] | 296 | */ |
---|
[a2e3f33] | 297 | RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class( |
---|
| 298 | Objects_Id id |
---|
| 299 | ) |
---|
| 300 | { |
---|
| 301 | return (uint32_t) |
---|
| 302 | ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS); |
---|
| 303 | } |
---|
[6c06288] | 304 | |
---|
[9184270] | 305 | /** |
---|
[a2e3f33] | 306 | * This function returns the node portion of the ID. |
---|
[9184270] | 307 | * |
---|
[a2e3f33] | 308 | * @param[in] id is the object Id to be processed |
---|
[f839bf5a] | 309 | * |
---|
[a2e3f33] | 310 | * @return This method returns the node portion of an object ID. |
---|
[9184270] | 311 | */ |
---|
[a2e3f33] | 312 | RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node( |
---|
| 313 | Objects_Id id |
---|
| 314 | ) |
---|
| 315 | { |
---|
| 316 | /* |
---|
| 317 | * If using 16-bit Ids, then there is no node field and it MUST |
---|
| 318 | * be a single processor system. |
---|
| 319 | */ |
---|
| 320 | #if defined(RTEMS_USE_16_BIT_OBJECT) |
---|
| 321 | return 1; |
---|
| 322 | #else |
---|
| 323 | return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS; |
---|
| 324 | #endif |
---|
| 325 | } |
---|
[9184270] | 326 | |
---|
| 327 | /** |
---|
[a2e3f33] | 328 | * This function returns the index portion of the ID. |
---|
[f2f63d1] | 329 | * |
---|
[a2e3f33] | 330 | * @param[in] id is the Id to be processed |
---|
[9184270] | 331 | * |
---|
[a2e3f33] | 332 | * @return This method returns the class portion of the specified object ID. |
---|
[9184270] | 333 | */ |
---|
[a2e3f33] | 334 | RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index( |
---|
| 335 | Objects_Id id |
---|
| 336 | ) |
---|
| 337 | { |
---|
| 338 | return |
---|
| 339 | (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) & |
---|
| 340 | OBJECTS_INDEX_VALID_BITS); |
---|
| 341 | } |
---|
[9184270] | 342 | |
---|
[fe1dc22] | 343 | /** |
---|
[a2e3f33] | 344 | * This function builds an object's id from the processor node and index |
---|
| 345 | * values specified. |
---|
| 346 | * |
---|
| 347 | * @param[in] the_api indicates the API associated with this Id. |
---|
| 348 | * @param[in] the_class indicates the class of object. |
---|
| 349 | * It is specific to @a the_api. |
---|
| 350 | * @param[in] node is the node where this object resides. |
---|
| 351 | * @param[in] index is the instance number of this object. |
---|
| 352 | * |
---|
| 353 | * @return This method returns an object Id constructed from the arguments. |
---|
| 354 | */ |
---|
| 355 | RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id( |
---|
| 356 | Objects_APIs the_api, |
---|
[89be4e7] | 357 | uint16_t the_class, |
---|
| 358 | uint8_t node, |
---|
| 359 | uint16_t index |
---|
[a2e3f33] | 360 | ) |
---|
| 361 | { |
---|
| 362 | return (( (Objects_Id) the_api ) << OBJECTS_API_START_BIT) | |
---|
| 363 | (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) | |
---|
| 364 | #if !defined(RTEMS_USE_16_BIT_OBJECT) |
---|
| 365 | (( (Objects_Id) node ) << OBJECTS_NODE_START_BIT) | |
---|
| 366 | #endif |
---|
| 367 | (( (Objects_Id) index ) << OBJECTS_INDEX_START_BIT); |
---|
| 368 | } |
---|
[ac7d5ef0] | 369 | |
---|
[f6efd0bf] | 370 | /** |
---|
| 371 | * Returns if the object maximum specifies unlimited objects. |
---|
| 372 | * |
---|
| 373 | * @param[in] maximum The object maximum specification. |
---|
| 374 | * |
---|
| 375 | * @retval true Unlimited objects are available. |
---|
| 376 | * @retval false The object count is fixed. |
---|
| 377 | */ |
---|
| 378 | RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum ) |
---|
| 379 | { |
---|
| 380 | return (maximum & OBJECTS_UNLIMITED_OBJECTS) != 0; |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | /* |
---|
| 384 | * We cannot use an inline function for this since it may be evaluated at |
---|
| 385 | * compile time. |
---|
| 386 | */ |
---|
| 387 | #define _Objects_Maximum_per_allocation( maximum ) \ |
---|
| 388 | ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS)) |
---|
| 389 | |
---|
[a2e3f33] | 390 | /**@}*/ |
---|
| 391 | /**@}*/ |
---|
| 392 | /**@}*/ |
---|
[ac7d5ef0] | 393 | |
---|
| 394 | #ifdef __cplusplus |
---|
| 395 | } |
---|
| 396 | #endif |
---|
| 397 | |
---|
| 398 | #endif |
---|
[b10825c] | 399 | /* end of include file */ |
---|