1 | |
---|
2 | -- RTEMS / Body |
---|
3 | -- |
---|
4 | -- DESCRIPTION: |
---|
5 | -- |
---|
6 | -- This package provides the interface to the RTEMS API. |
---|
7 | -- |
---|
8 | -- |
---|
9 | -- DEPENDENCIES: |
---|
10 | -- |
---|
11 | -- |
---|
12 | -- |
---|
13 | -- COPYRIGHT (c) 1997-2011. |
---|
14 | -- On-Line Applications Research Corporation (OAR). |
---|
15 | -- |
---|
16 | -- The license and distribution terms for this file may in |
---|
17 | -- the file LICENSE in this distribution or at |
---|
18 | -- http://www.rtems.com/license/LICENSE. |
---|
19 | -- |
---|
20 | -- $Id$ |
---|
21 | -- |
---|
22 | |
---|
23 | with Ada; |
---|
24 | with Ada.Unchecked_Conversion; |
---|
25 | with Interfaces; use Interfaces; |
---|
26 | with Interfaces.C; use Interfaces.C; |
---|
27 | |
---|
28 | package body RTEMS is |
---|
29 | |
---|
30 | -- |
---|
31 | -- Utility Functions |
---|
32 | -- |
---|
33 | |
---|
34 | function From_Ada_Boolean |
---|
35 | (Ada_Boolean : Standard.Boolean) |
---|
36 | return RTEMS.Boolean |
---|
37 | is |
---|
38 | begin |
---|
39 | |
---|
40 | if Ada_Boolean then |
---|
41 | return RTEMS.True; |
---|
42 | end if; |
---|
43 | |
---|
44 | return RTEMS.False; |
---|
45 | |
---|
46 | end From_Ada_Boolean; |
---|
47 | |
---|
48 | function To_Ada_Boolean |
---|
49 | (RTEMS_Boolean : RTEMS.Boolean) |
---|
50 | return Standard.Boolean |
---|
51 | is |
---|
52 | begin |
---|
53 | |
---|
54 | if RTEMS_Boolean = RTEMS.True then |
---|
55 | return Standard.True; |
---|
56 | end if; |
---|
57 | |
---|
58 | return Standard.False; |
---|
59 | |
---|
60 | end To_Ada_Boolean; |
---|
61 | |
---|
62 | function Milliseconds_To_Microseconds |
---|
63 | (Milliseconds : RTEMS.Unsigned32) |
---|
64 | return RTEMS.Unsigned32 |
---|
65 | is |
---|
66 | begin |
---|
67 | |
---|
68 | return Milliseconds * 1000; |
---|
69 | |
---|
70 | end Milliseconds_To_Microseconds; |
---|
71 | |
---|
72 | function Microseconds_To_Ticks |
---|
73 | (Microseconds : RTEMS.Unsigned32) |
---|
74 | return RTEMS.Interval |
---|
75 | is |
---|
76 | function Microseconds_Per_Tick return RTEMS.Unsigned32; |
---|
77 | pragma Import (C, Microseconds_Per_Tick, "_ada_microseconds_per_tick"); |
---|
78 | begin |
---|
79 | |
---|
80 | return Microseconds / Microseconds_Per_Tick; |
---|
81 | |
---|
82 | end Microseconds_To_Ticks; |
---|
83 | |
---|
84 | function Milliseconds_To_Ticks |
---|
85 | (Milliseconds : RTEMS.Unsigned32) |
---|
86 | return RTEMS.Interval |
---|
87 | is |
---|
88 | begin |
---|
89 | |
---|
90 | return Microseconds_To_Ticks |
---|
91 | (Milliseconds_To_Microseconds (Milliseconds)); |
---|
92 | |
---|
93 | end Milliseconds_To_Ticks; |
---|
94 | |
---|
95 | procedure Name_To_Characters |
---|
96 | (Name : in RTEMS.Name; |
---|
97 | C1 : out Character; |
---|
98 | C2 : out Character; |
---|
99 | C3 : out Character; |
---|
100 | C4 : out Character) |
---|
101 | is |
---|
102 | C1_Value : RTEMS.Unsigned32; |
---|
103 | C2_Value : RTEMS.Unsigned32; |
---|
104 | C3_Value : RTEMS.Unsigned32; |
---|
105 | C4_Value : RTEMS.Unsigned32; |
---|
106 | begin |
---|
107 | |
---|
108 | C1_Value := Interfaces.Shift_Right (Name, 24); |
---|
109 | C2_Value := Interfaces.Shift_Right (Name, 16); |
---|
110 | C3_Value := Interfaces.Shift_Right (Name, 8); |
---|
111 | C4_Value := Name; |
---|
112 | |
---|
113 | C1_Value := C1_Value and 16#00FF#; |
---|
114 | C2_Value := C2_Value and 16#00FF#; |
---|
115 | C3_Value := C3_Value and 16#00FF#; |
---|
116 | C4_Value := C4_Value and 16#00FF#; |
---|
117 | |
---|
118 | C1 := Character'Val (C1_Value); |
---|
119 | C2 := Character'Val (C2_Value); |
---|
120 | C3 := Character'Val (C3_Value); |
---|
121 | C4 := Character'Val (C4_Value); |
---|
122 | |
---|
123 | end Name_To_Characters; |
---|
124 | |
---|
125 | function Get_Node (ID : in RTEMS.ID) return RTEMS.Unsigned32 is |
---|
126 | begin |
---|
127 | |
---|
128 | -- May not be right |
---|
129 | return Interfaces.Shift_Right (ID, 16); |
---|
130 | |
---|
131 | end Get_Node; |
---|
132 | |
---|
133 | function Get_Index (ID : in RTEMS.ID) return RTEMS.Unsigned32 is |
---|
134 | begin |
---|
135 | |
---|
136 | -- May not be right |
---|
137 | return ID and 16#FFFF#; |
---|
138 | |
---|
139 | end Get_Index; |
---|
140 | |
---|
141 | function Are_Statuses_Equal |
---|
142 | (Status : in RTEMS.Status_Codes; |
---|
143 | Desired : in RTEMS.Status_Codes) |
---|
144 | return Standard.Boolean |
---|
145 | is |
---|
146 | begin |
---|
147 | |
---|
148 | if Status = Desired then |
---|
149 | return Standard.True; |
---|
150 | end if; |
---|
151 | |
---|
152 | return Standard.False; |
---|
153 | |
---|
154 | end Are_Statuses_Equal; |
---|
155 | |
---|
156 | function Is_Status_Successful |
---|
157 | (Status : in RTEMS.Status_Codes) |
---|
158 | return Standard.Boolean |
---|
159 | is |
---|
160 | begin |
---|
161 | |
---|
162 | if Status = RTEMS.Successful then |
---|
163 | return Standard.True; |
---|
164 | end if; |
---|
165 | |
---|
166 | return Standard.False; |
---|
167 | |
---|
168 | end Is_Status_Successful; |
---|
169 | |
---|
170 | function Subtract |
---|
171 | (Left : in RTEMS.Address; |
---|
172 | Right : in RTEMS.Address) |
---|
173 | return RTEMS.Unsigned32 |
---|
174 | is |
---|
175 | function To_Unsigned32 is new Ada.Unchecked_Conversion ( |
---|
176 | System.Address, |
---|
177 | RTEMS.Unsigned32); |
---|
178 | |
---|
179 | begin |
---|
180 | return To_Unsigned32 (Left) - To_Unsigned32 (Right); |
---|
181 | end Subtract; |
---|
182 | |
---|
183 | function Are_Equal |
---|
184 | (Left : in RTEMS.Address; |
---|
185 | Right : in RTEMS.Address) |
---|
186 | return Standard.Boolean |
---|
187 | is |
---|
188 | function To_Unsigned32 is new Ada.Unchecked_Conversion ( |
---|
189 | System.Address, |
---|
190 | RTEMS.Unsigned32); |
---|
191 | |
---|
192 | begin |
---|
193 | return (To_Unsigned32 (Left) = To_Unsigned32 (Right)); |
---|
194 | end Are_Equal; |
---|
195 | |
---|
196 | -- |
---|
197 | -- |
---|
198 | -- RTEMS API |
---|
199 | -- |
---|
200 | |
---|
201 | function Build_Name ( |
---|
202 | C1 : in Character; |
---|
203 | C2 : in Character; |
---|
204 | C3 : in Character; |
---|
205 | C4 : in Character |
---|
206 | ) return RTEMS.Name is |
---|
207 | C1_Value : RTEMS.Unsigned32; |
---|
208 | C2_Value : RTEMS.Unsigned32; |
---|
209 | C3_Value : RTEMS.Unsigned32; |
---|
210 | C4_Value : RTEMS.Unsigned32; |
---|
211 | begin |
---|
212 | |
---|
213 | C1_Value := Character'Pos( C1 ); |
---|
214 | C2_Value := Character'Pos( C2 ); |
---|
215 | C3_Value := Character'Pos( C3 ); |
---|
216 | C4_Value := Character'Pos( C4 ); |
---|
217 | |
---|
218 | return Interfaces.Shift_Left( C1_Value, 24 ) or |
---|
219 | Interfaces.Shift_Left( C2_Value, 16 ) or |
---|
220 | Interfaces.Shift_Left( C3_Value, 8 ) or |
---|
221 | C4_Value; |
---|
222 | |
---|
223 | end Build_Name; |
---|
224 | |
---|
225 | -- |
---|
226 | -- Initialization Manager -- Shutdown Only |
---|
227 | -- |
---|
228 | procedure Shutdown_Executive (Status : in RTEMS.Unsigned32) is |
---|
229 | procedure Shutdown_Executive_Base (Status : RTEMS.Unsigned32); |
---|
230 | pragma Import (C, Shutdown_Executive_Base, "rtems_shutdown_executive"); |
---|
231 | begin |
---|
232 | Shutdown_Executive_Base (Status); |
---|
233 | end Shutdown_Executive; |
---|
234 | |
---|
235 | end RTEMS; |
---|