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

Kernel: Implement a naive version of virtconsole by memcpying to physical page

This patch allocates a physical page for each of the virtqueues and
memcpys to it when receiving a buffer to get a physical, aligned
contiguous buffer as required by the virtio specification.

Co-authored-by: Sahan <sahan.h.fernando@gmail.com>
This commit is contained in:
Idan Horowitz 2021-04-15 19:22:02 +10:00 committed by Andreas Kling
parent 42b1eb5af1
commit ecfa7cb824
8 changed files with 35 additions and 18 deletions

View file

@ -217,6 +217,10 @@ bool VirtIODevice::accept_device_features(u64 device_features, u64 accepted_feat
accepted_features &= ~(VIRTIO_F_RING_PACKED);
}
if (is_feature_set(device_features, VIRTIO_F_IN_ORDER)) {
accepted_features |= VIRTIO_F_IN_ORDER;
}
dbgln_if(VIRTIO_DEBUG, "{}: Device features: {}", m_class_name, device_features);
dbgln_if(VIRTIO_DEBUG, "{}: Accepted features: {}", m_class_name, accepted_features);
@ -342,7 +346,7 @@ bool VirtIODevice::finish_init()
void VirtIODevice::supply_buffer_and_notify(u16 queue_index, const u8* buffer, u32 len, BufferType buffer_type)
{
VERIFY(queue_index < m_queue_count);
if (get_queue(queue_index).supply_buffer(buffer, len, buffer_type))
if (get_queue(queue_index).supply_buffer({}, buffer, len, buffer_type))
notify_queue(queue_index);
}
@ -356,7 +360,6 @@ u8 VirtIODevice::isr_status()
void VirtIODevice::handle_irq(const RegisterState&)
{
u8 isr_type = isr_status();
dbgln_if(VIRTIO_DEBUG, "{}: Handling interrupt with status: {}", m_class_name, isr_type);
if (isr_type & DEVICE_CONFIG_INTERRUPT) {
if (!handle_device_config_change()) {
set_status_bit(DEVICE_STATUS_FAILED);
@ -369,6 +372,8 @@ void VirtIODevice::handle_irq(const RegisterState&)
return;
}
}
if (isr_type & ~(QUEUE_INTERRUPT | DEVICE_CONFIG_INTERRUPT))
dbgln("{}: Handling interrupt with unknown type: {}", m_class_name, isr_type);
}
}