source: rtems/cpukit/score/include/rtems/score/processormask.h @ 46f05b9

5
Last change on this file since 46f05b9 was 46f05b9, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 5, 2017 at 9:28:46 AM

SMP: Simplify SMP multicast actions

  • Property mode set to 100644
File size: 2.7 KB
Line 
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
29extern "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 */
63typedef uint32_t Processor_mask[ PROCESSOR_MASK_FIELD_COUNT ];
64
65RTEMS_INLINE_ROUTINE void _Processor_mask_Zero( Processor_mask mask )
66{
67  size_t i;
68
69  for ( i = 0; i < PROCESSOR_MASK_FIELD_COUNT; ++i ) {
70    mask[ i ] = 0;
71  }
72}
73
74RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_zero( const Processor_mask mask )
75{
76  size_t i;
77
78  for ( i = 0; i < PROCESSOR_MASK_FIELD_COUNT; ++i ) {
79    if ( mask[ i ] != 0 ) {
80      return false;
81    }
82  }
83
84  return true;
85}
86
87RTEMS_INLINE_ROUTINE void _Processor_mask_Assign( Processor_mask dst, const Processor_mask src )
88{
89  size_t i;
90
91  for ( i = 0; i < PROCESSOR_MASK_FIELD_COUNT; ++i ) {
92    dst[ i ] = src[ i ];
93  }
94}
95
96RTEMS_INLINE_ROUTINE void _Processor_mask_Set( Processor_mask mask, uint32_t index )
97{
98  mask[ PROCESSOR_MASK_FIELD( index ) ] |= PROCESSOR_MASK_BIT( index );
99}
100
101RTEMS_INLINE_ROUTINE void _Processor_mask_Clear( Processor_mask mask, uint32_t index )
102{
103  mask[ PROCESSOR_MASK_FIELD( index ) ] &= ~PROCESSOR_MASK_BIT( index );
104}
105
106RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set(
107  const Processor_mask mask,
108  uint32_t index
109)
110{
111  return ( mask[ PROCESSOR_MASK_FIELD( index ) ]
112    & PROCESSOR_MASK_BIT( index ) ) != 0;
113}
114
115/** @} */
116
117#ifdef __cplusplus
118}
119#endif /* __cplusplus */
120
121#endif /* _RTEMS_SCORE_PROCESSORMASK_H */
Note: See TracBrowser for help on using the repository browser.