]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmFvpDxe: Added Virtio Block support
authorOlivier Martin <olivier.martin@arm.com>
Fri, 13 Dec 2013 12:05:01 +0000 (12:05 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 13 Dec 2013 12:05:01 +0000 (12:05 +0000)
Right now the ARM Platform driver does not do much, but
I expect to move most platform specific code into platform
specific driver in the future.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
v5:
- ensure / document that the VIRTIO_BLK_DEVICE_PATH structure must be
  packed
- fix whitespace damage in definition of "mVirtioBlockDevicePath"
- the platform driver is added to all platform DSC and FDF files in the
  previous patch; this patch focuses on virtio only

Change-Id: I3505bfc5b31085b8017bd9e6895a155bd7a2eee9
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14981 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.c
ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.dsc
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-FVP-AArch64.fdf
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.dsc
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4-foundation.fdf
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.dsc
ArmPlatformPkg/ArmVExpressPkg/ArmVExpress-RTSM-AEMv8Ax4.fdf

index 527a5b6731b18ccfb7c3727316b5902dd68972c4..15b5f429a9cee3858de541ad1bb30cfe1f058673 100644 (file)
 **/
 
 #include <Library/UefiLib.h>
+#include <Library/VirtioMmioDeviceLib.h>
+#include <Library/DebugLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#define ARM_FVP_BASE_VIRTIO_BLOCK_BASE    0x1c130000
+
+#pragma pack(1)
+typedef struct {
+  VENDOR_DEVICE_PATH                  Vendor;
+  EFI_DEVICE_PATH_PROTOCOL            End;
+} VIRTIO_BLK_DEVICE_PATH;
+#pragma pack()
+
+VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath =
+{
+  {
+    {
+      HARDWARE_DEVICE_PATH,
+      HW_VENDOR_DP,
+      {
+        (UINT8)( sizeof(VENDOR_DEVICE_PATH) ),
+        (UINT8)((sizeof(VENDOR_DEVICE_PATH)) >> 8)
+      }
+    },
+    EFI_CALLER_ID_GUID,
+  },
+  {
+    END_DEVICE_PATH_TYPE,
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,
+    {
+      sizeof (EFI_DEVICE_PATH_PROTOCOL),
+      0
+    }
+  }
+};
 
 EFI_STATUS
 EFIAPI
@@ -21,6 +56,20 @@ ArmFvpInitialise (
   IN EFI_SYSTEM_TABLE   *SystemTable
   )
 {
+  EFI_STATUS              Status;
+
+  Status = gBS->InstallProtocolInterface (&ImageHandle,
+                 &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE,
+                 &mVirtioBlockDevicePath);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  // Declare the Virtio BlockIo device
+  Status = VirtioMmioInstallDevice (ARM_FVP_BASE_VIRTIO_BLOCK_BASE, ImageHandle);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((EFI_D_ERROR, "ArmFvpDxe: Failed to install Virtio block device\n"));
+  }
 
-  return EFI_SUCCESS;
+  return Status;
 }
index e39e6b6b53fcd2fa32fd6c4227894ab346c4ec6c..893fd8d41d656bb510dd1d99ba9a5574865a8c73 100644 (file)
 [Packages]
   MdePkg/MdePkg.dec
   ArmPlatformPkg/ArmPlatformPkg.dec
+  OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
   UefiDriverEntryPoint
   UefiBootServicesTableLib
+  VirtioMmioDeviceLib
+  BaseMemoryLib
index 42d793e0fa749dbeadbf224f64be3629a61647d1..e39ce19692f2ebd802978680807c58440da20bf1 100644 (file)
 \r
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf\r
 \r
+  # Virtio Support\r
+  VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf\r
+  VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf\r
+\r
 [LibraryClasses.common.SEC]\r
   ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf\r
   ArmPlatformSecLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf\r
   ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf\r
 !endif\r
 \r
+  #\r
+  # Platform Driver\r
+  #\r
+  ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf\r
+  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
+\r
   #\r
   # FAT filesystem + GPT/MBR partitioning\r
   #\r
index 7f62c240336e0a84217fa9b13546d87d2e96b946..a74878ba2bda6fd6ab48c604e673412af11a8b7f 100644 (file)
@@ -176,6 +176,12 @@ READ_LOCK_STATUS   = TRUE
   INF ArmPlatformPkg/Drivers/PL180MciDxe/PL180MciDxe.inf\r
 !endif\r
 \r
+  #\r
+  # Platform Driver\r
+  #\r
+  INF ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf\r
+  INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf\r
+
   #\r
   # UEFI application (Shell Embedded Boot Loader)\r
   #\r
index 99a8d16a9cff766d981a23fe8cd1a425d9d34427..2942b99acf7c8ffd405e78fbc34b584e8e245d10 100644 (file)
   ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexAEMv8Lib/ArmCortexAEMv8Lib.inf\r
   ArmPlatformLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibRTSM/ArmVExpressFoundationLib.inf\r
 \r
+  # Virtio Support
+  VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
+  VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
+
   ArmPlatformSysConfigLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSysConfigLib/ArmVExpressSysConfigLib.inf\r
 \r
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf\r
   # Platform Driver
   #
   ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning\r
index a4b5226d28aca53ff514e1c0454f27108c3fdede..bfb6cdf3d1a272bc82880842b9f956c9d19ab171 100644 (file)
@@ -158,6 +158,7 @@ READ_LOCK_STATUS   = TRUE
   # Platform Driver
   #
   INF ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+  INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
 
   #
   # UEFI application (Shell Embedded Boot Loader)\r
index d9d28f7286b9f82f27dd5b583f253652d2e30421..5d22f1d9bf3c67fa0428016840f011082244b787 100644 (file)
 \r
   TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf\r
 \r
+  # VirtIo Support
+  VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
+  VirtioMmioDeviceLib|OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDeviceLib.inf
+
 [LibraryClasses.common.SEC]\r
   ArmLib|ArmPkg/Library/ArmLib/AArch64/AArch64LibSec.inf\r
   ArmPlatformSecLib|ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressSecLibRTSM/ArmVExpressSecLib.inf\r
   # Platform Driver
   #
   ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning\r
index 5197cd93e82b4a55f4d6bc315e306a6b9c2e788d..5e34115cb556e59196628f22f567775b7ce30d8c 100644 (file)
@@ -168,6 +168,7 @@ READ_LOCK_STATUS   = TRUE
   # Platform Driver
   #
   INF ArmPlatformPkg/ArmVExpressPkg/ArmFvpDxe/ArmFvpDxe.inf
+  INF OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
 
   #\r
   # UEFI application (Shell Embedded Boot Loader)\r