forked from Imagelibrary/rtems
* ada/Makefile.am, ada/preinstall.am, ada/rtems.adb, ada/rtems.ads: Split RTEMS Ada95 binding into a master package and a child package per Manager. This is better Ada style. * ada/rtems-barrier.adb, ada/rtems-barrier.ads, ada/rtems-clock.adb, ada/rtems-clock.ads, ada/rtems-cpu_usage.ads, ada/rtems-debug.adb, ada/rtems-debug.ads, ada/rtems-event.adb, ada/rtems-event.ads, ada/rtems-extension.adb, ada/rtems-extension.ads, ada/rtems-fatal.adb, ada/rtems-fatal.ads, ada/rtems-interrupt.ads, ada/rtems-io.adb, ada/rtems-io.ads, ada/rtems-message_queue.adb, ada/rtems-message_queue.ads, ada/rtems-object.adb, ada/rtems-object.ads, ada/rtems-partition.adb, ada/rtems-partition.ads, ada/rtems-port.adb, ada/rtems-port.ads, ada/rtems-rate_monotonic.adb, ada/rtems-rate_monotonic.ads, ada/rtems-region.adb, ada/rtems-region.ads, ada/rtems-semaphore.adb, ada/rtems-semaphore.ads, ada/rtems-signal.adb, ada/rtems-signal.ads, ada/rtems-stack_checker.ads, ada/rtems-tasks.adb, ada/rtems-tasks.ads, ada/rtems-timer.adb, ada/rtems-timer.ads: New files.
236 lines
5.2 KiB
Ada
236 lines
5.2 KiB
Ada
|
|
-- RTEMS / Body
|
|
--
|
|
-- DESCRIPTION:
|
|
--
|
|
-- This package provides the interface to the RTEMS API.
|
|
--
|
|
--
|
|
-- DEPENDENCIES:
|
|
--
|
|
--
|
|
--
|
|
-- COPYRIGHT (c) 1997-2011.
|
|
-- On-Line Applications Research Corporation (OAR).
|
|
--
|
|
-- The license and distribution terms for this file may in
|
|
-- the file LICENSE in this distribution or at
|
|
-- http://www.rtems.com/license/LICENSE.
|
|
--
|
|
-- $Id$
|
|
--
|
|
|
|
with Ada;
|
|
with Ada.Unchecked_Conversion;
|
|
with Interfaces; use Interfaces;
|
|
with Interfaces.C; use Interfaces.C;
|
|
|
|
package body RTEMS is
|
|
|
|
--
|
|
-- Utility Functions
|
|
--
|
|
|
|
function From_Ada_Boolean
|
|
(Ada_Boolean : Standard.Boolean)
|
|
return RTEMS.Boolean
|
|
is
|
|
begin
|
|
|
|
if Ada_Boolean then
|
|
return RTEMS.True;
|
|
end if;
|
|
|
|
return RTEMS.False;
|
|
|
|
end From_Ada_Boolean;
|
|
|
|
function To_Ada_Boolean
|
|
(RTEMS_Boolean : RTEMS.Boolean)
|
|
return Standard.Boolean
|
|
is
|
|
begin
|
|
|
|
if RTEMS_Boolean = RTEMS.True then
|
|
return Standard.True;
|
|
end if;
|
|
|
|
return Standard.False;
|
|
|
|
end To_Ada_Boolean;
|
|
|
|
function Milliseconds_To_Microseconds
|
|
(Milliseconds : RTEMS.Unsigned32)
|
|
return RTEMS.Unsigned32
|
|
is
|
|
begin
|
|
|
|
return Milliseconds * 1000;
|
|
|
|
end Milliseconds_To_Microseconds;
|
|
|
|
function Microseconds_To_Ticks
|
|
(Microseconds : RTEMS.Unsigned32)
|
|
return RTEMS.Interval
|
|
is
|
|
function Microseconds_Per_Tick return RTEMS.Unsigned32;
|
|
pragma Import (C, Microseconds_Per_Tick, "_ada_microseconds_per_tick");
|
|
begin
|
|
|
|
return Microseconds / Microseconds_Per_Tick;
|
|
|
|
end Microseconds_To_Ticks;
|
|
|
|
function Milliseconds_To_Ticks
|
|
(Milliseconds : RTEMS.Unsigned32)
|
|
return RTEMS.Interval
|
|
is
|
|
begin
|
|
|
|
return Microseconds_To_Ticks
|
|
(Milliseconds_To_Microseconds (Milliseconds));
|
|
|
|
end Milliseconds_To_Ticks;
|
|
|
|
procedure Name_To_Characters
|
|
(Name : in RTEMS.Name;
|
|
C1 : out Character;
|
|
C2 : out Character;
|
|
C3 : out Character;
|
|
C4 : out Character)
|
|
is
|
|
C1_Value : RTEMS.Unsigned32;
|
|
C2_Value : RTEMS.Unsigned32;
|
|
C3_Value : RTEMS.Unsigned32;
|
|
C4_Value : RTEMS.Unsigned32;
|
|
begin
|
|
|
|
C1_Value := Interfaces.Shift_Right (Name, 24);
|
|
C2_Value := Interfaces.Shift_Right (Name, 16);
|
|
C3_Value := Interfaces.Shift_Right (Name, 8);
|
|
C4_Value := Name;
|
|
|
|
C1_Value := C1_Value and 16#00FF#;
|
|
C2_Value := C2_Value and 16#00FF#;
|
|
C3_Value := C3_Value and 16#00FF#;
|
|
C4_Value := C4_Value and 16#00FF#;
|
|
|
|
C1 := Character'Val (C1_Value);
|
|
C2 := Character'Val (C2_Value);
|
|
C3 := Character'Val (C3_Value);
|
|
C4 := Character'Val (C4_Value);
|
|
|
|
end Name_To_Characters;
|
|
|
|
function Get_Node (ID : in RTEMS.ID) return RTEMS.Unsigned32 is
|
|
begin
|
|
|
|
-- May not be right
|
|
return Interfaces.Shift_Right (ID, 16);
|
|
|
|
end Get_Node;
|
|
|
|
function Get_Index (ID : in RTEMS.ID) return RTEMS.Unsigned32 is
|
|
begin
|
|
|
|
-- May not be right
|
|
return ID and 16#FFFF#;
|
|
|
|
end Get_Index;
|
|
|
|
function Are_Statuses_Equal
|
|
(Status : in RTEMS.Status_Codes;
|
|
Desired : in RTEMS.Status_Codes)
|
|
return Standard.Boolean
|
|
is
|
|
begin
|
|
|
|
if Status = Desired then
|
|
return Standard.True;
|
|
end if;
|
|
|
|
return Standard.False;
|
|
|
|
end Are_Statuses_Equal;
|
|
|
|
function Is_Status_Successful
|
|
(Status : in RTEMS.Status_Codes)
|
|
return Standard.Boolean
|
|
is
|
|
begin
|
|
|
|
if Status = RTEMS.Successful then
|
|
return Standard.True;
|
|
end if;
|
|
|
|
return Standard.False;
|
|
|
|
end Is_Status_Successful;
|
|
|
|
function Subtract
|
|
(Left : in RTEMS.Address;
|
|
Right : in RTEMS.Address)
|
|
return RTEMS.Unsigned32
|
|
is
|
|
function To_Unsigned32 is new Ada.Unchecked_Conversion (
|
|
System.Address,
|
|
RTEMS.Unsigned32);
|
|
|
|
begin
|
|
return To_Unsigned32 (Left) - To_Unsigned32 (Right);
|
|
end Subtract;
|
|
|
|
function Are_Equal
|
|
(Left : in RTEMS.Address;
|
|
Right : in RTEMS.Address)
|
|
return Standard.Boolean
|
|
is
|
|
function To_Unsigned32 is new Ada.Unchecked_Conversion (
|
|
System.Address,
|
|
RTEMS.Unsigned32);
|
|
|
|
begin
|
|
return (To_Unsigned32 (Left) = To_Unsigned32 (Right));
|
|
end Are_Equal;
|
|
|
|
--
|
|
--
|
|
-- RTEMS API
|
|
--
|
|
|
|
function Build_Name (
|
|
C1 : in Character;
|
|
C2 : in Character;
|
|
C3 : in Character;
|
|
C4 : in Character
|
|
) return RTEMS.Name is
|
|
C1_Value : RTEMS.Unsigned32;
|
|
C2_Value : RTEMS.Unsigned32;
|
|
C3_Value : RTEMS.Unsigned32;
|
|
C4_Value : RTEMS.Unsigned32;
|
|
begin
|
|
|
|
C1_Value := Character'Pos( C1 );
|
|
C2_Value := Character'Pos( C2 );
|
|
C3_Value := Character'Pos( C3 );
|
|
C4_Value := Character'Pos( C4 );
|
|
|
|
return Interfaces.Shift_Left( C1_Value, 24 ) or
|
|
Interfaces.Shift_Left( C2_Value, 16 ) or
|
|
Interfaces.Shift_Left( C3_Value, 8 ) or
|
|
C4_Value;
|
|
|
|
end Build_Name;
|
|
|
|
--
|
|
-- Initialization Manager -- Shutdown Only
|
|
--
|
|
procedure Shutdown_Executive (Status : in RTEMS.Unsigned32) is
|
|
procedure Shutdown_Executive_Base (Status : RTEMS.Unsigned32);
|
|
pragma Import (C, Shutdown_Executive_Base, "rtems_shutdown_executive");
|
|
begin
|
|
Shutdown_Executive_Base (Status);
|
|
end Shutdown_Executive;
|
|
|
|
end RTEMS;
|