Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 1 | -- |
| 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 | |
| 16 | with Interfaces.C; |
| 17 | |
| 18 | use type Interfaces.C.int; |
| 19 | |
| 20 | package body HW.Debug_Sink is |
| 21 | |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 22 | function console_log_level |
| 23 | (msg_level : Interfaces.C.int) |
| 24 | return Interfaces.C.int; |
| 25 | pragma Import (C, console_log_level, "console_log_level"); |
| 26 | |
| 27 | Msg_Level_BIOS_DEBUG : constant := 7; |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 28 | |
| 29 | procedure console_tx_byte (chr : Interfaces.C.char); |
| 30 | pragma Import (C, console_tx_byte, "console_tx_byte"); |
| 31 | |
| 32 | procedure Put (Item : String) is |
| 33 | begin |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 34 | if console_log_level (Msg_Level_BIOS_DEBUG) /= 0 then |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 35 | for Idx in Item'Range loop |
| 36 | console_tx_byte (Interfaces.C.To_C (Item (Idx))); |
| 37 | end loop; |
| 38 | end if; |
| 39 | end Put; |
| 40 | |
| 41 | procedure Put_Char (Item : Character) is |
| 42 | begin |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 43 | if console_log_level (Msg_Level_BIOS_DEBUG) /= 0 then |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 44 | console_tx_byte (Interfaces.C.To_C (Item)); |
| 45 | end if; |
| 46 | end Put_Char; |
| 47 | |
| 48 | procedure New_Line is |
| 49 | begin |
| 50 | Put_Char (Character'Val (16#0a#)); |
| 51 | end New_Line; |
| 52 | |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 53 | end HW.Debug_Sink; |