From patchwork Sun Sep 10 11:21:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 812116 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="boxm05w7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xqpvj447Bz9sDB for ; Sun, 10 Sep 2017 21:37:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4C9B6C21E8C; Sun, 10 Sep 2017 11:29:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5D41FC21F2D; Sun, 10 Sep 2017 11:26:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 85C7DC21E41; Sun, 10 Sep 2017 11:24:10 +0000 (UTC) Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by lists.denx.de (Postfix) with ESMTPS id 5F7DBC21F0A for ; Sun, 10 Sep 2017 11:24:01 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id q8so4090729qtb.1 for ; Sun, 10 Sep 2017 04:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zmASFMSzYWSBSdugC77vjUNtmmQgCCSF2tHQAtczTpw=; b=boxm05w7nVv48S45/bKwIKjF/Gp5Wtx9LgdVGxLs4c1upk7qJyh6zakp5SigduKBZO PINwNEdq3jfhH96AQds5mmT0/kfpaCQG7johB8Mgp7wvldhvsZxMWZfgBIgEEY57WfL0 Z3yTvA45ewyhnGjCvAeDWmFGvT3ucrvifLl/sOfUWWI0BBJ6cNu/2YQ69T33teQOO/pe 89pIj3Rj3wLr94wBtgl89/Zfu5IqJ6Rfu7WPsM6FHxO+tnSFJb5ZtjjlPrKIrRlV2oD/ BNarFUIYM8Q1SBgWfz/DNvuSDAu0TeiPLN1D37+BGJdpFyiT060tba4DK8iKR+GcYJLe tCGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zmASFMSzYWSBSdugC77vjUNtmmQgCCSF2tHQAtczTpw=; b=UlnP43pYeNuq3ZLXolFVUuCl5EGcAh2wi1DmL2ugyPotkgECCFOvCCtz9uyRySNwlG V6lYbcG6XilDrhFDcZVhBa6fDoUweusrgJNo9IgP6RiYn1jFRBpF9CTy9hf73wgKNWwJ k2FDGXzoh25MM8bnel8Td92WGhnM2n+nAOy5EesrDhiYZxAxFG61XY0pxCr94+04xrSd t4aoG4ZEfeYnO1G2hpKBc4y+yc5jjYtSC4h1pyOf1xclLK1wZlGyhs5lcr3sxK+6l8pi sp0D8FobaQCP86ysmNGmVRdTtmN28jLqpYcyHs+luslV/YbcaQxdIcPWaGZPc52vgYG8 e+Hg== X-Gm-Message-State: AHPjjUjUX4L3f7R3yzpAyqpao5bkUf41cydAvvaWiW0kA/reor9mpd36 sJ81NNQdTs2aU30krxk= X-Google-Smtp-Source: AOwi7QDbGNeIw41Jee/zf19SfBxERxFMhqM2sxKduamVZLkC2TWM0sE/Kw2cM89WP9iDael+VaBxOw== X-Received: by 10.200.50.149 with SMTP id z21mr12918338qta.37.1505042640131; Sun, 10 Sep 2017 04:24:00 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id k20sm4185334qtj.2.2017.09.10.04.23.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 10 Sep 2017 04:23:58 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Sun, 10 Sep 2017 07:21:45 -0400 Message-Id: <20170910112149.21358-29-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170910112149.21358-1-robdclark@gmail.com> References: <20170910112149.21358-1-robdclark@gmail.com> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v2 19/21] efi_loader: split out escape sequence based size query X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- lib/efi_loader/efi_console.c | 53 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3fc82b8726..e8c02870eb 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) {