diff options
author | Simon Glass <sjg@chromium.org> | 2017-06-15 21:37:52 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-07-11 10:08:19 -0600 |
commit | 4e6bafa56807b7ea4ebfb2eebbcf2eae674866e0 (patch) | |
tree | 1f65834bb42f86f5b53738f512ca3af850bcc060 | |
parent | e5a9d27fdbcf59760a7ff69597584229e24ca456 (diff) |
console: Use map_sysmem() for the pre-relocation console
At present this feature casts the address to a pointer. Use the
map_sysmem() function so that it will work correctly on sandbox.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r-- | common/console.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/common/console.c b/common/console.c index 60e7a94a56..762d5f291c 100644 --- a/common/console.c +++ b/common/console.c @@ -11,6 +11,7 @@ #include <stdarg.h> #include <iomux.h> #include <malloc.h> +#include <mapmem.h> #include <os.h> #include <serial.h> #include <stdio_dev.h> @@ -416,9 +417,13 @@ int tstc(void) static void pre_console_putc(const char c) { - char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR; + char *buffer; + + buffer = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ); buffer[CIRC_BUF_IDX(gd->precon_buf_idx++)] = c; + + unmap_sysmem(buffer); } static void pre_console_puts(const char *s) @@ -430,14 +435,16 @@ static void pre_console_puts(const char *s) static void print_pre_console_buffer(int flushpoint) { unsigned long in = 0, out = 0; - char *buf_in = (char *)CONFIG_PRE_CON_BUF_ADDR; char buf_out[CONFIG_PRE_CON_BUF_SZ + 1]; + char *buf_in; + buf_in = map_sysmem(CONFIG_PRE_CON_BUF_ADDR, CONFIG_PRE_CON_BUF_SZ); if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ) in = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ; while (in < gd->precon_buf_idx) buf_out[out++] = buf_in[CIRC_BUF_IDX(in++)]; + unmap_sysmem(buf_in); buf_out[out] = 0; |