Change console code to emit SPEW with DEFAULT_CONSOLE_LOGLEVEL==8.
[coreboot.git] / src / console / console.c
1 /*
2  * Bootstrap code for the INTEL 
3  */
4
5 #include <arch/io.h>
6 #include <console/console.h>
7 #include <string.h>
8 #include <pc80/mc146818rtc.h>
9
10
11 /* initialize the console */
12 void console_init(void)
13 {
14         struct console_driver *driver;
15         if(get_option(&console_loglevel, "debug_level"))
16                 console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
17         
18         for(driver = console_drivers; driver < econsole_drivers; driver++) {
19                 if (!driver->init)
20                         continue;
21                 driver->init();
22         }
23 }
24
25 static void __console_tx_byte(unsigned char byte)
26 {
27         struct console_driver *driver;
28         for(driver = console_drivers; driver < econsole_drivers; driver++) {
29                 driver->tx_byte(byte);
30         }
31 }
32
33 void console_tx_flush(void)
34 {
35         struct console_driver *driver;
36         for(driver = console_drivers; driver < econsole_drivers; driver++) {
37                 if (!driver->tx_flush) 
38                         continue;
39                 driver->tx_flush();
40         }
41 }
42
43 void console_tx_byte(unsigned char byte)
44 {
45         if (byte == '\n')
46                 __console_tx_byte('\r');
47         __console_tx_byte(byte);
48 }
49
50 unsigned char console_rx_byte(void)
51 {
52         struct console_driver *driver;
53         for(driver = console_drivers; driver < econsole_drivers; driver++) {
54                 if (driver->tst_byte)
55                         break;
56         }
57         if (driver == econsole_drivers)
58                 return 0;
59         while (!driver->tst_byte());
60         return driver->rx_byte();
61 }
62
63 int console_tst_byte(void)
64 {
65         struct console_driver *driver;
66         for(driver = console_drivers; driver < econsole_drivers; driver++)
67                 if (driver->tst_byte)
68                         return driver->tst_byte();
69         return 0;
70 }
71
72 /*
73  *    Write POST information
74  */
75 void post_code(uint8_t value)
76 {
77 #if !defined(CONFIG_NO_POST) || CONFIG_NO_POST==0
78 #if CONFIG_SERIAL_POST==1
79         printk_emerg("POST: 0x%02x\n", value);
80 #endif
81         outb(value, 0x80);
82 #endif
83 }