1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:37:43 +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

@ -64,15 +64,15 @@ void VirtIOQueue::disable_interrupts()
m_driver->flags = 1;
}
bool VirtIOQueue::supply_buffer(const u8* buffer, u32 len, BufferType buffer_type)
bool VirtIOQueue::supply_buffer(Badge<VirtIODevice>, const u8* buffer, u32 length, BufferType buffer_type)
{
VERIFY(buffer && len > 0);
VERIFY(buffer && length > 0);
VERIFY(m_free_buffers > 0);
auto descriptor_index = m_free_head;
m_descriptors[descriptor_index].flags = static_cast<u16>(buffer_type);
m_descriptors[descriptor_index].address = reinterpret_cast<u64>(buffer);
m_descriptors[descriptor_index].length = len;
m_descriptors[descriptor_index].length = length;
m_free_buffers--;
m_free_head = (m_free_head + 1) % m_queue_size;