Revert "lib/cbmem_console: Move copy_console_buffer up in the file"

This reverts commit 6a3bdf9aa5.

Reason for revert: Oops, I thought I abandoned this. It's been replaced by https://review.coreboot.org/c/coreboot/+/61099/3

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: Id18e8e69481bdd78fdd70116940ea435922a9e77
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60853
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Rob Barnes <robbarnes@google.com>
This commit is contained in:
Raul Rangel 2022-01-21 16:46:55 +00:00
parent c7018cc009
commit 03b1d3ef48
1 changed files with 32 additions and 32 deletions

View File

@ -55,38 +55,6 @@ static bool console_paused;
#define STATIC_CONSOLE_SIZE 1024
static u8 static_console[STATIC_CONSOLE_SIZE];
/*
* Copy the current console buffer (either from the cache as RAM area or from
* the static buffer, pointed at by src_cons_p) into the newly initialized CBMEM
* console. The use of cbmemc_tx_byte() ensures that all special cases for the
* target console (e.g. overflow) will be handled. If there had been an
* overflow in the source console, log a message to that effect.
*/
static void copy_console_buffer(struct cbmem_console *src_cons_p)
{
u32 c;
if (!src_cons_p)
return;
if (src_cons_p->cursor & OVERFLOW) {
const char overflow_warning[] = "\n*** Pre-CBMEM " ENV_STRING
" console overflowed, log truncated! ***\n";
for (c = 0; c < sizeof(overflow_warning) - 1; c++)
cbmemc_tx_byte(overflow_warning[c]);
for (c = src_cons_p->cursor & CURSOR_MASK;
c < src_cons_p->size; c++)
cbmemc_tx_byte(src_cons_p->body[c]);
}
for (c = 0; c < (src_cons_p->cursor & CURSOR_MASK); c++)
cbmemc_tx_byte(src_cons_p->body[c]);
/* Invalidate the source console, so it will be reinitialized on the
next reboot. Otherwise, we might copy the same bytes again. */
src_cons_p->size = 0;
}
static int buffer_valid(struct cbmem_console *cbm_cons_p, u32 total_space)
{
return (cbm_cons_p->cursor & CURSOR_MASK) < cbm_cons_p->size &&
@ -139,6 +107,38 @@ void cbmemc_tx_byte(unsigned char data)
current_console->cursor = flags | cursor;
}
/*
* Copy the current console buffer (either from the cache as RAM area or from
* the static buffer, pointed at by src_cons_p) into the newly initialized CBMEM
* console. The use of cbmemc_tx_byte() ensures that all special cases for the
* target console (e.g. overflow) will be handled. If there had been an
* overflow in the source console, log a message to that effect.
*/
static void copy_console_buffer(struct cbmem_console *src_cons_p)
{
u32 c;
if (!src_cons_p)
return;
if (src_cons_p->cursor & OVERFLOW) {
const char overflow_warning[] = "\n*** Pre-CBMEM " ENV_STRING
" console overflowed, log truncated! ***\n";
for (c = 0; c < sizeof(overflow_warning) - 1; c++)
cbmemc_tx_byte(overflow_warning[c]);
for (c = src_cons_p->cursor & CURSOR_MASK;
c < src_cons_p->size; c++)
cbmemc_tx_byte(src_cons_p->body[c]);
}
for (c = 0; c < (src_cons_p->cursor & CURSOR_MASK); c++)
cbmemc_tx_byte(src_cons_p->body[c]);
/* Invalidate the source console, so it will be reinitialized on the
next reboot. Otherwise, we might copy the same bytes again. */
src_cons_p->size = 0;
}
static void cbmemc_reinit(int is_recovery)
{
const size_t size = CONFIG_CONSOLE_CBMEM_BUFFER_SIZE;