source: rtems/c/src/ada/rtems.ads @ 15c1978c

4.115
Last change on this file since 15c1978c was 5d443559, checked in by Joel Sherrill <joel.sherrill@…>, on 02/02/12 at 22:57:42

PR 1991/cpukit - attr.c (really mode code) warning rework

This PR was about a warning for no previous prototype for
rtems_interrupt_level_attribute. This method exists (like
a few others) to have real bodies for Classic API services
implemented as macros. These macros are not available from
anything but C and C++. The most explicit use was in the Ada
binding but these would be needed from assembly language
or any other non-C based language.

On top of needing a prototype, the methods were misnamed.
They were related to modes. This renames them, moves the
file, fixes test code, etc.

  • Property mode set to 100644
File size: 19.2 KB
Line 
1
2--  RTEMS / Specification
3--
4--  DESCRIPTION:
5--
6--  This package provides the interface to the RTEMS API.
7--
8--  DEPENDENCIES:
9--
10--  NOTES:
11--    RTEMS initialization and configuration are called from
12--    the BSP side, therefore should never be called from ADA.
13--
14--  COPYRIGHT (c) 1997-2011.
15--  On-Line Applications Research Corporation (OAR).
16--
17--  The license and distribution terms for this file may in
18--  the file LICENSE in this distribution or at
19--  http://www.rtems.com/license/LICENSE.
20--
21--  $Id$
22--
23
24with System;
25with System.Storage_Elements; use System.Storage_Elements;
26with Interfaces;
27with Interfaces.C;
28
29package RTEMS is
30pragma Elaborate_Body (RTEMS);
31
32   Structure_Alignment : constant := 8;
33
34   --
35   --  RTEMS Base Types
36   --
37
38   subtype Unsigned8  is Interfaces.Unsigned_8;
39   subtype Unsigned16 is Interfaces.Unsigned_16;
40   subtype Unsigned32 is Interfaces.Unsigned_32;
41   subtype Signed32   is Interfaces.Integer_32;
42
43   type Unsigned32_Pointer     is access all RTEMS.Unsigned32;
44   type Unsigned16_Pointer     is access all RTEMS.Unsigned16;
45   type Unsigned8_Pointer      is access all RTEMS.Unsigned8;
46   type Signed32_Pointer       is access all RTEMS.Signed32;
47
48   subtype Boolean             is RTEMS.Unsigned8;
49   subtype Address             is System.Address;
50   subtype Single              is Interfaces.C.C_float;
51   subtype Double              is Interfaces.C.Double;
52
53   --
54   --  The following define the size of each of the base types in
55   --  both bits and system units.
56   --
57
58   Unsigned8_Bits   : constant := 7;
59   Unsigned16_Bits  : constant := 15;
60   Unsigned32_Bits  : constant := 31;
61   Boolean_Bits     : constant := 7;
62   Address_Bits     : constant := 31;
63   Single_Bits      : constant := 31;
64   Double_Bits      : constant := 63;
65
66   Unsigned8_Units  : constant := 1;
67   Unsigned16_Units : constant := 2;
68   Unsigned32_Units : constant := 4;
69   Boolean_Units    : constant := 1;
70   Address_Units    : constant := 4;
71   Single_Units     : constant := 4;
72   Double_Units     : constant := 8;
73
74   Null_Address     : constant RTEMS.Address :=
75      System.Storage_Elements.To_Address(0);
76
77   True  : constant RTEMS.Boolean := 1;
78   False : constant RTEMS.Boolean := 0;
79
80   --
81   --  More Types
82   --
83
84   subtype Name                is RTEMS.Unsigned32;
85   subtype ID                  is RTEMS.Unsigned32;
86   subtype Interval            is RTEMS.Unsigned32;
87   subtype Attribute           is RTEMS.Unsigned32;
88   subtype Mode                is RTEMS.Unsigned32;
89   subtype Option              is RTEMS.Unsigned32;
90   subtype Notepad_Index       is RTEMS.Unsigned32 range 0 .. 15;
91
92   subtype Event_Set           is RTEMS.Unsigned32;
93   subtype Signal_Set          is RTEMS.Unsigned32;
94   subtype Device_Major_Number is RTEMS.Unsigned32;
95   subtype Device_Minor_Number is RTEMS.Unsigned32;
96   subtype ISR_Level           is RTEMS.Unsigned32;
97
98   subtype Node                is RTEMS.Unsigned32;
99
100   type Driver_Name_t is
101      record
102         Device_Name        : RTEMS.Address;
103         Device_Name_Length : RTEMS.Unsigned32;
104         Major              : RTEMS.Device_Major_Number;
105         Minor              : RTEMS.Device_Minor_Number;
106
107      end record;
108
109
110   --
111   --  Task Related Types
112   --
113
114   subtype TCB                 is RTEMS.Unsigned32;
115   type    TCB_Pointer         is access all RTEMS.TCB;
116
117   --
118   --  Time of Day Type
119   --
120
121   type Time_Of_Day is
122      record
123         Year    : RTEMS.Unsigned32; -- year, A.D.
124         Month   : RTEMS.Unsigned32; -- month, 1 .. 12
125         Day     : RTEMS.Unsigned32; -- day, 1 .. 31
126         Hour    : RTEMS.Unsigned32; -- hour, 0 .. 23
127         Minute  : RTEMS.Unsigned32; -- minute, 0 .. 59
128         Second  : RTEMS.Unsigned32; -- second, 0 .. 59
129         Ticks   : RTEMS.Unsigned32; -- elapsed ticks between seconds
130      end record;
131
132   type Time_T is new Interfaces.C.Long;
133
134   type Timespec is record
135      TV_Sec  : Time_T;
136      TV_Nsec : Interfaces.C.Long;
137   end record;
138   pragma Convention (C, Timespec);
139
140   type Time_Value is
141      record
142         Seconds      : RTEMS.Unsigned32;
143         Microseconds : RTEMS.Unsigned32;
144      end record;
145
146   --
147   --  Ident Options
148   --
149
150   Search_All_Nodes   : constant RTEMS.Node := 0;
151   Search_Other_Nodes : constant RTEMS.Node := 16#7FFFFFFE#;
152   Search_Local_Node  : constant RTEMS.Node := 16#7FFFFFFF#;
153   Who_Am_I           : constant RTEMS.Node := 0;
154
155   --
156   --  Options
157   --
158
159   Default_Options    : constant RTEMS.Option    := 16#0000#;
160
161   Wait      : constant RTEMS.Option := 16#0000#;
162   No_Wait   : constant RTEMS.Option := 16#0001#;
163
164   Event_All : constant RTEMS.Option := 16#0000#;
165   Event_Any : constant RTEMS.Option := 16#0002#;
166
167   --
168   --  Mode constants
169   --
170
171   Default_Modes      : constant RTEMS.Mode      := 16#0000#;
172
173   All_Mode_Masks     : constant RTEMS.Mode := 16#0000_ffff#;
174   Current_Mode       : constant RTEMS.Mode := 16#0000_0000#;
175   Preempt_Mask       : constant RTEMS.Mode := 16#0000_0100#;
176   Timeslice_Mask     : constant RTEMS.Mode := 16#0000_0200#;
177   ASR_Mask           : constant RTEMS.Mode := 16#0000_0400#;
178   Interrupt_Mask     : RTEMS.Mode;
179   Preempt            : constant RTEMS.Mode := 16#0000_0000#;
180   No_Preempt         : constant RTEMS.Mode := 16#0000_0100#;
181   No_Timeslice       : constant RTEMS.Mode := 16#0000_0000#;
182   Timeslice          : constant RTEMS.Mode := 16#0000_0200#;
183   ASR                : constant RTEMS.Mode := 16#0000_0000#;
184   No_ASR             : constant RTEMS.Mode := 16#0000_0400#;
185
186   pragma Import (C, Interrupt_Mask, "rtems_interrupt_mask");
187
188   --
189   --  Attribute constants
190   --
191
192   Default_Attributes      : constant RTEMS.Attribute := 16#00000000#;
193   No_Floating_Point       : constant RTEMS.Attribute := 16#00000000#;
194   Floating_Point          : constant RTEMS.Attribute := 16#00000001#;
195   Local                   : constant RTEMS.Attribute := 16#00000000#;
196   Global                  : constant RTEMS.Attribute := 16#00000002#;
197   FIFO                    : constant RTEMS.Attribute := 16#00000000#;
198   Priority                : constant RTEMS.Attribute := 16#00000004#;
199   Counting_Semaphore      : constant RTEMS.Attribute := 16#00000000#;
200   Binary_Semaphore        : constant RTEMS.Attribute := 16#00000010#;
201   Simple_Binary_Semaphore : constant RTEMS.Attribute := 16#00000020#;
202   No_Inherit_Priority     : constant RTEMS.Attribute := 16#00000000#;
203   Inherit_Priority        : constant RTEMS.Attribute := 16#00000040#;
204   No_Priority_Ceiling     : constant RTEMS.Attribute := 16#00000000#;
205   Priority_Ceiling        : constant RTEMS.Attribute := 16#00000080#;
206
207   function Interrupt_Level (
208      Level : in     RTEMS.Unsigned32
209   ) return RTEMS.Mode;
210   pragma Import (C, Interrupt_Level, "rtems_interrupt_level_body");
211
212   Minimum_Stack_Size : RTEMS.Unsigned32;
213   pragma Import (C, Minimum_Stack_Size, "rtems_minimum_stack_size");
214
215   --
216   --  Notepad index constants
217   --
218
219   Notepad_0  : constant RTEMS.Unsigned32 := 0;
220   Notepad_1  : constant RTEMS.Unsigned32 := 1;
221   Notepad_2  : constant RTEMS.Unsigned32 := 2;
222   Notepad_3  : constant RTEMS.Unsigned32 := 3;
223   Notepad_4  : constant RTEMS.Unsigned32 := 4;
224   Notepad_5  : constant RTEMS.Unsigned32 := 5;
225   Notepad_6  : constant RTEMS.Unsigned32 := 6;
226   Notepad_7  : constant RTEMS.Unsigned32 := 7;
227   Notepad_8  : constant RTEMS.Unsigned32 := 8;
228   Notepad_9  : constant RTEMS.Unsigned32 := 9;
229   Notepad_10 : constant RTEMS.Unsigned32 := 10;
230   Notepad_11 : constant RTEMS.Unsigned32 := 11;
231   Notepad_12 : constant RTEMS.Unsigned32 := 12;
232   Notepad_13 : constant RTEMS.Unsigned32 := 13;
233   Notepad_14 : constant RTEMS.Unsigned32 := 14;
234   Notepad_15 : constant RTEMS.Unsigned32 := 15;
235
236   --
237   --  Miscellaneous
238   --
239
240   No_Timeout                    : constant RTEMS.Interval := 0;
241   Self                          : constant RTEMS.ID       := 0;
242   Yield_Processor               : constant RTEMS.Interval := 0;
243   Rate_Monotonic_Period_Status  : constant RTEMS.Interval := 0;
244
245
246   --
247   --  Extension Callouts and Table
248   --
249
250   type Thread_Create_Extension is access function (
251      Current_Task : in     RTEMS.TCB_Pointer;
252      New_Task     : in     RTEMS.TCB_Pointer
253   ) return RTEMS.Boolean;
254   pragma Convention (C, Thread_Create_Extension);
255
256   type Thread_Start_Extension is access procedure (
257      Current_Task : in     RTEMS.TCB_Pointer;
258      Started_Task : in     RTEMS.TCB_Pointer
259   );
260   pragma Convention (C, Thread_Start_Extension);
261
262   type Thread_Restart_Extension is access procedure (
263      Current_Task   : in     RTEMS.TCB_Pointer;
264      Restarted_Task : in     RTEMS.TCB_Pointer
265   );
266   pragma Convention (C, Thread_Restart_Extension);
267
268   type Thread_Delete_Extension is access procedure (
269      Current_Task : in     RTEMS.TCB_Pointer;
270      Deleted_Task : in     RTEMS.TCB_Pointer
271   );
272   pragma Convention (C, Thread_Delete_Extension);
273
274   type Thread_Switch_Extension is access procedure (
275      Current_Task : in     RTEMS.TCB_Pointer;
276      Heir_Task    : in     RTEMS.TCB_Pointer
277   );
278   pragma Convention (C, Thread_Switch_Extension);
279
280   type Thread_Post_Switch_Extension is access procedure (
281      Current_Task : in     RTEMS.TCB_Pointer
282   );
283   pragma Convention (C, Thread_Post_Switch_Extension);
284
285   type Thread_Begin_Extension is access procedure (
286      Current_Task : in     RTEMS.TCB_Pointer
287   );
288   pragma Convention (C, Thread_Begin_Extension);
289
290   type Thread_Exitted_Extension is access procedure (
291      Current_Task : in     RTEMS.TCB_Pointer
292   );
293   pragma Convention (C, Thread_Exitted_Extension);
294
295   type Fatal_Error_Extension is access procedure (
296      Error : in     RTEMS.Unsigned32
297   );
298   pragma Convention (C, Fatal_Error_Extension);
299
300   type Extensions_Table is
301      record
302         Thread_Create      : RTEMS.Thread_Create_Extension;
303         Thread_Start       : RTEMS.Thread_Start_Extension;
304         Thread_Restart     : RTEMS.Thread_Restart_Extension;
305         Thread_Delete      : RTEMS.Thread_Delete_Extension;
306         Thread_Switch      : RTEMS.Thread_Switch_Extension;
307         Thread_Post_Switch : RTEMS.Thread_Post_Switch_Extension;
308         Thread_Begin       : RTEMS.Thread_Begin_Extension;
309         Thread_Exitted     : RTEMS.Thread_Exitted_Extension;
310         Fatal              : RTEMS.Fatal_Error_Extension;
311      end record;
312
313   type Extensions_Table_Pointer is access all Extensions_Table;
314
315   --
316   --  The following type define a pointer to a signal service routine.
317   --
318
319   type ASR_Handler is access procedure (
320      Signals : in     RTEMS.Signal_Set
321   );
322   pragma Convention (C, ASR_Handler);
323
324   --
325   --  Method Completions Status Codes
326   --
327
328   type Status_Codes is (
329      Successful,               -- successful completion
330      Task_Exitted,             -- returned from a task
331      MP_Not_Configured,        -- multiprocessing not configured
332      Invalid_Name,             -- invalid object name
333      Invalid_ID,               -- invalid object id
334      Too_Many,                 -- too many
335      Timeout,                  -- timed out waiting
336      Object_Was_Deleted,       -- object deleted while waiting
337      Invalid_Size,             -- specified size was invalid
338      Invalid_Address,          -- address specified is invalid
339      Invalid_Number,           -- number was invalid
340      Not_Defined,              -- item has not been initialized
341      Resource_In_Use,          -- resources still outstanding
342      Unsatisfied,              -- request not satisfied
343      Incorrect_State,          -- task is in wrong state
344      Already_Suspended,        -- task already in state
345      Illegal_On_Self,          -- illegal on calling task
346      Illegal_On_Remote_Object, -- illegal for remote object
347      Called_From_ISR,          -- called from wrong environment
348      Invalid_Priority,         -- invalid task priority
349      Invalid_Clock,            -- invalid date/time
350      Invalid_Node,             -- invalid node id
351      Not_Configured,           -- directive not configured
352      Not_Owner_Of_Resource,    -- not owner of resource
353      Not_Implemented,          -- directive not implemented
354      Internal_Error,           -- RTEMS inconsistency detected
355      No_Memory,                -- no memory left in heap
356      IO_Error,                 -- driver IO error
357      Proxy_Blocking            -- internal multiprocessing only
358   );
359
360   for Status_Codes'Size use 32;
361
362   for Status_Codes use (
363      Successful                  =>  0,
364      Task_Exitted                =>  1,
365      MP_Not_Configured           =>  2,
366      Invalid_Name                =>  3,
367      Invalid_ID                  =>  4,
368      Too_Many                    =>  5,
369      Timeout                     =>  6,
370      Object_Was_Deleted          =>  7,
371      Invalid_Size                =>  8,
372      Invalid_Address             =>  9,
373      Invalid_NumbeR              => 10,
374      Not_Defined                 => 11,
375      Resource_In_Use             => 12,
376      Unsatisfied                 => 13,
377      Incorrect_State             => 14,
378      Already_Suspended           => 15,
379      Illegal_On_Self             => 16,
380      Illegal_On_Remote_Object    => 17,
381      Called_From_ISR             => 18,
382      Invalid_Priority            => 19,
383      Invalid_Clock               => 20,
384      Invalid_Node                => 21,
385      Not_Configured              => 22,
386      Not_Owner_Of_Resource       => 23,
387      Not_ImplementeD             => 24,
388      Internal_Error              => 25,
389      No_Memory                   => 26,
390      IO_Error                    => 27,
391      Proxy_Blocking              => 28
392   );
393
394   --
395   --  RTEMS Events
396   --
397
398   Pending_Events : constant RTEMS.Event_Set := 16#0000_0000#;
399   All_Events     : constant RTEMS.Event_Set := 16#FFFF_FFFF#;
400   Event_0        : constant RTEMS.Event_Set := 16#0000_0001#;
401   Event_1        : constant RTEMS.Event_Set := 16#0000_0002#;
402   Event_2        : constant RTEMS.Event_Set := 16#0000_0004#;
403   Event_3        : constant RTEMS.Event_Set := 16#0000_0008#;
404   Event_4        : constant RTEMS.Event_Set := 16#0000_0010#;
405   Event_5        : constant RTEMS.Event_Set := 16#0000_0020#;
406   Event_6        : constant RTEMS.Event_Set := 16#0000_0040#;
407   Event_7        : constant RTEMS.Event_Set := 16#0000_0080#;
408   Event_8        : constant RTEMS.Event_Set := 16#0000_0100#;
409   Event_9        : constant RTEMS.Event_Set := 16#0000_0200#;
410   Event_10       : constant RTEMS.Event_Set := 16#0000_0400#;
411   Event_11       : constant RTEMS.Event_Set := 16#0000_0800#;
412   Event_12       : constant RTEMS.Event_Set := 16#0000_1000#;
413   Event_13       : constant RTEMS.Event_Set := 16#0000_2000#;
414   Event_14       : constant RTEMS.Event_Set := 16#0000_4000#;
415   Event_15       : constant RTEMS.Event_Set := 16#0000_8000#;
416   Event_16       : constant RTEMS.Event_Set := 16#0001_0000#;
417   Event_17       : constant RTEMS.Event_Set := 16#0002_0000#;
418   Event_18       : constant RTEMS.Event_Set := 16#0004_0000#;
419   Event_19       : constant RTEMS.Event_Set := 16#0008_0000#;
420   Event_20       : constant RTEMS.Event_Set := 16#0010_0000#;
421   Event_21       : constant RTEMS.Event_Set := 16#0020_0000#;
422   Event_22       : constant RTEMS.Event_Set := 16#0040_0000#;
423   Event_23       : constant RTEMS.Event_Set := 16#0080_0000#;
424   Event_24       : constant RTEMS.Event_Set := 16#0100_0000#;
425   Event_25       : constant RTEMS.Event_Set := 16#0200_0000#;
426   Event_26       : constant RTEMS.Event_Set := 16#0400_0000#;
427   Event_27       : constant RTEMS.Event_Set := 16#0800_0000#;
428   Event_28       : constant RTEMS.Event_Set := 16#1000_0000#;
429   Event_29       : constant RTEMS.Event_Set := 16#2000_0000#;
430   Event_30       : constant RTEMS.Event_Set := 16#4000_0000#;
431   Event_31       : constant RTEMS.Event_Set := 16#8000_0000#;
432
433   --
434   --  RTEMS Signals
435   --
436
437   All_Signals : constant RTEMS.Signal_Set := 16#7FFFFFFF#;
438   Signal_0    : constant RTEMS.Signal_Set := 16#00000001#;
439   Signal_1    : constant RTEMS.Signal_Set := 16#00000002#;
440   Signal_2    : constant RTEMS.Signal_Set := 16#00000004#;
441   Signal_3    : constant RTEMS.Signal_Set := 16#00000008#;
442   Signal_4    : constant RTEMS.Signal_Set := 16#00000010#;
443   Signal_5    : constant RTEMS.Signal_Set := 16#00000020#;
444   Signal_6    : constant RTEMS.Signal_Set := 16#00000040#;
445   Signal_7    : constant RTEMS.Signal_Set := 16#00000080#;
446   Signal_8    : constant RTEMS.Signal_Set := 16#00000100#;
447   Signal_9    : constant RTEMS.Signal_Set := 16#00000200#;
448   Signal_10   : constant RTEMS.Signal_Set := 16#00000400#;
449   Signal_11   : constant RTEMS.Signal_Set := 16#00000800#;
450   Signal_12   : constant RTEMS.Signal_Set := 16#00001000#;
451   Signal_13   : constant RTEMS.Signal_Set := 16#00002000#;
452   Signal_14   : constant RTEMS.Signal_Set := 16#00004000#;
453   Signal_15   : constant RTEMS.Signal_Set := 16#00008000#;
454   Signal_16   : constant RTEMS.Signal_Set := 16#00010000#;
455   Signal_17   : constant RTEMS.Signal_Set := 16#00020000#;
456   Signal_18   : constant RTEMS.Signal_Set := 16#00040000#;
457   Signal_19   : constant RTEMS.Signal_Set := 16#00080000#;
458   Signal_20   : constant RTEMS.Signal_Set := 16#00100000#;
459   Signal_21   : constant RTEMS.Signal_Set := 16#00200000#;
460   Signal_22   : constant RTEMS.Signal_Set := 16#00400000#;
461   Signal_23   : constant RTEMS.Signal_Set := 16#00800000#;
462   Signal_24   : constant RTEMS.Signal_Set := 16#01000000#;
463   Signal_25   : constant RTEMS.Signal_Set := 16#02000000#;
464   Signal_26   : constant RTEMS.Signal_Set := 16#04000000#;
465   Signal_27   : constant RTEMS.Signal_Set := 16#08000000#;
466   Signal_28   : constant RTEMS.Signal_Set := 16#10000000#;
467   Signal_29   : constant RTEMS.Signal_Set := 16#20000000#;
468   Signal_30   : constant RTEMS.Signal_Set := 16#40000000#;
469   Signal_31   : constant RTEMS.Signal_Set := 16#80000000#;
470
471   --
472   --  Utility Functions
473   --
474
475   function From_Ada_Boolean (
476      Ada_Boolean : Standard.Boolean
477   ) return RTEMS.Boolean;
478
479   function To_Ada_Boolean (
480      RTEMS_Boolean : RTEMS.Boolean
481   ) return Standard.Boolean;
482
483   function Milliseconds_To_Microseconds (
484      Milliseconds : RTEMS.Unsigned32
485   ) return RTEMS.Unsigned32;
486
487   function Microseconds_To_Ticks (
488      Microseconds : RTEMS.Unsigned32
489   ) return RTEMS.Interval;
490
491   function Milliseconds_To_Ticks (
492      Milliseconds : RTEMS.Unsigned32
493   ) return RTEMS.Interval;
494
495   procedure Name_To_Characters (
496      Name : in     RTEMS.Name;
497      C1   :    out Character;
498      C2   :    out Character;
499      C3   :    out Character;
500      C4   :    out Character
501   );
502
503   function Get_Node (
504      ID : in     RTEMS.ID
505   ) return RTEMS.Unsigned32;
506
507   function Get_Index (
508      ID : in     RTEMS.ID
509   ) return RTEMS.Unsigned32;
510
511   function Are_Statuses_Equal (
512      Status  : in     RTEMS.Status_Codes;
513      Desired : in     RTEMS.Status_Codes
514   ) return Standard.Boolean;
515
516   function Is_Status_Successful (
517      Status  : in     RTEMS.Status_Codes
518   ) return Standard.Boolean;
519
520   function Subtract (
521      Left   : in     RTEMS.Address;
522      Right  : in     RTEMS.Address
523   ) return RTEMS.Unsigned32;
524
525   function Are_Equal (
526      Left   : in     RTEMS.Address;
527      Right  : in     RTEMS.Address
528   ) return Standard.Boolean;
529
530   --
531   --  RTEMS API
532   --
533
534   function Build_Name (
535      C1 : in     Character;
536      C2 : in     Character;
537      C3 : in     Character;
538      C4 : in     Character
539   ) return RTEMS.Name;
540
541   --
542   --  Initialization Manager -- Shutdown Only
543   --
544   procedure Shutdown_Executive (
545      Status : in     RTEMS.Unsigned32
546   );
547
548end RTEMS;
549
Note: See TracBrowser for help on using the repository browser.