loader.efi: handle efi_cons_init() failure cases better
if we fail to allocate buffer, set up the TERM_EMU and continue. On output, use TERM_EMU in case we did fail to allocate buffer.
This commit is contained in:
parent
9dfa078252
commit
34edaae605
@ -855,27 +855,28 @@ efi_cons_update_mode(void)
|
|||||||
tp.tp_row = rows;
|
tp.tp_row = rows;
|
||||||
tp.tp_col = cols;
|
tp.tp_col = cols;
|
||||||
buffer = malloc(rows * cols * sizeof(*buffer));
|
buffer = malloc(rows * cols * sizeof(*buffer));
|
||||||
if (buffer == NULL)
|
if (buffer != NULL) {
|
||||||
return (false);
|
teken_set_winsize(&teken, &tp);
|
||||||
|
a = teken_get_defattr(&teken);
|
||||||
|
|
||||||
teken_set_winsize(&teken, &tp);
|
snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
|
||||||
a = teken_get_defattr(&teken);
|
env_setenv("teken.fg_color", EV_VOLATILE, env,
|
||||||
|
efi_set_colors, env_nounset);
|
||||||
|
snprintf(env, sizeof(env), "%d", a->ta_bgcolor);
|
||||||
|
env_setenv("teken.bg_color", EV_VOLATILE, env,
|
||||||
|
efi_set_colors, env_nounset);
|
||||||
|
|
||||||
snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
|
for (int row = 0; row < rows; row++) {
|
||||||
env_setenv("teken.fg_color", EV_VOLATILE, env, efi_set_colors,
|
for (int col = 0; col < cols; col++) {
|
||||||
env_nounset);
|
buffer[col + row * tp.tp_col].c = ' ';
|
||||||
snprintf(env, sizeof(env), "%d", a->ta_bgcolor);
|
buffer[col + row * tp.tp_col].a = *a;
|
||||||
env_setenv("teken.bg_color", EV_VOLATILE, env, efi_set_colors,
|
}
|
||||||
env_nounset);
|
|
||||||
|
|
||||||
for (int row = 0; row < rows; row++) {
|
|
||||||
for (int col = 0; col < cols; col++) {
|
|
||||||
buffer[col + row * tp.tp_col].c = ' ';
|
|
||||||
buffer[col + row * tp.tp_col].a = *a;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
#ifdef TERM_EMU
|
#ifdef TERM_EMU
|
||||||
|
if (buffer == NULL) {
|
||||||
conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR,
|
conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR,
|
||||||
DEFAULT_BGCOLOR));
|
DEFAULT_BGCOLOR));
|
||||||
end_term();
|
end_term();
|
||||||
@ -883,8 +884,8 @@ efi_cons_update_mode(void)
|
|||||||
curs_move(&curx, &cury, curx, cury);
|
curs_move(&curx, &cury, curx, cury);
|
||||||
fg_c = DEFAULT_FGCOLOR;
|
fg_c = DEFAULT_FGCOLOR;
|
||||||
bg_c = DEFAULT_BGCOLOR;
|
bg_c = DEFAULT_BGCOLOR;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
snprintf(env, sizeof (env), "%u", (unsigned)rows);
|
snprintf(env, sizeof (env), "%u", (unsigned)rows);
|
||||||
setenv("LINES", env, 1);
|
setenv("LINES", env, 1);
|
||||||
@ -1011,15 +1012,12 @@ efi_cons_putchar(int c)
|
|||||||
* Don't use Teken when we're doing pure serial, or a multiple console
|
* Don't use Teken when we're doing pure serial, or a multiple console
|
||||||
* with video "primary" because that's also serial.
|
* with video "primary" because that's also serial.
|
||||||
*/
|
*/
|
||||||
if ((mode & (RB_SERIAL | RB_MULTIPLE)) != 0) {
|
if ((mode & (RB_SERIAL | RB_MULTIPLE)) != 0 || buffer == NULL) {
|
||||||
input_byte(ch);
|
input_byte(ch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer != NULL)
|
teken_input(&teken, &ch, sizeof (ch));
|
||||||
teken_input(&teken, &ch, sizeof (ch));
|
|
||||||
else
|
|
||||||
efi_cons_efiputchar(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user