File : s-bbinte.ads
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . B B . I N T E R R U P T S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
10 -- Copyright (C) 2003-2004 The European Space Agency --
11 -- Copyright (C) 2003-2013, AdaCore --
12 -- --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 3, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. --
19 -- --
20 -- --
21 -- --
22 -- --
23 -- --
24 -- You should have received a copy of the GNU General Public License and --
25 -- a copy of the GCC Runtime Library Exception along with this program; --
26 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
27 -- <http://www.gnu.org/licenses/>. --
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 -- The port of GNARL to bare board targets was initially developed by the --
33 -- Real-Time Systems Group at the Technical University of Madrid. --
34 -- --
35 ------------------------------------------------------------------------------
36
37 -- Package in charge of implementing the basic routines for interrupt
38 -- management.
39
40 pragma Restrictions (No_Elaboration_Code);
41
42 with System;
43 with System.BB.Parameters;
44 with System.Multiprocessors;
45
46 package System.BB.Interrupts is
47 pragma Preelaborate;
48
49 Max_Interrupt : constant := System.BB.Parameters.Number_Of_Interrupt_ID;
50 -- Number of interrupts
51
52 subtype Interrupt_ID is Natural range 0 .. Max_Interrupt;
53 -- Interrupt identifier
54
55 No_Interrupt : constant Interrupt_ID := 0;
56 -- Special value indicating no interrupt
57
58 type Interrupt_Handler is access procedure (Id : Interrupt_ID);
59 -- Prototype of procedures used as low level handlers
60
61 procedure Initialize_Interrupts;
62 -- Initialize table containing the pointers to the different interrupt
63 -- stacks. Should be called before any other subprograms in this package.
64
65 procedure Attach_Handler
66 (Handler : not null Interrupt_Handler;
67 Id : Interrupt_ID;
68 Prio : Interrupt_Priority)
69 with
70 Pre => Id /= No_Interrupt;
71 pragma Inline (Attach_Handler);
72 -- Attach the procedure Handler as handler of the interrupt Id. Prio is
73 -- the priority of the associated protected object. This priority could be
74 -- used to program the hardware priority of the interrupt.
75
76 function Current_Interrupt return Interrupt_ID;
77 -- Function that returns the hardware interrupt currently being handled on
78 -- the current CPU (if any). If no hardware interrupt is being handled the
79 -- returned value is No_Interrupt.
80
81 function Within_Interrupt_Stack
82 (Stack_Address : System.Address) return Boolean;
83 pragma Inline (Within_Interrupt_Stack);
84 -- Function that tells whether the Address passed as argument belongs to
85 -- the interrupt stack that is currently being used on current CPU (if
86 -- any). It returns True if Stack_Address is within the range of the
87 -- interrupt stack being used. False in case Stack_Address is not within
88 -- the interrupt stack (or no interrupt is being handled).
89
90 end System.BB.Interrupts;