Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62FCBC001DB for ; Sun, 13 Aug 2023 20:10:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E47380842; Sun, 13 Aug 2023 22:10:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="SMr4gaSu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D9A480DF7; Sun, 13 Aug 2023 22:10:47 +0200 (CEST) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 25823807C4 for ; Sun, 13 Aug 2023 22:10:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7908ff76516so85173839f.1 for ; Sun, 13 Aug 2023 13:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691957443; x=1692562243; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LXGPXpcgJnxhBQ3YIyXzrr5V5rk7NkEc5U1SAOvrME0=; b=SMr4gaSu+dNJN59BoHeZDDVlSBrE1T6Sd+Rqd0js20pqFQ+xm8wtcq8biuwPEdqXPD egItWFb5ea//FpVCqsxIxzsPRPkD2kAon8QK4W9KxtSR7ZuoHhFv646SCbr/nnmDUFfX jYi1iebcp7iK/EwqpkB3pLL12Zby1XnWKkucA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691957443; x=1692562243; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LXGPXpcgJnxhBQ3YIyXzrr5V5rk7NkEc5U1SAOvrME0=; b=Koo7D/H8AcD+9KGqYrpnvhBs35oGGw/fC9H+4wLpBn8yb7j3S6rXJqTeoR0Cn97Gpz 1RPB4WMhMHDKfF7l6ZQ/ZUBuqnkXG+wfSVloodyxRU8RqTTis0zWbSx5nkzoEjpTRxs+ 6kLD6fXG8l0rQmzIZfxO1HgIiAIDdz2xSRETBKG8K8D2cyA0H3YL/e91j79zhH/iwvmV IhBmFN5w2hnHO+Lj9/ZrgtmxBrb4il85tW4r+pK2x9n2HN8nTCR8MYhHEO3GlK4WRRjd Ef7GDE9JsLtyawMo5Y+yVG80kcSyt4m98fbc9XLDZu1sRk28DwEUccntp6BwkgKoNmJ0 qewA== X-Gm-Message-State: AOJu0YwGge6G/7rwsvxbK8Zg/OF6+hyjPH10JYjmxQQcEwUO0onuKmWz 15H+0rVZrkrf5cl3LPuLu1VSeHcOxJQKOtLveVY= X-Google-Smtp-Source: AGHT+IGHs3/uXxbE7dk9ajOoIfap5nTZEue/3WLfQs7ucEXTX466fpSp+Kd5cd6WVY3rd1UMefAnXA== X-Received: by 2002:a05:6602:1549:b0:790:96ba:ecb3 with SMTP id h9-20020a056602154900b0079096baecb3mr15171929iow.10.1691957443476; Sun, 13 Aug 2023 13:10:43 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id g3-20020a0566380c4300b004311d1cdef1sm2518434jal.169.2023.08.13.13.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 13:10:43 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Bin Meng , Jean-Marie Lemetayer , Jonas Karlman , Kever Yang , Peng Fan , Vladimir Zapolskiy Subject: [PATCH] x86: Update cbmem driver Date: Sun, 13 Aug 2023 14:10:35 -0600 Message-ID: <20230813201038.413362-1-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean This driver is not actually built since a Kconfig was never created for it. Add a Kconfig (which is already implied by COREBOOT) and update the implementation to avoid using unnecessary memory. Drop the #ifdef at the top since we can rely on Kconfig to get that right. To enable it (in addition to serial and video), use: setenv stdout serial,vidconsole,cbmem Signed-off-by: Simon Glass --- drivers/misc/Kconfig | 8 ++++++++ drivers/misc/cbmem_console.c | 26 +++++++++----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index b9f5c7a37aed..3df57a5bfbd9 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -122,6 +122,14 @@ config VEXPRESS_CONFIG configuration bus on the Arm Versatile Express boards via a sysreg driver. +config CBMEM_CONSOLE + bool "Write console output to coreboot cbmem" + depends on X86 + help + Enables console output to the cbmem console, which is a memory + region set up by coreboot to hold a record of all console output. + Enable this only if booting from coreboot. + config CMD_CROS_EC bool "Enable crosec command" depends on CROS_EC diff --git a/drivers/misc/cbmem_console.c b/drivers/misc/cbmem_console.c index 8bbe33d414da..6ae1389a23e0 100644 --- a/drivers/misc/cbmem_console.c +++ b/drivers/misc/cbmem_console.c @@ -5,27 +5,20 @@ #include #include -#ifndef CONFIG_SYS_COREBOOT -#error This driver requires coreboot -#endif - #include -struct cbmem_console { - u32 buffer_size; - u32 buffer_cursor; - u8 buffer_body[0]; -} __attribute__ ((__packed__)); - -static struct cbmem_console *cbmem_console_p; - void cbmemc_putc(struct stdio_dev *dev, char data) { - int cursor; + const struct sysinfo_t *sysinfo = cb_get_sysinfo(); + struct cbmem_console *cons = sysinfo ? sysinfo->cbmem_cons : NULL; + int pos; + + if (!cons) + return; - cursor = cbmem_console_p->buffer_cursor++; - if (cursor < cbmem_console_p->buffer_size) - cbmem_console_p->buffer_body[cursor] = data; + pos = cons->cursor++; + if (pos < cons->size) + cons->body[pos] = data; } void cbmemc_puts(struct stdio_dev *dev, const char *str) @@ -40,7 +33,6 @@ int cbmemc_init(void) { int rc; struct stdio_dev cons_dev; - cbmem_console_p = lib_sysinfo.cbmem_cons; memset(&cons_dev, 0, sizeof(cons_dev)); -- 2.41.0.640.ga95def55d0-goog