1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
8 #ifndef CONFIG_SYS_COREBOOT
9 #error This driver requires coreboot
12 #include <asm/arch/sysinfo.h>
14 struct cbmem_console {
18 } __attribute__ ((__packed__));
20 static struct cbmem_console *cbmem_console_p;
22 void cbmemc_putc(struct stdio_dev *dev, char data)
26 cursor = cbmem_console_p->buffer_cursor++;
27 if (cursor < cbmem_console_p->buffer_size)
28 cbmem_console_p->buffer_body[cursor] = data;
31 void cbmemc_puts(struct stdio_dev *dev, const char *str)
35 while ((c = *str++) != 0)
42 struct stdio_dev cons_dev;
43 cbmem_console_p = lib_sysinfo.cbmem_cons;
45 memset(&cons_dev, 0, sizeof(cons_dev));
47 strcpy(cons_dev.name, "cbmem");
48 cons_dev.flags = DEV_FLAGS_OUTPUT; /* Output only */
49 cons_dev.putc = cbmemc_putc;
50 cons_dev.puts = cbmemc_puts;
52 rc = stdio_register(&cons_dev);
54 return (rc == 0) ? 1 : rc;