Date: Thu, 9 Sep 2021 09:52:40 GMT From: Toomas Soome <tsoome@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 1f91b3b631db - stable/13 - loader.efi: fix console output after BS off Message-ID: <202109090952.1899qeVo068040@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=1f91b3b631dbbad5b81a89c894595ff25af42f4d commit 1f91b3b631dbbad5b81a89c894595ff25af42f4d Author: Toomas Soome <tsoome@FreeBSD.org> AuthorDate: 2021-09-02 21:17:32 +0000 Commit: Toomas Soome <tsoome@FreeBSD.org> CommitDate: 2021-09-09 08:28:07 +0000 loader.efi: fix console output after BS off When Boot Services (BS) are switched off, we can not use BS functions any more. Since drawn console does implement our own Blt(), we can use it to draw the console. However, SimpleTextOutput protocol based console output must be blocked. Tested by inserting printf() after ExitBootServices() call. (cherry picked from commit 4c7a3a70e047fbba2a3ce4a0168eaf2baddca76b) --- stand/common/gfx_fb.c | 14 +++++--------- stand/efi/libefi/efi_console.c | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c index 71c162a77f27..0cf357bd5f37 100644 --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -751,12 +751,15 @@ gfxfb_blt(void *BltBuffer, GFXFB_BLT_OPERATION BltOperation, #if defined(EFI) EFI_STATUS status; EFI_GRAPHICS_OUTPUT *gop = gfx_state.tg_private; + extern int boot_services_gone; + EFI_TPL tpl; /* * We assume Blt() does work, if not, we will need to build * exception list case by case. */ - if (gop != NULL) { + if (gop != NULL && boot_services_gone == 0) { + tpl = BS->RaiseTPL(TPL_NOTIFY); switch (BltOperation) { case GfxFbBltVideoFill: status = gop->Blt(gop, BltBuffer, EfiBltVideoFill, @@ -803,6 +806,7 @@ gfxfb_blt(void *BltBuffer, GFXFB_BLT_OPERATION BltOperation, break; } + BS->RestoreTPL(tpl); return (rv); } #endif @@ -1040,20 +1044,12 @@ void gfx_fb_cursor(void *arg, const teken_pos_t *p) { teken_gfx_t *state = arg; -#if defined(EFI) - EFI_TPL tpl; - - tpl = BS->RaiseTPL(TPL_NOTIFY); -#endif /* Switch cursor off in old location and back on in new. */ if (state->tg_cursor_visible) { gfx_fb_cursor_draw(state, &state->tg_cursor, false); gfx_fb_cursor_draw(state, p, true); } -#if defined(EFI) - BS->RestoreTPL(tpl); -#endif } void diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index 0c40b362f276..bacc2546e070 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <framebuffer.h> #include "bootstrap.h" +extern int boot_services_gone; extern EFI_GUID gop_guid; static EFI_GUID simple_input_ex_guid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; @@ -176,6 +177,9 @@ efi_text_cursor(void *arg, const teken_pos_t *p) teken_gfx_t *state = arg; UINTN col, row; + if (boot_services_gone) + return; + row = p->tp_row; if (p->tp_row >= state->tg_tp.tp_row) row = state->tg_tp.tp_row - 1; @@ -234,6 +238,9 @@ efi_text_putchar(void *s, const teken_pos_t *p, teken_char_t c, EFI_STATUS status; int idx; + if (boot_services_gone) + return; + idx = p->tp_col + p->tp_row * state->tg_tp.tp_col; if (idx >= state->tg_tp.tp_col * state->tg_tp.tp_row) return; @@ -251,6 +258,9 @@ efi_text_fill(void *arg, const teken_rect_t *r, teken_char_t c, teken_gfx_t *state = arg; teken_pos_t p; + if (boot_services_gone) + return; + if (state->tg_cursor_visible) conout->EnableCursor(conout, FALSE); for (p.tp_row = r->tr_begin.tp_row; p.tp_row < r->tr_end.tp_row; @@ -303,6 +313,9 @@ efi_text_copy(void *arg, const teken_rect_t *r, const teken_pos_t *p) int nrow, ncol, x, y; /* Has to be signed - >= 0 comparison */ bool scroll = false; + if (boot_services_gone) + return; + /* * Copying is a little tricky. We must make sure we do it in * correct order, to make sure we don't overwrite our own data. @@ -356,6 +369,9 @@ efi_text_param(void *arg, int cmd, unsigned int value) { teken_gfx_t *state = arg; + if (boot_services_gone) + return; + switch (cmd) { case TP_SETLOCALCURSOR: /* @@ -730,6 +746,9 @@ efi_term_emu(int c) int t, i; EFI_STATUS status; + if (boot_services_gone) + return; + switch (esc) { case 0: switch (c) { @@ -839,7 +858,8 @@ efi_term_emu(int c) break; } #else - efi_cons_rawputchar(c); + if (!boot_services_gone) + efi_cons_rawputchar(c); #endif }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109090952.1899qeVo068040>