- Initial checkin of the freebios2 tree
[coreboot.git] / src / console / console.c
1 /*
2  * Bootstrap code for the INTEL 
3  * $Id$
4  *
5  */
6
7 #include <arch/io.h>
8 #include <console/console.h>
9 #include <string.h>
10 #include <pc80/mc146818rtc.h>
11
12
13 static int initialized;
14
15 /* initialize the console */
16 void console_init(void)
17 {
18         struct console_driver *driver;
19         if(get_option(&console_loglevel, "debug_level"))
20                 console_loglevel=DEFAULT_CONSOLE_LOGLEVEL;
21
22         for(driver = console_drivers; driver < econsole_drivers; driver++) {
23                 if (!driver->init)
24                         continue;
25                 driver->init();
26         }
27         initialized = 1;
28 }
29
30 static void __console_tx_byte(unsigned char byte)
31 {
32         struct console_driver *driver;
33         for(driver = console_drivers; driver < econsole_drivers; driver++) {
34                 driver->tx_byte(byte);
35         }
36 }
37
38 void console_tx_flush(void)
39 {
40         struct console_driver *driver;
41         for(driver = console_drivers; driver < econsole_drivers; driver++) {
42                 if (!driver->tx_flush) 
43                         continue;
44                 driver->tx_flush();
45         }
46 }
47
48 void console_tx_byte(unsigned char byte)
49 {
50         if (!initialized)
51                 return;
52         if (byte == '\n')
53                 __console_tx_byte('\r');
54         __console_tx_byte(byte);
55 }
56
57 /*
58  *    Write POST information
59  */
60 void post_code(uint8_t value)
61 {
62 #ifdef CONFIG_SERIAL_POST
63         printk_info("POST: 0x%02x\n", value);
64 #elsif !define(NO_POST)
65         outb(value, 0x80);
66 #endif
67 }
68
69 /* Report a fatal error */
70 void die(char *msg)
71 {
72         printk_emerg("%s", msg);
73         post_code(0xff);
74         while (1);              /* Halt */
75 }