1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Implementation Helper for CPU Set |
---|
5 | * |
---|
6 | * This file contains the implementation helpers inlines and prototypes for |
---|
7 | * CPU set methods. |
---|
8 | */ |
---|
9 | |
---|
10 | /* |
---|
11 | * COPYRIGHT (c) 2014. |
---|
12 | * On-Line Applications Research Corporation (OAR). |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef _RTEMS_SCORE_CPUSETIMPL_H |
---|
20 | #define _RTEMS_SCORE_CPUSETIMPL_H |
---|
21 | |
---|
22 | #include <rtems/score/cpuset.h> |
---|
23 | #include <rtems/score/smp.h> |
---|
24 | |
---|
25 | #include <limits.h> |
---|
26 | |
---|
27 | #ifdef __cplusplus |
---|
28 | extern "C" { |
---|
29 | #endif |
---|
30 | |
---|
31 | #ifdef __RTEMS_HAVE_SYS_CPUSET_H__ |
---|
32 | |
---|
33 | /** |
---|
34 | * @brief Determine If the CPU Set if Valid |
---|
35 | * |
---|
36 | * This routine validates a cpuset size corresponds to the system |
---|
37 | * correct size, that at least one valid cpu is set and that no invalid |
---|
38 | * cpus are set. |
---|
39 | * |
---|
40 | * @param[in] cpuset is the cpuset to validate |
---|
41 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
42 | * |
---|
43 | * @return true if the set is valid |
---|
44 | */ |
---|
45 | bool _CPU_set_Is_valid( const cpu_set_t *cpuset, size_t setsize ); |
---|
46 | |
---|
47 | /** |
---|
48 | * @brief Print the CPU Set |
---|
49 | * |
---|
50 | * This routine will print the value of the given cpuset. |
---|
51 | * |
---|
52 | * @param[in] description is a string to print before the value. |
---|
53 | * @param[in] cpuset is the cpuset to validate |
---|
54 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
55 | */ |
---|
56 | void _CPU_set_Show( const char *description, const cpu_set_t *cpuset); |
---|
57 | |
---|
58 | /** |
---|
59 | * @brief Print the Default CPU Set |
---|
60 | * |
---|
61 | * This routine will print the value of the default cpuset. |
---|
62 | * |
---|
63 | * @param[in] description is a string to print before the value. |
---|
64 | */ |
---|
65 | void _CPU_set_Show_default( const char *description ); |
---|
66 | |
---|
67 | /** |
---|
68 | * @brief Obtain the Default CPU Set |
---|
69 | * |
---|
70 | * This routine returns the default cpuset for this system. |
---|
71 | * |
---|
72 | * @return a pointer to the default cpuset. |
---|
73 | */ |
---|
74 | const CPU_set_Control *_CPU_set_Default(void); |
---|
75 | |
---|
76 | /** |
---|
77 | * @brief Obtain the Maximum Number of CPUs Representable in CPU Set |
---|
78 | * |
---|
79 | * This routine returns maximum number of CPUs that can be represented |
---|
80 | * in the @a setsize specified. |
---|
81 | * |
---|
82 | * @return the number of representable cores in the cpuset |
---|
83 | */ |
---|
84 | RTEMS_INLINE_ROUTINE size_t _CPU_set_Maximum_CPU_count( size_t setsize ) |
---|
85 | { |
---|
86 | return setsize * CHAR_BIT; |
---|
87 | } |
---|
88 | |
---|
89 | /** |
---|
90 | * @brief Is this CPU Set Large Enough? |
---|
91 | * |
---|
92 | * This method can be used to determine if a particular cpuset is |
---|
93 | * large enough for the number of CPUs in the system. |
---|
94 | * |
---|
95 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
96 | * |
---|
97 | * @return true if the @a setsize is sufficient |
---|
98 | */ |
---|
99 | RTEMS_INLINE_ROUTINE bool _CPU_set_Is_large_enough( |
---|
100 | size_t setsize |
---|
101 | ) |
---|
102 | { |
---|
103 | return _CPU_set_Maximum_CPU_count( setsize ) >= _SMP_Get_processor_count(); |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * @brief Fill in CPU_set_Control |
---|
108 | * |
---|
109 | * This method fills in a CPU_set_Control based upon a cpu_set_t and |
---|
110 | * size information. |
---|
111 | * |
---|
112 | * @param[in] cpuset is the cpuset to validate |
---|
113 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
114 | */ |
---|
115 | static inline void _CPU_set_Set( |
---|
116 | size_t setsize, |
---|
117 | cpu_set_t *cpuset, |
---|
118 | CPU_set_Control *set |
---|
119 | ) |
---|
120 | { |
---|
121 | set->set = &set->preallocated; |
---|
122 | set->setsize = setsize; |
---|
123 | CPU_COPY( set->set, cpuset ); |
---|
124 | } |
---|
125 | #endif |
---|
126 | |
---|
127 | /** |
---|
128 | * @brief Initialize the CPU Set Handler |
---|
129 | * |
---|
130 | * This routine validates a cpuset sets at least one valid cpu and that |
---|
131 | * it does not set any invalid cpus. |
---|
132 | */ |
---|
133 | #if __RTEMS_HAVE_SYS_CPUSET_H__ && defined( RTEMS_SMP ) |
---|
134 | void _CPU_set_Handler_initialization(void); |
---|
135 | #else |
---|
136 | #define _CPU_set_Handler_initialization() do { } while ( 0 ) |
---|
137 | #endif |
---|
138 | |
---|
139 | /**@}*/ |
---|
140 | |
---|
141 | #ifdef __cplusplus |
---|
142 | } |
---|
143 | #endif |
---|
144 | #endif |
---|
145 | /* end of include file */ |
---|