d9057d813ab0f196753f919319818fda338aeeab
[coreboot.git] / src / cpu / x86 / smm / smiutil.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 #include <arch/io.h>
23 #include <arch/romcc_io.h>
24 #include <cpu/x86/cache.h>
25 #include <cpu/x86/smm.h>
26
27 #include <console/console.h>
28 #include <console/vtxprintf.h>
29 #if CONFIG_CONSOLE_SERIAL8250 || CONFIG_CONSOLE_SERIAL8250MEM
30 #include <uart8250.h>
31 #endif
32 #if CONFIG_USBDEBUG
33 #include <usbdebug.h>
34 #endif
35 #if CONFIG_CONSOLE_NE2K
36 #include <console/ne2k.h>
37 #endif
38
39 #if CONFIG_CONSOLE_SERIAL8250MEM
40 static u32 serial8250mem_base_address = 0;
41 #endif
42
43 void console_tx_flush(void)
44 {
45         // the tx_byte functions take care of the flush.
46         // if not, this should be implemented.
47 }
48
49 void console_tx_byte(unsigned char byte)
50 {
51         if (byte == '\n')
52                 console_tx_byte('\r');
53
54 #if CONFIG_CONSOLE_SERIAL8250MEM
55         if (serial8250mem_base_address)
56                 uart8250_mem_tx_byte(serial8250mem_base_address, byte);
57 #endif
58 #if CONFIG_CONSOLE_SERIAL8250
59         uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
60 #endif
61 #if CONFIG_USBDEBUG
62         usbdebug_tx_byte(byte);
63 #endif
64 #if CONFIG_CONSOLE_NE2K
65         ne2k_append_data(&byte, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
66 #endif
67 }
68
69 void console_init(void)
70 {
71 #if CONFIG_DEBUG_SMI
72         console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
73 #if CONFIG_CONSOLE_SERIAL8250
74         uart_init();
75 #endif
76 #if CONFIG_CONSOLE_SERIAL8250MEM
77         serial8250mem_base_address = uart_mem_init();
78 #endif
79 #else
80         console_loglevel = 1;
81 #endif
82 }
83