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 85C93EB64DA for ; Mon, 19 Jun 2023 12:13:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1C36384673; Mon, 19 Jun 2023 14:09:59 +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="cwIBHwIS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A42288631F; Mon, 19 Jun 2023 14:03:34 +0200 (CEST) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (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 2DE9C8637D for ; Mon, 19 Jun 2023 14:02:19 +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-wr1-x429.google.com with SMTP id ffacd0b85a97d-3112f5ab0b1so1411040f8f.0 for ; Mon, 19 Jun 2023 05:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1687176137; x=1689768137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P7xvFpczpvXQQfN1+j39sOvlO7oMiPke3m9WOuHH1kg=; b=cwIBHwISUVNhQkGyAEtAtdwvzQNJ3Vo1lz0ircLgVy1OK4LZAEM7UTCmLVwyUezd4k BSQdhydwVEfELElziL8cGHiyScCOjwUTxVcJLxR/G+crCgcD3bzweyTujmYNxHDcGUP9 Pfahohp+4VVKVBS8oCnM/sf2yAiKev0IcjZLo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687176137; x=1689768137; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P7xvFpczpvXQQfN1+j39sOvlO7oMiPke3m9WOuHH1kg=; b=lTxv88S2vKyF7G1LYDHknIg/vgmvM5Tvtk92wPITVpKjXfbvGFUOXDKWhqCfnnxhML T86PxZj8ZCI8XbYgtJA0TVC+2h5PotLPaePvLaVAyqNI3NU6k92dckEpF2DPFJcNMBul IUTIi7eH+RuKxCKnRwyMrA5JdPXTPvIqSBIQK5yOFb+jUy1rWR23tPE6RzW99RucFsxW sA2mMOSSRoAIvvUp+nESc0CbiJzdQXgoLCsJ1zmjgHzDCcuxJASKHaHus7t1aQVOmB6c inJcnHn9wTh+W3SGg/B0D6akDgBlHmlU/4Gi5/IalXd0VypttKcu2qlDfopKXLVrpdpz iX/Q== X-Gm-Message-State: AC+VfDxprVHrSYZmHjgRd/4syQo5cbeIQTwQg0FK6A580lAOk6cLq6Rb PGN7dVaQcm5Z42JCLm5C5zkG+rkUrLCMM8Bfw+k= X-Google-Smtp-Source: ACHHUZ7cK8SPU7P19eO6+PT6fjTAv9w6QONgNovkkyEUmiwSVAi3D3qVEUJ4hPpqq0U2FQVA5eLNwQ== X-Received: by 2002:a5d:4e08:0:b0:30f:caf6:5bde with SMTP id p8-20020a5d4e08000000b0030fcaf65bdemr5356693wrt.32.1687176137470; Mon, 19 Jun 2023 05:02:17 -0700 (PDT) Received: from sjg1.roam.corp.google.com (79-67-123-132.dynamic.dsl.as9105.com. [79.67.123.132]) by smtp.gmail.com with ESMTPSA id k6-20020adff5c6000000b0031122bd3c82sm8886794wrp.17.2023.06.19.05.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 05:02:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Bin Meng , Nikhil M Jain , Simon Glass Subject: [PATCH v4 34/45] x86: Refactor table-writing code a litlle Date: Mon, 19 Jun 2023 12:59:49 +0100 Message-ID: <20230619120011.1587499-5-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog In-Reply-To: <20230619120011.1587499-1-sjg@chromium.org> References: <20230619120011.1587499-1-sjg@chromium.org> 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 The implementation of write_tables() is confusing because it uses the rom_table_start variable as the address pointer as it progresses. Rename it to rom_addr to make the code clearer. Move the rom_table_end variable into the block where it is used. Also update logging to use the ACPI category, now that it is available. Signed-off-by: Simon Glass --- (no changes since v3) Changes in v3: - Add new patch to refactor table-writing code a ltitle arch/x86/lib/tables.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c index ea834a5035f5..132c02ee80f4 100644 --- a/arch/x86/lib/tables.c +++ b/arch/x86/lib/tables.c @@ -3,7 +3,7 @@ * Copyright (C) 2015, Bin Meng */ -#define LOG_CATEGORY LOGC_BOARD +#define LOG_CATEGORY LOGC_ACPI #include #include @@ -78,33 +78,33 @@ void table_fill_string(char *dest, const char *src, size_t n, char pad) int write_tables(void) { - u32 rom_table_start; - u32 rom_table_end; u32 high_table, table_size; struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1]; + u32 rom_addr; int i; - rom_table_start = ROM_TABLE_ADDR; + rom_addr = ROM_TABLE_ADDR; - debug("Writing tables to %x:\n", rom_table_start); + debug("Writing tables to %x:\n", rom_addr); for (i = 0; i < ARRAY_SIZE(table_list); i++) { const struct table_info *table = &table_list[i]; int size = table->size ? : CONFIG_ROM_TABLE_SIZE; + u32 rom_table_end; if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) { - rom_table_start = (ulong)bloblist_add(table->tag, size, + rom_addr = (ulong)bloblist_add(table->tag, size, table->align); - if (!rom_table_start) + if (!rom_addr) return log_msg_ret("bloblist", -ENOBUFS); } - rom_table_end = table->write(rom_table_start); + rom_table_end = table->write(rom_addr); if (!rom_table_end) { log_err("Can't create configuration table %d\n", i); return -EINTR; } if (IS_ENABLED(CONFIG_SEABIOS)) { - table_size = rom_table_end - rom_table_start; + table_size = rom_table_end - rom_addr; high_table = (u32)(ulong)high_table_malloc(table_size); if (high_table) { if (!table->write(high_table)) { @@ -123,13 +123,13 @@ int write_tables(void) } debug("- wrote '%s' to %x, end %x\n", table->name, - rom_table_start, rom_table_end); - if (rom_table_end - rom_table_start > size) { + rom_addr, rom_table_end); + if (rom_table_end - rom_addr > size) { log_err("Out of space for configuration tables: need %x, have %x\n", - rom_table_end - rom_table_start, size); + rom_table_end - rom_addr, size); return log_msg_ret("bloblist", -ENOSPC); } - rom_table_start = rom_table_end; + rom_addr = rom_table_end; } if (IS_ENABLED(CONFIG_SEABIOS)) { -- 2.41.0.162.gfafddb0af9-goog