2 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
20 #ifndef CONFIG_SYS_COREBOOT
21 #error This driver requires coreboot
24 #include <asm/arch/sysinfo.h>
26 struct cbmem_console {
30 } __attribute__ ((__packed__));
32 static struct cbmem_console *cbmem_console_p;
34 void cbmemc_putc(struct stdio_dev *dev, char data)
38 cursor = cbmem_console_p->buffer_cursor++;
39 if (cursor < cbmem_console_p->buffer_size)
40 cbmem_console_p->buffer_body[cursor] = data;
43 void cbmemc_puts(struct stdio_dev *dev, const char *str)
47 while ((c = *str++) != 0)
54 struct stdio_dev cons_dev;
55 cbmem_console_p = lib_sysinfo.cbmem_cons;
57 memset(&cons_dev, 0, sizeof(cons_dev));
59 strcpy(cons_dev.name, "cbmem");
60 cons_dev.flags = DEV_FLAGS_OUTPUT; /* Output only */
61 cons_dev.putc = cbmemc_putc;
62 cons_dev.puts = cbmemc_puts;
64 rc = stdio_register(&cons_dev);
66 return (rc == 0) ? 1 : rc;