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 | /** |
---|
32 | * @brief Determine If the CPU Set if Valid |
---|
33 | * |
---|
34 | * This routine validates a cpuset size corresponds to the system |
---|
35 | * correct size, that at least one valid cpu is set and that no invalid |
---|
36 | * cpus are set. |
---|
37 | * |
---|
38 | * @param[in] cpuset is the cpuset to validate |
---|
39 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
40 | * |
---|
41 | * @return true if the set is valid |
---|
42 | */ |
---|
43 | bool _CPU_set_Is_valid( const cpu_set_t *cpuset, size_t setsize ); |
---|
44 | |
---|
45 | /** |
---|
46 | * @brief Print the CPU Set |
---|
47 | * |
---|
48 | * This routine will print the value of the given cpuset. |
---|
49 | * |
---|
50 | * @param[in] description is a string to print before the value. |
---|
51 | * @param[in] cpuset is the cpuset to validate |
---|
52 | */ |
---|
53 | void _CPU_set_Show( const char *description, const cpu_set_t *cpuset); |
---|
54 | |
---|
55 | /** |
---|
56 | * @brief Print the Default CPU Set |
---|
57 | * |
---|
58 | * This routine will print the value of the default cpuset. |
---|
59 | * |
---|
60 | * @param[in] description is a string to print before the value. |
---|
61 | */ |
---|
62 | void _CPU_set_Show_default( const char *description ); |
---|
63 | |
---|
64 | /** |
---|
65 | * @brief Obtain the Default CPU Set |
---|
66 | * |
---|
67 | * This routine returns the default cpuset for this system. |
---|
68 | * |
---|
69 | * @return a pointer to the default cpuset. |
---|
70 | */ |
---|
71 | const CPU_set_Control *_CPU_set_Default(void); |
---|
72 | |
---|
73 | /** |
---|
74 | * @brief Obtain the Maximum Number of CPUs Representable in CPU Set |
---|
75 | * |
---|
76 | * This routine returns maximum number of CPUs that can be represented |
---|
77 | * in the @a setsize specified. |
---|
78 | * |
---|
79 | * @return the number of representable cores in the cpuset |
---|
80 | */ |
---|
81 | RTEMS_INLINE_ROUTINE size_t _CPU_set_Maximum_CPU_count( size_t setsize ) |
---|
82 | { |
---|
83 | return setsize * CHAR_BIT; |
---|
84 | } |
---|
85 | |
---|
86 | /** |
---|
87 | * @brief Is this CPU Set Large Enough? |
---|
88 | * |
---|
89 | * This method can be used to determine if a particular cpuset is |
---|
90 | * large enough for the number of CPUs in the system. |
---|
91 | * |
---|
92 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
93 | * |
---|
94 | * @return true if the @a setsize is sufficient |
---|
95 | */ |
---|
96 | RTEMS_INLINE_ROUTINE bool _CPU_set_Is_large_enough( |
---|
97 | size_t setsize |
---|
98 | ) |
---|
99 | { |
---|
100 | return _CPU_set_Maximum_CPU_count( setsize ) >= _SMP_Get_processor_count(); |
---|
101 | } |
---|
102 | |
---|
103 | /** |
---|
104 | * @brief Fill in CPU_set_Control |
---|
105 | * |
---|
106 | * This method fills in a CPU_set_Control based upon a cpu_set_t and |
---|
107 | * size information. |
---|
108 | * |
---|
109 | * @param[in] cpuset is the cpuset to validate |
---|
110 | * @param[in] setsize is the number of CPUs in the cpuset |
---|
111 | */ |
---|
112 | static inline void _CPU_set_Set( |
---|
113 | size_t setsize, |
---|
114 | cpu_set_t *cpuset, |
---|
115 | CPU_set_Control *set |
---|
116 | ) |
---|
117 | { |
---|
118 | set->set = &set->preallocated; |
---|
119 | set->setsize = setsize; |
---|
120 | CPU_COPY( set->set, cpuset ); |
---|
121 | } |
---|
122 | |
---|
123 | /**@}*/ |
---|
124 | |
---|
125 | #ifdef __cplusplus |
---|
126 | } |
---|
127 | #endif |
---|
128 | #endif |
---|
129 | /* end of include file */ |
---|