blob: 6a2889de8f925999f7c2f1638fa455d31c164ed8 [file] [log] [blame]
Elyes HAOUASfbf3a472020-05-09 13:22:30 +02001-- SPDX-License-Identifier: GPL-2.0-only
Nico Huberc83239e2016-10-05 17:46:49 +02002
3with Interfaces.C;
Nico Huber12441dc2021-07-27 13:46:55 +00004with CB.Config;
Nico Huberc83239e2016-10-05 17:46:49 +02005
Nico Huber12441dc2021-07-27 13:46:55 +00006use CB;
Nico Huberc83239e2016-10-05 17:46:49 +02007use type Interfaces.C.int;
8
9package body HW.Debug_Sink is
10
Nico Huber4a00ccc2018-06-04 15:10:54 +020011 function console_log_level
12 (msg_level : Interfaces.C.int)
13 return Interfaces.C.int;
14 pragma Import (C, console_log_level, "console_log_level");
15
16 Msg_Level_BIOS_DEBUG : constant := 7;
Nico Huberc83239e2016-10-05 17:46:49 +020017
Nico Huber12441dc2021-07-27 13:46:55 +000018 CONSOLE_LOG_FAST : constant := 1;
19 CONSOLE_LOG_ALL : constant := 2;
20
21 procedure cbmemc_tx_byte (chr : Interfaces.C.char);
22 pragma Import (C, cbmemc_tx_byte, "cbmemc_tx_byte");
23
Nico Huberc83239e2016-10-05 17:46:49 +020024 procedure console_tx_byte (chr : Interfaces.C.char);
25 pragma Import (C, console_tx_byte, "console_tx_byte");
26
Nico Huber12441dc2021-07-27 13:46:55 +000027 procedure Put (Item : String)
28 is
29 console_log : constant Interfaces.C.int :=
30 console_log_level (Msg_Level_BIOS_DEBUG);
Nico Huberc83239e2016-10-05 17:46:49 +020031 begin
Nico Huber12441dc2021-07-27 13:46:55 +000032 if console_log = CONSOLE_LOG_FAST then
33 if Config.CONSOLE_CBMEM then
34 for Idx in Item'Range loop
35 cbmemc_tx_byte (Interfaces.C.To_C (Item (Idx)));
36 end loop;
37 end if;
38 elsif console_log = CONSOLE_LOG_ALL then
Nico Huberc83239e2016-10-05 17:46:49 +020039 for Idx in Item'Range loop
40 console_tx_byte (Interfaces.C.To_C (Item (Idx)));
41 end loop;
42 end if;
43 end Put;
44
Nico Huber12441dc2021-07-27 13:46:55 +000045 procedure Put_Char (Item : Character)
46 is
47 console_log : constant Interfaces.C.int :=
48 console_log_level (Msg_Level_BIOS_DEBUG);
Nico Huberc83239e2016-10-05 17:46:49 +020049 begin
Nico Huber12441dc2021-07-27 13:46:55 +000050 if console_log = CONSOLE_LOG_FAST then
51 if Config.CONSOLE_CBMEM then
52 cbmemc_tx_byte (Interfaces.C.To_C (Item));
53 end if;
54 elsif console_log = CONSOLE_LOG_ALL then
Nico Huberc83239e2016-10-05 17:46:49 +020055 console_tx_byte (Interfaces.C.To_C (Item));
56 end if;
57 end Put_Char;
58
59 procedure New_Line is
60 begin
61 Put_Char (Character'Val (16#0a#));
62 end New_Line;
63
Nico Huberc83239e2016-10-05 17:46:49 +020064end HW.Debug_Sink;