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

4.104.114.84.9
Last change on this file since fa9ef954 was fa9ef954, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2003 at 6:53:21 PM

2003-09-04 Joel Sherrill <joel@…>

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