Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- This file is part of the coreboot project. |
| 3 | -- |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 4 | -- This program is free software; you can redistribute it and/or modify |
| 5 | -- it under the terms of the GNU General Public License as published by |
| 6 | -- the Free Software Foundation; version 2 of the License. |
| 7 | -- |
| 8 | -- This program is distributed in the hope that it will be useful, |
| 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | -- GNU General Public License for more details. |
| 12 | -- |
| 13 | |
| 14 | with Interfaces.C; |
| 15 | |
| 16 | use type Interfaces.C.int; |
| 17 | |
| 18 | package body HW.Debug_Sink is |
| 19 | |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 20 | function console_log_level |
| 21 | (msg_level : Interfaces.C.int) |
| 22 | return Interfaces.C.int; |
| 23 | pragma Import (C, console_log_level, "console_log_level"); |
| 24 | |
| 25 | Msg_Level_BIOS_DEBUG : constant := 7; |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 26 | |
| 27 | procedure console_tx_byte (chr : Interfaces.C.char); |
| 28 | pragma Import (C, console_tx_byte, "console_tx_byte"); |
| 29 | |
| 30 | procedure Put (Item : String) is |
| 31 | begin |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 32 | if console_log_level (Msg_Level_BIOS_DEBUG) /= 0 then |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 33 | for Idx in Item'Range loop |
| 34 | console_tx_byte (Interfaces.C.To_C (Item (Idx))); |
| 35 | end loop; |
| 36 | end if; |
| 37 | end Put; |
| 38 | |
| 39 | procedure Put_Char (Item : Character) is |
| 40 | begin |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 41 | if console_log_level (Msg_Level_BIOS_DEBUG) /= 0 then |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 42 | console_tx_byte (Interfaces.C.To_C (Item)); |
| 43 | end if; |
| 44 | end Put_Char; |
| 45 | |
| 46 | procedure New_Line is |
| 47 | begin |
| 48 | Put_Char (Character'Val (16#0a#)); |
| 49 | end New_Line; |
| 50 | |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 51 | end HW.Debug_Sink; |