diff options
Diffstat (limited to 'Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c')
-rw-r--r-- | Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c | 54 |
1 files changed, 54 insertions, 0 deletions
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__));
+ }
+ }
+ }
}
|