From patchwork Mon Jan 26 19:03:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43796 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0D72B20D5D for ; Mon, 26 Jan 2015 19:05:28 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id c13sf5282786eek.1 for ; Mon, 26 Jan 2015 11:05:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=bW+CkPlC6xm6B9sp2Xrmv/IuNsjdrWAKSeBzVPF+LWA=; b=JAritxvCYkkYM9GkzL876+b6jktD+nc/s/LH81QwkQyd7GPjskffa2ClrQoBj8S2NT wUoYRCENwyL0o7fqSXUo6N8VZF1H7e6CQ8MwqDzTSW/Qyi2GHKUxqCY1AbiQt7j14qGF BHR8CnhS4c/O4VFk5W3WiKi3wgeWdh0z6TsVrFoVrl72Dtkg2clhLdYx7gUS9M7l60hO qqKQ2lDLEcBTeTjRL8r2ZTzQKVqssIbKgUin/nUvArS+tuehgAd4CAoi0BONaAgKs5PS 8np+PKk+GcE4MjTnlW8izOQWVRpyeWEsVbD7a+JcqnezMCD3f4vlm2ES2NDHtMQFEwKv 6XJw== X-Gm-Message-State: ALoCoQliOt1rVG/Wd/Uv7ldTMCN7jUdu7+sPKSLU2WpecilRXZwYaWDGV6+WxXa2W91+hECM09P4 X-Received: by 10.113.5.170 with SMTP id cn10mr1471755lbd.21.1422299127280; Mon, 26 Jan 2015 11:05:27 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.201 with SMTP id x9ls610977lae.89.gmail; Mon, 26 Jan 2015 11:05:27 -0800 (PST) X-Received: by 10.112.181.165 with SMTP id dx5mr5079800lbc.89.1422299127134; Mon, 26 Jan 2015 11:05:27 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id f10si9759682lbs.123.2015.01.26.11.05.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:05:27 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id u10so9256632lbd.12 for ; Mon, 26 Jan 2015 11:05:27 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr22985172lal.29.1422299127043; Mon, 26 Jan 2015 11:05:27 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp870591lbj; Mon, 26 Jan 2015 11:05:26 -0800 (PST) X-Received: by 10.50.108.68 with SMTP id hi4mr17813594igb.38.1422299117396; Mon, 26 Jan 2015 11:05:17 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id 37si8036412iot.48.2015.01.26.11.05.16 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:05:17 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFoyC-0004xS-BJ; Mon, 26 Jan 2015 19:05:08 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YFoyB-0004x7-2E for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:05:07 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.176 as permitted sender) client-ip=74.125.82.176; envelope-from=ard.biesheuvel@linaro.org; helo=mail-we0-f176.google.com; Received: from mail-we0-f176.google.com ([74.125.82.176]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YFoy9-0007ER-SY for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:05:06 +0000 Received: by mail-we0-f176.google.com with SMTP id w62so10859606wes.7 for ; Mon, 26 Jan 2015 11:05:01 -0800 (PST) X-Received: by 10.180.210.167 with SMTP id mv7mr29348405wic.78.1422299100957; Mon, 26 Jan 2015 11:05:00 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.8.190]) by mx.google.com with ESMTPSA id fo17sm15471007wjc.19.2015.01.26.11.04.58 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:05:00 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, lersek@redhat.com, olivier.martin@arm.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, anthony.perard@citrix.com, christoffer.dall@linaro.org, xen-devel@lists.xen.org, ilias.biris@linaro.org Date: Mon, 26 Jan 2015 19:03:25 +0000 Message-Id: <1422299011-2409-24-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422299011-2409-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422299011-2409-1-git-send-email-ard.biesheuvel@linaro.org> X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1YFoy9-0007ER-SY Subject: [edk2] [PATCH v2 23/29] Ovmf/Xen: add ARM and AArch64 support to XenBusDxe X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This patch adds support to XenBusDxe for executing on ARM and AArch64 machines (the former only when built with GCC). Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- OvmfPkg/XenBusDxe/AtomicsGcc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ OvmfPkg/XenBusDxe/XenBusDxe.inf | 3 +++ 2 files changed, 47 insertions(+) diff --git a/OvmfPkg/XenBusDxe/AtomicsGcc.c b/OvmfPkg/XenBusDxe/AtomicsGcc.c new file mode 100644 index 000000000000..a0bdcbf67440 --- /dev/null +++ b/OvmfPkg/XenBusDxe/AtomicsGcc.c @@ -0,0 +1,44 @@ +/** @file + Arch-independent implementations of XenBusDxe atomics using GCC __builtins + + Copyright (C) 2014, Linaro Ltd. + + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +UINT16 +EFIAPI +InternalSyncCompareExchange16 ( + IN volatile UINT16 *Value, + IN UINT16 CompareValue, + IN UINT16 ExchangeValue + ) +{ + return __sync_val_compare_and_swap_2 (Value, CompareValue, ExchangeValue); +} + +INT32 +EFIAPI +TestAndClearBit ( + IN INT32 Bit, + IN volatile VOID *Address + ) +{ + // + // Calculate the effective address relative to 'Address' based on the + // higher order bits of 'Bit'. Use signed shift instead of division to + // ensure we round towards -Inf, and end up with a positive shift in 'Bit', + // even if 'Bit' itself is negative. + // + Address += (Bit >> 5) * sizeof(INT32); + Bit &= 31; + + return (__sync_fetch_and_and_4 (Address, ~(1U << Bit)) & (1U << Bit)) != 0; +} diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf index 31553ac5a64a..949ec0a0c732 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.inf +++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf @@ -54,6 +54,9 @@ X64/InterlockedCompareExchange16.nasm X64/TestAndClearBit.nasm +[Sources.AARCH64, Sources.ARM] + AtomicsGcc.c | GCC + [LibraryClasses] UefiDriverEntryPoint UefiBootServicesTableLib