From patchwork Thu Jun 28 03:38:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 935905 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="qBwTPuOz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41GQQC6g1Rz9s1B for ; Thu, 28 Jun 2018 13:34:59 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9F7AEC21DD7; Thu, 28 Jun 2018 03:33:53 +0000 (UTC) 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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C5B8AC21DF3; Thu, 28 Jun 2018 03:33:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2EEC6C21DF8; Thu, 28 Jun 2018 03:33:21 +0000 (UTC) Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by lists.denx.de (Postfix) with ESMTPS id 6AC6AC21DA1 for ; Thu, 28 Jun 2018 03:33:17 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id z1-v6so1820410pgv.12 for ; Wed, 27 Jun 2018 20:33:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=N3tkaOCUQhNqvIhB0mi3JGXRolmbl24AhSl0s1TdeOI=; b=qBwTPuOz7+DexFc+/ns9g23IQT1vsp2xMFy+NNhQiIYEL8PZBeQ6Rk4KD9bWWKSBFB kbCA1BM/9YlT/X1Cny9jRNfynkY0dvRbrZVvjIFJjbQO/285c6sa6PwJx7CgnUuaH4dt KbEvLOU4t6baSo2kdEBJq2rWHQrL0d7Az6JVlCYFs4VD//DfL3S6k6TEKUbE9rN4pElG 6IB0I3bqBbzf6mtDC9rGv0LwJmtoh0ORuEqzxZtG69UFl0UpIKdySKgiuIMVvfbYrHRd /GXoQWLwotKCBEsP9zE2+1bkWNXovES42qfth0q5yndNYYPzsMttOrXXSMtm2pGQlbIy VxAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=N3tkaOCUQhNqvIhB0mi3JGXRolmbl24AhSl0s1TdeOI=; b=CAOUrSsXE+eb43zF9FKbSZMvRSS6ICPlwj7xd534plvifaXYAXiezmgMujlH3zePx5 e1N1So4dMbCuh0DdppVMaioE9kmPzPwDZKoKG4DmupbZqEOQgh2EI+y/2i3fO8wIMyo7 N99iDo6k7dl3ivE4kX4yozLxJavP8KqXmOpnto/jOkJiW+TULYv92SZQBPODemcR464k /Rj5vJRZ+dlxLFHcVAv9jmrEYdpnVY1wwX9DwQPrQ3joZ8AZdEbx4ZyqqTdXVL9AjLfZ vFwmj/3k1ZF4lpz5FF1RIgRBGk8jzuE18R14INN/Dbzv4Sk35KvLhHSOi6ZbnKbN2Gv6 mGMg== X-Gm-Message-State: APt69E2LvRZsJI98mixlubnUjQmfQMKrAa80iOxfPbyhLyGa6B9ESV10 YbjNPSKgxTgryEgsKRZYHgY= X-Google-Smtp-Source: ADUXVKIRaLm98cmX+ATzoZixwy+BQ3/+4+qOv3ADijTP19AvzcS54XgBGIRAN4fvQTTXJH56Qri2nA== X-Received: by 2002:a65:4e86:: with SMTP id b6-v6mr7535273pgs.322.1530156796113; Wed, 27 Jun 2018 20:33:16 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com. [147.11.156.139]) by smtp.gmail.com with ESMTPSA id r65-v6sm9321231pfg.65.2018.06.27.20.33.14 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jun 2018 20:33:15 -0700 (PDT) From: Bin Meng To: Simon Glass , Alexander Graf , Heinrich Schuchardt , U-Boot Mailing List Date: Wed, 27 Jun 2018 20:38:03 -0700 Message-Id: <1530157086-4538-3-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1530157086-4538-1-git-send-email-bmeng.cn@gmail.com> References: <1530157086-4538-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v3 3/6] efi_loader: Install ACPI configuration tables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" ACPI tables can be passed via EFI configuration table to an EFI application. This is only supported on x86 so far. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- Changes in v3: - Use UEFI spec 2.7 provided ACPI table name Changes in v2: None cmd/bootefi.c | 5 +++++ include/efi_api.h | 4 ++++ include/efi_loader.h | 8 ++++++++ lib/efi_loader/Makefile | 1 + lib/efi_loader/efi_acpi.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 lib/efi_loader/efi_acpi.c diff --git a/cmd/bootefi.c b/cmd/bootefi.c index f55a40d..cd755b6 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -61,6 +61,11 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; #endif +#ifdef CONFIG_GENERATE_ACPI_TABLE + ret = efi_acpi_register(); + if (ret != EFI_SUCCESS) + goto out; +#endif #ifdef CONFIG_GENERATE_SMBIOS_TABLE ret = efi_smbios_register(); if (ret != EFI_SUCCESS) diff --git a/include/efi_api.h b/include/efi_api.h index 094be6e..0c3dd3c 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -282,6 +282,10 @@ struct efi_runtime_services { EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \ 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) +#define EFI_ACPI_TABLE_GUID \ + EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \ + 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81) + #define SMBIOS_TABLE_GUID \ EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \ 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) diff --git a/include/efi_loader.h b/include/efi_loader.h index c66252a..d837e7b 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -215,6 +215,14 @@ efi_status_t efi_net_register(void); efi_status_t efi_watchdog_register(void); /* Called by bootefi to make SMBIOS tables available */ /** + * efi_acpi_register() - write out ACPI tables + * + * Called by bootefi to make ACPI tables available + * + * @return 0 if OK, -ENOMEM if no memory is available for the tables + */ +efi_status_t efi_acpi_register(void); +/** * efi_smbios_register() - write out SMBIOS tables * * Called by bootefi to make SMBIOS tables available diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index c6046e3..d6402c4 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -22,4 +22,5 @@ obj-$(CONFIG_LCD) += efi_gop.o obj-$(CONFIG_DM_VIDEO) += efi_gop.o obj-$(CONFIG_PARTITIONS) += efi_disk.o obj-$(CONFIG_NET) += efi_net.o +obj-$(CONFIG_GENERATE_ACPI_TABLE) += efi_acpi.o obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c new file mode 100644 index 0000000..a4e5e53 --- /dev/null +++ b/lib/efi_loader/efi_acpi.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * EFI application ACPI tables support + * + * Copyright (C) 2018, Bin Meng + */ + +#include +#include +#include + +static const efi_guid_t acpi_guid = EFI_ACPI_TABLE_GUID; + +/* + * Install the ACPI table as a configuration table. + * + * @return status code + */ +efi_status_t efi_acpi_register(void) +{ + /* Map within the low 32 bits, to allow for 32bit ACPI tables */ + u64 acpi = U32_MAX; + efi_status_t ret; + + /* Reserve 64kiB page for ACPI */ + ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, + EFI_RUNTIME_SERVICES_DATA, 16, &acpi); + 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. + */ + assert(!(acpi & 0xf)); + write_acpi_tables(acpi); + + /* And expose them to our EFI payload */ + return efi_install_configuration_table(&acpi_guid, + (void *)(uintptr_t)acpi); +}