File : s-bbpara-tms570.ads


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                  GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                --
   4 --                                                                          --
   5 --                   S Y S T E M . B B . P A R A M E T E R S                --
   6 --                                                                          --
   7 --                                  S p e c                                 --
   8 --                                                                          --
   9 --        Copyright (C) 1999-2002 Universidad Politecnica de Madrid         --
  10 --             Copyright (C) 2003-2005 The European Space Agency            --
  11 --                     Copyright (C) 2003-2016, 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 --  This package defines basic parameters used by the low level tasking system
  38 
  39 --  This is the TMS570 (ARMv7) version of this package
  40 
  41 pragma Restrictions (No_Elaboration_Code);
  42 
  43 package System.BB.Parameters is
  44    pragma Pure;
  45 
  46    --------------------
  47    -- Hardware clock --
  48    --------------------
  49 
  50    Clock_Frequency : constant Natural := 180_000_000;
  51    --  Frequency of the CPU clock in Hz. We hard-code this hear to allow static
  52    --  computation of the required prescaler.
  53 
  54    RTI_kHz : constant := Clock_Frequency / 2000;
  55    --  Period of the unscaled clock in kHz. Assuming the clock frequency is
  56    --  an integral number of kHz allows for sufficient precision with typical
  57    --  clock frequencies. Account for the implicit 2x clock divider.
  58 
  59    pragma Assert (RTI_kHz in 100 .. 1_000_000, "Invalid RTI_FREQ");
  60    --  The system clock frequency has to be between 100 kHz and 1 GHz
  61 
  62    --  Try clock periods of 100 ns, 125 ns, 200 ns, 250 ns, 500 ns, 1 us,
  63    --  correspondsing to 10 MHz, 8 MHz, 5 MHz, 4 MHz, 2MHz, 1 MHz frequencies.
  64    --  This will get a fast clock, where each period is an integral number
  65    --  of nanoseconds, which is important for accurate conversions.
  66 
  67    --  For other input frequencies, try scaling the clock down to about 10 Mhz,
  68    --  while leaving Ticks_Per_Second exact.
  69 
  70    --  This will a few minutes before the 32-bit timer will wrap around
  71 
  72    Prescaler : constant :=
  73      (if    RTI_kHz mod 10_000 = 0 then RTI_kHz / 10_000  -- 10 MHz,   100 ns
  74       elsif RTI_kHz mod  8_000 = 0 then RTI_kHz /  8_000  --  8 MHz,   125 ns
  75       elsif RTI_kHz mod  5_000 = 0 then RTI_kHz /  5_000  --  5 MHz,   250 ns
  76       elsif RTI_kHz mod  4_000 = 0 then RTI_kHz /  4_000  --  4 MHz,   200 ns
  77       elsif RTI_kHz mod  2_000 = 0 then RTI_kHz /  2_000  --  2 MHz,   500 ns
  78       elsif RTI_kHz mod  1_000 = 0 then RTI_kHz /  1_000  --  1 MHz, 1_000 ns
  79       elsif RTI_kHz >= 100_000 then 10 --   10 MHz .. 50 MHz, 20 ..    100 ns
  80       elsif RTI_kHz >=  40_000 then  5 --    8 MHz .. 20 MHz, 50 ..    125 ns
  81       else 2);                         --   50 kHz .. 20 Mhz, 50 .. 20_000 ns
  82 
  83    Ticks_Per_Second : constant := (RTI_kHz * 1000) / Prescaler;
  84    --  Number of ticks per second
  85 
  86    ----------------
  87    -- Interrupts --
  88    ----------------
  89 
  90    --  These definitions are in this package in order to isolate target
  91    --  dependencies.
  92 
  93    Number_Of_Interrupt_ID : constant := 95;
  94    --  Number of interrupts supported by the VIC. For the TMS570 interrupts,
  95    --  we really only consider the 95 usable interrupt channels. The run time
  96    --  assumes the interrupt source to interrupt channel map is direct (1:1),
  97    --  as is the default, but the user can change this as long as the IRQ used
  98    --  by the system for alarms stays unchanged.
  99 
 100    Trap_Vectors : constant := 7;
 101    --  ARM in general has these traps:
 102    --    0   (at 16#0000#) Reset
 103    --    1   (at 16#0004#) Undefined Instruction (synchronous)
 104    --    2   (at 16#0008#) Supervisor Call (synchronous)
 105    --    3   (at 16#000C#) Abort - Prefetch (synchronous)
 106    --    4   (at 16#0010#) Abort - Data (asynchronous)
 107    --    5   (at 16#0014#) IRQ Trap (asynchronous)
 108    --    6   (at 16#0018#) FIQ Trap (asynchronous)
 109 
 110    ------------------------
 111    -- Context Management --
 112    ------------------------
 113 
 114    --  The run time stores a minimal amount of state in the thread context.
 115    --  Most state will be saved on the task's stack when calling a potentially
 116    --  blocking operation, or on the interrupt stack when the task is pre-
 117    --  empted. Most of the space is currently required for floating point
 118    --  state, which is saved lazily.
 119 
 120    --  The TMS570 processor needs to save:
 121 
 122    --   * 6 integer registers of 32 bits (r0, r1, PC, CPSR, R12, SP)
 123    --     for normal processing
 124 
 125    --   * 33 floating point registers of 32 bits (s0 .. s31, FPCSR)
 126 
 127    --  This amounts to 39 registers, rounded up to 40 for alignment.
 128 
 129    Context_Buffer_Capacity : constant := 40;
 130 
 131    ------------
 132    -- Stacks --
 133    ------------
 134 
 135    Interrupt_Stack_Size : constant := 4096;  --  bytes
 136    --  Size of each of the interrupt stacks. Each processor has its own
 137    --  set of interrupt stacks, one per interrupt priority.
 138 
 139    Interrupt_Sec_Stack_Size : constant := 128;
 140    --  Size of the secondary stack for interrupt handlers
 141 
 142    ----------
 143    -- CPUS --
 144    ----------
 145 
 146    Max_Number_Of_CPUs : constant := 1;
 147    --  Maximum number of CPUs
 148 
 149    Multiprocessor : constant Boolean := Max_Number_Of_CPUs /= 1;
 150    --  Are we on a multiprocessor board?
 151 
 152 end System.BB.Parameters;