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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [gcc/] [ada/] [i-vxwork.ads] - Blame information for rev 593

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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