1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Processor Mask API |
---|
5 | * |
---|
6 | * @ingroup ScoreProcessorMask |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2016 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Dornierstr. 4 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #ifndef _RTEMS_SCORE_PROCESSORMASK_H |
---|
24 | #define _RTEMS_SCORE_PROCESSORMASK_H |
---|
25 | |
---|
26 | #include <rtems/score/cpu.h> |
---|
27 | |
---|
28 | #ifdef __cplusplus |
---|
29 | extern "C" { |
---|
30 | #endif /* __cplusplus */ |
---|
31 | |
---|
32 | /** |
---|
33 | * @defgroup ScoreProcessorMask Processor Mask |
---|
34 | * |
---|
35 | * @ingroup Score |
---|
36 | * |
---|
37 | * The processor mask provides a bit map large enough to provide one bit for |
---|
38 | * each processor in the system. It is a fixed size internal data type |
---|
39 | * provided for efficiency in addition to the API level cpu_set_t. |
---|
40 | * |
---|
41 | * @{ |
---|
42 | */ |
---|
43 | |
---|
44 | #define PROCESSOR_MASK_BITS_PER_FIELD 32 |
---|
45 | |
---|
46 | #define PROCESSOR_MASK_FIELD_COUNT \ |
---|
47 | ( ( CPU_MAXIMUM_PROCESSORS + PROCESSOR_MASK_BITS_PER_FIELD - 1 ) \ |
---|
48 | / PROCESSOR_MASK_BITS_PER_FIELD ) |
---|
49 | |
---|
50 | #define PROCESSOR_MASK_BIT( index ) \ |
---|
51 | (1UL << ( ( index ) % PROCESSOR_MASK_BITS_PER_FIELD ) ) |
---|
52 | |
---|
53 | #define PROCESSOR_MASK_FIELD( index ) \ |
---|
54 | ( ( index ) / PROCESSOR_MASK_BITS_PER_FIELD ) |
---|
55 | |
---|
56 | /** |
---|
57 | * @brief A bit map consisting of 32-bit integer fields which is large enough |
---|
58 | * to provide one bit for each processor in the system. |
---|
59 | * |
---|
60 | * Processor 0 corresponds to the bit 0 (least-significant) of the field 0 in |
---|
61 | * the array, and so on. |
---|
62 | */ |
---|
63 | typedef uint32_t Processor_mask[ PROCESSOR_MASK_FIELD_COUNT ]; |
---|
64 | |
---|
65 | RTEMS_INLINE_ROUTINE void _Processor_mask_Set( Processor_mask mask, uint32_t index ) |
---|
66 | { |
---|
67 | mask[ PROCESSOR_MASK_FIELD( index ) ] |= PROCESSOR_MASK_BIT( index ); |
---|
68 | } |
---|
69 | |
---|
70 | RTEMS_INLINE_ROUTINE void _Processor_mask_Clear( Processor_mask mask, uint32_t index ) |
---|
71 | { |
---|
72 | mask[ PROCESSOR_MASK_FIELD( index ) ] &= ~PROCESSOR_MASK_BIT( index ); |
---|
73 | } |
---|
74 | |
---|
75 | RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set( |
---|
76 | const Processor_mask mask, |
---|
77 | uint32_t index |
---|
78 | ) |
---|
79 | { |
---|
80 | return ( mask[ PROCESSOR_MASK_FIELD( index ) ] |
---|
81 | & PROCESSOR_MASK_BIT( index ) ) != 0; |
---|
82 | } |
---|
83 | |
---|
84 | /** @} */ |
---|
85 | |
---|
86 | #ifdef __cplusplus |
---|
87 | } |
---|
88 | #endif /* __cplusplus */ |
---|
89 | |
---|
90 | #endif /* _RTEMS_SCORE_PROCESSORMASK_H */ |
---|