Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel/HID: Add support for virtio input devices (+ use them for RISC-V in run.py) #24254

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Kernel/Bus/PCI/IDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum DeviceID {
VirtIOConsole = 0x1003,
VirtIOEntropy = 0x1005,
VirtIOGPU = 0x1050,
VirtIOInput = 0x1052,
};

}
6 changes: 6 additions & 0 deletions Kernel/Bus/VirtIO/Transport/PCIe/Detect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <Kernel/Bus/PCI/IDs.h>
#include <Kernel/Bus/VirtIO/Device.h>
#include <Kernel/Bus/VirtIO/Transport/PCIe/Detect.h>
#include <Kernel/Devices/HID/VirtIO/Input.h>
#include <Kernel/Devices/Serial/VirtIO/Console.h>
#include <Kernel/Sections.h>
#include <Kernel/Security/Random/VirtIO/RNG.h>
Expand Down Expand Up @@ -46,6 +47,11 @@ UNMAP_AFTER_INIT void detect_pci_instances()
// This should have been initialized by the storage subsystem
break;
}
case PCI::DeviceID::VirtIOInput: {
auto& input = Input::must_create_for_pci_instance(device_identifier).leak_ref();
ADKaster marked this conversation as resolved.
Show resolved Hide resolved
MUST(input.initialize_virtio_resources());
break;
}
default:
dbgln_if(VIRTIO_DEBUG, "VirtIO: Unknown VirtIO device with ID: {}", device_identifier.hardware_id().device_id);
break;
Expand Down
6 changes: 5 additions & 1 deletion Kernel/Bus/VirtIO/Transport/PCIe/TransportLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ StringView PCIeTransportLink::determine_device_class_name() const
return "VirtIOConsole"sv;
case 4:
return "VirtIORNG"sv;
case 18:
return "VirtIOInput"sv;
default:
dbgln("VirtIO: Unknown subsystem_device_id {}", subsystem_device_id);
VERIFY_NOT_REACHED();
Expand All @@ -50,8 +52,10 @@ StringView PCIeTransportLink::determine_device_class_name() const
return "VirtIORNG"sv;
case PCI::DeviceID::VirtIOGPU:
return "VirtIOGPU"sv;
case PCI::DeviceID::VirtIOInput:
return "VirtIOInput"sv;
default:
dbgln("VirtIO: Unknown device_id {}", id.vendor_id);
dbgln("VirtIO: Unknown device_id {:#x}", id.device_id);
VERIFY_NOT_REACHED();
}
}
Expand Down
1 change: 1 addition & 0 deletions Kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ set(KERNEL_SOURCES
Devices/HID/PS2/KeyboardDevice.cpp
Devices/HID/PS2/MouseDevice.cpp
Devices/HID/USB/MouseDevice.cpp
Devices/HID/VirtIO/Input.cpp
Devices/Generic/ConsoleDevice.cpp
Devices/Generic/DeviceControlDevice.cpp
Devices/Generic/FullDevice.cpp
Expand Down