- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/platform/mbed_critical.h
r352 r374 1 1 2 /** \addtogroup platform */3 /** @{*/4 2 /* 5 3 * Copyright (c) 2015-2016, ARM Limited, All Rights Reserved … … 30 28 #endif 31 29 30 /** \addtogroup platform */ 31 /** @{*/ 32 /** 33 * \defgroup platform_critical critical section function 34 * @{ 35 */ 32 36 33 37 /** Determine the current interrupts enabled state 34 38 * 35 39 * This function can be called to determine whether or not interrupts are currently enabled. 36 * \note40 * @note 37 41 * NOTE: 38 42 * This function works for both cortex-A and cortex-M, although the underlyng implementation … … 42 46 bool core_util_are_interrupts_enabled(void); 43 47 48 /** Determine if this code is executing from an interrupt 49 * 50 * This function can be called to determine if the code is running on interrupt context. 51 * @note 52 * NOTE: 53 * This function works for both cortex-A and cortex-M, although the underlyng implementation 54 * differs. 55 * @return true if in an isr, false otherwise 56 */ 57 bool core_util_is_isr_active(void); 58 44 59 /** Mark the start of a critical section 45 60 * 46 61 * This function should be called to mark the start of a critical section of code. 47 * \note62 * @note 48 63 * NOTES: 49 64 * 1) The use of this style of critical section is targetted at C based implementations. … … 58 73 * 59 74 * This function should be called to mark the end of a critical section of code. 60 * \note75 * @note 61 76 * NOTES: 62 77 * 1) The use of this style of critical section is targetted at C based implementations. … … 69 84 70 85 /** 86 * Determine if we are currently in a critical section 87 * 88 * @return true if in a critical section, false otherwise. 89 */ 90 bool core_util_in_critical_section(void); 91 92 /** 71 93 * Atomic compare and set. It compares the contents of a memory location to a 72 94 * given value and, only if they are the same, modifies the contents of that … … 83 105 * expected current value of the data being set atomically. 84 106 * The computed 'desiredValue' should be a function of this current value. 85 * @ Note: This is an in-out parameter. In the107 * @note: This is an in-out parameter. In the 86 108 * failure case of atomic_cas (where the 87 109 * destination isn't set), the pointee of expectedCurrentValue is … … 106 128 * } 107 129 * 108 * @ Note: In the failure case (where the destination isn't set), the value109 * pointed to by expectedCurrentValue is stillupdated with the current value.130 * @note: In the failure case (where the destination isn't set), the value 131 * pointed to by expectedCurrentValue is instead updated with the current value. 110 132 * This property helps writing concise code for the following incr: 111 133 * … … 118 140 * return value + a 119 141 * } 120 */ 121 bool core_util_atomic_cas_u8(uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue); 142 * 143 * @note: This corresponds to the C11 "atomic_compare_exchange_strong" - it 144 * always succeeds if the current value is expected, as per the pseudocode 145 * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. 146 */ 147 bool core_util_atomic_cas_u8(volatile uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue); 122 148 123 149 /** … … 136 162 * expected current value of the data being set atomically. 137 163 * The computed 'desiredValue' should be a function of this current value. 138 * @ Note: This is an in-out parameter. In the164 * @note: This is an in-out parameter. In the 139 165 * failure case of atomic_cas (where the 140 166 * destination isn't set), the pointee of expectedCurrentValue is … … 159 185 * } 160 186 * 161 * @ Note: In the failure case (where the destination isn't set), the value162 * pointed to by expectedCurrentValue is stillupdated with the current value.187 * @note: In the failure case (where the destination isn't set), the value 188 * pointed to by expectedCurrentValue is instead updated with the current value. 163 189 * This property helps writing concise code for the following incr: 164 190 * … … 171 197 * return value + a 172 198 * } 173 */ 174 bool core_util_atomic_cas_u16(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue); 199 * 200 * @note: This corresponds to the C11 "atomic_compare_exchange_strong" - it 201 * always succeeds if the current value is expected, as per the pseudocode 202 * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. 203 */ 204 bool core_util_atomic_cas_u16(volatile uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue); 175 205 176 206 /** … … 189 219 * expected current value of the data being set atomically. 190 220 * The computed 'desiredValue' should be a function of this current value. 191 * @ Note: This is an in-out parameter. In the221 * @note: This is an in-out parameter. In the 192 222 * failure case of atomic_cas (where the 193 223 * destination isn't set), the pointee of expectedCurrentValue is … … 212 242 * } 213 243 * 214 * @ Note: In the failure case (where the destination isn't set), the value215 * pointed to by expectedCurrentValue is stillupdated with the current value.244 * @note: In the failure case (where the destination isn't set), the value 245 * pointed to by expectedCurrentValue is instead updated with the current value. 216 246 * This property helps writing concise code for the following incr: 217 247 * … … 223 253 * } 224 254 * return value + a 225 * } 226 */ 227 bool core_util_atomic_cas_u32(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue); 255 * 256 * @note: This corresponds to the C11 "atomic_compare_exchange_strong" - it 257 * always succeeds if the current value is expected, as per the pseudocode 258 * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. 259 * } 260 */ 261 bool core_util_atomic_cas_u32(volatile uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue); 228 262 229 263 /** … … 242 276 * expected current value of the data being set atomically. 243 277 * The computed 'desiredValue' should be a function of this current value. 244 * @ Note: This is an in-out parameter. In the278 * @note: This is an in-out parameter. In the 245 279 * failure case of atomic_cas (where the 246 280 * destination isn't set), the pointee of expectedCurrentValue is … … 265 299 * } 266 300 * 267 * @ Note: In the failure case (where the destination isn't set), the value268 * pointed to by expectedCurrentValue is stillupdated with the current value.301 * @note: In the failure case (where the destination isn't set), the value 302 * pointed to by expectedCurrentValue is instead updated with the current value. 269 303 * This property helps writing concise code for the following incr: 270 304 * … … 277 311 * return value + a 278 312 * } 279 */ 280 bool core_util_atomic_cas_ptr(void **ptr, void **expectedCurrentValue, void *desiredValue); 313 * 314 * @note: This corresponds to the C11 "atomic_compare_exchange_strong" - it 315 * always succeeds if the current value is expected, as per the pseudocode 316 * above; it will not spuriously fail as "atomic_compare_exchange_weak" may. 317 */ 318 bool core_util_atomic_cas_ptr(void *volatile *ptr, void **expectedCurrentValue, void *desiredValue); 281 319 282 320 /** … … 286 324 * @return The new incremented value. 287 325 */ 288 uint8_t core_util_atomic_incr_u8( uint8_t *valuePtr, uint8_t delta);326 uint8_t core_util_atomic_incr_u8(volatile uint8_t *valuePtr, uint8_t delta); 289 327 290 328 /** … … 294 332 * @return The new incremented value. 295 333 */ 296 uint16_t core_util_atomic_incr_u16( uint16_t *valuePtr, uint16_t delta);334 uint16_t core_util_atomic_incr_u16(volatile uint16_t *valuePtr, uint16_t delta); 297 335 298 336 /** … … 302 340 * @return The new incremented value. 303 341 */ 304 uint32_t core_util_atomic_incr_u32( uint32_t *valuePtr, uint32_t delta);342 uint32_t core_util_atomic_incr_u32(volatile uint32_t *valuePtr, uint32_t delta); 305 343 306 344 /** … … 313 351 * and the pointer is incremented by bytes. 314 352 */ 315 void *core_util_atomic_incr_ptr(void * *valuePtr, ptrdiff_t delta);353 void *core_util_atomic_incr_ptr(void *volatile *valuePtr, ptrdiff_t delta); 316 354 317 355 /** … … 321 359 * @return The new decremented value. 322 360 */ 323 uint8_t core_util_atomic_decr_u8( uint8_t *valuePtr, uint8_t delta);361 uint8_t core_util_atomic_decr_u8(volatile uint8_t *valuePtr, uint8_t delta); 324 362 325 363 /** … … 329 367 * @return The new decremented value. 330 368 */ 331 uint16_t core_util_atomic_decr_u16( uint16_t *valuePtr, uint16_t delta);369 uint16_t core_util_atomic_decr_u16(volatile uint16_t *valuePtr, uint16_t delta); 332 370 333 371 /** … … 337 375 * @return The new decremented value. 338 376 */ 339 uint32_t core_util_atomic_decr_u32( uint32_t *valuePtr, uint32_t delta);377 uint32_t core_util_atomic_decr_u32(volatile uint32_t *valuePtr, uint32_t delta); 340 378 341 379 /** … … 348 386 * and the pointer is decremented by bytes 349 387 */ 350 void *core_util_atomic_decr_ptr(void * *valuePtr, ptrdiff_t delta);388 void *core_util_atomic_decr_ptr(void *volatile *valuePtr, ptrdiff_t delta); 351 389 352 390 #ifdef __cplusplus 353 391 } // extern "C" 354 392 #endif 355 393 /**@}*/ 394 395 /**@}*/ 356 396 357 397 #endif // __MBED_UTIL_CRITICAL_H__ 358 398 359 /** @}*/ 399 400
Note:
See TracChangeset
for help on using the changeset viewer.