From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Jordan Justen <jordan.l.justen@intel.com>,
Philippe Mathieu-Daude <philmd@redhat.com>
Subject: [PATCH v5 2/7] OvmfPkg/VirtioMmioDeviceLib: Add virtio 1.0 detection.
Date: Fri, 27 Aug 2021 15:44:54 +0200 [thread overview]
Message-ID: <20210827134459.635098-3-kraxel@redhat.com> (raw)
In-Reply-To: <20210827134459.635098-1-kraxel@redhat.com>
Add #defines for the Version field. Read and store the version,
log the version found as info message.
Continue to return UNSUPPORTED for now, we need some more patches
to complete virtio 1.0 support first.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
.../VirtioMmioDeviceLib/VirtioMmioDevice.h | 4 ++++
.../VirtioMmioDeviceLib/VirtioMmioDevice.c | 17 +++++++++++++----
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
index ab53b90d51c9..0c2f99633c46 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.h
@@ -23,9 +23,13 @@
#include <Library/MemoryAllocationLib.h>
#define VIRTIO_MMIO_DEVICE_SIGNATURE SIGNATURE_32 ('V', 'M', 'I', 'O')
+#define VIRTIO_MMIO_DEVICE_VERSION_0_95 1
+#define VIRTIO_MMIO_DEVICE_VERSION_1_00 2
+
typedef struct {
UINT32 Signature;
+ UINT32 Version;
VIRTIO_DEVICE_PROTOCOL VirtioDevice;
PHYSICAL_ADDRESS BaseAddress;
} VIRTIO_MMIO_DEVICE;
diff --git a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
index 6dbbba008c75..0c92f5373151 100644
--- a/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
+++ b/OvmfPkg/Library/VirtioMmioDeviceLib/VirtioMmioDevice.c
@@ -58,7 +58,6 @@ VirtioMmioInit (
)
{
UINT32 MagicValue;
- UINT32 Version;
//
// Initialize VirtIo Mmio Device
@@ -66,7 +65,6 @@ VirtioMmioInit (
CopyMem (&Device->VirtioDevice, &mMmioDeviceProtocolTemplate,
sizeof (VIRTIO_DEVICE_PROTOCOL));
Device->BaseAddress = BaseAddress;
- Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
Device->VirtioDevice.SubSystemDeviceId =
MmioRead32 (BaseAddress + VIRTIO_MMIO_OFFSET_DEVICE_ID);
@@ -78,8 +76,19 @@ VirtioMmioInit (
return EFI_UNSUPPORTED;
}
- Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION);
- if (Version != 1) {
+ Device->Version = VIRTIO_CFG_READ (Device, VIRTIO_MMIO_OFFSET_VERSION);
+ switch (Device->Version) {
+ case VIRTIO_MMIO_DEVICE_VERSION_0_95:
+ DEBUG ((DEBUG_INFO, "%a virtio 0.9.5, id %d\n", __FUNCTION__,
+ Device->VirtioDevice.SubSystemDeviceId));
+ Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (0, 9, 5);
+ break;
+ case VIRTIO_MMIO_DEVICE_VERSION_1_00:
+ DEBUG ((DEBUG_INFO, "%a virtio 1.0, id %d\n", __FUNCTION__,
+ Device->VirtioDevice.SubSystemDeviceId));
+ Device->VirtioDevice.Revision = VIRTIO_SPEC_REVISION (1, 0, 0);
+ return EFI_UNSUPPORTED;
+ default:
return EFI_UNSUPPORTED;
}
--
2.31.1
next prev parent reply other threads:[~2021-08-27 13:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-27 13:44 [PATCH v5 0/7] add support for virtio-mmio 1.0 Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 1/7] OvmfPkg/Virtio10: Add virtio-mmio 1.0 defines Gerd Hoffmann
2021-08-27 13:44 ` Gerd Hoffmann [this message]
2021-08-27 13:44 ` [PATCH v5 3/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetPageSize Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 4/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Fix SetQueueAddress Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 5/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Add default QueueNum Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 6/7] OvmfPkg/VirtioMmioDeviceLib: virtio 1.0: Adapt feature bit handling Gerd Hoffmann
2021-08-27 13:44 ` [PATCH v5 7/7] OvmfPkg/VirtioMmioDeviceLib: enable virtio 1.0 Gerd Hoffmann
2021-08-28 1:49 ` [PATCH v5 0/7] add support for virtio-mmio 1.0 Yao, Jiewen
2021-08-30 1:20 ` Yao, Jiewen
2021-08-30 1:21 ` Yao, Jiewen
2021-08-30 3:17 ` 回复: [edk2-devel] " gaoliming
2021-08-30 7:54 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210827134459.635098-3-kraxel@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox