Coding-style and whitespace fixes (also to make the code more similar
[coreboot.git] / src / console / console.c
blob86ec26d3129997f455f708843e517e2b7a69f215
1 /*
2 * Bootstrap code for the INTEL
3 */
5 #include <arch/io.h>
6 #include <console/console.h>
7 #include <string.h>
8 #include <pc80/mc146818rtc.h>
11 static int initialized;
13 /* initialize the console */
14 void console_init(void)
16 struct console_driver *driver;
17 if(get_option(&console_loglevel, "debug_level"))
18 console_loglevel=DEFAULT_CONSOLE_LOGLEVEL;
20 for(driver = console_drivers; driver < econsole_drivers; driver++) {
21 if (!driver->init)
22 continue;
23 driver->init();
25 initialized = 1;
28 static void __console_tx_byte(unsigned char byte)
30 struct console_driver *driver;
31 for(driver = console_drivers; driver < econsole_drivers; driver++) {
32 driver->tx_byte(byte);
36 void console_tx_flush(void)
38 struct console_driver *driver;
39 for(driver = console_drivers; driver < econsole_drivers; driver++) {
40 if (!driver->tx_flush)
41 continue;
42 driver->tx_flush();
46 void console_tx_byte(unsigned char byte)
48 if (!initialized)
49 return;
50 if (byte == '\n')
51 __console_tx_byte('\r');
52 __console_tx_byte(byte);
55 unsigned char console_rx_byte(void)
57 struct console_driver *driver;
58 if (!initialized)
59 return 0;
60 for(driver = console_drivers; driver < econsole_drivers; driver++) {
61 if (driver->tst_byte)
62 break;
64 if (driver == econsole_drivers)
65 return 0;
66 while (!driver->tst_byte());
67 return driver->rx_byte();
70 int console_tst_byte(void)
72 struct console_driver *driver;
73 if (!initialized)
74 return 0;
75 for(driver = console_drivers; driver < econsole_drivers; driver++)
76 if (driver->tst_byte)
77 return driver->tst_byte();
78 return 0;
82 * Write POST information
84 void post_code(uint8_t value)
86 #if NO_POST==0
87 #if CONFIG_SERIAL_POST==1
88 printk_emerg("POST: 0x%02x\n", value);
89 #endif
90 outb(value, 0x80);
91 #endif
94 /* Report a fatal error */
95 void die(const char *msg)
97 printk_emerg("%s", msg);
98 post_code(0xff);
99 while (1); /* Halt */