re-order console output functions, add proper prototypes,
[coreboot.git] / src / arch / ppc / 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 <stdarg.h>
21 #include <console/vtxprintf.h>
22 #include <console/loglevel.h>
23 #include <uart8250.h>
24
25 int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
26
27 void console_tx_byte(unsigned char byte)
28 {
29         if (byte == '\n')
30                 uart8250_tx_byte(CONFIG_TTYS0_BASE, '\r');
31
32         uart8250_tx_byte(CONFIG_TTYS0_BASE, byte);
33 }
34
35 int do_printk(int msg_level, const char *fmt, ...)
36 {
37         va_list args;
38         int i;
39
40         if (msg_level >= console_loglevel) {
41                 return 0;
42         }
43
44         va_start(args, fmt);
45         i = vtxprintf(console_tx_byte, fmt, args);
46         va_end(args);
47
48         return i;
49 }