https://git.reactos.org/?p=reactos.git;a=commitdiff;h=823fdb19d75b29352b162…
commit 823fdb19d75b29352b1621e16f5c955153d90ed3
Author: Adam Słaboń <asaillen(a)protonmail.com>
AuthorDate: Wed Jan 17 02:55:35 2024 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jan 16 17:55:35 2024 -0800
[SDK][VIRTIO][NETKVM] Make VirtIO a separate library (#6280)
* [SDK][VIRTIO][NETKVM] Make VirtIO a separate library
This is to avoid code duplication when more VirtIO drivers are brought in. This will
also be used on development of a VirtIO XDDM GPU Driver.
* [VIRTIO] Sync with upstream
---
drivers/network/dd/netkvm/CMakeLists.txt | 10 +++-------
media/doc/3rd Party Files.txt | 8 +++++++-
sdk/lib/drivers/CMakeLists.txt | 1 +
sdk/lib/drivers/virtio/CMakeLists.txt | 17 +++++++++++++++++
.../dd/netkvm => sdk/lib/drivers}/virtio/LICENSE | 0
.../dd/netkvm => sdk/lib/drivers}/virtio/VirtIO.h | 0
.../netkvm => sdk/lib/drivers}/virtio/VirtIOPCICommon.c | 0
.../netkvm => sdk/lib/drivers}/virtio/VirtIOPCILegacy.c | 0
.../netkvm => sdk/lib/drivers}/virtio/VirtIOPCIModern.c | 5 +++++
.../lib/drivers}/virtio/VirtIORing-Packed.c | 0
.../dd/netkvm => sdk/lib/drivers}/virtio/VirtIORing.c | 0
.../dd/netkvm => sdk/lib/drivers}/virtio/kdebugprint.h | 0
.../dd/netkvm => sdk/lib/drivers}/virtio/linux/types.h | 0
.../lib/drivers}/virtio/linux/virtio_config.h | 0
.../lib/drivers}/virtio/linux/virtio_types.h | 0
.../dd/netkvm => sdk/lib/drivers}/virtio/osdep.h | 2 ++
.../dd/netkvm => sdk/lib/drivers}/virtio/virtio_pci.h | 0
.../lib/drivers}/virtio/virtio_pci_common.h | 0
.../dd/netkvm => sdk/lib/drivers}/virtio/virtio_ring.h | 0
.../drivers}/virtio/windows/virtio_ring_allocation.h | 0
20 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/network/dd/netkvm/CMakeLists.txt
b/drivers/network/dd/netkvm/CMakeLists.txt
index 26ff48a184b..7aa1ca6d146 100644
--- a/drivers/network/dd/netkvm/CMakeLists.txt
+++ b/drivers/network/dd/netkvm/CMakeLists.txt
@@ -1,5 +1,6 @@
-include_directories(BEFORE Common virtio)
+include_directories(BEFORE Common
+ ${REACTOS_SOURCE_DIR}/sdk/lib/drivers/virtio)
add_definitions(
-DNDIS_MINIPORT_DRIVER
@@ -11,16 +12,12 @@ list(APPEND SOURCE
Common/ParaNdis-VirtIO.c
Common/ParaNdis-Debug.c
Common/sw-offload.c
- virtio/VirtIOPCICommon.c
- virtio/VirtIOPCILegacy.c
- virtio/VirtIOPCIModern.c
- virtio/VirtIORing.c
- virtio/VirtIORing-Packed.c
wxp/ParaNdis5-Driver.c
wxp/ParaNdis5-Impl.c
wxp/ParaNdis5-Oid.c)
add_library(netkvm MODULE ${SOURCE} wxp/parandis.rc)
+target_link_libraries(netkvm virtio)
set_module_type(netkvm kernelmodedriver)
add_importlibs(netkvm ndis ntoskrnl hal)
add_cd_file(TARGET netkvm DESTINATION reactos/system32/drivers FOR all)
@@ -29,7 +26,6 @@ add_driver_inf(netkvm netkvm.inf)
if(NOT MSVC)
target_compile_options(netkvm PRIVATE
-Wno-unused-function
- -Wno-unknown-pragmas
-Wno-pointer-sign
-Wno-pointer-to-int-cast
-Wno-int-to-pointer-cast
diff --git a/media/doc/3rd Party Files.txt b/media/doc/3rd Party Files.txt
index b39199a5cd6..83175a78dd9 100644
--- a/media/doc/3rd Party Files.txt
+++ b/media/doc/3rd Party Files.txt
@@ -74,6 +74,12 @@ Used Version: 20221020
License: GPL-2.0 (
https://spdx.org/licenses/GPL-2.0.html)
URL:
https://acpica.org/
+Title: VirtIO Windows guest driver library
+Path: sdk/lib/drivers/virtio
+Used Version: git commit 4c4d181
+License: BSD-3-Clause (
https://spdx.org/licenses/BSD-3-Clause.html)
+URL:
https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/VirtIO
+
Title: WinBtrfs
Path: dll/shellext/shellbtrfs
Path: drivers/filesystems/btrfs
@@ -115,7 +121,7 @@ Title: VirtIO NetKVM Windows guest driver
Path: drivers/network/dd/netkvm
Used Version: git commit 5e01b36
License: BSD-3-Clause (
https://spdx.org/licenses/BSD-3-Clause.html)
-URL:
https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/NetKVM/…
+URL:
https://github.com/virtio-win/kvm-guest-drivers-windows/tree/03ca1696b9474d…
Title: Microsoft CDROM Storage Class Driver
Path: drivers/storage/class/cdrom
diff --git a/sdk/lib/drivers/CMakeLists.txt b/sdk/lib/drivers/CMakeLists.txt
index 2dd4251706e..4e43c7f8bec 100644
--- a/sdk/lib/drivers/CMakeLists.txt
+++ b/sdk/lib/drivers/CMakeLists.txt
@@ -9,4 +9,5 @@ add_subdirectory(rdbsslib)
add_subdirectory(rtlver)
add_subdirectory(rxce)
add_subdirectory(sound)
+add_subdirectory(virtio)
add_subdirectory(wdf)
diff --git a/sdk/lib/drivers/virtio/CMakeLists.txt
b/sdk/lib/drivers/virtio/CMakeLists.txt
new file mode 100644
index 00000000000..c7cffcc09a7
--- /dev/null
+++ b/sdk/lib/drivers/virtio/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+list(APPEND SOURCE
+ VirtIOPCICommon.c
+ VirtIOPCILegacy.c
+ VirtIOPCIModern.c
+ VirtIORing.c
+ VirtIORing-Packed.c)
+
+add_library(virtio ${SOURCE})
+add_dependencies(virtio xdk)
+
+if(NOT MSVC)
+ target_compile_options(virtio PRIVATE
+ -Wno-unused-function
+ -Wno-unknown-pragmas
+ -Wno-attributes)
+endif()
diff --git a/drivers/network/dd/netkvm/virtio/LICENSE b/sdk/lib/drivers/virtio/LICENSE
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/LICENSE
rename to sdk/lib/drivers/virtio/LICENSE
diff --git a/drivers/network/dd/netkvm/virtio/VirtIO.h b/sdk/lib/drivers/virtio/VirtIO.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/VirtIO.h
rename to sdk/lib/drivers/virtio/VirtIO.h
diff --git a/drivers/network/dd/netkvm/virtio/VirtIOPCICommon.c
b/sdk/lib/drivers/virtio/VirtIOPCICommon.c
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/VirtIOPCICommon.c
rename to sdk/lib/drivers/virtio/VirtIOPCICommon.c
diff --git a/drivers/network/dd/netkvm/virtio/VirtIOPCILegacy.c
b/sdk/lib/drivers/virtio/VirtIOPCILegacy.c
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/VirtIOPCILegacy.c
rename to sdk/lib/drivers/virtio/VirtIOPCILegacy.c
diff --git a/drivers/network/dd/netkvm/virtio/VirtIOPCIModern.c
b/sdk/lib/drivers/virtio/VirtIOPCIModern.c
similarity index 98%
rename from drivers/network/dd/netkvm/virtio/VirtIOPCIModern.c
rename to sdk/lib/drivers/virtio/VirtIOPCIModern.c
index 8a44a2b3465..7d303069d90 100644
--- a/drivers/network/dd/netkvm/virtio/VirtIOPCIModern.c
+++ b/sdk/lib/drivers/virtio/VirtIOPCIModern.c
@@ -184,6 +184,11 @@ static void vio_modern_reset(VirtIODevice *vdev)
* including MSI-X interrupts, if any.
*/
while (ioread8(vdev, &vdev->common->device_status)) {
+ u16 val;
+ if (pci_read_config_word(vdev, 0, &val) || val == 0xffff) {
+ DPrintf(0, "PCI config space is not readable, probably the device is
removed\n", 0);
+ break;
+ }
vdev_sleep(vdev, 1);
}
}
diff --git a/drivers/network/dd/netkvm/virtio/VirtIORing-Packed.c
b/sdk/lib/drivers/virtio/VirtIORing-Packed.c
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/VirtIORing-Packed.c
rename to sdk/lib/drivers/virtio/VirtIORing-Packed.c
diff --git a/drivers/network/dd/netkvm/virtio/VirtIORing.c
b/sdk/lib/drivers/virtio/VirtIORing.c
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/VirtIORing.c
rename to sdk/lib/drivers/virtio/VirtIORing.c
diff --git a/drivers/network/dd/netkvm/virtio/kdebugprint.h
b/sdk/lib/drivers/virtio/kdebugprint.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/kdebugprint.h
rename to sdk/lib/drivers/virtio/kdebugprint.h
diff --git a/drivers/network/dd/netkvm/virtio/linux/types.h
b/sdk/lib/drivers/virtio/linux/types.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/linux/types.h
rename to sdk/lib/drivers/virtio/linux/types.h
diff --git a/drivers/network/dd/netkvm/virtio/linux/virtio_config.h
b/sdk/lib/drivers/virtio/linux/virtio_config.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/linux/virtio_config.h
rename to sdk/lib/drivers/virtio/linux/virtio_config.h
diff --git a/drivers/network/dd/netkvm/virtio/linux/virtio_types.h
b/sdk/lib/drivers/virtio/linux/virtio_types.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/linux/virtio_types.h
rename to sdk/lib/drivers/virtio/linux/virtio_types.h
diff --git a/drivers/network/dd/netkvm/virtio/osdep.h b/sdk/lib/drivers/virtio/osdep.h
similarity index 96%
rename from drivers/network/dd/netkvm/virtio/osdep.h
rename to sdk/lib/drivers/virtio/osdep.h
index b1c98145060..36a929294f4 100644
--- a/drivers/network/dd/netkvm/virtio/osdep.h
+++ b/sdk/lib/drivers/virtio/osdep.h
@@ -24,8 +24,10 @@
#endif
#ifndef __REACTOS__
+#if !defined(ENOSPC)
#define ENOSPC 1
#endif
+#endif
#if !defined(__cplusplus) && !defined(bool)
// Important note: in MSFT C++ bool length is 1 bytes
diff --git a/drivers/network/dd/netkvm/virtio/virtio_pci.h
b/sdk/lib/drivers/virtio/virtio_pci.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/virtio_pci.h
rename to sdk/lib/drivers/virtio/virtio_pci.h
diff --git a/drivers/network/dd/netkvm/virtio/virtio_pci_common.h
b/sdk/lib/drivers/virtio/virtio_pci_common.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/virtio_pci_common.h
rename to sdk/lib/drivers/virtio/virtio_pci_common.h
diff --git a/drivers/network/dd/netkvm/virtio/virtio_ring.h
b/sdk/lib/drivers/virtio/virtio_ring.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/virtio_ring.h
rename to sdk/lib/drivers/virtio/virtio_ring.h
diff --git a/drivers/network/dd/netkvm/virtio/windows/virtio_ring_allocation.h
b/sdk/lib/drivers/virtio/windows/virtio_ring_allocation.h
similarity index 100%
rename from drivers/network/dd/netkvm/virtio/windows/virtio_ring_allocation.h
rename to sdk/lib/drivers/virtio/windows/virtio_ring_allocation.h