gnat_riscv64_elf_13.2.1_938f208c/riscv64-elf/lib/gnat/light-tasking-polarfiresoc/gnarl/s-bbbosu.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
------------------------------------------------------------------------------
--                                                                          --
--                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
--                                                                          --
--                S Y S T E M . B B . B O A R D _ S U P P O R T             --
--                                                                          --
--                                  S p e c                                 --
--                                                                          --
--        Copyright (C) 1999-2002 Universidad Politecnica de Madrid         --
--             Copyright (C) 2003-2006 The European Space Agency            --
--                     Copyright (C) 2003-2023, AdaCore                     --
--                                                                          --
-- GNARL is free software; you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
--                                                                          --
-- GNARL was developed by the GNARL team at Florida State University.       --
-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
--                                                                          --
-- The port of GNARL to bare board targets was initially developed by the   --
-- Real-Time Systems Group at the Technical University of Madrid.           --
--                                                                          --
------------------------------------------------------------------------------

--  This package defines an interface used for handling the peripherals
--  available in the target board that are needed by the target-independent
--  part of the run time.

pragma Restrictions (No_Elaboration_Code);

with System.Multiprocessors;
with System.BB.Interrupts;
with System.BB.Time;

package System.BB.Board_Support is
   pragma Preelaborate;

   -----------------------------
   -- Hardware Initialization --
   -----------------------------

   procedure Initialize_Board;
   --  Procedure that performs the hardware initialization of the board. Should
   --  be called before any other operations in this package.

   ------------------------------------------------
   -- Clock and Timer Definitions and Primitives --
   ------------------------------------------------

   package Time is
      function Read_Clock return BB.Time.Time;
      --  Read the value contained in the clock hardware counter, and return
      --  the number of ticks elapsed since the last clock interrupt, that is,
      --  since the clock counter was last reloaded.

      procedure Set_Alarm (Ticks : BB.Time.Time);
      --  Sets an alarm as an absolute time. The interrupt will be raised when
      --  the clock reaches 'Ticks'.
      --  This cancels any previous alarm set.

      procedure Install_Alarm_Handler (Handler : Interrupts.Interrupt_Handler);
      --  Install Handler as alarm interrupt handler

      procedure Clear_Alarm_Interrupt;
      pragma Inline (Clear_Alarm_Interrupt);
      --  Acknowledge the alarm interrupt
   end Time;

   ----------------
   -- Interrupts --
   ----------------

   package Interrupts is
      function Priority_Of_Interrupt
        (Interrupt : System.BB.Interrupts.Interrupt_ID)
        return System.Any_Priority;
      pragma Inline (Priority_Of_Interrupt);
      --  Function to obtain the priority associated with an interrupt.

      procedure Install_Interrupt_Handler
        (Interrupt : System.BB.Interrupts.Interrupt_ID;
         Prio      : Interrupt_Priority);
      --  Determine the trap vector that will be called for handling the given
      --  external interrupt on the current CPU, and install the given handler
      --  there. It is an error to try to install two different handlers for
      --  the vector, though this procedure may be called for multiple
      --  interrupts that share the same vector, as long as they use the same
      --  handler. The handler expects a single argument indicating the vector
      --  called. This routine may need to set up the interrupt controller to
      --  enable the given interrupt source, so it will actually cause a trap
      --  on the CPU. Note, this should not actually enable interrupts, as this
      --  is only done through CPU_Primitives.Enable_Interrupts, which
      --  typically uses a processor status register. Prio is the priority for
      --  the interrupt, and the hardware can be programmed to use that
      --  priority.

      procedure Set_Current_Priority (Priority : Integer);
      pragma Inline (Set_Current_Priority);
      --  Only allow interrupts higher than the specified priority. This
      --  routine differes from the Enable_Interrupts/Disable_Interrupts
      --  procedures in CPU_Primitives in that it disables interrupts at the
      --  board level, rather than the CPU. Typically if board-specific support
      --  of an interrupt controller is needed to block interrupts of
      --  insufficient priority, this routine will be needed. On other systems,
      --  where the processor has this control, or where only a single
      --  interrupt priority is supported, this may be a null procedure.

      procedure Power_Down;
      pragma Inline (Power_Down);
      --  Power-down the current CPU. This procedure is called only by the idle
      --  task, with interrupt enabled.
   end Interrupts;

   package Multiprocessors is
      --  The following functions define an interface for handling the "poke"
      --  interrupts that are used to signal other processors in an
      --  multiprocessor system.

      function Number_Of_CPUs return System.Multiprocessors.CPU;
      pragma Inline (Number_Of_CPUs);
      --  Return the number of available CPUs on the target

      function Current_CPU return System.Multiprocessors.CPU;
      pragma Inline (Current_CPU);
      --  Return the id of the current CPU

      procedure Poke_CPU (CPU_Id : System.Multiprocessors.CPU);
      --  Poke the given CPU to signal that a rescheduling may be required

      procedure Start_All_CPUs;
      --  Start all slave CPUs
   end Multiprocessors;
end System.BB.Board_Support;