Debian Codegraph @

src/console/hw-debug_sink.adb

raw
1 -- SPDX-License-Identifier: GPL-2.0-only
2
3 with Interfaces.C;
4 with CB.Config;
5
6 use CB;
7 use type Interfaces.C.int;
8
9 package body HW.Debug_Sink is
10
11 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;
17
18 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
24 procedure console_tx_byte (chr : Interfaces.C.char);
25 pragma Import (C, console_tx_byte, "console_tx_byte");
26
27 procedure Put (Item : String)
28 is
29 console_log : constant Interfaces.C.int :=
30 console_log_level (Msg_Level_BIOS_DEBUG);
31 begin
32 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
39 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
45 procedure Put_Char (Item : Character)
46 is
47 console_log : constant Interfaces.C.int :=
48 console_log_level (Msg_Level_BIOS_DEBUG);
49 begin
50 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
55 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
64 end HW.Debug_Sink;