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