cbmem: Terminate the cbmem console at the cursor position.
If the cbmem console buffer isn't zero filled before it's used, there won't be a terminator at the end. We need to put one at the cursor position manually. BUG=chrome-os-partner:19420 TEST=Booted and ran cbmem -c on pit. No longer saw lots of garbage printed after the actual console output. BRANCH=None Change-Id: I69870c2b24b67ce3cbcd402b62f3574acb4c2a8f Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://gerrit.chromium.org/gerrit/65300 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
This commit is contained in:
parent
981cbd6113
commit
8ec61e52a6
1 changed files with 4 additions and 2 deletions
|
|
@ -368,7 +368,7 @@ static void dump_console(void)
|
|||
{
|
||||
void *console_p;
|
||||
char *console_c;
|
||||
uint32_t size;
|
||||
uint32_t size, cursor;
|
||||
|
||||
if (console.tag != LB_TAG_CBMEM_CONSOLE) {
|
||||
fprintf(stderr, "No console found in coreboot table.\n");
|
||||
|
|
@ -382,7 +382,8 @@ static void dump_console(void)
|
|||
* char console[size]
|
||||
* Hence we have to add 8 to get to the actual console string.
|
||||
*/
|
||||
size = *(uint32_t *)console_p;
|
||||
size = ((uint32_t *)console_p)[0];
|
||||
cursor = ((uint32_t *)console_p)[1];
|
||||
console_c = malloc(size + 1);
|
||||
if (!console_c) {
|
||||
fprintf(stderr, "Not enough memory for console.\n");
|
||||
|
|
@ -391,6 +392,7 @@ static void dump_console(void)
|
|||
|
||||
memcpy(console_c, console_p + 8, size);
|
||||
console_c[size] = 0;
|
||||
console_c[cursor] = 0;
|
||||
|
||||
printf("%s", console_c);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue