From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nmwk9-0005hY-E1 for mharc-grub-devel@gnu.org; Fri, 06 May 2022 08:07:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmwk7-0005eK-Na for grub-devel@gnu.org; Fri, 06 May 2022 08:07:31 -0400 Received: from mail-vs1-xe2d.google.com ([2607:f8b0:4864:20::e2d]:34763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nmwk5-0003i2-Nf for grub-devel@gnu.org; Fri, 06 May 2022 08:07:31 -0400 Received: by mail-vs1-xe2d.google.com with SMTP id e10so6952569vsr.1 for ; Fri, 06 May 2022 05:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1wyyG49b9JMTguFNQY0AXAdLTFj4uLhq0bFHNgMUMAk=; b=0ZAAdX9+ad47yqNo/SwTZFLbp23D502WOn2BO/F0ofoMs5/p+YnhlCHdcgTBevFjhi 3jmoSzgwj7wHwv/uDV61C2gMQK8czQTUqRYC8vGdGc8KGhkgyLVhGJbQJgKCUw5ZGlSK CqyAKtna9M9G+sW73EjiwsenlA/ZYYNtiZ75UVimJe+rOSq0rtUfC+3QxO6t35+rZ+95 GAqP98AfdN+b2Ou/7g/CtT1XUmrbRL2y+NxFep/sPCBCKwjFmlhSifYB6jABHaNJXHAo A49bxfJeY9mlDy/5X8E4i08vScNhUB1Aw4G4v7wieXXsKmysjXX7hsuAHvSDGaFlDsrx 6fYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1wyyG49b9JMTguFNQY0AXAdLTFj4uLhq0bFHNgMUMAk=; b=W1l7zUCDsUlNrY/5TkM2jcqOFFIbjOn8CDJPfB9O3yt9HQhU1RzajAycCZRbpfIQry Dmt0o4fRn9QpZFhhiJAU9xS+LQlloSj9O7XFI5OJrOI9gbQfENyuwEpqndvvubcWapx5 cUpk1gQHRVYvXiLDTPIy0JhkKcJXLZKgf2Q5azgqW1vt1JccKKIU36xGub5BZiJMbjsc jnYsVcpVemBAyem0dNONGTDCQPdhITUdJe5FhO8ceEo6o3ETPpwJe6/UJNEAqikIhiW8 FkaTCUtXtxzZstCiBN/D6C0AGjEKghEyU7KGaSZWaLutPK+cYhmKymJCGza9BdUbzjyB 9Sqw== X-Gm-Message-State: AOAM532yVSb/abirClNEVGB3jSkN3XMhcW4Ipw/+jNIAAe617xXmtCaR AoiL8qVog9FAWpR6bguFM8v4KxxAQIZykzsf X-Google-Smtp-Source: ABdhPJw+vTQS0BCsHeLfnW8xm6CiWHnM6nxJfX/UE6AUSYW6fBh2JViah2NJ3Lavwbk6TQRWSOjf9w== X-Received: by 2002:a67:d59c:0:b0:32d:25e7:b597 with SMTP id m28-20020a67d59c000000b0032d25e7b597mr868358vsj.69.1651838848233; Fri, 06 May 2022 05:07:28 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.249]) by smtp.gmail.com with ESMTPSA id j27-20020a05612212bb00b00351bcf78967sm642750vkp.9.2022.05.06.05.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 05:07:27 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v2] efi: Set text-mode console resolution to maximum supported Date: Fri, 6 May 2022 07:06:58 -0500 Message-Id: <20220506120658.1450361-1-development@efficientek.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::e2d; envelope-from=development@efficientek.com; helo=mail-vs1-xe2d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 12:07:32 -0000 On some buggy EFI firmwares, GRUB is started with the console resolution set to the maximum but the output console EFI object has the mode set as 0, which is the minimum supported mode of 80x25 characters. This causes strange behavior at the GRUB shell where output can fill the screen, but the prompt is at line 80 in the middle of the screen. When initializing the EFI console, find the largest console resolution supported by area and set that as the current output mode. This works around the buggy firmware and provides a GRUB shell that displays correctly. Signed-off-by: Glenn Washburn --- v2: Fix to query each mode instead of just the current mode --- grub-core/term/efi/console.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index a3622e4fe..a98b84aac 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -141,6 +141,10 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), static grub_err_t grub_prepare_for_text_output (struct grub_term_output *term) { + grub_efi_simple_text_output_interface_t *o; + grub_efi_uintn_t columns, columns_max, rows, rows_max; + grub_efi_int32_t i, mode_max; + if (grub_efi_is_finished) return GRUB_ERR_BAD_DEVICE; @@ -155,6 +159,16 @@ grub_prepare_for_text_output (struct grub_term_output *term) return GRUB_ERR_BAD_DEVICE; } + /* Set text-mode resolution to maximum supported */ + o = grub_efi_system_table->con_out; + for (i=0, columns_max=0, rows_max=0, mode_max=0; i < o->mode->max_mode; i++) + if (GRUB_EFI_SUCCESS == efi_call_4 (o->query_mode, o, i, + &columns, &rows) + && (columns_max * rows_max) < (columns * rows)) + mode_max = i; + + efi_call_2 (o->set_mode, o, mode_max); + if (cursor_mode != GRUB_CURSOR_MODE_UNDEFINED) grub_console_setcursor (term, cursor_mode); if (text_colorstate != GRUB_TERM_COLOR_UNDEFINED) -- 2.34.1