public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Thomas Abraham <thomas.abraham@arm.com>
To: edk2-devel@lists.01.org
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
	Daniil Egranov <daniil.egranov@arm.com>
Subject: [PATCH edk2-platforms v4 4/9] Platform/ARM/Sgi: add support for virtio block device
Date: Mon, 21 May 2018 13:55:47 +0530	[thread overview]
Message-ID: <1526891152-18739-5-git-send-email-thomas.abraham@arm.com> (raw)
In-Reply-To: <1526891152-18739-1-git-send-email-thomas.abraham@arm.com>

From: Daniil Egranov <daniil.egranov@arm.com>

Add the registration of the virtio block device.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
Signed-off-by: Thomas Abraham <thomas.abraham@arm.com>
---
 .../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 eb26fde..fb1e390 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
@@ -15,11 +15,27 @@
 #include <Library/DebugLib.h>
 
 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 dbe04c5..995f80d 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..58dfd22
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
@@ -0,0 +1,76 @@
+/** @file
+
+  Copyright (c) 2018, ARM Ltd. All rights reserved.<BR>
+
+  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 <Library/VirtioMmioDeviceLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <SgiPlatform.h>
+
+#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



  parent reply	other threads:[~2018-05-21  8:26 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21  8:25 [PATCH edk2-platforms v4 0/9] Platform/ARM/Sgi: Add Arm's SGI platform support Thomas Abraham
2018-05-21  8:25 ` [PATCH edk2-platforms v4 1/9] Platform/ARM/Sgi: Add Platform library implementation Thomas Abraham
2018-05-21  8:50   ` Ard Biesheuvel
2018-05-21  8:25 ` [PATCH edk2-platforms v4 2/9] Platform/ARM/Sgi: add NOR flash platform " Thomas Abraham
2018-05-21  8:53   ` Ard Biesheuvel
2018-05-23  4:07     ` Thomas Abraham
2018-05-21  8:25 ` [PATCH edk2-platforms v4 3/9] Platform/ARM/Sgi: add initial platform dxe driver implementation Thomas Abraham
2018-05-21  8:55   ` Ard Biesheuvel
2018-05-23  4:08     ` Thomas Abraham
2018-05-21  8:25 ` Thomas Abraham [this message]
2018-05-21  8:58   ` [PATCH edk2-platforms v4 4/9] Platform/ARM/Sgi: add support for virtio block device Ard Biesheuvel
2018-05-23  4:09     ` Thomas Abraham
2018-05-21  8:25 ` [PATCH edk2-platforms v4 5/9] Platform/ARM/Sgi: add the initial set of acpi tables Thomas Abraham
2018-05-21  8:48   ` Alexei Fedorov
2018-05-23  4:20     ` Thomas Abraham
2018-05-21  9:06   ` Ard Biesheuvel
2018-05-21 10:09     ` Alexei Fedorov
2018-05-23  4:23     ` Thomas Abraham
2018-05-21  8:25 ` [PATCH edk2-platforms v4 6/9] Platform/ARM/Sgi: add initial support for ARM SGI platform Thomas Abraham
2018-05-21  9:08   ` Ard Biesheuvel
2018-05-21  8:25 ` [PATCH edk2-platforms v4 7/9] Platform/ARM/Sgi: add support for smsc91x ethernet controller Thomas Abraham
2018-05-21  9:09   ` Ard Biesheuvel
2018-05-23  4:11     ` Thomas Abraham
2018-05-21  8:25 ` [PATCH edk2-platforms v4 8/9] Platform/ARM/Sgi: implement PciHostBridgeLib support Thomas Abraham
2018-05-21  9:16   ` Ard Biesheuvel
2018-05-23  4:14     ` Thomas Abraham
2018-05-21  8:25 ` [PATCH edk2-platforms v4 9/9] Platform/ARM/Sgi: Add Ssdt, Iort and Mcfg tables Thomas Abraham
2018-05-21  9:29   ` Ard Biesheuvel
2018-05-23  4:19     ` Thomas Abraham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1526891152-18739-5-git-send-email-thomas.abraham@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox