From nobody Thu Mar 28 17:52:46 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zoho.com; dkim=fail spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org; Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1492641412323716.094762466952; Wed, 19 Apr 2017 15:36:52 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1d0yDI-0002RX-Ud; Thu, 20 Apr 2017 00:36:41 +0200 Received: from mail-io0-f176.google.com ([209.85.223.176]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.86_2) (envelope-from ) id 1d0yD6-0002QH-FN for seabios@seabios.org; Thu, 20 Apr 2017 00:36:36 +0200 Received: by mail-io0-f176.google.com with SMTP id o22so43600632iod.3 for ; Wed, 19 Apr 2017 15:36:28 -0700 (PDT) Received: from jwerner-linux.mtv.corp.google.com ([172.22.64.164]) by smtp.gmail.com with ESMTPSA id d187sm6342966pfd.47.2017.04.19.15.36.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Apr 2017 15:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=cwnFYoxRxxfYCdrrnWuTHkMShiBFVegX0Z4CAA5SRu0=; b=a+5782hbfRKEOnDYpx0MtWvRbNnJqNMxs8TDOiza/LbYjHZRcCBMDDg4/g7Cgb+FWE WZUYqE1osJXh6IuaqWJxAHcuOuxHjl49ztMrO3RFvR8l8ZECtlGVXALWTOzHLOp6aUG8 7O9M4474+8Eo9Rs470jUCgO2B4xdOz6Ys6RAE= 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; bh=cwnFYoxRxxfYCdrrnWuTHkMShiBFVegX0Z4CAA5SRu0=; b=XUdmD5zrh426+YdAWzHtwVCLRhJQlTAOus+JIdV5iRlt7pGs2KjEEz2UAypshiH+7T 2J5FOVC0ByMy4Fl9xQR2xgmG865D52Y5+eLER89fizbS13CJx9iUG6YpKo5CfsfvM8N9 E+TQ+JFFJthMDbJeBCTpiLExFZ2VA+BvKbOP4Zc2T1hTh6XOxvclXs0Ppb35pajh4LjJ Mrtt92+PTVqppPXde3WcTe6p18OBHnbKfp5Adr9BbxHC4qEQ7pf34RxO8heyY3q9uv3B 5Cc4IxBsS29vhrqpawY9HZDQ0goxmeQY6jiSvS/UpdPbUY5YazjsyaHv0UvcnxBrPq/z r38w== X-Gm-Message-State: AN3rC/7gcW+MSWQXrWqZiPJ8ucI2+xa+uXBC3bEgObKDR1rYHd9dHaDd YvGilwRPs9wXYDAy X-Received: by 10.84.238.9 with SMTP id u9mr6601308plk.174.1492641386157; Wed, 19 Apr 2017 15:36:26 -0700 (PDT) From: Julius Werner To: seabios@seabios.org Date: Wed, 19 Apr 2017 15:36:09 -0700 Message-Id: <20170419223609.15116-1-jwerner@chromium.org> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog X-Spam-Score: -2.7 (--) Subject: [SeaBIOS] [PATCH] coreboot: Adapt to upstream CBMEM console changes X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julius Werner , Gerd Hoffmann MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" coreboot's CBMEM console format changed with https://review.coreboot.org/#/c/18301. This patch adapts the SeaBIOS implementation to support the new format. (SeaBIOS versions with this patch will continue to work fine with older version of coreboot. SeaBIOS versions without this patch may fail to log messages to the CBMEM console if run with newer versions of coreboot, but should not experience any more serious issues than that.) Signed-off-by: Julius Werner --- src/fw/coreboot.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c index 4957b80..7214f8a 100644 --- a/src/fw/coreboot.c +++ b/src/fw/coreboot.c @@ -80,10 +80,12 @@ struct cb_cbmem_ref { #define CB_TAG_CBMEM_CONSOLE 0x17 =20 struct cbmem_console { - u32 buffer_size; - u32 buffer_cursor; - u8 buffer_body[0]; + u32 size; + u32 cursor; + u8 body[0]; } PACKED; +#define CBMC_CURSOR_MASK ((1 << 28) - 1) +#define CBMC_OVERFLOW (1 << 31) static struct cbmem_console *cbcon =3D NULL; =20 static u16 @@ -220,9 +222,16 @@ void coreboot_debug_putc(char c) return; if (!cbcon) return; - u32 cursor =3D cbcon->buffer_cursor++; - if (cursor < cbcon->buffer_size) - cbcon->buffer_body[cursor] =3D c; + u32 cursor =3D cbcon->cursor & CBMC_CURSOR_MASK; + u32 flags =3D cbcon->cursor & ~CBMC_CURSOR_MASK; + if (cursor >=3D cbcon->size) + return; // Old coreboot version with legacy overflow mechanism. + cbcon->body[cursor++] =3D c; + if (cursor >=3D cbcon->size) { + cursor =3D 0; + flags |=3D CBMC_OVERFLOW; + } + cbcon->cursor =3D flags | cursor; } =20 /**************************************************************** --=20 2.12.2.816.g2cccc81164-goog _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios