From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=217.140.101.70; helo=foss.arm.com; envelope-from=thomas.abraham@arm.com; receiver=edk2-devel@lists.01.org Received: from foss.arm.com (foss.arm.com [217.140.101.70]) by ml01.01.org (Postfix) with ESMTP id 404E9223E0BA3 for ; Thu, 22 Mar 2018 23:25:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF8491435; Thu, 22 Mar 2018 23:32:03 -0700 (PDT) Received: from usa.arm.com (a74716-lin.blr.arm.com [10.162.4.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8D5693F24A; Thu, 22 Mar 2018 23:32:02 -0700 (PDT) From: Thomas Abraham To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, Daniil Egranov , Thomas Abraham Date: Fri, 23 Mar 2018 12:01:21 +0530 Message-Id: <1521786683-32320-5-git-send-email-thomas.abraham@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521786683-32320-1-git-send-email-thomas.abraham@arm.com> References: <1521786683-32320-1-git-send-email-thomas.abraham@arm.com> Subject: [PATCH 4/6] Platform/ARM/Sgi: add support for virtio block device X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Mar 2018 06:25:31 -0000 From: Daniil Egranov Add the registration of the virtio block device. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Daniil Egranov Signed-off-by: Thomas Abraham --- .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 18 ++++- .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 1 + .../ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c | 76 ++++++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c index 2da768a..5d54f06 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c @@ -15,11 +15,27 @@ #include EFI_STATUS +InitVirtioBlockIo ( + IN EFI_HANDLE ImageHandle + ); + +EFI_STATUS EFIAPI ArmSgiPkgEntryPoint ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { - return EFI_SUCCESS; + EFI_STATUS Status; + + // Install Virtio Block IO. + if ( FeaturePcdGet (PcdVirtioSupported) == TRUE ) { + Status = InitVirtioBlockIo (ImageHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio Block IO\n")); + return Status; + } + } + + return Status; } diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf index 379d7f4..534947f 100644 --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf @@ -20,6 +20,7 @@ [Sources.common] PlatformDxe.c + VirtioBlockIo.c [Packages] ArmPkg/ArmPkg.dec diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c new file mode 100644 index 0000000..eb00225 --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c @@ -0,0 +1,76 @@ +/** @file + + Copyright (c) 2018, ARM 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 + +#pragma pack (1) +typedef struct { + VENDOR_DEVICE_PATH Vendor; + EFI_DEVICE_PATH_PROTOCOL End; +} VIRTIO_BLK_DEVICE_PATH; +#pragma pack () + +STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath = +{ + { + { + HARDWARE_DEVICE_PATH, + HW_VENDOR_DP, + { + (UINT8)( sizeof (VENDOR_DEVICE_PATH) ), + (UINT8)( (sizeof (VENDOR_DEVICE_PATH) ) >> 8) + } + }, + EFI_CALLER_ID_GUID, + }, + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + sizeof (EFI_DEVICE_PATH_PROTOCOL), + 0 + } + } +}; + +/** + * Entrypoint for 'VirtioBlockIo' driver + */ +EFI_STATUS +InitVirtioBlockIo ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status = 0; + + Status = gBS->InstallProtocolInterface (&ImageHandle, + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, + &mVirtioBlockDevicePath); + + if (EFI_ERROR (Status)) { + return Status; + } + + // Declare the Virtio BlockIo device + Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio block device\n")); + } + + return Status; +} -- 2.7.4