1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . O S _ I N T E R F A C E --
9 -- Copyright (C) 1991-2001 Florida State University --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. It is --
30 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
31 -- State University (http://www.gnat.com). --
33 ------------------------------------------------------------------------------
35 -- RT GNU/Linux version.
37 -- This package encapsulates all direct interfaces to OS services
38 -- that are needed by children of System.
40 -- PLEASE DO NOT add any with-clauses to this package
41 -- or remove the pragma Elaborate_Body.
42 -- It is designed to be a bottom-level (leaf) package.
46 package System
.OS_Interface
is
50 subtype int
is Interfaces
.C
.int
;
51 subtype unsigned_long
is Interfaces
.C
.unsigned_long
;
53 -- RT GNU/Linux kernel threads should not use the
54 -- OS signal interfaces.
56 Max_Interrupt
: constant := 2;
57 type Signal
is new int
range 0 .. Max_Interrupt
;
58 type sigset_t
is new Integer;
64 RT_TICKS_PER_SEC
: constant := 1193180;
65 -- the amount of time units in one second.
67 RT_TIME_END
: constant := 16#
7fffFfffFfffFfff#
;
69 type RTIME
is range -2 ** 63 .. 2 ** 63 - 1;
70 -- the introduction of type RTIME is due to the fact that RT-GNU/Linux
71 -- uses this type to represent time. In RT-GNU/Linux, it's a long long
72 -- integer that takes 64 bits for storage
74 -------------------------
75 -- Priority Scheduling --
76 -------------------------
78 RT_LOWEST_PRIORITY
: constant System
.Any_Priority
:=
79 System
.Any_Priority
'First;
80 -- for the lowest priority task in RT-GNU/Linux. By the design, this
81 -- task is the regular GNU/Linux kernel.
83 RT_TASK_MAGIC
: constant := 16#
754d2774#
;
84 -- a special constant used as a label for a task that has been created
86 ----------------------------
87 -- RT constants and types --
88 ----------------------------
91 pragma Import
(C
, SFIF
, "SFIF");
92 -- Interrupt emulation flag used by RT-GNU/Linux. If it's 0, the regular
93 -- GNU/Linux kernel is preempted. Otherwise, the regular Linux kernel is
96 GFP_ATOMIC
: constant := 16#
1#
;
97 GFP_KERNEL
: constant := 16#
3#
;
98 -- constants to indicate the priority of a call to kmalloc.
99 -- GFP_KERNEL is used in the current implementation to allocate
100 -- stack space for a task. Since GFP_ATOMIC has higher priority,
101 -- if necessary, replace GFP_KERNEL with GFP_ATOMIC
103 type Rt_Task_States
is (RT_TASK_READY
, RT_TASK_DELAYED
, RT_TASK_DORMANT
);
109 type Thread_Body
is access
110 function (arg
: System
.Address
) return System
.Address
;
112 -- ??? need to define a type for references to (IDs of)
113 -- RT GNU/Linux lock objects, and implement the lock objects.
115 subtype Thread_Id
is System
.Address
;
117 -------------------------------
118 -- Useful imported functions --
119 -------------------------------
121 -------------------------------------
122 -- Functions from GNU/Linux kernel --
123 -------------------------------------
125 function Kmalloc
(size
: Integer; Priority
: Integer) return System
.Address
;
126 pragma Import
(C
, Kmalloc
, "kmalloc");
128 procedure Kfree
(Ptr
: System
.Address
);
129 pragma Import
(C
, Kfree
, "kfree");
131 procedure Printk
(Msg
: String);
132 pragma Import
(C
, Printk
, "printk");
134 ---------------------
135 -- RT time related --
136 ---------------------
138 function Rt_Get_Time
return RTIME
;
139 pragma Import
(C
, Rt_Get_Time
, "rt_get_time");
141 function Rt_Request_Timer
(Fn
: System
.Address
) return Integer;
142 procedure Rt_Request_Timer
(Fn
: System
.Address
);
143 pragma Import
(C
, Rt_Request_Timer
, "rt_request_timer");
145 procedure Rt_Free_Timer
;
146 pragma Import
(C
, Rt_Free_Timer
, "rt_free_timer");
148 procedure Rt_Set_Timer
(T
: RTIME
);
149 pragma Import
(C
, Rt_Set_Timer
, "rt_set_timer");
151 procedure Rt_No_Timer
;
152 pragma Import
(C
, Rt_No_Timer
, "rt_no_timer");
154 ---------------------
155 -- RT FIFO related --
156 ---------------------
158 function Rtf_Create
(Fifo
: Integer; Size
: Integer) return Integer;
159 pragma Import
(C
, Rtf_Create
, "rtf_create");
161 function Rtf_Destroy
(Fifo
: Integer) return Integer;
162 pragma Import
(C
, Rtf_Destroy
, "rtf_destroy");
164 function Rtf_Resize
(Minor
: Integer; Size
: Integer) return Integer;
165 pragma Import
(C
, Rtf_Resize
, "rtf_resize");
169 Buf
: System
.Address
;
170 Count
: Integer) return Integer;
171 pragma Import
(C
, Rtf_Put
, "rtf_put");
175 Buf
: System
.Address
;
176 Count
: Integer) return Integer;
177 pragma Import
(C
, Rtf_Get
, "rtf_get");
179 function Rtf_Create_Handler
181 Handler
: System
.Address
) return Integer;
182 pragma Import
(C
, Rtf_Create_Handler
, "rtf_create_handler");
186 end System
.OS_Interface
;