Elyes HAOUAS | fbf3a47 | 2020-05-09 13:22:30 +0200 | [diff] [blame] | 1 | -- SPDX-License-Identifier: GPL-2.0-only |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 2 | |
| 3 | with Interfaces.C; |
| 4 | |
| 5 | use type Interfaces.C.int; |
| 6 | |
| 7 | package body HW.Debug_Sink is |
| 8 | |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 9 | function console_log_level |
| 10 | (msg_level : Interfaces.C.int) |
| 11 | return Interfaces.C.int; |
| 12 | pragma Import (C, console_log_level, "console_log_level"); |
| 13 | |
| 14 | Msg_Level_BIOS_DEBUG : constant := 7; |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 15 | |
| 16 | procedure console_tx_byte (chr : Interfaces.C.char); |
| 17 | pragma Import (C, console_tx_byte, "console_tx_byte"); |
| 18 | |
| 19 | procedure Put (Item : String) is |
| 20 | begin |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 21 | if console_log_level (Msg_Level_BIOS_DEBUG) /= 0 then |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 22 | for Idx in Item'Range loop |
| 23 | console_tx_byte (Interfaces.C.To_C (Item (Idx))); |
| 24 | end loop; |
| 25 | end if; |
| 26 | end Put; |
| 27 | |
| 28 | procedure Put_Char (Item : Character) is |
| 29 | begin |
Nico Huber | 4a00ccc | 2018-06-04 15:10:54 +0200 | [diff] [blame] | 30 | if console_log_level (Msg_Level_BIOS_DEBUG) /= 0 then |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 31 | console_tx_byte (Interfaces.C.To_C (Item)); |
| 32 | end if; |
| 33 | end Put_Char; |
| 34 | |
| 35 | procedure New_Line is |
| 36 | begin |
| 37 | Put_Char (Character'Val (16#0a#)); |
| 38 | end New_Line; |
| 39 | |
Nico Huber | c83239e | 2016-10-05 17:46:49 +0200 | [diff] [blame] | 40 | end HW.Debug_Sink; |