libpayload: Implement reading from CBMEM console

To support showing CBMEM logs on recovery screen, add a function
cbmem_console_snapshot() to copy the CBMEM console to an allocated
buffer. Non-printable characters are automatically replaced with '?' to
ensure the returned string is printable.

BRANCH=none
BUG=b:146105976
TEST=emerge-nami libpayload

Change-Id: Ie324055f5fd8276f1d833fc9d04f60a792dbb9f6
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/37667
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
This commit is contained in:
Yu-Ping Wu
2019-12-02 11:11:53 +08:00
committed by Patrick Georgi
parent c32ca089c9
commit 41956b5742
2 changed files with 53 additions and 0 deletions

View File

@ -313,6 +313,13 @@ void video_printf(int foreground, int background, enum video_printf_align align,
*/
void cbmem_console_init(void);
void cbmem_console_write(const void *buffer, size_t count);
/**
* Take a snapshot of the CBMEM memory console. This function will allocate a
* range of memory. Callers must free the returned buffer by themselves.
*
* @return The allocated buffer on success, NULL on failure.
*/
char *cbmem_console_snapshot(void);
/** @} */
/* drivers/option.c */