aboutsummaryrefslogtreecommitdiff
path: root/stand/efi/libefi
diff options
context:
space:
mode:
authorToomas Soome <tsoome@FreeBSD.org>2020-03-18 22:21:42 +0000
committerToomas Soome <tsoome@FreeBSD.org>2020-03-18 22:21:42 +0000
commit34edaae6054fa0163252d143af745daeddd5c693 (patch)
tree00b04ff409b786ab25953ae592545dd543b9ed2a /stand/efi/libefi
parent9dfa07825247787f01e891acf1dae4136647eac1 (diff)
downloadsrc-34edaae6054fa0163252d143af745daeddd5c693.tar.gz
src-34edaae6054fa0163252d143af745daeddd5c693.zip
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.
Notes
Notes: svn path=/head/; revision=359099
Diffstat (limited to 'stand/efi/libefi')
-rw-r--r--stand/efi/libefi/efi_console.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c
index 7102d834c34d..deca014999bc 100644
--- a/stand/efi/libefi/efi_console.c
+++ b/stand/efi/libefi/efi_console.c
@@ -855,27 +855,28 @@ efi_cons_update_mode(void)
tp.tp_row = rows;
tp.tp_col = cols;
buffer = malloc(rows * cols * sizeof(*buffer));
- if (buffer == NULL)
- return (false);
-
- teken_set_winsize(&teken, &tp);
- a = teken_get_defattr(&teken);
-
- snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
- 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);
-
- 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;
+ if (buffer != NULL) {
+ teken_set_winsize(&teken, &tp);
+ a = teken_get_defattr(&teken);
+
+ snprintf(env, sizeof(env), "%d", a->ta_fgcolor);
+ 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);
+
+ 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
+ if (buffer == NULL) {
conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR,
DEFAULT_BGCOLOR));
end_term();
@@ -883,8 +884,8 @@ efi_cons_update_mode(void)
curs_move(&curx, &cury, curx, cury);
fg_c = DEFAULT_FGCOLOR;
bg_c = DEFAULT_BGCOLOR;
-#endif
}
+#endif
snprintf(env, sizeof (env), "%u", (unsigned)rows);
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
* 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);
return;
}
- if (buffer != NULL)
- teken_input(&teken, &ch, sizeof (ch));
- else
- efi_cons_efiputchar(c);
+ teken_input(&teken, &ch, sizeof (ch));
}
static int