summaryrefslogtreecommitdiff
path: root/Platform
diff options
context:
space:
mode:
authorDaniil Egranov <daniil.egranov@arm.com>2018-12-14 22:28:13 +0530
committerArd Biesheuvel <ard.biesheuvel@linaro.org>2018-12-19 17:06:55 +0100
commitaafeacfb3a22a24194a121ccc85c65eba20c3190 (patch)
tree4c6234d68152a694333d5cb1824b9317cf717d1c /Platform
parent8dab39b3ef9996579bf168789c9f816dd67cc249 (diff)
Platform/ARM/SgiPkg: Add support for virtio net device
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> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Diffstat (limited to 'Platform')
-rw-r--r--Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf3
-rw-r--r--Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c54
-rw-r--r--Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h3
-rw-r--r--Platform/ARM/SgiPkg/SgiPlatform.dec6
-rw-r--r--Platform/ARM/SgiPkg/SgiPlatform.dsc18
-rw-r--r--Platform/ARM/SgiPkg/SgiPlatform.fdf4
6 files changed, 84 insertions, 4 deletions
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
index f920f6ec..3283ff04 100644
--- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf
@@ -42,10 +42,13 @@
[FeaturePcd]
gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported
+ gArmSgiTokenSpaceGuid.PcdVirtioNetSupported
[FixedPcd]
gArmSgiTokenSpaceGuid.PcdVirtioBlkBaseAddress
gArmSgiTokenSpaceGuid.PcdVirtioBlkSize
+ gArmSgiTokenSpaceGuid.PcdVirtioNetBaseAddress
+ gArmSgiTokenSpaceGuid.PcdVirtioNetSize
[Depex]
TRUE
diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c
index 1eb4bc14..92ad704c 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.
@@ -61,6 +84,7 @@ InitVirtioDevices (
{
EFI_STATUS Status;
STATIC EFI_HANDLE mVirtIoBlkController = NULL;
+ STATIC EFI_HANDLE mVirtIoNetController = NULL;
// Install protocol interface for storage device
if ((FeaturePcdGet (PcdVirtioBlkSupported)) &&
@@ -90,4 +114,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__));
+ }
+ }
+ }
}
diff --git a/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h b/Platform/ARM/SgiPkg/Include/Guid/SgiVirtioDevicesFormSet.h
index 80d3e3ae..b7aab64d 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/SgiPlatform.dec b/Platform/ARM/SgiPkg/SgiPlatform.dec
index 9300337a..10157c7b 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dec
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dec
@@ -38,6 +38,7 @@
[PcdsFeatureFlag.common]
gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|FALSE|BOOLEAN|0x00000001
+ gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|FALSE|BOOLEAN|0x00000010
[PcdsFixedAtBuild]
gArmSgiTokenSpaceGuid.PcdDramBlock2Base|0|UINT64|0x00000002
@@ -48,5 +49,10 @@
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]
gNtFwConfigDtInfoPpiGuid = { 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 ffebddc1..7995c7d1 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.dsc
+++ b/Platform/ARM/SgiPkg/SgiPlatform.dsc
@@ -47,6 +47,7 @@
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
@@ -101,6 +102,7 @@
[PcdsFeatureFlag.common]
gArmSgiTokenSpaceGuid.PcdVirtioBlkSupported|TRUE
+ gArmSgiTokenSpaceGuid.PcdVirtioNetSupported|TRUE
[PcdsFixedAtBuild.common]
gArmTokenSpaceGuid.PcdVFPEnabled|1
@@ -182,14 +184,19 @@
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
@@ -294,8 +301,11 @@
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 9c0ec1fa..80c3412f 100644
--- a/Platform/ARM/SgiPkg/SgiPlatform.fdf
+++ b/Platform/ARM/SgiPkg/SgiPlatform.fdf
@@ -197,7 +197,11 @@ READ_LOCK_STATUS = TRUE
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