2 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
4 * SPDX-License-Identifier: GPL-2.0
9 #ifndef CONFIG_SYS_COREBOOT
10 #error This driver requires coreboot
13 #include <asm/arch/sysinfo.h>
15 struct cbmem_console {
19 } __attribute__ ((__packed__));
21 static struct cbmem_console *cbmem_console_p;
23 void cbmemc_putc(struct stdio_dev *dev, char data)
27 cursor = cbmem_console_p->buffer_cursor++;
28 if (cursor < cbmem_console_p->buffer_size)
29 cbmem_console_p->buffer_body[cursor] = data;
32 void cbmemc_puts(struct stdio_dev *dev, const char *str)
36 while ((c = *str++) != 0)
43 struct stdio_dev cons_dev;
44 cbmem_console_p = lib_sysinfo.cbmem_cons;
46 memset(&cons_dev, 0, sizeof(cons_dev));
48 strcpy(cons_dev.name, "cbmem");
49 cons_dev.flags = DEV_FLAGS_OUTPUT; /* Output only */
50 cons_dev.putc = cbmemc_putc;
51 cons_dev.puts = cbmemc_puts;
53 rc = stdio_register(&cons_dev);
55 return (rc == 0) ? 1 : rc;