From patchwork Fri Jun 22 12:44:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 139618 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp835171lji; Fri, 22 Jun 2018 05:50:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKIzLxPNNpZw3jCamjHbQaWwldb5tmuD5yzYyY83L04hAZBjKTYA2F6zosA0oz+u+E2tJw4 X-Received: by 2002:a50:e615:: with SMTP id y21-v6mr1731818edm.278.1529671833164; Fri, 22 Jun 2018 05:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529671833; cv=none; d=google.com; s=arc-20160816; b=O3rmJSmzYLZog5jMvuIYLQRNkEFXlFcYhIf/ZCEgwkwDXLzcbn7rnf/v8L2jWn6MVW z6HFrlVwUvWKV8Ej/ctKI4IctFBXHketVVgx724ZkU8C2eWphIsNTO6Qx3cBrqhiutyP 6HcM2fsCn/yE+xAxjHIoTJtri6VZUv+XXzRmSXHkozCoNX2n9g7b9urNz2eJHsPk0+Ox gI6E1Hzs/Z3d68BVguPxoDYAJfiUZILJMyNQmv00La1mV03bVflNDX8DALrIgcy621OM d0+5aJJvs3VeydcILVCFPACXw7S8xhQePOXLiYcudUSvUwL0V8GcGkN4TI2u7XymZMhz EUEA== 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:arc-authentication-results; bh=NEb/APNOApaMzMzzPxch2tB9jPkNYF1efl8KNSFC2Ww=; b=FCPyzECSgko8BqsRkyCrTlLAywnACTNooTUD0XPlQysO9HhOzKp7pvmeGspKQ1ZjKo lRqqW6ao4GtUqgfONhsxN6HfF+j1jGH7ByZRBf+feaSpBFnMHwjhGXuFDI0C0An/mZy7 1GaONxkmN3O2CaEgWtJMXDvrdWRtdOniAovr0RU72KmsuLGHph7Azk76oZcZB1GzfJCo bZ3lmYovZAdt/GEz7TeAT7ZQ7JyDSrUPjk8SQHfH+SD9Q9kzbYKNsAUIR/TiQRxckUjw wo7rOhapeI1NIIPk6Ge0LNOVg33YoASg0fR8aJ03XlFPQqel8B904exucboUKVMcghBk xoZg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id w2-v6si3993908edm.336.2018.06.22.05.50.32; Fri, 22 Jun 2018 05:50:33 -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; 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 Received: by lists.denx.de (Postfix, from userid 105) id C7A7DC21F7A; Fri, 22 Jun 2018 12:46:30 +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=none 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 EFE8EC2201E; Fri, 22 Jun 2018 12:44:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 86A26C21C2C; Fri, 22 Jun 2018 12:44:20 +0000 (UTC) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by lists.denx.de (Postfix) with ESMTPS id A2F40C21C57 for ; Fri, 22 Jun 2018 12:44:20 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CF77DACB0; Fri, 22 Jun 2018 12:44:19 +0000 (UTC) From: Alexander Graf To: u-boot@lists.denx.de Date: Fri, 22 Jun 2018 14:44:09 +0200 Message-Id: <20180622124418.52892-2-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180622124418.52892-1-agraf@suse.de> References: <20180622124418.52892-1-agraf@suse.de> Cc: Heinrich Schuchardt , Andy Shevchenko Subject: [U-Boot] [PATCH v5 01/10] 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" 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 Signed-off-by: Alexander Graf --- 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 d4da65ce53..41530a7537 100644 --- a/include/efi.h +++ b/include/efi.h @@ -19,8 +19,15 @@ #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)) #define efi_va_list __builtin_ms_va_list #define efi_va_start __builtin_ms_va_start @@ -32,7 +39,7 @@ #define efi_va_start va_start #define efi_va_arg va_arg #define efi_va_end va_end -#endif +#endif /* __x86_64__ */ struct efi_device_path; @@ -40,16 +47,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 f1a3929e32..a790d2d554 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