From patchwork Wed Apr 19 04:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1770533 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Re8ANXBj; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q1S6w3f4gz1yZk for ; Wed, 19 Apr 2023 14:12:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1EFE98627E; Wed, 19 Apr 2023 06:05:26 +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="Re8ANXBj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B617C86211; Wed, 19 Apr 2023 06:04:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) (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 763EE86241 for ; Wed, 19 Apr 2023 06:04: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-io1-xd2a.google.com with SMTP id ca18e2360f4ac-763703a6df9so33824039f.3 for ; Tue, 18 Apr 2023 21:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681877054; x=1684469054; 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=cMSHwcm7tGgbjLjTxpRiz8QAh4aEOcWlmqmbLrhed1A=; b=Re8ANXBjOqX+4zEt5HedB/GcqR6RmjRaoYymrBauUZUWGjs0neHKPIjo+2jkaj7C54 1LjeVUjsGWW9ENhI5Lhzr1ZsfFWzIGf3vL2uJz7lFZm0hJX8DTKpx9T7AYxRw6NyyS+5 adamWmoNxJOMVsSE/cUGnVD744sJvSSdb9U5k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681877054; x=1684469054; 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=cMSHwcm7tGgbjLjTxpRiz8QAh4aEOcWlmqmbLrhed1A=; b=PR1sUAOdXjRsgYaAMkxil6GCSgtcMDaOktM60AiNCHppcStJ24CKzwvhI4ytbHTN1O rbU8rAgf03ZvDOmHpMO7xt7aE6P9DzdbeyhKDbqqZpGIkEJwZZh/P6/+xs+VQKpynX6Q KGU2LofrfHX7xxJuwsq5pX5rhmvTyhrlYx2IUWCSWJu5BuGNeQVZ+Gq/a8Obpv1l9xed ym/0yuXX668s7E4g1newwhytZB9W1yM7rpalbtY9UDd8qvo1lmhz3uwHEKydws8AV2/u QLe/uq2y8mvfSHLGb55V29n/CbeJ3EBFjlg0EHjQ8z0hTR8ewk1zB2Nz0Q7Dr8ON14HC fX9A== X-Gm-Message-State: AAQBX9flz31mGXceTg4lrKLc53hF1X2mbVKrRja2cT8jaPEOSby5xFIm BzK6PYAyvt/xFuh5PaH1TQZsmXkzSj2vhtsYrq0= X-Google-Smtp-Source: AKy350Zom/vWfdaHX2jOqhH4f8TucVjCZG6zpw+zAXKO01Z9whL3XRBtwjtjBljMmvsR3aYTK8/Puw== X-Received: by 2002:a5e:d705:0:b0:760:debf:6c42 with SMTP id v5-20020a5ed705000000b00760debf6c42mr3320720iom.20.1681877054633; Tue, 18 Apr 2023 21:04:14 -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 i4-20020a05663815c400b0040f91082a4fsm3261982jat.75.2023.04.18.21.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 21:04:14 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Bin Meng , Simon Glass Subject: [PATCH v2 42/42] efi: Use the installed ACPI tables Date: Wed, 19 Apr 2023 16:03:14 +1200 Message-ID: <20230419160308.v2.42.I86db03df16c50b2b03532f99064a26c14704056f@changeid> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230419040314.160352-1-sjg@chromium.org> References: <20230419040314.160352-1-sjg@chromium.org> MIME-Version: 1.0 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 U-Boot sets up the ACPI tables during startup. Rather than creating a new set, install the existing ones. Create a memory-map record to cover the tables. Signed-off-by: Simon Glass --- Changes in v2: - Drop patch to set high bits of the mtrr base register, for now lib/efi_loader/efi_acpi.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c index 2ddc3502b5df..f755af76f866 100644 --- a/lib/efi_loader/efi_acpi.c +++ b/lib/efi_loader/efi_acpi.c @@ -10,6 +10,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; @@ -20,26 +23,28 @@ static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; */ efi_status_t efi_acpi_register(void) { - /* Map within the low 32 bits, to allow for 32bit ACPI tables */ - u64 acpi = U32_MAX; + ulong addr, start, end; efi_status_t ret; - ulong addr; - /* Reserve 64kiB page for ACPI */ - ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_ACPI_RECLAIM_MEMORY, 16, &acpi); + /* Mark space used for tables */ + start = ALIGN_DOWN(gd->arch.table_start, EFI_PAGE_MASK); + end = ALIGN(gd->arch.table_end, EFI_PAGE_MASK); + ret = efi_add_memory_map(start, end - start, EFI_ACPI_RECLAIM_MEMORY); if (ret != EFI_SUCCESS) return ret; + if (gd->arch.table_start_high) { + start = ALIGN_DOWN(gd->arch.table_start_high, EFI_PAGE_MASK); + end = ALIGN(gd->arch.table_end_high, EFI_PAGE_MASK); + ret = efi_add_memory_map(start, end - start, + EFI_ACPI_RECLAIM_MEMORY); + if (ret != EFI_SUCCESS) + return ret; + } - /* - * Generate ACPI tables - we know that efi_allocate_pages() returns - * a 4k-aligned address, so it is safe to assume that - * write_acpi_tables() will write the table at that address. - */ - addr = map_to_sysmem((void *)(ulong)acpi); - write_acpi_tables(addr); + addr = gd_acpi_start(); + printf("EFI using ACPI tables at %lx\n", addr); /* And expose them to our EFI payload */ return efi_install_configuration_table(&acpi_guid, - (void *)(uintptr_t)acpi); + (void *)(ulong)addr); }