* config/xtensa/xtensa.h (GO_IF_MODE_DEPENDENT_ADDRESS): Treat
[official-gcc.git] / gcc / ada / i-vxwork.ads
blob6a534a250653e4fac93136dafe7bd861b5e7e3d0
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA 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 -- --
10 -- Copyright (C) 1999 - 2002 Ada Core Technologies, 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, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, 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. It is --
31 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
32 -- State University (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This package provides a limited binding to the VxWorks API
37 -- In particular, it interfaces with the VxWorks hardware interrupt
38 -- facilities, allowing the use of low-latency direct-vectored
39 -- interrupt handlers. Note that such handlers have a variety of
40 -- restrictions regarding system calls. Less restrictive, but higher-
41 -- latency handlers can be written using Ada protected procedures,
42 -- Ada 83 style interrupt entries, or by signalling an Ada task
43 -- from within an interrupt handler using a binary semaphore as
44 -- described in the VxWorks Programmer's Manual
46 -- For complete documentation of the operations in this package, please
47 -- consult the VxWorks Programmer's Manual and VxWorks Reference Manual
49 with System.VxWorks;
51 package Interfaces.VxWorks is
52 pragma Preelaborate (VxWorks);
54 ------------------------------------------------------------------------
55 -- Here is a complete example that shows how to handle the Interrupt 0x14
56 -- with a direct-vectored interrupt handler in Ada using this package:
58 -- with Interfaces.VxWorks; use Interfaces.VxWorks;
59 -- with System;
61 -- package P is
63 -- Count : Integer;
64 -- pragma Atomic (Count);
66 -- Level : constant := 1;
67 -- -- Interrupt level used by this example
69 -- procedure Handler (parameter : System.Address);
71 -- end P;
73 -- package body P is
75 -- procedure Handler (parameter : System.Address) is
76 -- S : STATUS;
77 -- begin
78 -- Count := Count + 1;
79 -- logMsg ("received an interrupt" & ASCII.LF & ASCII.Nul);
81 -- -- Acknowledge VME interrupt
82 -- S := sysBusIntAck (intLevel => Level);
83 -- end Handler;
84 -- end P;
86 -- with Interfaces.VxWorks; use Interfaces.VxWorks;
87 -- with Ada.Text_IO; use Ada.Text_IO;
89 -- with P; use P;
90 -- procedure Useint is
91 -- -- Be sure to use a reasonable interrupt number for the target
92 -- -- board!
93 -- -- This one is the unused VME graphics interrupt on the PPC MV2604
94 -- Interrupt : constant := 16#14#;
96 -- task T;
98 -- S : STATUS;
100 -- task body T is
101 -- begin
102 -- loop
103 -- Put_Line ("Generating an interrupt...");
104 -- delay 1.0;
106 -- -- Generate VME interrupt, using interrupt number
107 -- S := sysBusIntGen (1, Interrupt);
108 -- end loop;
109 -- end T;
111 -- begin
112 -- S := sysIntEnable (intLevel => Level);
113 -- S := intConnect (INUM_TO_IVEC (Interrupt), handler'Access);
115 -- loop
116 -- delay 2.0;
117 -- Put_Line ("value of count:" & P.Count'Img);
118 -- end loop;
119 -- end Useint;
120 -------------------------------------
122 subtype int is Integer;
124 type STATUS is new int;
125 -- Equivalent of the C type STATUS
127 OK : constant STATUS := 0;
128 ERROR : constant STATUS := -1;
130 type VOIDFUNCPTR is access procedure (parameter : System.Address);
131 type Interrupt_Vector is new System.Address;
132 type Exception_Vector is new System.Address;
134 function intConnect
135 (vector : Interrupt_Vector;
136 handler : VOIDFUNCPTR;
137 parameter : System.Address := System.Null_Address) return STATUS;
138 -- Binding to the C routine intConnect. Use this to set up an
139 -- user handler. The routine generates a wrapper around the user
140 -- handler to save and restore context
142 function intVecGet
143 (Vector : Interrupt_Vector) return VOIDFUNCPTR;
144 -- Binding to the C routine intVecGet. Use this to get the
145 -- existing handler for later restoral
147 procedure intVecSet
148 (Vector : Interrupt_Vector;
149 Handler : VOIDFUNCPTR);
150 -- Binding to the C routine intVecSet. Use this to restore a
151 -- handler obtained using intVecGet
153 function INUM_TO_IVEC (intNum : int) return Interrupt_Vector;
154 -- Equivalent to the C macro INUM_TO_IVEC used to convert an interrupt
155 -- number to an interrupt vector
157 function sysIntEnable (intLevel : int) return STATUS;
158 -- Binding to the C routine sysIntEnable
160 function sysIntDisable (intLevel : int) return STATUS;
161 -- Binding to the C routine sysIntDisable
163 function sysBusIntAck (intLevel : int) return STATUS;
164 -- Binding to the C routine sysBusIntAck
166 function sysBusIntGen (intLevel : int; Intnum : int) return STATUS;
167 -- Binding to the C routine sysBusIntGen. Note that the T2
168 -- documentation implies that a vector address is the proper
169 -- argument - it's not. The interrupt number in the range
170 -- 0 .. 255 (for 68K and PPC) is the correct agument.
172 procedure logMsg
173 (fmt : String; arg1, arg2, arg3, arg4, arg5, arg6 : int := 0);
174 -- Binding to the C routine logMsg. Note that it is the caller's
175 -- responsibility to ensure that fmt is a null-terminated string
176 -- (e.g logMsg ("Interrupt" & ASCII.NUL))
178 type FP_CONTEXT is private;
179 -- Floating point context save and restore. Handlers using floating
180 -- point must be bracketed with these calls. The pFpContext parameter
181 -- should be an object of type FP_CONTEXT that is
182 -- declared local to the handler.
184 procedure fppRestore (pFpContext : in out FP_CONTEXT);
185 -- Restore floating point context
187 procedure fppSave (pFpContext : in out FP_CONTEXT);
188 -- Save floating point context
190 private
192 type FP_CONTEXT is new System.VxWorks.FP_CONTEXT;
193 -- Target-dependent floating point context type
195 pragma Import (C, intConnect, "intConnect");
196 pragma Import (C, intVecGet, "intVecGet");
197 pragma Import (C, intVecSet, "intVecSet");
198 pragma Import (C, INUM_TO_IVEC, "__gnat_inum_to_ivec");
199 pragma Import (C, sysIntEnable, "sysIntEnable");
200 pragma Import (C, sysIntDisable, "sysIntDisable");
201 pragma Import (C, sysBusIntAck, "sysBusIntAck");
202 pragma Import (C, sysBusIntGen, "sysBusIntGen");
203 pragma Import (C, logMsg, "logMsg");
204 pragma Import (C, fppRestore, "fppRestore");
205 pragma Import (C, fppSave, "fppSave");
206 end Interfaces.VxWorks;