blob: 5a165562dc91f5902dd565e5d97542fa4d448fcc [file] [log] [blame]
Nico Huberc83239e2016-10-05 17:46:49 +02001--
2-- This file is part of the coreboot project.
3--
4-- Copyright (C) 2015 secunet Security Networks AG
5--
6-- This program is free software; you can redistribute it and/or modify
7-- it under the terms of the GNU General Public License as published by
8-- the Free Software Foundation; version 2 of the License.
9--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-- GNU General Public License for more details.
14--
15
16with Interfaces.C;
17
18use type Interfaces.C.int;
19
20package body HW.Debug_Sink is
21
22 Sink_Enabled : Boolean;
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) is
28 begin
29 if Sink_Enabled then
30 for Idx in Item'Range loop
31 console_tx_byte (Interfaces.C.To_C (Item (Idx)));
32 end loop;
33 end if;
34 end Put;
35
36 procedure Put_Char (Item : Character) is
37 begin
38 if Sink_Enabled then
39 console_tx_byte (Interfaces.C.To_C (Item));
40 end if;
41 end Put_Char;
42
43 procedure New_Line is
44 begin
45 Put_Char (Character'Val (16#0a#));
46 end New_Line;
47
48 ----------------------------------------------------------------------------
49
50 function console_log_level
51 (msg_level : Interfaces.C.int)
52 return Interfaces.C.int;
53 pragma Import (C, console_log_level, "console_log_level");
54
55 Msg_Level_BIOS_DEBUG : constant := 7;
56
57begin
58 Sink_Enabled := console_log_level (Msg_Level_BIOS_DEBUG) /= 0;
59end HW.Debug_Sink;