OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [i-vxwork.ads] - Blame information for rev 706

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
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-2010, 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
--  In particular, it interfaces with the VxWorks hardware interrupt
34
--  facilities, allowing the use of low-latency direct-vectored
35
--  interrupt handlers. Note that such handlers have a variety of
36
--  restrictions regarding system calls and language constructs. In particular,
37
--  the use of exception handlers and functions returning variable-length
38
--  objects cannot be used. Less restrictive, but higher-latency handlers can
39
--  be written using Ada protected procedures, Ada 83 style interrupt entries,
40
--  or by signalling an Ada task from within an interrupt handler using a
41
--  binary semaphore as described in the VxWorks Programmer's Manual.
42
--
43
--  For complete documentation of the operations in this package, please
44
--  consult the VxWorks Programmer's Manual and VxWorks Reference Manual.
45
 
46
pragma Warnings (Off, "*foreign convention*");
47
pragma Warnings (Off, "*add Convention pragma*");
48
--  These are temporary pragmas to suppress warnings about mismatching
49
--  conventions, which will be a problem when we get rid of trampolines ???
50
 
51
with System.VxWorks;
52
 
53
package Interfaces.VxWorks is
54
   pragma Preelaborate;
55
 
56
   ------------------------------------------------------------------------
57
   --  Here is a complete example that shows how to handle the Interrupt 0x14
58
   --  with a direct-vectored interrupt handler in Ada using this package:
59
 
60
   --  with Interfaces.VxWorks; use Interfaces.VxWorks;
61
   --  with System;
62
   --
63
   --  package P is
64
   --
65
   --     Count : Integer;
66
   --     pragma Atomic (Count);
67
   --
68
   --     Level : constant := 1;
69
   --     --  Interrupt level used by this example
70
   --
71
   --     procedure Handler (parameter : System.Address);
72
   --
73
   --  end P;
74
   --
75
   --  package body P is
76
   --
77
   --     procedure Handler (parameter : System.Address) is
78
   --        S : STATUS;
79
   --     begin
80
   --        Count := Count + 1;
81
   --        logMsg ("received an interrupt" & ASCII.LF & ASCII.NUL);
82
   --
83
   --        --  Acknowledge VME interrupt
84
   --        S := sysBusIntAck (intLevel => Level);
85
   --     end Handler;
86
   --  end P;
87
   --
88
   --  with Interfaces.VxWorks; use Interfaces.VxWorks;
89
   --  with Ada.Text_IO; use Ada.Text_IO;
90
   --
91
   --  with P; use P;
92
   --  procedure Useint is
93
   --     --  Be sure to use a reasonable interrupt number for the target
94
   --     --  board!
95
   --     --  This one is the unused VME graphics interrupt on the PPC MV2604
96
   --     Interrupt : constant := 16#14#;
97
   --
98
   --     task T;
99
   --
100
   --     S : STATUS;
101
   --
102
   --     task body T is
103
   --     begin
104
   --        loop
105
   --           Put_Line ("Generating an interrupt...");
106
   --           delay 1.0;
107
   --
108
   --           --  Generate VME interrupt, using interrupt number
109
   --           S := sysBusIntGen (1, Interrupt);
110
   --        end loop;
111
   --     end T;
112
   --
113
   --  begin
114
   --     S := sysIntEnable (intLevel => Level);
115
   --     S := intConnect (INUM_TO_IVEC (Interrupt), handler'Access);
116
   --
117
   --     loop
118
   --        delay 2.0;
119
   --        Put_Line ("value of count:" & P.Count'Img);
120
   --     end loop;
121
   --  end Useint;
122
   -------------------------------------
123
 
124
   subtype int is Integer;
125
 
126
   type STATUS is new int;
127
   --  Equivalent of the C type STATUS
128
 
129
   OK    : constant STATUS := 0;
130
   ERROR : constant STATUS := -1;
131
 
132
   type VOIDFUNCPTR is access procedure (parameter : System.Address);
133
   type Interrupt_Vector is new System.Address;
134
   type Exception_Vector is new System.Address;
135
 
136
   function intConnect
137
     (vector    : Interrupt_Vector;
138
      handler   : VOIDFUNCPTR;
139
      parameter : System.Address := System.Null_Address) return STATUS;
140
   --  Binding to the C routine intConnect. Use this to set up an
141
   --  user handler. The routine generates a wrapper around the user
142
   --  handler to save and restore context
143
 
144
   function intContext return int;
145
   --  Binding to the C routine intContext. This function returns 1 only
146
   --  if the current execution state is in interrupt context.
147
 
148
   function intVecGet
149
     (Vector : Interrupt_Vector) return VOIDFUNCPTR;
150
   --  Binding to the C routine intVecGet. Use this to get the
151
   --  existing handler for later restoral
152
 
153
   procedure intVecSet
154
     (Vector  : Interrupt_Vector;
155
      Handler : VOIDFUNCPTR);
156
   --  Binding to the C routine intVecSet. Use this to restore a
157
   --  handler obtained using intVecGet
158
 
159
   function INUM_TO_IVEC (intNum : int) return Interrupt_Vector;
160
   --  Equivalent to the C macro INUM_TO_IVEC used to convert an interrupt
161
   --  number to an interrupt vector
162
 
163
   function sysIntEnable (intLevel : int) return STATUS;
164
   --  Binding to the C routine sysIntEnable
165
 
166
   function sysIntDisable (intLevel : int) return STATUS;
167
   --  Binding to the C routine sysIntDisable
168
 
169
   function sysBusIntAck (intLevel : int) return STATUS;
170
   --  Binding to the C routine sysBusIntAck
171
 
172
   function sysBusIntGen (intLevel : int; Intnum : int) return STATUS;
173
   --  Binding to the C routine sysBusIntGen. Note that the T2
174
   --  documentation implies that a vector address is the proper
175
   --  argument - it's not. The interrupt number in the range
176
   --  0 .. 255 (for 68K and PPC) is the correct argument.
177
 
178
   procedure logMsg
179
     (fmt : String; arg1, arg2, arg3, arg4, arg5, arg6 : int := 0);
180
   --  Binding to the C routine logMsg. Note that it is the caller's
181
   --  responsibility to ensure that fmt is a null-terminated string
182
   --  (e.g logMsg ("Interrupt" & ASCII.NUL))
183
 
184
   type FP_CONTEXT is private;
185
   --  Floating point context save and restore. Handlers using floating
186
   --  point must be bracketed with these calls. The pFpContext parameter
187
   --  should be an object of type FP_CONTEXT that is
188
   --  declared local to the handler.
189
 
190
   procedure fppRestore (pFpContext : in out FP_CONTEXT);
191
   --  Restore floating point context
192
 
193
   procedure fppSave (pFpContext : in out FP_CONTEXT);
194
   --  Save floating point context
195
 
196
private
197
 
198
   type FP_CONTEXT is new System.VxWorks.FP_CONTEXT;
199
   --  Target-dependent floating point context type
200
 
201
   pragma Import (C, intConnect, "intConnect");
202
   pragma Import (C, intContext, "intContext");
203
   pragma Import (C, intVecGet, "intVecGet");
204
   pragma Import (C, intVecSet, "intVecSet");
205
   pragma Import (C, INUM_TO_IVEC, "__gnat_inum_to_ivec");
206
   pragma Import (C, sysIntEnable, "sysIntEnable");
207
   pragma Import (C, sysIntDisable, "sysIntDisable");
208
   pragma Import (C, sysBusIntAck, "sysBusIntAck");
209
   pragma Import (C, sysBusIntGen, "sysBusIntGen");
210
   pragma Import (C, logMsg, "logMsg");
211
   pragma Import (C, fppRestore, "fppRestore");
212
   pragma Import (C, fppSave, "fppSave");
213
end Interfaces.VxWorks;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.