![]() |
|
|||
File indexing completed on 2025-05-11 08:24:13
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSScoreObject 0007 * 0008 * @brief This header file provides interfaces of the 0009 * @ref RTEMSScoreObject which are used by the implementation and the 0010 * @ref RTEMSImplApplConfig. 0011 */ 0012 0013 /* 0014 * COPYRIGHT (c) 1989-2011. 0015 * On-Line Applications Research Corporation (OAR). 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _RTEMS_SCORE_OBJECT_H 0040 #define _RTEMS_SCORE_OBJECT_H 0041 0042 #include <rtems/score/basedefs.h> 0043 #include <rtems/score/cpu.h> 0044 0045 #ifdef __cplusplus 0046 extern "C" { 0047 #endif 0048 0049 /** 0050 * @defgroup RTEMSScore SuperCore 0051 * 0052 * @ingroup RTEMSImpl 0053 * 0054 * @brief This group contains the SuperCore implementation. 0055 * 0056 * The SuperCore provides services for all APIs. 0057 */ 0058 0059 /** 0060 * @defgroup RTEMSScoreCPU CPU Architecture Support 0061 * 0062 * @ingroup RTEMSScore 0063 * 0064 * @brief This group contains the implementation to support a processor 0065 * architecture. 0066 */ 0067 0068 /** 0069 * @defgroup RTEMSScoreObject Object Handler 0070 * 0071 * @ingroup RTEMSScore 0072 * 0073 * @brief This group contains the Object Handler implementation. 0074 * 0075 * This handler provides mechanisms which can be used to initialize and 0076 * manipulate all objects which have identifiers. 0077 * 0078 * @{ 0079 */ 0080 0081 /** 0082 * The following type defines the control block used to manage 0083 * object names. 0084 */ 0085 typedef union { 0086 /** This is a pointer to a string name. */ 0087 const char *name_p; 0088 /** This is the actual 32-bit "raw" integer name. */ 0089 uint32_t name_u32; 0090 } Objects_Name; 0091 0092 /** 0093 * The following type defines the control block used to manage 0094 * object IDs. The format is as follows (0=LSB): 0095 * 0096 * Bits 0 .. 15 = index (up to 65535 objects of a type) 0097 * Bits 16 .. 23 = node (up to 255 nodes) 0098 * Bits 24 .. 26 = API (up to 7 API classes) 0099 * Bits 27 .. 31 = class (up to 31 object types per API) 0100 */ 0101 typedef uint32_t Objects_Id; 0102 0103 /** 0104 * This type is used to store the maximum number of allowed objects 0105 * of each type. 0106 */ 0107 typedef uint16_t Objects_Maximum; 0108 0109 /** 0110 * This is the bit position of the starting bit of the index portion of 0111 * the object Id. 0112 */ 0113 #define OBJECTS_INDEX_START_BIT 0U 0114 /** 0115 * This is the bit position of the starting bit of the node portion of 0116 * the object Id. 0117 */ 0118 #define OBJECTS_NODE_START_BIT 16U 0119 0120 /** 0121 * This is the bit position of the starting bit of the API portion of 0122 * the object Id. 0123 */ 0124 #define OBJECTS_API_START_BIT 24U 0125 0126 /** 0127 * This is the bit position of the starting bit of the class portion of 0128 * the object Id. 0129 */ 0130 #define OBJECTS_CLASS_START_BIT 27U 0131 0132 /** 0133 * This mask is used to extract the index portion of an object Id. 0134 */ 0135 #define OBJECTS_INDEX_MASK (Objects_Id)0x0000ffffU 0136 0137 /** 0138 * This mask is used to extract the node portion of an object Id. 0139 */ 0140 #define OBJECTS_NODE_MASK (Objects_Id)0x00ff0000U 0141 0142 /** 0143 * This mask is used to extract the API portion of an object Id. 0144 */ 0145 #define OBJECTS_API_MASK (Objects_Id)0x07000000U 0146 0147 /** 0148 * This mask is used to extract the class portion of an object Id. 0149 */ 0150 #define OBJECTS_CLASS_MASK (Objects_Id)0xf8000000U 0151 0152 /** 0153 * This mask represents the bits that is used to ensure no extra bits 0154 * are set after shifting to extract the index portion of an object Id. 0155 */ 0156 #define OBJECTS_INDEX_VALID_BITS (Objects_Id)0x0000ffffU 0157 0158 /** 0159 * This mask represents the bits that is used to ensure no extra bits 0160 * are set after shifting to extract the node portion of an object Id. 0161 */ 0162 #define OBJECTS_NODE_VALID_BITS (Objects_Id)0x000000ffU 0163 0164 /** 0165 * This mask represents the bits that is used to ensure no extra bits 0166 * are set after shifting to extract the API portion of an object Id. 0167 */ 0168 #define OBJECTS_API_VALID_BITS (Objects_Id)0x00000007U 0169 0170 /** 0171 * This mask represents the bits that is used to ensure no extra bits 0172 * are set after shifting to extract the class portion of an object Id. 0173 */ 0174 #define OBJECTS_CLASS_VALID_BITS (Objects_Id)0x0000001fU 0175 0176 /** 0177 * Mask to enable unlimited objects. This is used in the configuration 0178 * table when specifying the number of configured objects. 0179 */ 0180 #define OBJECTS_UNLIMITED_OBJECTS 0x80000000U 0181 0182 /** 0183 * This is the lowest value for the index portion of an object Id. 0184 */ 0185 #define OBJECTS_ID_INITIAL_INDEX (0) 0186 0187 /** 0188 * This is the highest value for the index portion of an object Id. 0189 */ 0190 #define OBJECTS_ID_FINAL_INDEX (0xffffU) 0191 0192 /** 0193 * This enumerated type is used in the class field of the object ID. 0194 */ 0195 typedef enum { 0196 OBJECTS_NO_API = 0, 0197 OBJECTS_INTERNAL_API = 1, 0198 OBJECTS_CLASSIC_API = 2, 0199 OBJECTS_POSIX_API = 3, 0200 OBJECTS_FAKE_OBJECTS_API = 7 0201 } Objects_APIs; 0202 0203 /** This macro is used to generically specify the last API index. */ 0204 #define OBJECTS_APIS_LAST OBJECTS_POSIX_API 0205 0206 /** 0207 * No object can have this ID. 0208 */ 0209 #define OBJECTS_ID_NONE 0 0210 0211 /** 0212 * The following defines the constant which may be used 0213 * to manipulate the calling task. 0214 */ 0215 #define OBJECTS_ID_OF_SELF ((Objects_Id) 0) 0216 0217 /** 0218 * The following constant is used to specify that a name to ID search 0219 * should search through all nodes. 0220 */ 0221 #define OBJECTS_SEARCH_ALL_NODES 0 0222 0223 /** 0224 * The following constant is used to specify that a name to ID search 0225 * should search through all nodes except the current node. 0226 */ 0227 #define OBJECTS_SEARCH_OTHER_NODES 0x7FFFFFFE 0228 0229 /** 0230 * The following constant is used to specify that a name to ID search 0231 * should search only on this node. 0232 */ 0233 #define OBJECTS_SEARCH_LOCAL_NODE 0x7FFFFFFF 0234 0235 /** 0236 * The following constant is used to specify that a name to ID search 0237 * is being asked for the ID of the currently executing task. 0238 */ 0239 #define OBJECTS_WHO_AM_I 0 0240 0241 /** 0242 * This macros calculates the lowest ID for the specified api, class, 0243 * and node. 0244 */ 0245 #define OBJECTS_ID_INITIAL(_api, _class, _node) \ 0246 _Objects_Build_id( (_api), (_class), (_node), OBJECTS_ID_INITIAL_INDEX ) 0247 0248 /** 0249 * This macro specifies the highest object ID value 0250 */ 0251 #define OBJECTS_ID_FINAL ((Objects_Id)~0) 0252 0253 /** 0254 * This macro is used to build a thirty-two bit style name from 0255 * four characters. The most significant byte will be the 0256 * character @a _C1. 0257 * 0258 * @param[in] _C1 is the first character of the name 0259 * @param[in] _C2 is the second character of the name 0260 * @param[in] _C3 is the third character of the name 0261 * @param[in] _C4 is the fourth character of the name 0262 */ 0263 #define _Objects_Build_name( _C1, _C2, _C3, _C4 ) \ 0264 ( (uint32_t) (uint8_t) (_C1) << 24 | \ 0265 (uint32_t) (uint8_t) (_C2) << 16 | \ 0266 (uint32_t) (uint8_t) (_C3) << 8 | \ 0267 (uint8_t) (_C4) ) 0268 0269 /** 0270 * @brief Returns the API portion of the ID. 0271 * 0272 * @param id The object Id to be processed. 0273 * 0274 * @return An object Id constructed from the arguments. 0275 */ 0276 static inline Objects_APIs _Objects_Get_API( 0277 Objects_Id id 0278 ) 0279 { 0280 return (Objects_APIs) ((id >> OBJECTS_API_START_BIT) & OBJECTS_API_VALID_BITS); 0281 } 0282 0283 /** 0284 * @brief Returns the class portion of the ID. 0285 * 0286 * @param id The object Id to be processed. 0287 * 0288 * @return The class portion of the ID. 0289 */ 0290 static inline uint32_t _Objects_Get_class( 0291 Objects_Id id 0292 ) 0293 { 0294 return (uint32_t) 0295 ((id >> OBJECTS_CLASS_START_BIT) & OBJECTS_CLASS_VALID_BITS); 0296 } 0297 0298 /** 0299 * @brief Returns the node portion of the ID. 0300 * 0301 * @param id The object Id to be processed. 0302 * 0303 * @return Returns the node portion of an object ID. 0304 */ 0305 static inline uint32_t _Objects_Get_node( 0306 Objects_Id id 0307 ) 0308 { 0309 return (id >> OBJECTS_NODE_START_BIT) & OBJECTS_NODE_VALID_BITS; 0310 } 0311 0312 /** 0313 * @brief Returns the index portion of the ID. 0314 * 0315 * @param id is the Id to be processed. 0316 * 0317 * @return Returns the index portion of the specified object ID. 0318 */ 0319 static inline Objects_Maximum _Objects_Get_index( 0320 Objects_Id id 0321 ) 0322 { 0323 return 0324 (Objects_Maximum)((id >> OBJECTS_INDEX_START_BIT) & 0325 OBJECTS_INDEX_VALID_BITS); 0326 } 0327 0328 /** 0329 * @brief Builds an object ID from its components. 0330 * 0331 * @param the_api The object API. 0332 * @param the_class The object API class. 0333 * @param node The object node. 0334 * @param index The object index. 0335 * 0336 * @return Returns the object ID constructed from the arguments. 0337 */ 0338 #define _Objects_Build_id( the_api, the_class, node, index ) \ 0339 ( (Objects_Id) ( (Objects_Id) the_api << OBJECTS_API_START_BIT ) | \ 0340 ( (Objects_Id) the_class << OBJECTS_CLASS_START_BIT ) | \ 0341 ( (Objects_Id) node << OBJECTS_NODE_START_BIT ) | \ 0342 ( (Objects_Id) index << OBJECTS_INDEX_START_BIT ) ) 0343 0344 /** 0345 * Returns if the object maximum specifies unlimited objects. 0346 * 0347 * @param[in] maximum The object maximum specification. 0348 * 0349 * @retval true Unlimited objects are available. 0350 * @retval false The object count is fixed. 0351 */ 0352 #define _Objects_Is_unlimited( maximum ) \ 0353 ( ( ( maximum ) & OBJECTS_UNLIMITED_OBJECTS ) != 0 ) 0354 0355 /* 0356 * We cannot use an inline function for this since it may be evaluated at 0357 * compile time. 0358 */ 0359 #define _Objects_Maximum_per_allocation( maximum ) \ 0360 ((Objects_Maximum) ((maximum) & ~OBJECTS_UNLIMITED_OBJECTS)) 0361 0362 /** 0363 * @brief The local MPCI node number. 0364 */ 0365 #if defined(RTEMS_MULTIPROCESSING) 0366 extern uint16_t _Objects_Local_node; 0367 #else 0368 #define _Objects_Local_node ((uint16_t) 1) 0369 #endif 0370 0371 /** @} */ 0372 0373 #ifdef __cplusplus 0374 } 0375 #endif 0376 0377 #endif 0378 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |