1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00

Kernel: Register Virtio console ports with device management

Previously, Virtio console ports would not show up in `/sys/dev/char/`.
Also adds support to `SystemServer` to create more than one console
port device in `/dev/` in the multiport case.
This commit is contained in:
Jelle Raaijmakers 2021-11-29 16:03:38 +01:00 committed by Andreas Kling
parent 2565f458d1
commit e187207610
2 changed files with 7 additions and 13 deletions

View file

@ -6,6 +6,7 @@
*/
#include <Kernel/Bus/VirtIO/Console.h>
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/Sections.h>
#include <Kernel/WorkQueue.h>
@ -50,10 +51,10 @@ UNMAP_AFTER_INIT void Console::initialize()
if (success) {
finish_init();
if (is_feature_accepted(VIRTIO_CONSOLE_F_MULTIPORT))
if (is_feature_accepted(VIRTIO_CONSOLE_F_MULTIPORT)) {
setup_multiport();
else {
auto port = make_ref_counted<VirtIO::ConsolePort>(0u, *this);
} else {
auto port = MUST(DeviceManagement::the().try_create_device<VirtIO::ConsolePort>(0u, *this));
port->init_receive_buffer({});
m_ports.append(port);
}
@ -160,13 +161,13 @@ void Console::process_control_message(ControlMessage message)
return;
}
m_ports.at(id) = make_ref_counted<VirtIO::ConsolePort>(id, *this);
m_ports.at(id) = MUST(DeviceManagement::the().try_create_device<VirtIO::ConsolePort>(id, *this));
ControlMessage ready_event {
.id = static_cast<u32>(id),
.event = (u16)ControlEvent::PortReady,
.value = (u16)ControlMessage::Status::Success
};
write_control_message(ready_event);
});