summaryrefslogtreecommitdiff
path: root/payloads/libpayload
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload')
-rw-r--r--payloads/libpayload/drivers/cbmem_console.c29
-rw-r--r--payloads/libpayload/include/coreboot_tables.h2
-rw-r--r--payloads/libpayload/include/sysinfo.h4
-rw-r--r--payloads/libpayload/libc/coreboot.c8
4 files changed, 29 insertions, 14 deletions
diff --git a/payloads/libpayload/drivers/cbmem_console.c b/payloads/libpayload/drivers/cbmem_console.c
index 053802cbd9..22d5312c3a 100644
--- a/payloads/libpayload/drivers/cbmem_console.c
+++ b/payloads/libpayload/drivers/cbmem_console.c
@@ -38,7 +38,7 @@ struct cbmem_console {
#define CURSOR_MASK ((1 << 28) - 1)
#define OVERFLOW (1 << 31)
-static struct cbmem_console *cbmem_console_p;
+static uintptr_t cbmem_console_p;
static struct console_output_driver cbmem_console_driver =
{
@@ -47,27 +47,32 @@ static struct console_output_driver cbmem_console_driver =
static void do_write(const void *buffer, size_t count)
{
- memcpy(cbmem_console_p->body + (cbmem_console_p->cursor & CURSOR_MASK),
- buffer, count);
- cbmem_console_p->cursor += count;
+ struct cbmem_console *const cbmem_cons = phys_to_virt(cbmem_console_p);
+
+ memcpy(cbmem_cons->body + (cbmem_cons->cursor & CURSOR_MASK), buffer, count);
+ cbmem_cons->cursor += count;
}
void cbmem_console_init(void)
{
+ const struct cbmem_console *const cbmem_cons = phys_to_virt(lib_sysinfo.cbmem_cons);
+
cbmem_console_p = lib_sysinfo.cbmem_cons;
- if (cbmem_console_p && cbmem_console_p->size)
+
+ if (cbmem_console_p && cbmem_cons->size)
console_add_output_driver(&cbmem_console_driver);
}
void cbmem_console_write(const void *buffer, size_t count)
{
- while ((cbmem_console_p->cursor & CURSOR_MASK) + count >=
- cbmem_console_p->size) {
- size_t still_fits = cbmem_console_p->size -
- (cbmem_console_p->cursor & CURSOR_MASK);
+ struct cbmem_console *const cbmem_cons = phys_to_virt(cbmem_console_p);
+
+ while ((cbmem_cons->cursor & CURSOR_MASK) + count >=
+ cbmem_cons->size) {
+ size_t still_fits = cbmem_cons->size - (cbmem_cons->cursor & CURSOR_MASK);
do_write(buffer, still_fits);
- cbmem_console_p->cursor &= ~CURSOR_MASK;
- cbmem_console_p->cursor |= OVERFLOW;
+ cbmem_cons->cursor &= ~CURSOR_MASK;
+ cbmem_cons->cursor |= OVERFLOW;
buffer += still_fits;
count -= still_fits;
}
@@ -77,7 +82,7 @@ void cbmem_console_write(const void *buffer, size_t count)
char *cbmem_console_snapshot(void)
{
- const struct cbmem_console *console_p = cbmem_console_p;
+ const struct cbmem_console *const console_p = phys_to_virt(cbmem_console_p);
char *console_c;
uint32_t size, cursor, overflow;
diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h
index 91d3520ad5..c281417f10 100644
--- a/payloads/libpayload/include/coreboot_tables.h
+++ b/payloads/libpayload/include/coreboot_tables.h
@@ -31,6 +31,7 @@
#include <arch/types.h>
#include <ipchksum.h>
+#include <stdint.h>
enum {
CB_TAG_UNUSED = 0x0000,
@@ -396,4 +397,5 @@ static inline const char *cb_mb_part_string(const struct cb_mainboard *cbm)
/* Helper functions */
void *get_cbmem_ptr(unsigned char *ptr);
+uintptr_t get_cbmem_addr(const void *cbmem_tab_entry);
#endif
diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h
index 6e83f684df..3b1b9c9742 100644
--- a/payloads/libpayload/include/sysinfo.h
+++ b/payloads/libpayload/include/sysinfo.h
@@ -29,6 +29,8 @@
#ifndef _SYSINFO_H
#define _SYSINFO_H
+#include <stdint.h>
+
/* Maximum number of memory range definitions. */
#define SYSINFO_MAX_MEM_RANGES 32
/* Allow a maximum of 8 GPIOs */
@@ -101,7 +103,7 @@ struct sysinfo_t {
#endif
void *tstamp_table;
- void *cbmem_cons;
+ uintptr_t cbmem_cons;
void *mrc_cache;
void *acpi_gnvs;
diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c
index c6fb57fde9..25812e5a95 100644
--- a/payloads/libpayload/libc/coreboot.c
+++ b/payloads/libpayload/libc/coreboot.c
@@ -47,6 +47,12 @@ void *get_cbmem_ptr(unsigned char *ptr)
return phys_to_virt(cbmem->cbmem_tab);
}
+uintptr_t get_cbmem_addr(const void *const cbmem_tab_entry)
+{
+ const struct cb_cbmem_tab *const cbmem = cbmem_tab_entry;
+ return cbmem->cbmem_tab;
+}
+
static void cb_parse_memory(void *ptr, struct sysinfo_t *info)
{
struct cb_memory *mem = ptr;
@@ -135,7 +141,7 @@ static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info)
static void cb_parse_cbmem_cons(unsigned char *ptr, struct sysinfo_t *info)
{
- info->cbmem_cons = get_cbmem_ptr(ptr);
+ info->cbmem_cons = get_cbmem_addr(ptr);
}
static void cb_parse_acpi_gnvs(unsigned char *ptr, struct sysinfo_t *info)