summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/rtems/modes.h
blob: ccaef240d773c5d2ad9791c9ae8ad10fad5b3e79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
 * @file
 *
 * @ingroup ClassicModes
 *
 * This include file contains all constants and structures associated
 * with the RTEMS thread and RTEMS_ASR modes.
 */

/* COPYRIGHT (c) 1989-2013.
 * On-Line Applications Research Corporation (OAR).
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.org/license/LICENSE.
 */

#ifndef _RTEMS_RTEMS_MODES_H
#define _RTEMS_RTEMS_MODES_H

#include <rtems/score/cpu.h>

#ifdef __cplusplus
extern "C" {
#endif

/**
 *  @defgroup ClassicModes Modes
 *
 *  @ingroup RTEMSAPIClassic
 *
 *  This encapsulates functionality related to the task modes supported
 *  by the Classic API Task Manager.
 */
/**@{*/

/**
 *  The following type defines the control block used to manage
 *  each a mode set.
 */
typedef uint32_t   rtems_mode;

/**
 *  The following constants define the individual modes and masks
 *  which may be used to compose a mode set and to alter modes.
 */
#define RTEMS_ALL_MODE_MASKS     0x0000ffff

/**
 *  This mode constant is the default mode set.
 */
#define RTEMS_DEFAULT_MODES     0x00000000

/**
 *  This mode constant is used when the user wishes to obtain their
 *  current execution mode.
 */
#define RTEMS_CURRENT_MODE      0

/** This mode constant corresponds to the timeslice enable/disable bit. */
#define RTEMS_TIMESLICE_MASK  0x00000200

/** This mode constant corresponds to the preemption enable/disable bit. */
#define RTEMS_PREEMPT_MASK    0x00000100

/** This mode constant corresponds to the signal enable/disable bit. */
#define RTEMS_ASR_MASK        0x00000400

/** This mode constant corresponds to the interrupt enable/disable bits. */
#define RTEMS_INTERRUPT_MASK  CPU_MODES_INTERRUPT_MASK

/** This mode constant is used to indicate preemption is enabled. */
#define RTEMS_PREEMPT      0x00000000
/** This mode constant is used to indicate preemption is disabled. */
#define RTEMS_NO_PREEMPT   0x00000100

/** This mode constant is used to indicate timeslicing is disabled. */
#define RTEMS_NO_TIMESLICE 0x00000000
/** This mode constant is used to indicate timeslicing is enabled. */
#define RTEMS_TIMESLICE    0x00000200

/** This mode constant is used to indicate signal processing is enabled. */
#define RTEMS_ASR          0x00000000
/** This mode constant is used to indicate signal processing is disabled. */
#define RTEMS_NO_ASR       0x00000400

/**
 * @brief RTEMS_INTERRUPT_LEVEL
 *
 * This function returns the processor dependent interrupt
 * level which corresponds to the requested interrupt level.
 *
 * @note RTEMS supports 256 interrupt levels using the least
 *       significant eight bits of MODES.CONTROL. On any
 *       particular CPU, fewer than 256 levels may be supported.
 */
#define RTEMS_INTERRUPT_LEVEL( _mode_set ) \
  ( (_mode_set) & RTEMS_INTERRUPT_MASK )

/**
 *  @brief Interrupt Mask Variable
 *
 *  This variable is used by bindings from languages other than C and C++.
 */
extern const uint32_t rtems_interrupt_mask;

/**
 * @brief Body for RTEMS_INTERRUPT_LEVEL Macro
 *
 * @param[in] level is the desired interrupt level
 *
 * @retval This methods returns a mode with the desired interrupt
 *         @a level in the proper bitfield location.
 *
 * @note This variable is used by bindings from languages other than
 *       C and C++.
 */
rtems_mode rtems_interrupt_level_body(
  uint32_t   level
);

/**@}*/

#ifdef __cplusplus
}
#endif

#endif
/* end of include file */