From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nmuXq-0003Pq-09 for mharc-grub-devel@gnu.org; Fri, 06 May 2022 05:46:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nmuXl-0003Pa-NK for grub-devel@gnu.org; Fri, 06 May 2022 05:46:38 -0400 Received: from mail-vk1-xa30.google.com ([2607:f8b0:4864:20::a30]:46732) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nmuXj-0004tM-Uf for grub-devel@gnu.org; Fri, 06 May 2022 05:46:37 -0400 Received: by mail-vk1-xa30.google.com with SMTP id m203so3299711vke.13 for ; Fri, 06 May 2022 02:46:35 -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=2OwPx3aR14X4z22aDrGcFacd6AWe/vD11n0pYnVSGxI=; b=bkoiNv3s+qnlDj7Sf9xHh1RxdLA6SYgmvbAUSyeOTd7K0R+JAWI1eKkcxLC6OKNKkO 4dtTgDWVOgPc7yQ4c3v0bfjVvrZDhH5QGpxp5V5+eSMfWVcl/TPzWZl5+NE5Hf6+pqer lHPMALru1TKdCJ31f+AWe9p+LT6ySTB/z/KExuybx0SPkHjHLiTNmX4ruhyj+mLsg1eJ +3gozlXeNOe+8sEp6GvVThRCExv81aFCKHORHBDxbLmUuuj6s9wa3lNynd+r/H48YdlR o+nVwoM/FJFDoB7qubE3UqaudKygLUAli6TBh3gff22yTZ420zKpkJG2rJzOwb+56zXa AOKw== 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=2OwPx3aR14X4z22aDrGcFacd6AWe/vD11n0pYnVSGxI=; b=uR29LJ9rGiqJzSCHvOdixU8xNraUJVM/16veXp8X/z32WCKXFkkUoMX/Z1zvy5q1Vn 0OQu3QwRq3/VdgKrpHOXCaqETvmk6WG6NFWXLx5B5j4V+sXhzD8Sq2zRj4RH6yfkRIPg 3iM8rlXIxnqHy7ZJ7HfqOp+pYI/NMwXD3/0S75SBuNnS4KJkXr2zFqe5TUDzDY90UXF/ 6TZA4aCXgygiC0M7Phj4hbsY5jKtNeOP4qq54zu+w7dEgV3PZtAHe7jOjNpJcZvjIMew 0728ng9S8UsoSxt4DLF8y4IQ99KjvoYg7Q9Lx2bV/3XpWBbmtUNP3R3bT/IPo4k8laIM enbA== X-Gm-Message-State: AOAM531UiYTaCwMzHPXfT5ugSlqkQ4fB2ZxdJitlxC2QvjmdhZcujk1D Xebe+PhuHYCRC+13lW9l1Pjh1q8v/tQyIym1 X-Google-Smtp-Source: ABdhPJz1pFqf7kusE3Slpb4D4xgFvt3iIMQYWVzdL1zw8mhTIDtKOmAWHN+6QvOnNjV+C2hH5HWaRQ== X-Received: by 2002:a1f:c14e:0:b0:34e:1cf0:38d8 with SMTP id r75-20020a1fc14e000000b0034e1cf038d8mr785979vkf.28.1651830394348; Fri, 06 May 2022 02:46:34 -0700 (PDT) Received: from localhost.localdomain ([37.218.244.249]) by smtp.gmail.com with ESMTPSA id b19-20020ab06653000000b00364eac116f0sm560756uaq.2.2022.05.06.02.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 02:46:33 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH] efi: Set text-mode console resolution to maximum supported Date: Fri, 6 May 2022 04:46:17 -0500 Message-Id: <20220506094617.1258175-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::a30; envelope-from=development@efficientek.com; helo=mail-vk1-xa30.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 09:46:40 -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 --- 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..06da5548f 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, o->mode->mode, + &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