summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers/cbmem_console.c
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload/drivers/cbmem_console.c')
-rw-r--r--payloads/libpayload/drivers/cbmem_console.c29
1 files changed, 17 insertions, 12 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;