RTEMS CPU Kit with SuperCore  4.10.99.0
rtems/score/object.h
Go to the documentation of this file.
00001 
00011 /*
00012  *  COPYRIGHT (c) 1989-2011.
00013  *  On-Line Applications Research Corporation (OAR).
00014  *
00015  *  The license and distribution terms for this file may be
00016  *  found in the file LICENSE in this distribution or at
00017  *  http://www.rtems.org/license/LICENSE.
00018  */
00019 
00020 #ifndef _RTEMS_SCORE_OBJECT_H
00021 #define _RTEMS_SCORE_OBJECT_H
00022 
00023 #include <rtems/score/basedefs.h>
00024 #include <rtems/score/chain.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00037 #if defined(RTEMS_POSIX_API)
00038 
00044   #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES
00045 #endif
00046 
00067 typedef union {
00068   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
00069 
00070     const char *name_p;
00071   #endif
00072 
00073   uint32_t    name_u32;
00074 } Objects_Name;
00075 
00076 #if defined(RTEMS_USE_16_BIT_OBJECT)
00077 
00085 typedef uint16_t   Objects_Id;
00086 
00091 typedef uint8_t    Objects_Maximum;
00092 
00093 #define OBJECTS_INDEX_START_BIT  0U
00094 #define OBJECTS_API_START_BIT    8U
00095 #define OBJECTS_CLASS_START_BIT 11U
00096 
00097 #define OBJECTS_INDEX_MASK      (Objects_Id)0x00ffU
00098 #define OBJECTS_API_MASK        (Objects_Id)0x0700U
00099 #define OBJECTS_CLASS_MASK      (Objects_Id)0xF800U
00100 
00101 #define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x00ffU
00102 #define OBJECTS_API_VALID_BITS    (Objects_Id)0x0007U
00103 /* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */
00104 #define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x001fU
00105 
00106 #define OBJECTS_UNLIMITED_OBJECTS 0x8000U
00107 
00108 #define OBJECTS_ID_INITIAL_INDEX  (0)
00109 #define OBJECTS_ID_FINAL_INDEX    (0xff)
00110 
00111 #else
00112 
00121 typedef uint32_t   Objects_Id;
00122 
00127 typedef uint16_t   Objects_Maximum;
00128 
00133 #define OBJECTS_INDEX_START_BIT  0U
00134 
00138 #define OBJECTS_NODE_START_BIT  16U
00139 
00144 #define OBJECTS_API_START_BIT   24U
00145 
00150 #define OBJECTS_CLASS_START_BIT 27U
00151 
00155 #define OBJECTS_INDEX_MASK      (Objects_Id)0x0000ffffU
00156 
00160 #define OBJECTS_NODE_MASK       (Objects_Id)0x00ff0000U
00161 
00165 #define OBJECTS_API_MASK        (Objects_Id)0x07000000U
00166 
00170 #define OBJECTS_CLASS_MASK      (Objects_Id)0xf8000000U
00171 
00176 #define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x0000ffffU
00177 
00182 #define OBJECTS_NODE_VALID_BITS   (Objects_Id)0x000000ffU
00183 
00188 #define OBJECTS_API_VALID_BITS    (Objects_Id)0x00000007U
00189 
00194 #define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x0000001fU
00195 
00200 #define OBJECTS_UNLIMITED_OBJECTS 0x80000000U
00201 
00205 #define OBJECTS_ID_INITIAL_INDEX  (0)
00206 
00210 #define OBJECTS_ID_FINAL_INDEX    (0xffffU)
00211 #endif
00212 
00216 typedef enum {
00217   OBJECTS_NO_API       = 0,
00218   OBJECTS_INTERNAL_API = 1,
00219   OBJECTS_CLASSIC_API  = 2,
00220   OBJECTS_POSIX_API    = 3,
00221   OBJECTS_FAKE_OBJECTS_API = 7
00222 } Objects_APIs;
00223 
00225 #define OBJECTS_APIS_LAST OBJECTS_POSIX_API
00226 
00231 typedef struct {
00233   Chain_Node     Node;
00235   Objects_Id     id;
00237   Objects_Name   name;
00238 } Objects_Control;
00239 
00240 #if defined( RTEMS_MULTIPROCESSING )
00241 
00245 typedef struct {
00247   Objects_Control Object;
00252   uint32_t        name;
00253 }   Objects_MP_Control;
00254 #endif
00255 
00259 #define OBJECTS_ID_NONE 0
00260 
00265 #define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
00266 
00271 #define OBJECTS_SEARCH_ALL_NODES   0
00272 
00277 #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
00278 
00283 #define OBJECTS_SEARCH_LOCAL_NODE  0x7FFFFFFF
00284 
00289 #define OBJECTS_WHO_AM_I           0
00290 
00295 #define OBJECTS_ID_INITIAL(_api, _class, _node) \
00296   _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
00297 
00301 #define OBJECTS_ID_FINAL           ((Objects_Id)~0)
00302 
00313 #define  _Objects_Build_name( _C1, _C2, _C3, _C4 ) \
00314   ( (uint32_t)(_C1) << 24 | \
00315     (uint32_t)(_C2) << 16 | \
00316     (uint32_t)(_C3) << 8 | \
00317     (uint32_t)(_C4) )
00318 
00326 RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
00327   Objects_Id id
00328 )
00329 {
00330   return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
00331 }
00332 
00338 RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class(
00339   Objects_Id id
00340 )
00341 {
00342   return (uint32_t)
00343     ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
00344 }
00345 
00353 RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(
00354   Objects_Id id
00355 )
00356 {
00357   /*
00358    * If using 16-bit Ids, then there is no node field and it MUST
00359    * be a single processor system.
00360    */
00361   #if defined(RTEMS_USE_16_BIT_OBJECT)
00362     return 1;
00363   #else
00364     return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
00365   #endif
00366 }
00367 
00375 RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(
00376   Objects_Id id
00377 )
00378 {
00379   return
00380     (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) &
00381                                           OBJECTS_INDEX_VALID_BITS);
00382 }
00383 
00396 RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
00397   Objects_APIs     the_api,
00398   uint32_t         the_class,
00399   uint32_t         node,
00400   uint32_t         index
00401 )
00402 {
00403   return (( (Objects_Id) the_api )   << OBJECTS_API_START_BIT)   |
00404          (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) |
00405          #if !defined(RTEMS_USE_16_BIT_OBJECT)
00406            (( (Objects_Id) node )    << OBJECTS_NODE_START_BIT)  |
00407          #endif
00408          (( (Objects_Id) index )     << OBJECTS_INDEX_START_BIT);
00409 }
00410 
00419 RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum )
00420 {
00421   return (maximum & OBJECTS_UNLIMITED_OBJECTS) != 0;
00422 }
00423 
00424 /*
00425  * We cannot use an inline function for this since it may be evaluated at
00426  * compile time.
00427  */
00428 #define _Objects_Maximum_per_allocation( maximum ) \
00429   ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS))
00430 
00435 #ifdef __cplusplus
00436 }
00437 #endif
00438 
00439 #endif
00440 /* end of include file */