public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device
@ 2018-12-04  9:12 Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration Vijayenthiran Subramaniam
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

This patch series adds support for virtio network controller found in ARM SGI
plaform's fast models. The first patch in this series restructure the
virtio device registration code to allow registration of additional virtio
devices. The second patch adds support for the virtio network device. The rest
of the patches update the ACPI tables to add an entry for the virtio network
device and corresponding PCDs for virtio block and network device.

Daniil Egranov (4):
  Platform/ARM/SgiPkg: Restructure virtio device registration
  Platform/ARM/SgiPkg: Add support for virtio net device
  Sgi575: AcpiTables: Use PCDs for virtio disk
  Sgi575: AcpiTables: Add entry for virtio network device

Vijayenthiran Subramaniam (4):
  SgiClark.Ares: AcpiTables: Use PCDs for virtio disk
  SgiClark.Ares: AcpiTables: Add entry for virtio network device
  SgiClark.Helios: AcpiTables: Use PCDs for virtio disk
  SgiClark.Helios: AcpiTables: Add entry for virtio network device

 Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  14 ++-
 Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  21 +++-
 Platform/ARM/SgiPkg/SgiPlatform.fdf                                          |   4 +
 Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf                          |   7 ++
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf                    |   7 ++
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf                  |   7 ++
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  11 +-
 Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   |  24 ++++
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        |  14 +--
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 117 +++++++++++++++-----
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl                               |  28 ++++-
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl                         |  29 ++++-
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl                       |  28 ++++-
 13 files changed, 260 insertions(+), 51 deletions(-)
 create mode 100644 Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
 rename Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} (25%)

-- 
2.7.4



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04 14:46   ` Ard Biesheuvel
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 2/8] Platform/ARM/SgiPkg: Add support for virtio net device Vijayenthiran Subramaniam
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

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

SGI platforms support multiple virtio devices. So the existing code, that
supports registration of only the virtio disk, is restructured to
accommodate the registration of additional virtio devices.

In addition to this, PCDs to represent the virtio controller base and
address space size are introduced.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
---
 Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  8 ++-
 Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  7 +-
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  8 ++-
 Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   | 21 ++++++
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        | 14 +---
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 67 ++++++++++++--------
 6 files changed, 81 insertions(+), 44 deletions(-)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
index f6e0ba1e927a..ed29a4d5d91f 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dec
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
@@ -37,12 +37,16 @@ [Guids.common]
   gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, { 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
 
 [PcdsFeatureFlag.common]
-  # Set this PCD to TRUE to enable virtio support.
-  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
 
 [PcdsFixedAtBuild]
   gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
   gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
 
+  # Virtio Block device
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
+
 [Ppis]
   gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index b3f76d2d9720..ada72be72f8a 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
 ################################################################################
 
 [PcdsFeatureFlag.common]
-  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
 
 [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdVFPEnabled|1
@@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
   # Ethernet
   gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
 
+  # Virtio Disk
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
index d903ed8d3375..f920f6ecafb8 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
@@ -20,7 +20,7 @@ [Defines]
 
 [Sources.common]
   PlatformDxe.c
-  VirtioBlockIo.c
+  VirtioDevices.c
 
 [Packages]
   EmbeddedPkg/EmbeddedPkg.dec
@@ -41,7 +41,11 @@ [Guids]
   gSgiClarkHeliosAcpiTablesFileGuid
 
 [FeaturePcd]
-  gArmSgiTokenSpaceGuid.PcdVirtioSupported
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
+
+[FixedPcd]
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
 
 [Depex]
   TRUE
diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
new file mode 100644
index 000000000000..80d3e3ae4f91
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
@@ -0,0 +1,21 @@
+/** @file
+*
+*  Copyright (c) 2018, ARM Limited. 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.
+*
+**/
+
+#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
+#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
+
+#define SGI_VIRTIO_BLOCK_GUID  \
+  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
+
+#endif
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
index a8708a5c4ce5..aa032c41f686 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
@@ -17,9 +17,8 @@
 #include <Library/HobLib.h>
 #include <SgiPlatform.h>
 
-EFI_STATUS
-InitVirtioBlockIo (
-  IN EFI_HANDLE         ImageHandle
+VOID
+InitVirtioDevices (
   );
 
 EFI_STATUS
@@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
     return Status;
   }
 
-  Status = EFI_REQUEST_UNLOAD_IMAGE;
-  if (FeaturePcdGet (PcdVirtioSupported)) {
-    Status = InitVirtioBlockIo (ImageHandle);
-    if (EFI_ERROR (Status)) {
-      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block device\n",
-        __FUNCTION__));
-    }
-  }
+  InitVirtioDevices ();
 
   return Status;
 }
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
similarity index 41%
rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
index 5b5863f4b806..4703aec06968 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
@@ -12,6 +12,7 @@
 
 **/
 
+#include <Guid/SgiVirtioDevicesFormSet.h>
 #include <Library/VirtioMmioDeviceLib.h>
 #include <Library/DevicePathLib.h>
 #include <Library/DebugLib.h>
@@ -20,12 +21,12 @@
 
 #pragma pack (1)
 typedef struct {
-  VENDOR_DEVICE_PATH                  Vendor;
+  VENDOR_DEVICE_PATH                  VendorDevicePath;
   EFI_DEVICE_PATH_PROTOCOL            End;
-} VIRTIO_BLK_DEVICE_PATH;
+} VIRTIO_DEVICE_PATH;
 #pragma pack ()
 
-STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
+STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
 {
   {
     {
@@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
         (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
       }
     },
-    EFI_CALLER_ID_GUID,
+    SGI_VIRTIO_BLOCK_GUID,
   },
   {
     END_DEVICE_PATH_TYPE,
@@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
 };
 
 /**
- * Entrypoint for 'VirtioBlockIo' driver
- */
-EFI_STATUS
-InitVirtioBlockIo (
-   IN EFI_HANDLE         ImageHandle
+  Initialize platform Virtio devices.
+
+  @return None.
+**/
+VOID
+InitVirtioDevices (
   )
 {
   EFI_STATUS Status;
+  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
 
-  Status = gBS->InstallProtocolInterface (&ImageHandle,
-                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
-                  &mVirtioBlockDevicePath);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
-      "protocol for the virtio block device (Status == %r)\n",
-      __FUNCTION__, Status));
-    return Status;
+  // Install protocol interface for storage device
+  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
+      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
+    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
+                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
+                    &mVirtioBlockDevicePath);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
+        "for Virtio Block device (Status = %r)\n",
+        __FUNCTION__, Status));
+    } else {
+      // Declare the Virtio BlockIo device
+      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioBlkBaseAddress),
+                 mVirtIoBlkController);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device "
+          "(Status == %r)\n", __FUNCTION__, Status));
+        gBS->UninstallProtocolInterface (
+               mVirtIoBlkController,
+               &gEfiDevicePathProtocolGuid,
+               &mVirtioBlockDevicePath
+             );
+      } else {
+        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
+          __FUNCTION__));
+      }
+    }
   }
-
-  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR,
-      "%a: Failed to install Virtio block device (Status == %r)\n",
-      __FUNCTION__, Status));
-    gBS->UninstallProtocolInterface (ImageHandle,
-           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
-  }
-
-  return Status;
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 2/8] Platform/ARM/SgiPkg: Add support for virtio net device
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 3/8] Sgi575: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

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

Add support for virtio net device by adding PCDs to specify the data
required to setup the virtio net device and register it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
---
 Platform/ARM/SgiPkg/SgiPlatform.dec                        |  6 +++
 Platform/ARM/SgiPkg/SgiPlatform.dsc                        | 18 +++++--
 Platform/ARM/SgiPkg/SgiPlatform.fdf                        |  4 ++
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf    |  3 ++
 Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h |  3 ++
 Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c    | 54 ++++++++++++++++++++
 6 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
index ed29a4d5d91f..39cc3f89fd57 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dec
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
@@ -38,6 +38,7 @@ [Guids.common]
 
 [PcdsFeatureFlag.common]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|FALSE|BOOLEAN|0x00000010
 
 [PcdsFixedAtBuild]
   gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
@@ -48,5 +49,10 @@ [PcdsFixedAtBuild]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
   gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
 
+  # Virtio Network device
+  gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress|0x00000000|UINT32|0x00000007
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x00000000|UINT32|0x00000008
+  gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|0x00000000|UINT32|0x00000009
+
 [Ppis]
   gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
index ada72be72f8a..0c794c6b299d 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -45,6 +45,7 @@ [LibraryClasses.common]
   VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
   VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
   FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+  OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
 
 [LibraryClasses.common.SEC]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
@@ -99,6 +100,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
 
 [PcdsFeatureFlag.common]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|TRUE
 
 [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdVFPEnabled|1
@@ -177,14 +179,19 @@ [PcdsFixedAtBuild.common]
   gArmPlatformTokenSpaceGuid.PcdCoreCount|4
   gArmPlatformTokenSpaceGuid.PcdClusterCount|2
 
-  # Ethernet
-  gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
-
   # Virtio Disk
   gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
   gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
 
+  # Ethernet / Virtio Network
+!ifdef EDK2_ENABLE_SMSC_91X
+  gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
+!endif
+  gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress|0x1c150000
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSize|0x10000
+  gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt|204
+
 ################################################################################
 #
 # Components Section - list of all EDK II Modules needed by this Platform
@@ -288,8 +295,11 @@ [Components.common]
       PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   }
 
-  # SMSC LAN 91C111
+  # SMSC LAN 91C111 / Virtio Network
+!ifdef EDK2_ENABLE_SMSC_91X
   EmbeddedPkg/Drivers/Lan91xDxe/Lan91xDxe.inf
+!endif
+  OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
   #
   # Required by PCI
diff --git a/Platform/ARM/SgiPkg/SgiPlatform.fdf b/Platform/ARM/SgiPkg/SgiPlatform.fdf
index b7af4a2a5925..ddf1fda5a16e 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.fdf
+++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf
@@ -191,7 +191,11 @@ [FV.FvMain]
   INF NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
   INF NetworkPkg/TcpDxe/TcpDxe.inf
   INF NetworkPkg/IScsiDxe/IScsiDxe.inf
+
+!ifdef EDK2_ENABLE_SMSC_91X
   INF EmbeddedPkg/Drivers/Lan91xDxe/Lan91xDxe.inf
+!endif
+  INF OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
 [FV.FVMAIN_COMPACT]
 FvAlignment        = 16
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
index f920f6ecafb8..3283ff045372 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
@@ -42,10 +42,13 @@ [Guids]
 
 [FeaturePcd]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSupported
 
 [FixedPcd]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
+  gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSize
 
 [Depex]
   TRUE
diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
index 80d3e3ae4f91..b7aab64d7bf7 100644
--- a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
+++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
@@ -18,4 +18,7 @@
 #define SGI_VIRTIO_BLOCK_GUID  \
   { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
 
+#define SGI_VIRTIO_NET_GUID  \
+  { 0xf5a453e8, 0x5f5f, 0x4e7b, { 0x89, 0x4f, 0x3a, 0x23, 0x74, 0xc7, 0x28, 0xb1 } }
+
 #endif
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
index 4703aec06968..e2efc4e18e13 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
@@ -49,6 +49,29 @@ STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
   }
 };
 
+STATIC VIRTIO_DEVICE_PATH mVirtioNetDevicePath =
+{
+  {
+    {
+      HARDWARE_DEVICE_PATH,
+      HW_VENDOR_DP,
+      {
+        (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+        (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+      }
+    },
+    SGI_VIRTIO_NET_GUID,
+  },
+  {
+    END_DEVICE_PATH_TYPE,
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,
+    {
+      sizeof (EFI_DEVICE_PATH_PROTOCOL),
+      0
+    }
+  }
+};
+
 /**
   Initialize platform Virtio devices.
 
@@ -60,6 +83,7 @@ InitVirtioDevices (
 {
   EFI_STATUS Status;
   STATIC EFI_HANDLE mVirtIoBlkController = NULL;
+  STATIC EFI_HANDLE mVirtIoNetController = NULL;
 
   // Install protocol interface for storage device
   if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
@@ -89,4 +113,34 @@ InitVirtioDevices (
       }
     }
   }
+
+  // Install protocol interface for network device
+  if ((FeaturePcdGet (PcdVirtioNetSupported)) &&
+      (FixedPcdGet32 (PcdVirtioNetBaseAddress))) {
+    Status = gBS->InstallProtocolInterface (&mVirtIoNetController,
+                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
+                    &mVirtioNetDevicePath);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
+        "for Virtio Network device (Status = %r)\n",
+        __FUNCTION__, Status));
+    } else {
+      // Declare the Virtio Net device
+      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioNetBaseAddress),
+                 mVirtIoNetController);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Network MMIO device "
+          "(Status == %r)\n",
+          __FUNCTION__, Status));
+        gBS->UninstallProtocolInterface (
+               mVirtIoNetController,
+               &gEfiDevicePathProtocolGuid,
+               &mVirtioNetDevicePath
+            );
+      } else {
+        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Network device\n",
+          __FUNCTION__));
+      }
+    }
+  }
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 3/8] Sgi575: AcpiTables: Use PCDs for virtio disk
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 2/8] Platform/ARM/SgiPkg: Add support for virtio net device Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 4/8] Sgi575: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

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

Use PCDs instead of hardcoded values for virtio disk in DSDT.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
---
 Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf |  4 ++++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl      | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf b/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf
index 59ccb79b6475..e236b940a802 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf
@@ -55,4 +55,8 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdPciBusMin
   gArmTokenSpaceGuid.PcdPciBusMax
 
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt
+
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
index 509cd7cd4262..833f5b44b6a8 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
@@ -104,8 +104,14 @@ DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARMSGI", EFI_ACPI_ARM_OEM
     Name (_CCA, 1)    // mark the device coherent
 
     Name (_CRS, ResourceTemplate() {
-      Memory32Fixed (ReadWrite, 0x1c130000, 0x10000)
-      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 202 }
+      Memory32Fixed (
+        ReadWrite,
+        FixedPcdGet32 (PcdVirtioBlkBaseAddress),
+        FixedPcdGet32 (PcdVirtioBlkSize)
+      )
+      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
+        FixedPcdGet32 (PcdVirtioBlkInterrupt)
+      }
     })
   }
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 4/8] Sgi575: AcpiTables: Add entry for virtio network device
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
                   ` (2 preceding siblings ...)
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 3/8] Sgi575: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 5/8] SgiClark.Ares: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

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

SGI575 include an instance of the virtio network device. So add
a representation for it in the ACPI tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
---
 Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf |  3 +++
 Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl      | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf b/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf
index e236b940a802..c666ea9d51c7 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575AcpiTables.inf
@@ -58,5 +58,8 @@ [FixedPcd]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
   gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt
+  gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSize
+  gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt
 
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
diff --git a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
index 833f5b44b6a8..36bc8c3809a0 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
+++ b/Platform/ARM/SgiPkg/AcpiTables/Sgi575/Dsdt.asl
@@ -114,4 +114,22 @@ DefinitionBlock("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARMSGI", EFI_ACPI_ARM_OEM
       }
     })
   }
+
+  // VIRTIO NET
+  Device (VR01) {
+    Name (_HID, "LNRO0005")
+    Name (_UID, 1)
+    Name (_CCA, 1)    // mark the device coherent
+
+    Name (_CRS, ResourceTemplate() {
+      Memory32Fixed (
+        ReadWrite,
+        FixedPcdGet32 (PcdVirtioNetBaseAddress),
+        FixedPcdGet32 (PcdVirtioNetSize)
+      )
+      Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
+        FixedPcdGet32 (PcdVirtioNetInterrupt)
+      }
+    })
+  }
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 5/8] SgiClark.Ares: AcpiTables: Use PCDs for virtio disk
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
                   ` (3 preceding siblings ...)
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 4/8] Sgi575: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 6/8] SgiClark.Ares: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

Use PCDs instead of hardcoded values for virtio disk in DSDT.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
---
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf |  4 ++++
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl      | 12 +++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf
index dcfe4929bb5a..10a805e07fd1 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf
@@ -55,4 +55,8 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdPciBusMin
   gArmTokenSpaceGuid.PcdPciBusMax
 
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt
+
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl
index c94a7c69e33a..af4dc424a77c 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl
@@ -107,9 +107,15 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARMSGI",
       Name (_UID, 0)
       Name (_CCA, 1)    // mark the device coherent
 
-      Name (_CRS, ResourceTemplate () {
-        Memory32Fixed (ReadWrite, 0x1c130000, 0x10000)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 202 }
+      Name (_CRS, ResourceTemplate() {
+        Memory32Fixed (
+          ReadWrite,
+          FixedPcdGet32 (PcdVirtioBlkBaseAddress),
+          FixedPcdGet32 (PcdVirtioBlkSize)
+        )
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
+          FixedPcdGet32 (PcdVirtioBlkInterrupt)
+        }
       })
     }
   } // Scope(_SB)
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 6/8] SgiClark.Ares: AcpiTables: Add entry for virtio network device
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
                   ` (4 preceding siblings ...)
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 5/8] SgiClark.Ares: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 7/8] SgiClark.Helios: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 8/8] SgiClark.Helios: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

SgiClark Ares include an instance of the virtio network device. Add
a representation for it in the ACPI tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
---
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf |  3 +++
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl      | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf
index 10a805e07fd1..d4bacdbc8c85 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAresAcpiTables.inf
@@ -58,5 +58,8 @@ [FixedPcd]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
   gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt
+  gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSize
+  gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt
 
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl
index af4dc424a77c..69dc33c06b4d 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkAres/Dsdt.asl
@@ -118,5 +118,22 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARMSGI",
         }
       })
     }
+
+    // VIRTIO NET
+    Device (VR01) {
+      Name (_HID, "LNRO0005")
+      Name (_UID, 1)
+      Name (_CCA, 1)    // mark the device coherent
+
+      Name (_CRS, ResourceTemplate() {
+        Memory32Fixed (ReadWrite,
+          FixedPcdGet32 (PcdVirtioNetBaseAddress),
+          FixedPcdGet32 (PcdVirtioNetSize)
+        )
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
+          FixedPcdGet32 (PcdVirtioNetInterrupt)
+        }
+      })
+    }
   } // Scope(_SB)
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 7/8] SgiClark.Helios: AcpiTables: Use PCDs for virtio disk
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
                   ` (5 preceding siblings ...)
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 6/8] SgiClark.Ares: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 8/8] SgiClark.Helios: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

Use PCDs instead of hardcoded values for virtio disk in DSDT.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
---
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf |  4 ++++
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl      | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf
index 0ecce2db8a5d..3686e91bb7e7 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf
@@ -55,4 +55,8 @@ [FixedPcd]
   gArmTokenSpaceGuid.PcdPciBusMin
   gArmTokenSpaceGuid.PcdPciBusMax
 
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
+  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt
+
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl
index b8eb3b8e7332..3dcf6f71eadb 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl
@@ -254,8 +254,14 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARMSGI",
       Name (_CCA, 1)    // mark the device coherent
 
       Name (_CRS, ResourceTemplate() {
-        Memory32Fixed (ReadWrite, 0x1c130000, 0x10000)
-        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 202 }
+        Memory32Fixed (
+          ReadWrite,
+          FixedPcdGet32 (PcdVirtioBlkBaseAddress),
+          FixedPcdGet32 (PcdVirtioBlkSize)
+        )
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
+          FixedPcdGet32 (PcdVirtioBlkInterrupt)
+        }
       })
     }
   } // Scope(_SB)
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v1 edk2-platforms 8/8] SgiClark.Helios: AcpiTables: Add entry for virtio network device
  2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
                   ` (6 preceding siblings ...)
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 7/8] SgiClark.Helios: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
@ 2018-12-04  9:12 ` Vijayenthiran Subramaniam
  7 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-04  9:12 UTC (permalink / raw)
  To: edk2-devel, ard.biesheuvel, leif.lindholm

SgiClark Helios include an instance of the virtio network device. Add
a representation for it in the ACPI tables.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com>
---
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf |  3 +++
 Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl      | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf
index 3686e91bb7e7..8b45702b7cd3 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHeliosAcpiTables.inf
@@ -58,5 +58,8 @@ [FixedPcd]
   gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
   gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
   gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt
+  gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress
+  gArmSgiTokenSpaceGuid.PcdVirtioNetSize
+  gArmSgiTokenSpaceGuid.PcdVirtioNetInterrupt
 
   gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
diff --git a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl
index 3dcf6f71eadb..7cfc419eb3a2 100644
--- a/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl
+++ b/Platform/ARM/SgiPkg/AcpiTables/SgiClarkHelios/Dsdt.asl
@@ -264,5 +264,23 @@ DefinitionBlock ("DsdtTable.aml", "DSDT", 1, "ARMLTD", "ARMSGI",
         }
       })
     }
+
+    // VIRTIO NET
+    Device (VR01) {
+      Name (_HID, "LNRO0005")
+      Name (_UID, 1)
+      Name (_CCA, 1)    // mark the device coherent
+
+      Name (_CRS, ResourceTemplate() {
+        Memory32Fixed (
+          ReadWrite,
+          FixedPcdGet32 (PcdVirtioNetBaseAddress),
+          FixedPcdGet32 (PcdVirtioNetSize)
+        )
+        Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) {
+          FixedPcdGet32 (PcdVirtioNetInterrupt)
+        }
+      })
+    }
   } // Scope(_SB)
 }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-04  9:12 ` [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration Vijayenthiran Subramaniam
@ 2018-12-04 14:46   ` Ard Biesheuvel
  2018-12-05  6:10     ` Vijayenthiran Subramaniam
  0 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2018-12-04 14:46 UTC (permalink / raw)
  To: vijayenthiran.subramaniam
  Cc: edk2-devel@lists.01.org, Leif Lindholm, Daniil Egranov

On Tue, 4 Dec 2018 at 10:12, Vijayenthiran Subramaniam
<vijayenthiran.subramaniam@arm.com> wrote:
>
> From: Daniil Egranov <daniil.egranov@arm.com>
>
> SGI platforms support multiple virtio devices. So the existing code, that
> supports registration of only the virtio disk, is restructured to
> accommodate the registration of additional virtio devices.
>
> In addition to this, PCDs to represent the virtio controller base and
> address space size are introduced.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
> ---
>  Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  8 ++-
>  Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  7 +-
>  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  8 ++-
>  Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   | 21 ++++++
>  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        | 14 +---
>  Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 67 ++++++++++++--------
>  6 files changed, 81 insertions(+), 44 deletions(-)
>

Can these platforms only ever expose a single block device and a
single network device?

> diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
> index f6e0ba1e927a..ed29a4d5d91f 100644
> --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> @@ -37,12 +37,16 @@ [Guids.common]
>    gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, { 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
>
>  [PcdsFeatureFlag.common]
> -  # Set this PCD to TRUE to enable virtio support.
> -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
>
>  [PcdsFixedAtBuild]
>    gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
>    gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
>
> +  # Virtio Block device
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
> +
>  [Ppis]
>    gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
> diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> index b3f76d2d9720..ada72be72f8a 100644
> --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> @@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
>  ################################################################################
>
>  [PcdsFeatureFlag.common]
> -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
>
>  [PcdsFixedAtBuild.common]
>    gArmTokenSpaceGuid.PcdVFPEnabled|1
> @@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
>    # Ethernet
>    gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
>
> +  # Virtio Disk
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
> +
>  ################################################################################
>  #
>  # Components Section - list of all EDK II Modules needed by this Platform
> diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> index d903ed8d3375..f920f6ecafb8 100644
> --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> @@ -20,7 +20,7 @@ [Defines]
>
>  [Sources.common]
>    PlatformDxe.c
> -  VirtioBlockIo.c
> +  VirtioDevices.c
>
>  [Packages]
>    EmbeddedPkg/EmbeddedPkg.dec
> @@ -41,7 +41,11 @@ [Guids]
>    gSgiClarkHeliosAcpiTablesFileGuid
>
>  [FeaturePcd]
> -  gArmSgiTokenSpaceGuid.PcdVirtioSupported
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
> +
> +[FixedPcd]
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
> +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
>
>  [Depex]
>    TRUE
> diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> new file mode 100644
> index 000000000000..80d3e3ae4f91
> --- /dev/null
> +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> @@ -0,0 +1,21 @@
> +/** @file
> +*
> +*  Copyright (c) 2018, ARM Limited. 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.
> +*
> +**/
> +
> +#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
> +#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
> +
> +#define SGI_VIRTIO_BLOCK_GUID  \
> +  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
> +
> +#endif
> diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> index a8708a5c4ce5..aa032c41f686 100644
> --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> @@ -17,9 +17,8 @@
>  #include <Library/HobLib.h>
>  #include <SgiPlatform.h>
>
> -EFI_STATUS
> -InitVirtioBlockIo (
> -  IN EFI_HANDLE         ImageHandle
> +VOID
> +InitVirtioDevices (
>    );
>
>  EFI_STATUS
> @@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
>      return Status;
>    }
>
> -  Status = EFI_REQUEST_UNLOAD_IMAGE;
> -  if (FeaturePcdGet (PcdVirtioSupported)) {
> -    Status = InitVirtioBlockIo (ImageHandle);
> -    if (EFI_ERROR (Status)) {
> -      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block device\n",
> -        __FUNCTION__));
> -    }
> -  }
> +  InitVirtioDevices ();
>
>    return Status;
>  }
> diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> similarity index 41%
> rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> index 5b5863f4b806..4703aec06968 100644
> --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> @@ -12,6 +12,7 @@
>
>  **/
>
> +#include <Guid/SgiVirtioDevicesFormSet.h>
>  #include <Library/VirtioMmioDeviceLib.h>
>  #include <Library/DevicePathLib.h>
>  #include <Library/DebugLib.h>
> @@ -20,12 +21,12 @@
>
>  #pragma pack (1)
>  typedef struct {
> -  VENDOR_DEVICE_PATH                  Vendor;
> +  VENDOR_DEVICE_PATH                  VendorDevicePath;
>    EFI_DEVICE_PATH_PROTOCOL            End;
> -} VIRTIO_BLK_DEVICE_PATH;
> +} VIRTIO_DEVICE_PATH;
>  #pragma pack ()
>
> -STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
>  {
>    {
>      {
> @@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
>          (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
>        }
>      },
> -    EFI_CALLER_ID_GUID,
> +    SGI_VIRTIO_BLOCK_GUID,
>    },
>    {
>      END_DEVICE_PATH_TYPE,
> @@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
>  };
>
>  /**
> - * Entrypoint for 'VirtioBlockIo' driver
> - */
> -EFI_STATUS
> -InitVirtioBlockIo (
> -   IN EFI_HANDLE         ImageHandle
> +  Initialize platform Virtio devices.
> +
> +  @return None.
> +**/
> +VOID
> +InitVirtioDevices (
>    )
>  {
>    EFI_STATUS Status;
> +  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
>
> -  Status = gBS->InstallProtocolInterface (&ImageHandle,
> -                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> -                  &mVirtioBlockDevicePath);
> -  if (EFI_ERROR (Status)) {
> -    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
> -      "protocol for the virtio block device (Status == %r)\n",
> -      __FUNCTION__, Status));
> -    return Status;
> +  // Install protocol interface for storage device
> +  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
> +      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
> +    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
> +                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> +                    &mVirtioBlockDevicePath);
> +    if (EFI_ERROR (Status)) {
> +      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
> +        "for Virtio Block device (Status = %r)\n",
> +        __FUNCTION__, Status));
> +    } else {
> +      // Declare the Virtio BlockIo device
> +      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioBlkBaseAddress),
> +                 mVirtIoBlkController);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device "
> +          "(Status == %r)\n", __FUNCTION__, Status));
> +        gBS->UninstallProtocolInterface (
> +               mVirtIoBlkController,
> +               &gEfiDevicePathProtocolGuid,
> +               &mVirtioBlockDevicePath
> +             );
> +      } else {
> +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
> +          __FUNCTION__));
> +      }
> +    }
>    }
> -
> -  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle);
> -  if (EFI_ERROR (Status)) {
> -    DEBUG ((DEBUG_ERROR,
> -      "%a: Failed to install Virtio block device (Status == %r)\n",
> -      __FUNCTION__, Status));
> -    gBS->UninstallProtocolInterface (ImageHandle,
> -           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
> -  }
> -
> -  return Status;
>  }
> --
> 2.7.4
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-04 14:46   ` Ard Biesheuvel
@ 2018-12-05  6:10     ` Vijayenthiran Subramaniam
  2018-12-06 17:17       ` Ard Biesheuvel
  0 siblings, 1 reply; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-05  6:10 UTC (permalink / raw)
  To: ard.biesheuvel; +Cc: edk2-devel

Hi Ard,

The virtio block device and virtio network device are available in software
model only. As of now, it exposes only one instance of each device.

On Tue, Dec 4, 2018 at 8:16 PM Ard Biesheuvel <ard.biesheuvel@linaro.org>
wrote:

> On Tue, 4 Dec 2018 at 10:12, Vijayenthiran Subramaniam
> <vijayenthiran.subramaniam@arm.com> wrote:
> >
> > From: Daniil Egranov <daniil.egranov@arm.com>
> >
> > SGI platforms support multiple virtio devices. So the existing code, that
> > supports registration of only the virtio disk, is restructured to
> > accommodate the registration of additional virtio devices.
> >
> > In addition to this, PCDs to represent the virtio controller base and
> > address space size are introduced.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
> > ---
> >  Platform/ARM/SgiPkg/SgiPlatform.dec
>       |  8 ++-
> >  Platform/ARM/SgiPkg/SgiPlatform.dsc
>       |  7 +-
> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
>       |  8 ++-
> >  Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
>      | 21 ++++++
> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
>       | 14 +---
> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c =>
> VirtioDevices.c} | 67 ++++++++++++--------
> >  6 files changed, 81 insertions(+), 44 deletions(-)
> >
>
> Can these platforms only ever expose a single block device and a
> single network device?
>
> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec
> b/Platform/ARM/SgiPkg/SgiPlatform.dec
> > index f6e0ba1e927a..ed29a4d5d91f 100644
> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> > @@ -37,12 +37,16 @@ [Guids.common]
> >    gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, {
> 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
> >
> >  [PcdsFeatureFlag.common]
> > -  # Set this PCD to TRUE to enable virtio support.
> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
> >
> >  [PcdsFixedAtBuild]
> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
> >
> > +  # Virtio Block device
> > +
> gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
> > +
> gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
> > +
> >  [Ppis]
> >    gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8,
> 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > index b3f76d2d9720..ada72be72f8a 100644
> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > @@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER,
> LibraryClasses.common.UEFI_APPLICATION, Libr
> >
> ################################################################################
> >
> >  [PcdsFeatureFlag.common]
> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
> >
> >  [PcdsFixedAtBuild.common]
> >    gArmTokenSpaceGuid.PcdVFPEnabled|1
> > @@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
> >    # Ethernet
> >    gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
> >
> > +  # Virtio Disk
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
> > +
> >
> ################################################################################
> >  #
> >  # Components Section - list of all EDK II Modules needed by this
> Platform
> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > index d903ed8d3375..f920f6ecafb8 100644
> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > @@ -20,7 +20,7 @@ [Defines]
> >
> >  [Sources.common]
> >    PlatformDxe.c
> > -  VirtioBlockIo.c
> > +  VirtioDevices.c
> >
> >  [Packages]
> >    EmbeddedPkg/EmbeddedPkg.dec
> > @@ -41,7 +41,11 @@ [Guids]
> >    gSgiClarkHeliosAcpiTablesFileGuid
> >
> >  [FeaturePcd]
> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
> > +
> > +[FixedPcd]
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
> >
> >  [Depex]
> >    TRUE
> > diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> > new file mode 100644
> > index 000000000000..80d3e3ae4f91
> > --- /dev/null
> > +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> > @@ -0,0 +1,21 @@
> > +/** @file
> > +*
> > +*  Copyright (c) 2018, ARM Limited. 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.
> > +*
> > +**/
> > +
> > +#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
> > +#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
> > +
> > +#define SGI_VIRTIO_BLOCK_GUID  \
> > +  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c,
> 0xe2, 0x28 } }
> > +
> > +#endif
> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > index a8708a5c4ce5..aa032c41f686 100644
> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > @@ -17,9 +17,8 @@
> >  #include <Library/HobLib.h>
> >  #include <SgiPlatform.h>
> >
> > -EFI_STATUS
> > -InitVirtioBlockIo (
> > -  IN EFI_HANDLE         ImageHandle
> > +VOID
> > +InitVirtioDevices (
> >    );
> >
> >  EFI_STATUS
> > @@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
> >      return Status;
> >    }
> >
> > -  Status = EFI_REQUEST_UNLOAD_IMAGE;
> > -  if (FeaturePcdGet (PcdVirtioSupported)) {
> > -    Status = InitVirtioBlockIo (ImageHandle);
> > -    if (EFI_ERROR (Status)) {
> > -      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block
> device\n",
> > -        __FUNCTION__));
> > -    }
> > -  }
> > +  InitVirtioDevices ();
> >
> >    return Status;
> >  }
> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > similarity index 41%
> > rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> > rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > index 5b5863f4b806..4703aec06968 100644
> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > @@ -12,6 +12,7 @@
> >
> >  **/
> >
> > +#include <Guid/SgiVirtioDevicesFormSet.h>
> >  #include <Library/VirtioMmioDeviceLib.h>
> >  #include <Library/DevicePathLib.h>
> >  #include <Library/DebugLib.h>
> > @@ -20,12 +21,12 @@
> >
> >  #pragma pack (1)
> >  typedef struct {
> > -  VENDOR_DEVICE_PATH                  Vendor;
> > +  VENDOR_DEVICE_PATH                  VendorDevicePath;
> >    EFI_DEVICE_PATH_PROTOCOL            End;
> > -} VIRTIO_BLK_DEVICE_PATH;
> > +} VIRTIO_DEVICE_PATH;
> >  #pragma pack ()
> >
> > -STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
> >  {
> >    {
> >      {
> > @@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> >          (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> >        }
> >      },
> > -    EFI_CALLER_ID_GUID,
> > +    SGI_VIRTIO_BLOCK_GUID,
> >    },
> >    {
> >      END_DEVICE_PATH_TYPE,
> > @@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath
> =
> >  };
> >
> >  /**
> > - * Entrypoint for 'VirtioBlockIo' driver
> > - */
> > -EFI_STATUS
> > -InitVirtioBlockIo (
> > -   IN EFI_HANDLE         ImageHandle
> > +  Initialize platform Virtio devices.
> > +
> > +  @return None.
> > +**/
> > +VOID
> > +InitVirtioDevices (
> >    )
> >  {
> >    EFI_STATUS Status;
> > +  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
> >
> > -  Status = gBS->InstallProtocolInterface (&ImageHandle,
> > -                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> > -                  &mVirtioBlockDevicePath);
> > -  if (EFI_ERROR (Status)) {
> > -    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
> > -      "protocol for the virtio block device (Status == %r)\n",
> > -      __FUNCTION__, Status));
> > -    return Status;
> > +  // Install protocol interface for storage device
> > +  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
> > +      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
> > +    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
> > +                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> > +                    &mVirtioBlockDevicePath);
> > +    if (EFI_ERROR (Status)) {
> > +      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH
> protocol "
> > +        "for Virtio Block device (Status = %r)\n",
> > +        __FUNCTION__, Status));
> > +    } else {
> > +      // Declare the Virtio BlockIo device
> > +      Status = VirtioMmioInstallDevice (FixedPcdGet32
> (PcdVirtioBlkBaseAddress),
> > +                 mVirtIoBlkController);
> > +      if (EFI_ERROR (Status)) {
> > +        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO
> device "
> > +          "(Status == %r)\n", __FUNCTION__, Status));
> > +        gBS->UninstallProtocolInterface (
> > +               mVirtIoBlkController,
> > +               &gEfiDevicePathProtocolGuid,
> > +               &mVirtioBlockDevicePath
> > +             );
> > +      } else {
> > +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
> > +          __FUNCTION__));
> > +      }
> > +    }
> >    }
> > -
> > -  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE,
> ImageHandle);
> > -  if (EFI_ERROR (Status)) {
> > -    DEBUG ((DEBUG_ERROR,
> > -      "%a: Failed to install Virtio block device (Status == %r)\n",
> > -      __FUNCTION__, Status));
> > -    gBS->UninstallProtocolInterface (ImageHandle,
> > -           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
> > -  }
> > -
> > -  return Status;
> >  }
> > --
> > 2.7.4
> >
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
>


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-05  6:10     ` Vijayenthiran Subramaniam
@ 2018-12-06 17:17       ` Ard Biesheuvel
  2018-12-07  5:49         ` Vijayenthiran Subramaniam
  0 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2018-12-06 17:17 UTC (permalink / raw)
  To: vijayenthiran.subramaniam; +Cc: edk2-devel@lists.01.org

On Wed, 5 Dec 2018 at 07:10, Vijayenthiran Subramaniam
<vijayenthiran.subramaniam@arm.com> wrote:
>
> Hi Ard,
>
> The virtio block device and virtio network device are available in software model only. As of now, it exposes only one instance of each device.
>

Are the virtio devices described by the device tree obtained from the
secure firmware?

> On Tue, Dec 4, 2018 at 8:16 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>>
>> On Tue, 4 Dec 2018 at 10:12, Vijayenthiran Subramaniam
>> <vijayenthiran.subramaniam@arm.com> wrote:
>> >
>> > From: Daniil Egranov <daniil.egranov@arm.com>
>> >
>> > SGI platforms support multiple virtio devices. So the existing code, that
>> > supports registration of only the virtio disk, is restructured to
>> > accommodate the registration of additional virtio devices.
>> >
>> > In addition to this, PCDs to represent the virtio controller base and
>> > address space size are introduced.
>> >
>> > Contributed-under: TianoCore Contribution Agreement 1.1
>> > Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
>> > ---
>> >  Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  8 ++-
>> >  Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  7 +-
>> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  8 ++-
>> >  Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   | 21 ++++++
>> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        | 14 +---
>> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 67 ++++++++++++--------
>> >  6 files changed, 81 insertions(+), 44 deletions(-)
>> >
>>
>> Can these platforms only ever expose a single block device and a
>> single network device?
>>
>> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
>> > index f6e0ba1e927a..ed29a4d5d91f 100644
>> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
>> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
>> > @@ -37,12 +37,16 @@ [Guids.common]
>> >    gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, { 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
>> >
>> >  [PcdsFeatureFlag.common]
>> > -  # Set this PCD to TRUE to enable virtio support.
>> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
>> >
>> >  [PcdsFixedAtBuild]
>> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
>> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
>> >
>> > +  # Virtio Block device
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
>> > +
>> >  [Ppis]
>> >    gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
>> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
>> > index b3f76d2d9720..ada72be72f8a 100644
>> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
>> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
>> > @@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
>> >  ################################################################################
>> >
>> >  [PcdsFeatureFlag.common]
>> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
>> >
>> >  [PcdsFixedAtBuild.common]
>> >    gArmTokenSpaceGuid.PcdVFPEnabled|1
>> > @@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
>> >    # Ethernet
>> >    gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
>> >
>> > +  # Virtio Disk
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
>> > +
>> >  ################################################################################
>> >  #
>> >  # Components Section - list of all EDK II Modules needed by this Platform
>> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
>> > index d903ed8d3375..f920f6ecafb8 100644
>> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
>> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
>> > @@ -20,7 +20,7 @@ [Defines]
>> >
>> >  [Sources.common]
>> >    PlatformDxe.c
>> > -  VirtioBlockIo.c
>> > +  VirtioDevices.c
>> >
>> >  [Packages]
>> >    EmbeddedPkg/EmbeddedPkg.dec
>> > @@ -41,7 +41,11 @@ [Guids]
>> >    gSgiClarkHeliosAcpiTablesFileGuid
>> >
>> >  [FeaturePcd]
>> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
>> > +
>> > +[FixedPcd]
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
>> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
>> >
>> >  [Depex]
>> >    TRUE
>> > diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
>> > new file mode 100644
>> > index 000000000000..80d3e3ae4f91
>> > --- /dev/null
>> > +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
>> > @@ -0,0 +1,21 @@
>> > +/** @file
>> > +*
>> > +*  Copyright (c) 2018, ARM Limited. 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.
>> > +*
>> > +**/
>> > +
>> > +#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
>> > +#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
>> > +
>> > +#define SGI_VIRTIO_BLOCK_GUID  \
>> > +  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
>> > +
>> > +#endif
>> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
>> > index a8708a5c4ce5..aa032c41f686 100644
>> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
>> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
>> > @@ -17,9 +17,8 @@
>> >  #include <Library/HobLib.h>
>> >  #include <SgiPlatform.h>
>> >
>> > -EFI_STATUS
>> > -InitVirtioBlockIo (
>> > -  IN EFI_HANDLE         ImageHandle
>> > +VOID
>> > +InitVirtioDevices (
>> >    );
>> >
>> >  EFI_STATUS
>> > @@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
>> >      return Status;
>> >    }
>> >
>> > -  Status = EFI_REQUEST_UNLOAD_IMAGE;
>> > -  if (FeaturePcdGet (PcdVirtioSupported)) {
>> > -    Status = InitVirtioBlockIo (ImageHandle);
>> > -    if (EFI_ERROR (Status)) {
>> > -      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block device\n",
>> > -        __FUNCTION__));
>> > -    }
>> > -  }
>> > +  InitVirtioDevices ();
>> >
>> >    return Status;
>> >  }
>> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
>> > similarity index 41%
>> > rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
>> > rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
>> > index 5b5863f4b806..4703aec06968 100644
>> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
>> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
>> > @@ -12,6 +12,7 @@
>> >
>> >  **/
>> >
>> > +#include <Guid/SgiVirtioDevicesFormSet.h>
>> >  #include <Library/VirtioMmioDeviceLib.h>
>> >  #include <Library/DevicePathLib.h>
>> >  #include <Library/DebugLib.h>
>> > @@ -20,12 +21,12 @@
>> >
>> >  #pragma pack (1)
>> >  typedef struct {
>> > -  VENDOR_DEVICE_PATH                  Vendor;
>> > +  VENDOR_DEVICE_PATH                  VendorDevicePath;
>> >    EFI_DEVICE_PATH_PROTOCOL            End;
>> > -} VIRTIO_BLK_DEVICE_PATH;
>> > +} VIRTIO_DEVICE_PATH;
>> >  #pragma pack ()
>> >
>> > -STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
>> > +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
>> >  {
>> >    {
>> >      {
>> > @@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
>> >          (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
>> >        }
>> >      },
>> > -    EFI_CALLER_ID_GUID,
>> > +    SGI_VIRTIO_BLOCK_GUID,
>> >    },
>> >    {
>> >      END_DEVICE_PATH_TYPE,
>> > @@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
>> >  };
>> >
>> >  /**
>> > - * Entrypoint for 'VirtioBlockIo' driver
>> > - */
>> > -EFI_STATUS
>> > -InitVirtioBlockIo (
>> > -   IN EFI_HANDLE         ImageHandle
>> > +  Initialize platform Virtio devices.
>> > +
>> > +  @return None.
>> > +**/
>> > +VOID
>> > +InitVirtioDevices (
>> >    )
>> >  {
>> >    EFI_STATUS Status;
>> > +  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
>> >
>> > -  Status = gBS->InstallProtocolInterface (&ImageHandle,
>> > -                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
>> > -                  &mVirtioBlockDevicePath);
>> > -  if (EFI_ERROR (Status)) {
>> > -    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
>> > -      "protocol for the virtio block device (Status == %r)\n",
>> > -      __FUNCTION__, Status));
>> > -    return Status;
>> > +  // Install protocol interface for storage device
>> > +  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
>> > +      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
>> > +    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
>> > +                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
>> > +                    &mVirtioBlockDevicePath);
>> > +    if (EFI_ERROR (Status)) {
>> > +      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
>> > +        "for Virtio Block device (Status = %r)\n",
>> > +        __FUNCTION__, Status));
>> > +    } else {
>> > +      // Declare the Virtio BlockIo device
>> > +      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioBlkBaseAddress),
>> > +                 mVirtIoBlkController);
>> > +      if (EFI_ERROR (Status)) {
>> > +        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device "
>> > +          "(Status == %r)\n", __FUNCTION__, Status));
>> > +        gBS->UninstallProtocolInterface (
>> > +               mVirtIoBlkController,
>> > +               &gEfiDevicePathProtocolGuid,
>> > +               &mVirtioBlockDevicePath
>> > +             );
>> > +      } else {
>> > +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
>> > +          __FUNCTION__));
>> > +      }
>> > +    }
>> >    }
>> > -
>> > -  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle);
>> > -  if (EFI_ERROR (Status)) {
>> > -    DEBUG ((DEBUG_ERROR,
>> > -      "%a: Failed to install Virtio block device (Status == %r)\n",
>> > -      __FUNCTION__, Status));
>> > -    gBS->UninstallProtocolInterface (ImageHandle,
>> > -           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
>> > -  }
>> > -
>> > -  return Status;
>> >  }
>> > --
>> > 2.7.4
>> >
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org
>> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-06 17:17       ` Ard Biesheuvel
@ 2018-12-07  5:49         ` Vijayenthiran Subramaniam
  2018-12-11  9:07           ` Vijayenthiran Subramaniam
  0 siblings, 1 reply; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-07  5:49 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel

On Thu, Dec 6, 2018 at 5:18 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> On Wed, 5 Dec 2018 at 07:10, Vijayenthiran Subramaniam
> <vijayenthiran.subramaniam@arm.com> wrote:
> >
> > Hi Ard,
> >
> > The virtio block device and virtio network device are available in software model only. As of now, it exposes only one instance of each device.
> >
>
> Are the virtio devices described by the device tree obtained from the
> secure firmware?

No. The device tree from secure firmware does not carry any devices
information other than platform/config id.

>
> > On Tue, Dec 4, 2018 at 8:16 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >>
> >> On Tue, 4 Dec 2018 at 10:12, Vijayenthiran Subramaniam
> >> <vijayenthiran.subramaniam@arm.com> wrote:
> >> >
> >> > From: Daniil Egranov <daniil.egranov@arm.com>
> >> >
> >> > SGI platforms support multiple virtio devices. So the existing code, that
> >> > supports registration of only the virtio disk, is restructured to
> >> > accommodate the registration of additional virtio devices.
> >> >
> >> > In addition to this, PCDs to represent the virtio controller base and
> >> > address space size are introduced.
> >> >
> >> > Contributed-under: TianoCore Contribution Agreement 1.1
> >> > Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
> >> > ---
> >> >  Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  8 ++-
> >> >  Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  7 +-
> >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  8 ++-
> >> >  Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   | 21 ++++++
> >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        | 14 +---
> >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 67 ++++++++++++--------
> >> >  6 files changed, 81 insertions(+), 44 deletions(-)
> >> >
> >>
> >> Can these platforms only ever expose a single block device and a
> >> single network device?
> >>
> >> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
> >> > index f6e0ba1e927a..ed29a4d5d91f 100644
> >> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> >> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> >> > @@ -37,12 +37,16 @@ [Guids.common]
> >> >    gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, { 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
> >> >
> >> >  [PcdsFeatureFlag.common]
> >> > -  # Set this PCD to TRUE to enable virtio support.
> >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
> >> >
> >> >  [PcdsFixedAtBuild]
> >> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
> >> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
> >> >
> >> > +  # Virtio Block device
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
> >> > +
> >> >  [Ppis]
> >> >    gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
> >> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> >> > index b3f76d2d9720..ada72be72f8a 100644
> >> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> >> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> >> > @@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
> >> >  ################################################################################
> >> >
> >> >  [PcdsFeatureFlag.common]
> >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
> >> >
> >> >  [PcdsFixedAtBuild.common]
> >> >    gArmTokenSpaceGuid.PcdVFPEnabled|1
> >> > @@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
> >> >    # Ethernet
> >> >    gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
> >> >
> >> > +  # Virtio Disk
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
> >> > +
> >> >  ################################################################################
> >> >  #
> >> >  # Components Section - list of all EDK II Modules needed by this Platform
> >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> >> > index d903ed8d3375..f920f6ecafb8 100644
> >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> >> > @@ -20,7 +20,7 @@ [Defines]
> >> >
> >> >  [Sources.common]
> >> >    PlatformDxe.c
> >> > -  VirtioBlockIo.c
> >> > +  VirtioDevices.c
> >> >
> >> >  [Packages]
> >> >    EmbeddedPkg/EmbeddedPkg.dec
> >> > @@ -41,7 +41,11 @@ [Guids]
> >> >    gSgiClarkHeliosAcpiTablesFileGuid
> >> >
> >> >  [FeaturePcd]
> >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
> >> > +
> >> > +[FixedPcd]
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
> >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
> >> >
> >> >  [Depex]
> >> >    TRUE
> >> > diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> >> > new file mode 100644
> >> > index 000000000000..80d3e3ae4f91
> >> > --- /dev/null
> >> > +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> >> > @@ -0,0 +1,21 @@
> >> > +/** @file
> >> > +*
> >> > +*  Copyright (c) 2018, ARM Limited. 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.
> >> > +*
> >> > +**/
> >> > +
> >> > +#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
> >> > +#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
> >> > +
> >> > +#define SGI_VIRTIO_BLOCK_GUID  \
> >> > +  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
> >> > +
> >> > +#endif
> >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> >> > index a8708a5c4ce5..aa032c41f686 100644
> >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> >> > @@ -17,9 +17,8 @@
> >> >  #include <Library/HobLib.h>
> >> >  #include <SgiPlatform.h>
> >> >
> >> > -EFI_STATUS
> >> > -InitVirtioBlockIo (
> >> > -  IN EFI_HANDLE         ImageHandle
> >> > +VOID
> >> > +InitVirtioDevices (
> >> >    );
> >> >
> >> >  EFI_STATUS
> >> > @@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
> >> >      return Status;
> >> >    }
> >> >
> >> > -  Status = EFI_REQUEST_UNLOAD_IMAGE;
> >> > -  if (FeaturePcdGet (PcdVirtioSupported)) {
> >> > -    Status = InitVirtioBlockIo (ImageHandle);
> >> > -    if (EFI_ERROR (Status)) {
> >> > -      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block device\n",
> >> > -        __FUNCTION__));
> >> > -    }
> >> > -  }
> >> > +  InitVirtioDevices ();
> >> >
> >> >    return Status;
> >> >  }
> >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> >> > similarity index 41%
> >> > rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> >> > rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> >> > index 5b5863f4b806..4703aec06968 100644
> >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> >> > @@ -12,6 +12,7 @@
> >> >
> >> >  **/
> >> >
> >> > +#include <Guid/SgiVirtioDevicesFormSet.h>
> >> >  #include <Library/VirtioMmioDeviceLib.h>
> >> >  #include <Library/DevicePathLib.h>
> >> >  #include <Library/DebugLib.h>
> >> > @@ -20,12 +21,12 @@
> >> >
> >> >  #pragma pack (1)
> >> >  typedef struct {
> >> > -  VENDOR_DEVICE_PATH                  Vendor;
> >> > +  VENDOR_DEVICE_PATH                  VendorDevicePath;
> >> >    EFI_DEVICE_PATH_PROTOCOL            End;
> >> > -} VIRTIO_BLK_DEVICE_PATH;
> >> > +} VIRTIO_DEVICE_PATH;
> >> >  #pragma pack ()
> >> >
> >> > -STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> >> > +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
> >> >  {
> >> >    {
> >> >      {
> >> > @@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> >> >          (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> >> >        }
> >> >      },
> >> > -    EFI_CALLER_ID_GUID,
> >> > +    SGI_VIRTIO_BLOCK_GUID,
> >> >    },
> >> >    {
> >> >      END_DEVICE_PATH_TYPE,
> >> > @@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> >> >  };
> >> >
> >> >  /**
> >> > - * Entrypoint for 'VirtioBlockIo' driver
> >> > - */
> >> > -EFI_STATUS
> >> > -InitVirtioBlockIo (
> >> > -   IN EFI_HANDLE         ImageHandle
> >> > +  Initialize platform Virtio devices.
> >> > +
> >> > +  @return None.
> >> > +**/
> >> > +VOID
> >> > +InitVirtioDevices (
> >> >    )
> >> >  {
> >> >    EFI_STATUS Status;
> >> > +  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
> >> >
> >> > -  Status = gBS->InstallProtocolInterface (&ImageHandle,
> >> > -                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> >> > -                  &mVirtioBlockDevicePath);
> >> > -  if (EFI_ERROR (Status)) {
> >> > -    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
> >> > -      "protocol for the virtio block device (Status == %r)\n",
> >> > -      __FUNCTION__, Status));
> >> > -    return Status;
> >> > +  // Install protocol interface for storage device
> >> > +  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
> >> > +      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
> >> > +    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
> >> > +                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> >> > +                    &mVirtioBlockDevicePath);
> >> > +    if (EFI_ERROR (Status)) {
> >> > +      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
> >> > +        "for Virtio Block device (Status = %r)\n",
> >> > +        __FUNCTION__, Status));
> >> > +    } else {
> >> > +      // Declare the Virtio BlockIo device
> >> > +      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioBlkBaseAddress),
> >> > +                 mVirtIoBlkController);
> >> > +      if (EFI_ERROR (Status)) {
> >> > +        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device "
> >> > +          "(Status == %r)\n", __FUNCTION__, Status));
> >> > +        gBS->UninstallProtocolInterface (
> >> > +               mVirtIoBlkController,
> >> > +               &gEfiDevicePathProtocolGuid,
> >> > +               &mVirtioBlockDevicePath
> >> > +             );
> >> > +      } else {
> >> > +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
> >> > +          __FUNCTION__));
> >> > +      }
> >> > +    }
> >> >    }
> >> > -
> >> > -  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle);
> >> > -  if (EFI_ERROR (Status)) {
> >> > -    DEBUG ((DEBUG_ERROR,
> >> > -      "%a: Failed to install Virtio block device (Status == %r)\n",
> >> > -      __FUNCTION__, Status));
> >> > -    gBS->UninstallProtocolInterface (ImageHandle,
> >> > -           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
> >> > -  }
> >> > -
> >> > -  return Status;
> >> >  }
> >> > --
> >> > 2.7.4
> >> >
> >> _______________________________________________
> >> edk2-devel mailing list
> >> edk2-devel@lists.01.org
> >> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-07  5:49         ` Vijayenthiran Subramaniam
@ 2018-12-11  9:07           ` Vijayenthiran Subramaniam
  2018-12-14 14:55             ` Ard Biesheuvel
  0 siblings, 1 reply; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-11  9:07 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel

On Fri, Dec 7, 2018 at 5:49 AM Vijayenthiran Subramaniam
<vijayenthiran.subramaniam@arm.com> wrote:
>
> On Thu, Dec 6, 2018 at 5:18 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> >
> > On Wed, 5 Dec 2018 at 07:10, Vijayenthiran Subramaniam
> > <vijayenthiran.subramaniam@arm.com> wrote:
> > >
> > > Hi Ard,
> > >
> > > The virtio block device and virtio network device are available in software model only. As of now, it exposes only one instance of each device.
> > >
> >
> > Are the virtio devices described by the device tree obtained from the
> > secure firmware?
>
> No. The device tree from secure firmware does not carry any devices
> information other than platform/config id.
>

Please let me know if there are any further comments on this patch
series. Otherwise, requesting to review the series and merge.

> >
> > > On Tue, Dec 4, 2018 at 8:16 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > >>
> > >> On Tue, 4 Dec 2018 at 10:12, Vijayenthiran Subramaniam
> > >> <vijayenthiran.subramaniam@arm.com> wrote:
> > >> >
> > >> > From: Daniil Egranov <daniil.egranov@arm.com>
> > >> >
> > >> > SGI platforms support multiple virtio devices. So the existing code, that
> > >> > supports registration of only the virtio disk, is restructured to
> > >> > accommodate the registration of additional virtio devices.
> > >> >
> > >> > In addition to this, PCDs to represent the virtio controller base and
> > >> > address space size are introduced.
> > >> >
> > >> > Contributed-under: TianoCore Contribution Agreement 1.1
> > >> > Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
> > >> > ---
> > >> >  Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  8 ++-
> > >> >  Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  7 +-
> > >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  8 ++-
> > >> >  Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   | 21 ++++++
> > >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        | 14 +---
> > >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 67 ++++++++++++--------
> > >> >  6 files changed, 81 insertions(+), 44 deletions(-)
> > >> >
> > >>
> > >> Can these platforms only ever expose a single block device and a
> > >> single network device?
> > >>
> > >> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
> > >> > index f6e0ba1e927a..ed29a4d5d91f 100644
> > >> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> > >> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> > >> > @@ -37,12 +37,16 @@ [Guids.common]
> > >> >    gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, { 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
> > >> >
> > >> >  [PcdsFeatureFlag.common]
> > >> > -  # Set this PCD to TRUE to enable virtio support.
> > >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
> > >> >
> > >> >  [PcdsFixedAtBuild]
> > >> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
> > >> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
> > >> >
> > >> > +  # Virtio Block device
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
> > >> > +
> > >> >  [Ppis]
> > >> >    gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
> > >> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > >> > index b3f76d2d9720..ada72be72f8a 100644
> > >> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > >> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > >> > @@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
> > >> >  ################################################################################
> > >> >
> > >> >  [PcdsFeatureFlag.common]
> > >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
> > >> >
> > >> >  [PcdsFixedAtBuild.common]
> > >> >    gArmTokenSpaceGuid.PcdVFPEnabled|1
> > >> > @@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
> > >> >    # Ethernet
> > >> >    gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
> > >> >
> > >> > +  # Virtio Disk
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
> > >> > +
> > >> >  ################################################################################
> > >> >  #
> > >> >  # Components Section - list of all EDK II Modules needed by this Platform
> > >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > >> > index d903ed8d3375..f920f6ecafb8 100644
> > >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > >> > @@ -20,7 +20,7 @@ [Defines]
> > >> >
> > >> >  [Sources.common]
> > >> >    PlatformDxe.c
> > >> > -  VirtioBlockIo.c
> > >> > +  VirtioDevices.c
> > >> >
> > >> >  [Packages]
> > >> >    EmbeddedPkg/EmbeddedPkg.dec
> > >> > @@ -41,7 +41,11 @@ [Guids]
> > >> >    gSgiClarkHeliosAcpiTablesFileGuid
> > >> >
> > >> >  [FeaturePcd]
> > >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
> > >> > +
> > >> > +[FixedPcd]
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
> > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
> > >> >
> > >> >  [Depex]
> > >> >    TRUE
> > >> > diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> > >> > new file mode 100644
> > >> > index 000000000000..80d3e3ae4f91
> > >> > --- /dev/null
> > >> > +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> > >> > @@ -0,0 +1,21 @@
> > >> > +/** @file
> > >> > +*
> > >> > +*  Copyright (c) 2018, ARM Limited. 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.
> > >> > +*
> > >> > +**/
> > >> > +
> > >> > +#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
> > >> > +#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
> > >> > +
> > >> > +#define SGI_VIRTIO_BLOCK_GUID  \
> > >> > +  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
> > >> > +
> > >> > +#endif
> > >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > >> > index a8708a5c4ce5..aa032c41f686 100644
> > >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > >> > @@ -17,9 +17,8 @@
> > >> >  #include <Library/HobLib.h>
> > >> >  #include <SgiPlatform.h>
> > >> >
> > >> > -EFI_STATUS
> > >> > -InitVirtioBlockIo (
> > >> > -  IN EFI_HANDLE         ImageHandle
> > >> > +VOID
> > >> > +InitVirtioDevices (
> > >> >    );
> > >> >
> > >> >  EFI_STATUS
> > >> > @@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
> > >> >      return Status;
> > >> >    }
> > >> >
> > >> > -  Status = EFI_REQUEST_UNLOAD_IMAGE;
> > >> > -  if (FeaturePcdGet (PcdVirtioSupported)) {
> > >> > -    Status = InitVirtioBlockIo (ImageHandle);
> > >> > -    if (EFI_ERROR (Status)) {
> > >> > -      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block device\n",
> > >> > -        __FUNCTION__));
> > >> > -    }
> > >> > -  }
> > >> > +  InitVirtioDevices ();
> > >> >
> > >> >    return Status;
> > >> >  }
> > >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > >> > similarity index 41%
> > >> > rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> > >> > rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > >> > index 5b5863f4b806..4703aec06968 100644
> > >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> > >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > >> > @@ -12,6 +12,7 @@
> > >> >
> > >> >  **/
> > >> >
> > >> > +#include <Guid/SgiVirtioDevicesFormSet.h>
> > >> >  #include <Library/VirtioMmioDeviceLib.h>
> > >> >  #include <Library/DevicePathLib.h>
> > >> >  #include <Library/DebugLib.h>
> > >> > @@ -20,12 +21,12 @@
> > >> >
> > >> >  #pragma pack (1)
> > >> >  typedef struct {
> > >> > -  VENDOR_DEVICE_PATH                  Vendor;
> > >> > +  VENDOR_DEVICE_PATH                  VendorDevicePath;
> > >> >    EFI_DEVICE_PATH_PROTOCOL            End;
> > >> > -} VIRTIO_BLK_DEVICE_PATH;
> > >> > +} VIRTIO_DEVICE_PATH;
> > >> >  #pragma pack ()
> > >> >
> > >> > -STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > >> > +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
> > >> >  {
> > >> >    {
> > >> >      {
> > >> > @@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > >> >          (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> > >> >        }
> > >> >      },
> > >> > -    EFI_CALLER_ID_GUID,
> > >> > +    SGI_VIRTIO_BLOCK_GUID,
> > >> >    },
> > >> >    {
> > >> >      END_DEVICE_PATH_TYPE,
> > >> > @@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > >> >  };
> > >> >
> > >> >  /**
> > >> > - * Entrypoint for 'VirtioBlockIo' driver
> > >> > - */
> > >> > -EFI_STATUS
> > >> > -InitVirtioBlockIo (
> > >> > -   IN EFI_HANDLE         ImageHandle
> > >> > +  Initialize platform Virtio devices.
> > >> > +
> > >> > +  @return None.
> > >> > +**/
> > >> > +VOID
> > >> > +InitVirtioDevices (
> > >> >    )
> > >> >  {
> > >> >    EFI_STATUS Status;
> > >> > +  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
> > >> >
> > >> > -  Status = gBS->InstallProtocolInterface (&ImageHandle,
> > >> > -                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> > >> > -                  &mVirtioBlockDevicePath);
> > >> > -  if (EFI_ERROR (Status)) {
> > >> > -    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
> > >> > -      "protocol for the virtio block device (Status == %r)\n",
> > >> > -      __FUNCTION__, Status));
> > >> > -    return Status;
> > >> > +  // Install protocol interface for storage device
> > >> > +  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
> > >> > +      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
> > >> > +    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
> > >> > +                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> > >> > +                    &mVirtioBlockDevicePath);
> > >> > +    if (EFI_ERROR (Status)) {
> > >> > +      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
> > >> > +        "for Virtio Block device (Status = %r)\n",
> > >> > +        __FUNCTION__, Status));
> > >> > +    } else {
> > >> > +      // Declare the Virtio BlockIo device
> > >> > +      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioBlkBaseAddress),
> > >> > +                 mVirtIoBlkController);
> > >> > +      if (EFI_ERROR (Status)) {
> > >> > +        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device "
> > >> > +          "(Status == %r)\n", __FUNCTION__, Status));
> > >> > +        gBS->UninstallProtocolInterface (
> > >> > +               mVirtIoBlkController,
> > >> > +               &gEfiDevicePathProtocolGuid,
> > >> > +               &mVirtioBlockDevicePath
> > >> > +             );
> > >> > +      } else {
> > >> > +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
> > >> > +          __FUNCTION__));
> > >> > +      }
> > >> > +    }
> > >> >    }
> > >> > -
> > >> > -  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle);
> > >> > -  if (EFI_ERROR (Status)) {
> > >> > -    DEBUG ((DEBUG_ERROR,
> > >> > -      "%a: Failed to install Virtio block device (Status == %r)\n",
> > >> > -      __FUNCTION__, Status));
> > >> > -    gBS->UninstallProtocolInterface (ImageHandle,
> > >> > -           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
> > >> > -  }
> > >> > -
> > >> > -  return Status;
> > >> >  }
> > >> > --
> > >> > 2.7.4
> > >> >
> > >> _______________________________________________
> > >> edk2-devel mailing list
> > >> edk2-devel@lists.01.org
> > >> https://lists.01.org/mailman/listinfo/edk2-devel
> > _______________________________________________
> > edk2-devel mailing list
> > edk2-devel@lists.01.org
> > https://lists.01.org/mailman/listinfo/edk2-devel

Regards,
Vijayenthiran


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-11  9:07           ` Vijayenthiran Subramaniam
@ 2018-12-14 14:55             ` Ard Biesheuvel
  2018-12-14 16:50               ` Vijayenthiran Subramaniam
  0 siblings, 1 reply; 16+ messages in thread
From: Ard Biesheuvel @ 2018-12-14 14:55 UTC (permalink / raw)
  To: Vijayenthiran Subramaniam; +Cc: edk2-devel@lists.01.org

On Tue, 11 Dec 2018 at 10:08, Vijayenthiran Subramaniam
<vijayenthiran.subramaniam@arm.com> wrote:
>
> On Fri, Dec 7, 2018 at 5:49 AM Vijayenthiran Subramaniam
> <vijayenthiran.subramaniam@arm.com> wrote:
> >
> > On Thu, Dec 6, 2018 at 5:18 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > >
> > > On Wed, 5 Dec 2018 at 07:10, Vijayenthiran Subramaniam
> > > <vijayenthiran.subramaniam@arm.com> wrote:
> > > >
> > > > Hi Ard,
> > > >
> > > > The virtio block device and virtio network device are available in software model only. As of now, it exposes only one instance of each device.
> > > >
> > >
> > > Are the virtio devices described by the device tree obtained from the
> > > secure firmware?
> >
> > No. The device tree from secure firmware does not carry any devices
> > information other than platform/config id.
> >
>
> Please let me know if there are any further comments on this patch
> series. Otherwise, requesting to review the series and merge.
>

Please rebase the series against latest edk2-platforms, and I will do
the final review (and merge)

> > >
> > > > On Tue, Dec 4, 2018 at 8:16 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > > >>
> > > >> On Tue, 4 Dec 2018 at 10:12, Vijayenthiran Subramaniam
> > > >> <vijayenthiran.subramaniam@arm.com> wrote:
> > > >> >
> > > >> > From: Daniil Egranov <daniil.egranov@arm.com>
> > > >> >
> > > >> > SGI platforms support multiple virtio devices. So the existing code, that
> > > >> > supports registration of only the virtio disk, is restructured to
> > > >> > accommodate the registration of additional virtio devices.
> > > >> >
> > > >> > In addition to this, PCDs to represent the virtio controller base and
> > > >> > address space size are introduced.
> > > >> >
> > > >> > Contributed-under: TianoCore Contribution Agreement 1.1
> > > >> > Signed-off-by: Daniil Egranov <daniil.egranov@arm.com>
> > > >> > ---
> > > >> >  Platform/ARM/SgiPkg/SgiPlatform.dec                                          |  8 ++-
> > > >> >  Platform/ARM/SgiPkg/SgiPlatform.dsc                                          |  7 +-
> > > >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf                      |  8 ++-
> > > >> >  Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h                   | 21 ++++++
> > > >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c                        | 14 +---
> > > >> >  Platform/ARM/SgiPkg/Drivers/PlatformDxe/{VirtioBlockIo.c => VirtioDevices.c} | 67 ++++++++++++--------
> > > >> >  6 files changed, 81 insertions(+), 44 deletions(-)
> > > >> >
> > > >>
> > > >> Can these platforms only ever expose a single block device and a
> > > >> single network device?
> > > >>
> > > >> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
> > > >> > index f6e0ba1e927a..ed29a4d5d91f 100644
> > > >> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dec
> > > >> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
> > > >> > @@ -37,12 +37,16 @@ [Guids.common]
> > > >> >    gSgiClarkHeliosAcpiTablesFileGuid = { 0x2af40815, 0xa84e, 0x4de9, { 0x8c, 0x38, 0x91, 0x40, 0xb3, 0x54, 0x40, 0x73 } }
> > > >> >
> > > >> >  [PcdsFeatureFlag.common]
> > > >> > -  # Set this PCD to TRUE to enable virtio support.
> > > >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE|BOOLEAN|0x00000001
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
> > > >> >
> > > >> >  [PcdsFixedAtBuild]
> > > >> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
> > > >> >    gArmSgiTokenSpaceGuid.PcdDramBlock2Size|0|UINT64|0x00000003
> > > >> >
> > > >> > +  # Virtio Block device
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x00000000|UINT32|0x00000004
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x00000000|UINT32|0x00000005
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|0x00000000|UINT32|0x00000006
> > > >> > +
> > > >> >  [Ppis]
> > > >> >    gHwConfigDtInfoPpiGuid     = { 0x6f606eb3, 0x9123, 0x4e15, { 0xa8, 0x9b, 0x0f, 0xac, 0x66, 0xef, 0xd0, 0x17 } }
> > > >> > diff --git a/Platform/ARM/SgiPkg/SgiPlatform.dsc b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > > >> > index b3f76d2d9720..ada72be72f8a 100644
> > > >> > --- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > > >> > +++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
> > > >> > @@ -98,7 +98,7 @@ [LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, Libr
> > > >> >  ################################################################################
> > > >> >
> > > >> >  [PcdsFeatureFlag.common]
> > > >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported|TRUE
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
> > > >> >
> > > >> >  [PcdsFixedAtBuild.common]
> > > >> >    gArmTokenSpaceGuid.PcdVFPEnabled|1
> > > >> > @@ -180,6 +180,11 @@ [PcdsFixedAtBuild.common]
> > > >> >    # Ethernet
> > > >> >    gEmbeddedTokenSpaceGuid.PcdLan91xDxeBaseAddress|0x18000000
> > > >> >
> > > >> > +  # Virtio Disk
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress|0x1c130000
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize|0x10000
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkInterrupt|202
> > > >> > +
> > > >> >  ################################################################################
> > > >> >  #
> > > >> >  # Components Section - list of all EDK II Modules needed by this Platform
> > > >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > > >> > index d903ed8d3375..f920f6ecafb8 100644
> > > >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > > >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
> > > >> > @@ -20,7 +20,7 @@ [Defines]
> > > >> >
> > > >> >  [Sources.common]
> > > >> >    PlatformDxe.c
> > > >> > -  VirtioBlockIo.c
> > > >> > +  VirtioDevices.c
> > > >> >
> > > >> >  [Packages]
> > > >> >    EmbeddedPkg/EmbeddedPkg.dec
> > > >> > @@ -41,7 +41,11 @@ [Guids]
> > > >> >    gSgiClarkHeliosAcpiTablesFileGuid
> > > >> >
> > > >> >  [FeaturePcd]
> > > >> > -  gArmSgiTokenSpaceGuid.PcdVirtioSupported
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
> > > >> > +
> > > >> > +[FixedPcd]
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
> > > >> > +  gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
> > > >> >
> > > >> >  [Depex]
> > > >> >    TRUE
> > > >> > diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> > > >> > new file mode 100644
> > > >> > index 000000000000..80d3e3ae4f91
> > > >> > --- /dev/null
> > > >> > +++ b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
> > > >> > @@ -0,0 +1,21 @@
> > > >> > +/** @file
> > > >> > +*
> > > >> > +*  Copyright (c) 2018, ARM Limited. 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.
> > > >> > +*
> > > >> > +**/
> > > >> > +
> > > >> > +#ifndef  __SGI_VIRTIO_DEVICES_FORMSET_H__
> > > >> > +#define  __SGI_VIRTIO_DEVICES_FORMSET_H__
> > > >> > +
> > > >> > +#define SGI_VIRTIO_BLOCK_GUID  \
> > > >> > +  { 0x5a96cdcd, 0x6116, 0x4929, { 0xb7, 0x01, 0x3a, 0xc2, 0xfb, 0x1c, 0xe2, 0x28 } }
> > > >> > +
> > > >> > +#endif
> > > >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > > >> > index a8708a5c4ce5..aa032c41f686 100644
> > > >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > > >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c
> > > >> > @@ -17,9 +17,8 @@
> > > >> >  #include <Library/HobLib.h>
> > > >> >  #include <SgiPlatform.h>
> > > >> >
> > > >> > -EFI_STATUS
> > > >> > -InitVirtioBlockIo (
> > > >> > -  IN EFI_HANDLE         ImageHandle
> > > >> > +VOID
> > > >> > +InitVirtioDevices (
> > > >> >    );
> > > >> >
> > > >> >  EFI_STATUS
> > > >> > @@ -63,14 +62,7 @@ ArmSgiPkgEntryPoint (
> > > >> >      return Status;
> > > >> >    }
> > > >> >
> > > >> > -  Status = EFI_REQUEST_UNLOAD_IMAGE;
> > > >> > -  if (FeaturePcdGet (PcdVirtioSupported)) {
> > > >> > -    Status = InitVirtioBlockIo (ImageHandle);
> > > >> > -    if (EFI_ERROR (Status)) {
> > > >> > -      DEBUG ((DEBUG_ERROR, "%a: Failed to install Virtio Block device\n",
> > > >> > -        __FUNCTION__));
> > > >> > -    }
> > > >> > -  }
> > > >> > +  InitVirtioDevices ();
> > > >> >
> > > >> >    return Status;
> > > >> >  }
> > > >> > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > > >> > similarity index 41%
> > > >> > rename from Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> > > >> > rename to Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > > >> > index 5b5863f4b806..4703aec06968 100644
> > > >> > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c
> > > >> > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
> > > >> > @@ -12,6 +12,7 @@
> > > >> >
> > > >> >  **/
> > > >> >
> > > >> > +#include <Guid/SgiVirtioDevicesFormSet.h>
> > > >> >  #include <Library/VirtioMmioDeviceLib.h>
> > > >> >  #include <Library/DevicePathLib.h>
> > > >> >  #include <Library/DebugLib.h>
> > > >> > @@ -20,12 +21,12 @@
> > > >> >
> > > >> >  #pragma pack (1)
> > > >> >  typedef struct {
> > > >> > -  VENDOR_DEVICE_PATH                  Vendor;
> > > >> > +  VENDOR_DEVICE_PATH                  VendorDevicePath;
> > > >> >    EFI_DEVICE_PATH_PROTOCOL            End;
> > > >> > -} VIRTIO_BLK_DEVICE_PATH;
> > > >> > +} VIRTIO_DEVICE_PATH;
> > > >> >  #pragma pack ()
> > > >> >
> > > >> > -STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > > >> > +STATIC VIRTIO_DEVICE_PATH mVirtioBlockDevicePath =
> > > >> >  {
> > > >> >    {
> > > >> >      {
> > > >> > @@ -36,7 +37,7 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > > >> >          (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
> > > >> >        }
> > > >> >      },
> > > >> > -    EFI_CALLER_ID_GUID,
> > > >> > +    SGI_VIRTIO_BLOCK_GUID,
> > > >> >    },
> > > >> >    {
> > > >> >      END_DEVICE_PATH_TYPE,
> > > >> > @@ -49,33 +50,43 @@ STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
> > > >> >  };
> > > >> >
> > > >> >  /**
> > > >> > - * Entrypoint for 'VirtioBlockIo' driver
> > > >> > - */
> > > >> > -EFI_STATUS
> > > >> > -InitVirtioBlockIo (
> > > >> > -   IN EFI_HANDLE         ImageHandle
> > > >> > +  Initialize platform Virtio devices.
> > > >> > +
> > > >> > +  @return None.
> > > >> > +**/
> > > >> > +VOID
> > > >> > +InitVirtioDevices (
> > > >> >    )
> > > >> >  {
> > > >> >    EFI_STATUS Status;
> > > >> > +  STATIC EFI_HANDLE mVirtIoBlkController = NULL;
> > > >> >
> > > >> > -  Status = gBS->InstallProtocolInterface (&ImageHandle,
> > > >> > -                  &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> > > >> > -                  &mVirtioBlockDevicePath);
> > > >> > -  if (EFI_ERROR (Status)) {
> > > >> > -    DEBUG ((DEBUG_ERROR, "%a: Failed to install the EFI_DEVICE_PATH "
> > > >> > -      "protocol for the virtio block device (Status == %r)\n",
> > > >> > -      __FUNCTION__, Status));
> > > >> > -    return Status;
> > > >> > +  // Install protocol interface for storage device
> > > >> > +  if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
> > > >> > +      (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) {
> > > >> > +    Status = gBS->InstallProtocolInterface (&mVirtIoBlkController,
> > > >> > +                    &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
> > > >> > +                    &mVirtioBlockDevicePath);
> > > >> > +    if (EFI_ERROR (Status)) {
> > > >> > +      DEBUG ((DEBUG_ERROR, "%a: Failed to install EFI_DEVICE_PATH protocol "
> > > >> > +        "for Virtio Block device (Status = %r)\n",
> > > >> > +        __FUNCTION__, Status));
> > > >> > +    } else {
> > > >> > +      // Declare the Virtio BlockIo device
> > > >> > +      Status = VirtioMmioInstallDevice (FixedPcdGet32 (PcdVirtioBlkBaseAddress),
> > > >> > +                 mVirtIoBlkController);
> > > >> > +      if (EFI_ERROR (Status)) {
> > > >> > +        DEBUG ((DEBUG_ERROR, "%a: Unable to find Virtio Block MMIO device "
> > > >> > +          "(Status == %r)\n", __FUNCTION__, Status));
> > > >> > +        gBS->UninstallProtocolInterface (
> > > >> > +               mVirtIoBlkController,
> > > >> > +               &gEfiDevicePathProtocolGuid,
> > > >> > +               &mVirtioBlockDevicePath
> > > >> > +             );
> > > >> > +      } else {
> > > >> > +        DEBUG ((DEBUG_INIT, "%a: Installed Virtio Block device\n",
> > > >> > +          __FUNCTION__));
> > > >> > +      }
> > > >> > +    }
> > > >> >    }
> > > >> > -
> > > >> > -  Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle);
> > > >> > -  if (EFI_ERROR (Status)) {
> > > >> > -    DEBUG ((DEBUG_ERROR,
> > > >> > -      "%a: Failed to install Virtio block device (Status == %r)\n",
> > > >> > -      __FUNCTION__, Status));
> > > >> > -    gBS->UninstallProtocolInterface (ImageHandle,
> > > >> > -           &gEfiDevicePathProtocolGuid, &mVirtioBlockDevicePath);
> > > >> > -  }
> > > >> > -
> > > >> > -  return Status;
> > > >> >  }
> > > >> > --
> > > >> > 2.7.4
> > > >> >
> > > >> _______________________________________________
> > > >> edk2-devel mailing list
> > > >> edk2-devel@lists.01.org
> > > >> https://lists.01.org/mailman/listinfo/edk2-devel
> > > _______________________________________________
> > > edk2-devel mailing list
> > > edk2-devel@lists.01.org
> > > https://lists.01.org/mailman/listinfo/edk2-devel
>
> Regards,
> Vijayenthiran


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration
  2018-12-14 14:55             ` Ard Biesheuvel
@ 2018-12-14 16:50               ` Vijayenthiran Subramaniam
  0 siblings, 0 replies; 16+ messages in thread
From: Vijayenthiran Subramaniam @ 2018-12-14 16:50 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel

On Fri, Dec 14, 2018 at 8:26 PM Ard Biesheuvel
<ard.biesheuvel@linaro.org> wrote:
>
> On Tue, 11 Dec 2018 at 10:08, Vijayenthiran Subramaniam
> <vijayenthiran.subramaniam@arm.com> wrote:
> >
> > On Fri, Dec 7, 2018 at 5:49 AM Vijayenthiran Subramaniam
> > <vijayenthiran.subramaniam@arm.com> wrote:
> > >
> > > On Thu, Dec 6, 2018 at 5:18 PM Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> > > >
> > > > On Wed, 5 Dec 2018 at 07:10, Vijayenthiran Subramaniam
> > > > <vijayenthiran.subramaniam@arm.com> wrote:
> > > > >
> > > > > Hi Ard,
> > > > >
> > > > > The virtio block device and virtio network device are available in software model only. As of now, it exposes only one instance of each device.
> > > > >
> > > >
> > > > Are the virtio devices described by the device tree obtained from the
> > > > secure firmware?
> > >
> > > No. The device tree from secure firmware does not carry any devices
> > > information other than platform/config id.
> > >
> >
> > Please let me know if there are any further comments on this patch
> > series. Otherwise, requesting to review the series and merge.
> >
>
> Please rebase the series against latest edk2-platforms, and I will do
> the final review (and merge)

Sure. Will post the series as v2 after rebasing.

Thanks,
Vijayenthiran.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-12-14 16:50 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-04  9:12 [PATCH v1 edk2-platforms 0/8] Platform/ARM/Sgi: Add support for virtio network device Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 1/8] Platform/ARM/SgiPkg: Restructure virtio device registration Vijayenthiran Subramaniam
2018-12-04 14:46   ` Ard Biesheuvel
2018-12-05  6:10     ` Vijayenthiran Subramaniam
2018-12-06 17:17       ` Ard Biesheuvel
2018-12-07  5:49         ` Vijayenthiran Subramaniam
2018-12-11  9:07           ` Vijayenthiran Subramaniam
2018-12-14 14:55             ` Ard Biesheuvel
2018-12-14 16:50               ` Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 2/8] Platform/ARM/SgiPkg: Add support for virtio net device Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 3/8] Sgi575: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 4/8] Sgi575: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 5/8] SgiClark.Ares: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 6/8] SgiClark.Ares: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 7/8] SgiClark.Helios: AcpiTables: Use PCDs for virtio disk Vijayenthiran Subramaniam
2018-12-04  9:12 ` [PATCH v1 edk2-platforms 8/8] SgiClark.Helios: AcpiTables: Add entry for virtio network device Vijayenthiran Subramaniam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox