2 * This file is part of the coreboot project.
4 * Copyright (C) 2003 Eric Biederman
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.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include <console/loglevel.h>
22 #include <console/post_codes.h>
25 /* Using a global varible can cause problems when we reset the stack
26 * from cache as ram to ram. If we make this a define USE_SHARED_STACK
27 * we could use the same code on all architectures.
29 #define console_loglevel CONFIG_DEFAULT_CONSOLE_LOGLEVEL
30 #if CONFIG_CONSOLE_SERIAL8250
34 #if CONFIG_CONSOLE_SERIAL8250
35 #include "lib/uart8250.c"
37 #if CONFIG_CONSOLE_NE2K
41 static void __console_tx_byte(unsigned char byte)
43 #if CONFIG_CONSOLE_SERIAL8250
44 uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
46 #if CONFIG_CONSOLE_NE2K
47 ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
51 static void __console_tx_nibble(unsigned nibble)
58 __console_tx_byte(digit);
61 static void __console_tx_char(int loglevel, unsigned char byte)
63 if (console_loglevel >= loglevel) {
64 #if CONFIG_CONSOLE_SERIAL8250
65 uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
67 #if CONFIG_CONSOLE_NE2K
68 ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
69 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
74 static void __console_tx_hex8(int loglevel, unsigned char value)
76 if (console_loglevel >= loglevel) {
77 __console_tx_nibble((value >> 4U) & 0x0fU);
78 __console_tx_nibble(value & 0x0fU);
80 #if CONFIG_CONSOLE_NE2K
81 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
85 static void __console_tx_hex16(int loglevel, unsigned short value)
87 if (console_loglevel >= loglevel) {
88 __console_tx_nibble((value >> 12U) & 0x0fU);
89 __console_tx_nibble((value >> 8U) & 0x0fU);
90 __console_tx_nibble((value >> 4U) & 0x0fU);
91 __console_tx_nibble(value & 0x0fU);
93 #if CONFIG_CONSOLE_NE2K
94 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
98 static void __console_tx_hex32(int loglevel, unsigned int value)
100 if (console_loglevel >= loglevel) {
101 __console_tx_nibble((value >> 28U) & 0x0fU);
102 __console_tx_nibble((value >> 24U) & 0x0fU);
103 __console_tx_nibble((value >> 20U) & 0x0fU);
104 __console_tx_nibble((value >> 16U) & 0x0fU);
105 __console_tx_nibble((value >> 12U) & 0x0fU);
106 __console_tx_nibble((value >> 8U) & 0x0fU);
107 __console_tx_nibble((value >> 4U) & 0x0fU);
108 __console_tx_nibble(value & 0x0fU);
110 #if CONFIG_CONSOLE_NE2K
111 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
115 static void __console_tx_string(int loglevel, const char *str)
117 if (console_loglevel >= loglevel) {
119 while((ch = *str++) != '\0') {
121 __console_tx_byte('\r');
122 __console_tx_byte(ch);
124 #if CONFIG_CONSOLE_NE2K
125 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
130 /* if included by romcc, include the sources, too. romcc can't use prototypes */
131 #include <console/console.c>
132 #include <console/post.c>
133 #include <console/die.c>