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 --
11 -- Copyright (C) 1991-2001 Florida State University --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNARL; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com). --
35 ------------------------------------------------------------------------------
37 -- RT GNU/Linux version.
39 -- This package encapsulates all direct interfaces to OS services
40 -- that are needed by children of System.
42 -- PLEASE DO NOT add any with-clauses to this package
43 -- or remove the pragma Elaborate_Body.
44 -- It is designed to be a bottom-level (leaf) package.
48 package System
.OS_Interface
is
52 subtype int
is Interfaces
.C
.int
;
53 subtype unsigned_long
is Interfaces
.C
.unsigned_long
;
55 -- RT GNU/Linux kernel threads should not use the
56 -- OS signal interfaces.
58 Max_Interrupt
: constant := 2;
59 type Signal
is new int
range 0 .. Max_Interrupt
;
60 type sigset_t
is new Integer;
66 RT_TICKS_PER_SEC
: constant := 1193180;
67 -- the amount of time units in one second.
69 RT_TIME_END
: constant := 16#
7fffFfffFfffFfff#
;
71 type RTIME
is range -2 ** 63 .. 2 ** 63 - 1;
72 -- the introduction of type RTIME is due to the fact that RT-GNU/Linux
73 -- uses this type to represent time. In RT-GNU/Linux, it's a long long
74 -- integer that takes 64 bits for storage
76 -------------------------
77 -- Priority Scheduling --
78 -------------------------
80 RT_LOWEST_PRIORITY
: constant System
.Any_Priority
:=
81 System
.Any_Priority
'First;
82 -- for the lowest priority task in RT-GNU/Linux. By the design, this
83 -- task is the regular GNU/Linux kernel.
85 RT_TASK_MAGIC
: constant := 16#
754d2774#
;
86 -- a special constant used as a label for a task that has been created
88 ----------------------------
89 -- RT constants and types --
90 ----------------------------
93 pragma Import
(C
, SFIF
, "SFIF");
94 -- Interrupt emulation flag used by RT-GNU/Linux. If it's 0, the regular
95 -- GNU/Linux kernel is preempted. Otherwise, the regular Linux kernel is
98 GFP_ATOMIC
: constant := 16#
1#
;
99 GFP_KERNEL
: constant := 16#
3#
;
100 -- constants to indicate the priority of a call to kmalloc.
101 -- GFP_KERNEL is used in the current implementation to allocate
102 -- stack space for a task. Since GFP_ATOMIC has higher priority,
103 -- if necessary, replace GFP_KERNEL with GFP_ATOMIC
105 type Rt_Task_States
is (RT_TASK_READY
, RT_TASK_DELAYED
, RT_TASK_DORMANT
);
111 type Thread_Body
is access
112 function (arg
: System
.Address
) return System
.Address
;
114 -- ??? need to define a type for references to (IDs of)
115 -- RT GNU/Linux lock objects, and implement the lock objects.
117 subtype Thread_Id
is System
.Address
;
119 -------------------------------
120 -- Useful imported functions --
121 -------------------------------
123 -------------------------------------
124 -- Functions from GNU/Linux kernel --
125 -------------------------------------
127 function Kmalloc
(size
: Integer; Priority
: Integer) return System
.Address
;
128 pragma Import
(C
, Kmalloc
, "kmalloc");
130 procedure Kfree
(Ptr
: System
.Address
);
131 pragma Import
(C
, Kfree
, "kfree");
133 procedure Printk
(Msg
: String);
134 pragma Import
(C
, Printk
, "printk");
136 ---------------------
137 -- RT time related --
138 ---------------------
140 function Rt_Get_Time
return RTIME
;
141 pragma Import
(C
, Rt_Get_Time
, "rt_get_time");
143 function Rt_Request_Timer
(Fn
: System
.Address
) return Integer;
144 procedure Rt_Request_Timer
(Fn
: System
.Address
);
145 pragma Import
(C
, Rt_Request_Timer
, "rt_request_timer");
147 procedure Rt_Free_Timer
;
148 pragma Import
(C
, Rt_Free_Timer
, "rt_free_timer");
150 procedure Rt_Set_Timer
(T
: RTIME
);
151 pragma Import
(C
, Rt_Set_Timer
, "rt_set_timer");
153 procedure Rt_No_Timer
;
154 pragma Import
(C
, Rt_No_Timer
, "rt_no_timer");
156 ---------------------
157 -- RT FIFO related --
158 ---------------------
160 function Rtf_Create
(Fifo
: Integer; Size
: Integer) return Integer;
161 pragma Import
(C
, Rtf_Create
, "rtf_create");
163 function Rtf_Destroy
(Fifo
: Integer) return Integer;
164 pragma Import
(C
, Rtf_Destroy
, "rtf_destroy");
166 function Rtf_Resize
(Minor
: Integer; Size
: Integer) return Integer;
167 pragma Import
(C
, Rtf_Resize
, "rtf_resize");
171 Buf
: System
.Address
;
172 Count
: Integer) return Integer;
173 pragma Import
(C
, Rtf_Put
, "rtf_put");
177 Buf
: System
.Address
;
178 Count
: Integer) return Integer;
179 pragma Import
(C
, Rtf_Get
, "rtf_get");
181 function Rtf_Create_Handler
183 Handler
: System
.Address
) return Integer;
184 pragma Import
(C
, Rtf_Create_Handler
, "rtf_create_handler");
188 end System
.OS_Interface
;