From owner-dev-commits-src-branches@freebsd.org Thu Sep 9 09:52:41 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2A99666CF42; Thu, 9 Sep 2021 09:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H4vST0XYwz3mXW; Thu, 9 Sep 2021 09:52:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E643017980; Thu, 9 Sep 2021 09:52:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1899qeOC068041; Thu, 9 Sep 2021 09:52:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1899qeVo068040; Thu, 9 Sep 2021 09:52:40 GMT (envelope-from git) Date: Thu, 9 Sep 2021 09:52:40 GMT Message-Id: <202109090952.1899qeVo068040@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Toomas Soome Subject: git: 1f91b3b631db - stable/13 - loader.efi: fix console output after BS off MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tsoome X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1f91b3b631dbbad5b81a89c894595ff25af42f4d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2021 09:52:41 -0000 The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=1f91b3b631dbbad5b81a89c894595ff25af42f4d commit 1f91b3b631dbbad5b81a89c894595ff25af42f4d Author: Toomas Soome AuthorDate: 2021-09-02 21:17:32 +0000 Commit: Toomas Soome 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 #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 }