From patchwork Tue Aug 4 18:33:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 503763 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 50FC91402C4 for ; Wed, 5 Aug 2015 04:37:26 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=XHnHXwh+; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 497D3A75FB; Tue, 4 Aug 2015 20:36:16 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GTZWWg90PAt8; Tue, 4 Aug 2015 20:36:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E51C6A7667; Tue, 4 Aug 2015 20:35:26 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A1E0A75D9 for ; Tue, 4 Aug 2015 20:35:06 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KuLQ5njQj1Vn for ; Tue, 4 Aug 2015 20:35:06 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ig0-f170.google.com (mail-ig0-f170.google.com [209.85.213.170]) by theia.denx.de (Postfix) with ESMTPS id 26B9DA75ED for ; Tue, 4 Aug 2015 20:35:00 +0200 (CEST) Received: by igr7 with SMTP id 7so80423095igr.0 for ; Tue, 04 Aug 2015 11:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=IWLxyHsmnKbt9QlCwctcdLS3o3G16IRF3Fj4I9oogno=; b=XHnHXwh+iPkxW2KA8j5yoCooJ8SAy7ju3wZq5SWPh4pGd8zul6NoD4UneUdIGzj9hZ 7ABh/YH6Rg2J90BesqSTqxLP56PCZqKlf6iVxeoGVGvMzXFK8jv04BV9SrwdW4nUZs17 Vmk5W+aM0rt165C4g9cRnd59GW2pPK9vcuRTaTtOkkmgaaqhBX+TYR2M34BhD3zSkeUJ PEBEb6kyeDPKn6ArZk1KpndfhumCKg2RPNG8TIfNp5zMAKctxID8lkD701zj5T/eGW3w ZWAMIYRslVw2cetZx9mbEwkJgs76RvuySjCaNtAW39FOFP4vrGPXSCiCfbpXMnUnZIbF 3ojA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=IWLxyHsmnKbt9QlCwctcdLS3o3G16IRF3Fj4I9oogno=; b=BSaHf1GVaKXZZYPImsE6FbIU+uyV1W9GjTbihayv0YOaEvfeGUcAi7GaPvFBzGvvjk H7JVwf/Wl0rFG0XD7PJMox0N2Dn0XNBewF6jN1nN1kuOhVm7a86VvqPrpCsnFb4ybfAP wQM8Ga+XHv5+p8AfxoVyh/ESTExXEFztmU6ZcCwYX+Qyu9FccoUC4OtebprKFahHys6l npJ0ZsInq9vwPXEH64Ih6UGa/XPkymgql7IFMPFsbp/5mRfF0c+PCf529+fjbLbbgaW5 QAT0sdE09cxANymfv5iPu6VytbgTVJnzHXaH8/5QoF9iOKCBhU9XlA5ydgBjqIiGxr+V /row== X-Gm-Message-State: ALoCoQlWACGIxmHcgaohOWfafRbu+qVlHZ2fDSJE449RfZmxvrYiVqRdOLsusYCw4DuHTnaltQne X-Received: by 10.50.40.101 with SMTP id w5mr1054745igk.12.1438713299193; Tue, 04 Aug 2015 11:34:59 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id 38sm112591ior.17.2015.08.04.11.34.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 11:34:58 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 6D6C4221A6A; Tue, 4 Aug 2015 12:34:54 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Tue, 4 Aug 2015 12:33:58 -0600 Message-Id: <1438713246-1887-21-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.rc2.392.g76e840b In-Reply-To: <1438713246-1887-1-git-send-email-sjg@chromium.org> References: <1438713246-1887-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH v3 20/28] efi: Add functions for decoding the EFI tables X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" The EFI stub can pass a table to U-Boot with information about the memory map Potentially other things will follow. Add a way to access this table. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- Changes in v3: None Changes in v2: None lib/efi/Makefile | 1 + lib/efi/efi_info.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 lib/efi/efi_info.c diff --git a/lib/efi/Makefile b/lib/efi/Makefile index 4bc67f0..e32dc14 100644 --- a/lib/efi/Makefile +++ b/lib/efi/Makefile @@ -5,6 +5,7 @@ # obj-$(CONFIG_EFI_APP) += efi_app.o efi.o +obj-$(CONFIG_EFI_STUB) += efi_info.o CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) diff --git a/lib/efi/efi_info.c b/lib/efi/efi_info.c new file mode 100644 index 0000000..0cd9a7e --- /dev/null +++ b/lib/efi/efi_info.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2015 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Access to the EFI information table + */ + +#include +#include +#include +#include + +int efi_info_get(enum efi_entry_t type, void **datap, int *sizep) +{ + struct efi_entry_hdr *entry; + struct efi_info_hdr *info; + int ret; + + if (!gd->arch.table) + return -ENODATA; + + info = map_sysmem(gd->arch.table, 0); + if (info->version != EFI_TABLE_VERSION) { + ret = -EPROTONOSUPPORT; + goto err; + } + + entry = (struct efi_entry_hdr *)((ulong)info + info->hdr_size); + while (entry->type != EFIET_END) { + if (entry->type == type) { + if (entry->addr) + *datap = map_sysmem(entry->addr, entry->size); + else + *datap = entry + 1; + *sizep = entry->size; + return 0; + } + entry = (struct efi_entry_hdr *)((ulong)entry + entry->link); + } + + ret = -ENOENT; +err: + unmap_sysmem(info); + + return ret; +}