J. Neuschäfer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84214?usp=email )
Change subject: [WIP] src/console: Add read-only flash console ......................................................................
[WIP] src/console: Add read-only flash console
Change-Id: Ie2f7a48e0cc6f7e91129bea9f15a5b7de3bbdfab Signed-off-by: J. Neuschäfer j.ne@posteo.net --- M src/console/Kconfig M src/console/console.c M src/drivers/spi/Makefile.mk A src/drivers/spi/ro_flashconsole.c A src/include/console/ro_flash.h 5 files changed, 66 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/84214/1
diff --git a/src/console/Kconfig b/src/console/Kconfig index db71204..c90c083 100644 --- a/src/console/Kconfig +++ b/src/console/Kconfig @@ -300,6 +300,22 @@ value (128K or 0x20000 bytes) is large enough to accommodate even the BIOS_SPEW level.
+config CONSOLE_RO_FLASH + bool "Read-only flash console" + default n + help + Read-only flash console. (TODO) + +if CONSOLE_RO_FLASH + +config CONSOLE_RO_FLASH_OFFSET + hex "Base offset into flash" + +config CONSOLE_RO_FLASH_SHIFT + int "Bit shift" + +endif # CONSOLE_RO_FLASH + config CONSOLE_I2C_SMBUS bool "SMBus console output" depends on SOUTHBRIDGE_INTEL_COMMON_SMBUS diff --git a/src/console/console.c b/src/console/console.c index bb9d374..cec3c43 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -12,6 +12,7 @@ #include <console/system76_ec.h> #include <console/uart.h> #include <console/usb.h> +#include <console/ro_flash.h> #include <types.h>
/* Note: when adding a new console, make sure you update the definition of @@ -27,6 +28,7 @@ __usbdebug_init(); __spiconsole_init(); __flashconsole_init(); + __ro_flashconsole_init(); __system76_ec_init(); __i2c_smbus_console_init(); __simnow_console_init(); @@ -47,6 +49,7 @@ __ne2k_tx_byte(byte); __usb_tx_byte(byte); __spiconsole_tx_byte(byte); + __ro_flashconsole_tx_byte(byte); __system76_ec_tx_byte(byte); __i2c_smbus_console_tx_byte(byte); __simnow_console_tx_byte(byte); diff --git a/src/drivers/spi/Makefile.mk b/src/drivers/spi/Makefile.mk index 97c3d63..6724cd1 100644 --- a/src/drivers/spi/Makefile.mk +++ b/src/drivers/spi/Makefile.mk @@ -20,6 +20,7 @@ $(1)-$(CONFIG_SPI_SDCARD) += spi_sdcard.c $(1)-$(CONFIG_BOOT_DEVICE_SPI_FLASH_RW_NOMMAP$(2)) += boot_device_rw_nommap.c $(1)-$(CONFIG_CONSOLE_SPI_FLASH) += flashconsole.c +$(1)-$(CONFIG_CONSOLE_RO_FLASH) += ro_flashconsole.c $(1)-$(CONFIG_SPI_FLASH_ADESTO) += adesto.c $(1)-$(CONFIG_SPI_FLASH_AMIC) += amic.c $(1)-$(CONFIG_SPI_FLASH_ATMEL) += atmel.c diff --git a/src/drivers/spi/ro_flashconsole.c b/src/drivers/spi/ro_flashconsole.c new file mode 100644 index 0000000..14a12d0 --- /dev/null +++ b/src/drivers/spi/ro_flashconsole.c @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <console/ro_flash.h> +#include <commonlib/region.h> +#include <boot_device.h> + +void ro_flashconsole_init(void) +{ +} + +void ro_flashconsole_tx_byte(unsigned char c) +{ + const struct region_device *rdev = boot_device_ro(); + uint32_t offset = CONFIG_CONSOLE_RO_FLASH_OFFSET + (c << CONFIG_CONSOLE_RO_FLASH_SHIFT); + + char buf[1]; + rdev_readat(rdev, buf, offset, 1); +} diff --git a/src/include/console/ro_flash.h b/src/include/console/ro_flash.h new file mode 100644 index 0000000..c5858b5 --- /dev/null +++ b/src/include/console/ro_flash.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef CONSOLE_RO_FLASH_H +#define CONSOLE_RO_FLASH_H + +#include <stdint.h> + +void ro_flashconsole_init(void); +void ro_flashconsole_tx_byte(unsigned char data); + +#define __RO_FLASHCONSOLE_ENABLE__ CONFIG(CONSOLE_RO_FLASH) + +#if __RO_FLASHCONSOLE_ENABLE__ +static inline void __ro_flashconsole_init(void) +{ + ro_flashconsole_init(); +} + +static inline void __ro_flashconsole_tx_byte(u8 data) +{ + ro_flashconsole_tx_byte(data); +} +#else +static inline void __ro_flashconsole_init(void) {} +static inline void __ro_flashconsole_tx_byte(u8 data) {} +#endif + +#endif /* CONSOLE_RO_FLASH_H */