File : s-textio-leon.adb


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                         GNAT RUN-TIME COMPONENTS                         --
   4 --                                                                          --
   5 --                       S Y S T E M . T E X T _ I O                        --
   6 --                                                                          --
   7 --                                 B o d y                                  --
   8 --                                                                          --
   9 --          Copyright (C) 1992-2016, Free Software Foundation, Inc.         --
  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 --                                                                          --
  19 --                                                                          --
  20 --                                                                          --
  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 -- GNAT was originally developed  by the GNAT team at  New York University. --
  28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
  29 --                                                                          --
  30 ------------------------------------------------------------------------------
  31 
  32 with System.BB.Board_Parameters;
  33 
  34 package body System.Text_IO is
  35 
  36    -----------
  37    -- Local --
  38    -----------
  39 
  40    type Scaler_12 is mod 2 **  12;
  41    for Scaler_12'Size use  12;
  42 
  43    type Reserved_20 is array (0 .. 19) of Boolean;
  44    for Reserved_20'Size use 20;
  45    pragma Pack (Reserved_20);
  46 
  47    type Reserved_23 is array (0 .. 22) of Boolean;
  48    for Reserved_23'Size use 23;
  49    pragma Pack (Reserved_23);
  50 
  51    type Reserved_24 is array (0 .. 23) of Boolean;
  52    for Reserved_24'Size use 24;
  53    pragma Pack (Reserved_24);
  54 
  55    type Reserved_25 is array (0 .. 24) of Boolean;
  56    for Reserved_25'Size use 25;
  57    pragma Pack (Reserved_25);
  58 
  59    UART_1_Data_Register_Address :
  60      constant System.Address := 16#80000070#;
  61 
  62    UART_1_Status_Register_Address :
  63      constant System.Address := 16#80000074#;
  64 
  65    UART_1_Control_Register_Address :
  66      constant System.Address := 16#80000078#;
  67 
  68    UART_1_Scaler_Register_Address :
  69      constant System.Address := 16#8000007C#;
  70 
  71    type UART_Data_Register is
  72       record
  73          RTD      : Character;
  74          Reserved : Reserved_24;
  75       end record;
  76 
  77    for UART_Data_Register use
  78       record
  79          RTD      at 0 range 24 .. 31;
  80          Reserved at 0 range  0 .. 23;
  81       end record;
  82 
  83    for UART_Data_Register'Size use 32;
  84 
  85    pragma Suppress_Initialization (UART_Data_Register);
  86 
  87    type UART_Status_Register is
  88       record
  89          DR       : Boolean;
  90          TS       : Boolean;
  91          TH       : Boolean;
  92          BR       : Boolean;
  93          OV       : Boolean;
  94          PE       : Boolean;
  95          FE       : Boolean;
  96          Reserved : Reserved_25;
  97       end record;
  98 
  99    for UART_Status_Register use
 100       record
 101          DR       at 0 range 31 .. 31;
 102          TS       at 0 range 30 .. 30;
 103          TH       at 0 range 29 .. 29;
 104          BR       at 0 range 28 .. 28;
 105          OV       at 0 range 27 .. 27;
 106          PE       at 0 range 26 .. 26;
 107          FE       at 0 range 25 .. 25;
 108          Reserved at 0 range  0 .. 24;
 109       end record;
 110 
 111    for UART_Status_Register'Size use 32;
 112 
 113    pragma Suppress_Initialization (UART_Status_Register);
 114 
 115    type UART_Control_Register is
 116       record
 117          RE       : Boolean;
 118          TE       : Boolean;
 119          RI       : Boolean;
 120          TI       : Boolean;
 121          PS       : Boolean;
 122          PE       : Boolean;
 123          FL       : Boolean;
 124          LB       : Boolean;
 125          EC       : Boolean;
 126          Reserved : Reserved_23;
 127       end record;
 128 
 129       for UART_Control_Register use
 130       record
 131          RE       at 0 range 31 .. 31;
 132          TE       at 0 range 30 .. 30;
 133          RI       at 0 range 29 .. 29;
 134          TI       at 0 range 28 .. 28;
 135          PS       at 0 range 27 .. 27;
 136          PE       at 0 range 26 .. 26;
 137          FL       at 0 range 25 .. 25;
 138          LB       at 0 range 24 .. 24;
 139          EC       at 0 range 23 .. 23;
 140          Reserved at 0 range  0 .. 22;
 141       end record;
 142 
 143    for UART_Control_Register'Size use 32;
 144 
 145    pragma Suppress_Initialization (UART_Control_Register);
 146 
 147    type UART_Scaler_Register is
 148       record
 149          UART_Scaler : Scaler_12;
 150          Reserved    : Reserved_20;
 151       end record;
 152 
 153    for UART_Scaler_Register use
 154       record
 155          UART_Scaler at 0 range 20 .. 31;
 156          Reserved    at 0 range  0 .. 19;
 157       end record;
 158 
 159    for UART_Scaler_Register'Size use 32;
 160 
 161    pragma Suppress_Initialization (UART_Scaler_Register);
 162 
 163    UART_1_Data : UART_Data_Register;
 164    pragma Atomic (UART_1_Data);
 165    for UART_1_Data'Address use UART_1_Data_Register_Address;
 166 
 167    UART_1_Status : UART_Status_Register;
 168    pragma Atomic (UART_1_Status);
 169    for UART_1_Status'Address use UART_1_Status_Register_Address;
 170 
 171    UART_1_Control : UART_Control_Register;
 172    pragma Atomic (UART_1_Control);
 173    for UART_1_Control'Address use UART_1_Control_Register_Address;
 174 
 175    UART_1_Scaler : UART_Scaler_Register;
 176    pragma Atomic (UART_1_Scaler);
 177    for UART_1_Scaler'Address use UART_1_Scaler_Register_Address;
 178 
 179    ---------
 180    -- Get --
 181    ---------
 182 
 183    function Get return Character is
 184    begin
 185       --  Will never be called
 186 
 187       raise Program_Error;
 188       return ASCII.NUL;
 189    end Get;
 190 
 191    ----------------
 192    -- Initialize --
 193    ----------------
 194 
 195    procedure Initialize is
 196       Control_Aux : UART_Control_Register;
 197       Scaler_Aux  : UART_Scaler_Register;
 198 
 199    begin
 200       Control_Aux := UART_1_Control;
 201 
 202       Scaler_Aux :=
 203         (UART_Scaler =>
 204            Scaler_12 ((System.BB.Board_Parameters.Clock_Frequency * 10
 205                        / (115200 * 8) - 5) / 10),
 206          Reserved => (others => False));
 207 
 208       Control_Aux.RE := True;
 209       Control_Aux.TE := True;
 210       Control_Aux.RI := False;
 211       Control_Aux.PE := False;
 212       Control_Aux.PS := False;
 213       Control_Aux.FL := False;
 214       Control_Aux.LB := False;
 215       Control_Aux.EC := False;
 216       Control_Aux.Reserved := (others => False);
 217 
 218       UART_1_Control := Control_Aux;
 219       UART_1_Scaler  := Scaler_Aux;
 220 
 221       Initialized := True;
 222    end Initialize;
 223 
 224    -----------------
 225    -- Is_Rx_Ready --
 226    -----------------
 227 
 228    function Is_Rx_Ready return Boolean is
 229    begin
 230       return False;
 231    end Is_Rx_Ready;
 232 
 233    -----------------
 234    -- Is_Tx_Ready --
 235    -----------------
 236 
 237    function Is_Tx_Ready return Boolean is
 238       UART_Status_Aux : constant UART_Status_Register := UART_1_Status;
 239    begin
 240       return UART_Status_Aux.TH;
 241    end Is_Tx_Ready;
 242 
 243    ---------
 244    -- Put --
 245    ---------
 246 
 247    procedure Put (C : Character) is
 248       UART_Tx : constant UART_Data_Register :=
 249                   (RTD => C, Reserved => (others => False));
 250    begin
 251       UART_1_Data := UART_Tx;
 252    end Put;
 253 
 254    ----------------------------
 255    -- Use_Cr_Lf_For_New_Line --
 256    ----------------------------
 257 
 258    function Use_Cr_Lf_For_New_Line return Boolean is
 259    begin
 260       return True;
 261    end Use_Cr_Lf_For_New_Line;
 262 
 263 end System.Text_IO;