RTEMS: cpukit/include/rtems/score/processormask.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
processormask.h
Go to the documentation of this file.
1
9/*
10 * Copyright (c) 2016, 2017 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#include <sys/cpuset.h>
29
30#include <strings.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif /* __cplusplus */
35
54 typedef BITSET_DEFINE( Processor_mask, CPU_MAXIMUM_PROCESSORS ) Processor_mask;
55
61 RTEMS_INLINE_ROUTINE void _Processor_mask_Zero( Processor_mask *mask )
62{
63 BIT_ZERO( CPU_MAXIMUM_PROCESSORS, mask );
64}
65
74 RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_zero( const Processor_mask *mask )
75{
76 return BIT_EMPTY( CPU_MAXIMUM_PROCESSORS, mask );
77}
78
84 RTEMS_INLINE_ROUTINE void _Processor_mask_Fill( Processor_mask *mask )
85{
86 BIT_FILL( CPU_MAXIMUM_PROCESSORS, mask );
87}
88
95 RTEMS_INLINE_ROUTINE void _Processor_mask_Assign(
96 Processor_mask *dst, const Processor_mask *src
97)
98{
99 BIT_COPY( CPU_MAXIMUM_PROCESSORS, src, dst );
100}
101
108 RTEMS_INLINE_ROUTINE void _Processor_mask_Set(
109 Processor_mask *mask,
110 uint32_t index
111)
112{
113 BIT_SET( CPU_MAXIMUM_PROCESSORS, index, mask );
114}
115
122 RTEMS_INLINE_ROUTINE void _Processor_mask_Clear(
123 Processor_mask *mask,
124 uint32_t index
125)
126{
127 BIT_CLR( CPU_MAXIMUM_PROCESSORS, index, mask );
128}
129
139 RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set(
140 const Processor_mask *mask,
141 uint32_t index
142)
143{
144 return BIT_ISSET( CPU_MAXIMUM_PROCESSORS, index, mask );
145}
146
156 RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_equal(
157 const Processor_mask *a,
158 const Processor_mask *b
159)
160{
161 return !BIT_CMP( CPU_MAXIMUM_PROCESSORS, a, b );
162}
163
174 RTEMS_INLINE_ROUTINE bool _Processor_mask_Has_overlap(
175 const Processor_mask *a,
176 const Processor_mask *b
177)
178{
179 return BIT_OVERLAP( CPU_MAXIMUM_PROCESSORS, a, b );
180}
181
192 RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_subset(
193 const Processor_mask *big,
194 const Processor_mask *small
195)
196{
197 return BIT_SUBSET( CPU_MAXIMUM_PROCESSORS, big, small );
198}
199
207 RTEMS_INLINE_ROUTINE void _Processor_mask_And(
208 Processor_mask *a,
209 const Processor_mask *b,
210 const Processor_mask *c
211)
212{
213 BIT_AND2( CPU_MAXIMUM_PROCESSORS, a, b, c );
214}
215
223 RTEMS_INLINE_ROUTINE void _Processor_mask_Nand(
224 Processor_mask *a,
225 const Processor_mask *b,
226 const Processor_mask *c
227)
228{
229 BIT_NAND2( CPU_MAXIMUM_PROCESSORS, a, b, c );
230}
231
239 RTEMS_INLINE_ROUTINE void _Processor_mask_Or(
240 Processor_mask *a,
241 const Processor_mask *b,
242 const Processor_mask *c
243)
244{
245 BIT_OR2( CPU_MAXIMUM_PROCESSORS, a, b, c );
246}
247
255 RTEMS_INLINE_ROUTINE void _Processor_mask_Xor(
256 Processor_mask *a,
257 const Processor_mask *b,
258 const Processor_mask *c
259)
260{
261 BIT_XOR2( CPU_MAXIMUM_PROCESSORS, a, b, c );
262}
263
271 RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Count( const Processor_mask *a )
272{
273 return (uint32_t) BIT_COUNT( CPU_MAXIMUM_PROCESSORS, a );
274}
275
283 RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Find_last_set( const Processor_mask *a )
284{
285 return (uint32_t) BIT_FLS( CPU_MAXIMUM_PROCESSORS, a );
286}
287
297 RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_To_uint32_t(
298 const Processor_mask *mask,
299 uint32_t index
300)
301{
302 long bits = mask->__bits[ __bitset_words( index ) ];
303
304 return (uint32_t) (bits >> (32 * (index % _BITSET_BITS) / 32));
305}
306
315 RTEMS_INLINE_ROUTINE void _Processor_mask_From_uint32_t(
316 Processor_mask *mask,
317 uint32_t bits,
318 uint32_t index
319)
320{
321 _Processor_mask_Zero( mask );
322 mask->__bits[ __bitset_words( index ) ] = ((long) bits) << (32 * (index % _BITSET_BITS) / 32);
323}
324
331 RTEMS_INLINE_ROUTINE void _Processor_mask_From_index(
332 Processor_mask *mask,
333 uint32_t index
334)
335{
336 BIT_SETOF( CPU_MAXIMUM_PROCESSORS, (int) index, mask );
337}
338
339typedef enum {
340 PROCESSOR_MASK_COPY_LOSSLESS,
341 PROCESSOR_MASK_COPY_PARTIAL_LOSS,
342 PROCESSOR_MASK_COPY_COMPLETE_LOSS,
343 PROCESSOR_MASK_COPY_INVALID_SIZE
344} Processor_mask_Copy_status;
345
354 RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_at_most_partial_loss(
355 Processor_mask_Copy_status status
356)
357{
358 return (unsigned int) status <= PROCESSOR_MASK_COPY_PARTIAL_LOSS;
359}
360
378Processor_mask_Copy_status _Processor_mask_Copy(
379 long *dst,
380 size_t dst_size,
381 const long *src,
382 size_t src_size
383);
384
401 RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_To_cpu_set_t(
402 const Processor_mask *src,
403 size_t dst_size,
404 cpu_set_t *dst
405)
406{
407 return _Processor_mask_Copy(
408 &dst->__bits[ 0 ],
409 dst_size,
410 &src->__bits[ 0 ],
411 sizeof( *src )
412 );
413}
414
431 RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t(
432 Processor_mask *dst,
433 size_t src_size,
434 const cpu_set_t *src
435)
436{
437 return _Processor_mask_Copy(
438 &dst->__bits[ 0 ],
439 sizeof( *dst ),
440 &src->__bits[ 0 ],
441 src_size
442 );
443}
444
445extern const Processor_mask _Processor_mask_The_one_and_only;
446
449#ifdef __cplusplus
450}
451#endif /* __cplusplus */
452
453#endif /* _RTEMS_SCORE_PROCESSORMASK_H */
RTEMS_INLINE_ROUTINE
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
_Processor_mask_And
RTEMS_INLINE_ROUTINE void _Processor_mask_And(Processor_mask *a, const Processor_mask *b, const Processor_mask *c)
Performs a bitwise a = b & c.
Definition: processormask.h:207
BITSET_DEFINE
typedef BITSET_DEFINE(Processor_mask, CPU_MAXIMUM_PROCESSORS) Processor_mask
A bit map which is large enough to provide one bit for each processor in the system.
_Processor_mask_From_index
RTEMS_INLINE_ROUTINE void _Processor_mask_From_index(Processor_mask *mask, uint32_t index)
Creates a processor set from the specified index.
Definition: processormask.h:331
_Processor_mask_Or
RTEMS_INLINE_ROUTINE void _Processor_mask_Or(Processor_mask *a, const Processor_mask *b, const Processor_mask *c)
Performs a bitwise a = b | c.
Definition: processormask.h:239
_Processor_mask_Assign
RTEMS_INLINE_ROUTINE void _Processor_mask_Assign(Processor_mask *dst, const Processor_mask *src)
Copies the mask to another mask, also considers CPU_MAXIMUM_PROCESSORS.
Definition: processormask.h:95
_Processor_mask_Is_subset
RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_subset(const Processor_mask *big, const Processor_mask *small)
Checks if the processor set small is a subset of processor set big.
Definition: processormask.h:192
_Processor_mask_Xor
RTEMS_INLINE_ROUTINE void _Processor_mask_Xor(Processor_mask *a, const Processor_mask *b, const Processor_mask *c)
Performs a bitwise a = b ^ c.
Definition: processormask.h:255
_Processor_mask_To_cpu_set_t
RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_To_cpu_set_t(const Processor_mask *src, size_t dst_size, cpu_set_t *dst)
Copies one mask to another.
Definition: processormask.h:401
_Processor_mask_From_uint32_t
RTEMS_INLINE_ROUTINE void _Processor_mask_From_uint32_t(Processor_mask *mask, uint32_t bits, uint32_t index)
Creates a processor set from an unsigned 32-bit integer relative to the specified index.
Definition: processormask.h:315
_Processor_mask_Clear
RTEMS_INLINE_ROUTINE void _Processor_mask_Clear(Processor_mask *mask, uint32_t index)
Clears the specified index bit of the mask.
Definition: processormask.h:122
_Processor_mask_Is_equal
RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_equal(const Processor_mask *a, const Processor_mask *b)
Checks if the processor sets a and b are equal.
Definition: processormask.h:156
_Processor_mask_Zero
RTEMS_INLINE_ROUTINE void _Processor_mask_Zero(Processor_mask *mask)
Sets the bits of the mask to zero, also considers CPU_MAXIMUM_PROCESSORS.
Definition: processormask.h:61
_Processor_mask_Is_at_most_partial_loss
RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_at_most_partial_loss(Processor_mask_Copy_status status)
Checks if the copy status guarantees at most partial loss.
Definition: processormask.h:354
_Processor_mask_Has_overlap
RTEMS_INLINE_ROUTINE bool _Processor_mask_Has_overlap(const Processor_mask *a, const Processor_mask *b)
Checks if the intersection of the processor sets a and b is non-empty.
Definition: processormask.h:174
_Processor_mask_To_uint32_t
RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_To_uint32_t(const Processor_mask *mask, uint32_t index)
Returns the subset of 32 processors containing the specified index as an unsigned 32-bit integer.
Definition: processormask.h:297
_Processor_mask_Set
RTEMS_INLINE_ROUTINE void _Processor_mask_Set(Processor_mask *mask, uint32_t index)
Sets the specified index bit of the mask.
Definition: processormask.h:108
_Processor_mask_Is_set
RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set(const Processor_mask *mask, uint32_t index)
Checks if the specified index bit of the mask is set.
Definition: processormask.h:139
_Processor_mask_Is_zero
RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_zero(const Processor_mask *mask)
Checks if the mask is zero, also considers CPU_MAXIMUM_PROCESSORS.
Definition: processormask.h:74
_Processor_mask_Nand
RTEMS_INLINE_ROUTINE void _Processor_mask_Nand(Processor_mask *a, const Processor_mask *b, const Processor_mask *c)
Performs a bitwise a = b & ~c.
Definition: processormask.h:223
_Processor_mask_Count
RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Count(const Processor_mask *a)
Gets the number of set bits in the processor mask.
Definition: processormask.h:271
_Processor_mask_Fill
RTEMS_INLINE_ROUTINE void _Processor_mask_Fill(Processor_mask *mask)
Fills the mask, also considers CPU_MAXIMUM_PROCESSORS.
Definition: processormask.h:84
_Processor_mask_Find_last_set
RTEMS_INLINE_ROUTINE uint32_t _Processor_mask_Find_last_set(const Processor_mask *a)
Finds the last set of the processor mask.
Definition: processormask.h:283
_Processor_mask_Copy
Processor_mask_Copy_status _Processor_mask_Copy(long *dst, size_t dst_size, const long *src, size_t src_size)
Copies one mask to another.
Definition: processormaskcopy.c:31
_Processor_mask_From_cpu_set_t
RTEMS_INLINE_ROUTINE Processor_mask_Copy_status _Processor_mask_From_cpu_set_t(Processor_mask *dst, size_t src_size, const cpu_set_t *src)
Copies one mask to another.
Definition: processormask.h:431