After this has been brought up many times before, rename src/arch/i386 to
[coreboot.git] / src / arch / x86 / lib / printk_init.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; version 2 of
7  * the License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
17  * MA 02110-1301 USA
18  */
19
20 #include <console/console.h>
21 #include <console/vtxprintf.h>
22 #include <uart8250.h>
23
24 #if CONFIG_CONSOLE_NE2K
25 #include <console/ne2k.h>
26 #endif
27
28 static void console_tx_byte(unsigned char byte)
29 {
30 #if CONFIG_CONSOLE_NE2K
31 #ifdef __PRE_RAM__
32         ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
33 #endif
34 #endif
35         if (byte == '\n')
36                 uart8250_tx_byte(CONFIG_TTYS0_BASE, '\r');
37
38         uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
39 }
40
41 int do_printk(int msg_level, const char *fmt, ...)
42 {
43         va_list args;
44         int i;
45
46         if (msg_level > console_loglevel) {
47                 return 0;
48         }
49
50         va_start(args, fmt);
51         i = vtxprintf(console_tx_byte, fmt, args);
52         va_end(args);
53 #if CONFIG_CONSOLE_NE2K
54         ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
55 #endif
56         return i;
57 }