annotate gcc/ada/libgnarl/s-osinte__vxworks.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . O S _ I N T E R F A C E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1991-2017, Florida State University --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
10 -- Copyright (C) 1995-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
11 -- --
kono
parents:
diff changeset
12 -- GNARL is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
13 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
14 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
17 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
18 -- --
kono
parents:
diff changeset
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
20 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
21 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
22 -- --
kono
parents:
diff changeset
23 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
24 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
26 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
27 -- --
kono
parents:
diff changeset
28 -- GNARL was developed by the GNARL team at Florida State University. --
kono
parents:
diff changeset
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
kono
parents:
diff changeset
30 -- --
kono
parents:
diff changeset
31 ------------------------------------------------------------------------------
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 -- This is the VxWorks version of this package
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 -- This package encapsulates all direct interfaces to OS services that are
kono
parents:
diff changeset
36 -- needed by the tasking run-time (libgnarl).
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- PLEASE DO NOT add any with-clauses to this package or remove the pragma
kono
parents:
diff changeset
39 -- Preelaborate. This package is designed to be a bottom-level (leaf) package.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 with Interfaces.C;
kono
parents:
diff changeset
42 with System.VxWorks;
kono
parents:
diff changeset
43 with System.VxWorks.Ext;
kono
parents:
diff changeset
44 with System.Multiprocessors;
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 package System.OS_Interface is
kono
parents:
diff changeset
47 pragma Preelaborate;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 subtype int is Interfaces.C.int;
kono
parents:
diff changeset
50 subtype unsigned is Interfaces.C.unsigned;
kono
parents:
diff changeset
51 subtype short is Short_Integer;
kono
parents:
diff changeset
52 type unsigned_int is mod 2 ** int'Size;
kono
parents:
diff changeset
53 type long is new Long_Integer;
kono
parents:
diff changeset
54 type unsigned_long is mod 2 ** long'Size;
kono
parents:
diff changeset
55 type long_long is new Long_Long_Integer;
kono
parents:
diff changeset
56 type unsigned_long_long is mod 2 ** long_long'Size;
kono
parents:
diff changeset
57 type size_t is mod 2 ** Standard'Address_Size;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 -----------
kono
parents:
diff changeset
60 -- Errno --
kono
parents:
diff changeset
61 -----------
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 function errno return int;
kono
parents:
diff changeset
64 pragma Import (C, errno, "errnoGet");
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 EINTR : constant := 4;
kono
parents:
diff changeset
67 EAGAIN : constant := 35;
kono
parents:
diff changeset
68 ENOMEM : constant := 12;
kono
parents:
diff changeset
69 EINVAL : constant := 22;
kono
parents:
diff changeset
70 ETIMEDOUT : constant := 60;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 FUNC_ERR : constant := -1;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 ----------------------------
kono
parents:
diff changeset
75 -- Signals and interrupts --
kono
parents:
diff changeset
76 ----------------------------
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 NSIG : constant := 64;
kono
parents:
diff changeset
79 -- Number of signals on the target OS
kono
parents:
diff changeset
80 type Signal is new int range 0 .. Interfaces.C."-" (NSIG, 1);
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 Max_HW_Interrupt : constant := System.VxWorks.Num_HW_Interrupts - 1;
kono
parents:
diff changeset
83 type HW_Interrupt is new int range 0 .. Max_HW_Interrupt;
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 Max_Interrupt : constant := Max_HW_Interrupt;
kono
parents:
diff changeset
86 subtype Interrupt_Range is Natural range 0 .. Max_HW_Interrupt;
kono
parents:
diff changeset
87 -- For s-interr
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 -- Signals common to Vxworks 5.x and 6.x
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 SIGILL : constant := 4; -- illegal instruction (not reset when caught)
kono
parents:
diff changeset
92 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
kono
parents:
diff changeset
93 SIGFPE : constant := 8; -- floating point exception
kono
parents:
diff changeset
94 SIGBUS : constant := 10; -- bus error
kono
parents:
diff changeset
95 SIGSEGV : constant := 11; -- segmentation violation
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 -- Signals specific to VxWorks 6.x
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 SIGHUP : constant := 1; -- hangup
kono
parents:
diff changeset
100 SIGINT : constant := 2; -- interrupt
kono
parents:
diff changeset
101 SIGQUIT : constant := 3; -- quit
kono
parents:
diff changeset
102 SIGTRAP : constant := 5; -- trace trap (not reset when caught)
kono
parents:
diff changeset
103 SIGEMT : constant := 7; -- EMT instruction
kono
parents:
diff changeset
104 SIGKILL : constant := 9; -- kill
kono
parents:
diff changeset
105 SIGFMT : constant := 12; -- STACK FORMAT ERROR (not posix)
kono
parents:
diff changeset
106 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
kono
parents:
diff changeset
107 SIGALRM : constant := 14; -- alarm clock
kono
parents:
diff changeset
108 SIGTERM : constant := 15; -- software termination signal from kill
kono
parents:
diff changeset
109 SIGCNCL : constant := 16; -- pthreads cancellation signal
kono
parents:
diff changeset
110 SIGSTOP : constant := 17; -- sendable stop signal not from tty
kono
parents:
diff changeset
111 SIGTSTP : constant := 18; -- stop signal from tty
kono
parents:
diff changeset
112 SIGCONT : constant := 19; -- continue a stopped process
kono
parents:
diff changeset
113 SIGCHLD : constant := 20; -- to parent on child stop or exit
kono
parents:
diff changeset
114 SIGTTIN : constant := 21; -- to readers pgrp upon background tty read
kono
parents:
diff changeset
115 SIGTTOU : constant := 22; -- like TTIN for output
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 SIGRES1 : constant := 23; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
118 SIGRES2 : constant := 24; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
119 SIGRES3 : constant := 25; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
120 SIGRES4 : constant := 26; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
121 SIGRES5 : constant := 27; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
122 SIGRES6 : constant := 28; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
123 SIGRES7 : constant := 29; -- reserved signal number (Not POSIX)
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 SIGUSR1 : constant := 30; -- user defined signal 1
kono
parents:
diff changeset
126 SIGUSR2 : constant := 31; -- user defined signal 2
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 SIGPOLL : constant := 32; -- pollable event
kono
parents:
diff changeset
129 SIGPROF : constant := 33; -- profiling timer expired
kono
parents:
diff changeset
130 SIGSYS : constant := 34; -- bad system call
kono
parents:
diff changeset
131 SIGURG : constant := 35; -- high bandwidth data is available at socket
kono
parents:
diff changeset
132 SIGVTALRM : constant := 36; -- virtual timer expired
kono
parents:
diff changeset
133 SIGXCPU : constant := 37; -- CPU time limit exceeded
kono
parents:
diff changeset
134 SIGXFSZ : constant := 38; -- file size time limit exceeded
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 SIGEVTS : constant := 39; -- signal event thread send
kono
parents:
diff changeset
137 SIGEVTD : constant := 40; -- signal event thread delete
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 SIGRTMIN : constant := 48; -- Realtime signal min
kono
parents:
diff changeset
140 SIGRTMAX : constant := 63; -- Realtime signal max
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 -----------------------------------
kono
parents:
diff changeset
143 -- Signal processing definitions --
kono
parents:
diff changeset
144 -----------------------------------
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 -- The how in sigprocmask()
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 SIG_BLOCK : constant := 1;
kono
parents:
diff changeset
149 SIG_UNBLOCK : constant := 2;
kono
parents:
diff changeset
150 SIG_SETMASK : constant := 3;
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 -- The sa_flags in struct sigaction
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 SA_SIGINFO : constant := 16#0002#;
kono
parents:
diff changeset
155 SA_ONSTACK : constant := 16#0004#;
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 SIG_DFL : constant := 0;
kono
parents:
diff changeset
158 SIG_IGN : constant := 1;
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 type sigset_t is private;
kono
parents:
diff changeset
161
kono
parents:
diff changeset
162 type struct_sigaction is record
kono
parents:
diff changeset
163 sa_handler : System.Address;
kono
parents:
diff changeset
164 sa_mask : sigset_t;
kono
parents:
diff changeset
165 sa_flags : int;
kono
parents:
diff changeset
166 end record;
kono
parents:
diff changeset
167 pragma Convention (C, struct_sigaction);
kono
parents:
diff changeset
168 type struct_sigaction_ptr is access all struct_sigaction;
kono
parents:
diff changeset
169
kono
parents:
diff changeset
170 function sigaddset (set : access sigset_t; sig : Signal) return int;
kono
parents:
diff changeset
171 pragma Import (C, sigaddset, "sigaddset");
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 function sigdelset (set : access sigset_t; sig : Signal) return int;
kono
parents:
diff changeset
174 pragma Import (C, sigdelset, "sigdelset");
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 function sigfillset (set : access sigset_t) return int;
kono
parents:
diff changeset
177 pragma Import (C, sigfillset, "sigfillset");
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 function sigismember (set : access sigset_t; sig : Signal) return int;
kono
parents:
diff changeset
180 pragma Import (C, sigismember, "sigismember");
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 function sigemptyset (set : access sigset_t) return int;
kono
parents:
diff changeset
183 pragma Import (C, sigemptyset, "sigemptyset");
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 function sigaction
kono
parents:
diff changeset
186 (sig : Signal;
kono
parents:
diff changeset
187 act : struct_sigaction_ptr;
kono
parents:
diff changeset
188 oact : struct_sigaction_ptr) return int;
kono
parents:
diff changeset
189 pragma Import (C, sigaction, "sigaction");
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 type isr_address is access procedure (sig : int);
kono
parents:
diff changeset
192 pragma Convention (C, isr_address);
kono
parents:
diff changeset
193
kono
parents:
diff changeset
194 function c_signal (sig : Signal; handler : isr_address) return isr_address;
kono
parents:
diff changeset
195 pragma Import (C, c_signal, "signal");
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 function pthread_sigmask
kono
parents:
diff changeset
198 (how : int;
kono
parents:
diff changeset
199 set : access sigset_t;
kono
parents:
diff changeset
200 oset : access sigset_t) return int;
kono
parents:
diff changeset
201 pragma Import (C, pthread_sigmask, "sigprocmask");
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 subtype t_id is System.VxWorks.Ext.t_id;
kono
parents:
diff changeset
204 subtype Thread_Id is t_id;
kono
parents:
diff changeset
205 -- Thread_Id and t_id are VxWorks identifiers for tasks. This value,
kono
parents:
diff changeset
206 -- although represented as a Long_Integer, is in fact an address. With
kono
parents:
diff changeset
207 -- some BSPs, this address can have a value sufficiently high that the
kono
parents:
diff changeset
208 -- Thread_Id becomes negative: this should not be considered as an error.
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 function kill (pid : t_id; sig : Signal) return int;
kono
parents:
diff changeset
211 pragma Inline (kill);
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 function getpid return t_id renames System.VxWorks.Ext.getpid;
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 function Task_Stop (tid : t_id) return int
kono
parents:
diff changeset
216 renames System.VxWorks.Ext.Task_Stop;
kono
parents:
diff changeset
217 -- If we are in the kernel space, stop the task whose t_id is given in
kono
parents:
diff changeset
218 -- parameter in such a way that it can be examined by the debugger. This
kono
parents:
diff changeset
219 -- typically maps to taskSuspend on VxWorks 5 and to taskStop on VxWorks 6.
kono
parents:
diff changeset
220
kono
parents:
diff changeset
221 function Task_Cont (tid : t_id) return int
kono
parents:
diff changeset
222 renames System.VxWorks.Ext.Task_Cont;
kono
parents:
diff changeset
223 -- If we are in the kernel space, continue the task whose t_id is given
kono
parents:
diff changeset
224 -- in parameter if it has been stopped previously to be examined by the
kono
parents:
diff changeset
225 -- debugger (e.g. by taskStop). It typically maps to taskResume on VxWorks
kono
parents:
diff changeset
226 -- 5 and to taskCont on VxWorks 6.
kono
parents:
diff changeset
227
kono
parents:
diff changeset
228 function Int_Lock return int renames System.VxWorks.Ext.Int_Lock;
kono
parents:
diff changeset
229 -- If we are in the kernel space, lock interrupts. It typically maps to
kono
parents:
diff changeset
230 -- intLock.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 function Int_Unlock (Old : int) return int
kono
parents:
diff changeset
233 renames System.VxWorks.Ext.Int_Unlock;
kono
parents:
diff changeset
234 -- If we are in the kernel space, unlock interrupts. It typically maps to
kono
parents:
diff changeset
235 -- intUnlock. The parameter Old is only used on PowerPC where it contains
kono
parents:
diff changeset
236 -- the returned value from Int_Lock (the old MPSR).
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 ----------
kono
parents:
diff changeset
239 -- Time --
kono
parents:
diff changeset
240 ----------
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 type time_t is new unsigned_long;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 type timespec is record
kono
parents:
diff changeset
245 ts_sec : time_t;
kono
parents:
diff changeset
246 ts_nsec : long;
kono
parents:
diff changeset
247 end record;
kono
parents:
diff changeset
248 pragma Convention (C, timespec);
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 type clockid_t is new int;
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 function To_Duration (TS : timespec) return Duration;
kono
parents:
diff changeset
253 pragma Inline (To_Duration);
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 function To_Timespec (D : Duration) return timespec;
kono
parents:
diff changeset
256 pragma Inline (To_Timespec);
kono
parents:
diff changeset
257 -- Convert a Duration value to a timespec value. Note that in VxWorks,
kono
parents:
diff changeset
258 -- timespec is always non-negative (since time_t is defined above as
kono
parents:
diff changeset
259 -- unsigned long). This means that there is a potential problem if a
kono
parents:
diff changeset
260 -- negative argument is passed for D. However, in actual usage, the
kono
parents:
diff changeset
261 -- value of the input argument D is always non-negative, so no problem
kono
parents:
diff changeset
262 -- arises in practice.
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 function To_Clock_Ticks (D : Duration) return int;
kono
parents:
diff changeset
265 -- Convert a duration value (in seconds) into clock ticks
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 function clock_gettime
kono
parents:
diff changeset
268 (clock_id : clockid_t; tp : access timespec) return int;
kono
parents:
diff changeset
269 pragma Import (C, clock_gettime, "clock_gettime");
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 ----------------------
kono
parents:
diff changeset
272 -- Utility Routines --
kono
parents:
diff changeset
273 ----------------------
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 function To_VxWorks_Priority (Priority : int) return int;
kono
parents:
diff changeset
276 pragma Inline (To_VxWorks_Priority);
kono
parents:
diff changeset
277 -- Convenience routine to convert between VxWorks priority and Ada priority
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 --------------------------
kono
parents:
diff changeset
280 -- VxWorks specific API --
kono
parents:
diff changeset
281 --------------------------
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 subtype STATUS is int;
kono
parents:
diff changeset
284 -- Equivalent of the C type STATUS
kono
parents:
diff changeset
285
kono
parents:
diff changeset
286 OK : constant STATUS := 0;
kono
parents:
diff changeset
287 ERROR : constant STATUS := Interfaces.C.int (-1);
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 function taskIdVerify (tid : t_id) return STATUS;
kono
parents:
diff changeset
290 pragma Import (C, taskIdVerify, "taskIdVerify");
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 function taskIdSelf return t_id;
kono
parents:
diff changeset
293 pragma Import (C, taskIdSelf, "taskIdSelf");
kono
parents:
diff changeset
294
kono
parents:
diff changeset
295 function taskOptionsGet (tid : t_id; pOptions : access int) return int;
kono
parents:
diff changeset
296 pragma Import (C, taskOptionsGet, "taskOptionsGet");
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 function taskSuspend (tid : t_id) return int;
kono
parents:
diff changeset
299 pragma Import (C, taskSuspend, "taskSuspend");
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 function taskResume (tid : t_id) return int;
kono
parents:
diff changeset
302 pragma Import (C, taskResume, "taskResume");
kono
parents:
diff changeset
303
kono
parents:
diff changeset
304 function taskIsSuspended (tid : t_id) return int;
kono
parents:
diff changeset
305 pragma Import (C, taskIsSuspended, "taskIsSuspended");
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 function taskDelay (ticks : int) return int;
kono
parents:
diff changeset
308 pragma Import (C, taskDelay, "taskDelay");
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 function sysClkRateGet return int;
kono
parents:
diff changeset
311 pragma Import (C, sysClkRateGet, "sysClkRateGet");
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 -- VxWorks 5.x specific functions
kono
parents:
diff changeset
314 -- Must not be called from run-time for versions that do not support
kono
parents:
diff changeset
315 -- taskVarLib: eg VxWorks 6 RTPs
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 function taskVarAdd
kono
parents:
diff changeset
318 (tid : t_id; pVar : access System.Address) return int;
kono
parents:
diff changeset
319 pragma Import (C, taskVarAdd, "taskVarAdd");
kono
parents:
diff changeset
320
kono
parents:
diff changeset
321 function taskVarDelete
kono
parents:
diff changeset
322 (tid : t_id; pVar : access System.Address) return int;
kono
parents:
diff changeset
323 pragma Import (C, taskVarDelete, "taskVarDelete");
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 function taskVarSet
kono
parents:
diff changeset
326 (tid : t_id;
kono
parents:
diff changeset
327 pVar : access System.Address;
kono
parents:
diff changeset
328 value : System.Address) return int;
kono
parents:
diff changeset
329 pragma Import (C, taskVarSet, "taskVarSet");
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 function taskVarGet
kono
parents:
diff changeset
332 (tid : t_id;
kono
parents:
diff changeset
333 pVar : access System.Address) return int;
kono
parents:
diff changeset
334 pragma Import (C, taskVarGet, "taskVarGet");
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 -- VxWorks 6.x specific functions
kono
parents:
diff changeset
337
kono
parents:
diff changeset
338 -- Can only be called from the VxWorks 6 run-time libary that supports
kono
parents:
diff changeset
339 -- tlsLib, and not by the VxWorks 6.6 SMP library
kono
parents:
diff changeset
340
kono
parents:
diff changeset
341 function tlsKeyCreate return int;
kono
parents:
diff changeset
342 pragma Import (C, tlsKeyCreate, "tlsKeyCreate");
kono
parents:
diff changeset
343
kono
parents:
diff changeset
344 function tlsValueGet (key : int) return System.Address;
kono
parents:
diff changeset
345 pragma Import (C, tlsValueGet, "tlsValueGet");
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 function tlsValueSet (key : int; value : System.Address) return STATUS;
kono
parents:
diff changeset
348 pragma Import (C, tlsValueSet, "tlsValueSet");
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 -- Option flags for taskSpawn
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 VX_UNBREAKABLE : constant := 16#0002#;
kono
parents:
diff changeset
353 VX_FP_PRIVATE_ENV : constant := 16#0080#;
kono
parents:
diff changeset
354 VX_NO_STACK_FILL : constant := 16#0100#;
kono
parents:
diff changeset
355
kono
parents:
diff changeset
356 function taskSpawn
kono
parents:
diff changeset
357 (name : System.Address; -- Pointer to task name
kono
parents:
diff changeset
358 priority : int;
kono
parents:
diff changeset
359 options : int;
kono
parents:
diff changeset
360 stacksize : size_t;
kono
parents:
diff changeset
361 start_routine : System.Address;
kono
parents:
diff changeset
362 arg1 : System.Address;
kono
parents:
diff changeset
363 arg2 : int := 0;
kono
parents:
diff changeset
364 arg3 : int := 0;
kono
parents:
diff changeset
365 arg4 : int := 0;
kono
parents:
diff changeset
366 arg5 : int := 0;
kono
parents:
diff changeset
367 arg6 : int := 0;
kono
parents:
diff changeset
368 arg7 : int := 0;
kono
parents:
diff changeset
369 arg8 : int := 0;
kono
parents:
diff changeset
370 arg9 : int := 0;
kono
parents:
diff changeset
371 arg10 : int := 0) return t_id;
kono
parents:
diff changeset
372 pragma Import (C, taskSpawn, "taskSpawn");
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 procedure taskDelete (tid : t_id);
kono
parents:
diff changeset
375 pragma Import (C, taskDelete, "taskDelete");
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 function Set_Time_Slice (ticks : int) return int
kono
parents:
diff changeset
378 renames System.VxWorks.Ext.Set_Time_Slice;
kono
parents:
diff changeset
379 -- Calls kernelTimeSlice under VxWorks 5.x, VxWorks 653, or in VxWorks 6
kono
parents:
diff changeset
380 -- kernel apps. Returns ERROR for RTPs, VxWorks 5 /CERT
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 function taskPriorityGet (tid : t_id; pPriority : access int) return int;
kono
parents:
diff changeset
383 pragma Import (C, taskPriorityGet, "taskPriorityGet");
kono
parents:
diff changeset
384
kono
parents:
diff changeset
385 function taskPrioritySet (tid : t_id; newPriority : int) return int;
kono
parents:
diff changeset
386 pragma Import (C, taskPrioritySet, "taskPrioritySet");
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 -- Semaphore creation flags
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 SEM_Q_FIFO : constant := 0;
kono
parents:
diff changeset
391 SEM_Q_PRIORITY : constant := 1;
kono
parents:
diff changeset
392 SEM_DELETE_SAFE : constant := 4; -- only valid for binary semaphore
kono
parents:
diff changeset
393 SEM_INVERSION_SAFE : constant := 8; -- only valid for binary semaphore
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 -- Semaphore initial state flags
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 SEM_EMPTY : constant := 0;
kono
parents:
diff changeset
398 SEM_FULL : constant := 1;
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 -- Semaphore take (semTake) time constants
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 WAIT_FOREVER : constant := -1;
kono
parents:
diff changeset
403 NO_WAIT : constant := 0;
kono
parents:
diff changeset
404
kono
parents:
diff changeset
405 -- Error codes (errno). The lower level 16 bits are the error code, with
kono
parents:
diff changeset
406 -- the upper 16 bits representing the module number in which the error
kono
parents:
diff changeset
407 -- occurred. By convention, the module number is 0 for UNIX errors. VxWorks
kono
parents:
diff changeset
408 -- reserves module numbers 1-500, with the remaining module numbers being
kono
parents:
diff changeset
409 -- available for user applications.
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 M_objLib : constant := 61 * 2**16;
kono
parents:
diff changeset
412 -- semTake() failure with ticks = NO_WAIT
kono
parents:
diff changeset
413 S_objLib_OBJ_UNAVAILABLE : constant := M_objLib + 2;
kono
parents:
diff changeset
414 -- semTake() timeout with ticks > NO_WAIT
kono
parents:
diff changeset
415 S_objLib_OBJ_TIMEOUT : constant := M_objLib + 4;
kono
parents:
diff changeset
416
kono
parents:
diff changeset
417 subtype SEM_ID is System.VxWorks.Ext.SEM_ID;
kono
parents:
diff changeset
418 -- typedef struct semaphore *SEM_ID;
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 -- We use two different kinds of VxWorks semaphores: mutex and binary
kono
parents:
diff changeset
421 -- semaphores. A null ID is returned when a semaphore cannot be created.
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 function semBCreate (options : int; initial_state : int) return SEM_ID;
kono
parents:
diff changeset
424 pragma Import (C, semBCreate, "semBCreate");
kono
parents:
diff changeset
425 -- Create a binary semaphore. Return ID, or 0 if memory could not
kono
parents:
diff changeset
426 -- be allocated.
kono
parents:
diff changeset
427
kono
parents:
diff changeset
428 function semMCreate (options : int) return SEM_ID;
kono
parents:
diff changeset
429 pragma Import (C, semMCreate, "semMCreate");
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 function semDelete (Sem : SEM_ID) return int
kono
parents:
diff changeset
432 renames System.VxWorks.Ext.semDelete;
kono
parents:
diff changeset
433 -- Delete a semaphore
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 function semGive (Sem : SEM_ID) return int;
kono
parents:
diff changeset
436 pragma Import (C, semGive, "semGive");
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 function semTake (Sem : SEM_ID; timeout : int) return int;
kono
parents:
diff changeset
439 pragma Import (C, semTake, "semTake");
kono
parents:
diff changeset
440 -- Attempt to take binary semaphore. Error is returned if operation
kono
parents:
diff changeset
441 -- times out
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 function semFlush (SemID : SEM_ID) return STATUS;
kono
parents:
diff changeset
444 pragma Import (C, semFlush, "semFlush");
kono
parents:
diff changeset
445 -- Release all threads blocked on the semaphore
kono
parents:
diff changeset
446
kono
parents:
diff changeset
447 ------------------------------------------------------------
kono
parents:
diff changeset
448 -- Binary Semaphore Wrapper to Support interrupt Tasks --
kono
parents:
diff changeset
449 ------------------------------------------------------------
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 type Binary_Semaphore_Id is new Long_Integer;
kono
parents:
diff changeset
452
kono
parents:
diff changeset
453 function Binary_Semaphore_Create return Binary_Semaphore_Id;
kono
parents:
diff changeset
454 pragma Inline (Binary_Semaphore_Create);
kono
parents:
diff changeset
455
kono
parents:
diff changeset
456 function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int;
kono
parents:
diff changeset
457 pragma Inline (Binary_Semaphore_Delete);
kono
parents:
diff changeset
458
kono
parents:
diff changeset
459 function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int;
kono
parents:
diff changeset
460 pragma Inline (Binary_Semaphore_Obtain);
kono
parents:
diff changeset
461
kono
parents:
diff changeset
462 function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int;
kono
parents:
diff changeset
463 pragma Inline (Binary_Semaphore_Release);
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int;
kono
parents:
diff changeset
466 pragma Inline (Binary_Semaphore_Flush);
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 ------------------------------------------------------------
kono
parents:
diff changeset
469 -- Hardware Interrupt Wrappers to Support Interrupt Tasks --
kono
parents:
diff changeset
470 ------------------------------------------------------------
kono
parents:
diff changeset
471
kono
parents:
diff changeset
472 type Interrupt_Handler is access procedure (parameter : System.Address);
kono
parents:
diff changeset
473 pragma Convention (C, Interrupt_Handler);
kono
parents:
diff changeset
474
kono
parents:
diff changeset
475 type Interrupt_Vector is new System.Address;
kono
parents:
diff changeset
476
kono
parents:
diff changeset
477 function Interrupt_Connect
kono
parents:
diff changeset
478 (Vector : Interrupt_Vector;
kono
parents:
diff changeset
479 Handler : Interrupt_Handler;
kono
parents:
diff changeset
480 Parameter : System.Address := System.Null_Address) return int;
kono
parents:
diff changeset
481 pragma Inline (Interrupt_Connect);
kono
parents:
diff changeset
482 -- Use this to set up an user handler. The routine installs a user handler
kono
parents:
diff changeset
483 -- which is invoked after the OS has saved enough context for a high-level
kono
parents:
diff changeset
484 -- language routine to be safely invoked.
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 function Interrupt_Context return int;
kono
parents:
diff changeset
487 pragma Inline (Interrupt_Context);
kono
parents:
diff changeset
488 -- Return 1 if executing in an interrupt context; return 0 if executing in
kono
parents:
diff changeset
489 -- a task context.
kono
parents:
diff changeset
490
kono
parents:
diff changeset
491 function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector;
kono
parents:
diff changeset
492 pragma Inline (Interrupt_Number_To_Vector);
kono
parents:
diff changeset
493 -- Convert a logical interrupt number to the hardware interrupt vector
kono
parents:
diff changeset
494 -- number used to connect the interrupt.
kono
parents:
diff changeset
495
kono
parents:
diff changeset
496 --------------------------------
kono
parents:
diff changeset
497 -- Processor Affinity for SMP --
kono
parents:
diff changeset
498 --------------------------------
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 function taskCpuAffinitySet (tid : t_id; CPU : int) return int
kono
parents:
diff changeset
501 renames System.VxWorks.Ext.taskCpuAffinitySet;
kono
parents:
diff changeset
502 -- For SMP run-times the affinity to CPU.
kono
parents:
diff changeset
503 -- For uniprocessor systems return ERROR status.
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 function taskMaskAffinitySet (tid : t_id; CPU_Set : unsigned) return int
kono
parents:
diff changeset
506 renames System.VxWorks.Ext.taskMaskAffinitySet;
kono
parents:
diff changeset
507 -- For SMP run-times the affinity to CPU_Set.
kono
parents:
diff changeset
508 -- For uniprocessor systems return ERROR status.
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 ---------------------
kono
parents:
diff changeset
511 -- Multiprocessors --
kono
parents:
diff changeset
512 ---------------------
kono
parents:
diff changeset
513
kono
parents:
diff changeset
514 function Current_CPU return Multiprocessors.CPU;
kono
parents:
diff changeset
515 -- Return the id of the current CPU
kono
parents:
diff changeset
516
kono
parents:
diff changeset
517 private
kono
parents:
diff changeset
518 type pid_t is new int;
kono
parents:
diff changeset
519
kono
parents:
diff changeset
520 ERROR_PID : constant pid_t := -1;
kono
parents:
diff changeset
521
kono
parents:
diff changeset
522 type sigset_t is new System.VxWorks.Ext.sigset_t;
kono
parents:
diff changeset
523 end System.OS_Interface;