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);
49 #if CONFIG_CONSOLE_CBMEM
54 static void __console_tx_nibble(unsigned nibble)
61 __console_tx_byte(digit);
64 static void __console_tx_char(int loglevel, unsigned char byte)
66 if (console_loglevel >= loglevel) {
67 #if CONFIG_CONSOLE_SERIAL8250
68 uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
70 #if CONFIG_CONSOLE_NE2K
71 ne2k_append_data_byte(byte, CONFIG_CONSOLE_NE2K_IO_PORT);
72 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
77 static void __console_tx_hex8(int loglevel, unsigned char value)
79 if (console_loglevel >= loglevel) {
80 __console_tx_nibble((value >> 4U) & 0x0fU);
81 __console_tx_nibble(value & 0x0fU);
83 #if CONFIG_CONSOLE_NE2K
84 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
88 static void __console_tx_hex16(int loglevel, unsigned short value)
90 if (console_loglevel >= loglevel) {
91 __console_tx_nibble((value >> 12U) & 0x0fU);
92 __console_tx_nibble((value >> 8U) & 0x0fU);
93 __console_tx_nibble((value >> 4U) & 0x0fU);
94 __console_tx_nibble(value & 0x0fU);
96 #if CONFIG_CONSOLE_NE2K
97 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
101 static void __console_tx_hex32(int loglevel, unsigned int value)
103 if (console_loglevel >= loglevel) {
104 __console_tx_nibble((value >> 28U) & 0x0fU);
105 __console_tx_nibble((value >> 24U) & 0x0fU);
106 __console_tx_nibble((value >> 20U) & 0x0fU);
107 __console_tx_nibble((value >> 16U) & 0x0fU);
108 __console_tx_nibble((value >> 12U) & 0x0fU);
109 __console_tx_nibble((value >> 8U) & 0x0fU);
110 __console_tx_nibble((value >> 4U) & 0x0fU);
111 __console_tx_nibble(value & 0x0fU);
113 #if CONFIG_CONSOLE_NE2K
114 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
118 static void __console_tx_string(int loglevel, const char *str)
120 if (console_loglevel >= loglevel) {
122 while((ch = *str++) != '\0') {
124 __console_tx_byte('\r');
125 __console_tx_byte(ch);
127 #if CONFIG_CONSOLE_NE2K
128 ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
133 /* if included by romcc, include the sources, too. romcc can't use prototypes */
134 #include <console/console.c>
135 #include <console/post.c>
136 #include <console/die.c>