From patchwork Fri Jan 23 15:03:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43666 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CE75C218DB for ; Fri, 23 Jan 2015 15:04:42 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf2166255lab.1 for ; Fri, 23 Jan 2015 07:04:41 -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=kqfU/Lex0meMW4srZWhJ2esi4Ht+WjGnl7UmTUyMm6U=; b=Tu65kkqowW6VPmCoi5QgKYIPv32ZUoegpDInjh9DXFsSXdEdbPKzl7pTHiw0VlIejO 6KZLG9SPae/uUxfBqALlJaXMUBVUt4P4+dT0azkSS8wPytGGqZJ99Jp+kp8CHbrKQeBh laY2fl255NMaH5os6uJzqsbJtbuQWwmd7Ipbm25T49EdFp55xYFOPUppbFTcOqJOvi5U vE24wSn5JZG98xIowlIb0EI54BnTjXhP1qGx1F51jO6in/Kvj3GvWk5kX7zOEjBl0n5R ZbN3qK/rA86qMo7orkFFp3sSYFnitpjsdxjnu5SNIj/9Q9tX8Oc3a0rsESCtC/9KuDmc BhhA== X-Gm-Message-State: ALoCoQln8t2vIQcGsMM7HALkb2cVDrGQDwCUz3YgwDHHK60C2tqQKge8b9xQr0RLMaQic/BakHDE X-Received: by 10.194.204.201 with SMTP id la9mr2498wjc.6.1422025481769; Fri, 23 Jan 2015 07:04:41 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.73 with SMTP id o9ls266781laj.65.gmail; Fri, 23 Jan 2015 07:04:41 -0800 (PST) X-Received: by 10.112.132.2 with SMTP id oq2mr7819364lbb.11.1422025481524; Fri, 23 Jan 2015 07:04:41 -0800 (PST) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id tt6si1599964lbb.45.2015.01.23.07.04.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 07:04:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id u14so7470441lbd.2 for ; Fri, 23 Jan 2015 07:04:41 -0800 (PST) X-Received: by 10.112.64.35 with SMTP id l3mr7721178lbs.82.1422025481427; Fri, 23 Jan 2015 07:04:41 -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.9.200 with SMTP id c8csp283264lbb; Fri, 23 Jan 2015 07:04:40 -0800 (PST) X-Received: by 10.43.19.134 with SMTP id qk6mr8939581icb.29.1422025479859; Fri, 23 Jan 2015 07:04:39 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ga8si1843875icb.31.2015.01.23.07.04.39 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:04:39 -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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfmi-0007Q8-8j; Fri, 23 Jan 2015 15:04:32 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YEfmh-0007Pq-90 for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:04:31 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 209.85.212.169 as permitted sender) client-ip=209.85.212.169; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wi0-f169.google.com; Received: from mail-wi0-f169.google.com ([209.85.212.169]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YEfmg-0004qV-7M for edk2-devel@lists.sourceforge.net; Fri, 23 Jan 2015 15:04:31 +0000 Received: by mail-wi0-f169.google.com with SMTP id bs8so3508989wib.0 for ; Fri, 23 Jan 2015 07:04:24 -0800 (PST) X-Received: by 10.180.35.42 with SMTP id e10mr4510904wij.11.1422025458710; Fri, 23 Jan 2015 07:04:18 -0800 (PST) Received: from ards-macbook-pro.local ([197.129.136.117]) by mx.google.com with ESMTPSA id pl1sm2176036wic.16.2015.01.23.07.04.15 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 07:04:17 -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: Fri, 23 Jan 2015 15:03:05 +0000 Message-Id: <1422025390-8036-17-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422025390-8036-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422025390-8036-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 X-Headers-End: 1YEfmg-0004qV-7M Subject: [edk2] [PATCH v1 16/21] 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.171 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(+) create mode 100644 OvmfPkg/XenBusDxe/AtomicsGcc.c 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 8294997e20db..cc69551c2cbd 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