Chromebooks: mainboard.c: Do not spell Chromebook in CamelCase
[coreboot.git] / src / console / console.c
blob34a26ecb51a5512d1da9e3fb40fd9667c17d4aa6
1 /*
2 * This file is part of the coreboot project.
4 * Copyright (C) 2003 Eric Biederman
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #include <console/console.h>
21 #include <build.h>
22 #include <arch/hlt.h>
23 #include <arch/io.h>
25 #ifndef __PRE_RAM__
26 #include <string.h>
29 * FIXME: get_option() needs to be abstracted better so that other non-volatile
30 * storage can be used. This will benefit machines without CMOS as well as those
31 * without a battery-backed CMOS (e.g. some laptops).
33 #if CONFIG_HAVE_CMOS_DEFAULT
34 #include <pc80/mc146818rtc.h>
35 #else
36 static inline int get_option(void *dest, const char *name) { return -1; }
37 #endif
39 /* initialize the console */
40 void console_init(void)
42 struct console_driver *driver;
43 if(get_option(&console_loglevel, "debug_level"))
44 console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
46 for(driver = console_drivers; driver < econsole_drivers; driver++) {
47 if (!driver->init)
48 continue;
49 driver->init();
53 void console_tx_flush(void)
55 struct console_driver *driver;
56 for(driver = console_drivers; driver < econsole_drivers; driver++) {
57 if (!driver->tx_flush)
58 continue;
59 driver->tx_flush();
63 static void __console_tx_byte(unsigned char byte)
65 struct console_driver *driver;
66 for(driver = console_drivers; driver < econsole_drivers; driver++) {
67 driver->tx_byte(byte);
71 void console_tx_byte(unsigned char byte)
73 if (byte == '\n')
74 __console_tx_byte('\r');
75 __console_tx_byte(byte);
78 unsigned char console_rx_byte(void)
80 struct console_driver *driver;
81 for(driver = console_drivers; driver < econsole_drivers; driver++) {
82 if (driver->tst_byte)
83 break;
85 if (driver == econsole_drivers)
86 return 0;
87 while (!driver->tst_byte());
88 return driver->rx_byte();
91 int console_tst_byte(void)
93 struct console_driver *driver;
94 for(driver = console_drivers; driver < econsole_drivers; driver++)
95 if (driver->tst_byte)
96 return driver->tst_byte();
97 return 0;
100 #else // __PRE_RAM__ ^^^ NOT defined vvv defined
102 void console_init(void)
104 #if CONFIG_EARLY_CONSOLE
106 #if CONFIG_USBDEBUG
107 enable_usbdebug(CONFIG_USBDEBUG_DEFAULT_PORT);
108 early_usbdebug_init();
109 #endif
110 #if CONFIG_CONSOLE_SERIAL
111 uart_init();
112 #endif
113 #if CONFIG_DRIVERS_OXFORD_OXPCIE && CONFIG_CONSOLE_SERIAL8250MEM
114 oxford_init();
115 #endif
116 #if CONFIG_CONSOLE_NE2K
117 ne2k_init(CONFIG_CONSOLE_NE2K_IO_PORT);
118 #endif
119 #if CONFIG_CONSOLE_CBMEM
120 cbmemc_init();
121 #endif
122 static const char console_test[] =
123 "\n\ncoreboot-"
124 COREBOOT_VERSION
125 COREBOOT_EXTRA_VERSION
127 COREBOOT_BUILD
128 " starting...\n";
129 print_info(console_test);
131 #endif /* CONFIG_EARLY_CONSOLE */
133 #endif