source: rtems/c/src/librtems++/include/rtems++/rtemsTaskMode.h @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 7.2 KB
Line 
1/*
2  ------------------------------------------------------------------------
3
4  COPYRIGHT (c) 1997
5  Objective Design Systems Ltd Pty (ODS)
6  All rights reserved (R) Objective Design Systems Ltd Pty
7
8  The license and distribution terms for this file may be found in the
9  file LICENSE in this distribution or at
10  http://www.rtems.org/license/LICENSE.
11
12  ------------------------------------------------------------------------
13
14  rtemsTaskMode class.
15
16  This class allows the user to query or change the mode of an RTEMS
17  task.
18
19  This object only operates on the currently executing task.
20
21  The standard flags defined in RTEMS are used.
22
23  Methods are provided to operate on a group of modes which are
24  required to be changed in a single operation. The mode and mask is
25  specified by ORing the required flags.
26
27  Methods are provided for accessing and controlling a specific
28  mode. The returned value will only contain the requested mode's flags,
29  and only the that mode will be changed when setting a mode.
30
31  ------------------------------------------------------------------------ */
32
33#if !defined(_rtemsTaskMode_h_)
34#define _rtemsTaskMode_h_
35
36#include <rtems++/rtemsStatusCode.h>
37
38/* ----
39    rtemsTaskMode
40*/
41
42class rtemsTaskMode
43  : public rtemsStatusCode
44{
45public:
46
47  rtemsTaskMode() {};
48
49  // group mode control, OR the values together
50  inline const rtems_status_code get_mode(rtems_mode& mode);
51  inline const rtems_status_code set_mode(const rtems_mode mode,
52                                          const rtems_mode mask);
53  inline const rtems_status_code set_mode(const rtems_mode mode,
54                                          const rtems_mode mask,
55                                          rtems_mode& old_mode);
56
57  // preemption control
58  inline const rtems_status_code get_preemption_state(rtems_mode& preemption);
59  inline const rtems_status_code set_preemption_state(const rtems_mode preemption);
60  inline const rtems_status_code set_preemption_state(const rtems_mode preemption,
61                                                      rtems_mode& old_preemption);
62  inline const bool preemption_set(const rtems_mode preemption);
63
64  // timeslice control
65  inline const rtems_status_code get_timeslice_state(rtems_mode& timeslice);
66  inline const rtems_status_code set_timeslice_state(const rtems_mode timeslice);
67  inline const rtems_status_code set_timeslice_state(const rtems_mode timeslice,
68                                                     rtems_mode& old_timeslice);
69  inline const bool timeslice_set(const rtems_mode preemption);
70
71  // async-sub-routine control
72  inline const rtems_status_code get_asr_state(rtems_mode& asr);
73  inline const rtems_status_code set_asr_state(const rtems_mode asr);
74  inline const rtems_status_code set_asr_state(const rtems_mode asr,
75                                               rtems_mode& old_asr);
76  inline const bool asr_set(const rtems_mode preemption);
77
78  // interrupt mask control
79  inline const rtems_status_code get_interrupt_level(rtems_interrupt_level& level);
80  inline const rtems_status_code set_interrupt_level(const rtems_interrupt_level level);
81  inline const rtems_status_code set_interrupt_level(const rtems_interrupt_level level,
82                                                     rtems_interrupt_level& old_level);
83};
84
85const rtems_status_code rtemsTaskMode::get_mode(rtems_mode& mode)
86{
87  return set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &mode));
88}
89
90const rtems_status_code rtemsTaskMode::set_mode(const rtems_mode mode,
91                                                const rtems_mode mask)
92{
93  rtems_mode old_mode;
94  return set_status_code(rtems_task_mode(mode, mask, &old_mode));
95}
96
97const rtems_status_code rtemsTaskMode::set_mode(const rtems_mode mode,
98                                                const rtems_mode mask,
99                                                rtems_mode& old_mode)
100{
101  return set_status_code(rtems_task_mode(mode, mask, &old_mode));
102}
103
104const rtems_status_code rtemsTaskMode::get_preemption_state(rtems_mode& preemption)
105{
106  set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &preemption));
107  preemption &= RTEMS_PREEMPT_MASK;
108  return last_status_code();
109}
110
111const rtems_status_code rtemsTaskMode::set_preemption_state(const rtems_mode preemption)
112{
113  rtems_mode old_mode;
114  return set_status_code(rtems_task_mode(preemption, RTEMS_PREEMPT_MASK, &old_mode));
115}
116
117const rtems_status_code rtemsTaskMode::set_preemption_state(const rtems_mode preemption,
118                                                       rtems_mode& old_preemption)
119{
120  set_status_code(rtems_task_mode(preemption, RTEMS_PREEMPT_MASK, &old_preemption));
121  old_preemption &= RTEMS_PREEMPT_MASK;
122  return last_status_code();
123}
124
125const bool rtemsTaskMode::preemption_set(const rtems_mode preemption)
126{
127  return (preemption & RTEMS_PREEMPT_MASK) ? false : true;
128}
129
130const rtems_status_code rtemsTaskMode::get_timeslice_state(rtems_mode& timeslice)
131{
132  set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &timeslice));
133  timeslice &= RTEMS_TIMESLICE_MASK;
134  return last_status_code();
135}
136
137const rtems_status_code rtemsTaskMode::set_timeslice_state(const rtems_mode timeslice)
138{
139  rtems_mode old_mode;
140  return set_status_code(rtems_task_mode(timeslice, RTEMS_TIMESLICE_MASK, &old_mode));
141}
142
143const rtems_status_code rtemsTaskMode::set_timeslice_state(const rtems_mode timeslice,
144                                                           rtems_mode& old_timeslice)
145{
146  set_status_code(rtems_task_mode(timeslice, RTEMS_TIMESLICE_MASK, &old_timeslice));
147  old_timeslice &= RTEMS_TIMESLICE_MASK;
148  return last_status_code();
149}
150
151const bool rtemsTaskMode::timeslice_set(const rtems_mode timeslice)
152{
153  return (timeslice & RTEMS_TIMESLICE_MASK) ? true : false;
154}
155
156const rtems_status_code rtemsTaskMode::get_asr_state(rtems_mode& asr)
157{
158  set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &asr));
159  asr &= RTEMS_ASR_MASK;
160  return last_status_code();
161}
162
163const rtems_status_code rtemsTaskMode::set_asr_state(const rtems_mode asr)
164{
165  rtems_mode old_mode;
166  return set_status_code(rtems_task_mode(asr, RTEMS_ASR_MASK, &old_mode));
167}
168
169const rtems_status_code rtemsTaskMode::set_asr_state(const rtems_mode asr,
170                                                     rtems_mode& old_asr)
171{
172  set_status_code(rtems_task_mode(asr, RTEMS_ASR_MASK, &old_asr));
173  old_asr &= RTEMS_ASR_MASK;
174  return last_status_code();
175}
176
177const bool rtemsTaskMode::asr_set(const rtems_mode asr)
178{
179  return (asr & RTEMS_ASR_MASK) ? true : false;
180}
181
182const rtems_status_code rtemsTaskMode::get_interrupt_level(rtems_interrupt_level& level)
183{
184  rtems_mode mode;
185  set_status_code(rtems_task_mode(0, RTEMS_CURRENT_MODE, &mode));
186  level = mode & RTEMS_INTERRUPT_MASK;
187  return last_status_code();
188}
189
190const rtems_status_code rtemsTaskMode::set_interrupt_level(const rtems_interrupt_level level)
191{
192  rtems_mode old_mode;
193  return set_status_code(rtems_task_mode(level, RTEMS_INTERRUPT_MASK, &old_mode));
194}
195
196const rtems_status_code rtemsTaskMode::set_interrupt_level(rtems_interrupt_level level,
197                                                           rtems_interrupt_level& old_level)
198{
199  set_status_code(rtems_task_mode(level, RTEMS_INTERRUPT_MASK, &old_level));
200  old_level = old_level & RTEMS_INTERRUPT_MASK;
201  return last_status_code();
202}
203
204#endif  // _rtemsTaskMode_h_
Note: See TracBrowser for help on using the repository browser.