From patchwork Mon Jan 26 19:03:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 43800 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 28D1920D5D for ; Mon, 26 Jan 2015 19:05:45 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf5289101wgh.1 for ; Mon, 26 Jan 2015 11:05:44 -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=NZPGZAllJWqq9P2XbWlwzMBF9cW/vcE7cbThlFzy3Sw=; b=Ejs71tAohXqoi2qw3Xrok1kmhqG+hv4xzUvxGuVFgIUC7SCLsQQWqUdql8W45zRdka sLHXFsq6DhvOHCAoyeAacJ0o0gfWL4OPeheLmLzXDi3GAxZZ4HrhjHcco7f7Tj8UhYdG t88c78WXGCPKlIil0UGqutUG1DOYm1pIq00VbpySQBrbQyx0FJZh93kl/PspY6tCV1y7 xuM43QkI4MzRCv5djwAx4gWwKZLj+b8MOjzu/CfIXiqRSzJ/v1lZBLyq6CYWnjcI4Kmm xUUPHodNXddXJy4aHpF79FZ94XYZg1t3Y9iUgYHE76oETTmYx/VTrZiG+XWGJ5UpazTR 8XaA== X-Gm-Message-State: ALoCoQlgkOooDK65cgP8Sl5nXP8rdV2JCGTxMjyA0KPvyyrw7FNLekEiV0dy+aAUajX9SEA63Xnc X-Received: by 10.152.37.130 with SMTP id y2mr1508043laj.8.1422299144505; Mon, 26 Jan 2015 11:05:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.35 with SMTP id p3ls630310lap.49.gmail; Mon, 26 Jan 2015 11:05:44 -0800 (PST) X-Received: by 10.112.205.68 with SMTP id le4mr23011762lbc.96.1422299144221; Mon, 26 Jan 2015 11:05:44 -0800 (PST) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id ug7si9772606lbb.108.2015.01.26.11.05.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:05:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id q1so9436853lam.2 for ; Mon, 26 Jan 2015 11:05:44 -0800 (PST) X-Received: by 10.112.90.170 with SMTP id bx10mr8311770lbb.69.1422299144116; Mon, 26 Jan 2015 11:05:44 -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 h5csp870683lbj; Mon, 26 Jan 2015 11:05:43 -0800 (PST) X-Received: by 10.50.234.194 with SMTP id ug2mr5519332igc.39.1422299135545; Mon, 26 Jan 2015 11:05:35 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id n197si8047195ion.33.2015.01.26.11.05.34 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:05:35 -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 1YFoyS-0003AO-VJ; Mon, 26 Jan 2015 19:05:25 +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 1YFoyO-00039S-8H for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:05:20 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.52 as permitted sender) client-ip=74.125.82.52; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f52.google.com; Received: from mail-wg0-f52.google.com ([74.125.82.52]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YFoyN-0007Lt-VP for edk2-devel@lists.sourceforge.net; Mon, 26 Jan 2015 19:05:21 +0000 Received: by mail-wg0-f52.google.com with SMTP id y19so10746735wgg.11 for ; Mon, 26 Jan 2015 11:05:15 -0800 (PST) X-Received: by 10.180.74.52 with SMTP id q20mr23871353wiv.0.1422299114998; Mon, 26 Jan 2015 11:05:14 -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.05.11 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 11:05:14 -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:29 +0000 Message-Id: <1422299011-2409-28-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: 1YFoyN-0007Lt-VP Subject: [edk2] [PATCH v2 27/29] ArmVirtualizationPkg: add XenIoMmioLib 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.215.43 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 adds a XenIoMmioLib declaration and implementation that can be invoked to install the XENIO_PROTOCOL and a corresponding grant table address on a EFI handle. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec | 6 +++++ ArmPlatformPkg/ArmVirtualizationPkg/Include/Library/XenIoMmioLib.h | 20 +++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.inf | 38 +++++++++++++++++++++++++++++ 4 files changed, 155 insertions(+) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec index 868488906643..c690f1481093 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec @@ -30,6 +30,12 @@ [Includes.common] Include # Root include for the package +[LibraryClasses] + # + # library to create handles containing the XENIO_PROTOCOL I/O protocol + # + XenIoMmioLib|Include/Library/XenIoMmioLib.h + [Guids.common] gArmVirtualizationTokenSpaceGuid = { 0x0B6F5CA7, 0x4F53, 0x445A, { 0xB7, 0x6E, 0x2E, 0x36, 0x5B, 0x80, 0x63, 0x66 } } gEarlyPL011BaseAddressGuid = { 0xB199DEA9, 0xFD5C, 0x4A84, { 0x80, 0x82, 0x2F, 0x41, 0x70, 0x78, 0x03, 0x05 } } diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Include/Library/XenIoMmioLib.h b/ArmPlatformPkg/ArmVirtualizationPkg/Include/Library/XenIoMmioLib.h new file mode 100644 index 000000000000..faeabe5affe0 --- /dev/null +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Include/Library/XenIoMmioLib.h @@ -0,0 +1,20 @@ +/** @file +* Library to install the XENIO_PROTOCOL on a handle +* +* Copyright (c) 2015, Linaro Ltd. All rights reserved.
+* +* 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. +* +**/ + +EFI_STATUS +XenIoMmioInstall ( + IN EFI_HANDLE *Handle, + IN UINT64 GrantTableAddress + ); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.c b/ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.c new file mode 100644 index 000000000000..2d8413638680 --- /dev/null +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.c @@ -0,0 +1,91 @@ +/** @file +* Library to install the XENIO_PROTOCOL on a handle +* +* Copyright (c) 2015, Linaro Ltd. All rights reserved.
+* +* 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. +* +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#pragma pack (1) +typedef struct { + VENDOR_DEVICE_PATH Vendor; + EFI_DEVICE_PATH_PROTOCOL End; +} XENBUS_ROOT_DEVICE_PATH; +#pragma pack () + +EFI_STATUS +XenIoMmioInstall ( + IN EFI_HANDLE *Handle, + IN UINT64 GrantTableAddress + ) +{ + EFI_STATUS Status; + XENIO_PROTOCOL *XenIo; + XENBUS_ROOT_DEVICE_PATH *XenBusDevicePath; + + ASSERT (Handle != NULL); + + XenIo = AllocateZeroPool (sizeof *XenIo); + ASSERT (XenIo != NULL); + XenIo->GrantTableAddress = GrantTableAddress; + + XenBusDevicePath = (XENBUS_ROOT_DEVICE_PATH *)CreateDeviceNode ( + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + sizeof (XENBUS_ROOT_DEVICE_PATH)); + if (XenBusDevicePath == NULL) { + DEBUG ((EFI_D_ERROR, "%a: Out of memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + CopyMem (&XenBusDevicePath->Vendor.Guid, &gXenBusRootDeviceGuid, + sizeof (EFI_GUID)); + SetDevicePathNodeLength (&XenBusDevicePath->Vendor, + sizeof (*XenBusDevicePath) - sizeof (XenBusDevicePath->End)); + SetDevicePathEndNode (&XenBusDevicePath->End); + + Status = gBS->InstallProtocolInterface (Handle, + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, + XenBusDevicePath); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: Failed to install the EFI_DEVICE_PATH " + "protocol on handle 0x%p (Status == %r)\n", + __FUNCTION__, *Handle, Status)); + FreePool (XenBusDevicePath); + return Status; + } + + Status = gBS->InstallProtocolInterface (Handle, + &gXenIoProtocolGuid, EFI_NATIVE_INTERFACE, + XenIo); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: Failed to install XENIO_PROTOCOL on handle 0x%p " + "(Status == %r)\n", __FUNCTION__, *Handle, Status)); + + Status = gBS->UninstallProtocolInterface (*Handle, + &gEfiDevicePathProtocolGuid, XenBusDevicePath); + ASSERT_EFI_ERROR (Status); + FreePool (XenBusDevicePath); + FreePool (XenIo); + } + return Status; +} diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.inf b/ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.inf new file mode 100644 index 000000000000..14f24ff7fd2c --- /dev/null +++ b/ArmPlatformPkg/ArmVirtualizationPkg/Library/XenIoMmioLib/XenIoMmioLib.inf @@ -0,0 +1,38 @@ +## @file +# Library to install the XENIO_PROTOCOL on a handle +# +# Copyright (c) 2015, Linaro Ltd. All rights reserved.
+# +# 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. +# +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = XenIoMmioLib + FILE_GUID = 3CD90EEC-EBF3-425D-AAE8-B16215AC4F50 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = XenIoMmioLib + +[Sources] + XenIoMmioLib.c + +[Packages] + MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + BaseMemoryLib + +[Guids] + gXenBusRootDeviceGuid + +[Protocols] + gEfiDevicePathProtocolGuid