libpayload: Cache physical location of serial-console struct
In the presence of self-relocating payloads, it's safer to keep physical addresses in `libsysinfo`. Change-Id: Icd30e95c6b8115d16dd793914fb01a1a9da1854f Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/43577 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
This commit is contained in:
parent
b2eafa666c
commit
be842cb72d
|
@ -132,9 +132,9 @@ void serial_init(void)
|
|||
|
||||
void serial_console_init(void)
|
||||
{
|
||||
if (!lib_sysinfo.serial)
|
||||
if (!lib_sysinfo.cb_serial)
|
||||
return;
|
||||
cb_serial = *lib_sysinfo.serial;
|
||||
cb_serial = *(struct cb_serial *)phys_to_virt(lib_sysinfo.cb_serial);
|
||||
|
||||
serial_init();
|
||||
|
||||
|
|
|
@ -553,9 +553,7 @@ static struct console_output_driver consout = {};
|
|||
/* For simplicity's sake, let's rely on coreboot initializing the UART. */
|
||||
void serial_console_init(void)
|
||||
{
|
||||
struct cb_serial *sc_ptr = lib_sysinfo.serial;
|
||||
|
||||
if (!sc_ptr)
|
||||
if (!lib_sysinfo.cb_serial)
|
||||
return;
|
||||
|
||||
consin.havekey = serial_havechar;
|
||||
|
|
|
@ -343,9 +343,9 @@ int serial_getchar(void)
|
|||
/* For simplicity's sake, let's rely on coreboot initializing the UART. */
|
||||
void serial_console_init(void)
|
||||
{
|
||||
struct cb_serial *sc_ptr = lib_sysinfo.serial;
|
||||
struct cb_serial *sc_ptr = phys_to_virt(lib_sysinfo.cb_serial);
|
||||
|
||||
if (!sc_ptr)
|
||||
if (!lib_sysinfo.cb_serial)
|
||||
return;
|
||||
|
||||
base_uart_addr = (void *) sc_ptr->baseaddr;
|
||||
|
|
|
@ -275,7 +275,8 @@ static struct console_output_driver consout = {
|
|||
|
||||
static struct qup_regs *uart_base_address(void)
|
||||
{
|
||||
return (void *)(uintptr_t)lib_sysinfo.serial->baseaddr;
|
||||
const struct cb_serial *const serial = phys_to_virt(lib_sysinfo.cb_serial);
|
||||
return phys_to_virt(serial->baseaddr);
|
||||
}
|
||||
|
||||
static void uart_qupv3_tx_flush(void)
|
||||
|
@ -332,7 +333,7 @@ int serial_getchar(void)
|
|||
|
||||
void serial_console_init(void)
|
||||
{
|
||||
if (!lib_sysinfo.serial)
|
||||
if (!lib_sysinfo.cb_serial)
|
||||
return;
|
||||
|
||||
console_add_output_driver(&consout);
|
||||
|
|
|
@ -541,9 +541,9 @@ int serial_getchar(void)
|
|||
/* For simplicity's sake, let's rely on coreboot initializing the UART. */
|
||||
void serial_console_init(void)
|
||||
{
|
||||
struct cb_serial *sc_ptr = lib_sysinfo.serial;
|
||||
struct cb_serial *sc_ptr = phys_to_virt(lib_sysinfo.cb_serial);
|
||||
|
||||
if (!sc_ptr)
|
||||
if (!lib_sysinfo.cb_serial)
|
||||
return;
|
||||
|
||||
uart_board_param.uart_dm_base = (void *)(uintptr_t)sc_ptr->baseaddr;
|
||||
|
|
|
@ -90,10 +90,12 @@ static struct console_input_driver s5p_serial_input =
|
|||
|
||||
void serial_init(void)
|
||||
{
|
||||
if (!lib_sysinfo.serial || !lib_sysinfo.serial->baseaddr)
|
||||
const struct cb_serial *const serial = phys_to_virt(lib_sysinfo.cb_serial);
|
||||
|
||||
if (!lib_sysinfo.cb_serial || !serial->baseaddr)
|
||||
return;
|
||||
|
||||
uart_regs = (struct s5p_uart *)lib_sysinfo.serial->baseaddr;
|
||||
uart_regs = (struct s5p_uart *)serial->baseaddr;
|
||||
}
|
||||
|
||||
void serial_console_init(void)
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
|
||||
#include <coreboot_tables.h>
|
||||
|
||||
struct cb_serial;
|
||||
|
||||
/*
|
||||
* All pointers in here shall be virtual.
|
||||
*
|
||||
|
@ -51,7 +49,7 @@ struct cb_serial;
|
|||
*/
|
||||
struct sysinfo_t {
|
||||
unsigned int cpu_khz;
|
||||
struct cb_serial *serial;
|
||||
uintptr_t cb_serial;
|
||||
unsigned short ser_ioport;
|
||||
unsigned long ser_base; // for mmapped serial
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
|
|||
|
||||
static void cb_parse_serial(void *ptr, struct sysinfo_t *info)
|
||||
{
|
||||
info->serial = ((struct cb_serial *)ptr);
|
||||
info->cb_serial = virt_to_phys(ptr);
|
||||
}
|
||||
|
||||
static void cb_parse_vboot_workbuf(unsigned char *ptr, struct sysinfo_t *info)
|
||||
|
|
Loading…
Reference in New Issue