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/cpu.h>
00025 #include <rtems/score/chain.h>
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00038 #if defined(RTEMS_POSIX_API)
00039 
00045   #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES
00046 #endif
00047 
00068 typedef union {
00069   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
00070 
00071     const char *name_p;
00072   #endif
00073 
00074   uint32_t    name_u32;
00075 } Objects_Name;
00076 
00077 #if defined(RTEMS_USE_16_BIT_OBJECT)
00078 
00086 typedef uint16_t   Objects_Id;
00087 
00092 typedef uint8_t    Objects_Maximum;
00093 
00094 #define OBJECTS_INDEX_START_BIT  0U
00095 #define OBJECTS_API_START_BIT    8U
00096 #define OBJECTS_CLASS_START_BIT 11U
00097 
00098 #define OBJECTS_INDEX_MASK      (Objects_Id)0x00ffU
00099 #define OBJECTS_API_MASK        (Objects_Id)0x0700U
00100 #define OBJECTS_CLASS_MASK      (Objects_Id)0xF800U
00101 
00102 #define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x00ffU
00103 #define OBJECTS_API_VALID_BITS    (Objects_Id)0x0007U
00104 /* OBJECTS_NODE_VALID_BITS should not be used with 16 bit Ids */
00105 #define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x001fU
00106 
00107 #define OBJECTS_UNLIMITED_OBJECTS 0x8000U
00108 
00109 #define OBJECTS_ID_INITIAL_INDEX  (0)
00110 #define OBJECTS_ID_FINAL_INDEX    (0xff)
00111 
00112 #else
00113 
00122 typedef uint32_t   Objects_Id;
00123 
00128 typedef uint16_t   Objects_Maximum;
00129 
00134 #define OBJECTS_INDEX_START_BIT  0U
00135 
00139 #define OBJECTS_NODE_START_BIT  16U
00140 
00145 #define OBJECTS_API_START_BIT   24U
00146 
00151 #define OBJECTS_CLASS_START_BIT 27U
00152 
00156 #define OBJECTS_INDEX_MASK      (Objects_Id)0x0000ffffU
00157 
00161 #define OBJECTS_NODE_MASK       (Objects_Id)0x00ff0000U
00162 
00166 #define OBJECTS_API_MASK        (Objects_Id)0x07000000U
00167 
00171 #define OBJECTS_CLASS_MASK      (Objects_Id)0xf8000000U
00172 
00177 #define OBJECTS_INDEX_VALID_BITS  (Objects_Id)0x0000ffffU
00178 
00183 #define OBJECTS_NODE_VALID_BITS   (Objects_Id)0x000000ffU
00184 
00189 #define OBJECTS_API_VALID_BITS    (Objects_Id)0x00000007U
00190 
00195 #define OBJECTS_CLASS_VALID_BITS  (Objects_Id)0x0000001fU
00196 
00201 #define OBJECTS_UNLIMITED_OBJECTS 0x80000000U
00202 
00206 #define OBJECTS_ID_INITIAL_INDEX  (0)
00207 
00211 #define OBJECTS_ID_FINAL_INDEX    (0xffffU)
00212 #endif
00213 
00217 typedef enum {
00218   OBJECTS_NO_API       = 0,
00219   OBJECTS_INTERNAL_API = 1,
00220   OBJECTS_CLASSIC_API  = 2,
00221   OBJECTS_POSIX_API    = 3,
00222   OBJECTS_FAKE_OBJECTS_API = 7
00223 } Objects_APIs;
00224 
00226 #define OBJECTS_APIS_LAST OBJECTS_POSIX_API
00227 
00232 typedef struct {
00234   Chain_Node     Node;
00236   Objects_Id     id;
00238   Objects_Name   name;
00239 } Objects_Control;
00240 
00241 #if defined( RTEMS_MULTIPROCESSING )
00242 
00246 typedef struct {
00248   Objects_Control Object;
00253   uint32_t        name;
00254 }   Objects_MP_Control;
00255 #endif
00256 
00260 #define OBJECTS_ID_NONE 0
00261 
00266 #define OBJECTS_ID_OF_SELF ((Objects_Id) 0)
00267 
00272 #define OBJECTS_SEARCH_ALL_NODES   0
00273 
00278 #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE
00279 
00284 #define OBJECTS_SEARCH_LOCAL_NODE  0x7FFFFFFF
00285 
00290 #define OBJECTS_WHO_AM_I           0
00291 
00296 #define OBJECTS_ID_INITIAL(_api, _class, _node) \
00297   _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX )
00298 
00302 #define OBJECTS_ID_FINAL           ((Objects_Id)~0)
00303 
00314 #define  _Objects_Build_name( _C1, _C2, _C3, _C4 ) \
00315   ( (uint32_t)(_C1) << 24 | \
00316     (uint32_t)(_C2) << 16 | \
00317     (uint32_t)(_C3) << 8 | \
00318     (uint32_t)(_C4) )
00319 
00327 RTEMS_INLINE_ROUTINE Objects_APIs _Objects_Get_API(
00328   Objects_Id id
00329 )
00330 {
00331   return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS);
00332 }
00333 
00339 RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_class(
00340   Objects_Id id
00341 )
00342 {
00343   return (uint32_t)
00344     ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS);
00345 }
00346 
00354 RTEMS_INLINE_ROUTINE uint32_t _Objects_Get_node(
00355   Objects_Id id
00356 )
00357 {
00358   /*
00359    * If using 16-bit Ids, then there is no node field and it MUST
00360    * be a single processor system.
00361    */
00362   #if defined(RTEMS_USE_16_BIT_OBJECT)
00363     return 1;
00364   #else
00365     return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS;
00366   #endif
00367 }
00368 
00376 RTEMS_INLINE_ROUTINE Objects_Maximum _Objects_Get_index(
00377   Objects_Id id
00378 )
00379 {
00380   return
00381     (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) &
00382                                           OBJECTS_INDEX_VALID_BITS);
00383 }
00384 
00397 RTEMS_INLINE_ROUTINE Objects_Id _Objects_Build_id(
00398   Objects_APIs     the_api,
00399   uint32_t         the_class,
00400   uint32_t         node,
00401   uint32_t         index
00402 )
00403 {
00404   return (( (Objects_Id) the_api )   << OBJECTS_API_START_BIT)   |
00405          (( (Objects_Id) the_class ) << OBJECTS_CLASS_START_BIT) |
00406          #if !defined(RTEMS_USE_16_BIT_OBJECT)
00407            (( (Objects_Id) node )    << OBJECTS_NODE_START_BIT)  |
00408          #endif
00409          (( (Objects_Id) index )     << OBJECTS_INDEX_START_BIT);
00410 }
00411 
00420 RTEMS_INLINE_ROUTINE bool _Objects_Is_unlimited( uint32_t maximum )
00421 {
00422   return (maximum & OBJECTS_UNLIMITED_OBJECTS) != 0;
00423 }
00424 
00425 /*
00426  * We cannot use an inline function for this since it may be evaluated at
00427  * compile time.
00428  */
00429 #define _Objects_Maximum_per_allocation( maximum ) \
00430   ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS))
00431 
00436 #ifdef __cplusplus
00437 }
00438 #endif
00439 
00440 #endif
00441 /* end of include file */