File : g-io-put-leon3.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- G N A T . I O . P U T --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2012, AdaCore --
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 -- LEON3 version of text output routine
33
34 with System;
35
36 separate (GNAT.IO)
37 procedure Put (C : Character) is
38
39 -- Minimal version of output routine to output to a APBUART device. A
40 -- description of the UART is in the GRLIB IP Core User’s Manual. The
41 -- address is hardcoded based on default template designs and the default
42 -- configuration of various simulators.
43
44 type Register is mod 2**32;
45
46 UART_Address : constant := 16#8000_0100#;
47
48 UART_Data : Register; -- Write this register to transmit data
49 UART_Status : Register; -- Check this register for transmitter status
50
51 for UART_Data'Address use System'To_Address (UART_Address + 0);
52 for UART_Status'Address use System'To_Address (UART_Address + 4);
53
54 pragma Volatile (UART_Data);
55 pragma Volatile (UART_Status);
56
57 Transmitter_Empty_Bit : constant Register := 2**2;
58 -- When this bit is set, another character can be queued for transmission
59
60 begin
61 -- Busy-wait while the transmitter register is not empty
62
63 while (UART_Status and Transmitter_Empty_Bit) = 0 loop
64 null;
65 end loop;
66
67 UART_Data := Character'Pos (C);
68 end Put;