summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-09-13 18:05:42 -0400
committerAlexander Graf <agraf@suse.de>2017-09-20 11:14:12 +0200
commit71cc25c35c34945babbd94935a0e9c4f4ee942b2 (patch)
tree2e93da0ee796d08ef71d584f9f7423202586bff3 /lib
parent778e6af8a6e78f8754aaf5d9b80a51a267da10c7 (diff)
efi_loader: split out escape sequence based size query
We need to do something different for vidconsole, since it cannot respond to the query on stdin. Prep work for next patch. Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_console.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c
index 65c07fdf37..6502081706 100644
--- a/lib/efi_loader/efi_console.c
+++ b/lib/efi_loader/efi_console.c
@@ -186,6 +186,34 @@ static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols)
return (mode->rows == rows) && (mode->columns == cols);
}
+static int query_console_serial(int *rows, int *cols)
+{
+ /* Ask the terminal about its size */
+ int n[3];
+ u64 timeout;
+
+ /* Empty input buffer */
+ while (tstc())
+ getc();
+
+ printf(ESC"[18t");
+
+ /* Check if we have a terminal that understands */
+ timeout = timer_get_us() + 1000000;
+ while (!tstc())
+ if (timer_get_us() > timeout)
+ return -1;
+
+ /* Read {depth,rows,cols} */
+ if (term_read_reply(n, 3, 't'))
+ return -1;
+
+ *cols = n[2];
+ *rows = n[1];
+
+ return 0;
+}
+
static efi_status_t EFIAPI efi_cout_query_mode(
struct efi_simple_text_output_protocol *this,
unsigned long mode_number, unsigned long *columns,
@@ -194,33 +222,12 @@ static efi_status_t EFIAPI efi_cout_query_mode(
EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
if (!console_size_queried) {
- /* Ask the terminal about its size */
- int n[3];
- int cols;
- int rows;
- u64 timeout;
+ int rows, cols;
console_size_queried = true;
- /* Empty input buffer */
- while (tstc())
- getc();
-
- printf(ESC"[18t");
-
- /* Check if we have a terminal that understands */
- timeout = timer_get_us() + 1000000;
- while (!tstc())
- if (timer_get_us() > timeout)
- goto out;
-
- /* Read {depth,rows,cols} */
- if (term_read_reply(n, 3, 't')) {
+ if (query_console_serial(&rows, &cols))
goto out;
- }
-
- cols = n[2];
- rows = n[1];
/* Test if we can have Mode 1 */
if (cols >= 80 && rows >= 50) {