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