mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 19:11:53 +00:00
efi_loader: always check parameters in efi_cout_query_mode()
If we cannot determine the size of the serial terminal we still have to check the parameters of efi_cout_query_mode(). Querying the size of the serial terminal drains the keyboard buffer. So make sure we do this during the initialization and not in the midst of an EFI application. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
f2431415d6
commit
a4aa7bef3c
1 changed files with 48 additions and 42 deletions
|
@ -12,8 +12,6 @@
|
||||||
#include <stdio_dev.h>
|
#include <stdio_dev.h>
|
||||||
#include <video_console.h>
|
#include <video_console.h>
|
||||||
|
|
||||||
static bool console_size_queried;
|
|
||||||
|
|
||||||
#define EFI_COUT_MODE_2 2
|
#define EFI_COUT_MODE_2 2
|
||||||
#define EFI_MAX_COUT_MODE 3
|
#define EFI_MAX_COUT_MODE 3
|
||||||
|
|
||||||
|
@ -205,19 +203,18 @@ static int query_console_serial(int *rows, int *cols)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static efi_status_t EFIAPI efi_cout_query_mode(
|
/*
|
||||||
struct efi_simple_text_output_protocol *this,
|
* Update the mode table.
|
||||||
unsigned long mode_number, unsigned long *columns,
|
*
|
||||||
unsigned long *rows)
|
* By default the only mode available is 80x25. If the console has at least 50
|
||||||
|
* lines, enable mode 80x50. If we can query the console size and it is neither
|
||||||
|
* 80x25 nor 80x50, set it as an additional mode.
|
||||||
|
*/
|
||||||
|
static void query_console_size(void)
|
||||||
{
|
{
|
||||||
EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
|
|
||||||
|
|
||||||
if (!console_size_queried) {
|
|
||||||
const char *stdout_name = env_get("stdout");
|
const char *stdout_name = env_get("stdout");
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
|
|
||||||
console_size_queried = true;
|
|
||||||
|
|
||||||
if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
|
if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
|
||||||
IS_ENABLED(CONFIG_DM_VIDEO)) {
|
IS_ENABLED(CONFIG_DM_VIDEO)) {
|
||||||
struct stdio_dev *stdout_dev =
|
struct stdio_dev *stdout_dev =
|
||||||
|
@ -228,7 +225,7 @@ static efi_status_t EFIAPI efi_cout_query_mode(
|
||||||
rows = priv->rows;
|
rows = priv->rows;
|
||||||
cols = priv->cols;
|
cols = priv->cols;
|
||||||
} else if (query_console_serial(&rows, &cols)) {
|
} else if (query_console_serial(&rows, &cols)) {
|
||||||
goto out;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test if we can have Mode 1 */
|
/* Test if we can have Mode 1 */
|
||||||
|
@ -251,13 +248,19 @@ static efi_status_t EFIAPI efi_cout_query_mode(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static efi_status_t EFIAPI efi_cout_query_mode(
|
||||||
|
struct efi_simple_text_output_protocol *this,
|
||||||
|
unsigned long mode_number, unsigned long *columns,
|
||||||
|
unsigned long *rows)
|
||||||
|
{
|
||||||
|
EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
|
||||||
|
|
||||||
if (mode_number >= efi_con_mode.max_mode)
|
if (mode_number >= efi_con_mode.max_mode)
|
||||||
return EFI_EXIT(EFI_UNSUPPORTED);
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
||||||
|
|
||||||
if (efi_cout_modes[mode_number].present != 1)
|
if (efi_cout_modes[mode_number].present != 1)
|
||||||
return EFI_EXIT(EFI_UNSUPPORTED);
|
return EFI_EXIT(EFI_UNSUPPORTED);
|
||||||
|
|
||||||
out:
|
|
||||||
if (columns)
|
if (columns)
|
||||||
*columns = efi_cout_modes[mode_number].columns;
|
*columns = efi_cout_modes[mode_number].columns;
|
||||||
if (rows)
|
if (rows)
|
||||||
|
@ -565,6 +568,9 @@ int efi_console_register(void)
|
||||||
struct efi_object *efi_console_output_obj;
|
struct efi_object *efi_console_output_obj;
|
||||||
struct efi_object *efi_console_input_obj;
|
struct efi_object *efi_console_input_obj;
|
||||||
|
|
||||||
|
/* Set up mode information */
|
||||||
|
query_console_size();
|
||||||
|
|
||||||
/* Create handles */
|
/* Create handles */
|
||||||
r = efi_create_handle((efi_handle_t *)&efi_console_output_obj);
|
r = efi_create_handle((efi_handle_t *)&efi_console_output_obj);
|
||||||
if (r != EFI_SUCCESS)
|
if (r != EFI_SUCCESS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue