| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- I N T E R F A C E S . V X W O R K S -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1999-2025, AdaCore -- |
| 10 |
-- -- |
| 11 |
-- GNAT 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 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT 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. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNARL was developed by the GNARL team at Florida State University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
-- This package provides a limited binding to the VxWorks API |
| 33 |
|
| 34 |
-- In particular, it interfaces with the VxWorks hardware interrupt |
| 35 |
-- facilities, allowing the use of low-latency direct-vectored interrupt |
| 36 |
-- handlers. Note that such handlers have a variety of restrictions regarding |
| 37 |
-- system calls and language constructs. In particular, the use of exception |
| 38 |
-- handlers and functions returning variable-length objects cannot be used. |
| 39 |
-- Less restrictive, but higher-latency handlers can be written using Ada |
| 40 |
-- protected procedures, Ada 83 style interrupt entries, or by signalling |
| 41 |
-- an Ada task from within an interrupt handler using a binary semaphore |
| 42 |
-- as described in the VxWorks Programmer's Manual. |
| 43 |
-- |
| 44 |
-- For complete documentation of the operations in this package, please |
| 45 |
-- consult the VxWorks Programmer's Manual and VxWorks Reference Manual. |
| 46 |
|
| 47 |
pragma Warnings (Off, "*foreign convention*"); |
| 48 |
pragma Warnings (Off, "*add Convention pragma*"); |
| 49 |
-- These are temporary pragmas to suppress warnings about mismatching |
| 50 |
-- conventions, which will be a problem when we get rid of trampolines ??? |
| 51 |
|
| 52 |
with System.VxWorks; |
| 53 |
|
| 54 |
package Interfaces.VxWorks is |
| 55 |
pragma Preelaborate; |
| 56 |
|
| 57 |
subtype int is Integer; |
| 58 |
|
| 59 |
type STATUS is new int; |
| 60 |
-- Equivalent of the C type STATUS |
| 61 |
|
| 62 |
OK : constant STATUS := 0; |
| 63 |
ERROR : constant STATUS := -1; |
| 64 |
|
| 65 |
type BOOL is new int; |
| 66 |
-- Equivalent of the C type BOOL |
| 67 |
|
| 68 |
type Interrupt_Vector is new System.Address; |
| 69 |
|
| 70 |
function intContext return BOOL; |
| 71 |
-- Binding to the C routine intContext. This function returns 1 (TRUE) |
| 72 |
-- only if the current execution state is in interrupt context. |
| 73 |
|
| 74 |
function INUM_TO_IVEC (intNum : int) return Interrupt_Vector; |
| 75 |
-- Equivalent to the C macro INUM_TO_IVEC used to convert an interrupt |
| 76 |
-- number to an interrupt vector |
| 77 |
|
| 78 |
procedure logMsg |
| 79 |
(fmt : String; arg1, arg2, arg3, arg4, arg5, arg6 : int := 0); |
| 80 |
-- Binding to the C routine logMsg. Note that it is the caller's |
| 81 |
-- responsibility to ensure that fmt is a null-terminated string |
| 82 |
-- (e.g logMsg ("Interrupt" & ASCII.NUL)) |
| 83 |
|
| 84 |
type FP_CONTEXT is private; |
| 85 |
-- Floating point context save and restore. Handlers using floating point |
| 86 |
-- must be bracketed with these calls. The pFpContext parameter should be |
| 87 |
-- an object of type FP_CONTEXT that is declared local to the handler. |
| 88 |
|
| 89 |
procedure fppRestore (pFpContext : in out FP_CONTEXT); |
| 90 |
-- Restore floating point context |
| 91 |
|
| 92 |
procedure fppSave (pFpContext : in out FP_CONTEXT); |
| 93 |
-- Save floating point context |
| 94 |
|
| 95 |
private |
| 96 |
|
| 97 |
type FP_CONTEXT is new System.VxWorks.FP_CONTEXT; |
| 98 |
-- Target-dependent floating point context type |
| 99 |
|
| 100 |
pragma Import (C, intContext, "intContext"); |
| 101 |
pragma Import (C, INUM_TO_IVEC, "__gnat_inum_to_ivec"); |
| 102 |
pragma Import (C, logMsg, "logMsg"); |
| 103 |
pragma Import (C, fppRestore, "fppRestore"); |
| 104 |
pragma Import (C, fppSave, "fppSave"); |
| 105 |
|
| 106 |
end Interfaces.VxWorks; |