{"id":813651,"url":"http://patchwork.ozlabs.org/api/patches/813651/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170913220546.19560-22-robdclark@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170913220546.19560-22-robdclark@gmail.com>","list_archive_url":null,"date":"2017-09-13T22:05:44","name":"[U-Boot,v3,21/21] efi_loader: Some console improvements for vidconsole","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c787c91fbe1d4fe0ec8604835c99549a2ee5b0d2","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/?format=json","name":"Rob Clark","email":"robdclark@gmail.com"},"delegate":{"id":3400,"url":"http://patchwork.ozlabs.org/api/users/3400/?format=json","username":"agraf","first_name":"Alexander","last_name":"Graf","email":"agraf@suse.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170913220546.19560-22-robdclark@gmail.com/mbox/","series":[{"id":2990,"url":"http://patchwork.ozlabs.org/api/series/2990/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=2990","date":"2017-09-13T22:05:23","name":"efi_loader: enough UEFI for standard distro boot","version":3,"mbox":"http://patchwork.ozlabs.org/series/2990/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/813651/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/813651/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"p19Gjsn9\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xswzG1kg8z9s76\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Sep 2017 08:18:18 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 021A5C22739; Wed, 13 Sep 2017 22:11:40 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 8353BC22440;\n\tWed, 13 Sep 2017 22:09:19 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 293F4C22649; Wed, 13 Sep 2017 22:07:00 +0000 (UTC)","from mail-qk0-f193.google.com (mail-qk0-f193.google.com\n\t[209.85.220.193])\n\tby lists.denx.de (Postfix) with ESMTPS id 23125C222F6\n\tfor <u-boot@lists.denx.de>; Wed, 13 Sep 2017 22:06:57 +0000 (UTC)","by mail-qk0-f193.google.com with SMTP id g128so957656qke.0\n\tfor <u-boot@lists.denx.de>; Wed, 13 Sep 2017 15:06:57 -0700 (PDT)","from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\tc7sm6554168qtg.30.2017.09.13.15.06.54\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 13 Sep 2017 15:06:54 -0700 (PDT)"],"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,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=tTjJNgm+knfE2IVXbgcSZPd7Q9s0s6Q4yiWNU5LVgTo=;\n\tb=p19Gjsn94q8hJs1Xa1e60A1TEdRggJDYW4/tjg5KNI+WXmBIDg69dJHSv5vg9qVqyk\n\t1swG+00Mm1XRKUrayK7c+dhRH1w+uQAI8iTGsybpDDEwOI34BggMaO13Xg7PHSjX1G0R\n\t24kED1+O/e/7IvWW8UAmBiGqGws6BpZg4CNEzwIWhfaDxysFr26DISc1gR+sWnDGizbC\n\tZYL7w8/wDhNWlMd8OAvkbb93PccezIDl0MBhuwWsBkZqnq+11Zp8zsd3PNVFPovQMvp2\n\t5pENu/Y8WbWLKmJJavNtOR4z05ltwErLhVhkk6dMWd1Ph8jDcQnFWmPQHB3rBCVVY1Qb\n\tjo3Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=tTjJNgm+knfE2IVXbgcSZPd7Q9s0s6Q4yiWNU5LVgTo=;\n\tb=c8HcUQiVDfqnG0BpVi1cdALXvBcSAPVrVXTr9qyo5vtDcIx5Hwd4BpzDPx8483kEFD\n\t2tcirt8ES1bGcpBB48Hwzrk7TDHJQ05HtOwwPIfE7BQtlRRGk1c27mOeWf3fASeDhhVG\n\ta6OT7w0gATPNqgX1mSwD0+h9Lz3bPt3l0Gab26u/0KocZMVoWiNo1iilybUBpjY/reKK\n\tcp797hnlW70DHEJd/KgIbe2YYhXe6uQNnRPeKrhX+SfmTJburQzA1Sr9J4xZGwHDYkUr\n\t9WRzv0zJUNyi8aViEbP8c8Ij30Ohh0DMU+Krio7yF3EC3Wgkedzhw13id7AQP7nPGIQG\n\t75dg==","X-Gm-Message-State":"AHPjjUiP2byD/mAlDDZ2e5Mjh/b0IgblXojyxgjLq8i2aeagseYl6VtI\n\tupIz6p1yFt2av6I79DU=","X-Google-Smtp-Source":"AOwi7QAgQ2WMpVM6BL8QwKJkWqUvVnw/9ycqdDqC95Qin0teqklmoO7YOnQn2VRsqP8FvBxYjj+XEA==","X-Received":"by 10.55.98.18 with SMTP id w18mr27728572qkb.163.1505340415863; \n\tWed, 13 Sep 2017 15:06:55 -0700 (PDT)","From":"Rob Clark <robdclark@gmail.com>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Wed, 13 Sep 2017 18:05:44 -0400","Message-Id":"<20170913220546.19560-22-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 <xypron.glpk@gmx.de>, Peter Jones <pjones@redhat.com>","Subject":"[U-Boot] [PATCH v3 21/21] efi_loader: Some console improvements for\n\tvidconsole","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"1) use fputs() to reduce cache flushes from once-per-char to\n   once-per-string\n2) handle \\r, \\t, and \\b in addition to just \\n for tracking\n   cursor position\n3) cursor row/col are zero based, not one based\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n include/efi_api.h            |  6 +++--\n lib/efi_loader/efi_console.c | 58 ++++++++++++++++++++++++++------------------\n 2 files changed, 39 insertions(+), 25 deletions(-)","diff":"diff --git a/include/efi_api.h b/include/efi_api.h\nindex 604c5b7ec4..c3b9032a48 100644\n--- a/include/efi_api.h\n+++ b/include/efi_api.h\n@@ -29,6 +29,8 @@ enum efi_timer_delay {\n };\n \n #define UINTN size_t\n+typedef long INTN;\n+typedef uint16_t *efi_string_t;\n \n #define EVT_TIMER\t\t\t\t0x80000000\n #define EVT_RUNTIME\t\t\t\t0x40000000\n@@ -427,10 +429,10 @@ struct efi_simple_text_output_protocol {\n \tvoid *reset;\n \tefi_status_t (EFIAPI *output_string)(\n \t\t\tstruct efi_simple_text_output_protocol *this,\n-\t\t\tconst unsigned short *str);\n+\t\t\tconst efi_string_t str);\n \tefi_status_t (EFIAPI *test_string)(\n \t\t\tstruct efi_simple_text_output_protocol *this,\n-\t\t\tconst unsigned short *str);\n+\t\t\tconst efi_string_t str);\n \tefi_status_t(EFIAPI *query_mode)(\n \t\t\tstruct efi_simple_text_output_protocol *this,\n \t\t\tunsigned long mode_number, unsigned long *columns,\ndiff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c\nindex 9048a8d32c..afc725a2c7 100644\n--- a/lib/efi_loader/efi_console.c\n+++ b/lib/efi_loader/efi_console.c\n@@ -140,34 +140,46 @@ static efi_status_t EFIAPI efi_cout_reset(\n \treturn EFI_EXIT(EFI_UNSUPPORTED);\n }\n \n-static void print_unicode_in_utf8(u16 c)\n-{\n-\tchar utf8[MAX_UTF8_PER_UTF16] = { 0 };\n-\tutf16_to_utf8((u8 *)utf8, &c, 1);\n-\tputs(utf8);\n-}\n-\n static efi_status_t EFIAPI efi_cout_output_string(\n \t\t\tstruct efi_simple_text_output_protocol *this,\n-\t\t\tconst unsigned short *string)\n+\t\t\tconst efi_string_t string)\n {\n-\tstruct cout_mode *mode;\n-\tu16 ch;\n+\tstruct simple_text_output_mode *con = &efi_con_mode;\n+\tstruct cout_mode *mode = &efi_cout_modes[con->mode];\n \n-\tmode = &efi_cout_modes[efi_con_mode.mode];\n \tEFI_ENTRY(\"%p, %p\", this, string);\n-\tfor (;(ch = *string); string++) {\n-\t\tprint_unicode_in_utf8(ch);\n-\t\tefi_con_mode.cursor_column++;\n-\t\tif (ch == '\\n') {\n-\t\t\tefi_con_mode.cursor_column = 1;\n-\t\t\tefi_con_mode.cursor_row++;\n-\t\t} else if (efi_con_mode.cursor_column > mode->columns) {\n-\t\t\tefi_con_mode.cursor_column = 1;\n-\t\t\tefi_con_mode.cursor_row++;\n+\n+\tunsigned n16 = utf16_strlen(string);\n+\tchar buf[MAX_UTF8_PER_UTF16 * n16 + 1];\n+\tchar *p;\n+\n+\t*utf16_to_utf8((u8 *)buf, string, n16) = '\\0';\n+\n+\tfputs(stdout, buf);\n+\n+\tfor (p = buf; *p; p++) {\n+\t\tswitch (*p) {\n+\t\tcase '\\r':   /* carriage-return */\n+\t\t\tcon->cursor_column = 0;\n+\t\t\tbreak;\n+\t\tcase '\\n':   /* newline */\n+\t\t\tcon->cursor_column = 0;\n+\t\t\tcon->cursor_row++;\n+\t\t\tbreak;\n+\t\tcase '\\t':   /* tab, assume 8 char align */\n+\t\t\tbreak;\n+\t\tcase '\\b':   /* backspace */\n+\t\t\tcon->cursor_column = max(0, con->cursor_column - 1);\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tcon->cursor_column++;\n+\t\t\tbreak;\n+\t\t}\n+\t\tif (con->cursor_column >= mode->columns) {\n+\t\t\tcon->cursor_column = 0;\n+\t\t\tcon->cursor_row++;\n \t\t}\n-\t\tif (efi_con_mode.cursor_row > mode->rows)\n-\t\t\tefi_con_mode.cursor_row = mode->rows;\n+\t\tcon->cursor_row = min(con->cursor_row, (s32)mode->rows - 1);\n \t}\n \n \treturn EFI_EXIT(EFI_SUCCESS);\n@@ -175,7 +187,7 @@ static efi_status_t EFIAPI efi_cout_output_string(\n \n static efi_status_t EFIAPI efi_cout_test_string(\n \t\t\tstruct efi_simple_text_output_protocol *this,\n-\t\t\tconst unsigned short *string)\n+\t\t\tconst efi_string_t string)\n {\n \tEFI_ENTRY(\"%p, %p\", this, string);\n \treturn EFI_EXIT(EFI_SUCCESS);\n","prefixes":["U-Boot","v3","21/21"]}