From 79fba75529a98f31c0a8988419172103b40262ad Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Wed, 13 Feb 2019 12:52:11 +0100 Subject: [PATCH] Revert "efi_loader: query serial console size reliably" When an usb keyboard is connected to the RPi3, the console size detection hangs until a key is pressed. Revert the commit which introduced the bug. This reverts commit 6bb591f7041fdd201814b8866c1a55775662ab7f. Signed-off-by: Matthias Brugger --- lib/efi_loader/efi_console.c | 50 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 66c33a551d..b5930aee59 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -185,56 +185,32 @@ static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols) return (mode->rows == rows) && (mode->columns == cols); } -/** - * query_console_serial() - query console size - * - * @rows pointer to return number of rows - * @columns pointer to return number of columns - * Returns 0 on success - */ static int query_console_serial(int *rows, int *cols) { - int ret = 0; - int n[2]; + /* Ask the terminal about its size */ + int n[3]; u64 timeout; /* Empty input buffer */ while (tstc()) getc(); - /* - * Not all terminals understand CSI [18t for querying the console size. - * We should adhere to escape sequences documented in the console_codes - * man page and the ECMA-48 standard. - * - * So here we follow a different approach. We position the cursor to the - * bottom right and query its position. Before leaving the function we - * restore the original cursor position. - */ - printf(ESC "7" /* Save cursor position */ - ESC "[r" /* Set scrolling region to full window */ - ESC "[999;999H" /* Move to bottom right corner */ - ESC "[6n"); /* Query cursor position */ + printf(ESC"[18t"); - /* Allow up to one second for a response */ + /* Check if we have a terminal that understands */ timeout = timer_get_us() + 1000000; while (!tstc()) - if (timer_get_us() > timeout) { - ret = -1; - goto out; - } + if (timer_get_us() > timeout) + return -1; - /* Read {rows,cols} */ - if (term_read_reply(n, 2, 'R')) { - ret = 1; - goto out; - } + /* Read {depth,rows,cols} */ + if (term_read_reply(n, 3, 't')) + return -1; - *cols = n[1]; - *rows = n[0]; -out: - printf(ESC "8"); /* Restore cursor position */ - return ret; + *cols = n[2]; + *rows = n[1]; + + return 0; } /*