source: rtems/cpukit/sapi/include/rtems/cbs.h @ b5ffa5e

4.115
Last change on this file since b5ffa5e was b5ffa5e, checked in by Sebastian Huber <sebastian.huber@…>, on 07/23/13 at 07:44:47

sapi: Merge CBS API into one file

  • Property mode set to 100644
File size: 5.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Constants and Structures Associated
5 * with the CBS library in RTEMS
6 *
7 * This include file contains all the constants and structures associated
8 * with the CBS library in RTEMS.
9 */
10
11/*
12 *  Copyright (C) 2011 Petr Benes.
13 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
14 *
15 *  The license and distribution terms for this file may be
16 *  found in the file LICENSE in this distribution or at
17 *  http://www.rtems.com/license/LICENSE.
18 */
19
20#ifndef CONFIGURE_SCHEDULER_CBS
21  #error "cbs.h available only with CONFIGURE_SCHEDULER_CBS"
22#endif
23
24#ifndef _RTEMS_CBS_H
25#define _RTEMS_CBS_H
26
27#include <rtems/score/schedulercbs.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/* Return codes. */
34#define RTEMS_CBS_OK                       SCHEDULER_CBS_OK
35#define RTEMS_CBS_ERROR_GENERIC            SCHEDULER_CBS_ERROR_GENERIC
36#define RTEMS_CBS_ERROR_NO_MEMORY          SCHEDULER_CBS_ERROR_NO_MEMORY
37#define RTEMS_CBS_ERROR_INVALID_PARAMETER  SCHEDULER_CBS_ERROR_INVALID_PARAM
38#define RTEMS_CBS_ERROR_UNAUTHORIZED       SCHEDULER_CBS_ERROR_UNAUTHORIZED
39#define RTEMS_CBS_ERROR_UNIMPLEMENTED      SCHEDULER_CBS_ERROR_UNIMPLEMENTED
40#define RTEMS_CBS_ERROR_MISSING_COMPONENT  SCHEDULER_CBS_ERROR_MISSING_COMPONENT
41#define RTEMS_CBS_ERROR_INCONSISTENT_STATE SCHEDULER_CBS_ERROR_INCONSISTENT_STATE
42#define RTEMS_CBS_ERROR_SYSTEM_OVERLOAD    SCHEDULER_CBS_ERROR_SYSTEM_OVERLOAD
43#define RTEMS_CBS_ERROR_INTERNAL_ERROR     SCHEDULER_CBS_ERROR_INTERNAL_ERROR
44#define RTEMS_CBS_ERROR_NOT_FOUND          SCHEDULER_CBS_ERROR_NOT_FOUND
45#define RTEMS_CBS_ERROR_FULL               SCHEDULER_CBS_ERROR_FULL
46#define RTEMS_CBS_ERROR_EMPTY              SCHEDULER_CBS_ERROR_EMPTY
47#define RTEMS_CBS_ERROR_NOSERVER           SCHEDULER_CBS_ERROR_NOSERVER
48
49/** Callback function invoked when a budget overrun of a task occurs. */
50typedef Scheduler_CBS_Budget_overrun rtems_cbs_budget_overrun;
51
52/** Server id. */
53typedef Scheduler_CBS_Server_id rtems_cbs_server_id;
54
55/** Server parameters. */
56typedef Scheduler_CBS_Parameters rtems_cbs_parameters;
57
58/**
59 * @brief Initialize the CBS library.
60 *
61 * Initializes the CBS library.
62 *
63 * @return status code.
64 */
65RTEMS_INLINE_ROUTINE int rtems_cbs_initialize ( void )
66{
67  return _Scheduler_CBS_Initialize();
68}
69
70/**
71 * @brief Cleanup resources associated to the CBS Library
72 *
73 * Cleanup resources associated to the CBS Library.
74 *
75 * @return status code.
76 */
77RTEMS_INLINE_ROUTINE int rtems_cbs_cleanup ( void )
78{
79  return _Scheduler_CBS_Cleanup();
80}
81
82/**
83 * @brief Create a new server with specified parameters.
84 *
85 * Create a new server with specified parameters.
86 *
87 * @return status code.
88 */
89RTEMS_INLINE_ROUTINE int rtems_cbs_create_server (
90  rtems_cbs_parameters     *params,
91  rtems_cbs_budget_overrun  budget_overrun_callback,
92  rtems_cbs_server_id      *server_id
93)
94{
95  return _Scheduler_CBS_Create_server(
96             params,
97             budget_overrun_callback,
98             server_id
99         );
100}
101
102/**
103 * @brief Attach a task to an already existing server.
104 *
105 * Attach a task to an already existing server.
106 *
107 * @return status code.
108 */
109RTEMS_INLINE_ROUTINE int rtems_cbs_attach_thread (
110  rtems_cbs_server_id server_id,
111  rtems_id            task_id
112)
113{
114  return _Scheduler_CBS_Attach_thread( server_id, task_id );
115}
116
117/**
118 * @brief Detach from the CBS server.
119 *
120 * Detach from the CBS Server.
121 *
122 * @return status code.
123 */
124RTEMS_INLINE_ROUTINE int rtems_cbs_detach_thread (
125  rtems_cbs_server_id server_id,
126  rtems_id            task_id
127)
128{
129  return _Scheduler_CBS_Detach_thread( server_id, task_id );
130}
131
132/**
133 * @brief Detach all tasks from a server and destroy it.
134 *
135 * Detach all tasks from a server and destroy it.
136 *
137 * @return status code.
138 */
139RTEMS_INLINE_ROUTINE int rtems_cbs_destroy_server (
140  rtems_cbs_server_id server_id
141)
142{
143  return _Scheduler_CBS_Destroy_server( server_id );
144}
145
146/**
147 * @brief Get CBS server id.
148 *
149 * Get a thread server id, or RTEMS_CBS_E_NOT_FOUND if it is not
150 * attached to any server.
151 *
152 * @return status code.
153 */
154RTEMS_INLINE_ROUTINE int rtems_cbs_get_server_id (
155  rtems_id             task_id,
156  rtems_cbs_server_id *server_id
157)
158{
159  return _Scheduler_CBS_Get_server_id( task_id, server_id );
160}
161
162/**
163 * @brief Get CBS parameters.
164 *
165 * Retrieve CBS scheduling parameters.
166 *
167 * @return status code.
168 */
169RTEMS_INLINE_ROUTINE int rtems_cbs_get_parameters (
170  rtems_cbs_server_id   server_id,
171  rtems_cbs_parameters *params
172)
173{
174  return _Scheduler_CBS_Get_parameters( server_id, params );
175}
176
177/**
178 * @brief Set CBS parameters.
179 *
180 * Change CBS scheduling parameters.
181 *
182 * @return status code.
183 */
184RTEMS_INLINE_ROUTINE int rtems_cbs_set_parameters (
185  rtems_cbs_server_id   server_id,
186  rtems_cbs_parameters *params
187)
188{
189  return _Scheduler_CBS_Set_parameters( server_id, params );
190}
191
192/**
193 * @brief Get the CBS get execution time.
194 *
195 * Retrieve time info relative to the current server.
196 *
197 * @return status code.
198 */
199RTEMS_INLINE_ROUTINE int rtems_cbs_get_execution_time (
200  rtems_cbs_server_id    server_id,
201  time_t                *exec_time,
202  time_t                *abs_time
203)
204{
205  return _Scheduler_CBS_Get_execution_time( server_id, exec_time, abs_time );
206}
207
208/**
209 * @brief Get the remaining CBS budget.
210 *
211 * Retrieve remaining budget for the current server instance.
212 *
213 * @return status code.
214 */
215RTEMS_INLINE_ROUTINE int rtems_cbs_get_remaining_budget (
216  rtems_cbs_server_id  server_id,
217  time_t              *remaining_budget
218)
219{
220  return _Scheduler_CBS_Get_remaining_budget( server_id, remaining_budget );
221}
222
223/**
224 * @brief Get the approved CBS budget.
225 *
226 * Retrieve the budget that has been approved for the subsequent
227 * server instances.
228 *
229 * @return status code.
230 */
231RTEMS_INLINE_ROUTINE int rtems_cbs_get_approved_budget (
232  rtems_cbs_server_id  server_id,
233  time_t              *appr_budget
234)
235{
236  return _Scheduler_CBS_Get_approved_budget( server_id, appr_budget );
237}
238
239#ifdef __cplusplus
240}
241#endif
242
243#endif
244/* end of include file */
Note: See TracBrowser for help on using the repository browser.