1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * @ingroup RTEMSImplClassicTask |
---|
7 | * |
---|
8 | * @brief This header file provides the implementation interfaces of |
---|
9 | * the @ref RTEMSImplClassicTask. |
---|
10 | */ |
---|
11 | |
---|
12 | /* COPYRIGHT (c) 1989-2014. |
---|
13 | * On-Line Applications Research Corporation (OAR). |
---|
14 | * |
---|
15 | * Redistribution and use in source and binary forms, with or without |
---|
16 | * modification, are permitted provided that the following conditions |
---|
17 | * are met: |
---|
18 | * 1. Redistributions of source code must retain the above copyright |
---|
19 | * notice, this list of conditions and the following disclaimer. |
---|
20 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
21 | * notice, this list of conditions and the following disclaimer in the |
---|
22 | * documentation and/or other materials provided with the distribution. |
---|
23 | * |
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
34 | * POSSIBILITY OF SUCH DAMAGE. |
---|
35 | */ |
---|
36 | |
---|
37 | #ifndef _RTEMS_RTEMS_TASKSIMPL_H |
---|
38 | #define _RTEMS_RTEMS_TASKSIMPL_H |
---|
39 | |
---|
40 | #include <rtems/rtems/tasksdata.h> |
---|
41 | #include <rtems/score/objectimpl.h> |
---|
42 | #include <rtems/score/schedulerimpl.h> |
---|
43 | #include <rtems/score/threadimpl.h> |
---|
44 | |
---|
45 | #ifdef __cplusplus |
---|
46 | extern "C" { |
---|
47 | #endif |
---|
48 | |
---|
49 | /** |
---|
50 | * @defgroup RTEMSImplClassicTask Task Manager |
---|
51 | * |
---|
52 | * @ingroup RTEMSImplClassic |
---|
53 | * |
---|
54 | * @brief This group contains the Task Manager implementation. |
---|
55 | * |
---|
56 | * @{ |
---|
57 | */ |
---|
58 | |
---|
59 | /** |
---|
60 | * @brief RTEMS User Task Initialization |
---|
61 | * |
---|
62 | * This routine creates and starts all configured user |
---|
63 | * initialization threads. |
---|
64 | */ |
---|
65 | void _RTEMS_tasks_Initialize_user_tasks( void ); |
---|
66 | |
---|
67 | typedef rtems_status_code ( *RTEMS_tasks_Prepare_stack )( |
---|
68 | Thread_Configuration *, |
---|
69 | const rtems_task_config * |
---|
70 | ); |
---|
71 | |
---|
72 | rtems_status_code _RTEMS_tasks_Create( |
---|
73 | const rtems_task_config *config, |
---|
74 | rtems_id *id, |
---|
75 | RTEMS_tasks_Prepare_stack prepare_stack |
---|
76 | ); |
---|
77 | |
---|
78 | static inline Thread_Control *_RTEMS_tasks_Allocate(void) |
---|
79 | { |
---|
80 | _Objects_Allocator_lock(); |
---|
81 | |
---|
82 | _Thread_Kill_zombies(); |
---|
83 | |
---|
84 | return (Thread_Control *) |
---|
85 | _Objects_Allocate_unprotected( &_RTEMS_tasks_Information.Objects ); |
---|
86 | } |
---|
87 | |
---|
88 | /** |
---|
89 | * @brief Converts the RTEMS API priority to the corresponding SuperCore |
---|
90 | * priority and validates it. |
---|
91 | * |
---|
92 | * The RTEMS API system priority is accepted as valid. |
---|
93 | * |
---|
94 | * @param[in] scheduler The scheduler instance. |
---|
95 | * @param[in] priority The RTEMS API priority to convert and validate. |
---|
96 | * @param[out] valid Indicates if the RTEMS API priority is valid and a |
---|
97 | * corresponding SuperCore priority in the specified scheduler instance |
---|
98 | * exists. |
---|
99 | * |
---|
100 | * @return The corresponding SuperCore priority. |
---|
101 | */ |
---|
102 | static inline Priority_Control _RTEMS_Priority_To_core( |
---|
103 | const Scheduler_Control *scheduler, |
---|
104 | rtems_task_priority priority, |
---|
105 | bool *valid |
---|
106 | ) |
---|
107 | { |
---|
108 | *valid = ( priority <= scheduler->maximum_priority ); |
---|
109 | |
---|
110 | return _Scheduler_Map_priority( scheduler, (Priority_Control) priority ); |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * @brief Converts the SuperCore priority to the corresponding RTEMS API |
---|
115 | * priority. |
---|
116 | * |
---|
117 | * @param[in] scheduler The scheduler instance. |
---|
118 | * @param[in] priority The SuperCore priority to convert. |
---|
119 | * |
---|
120 | * @return The corresponding RTEMS API priority. |
---|
121 | */ |
---|
122 | static inline rtems_task_priority _RTEMS_Priority_From_core( |
---|
123 | const Scheduler_Control *scheduler, |
---|
124 | Priority_Control priority |
---|
125 | ) |
---|
126 | { |
---|
127 | return (rtems_task_priority) |
---|
128 | _Scheduler_Unmap_priority( scheduler, priority ); |
---|
129 | } |
---|
130 | |
---|
131 | /**@}*/ |
---|
132 | |
---|
133 | /** |
---|
134 | * @defgroup RTEMSImplClassicScheduler Scheduler Manager |
---|
135 | * |
---|
136 | * @ingroup RTEMSImplClassic |
---|
137 | * |
---|
138 | * @brief This group contains the Scheduler Manager implementation. |
---|
139 | */ |
---|
140 | |
---|
141 | #if defined(RTEMS_MULTIPROCESSING) |
---|
142 | #include <rtems/rtems/taskmp.h> |
---|
143 | #endif |
---|
144 | |
---|
145 | #ifdef __cplusplus |
---|
146 | } |
---|
147 | #endif |
---|
148 | |
---|
149 | #endif |
---|
150 | /* end of include file */ |
---|