From patchwork Fri Jun 22 08:38:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 139588 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp601009lji; Fri, 22 Jun 2018 01:34:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL66NiTUvttnDyDe+1ni4cuVuM9V5Laa9puc1oBOw9l79yVpPFdpACwJYxXoOL1NRKjEXSv X-Received: by 2002:a50:87e6:: with SMTP id 35-v6mr1011705edz.1.1529656469776; Fri, 22 Jun 2018 01:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529656469; cv=none; d=google.com; s=arc-20160816; b=0O+P7fQiNNXYXAiF/V7KVTYC8UPYND58E9gqzSRShWxeWS3Go3C3zWPdFNmYi2mWZD AuIXoPnv09jxTB7hgZdLqBVrlXHJQCEyQtvu6utPbsmQKWzJ0mHGJuaJv1BHyX60gMTm E4BVGVncCKFjKV2LkoP11y5WPKwEG/GAU+dUhz1mT3DtSfR9F4bOWRVDs+2xiGtSueB+ RpkcaG570QAuzSTXinxoxiQ9GIdEA8Hvro+BCipAK7DD8fw1tSJSv6Cch8eYLm2W8Lxp 7U7vwxSpplz9sAODODEWcKsdNNDGO3qAIG+g9/VbkA7IbFNWcMf9BV/J6PT2Dge46ywy tGgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=R47oGpkesYh54QT7rAgCzgdJA57I3fBvV78H+4WENjE=; b=Hbhvl0zF4HP+gRAmv4bDpBrSNYHJoGT71u4kEeyxh3MbjDcMrl5EWXU47Aj0RRRuTS H/SVeVYN4YDKd5s8mLIGlexSRMS+WttjLMY4ns5EtUZSXTtqvpzzxB66sZPgSezKzHwq SqmyVdHvG25wNGYeEHpdnyW4U92IT0c74HtwVHaH0q4WCZ50GkOIGEdJE0lfdasXBnjx BVNc1V9TSM1g4Pgho1dI598xvd79VhgIwJHOrGKs4lWQSjg1sIXUmY7tO1VZxiFqEolI cKLSUGWd9ONYrc2VVZjaLCuUdSuGqeBS3S6OT7OWIiHYSTFgxu6VuoFUmkEZTMADCh6g R9qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=YXZU7cY0; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id d11-v6si3397311edo.400.2018.06.22.01.34.29; Fri, 22 Jun 2018 01:34:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=YXZU7cY0; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: by lists.denx.de (Postfix, from userid 105) id 5B4CAC21E7E; Fri, 22 Jun 2018 08:34:02 +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 BD498C21FA3; Fri, 22 Jun 2018 08:33:45 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AC011C21C2F; Fri, 22 Jun 2018 08:33:42 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by lists.denx.de (Postfix) with ESMTPS id 1BC59C21C2C for ; Fri, 22 Jun 2018 08:33:42 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id a14-v6so2655180pgw.10 for ; Fri, 22 Jun 2018 01:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5jGZp2iL5hMxMp4kXFXr5JGeXlEwK4NBDK2KLKirhQk=; b=YXZU7cY0YOAqjSkxXjV+ra63ctCRZ3k9c2qBCJQmsTfCyM0bf8klS10Hkuo4Th34rL Ftj563onM1cUvPumsiB84Fo7N3Tv42gqw8wyAwfxxSKbDMsjfIZeCjTR9QKVvCf31Fym nKcC/59iA+/BVwzuodoo9tct828CYBE3kGgqI6rxBG96egDaIiJCnSBrAgdUsczjlnoS Ie1dHrrTgi6ivVyzXl1u+08xBetU3HIzbUBdbWEfEET6GfED5nkBM+VmhUHmmJmN+DXD QqmA/mNrYJYjBMeRueer0D85lb/u/bo8FNaa6vEGU5laya0yJgevLAV7eQCq7wSkBhOU aYxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5jGZp2iL5hMxMp4kXFXr5JGeXlEwK4NBDK2KLKirhQk=; b=f3zaZb0UxFV8wCzn4bv6gMXXHwKJ23LJHYqnAPMqtoK3pEHinem85y55MAnTbJSsMk sG1uK5Yj5cjj7OwCjBdBrMsylKM1ufWurtWxWXaJfgiiU3OBcjqYZ9v5ww4Y3VkWQFZz E1hj0AkW8r8rWrUHPhIP/28trKlXbWb1JtFiUt4vmYhW6DF2u8WQ51fL4W8AW1Uu85Nb f/jhfJw3oCSEy53gbfRrGp9d0cFd8uRLkDFLqUitQIuHbchMvrUNmcpEL4KIiqgN1cWB yQd9yko0oLMXyFsKzQy/g0aropoGrD5t2mJtNdenC741cCqwXe5h9BmaLVAOAv+86jPJ PFWQ== X-Gm-Message-State: APt69E0VZjG2JFucYZOhV/sTlniRCiKmwZLKs2OiK3u8FO1YjSH4EaXE Hv+tgDHlJxtyJiAMIHpxnUw= X-Received: by 2002:a63:8848:: with SMTP id l69-v6mr536271pgd.377.1529656420657; Fri, 22 Jun 2018 01:33:40 -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 y11-v6sm10219474pfn.92.2018.06.22.01.33.39 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Jun 2018 01:33:39 -0700 (PDT) From: Bin Meng To: Simon Glass , U-Boot Mailing List Date: Fri, 22 Jun 2018 01:38:26 -0700 Message-Id: <1529656712-3660-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1529656712-3660-1-git-send-email-bmeng.cn@gmail.com> References: <1529656712-3660-1-git-send-email-bmeng.cn@gmail.com> Cc: Alexander Graf Subject: [U-Boot] [PATCH 1/6] efi.h: Do not use config options 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" From: Alexander Graf Currently efi.h determines a few bits of its environment according to config options. This falls apart with the efi stub support which may result in efi.h getting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit. This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically. Signed-off-by: Alexander Graf Reviewed-by: Bin Meng Tested-by: Bin Meng [bmeng: added some comments to describe the __x86_64__ check] Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- include/efi.h | 24 +++++++++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/include/efi.h b/include/efi.h index 2448dde..0fe15e6 100644 --- a/include/efi.h +++ b/include/efi.h @@ -19,12 +19,19 @@ #include #include -#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* + * EFI on x86_64 uses the Microsoft ABI which is not the default for GCC. + * + * There are two scenarios for EFI on x86_64: building a 64-bit EFI stub + * codes (CONFIG_EFI_STUB_64BIT) and building a 64-bit U-Boot (CONFIG_X86_64). + * Either needs to be properly built with the '-m64' compiler flag, and hence + * it is enough to only check the compiler provided define __x86_64__ here. + */ +#ifdef __x86_64__ #define EFIAPI __attribute__((ms_abi)) #else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ struct efi_device_path; @@ -32,16 +39,7 @@ typedef struct { u8 b[16]; } efi_guid_t; -#define EFI_BITS_PER_LONG BITS_PER_LONG - -/* - * With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set - * in lib/efi/Makefile, when building the stub. - */ -#if defined(CONFIG_EFI_STUB_64BIT) && defined(EFI_STUB) -#undef EFI_BITS_PER_LONG -#define EFI_BITS_PER_LONG 64 -#endif +#define EFI_BITS_PER_LONG (sizeof(long) * 8) /* Bit mask for EFI status code with error */ #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1)) diff --git a/lib/efi/Makefile b/lib/efi/Makefile index f1a3929..a790d2d 100644 --- a/lib/efi/Makefile +++ b/lib/efi/Makefile @@ -7,11 +7,11 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB \ +CFLAGS_efi_stub.o := -fpic -fshort-wchar \ $(if $(CONFIG_EFI_STUB_64BIT),-m64) CFLAGS_REMOVE_efi.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB \ +CFLAGS_efi.o := -fpic -fshort-wchar \ $(if $(CONFIG_EFI_STUB_64BIT),-m64) extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o