From patchwork Wed Sep 13 22:05:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 813654 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="kFuTe9iF"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xswzp0HkGz9s76 for ; Thu, 14 Sep 2017 08:18:45 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id CDD4AC22721; Wed, 13 Sep 2017 22:13:46 +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 70DDDC2259B; Wed, 13 Sep 2017 22:13:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 901DFC225AC; Wed, 13 Sep 2017 22:06:54 +0000 (UTC) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by lists.denx.de (Postfix) with ESMTPS id 43DA3C21F60 for ; Wed, 13 Sep 2017 22:06:51 +0000 (UTC) Received: by mail-qt0-f196.google.com with SMTP id t46so942300qtj.3 for ; Wed, 13 Sep 2017 15:06:51 -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=kFuTe9iFoM7alWc7OE//IW/e/FV9tGgl3TmgTr+eO3FfQ5DSYjJ3wT1R+OBdYJWUVN To7NgcPgMSHiv5B14sFvJDUyyW2pHFwR+nHM5oseqzbSkpFyU5RTsSrlkVitTl4wv5tc tFGsnkT6p+oYOAFKeZPsjaSMMnIa6iFGdjotOiTrZgJqQ4gae8yjEkiD7cbmQf52O6y5 s5U9Nk4lady+7rLd2ColCYfLnLAtwpdWRG1oKNgYD7wdEWYeNCZ0zwwuIgO4LhhFmMPl Gu3gQPQNdU9ulemvIpyrbZNAthwia5M3aQT4026flN4VrIYRYs6CRT3VNNtbwLPglINq z93A== 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=ncHBabtQIREf3nzqcTcD04pqNTPlQN5QL7RDlbcKAytx6hXn1aRaOMYHGeoEbWGliV tUcX+ecirmHWPEHxo7hJgFMjmtITcQzoc1HtCPvlIbXzAvznq0a9fHO8U4kCtNhPhZ/J A3kZOys/IRpEcpssDZlSyd2Q1LJWC7Y8p//mu1vhbNmqpyvcrWJR3jp6BKTo1OXwwrMm bK5Z2fi1XAQbgmHViPZ0rpk4Eoi9FRjLRpYgAvlJk4/k6ukDu20o0rZvmYDI9ZpFz6aD /UiPP+oYCRIFpAnimZlu/ys4wH07stj51rKpEOkKR1AO0srq1IZ/ldaictIdeAKV/KFM S9zg== X-Gm-Message-State: AHPjjUg5QvLZoY1nms5ryxt2wF/1uP1JwuYqW2xIrPZYJfoobrIv8I0e I0sbse8QSPC9/n3y6s8= X-Google-Smtp-Source: AOwi7QB5D3vB68JYN/LWdw+ga3IalxQ5ZmDXLtqToxqIs0x6Gbcpxt1klz1ZA41gXUW3fSuafiNl1w== X-Received: by 10.200.3.111 with SMTP id w47mr18698830qtg.144.1505340409985; Wed, 13 Sep 2017 15:06:49 -0700 (PDT) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id v11sm10398324qkl.45.2017.09.13.15.06.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Sep 2017 15:06:49 -0700 (PDT) From: Rob Clark To: U-Boot Mailing List Date: Wed, 13 Sep 2017 18:05:42 -0400 Message-Id: <20170913220546.19560-20-robdclark@gmail.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170913220546.19560-1-robdclark@gmail.com> References: <20170913220546.19560-1-robdclark@gmail.com> Cc: Heinrich Schuchardt Subject: [U-Boot] [PATCH v3 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) {