mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:37:46 +00:00
Kernel: Move AHCIPort::ScatterList to VM::ScatterGatherList
We want to move this out of the AHCI subsystem into the VM system, since other parts of the kernel may need to perform scatter-gather IO. We rename the current VM::ScatterGatherList impl that's used in the virtio subsystem to VM::ScatterGatherRefList, since its distinguishing feature from the AHCI scatter-gather list is that it doesn't own its buffers.
This commit is contained in:
parent
b63b15eeb5
commit
8131c0de8c
11 changed files with 53 additions and 46 deletions
|
@ -335,7 +335,7 @@ void VirtIODevice::finish_init()
|
|||
dbgln_if(VIRTIO_DEBUG, "{}: Finished initialization", m_class_name);
|
||||
}
|
||||
|
||||
void VirtIODevice::supply_buffer_and_notify(u16 queue_index, const ScatterGatherList& scatter_list, BufferType buffer_type, void* token)
|
||||
void VirtIODevice::supply_buffer_and_notify(u16 queue_index, const ScatterGatherRefList& scatter_list, BufferType buffer_type, void* token)
|
||||
{
|
||||
VERIFY(queue_index < m_queue_count);
|
||||
if (get_queue(queue_index).supply_buffer({}, scatter_list, buffer_type, token))
|
||||
|
|
|
@ -196,7 +196,7 @@ protected:
|
|||
return is_feature_set(m_accepted_features, feature);
|
||||
}
|
||||
|
||||
void supply_buffer_and_notify(u16 queue_index, const ScatterGatherList&, BufferType, void* token);
|
||||
void supply_buffer_and_notify(u16 queue_index, const ScatterGatherRefList&, BufferType, void* token);
|
||||
|
||||
virtual bool handle_device_config_change() = 0;
|
||||
virtual void handle_queue_update(u16 queue_index) = 0;
|
||||
|
|
|
@ -43,7 +43,7 @@ VirtIOConsole::VirtIOConsole(PCI::Address address)
|
|||
finish_init();
|
||||
m_receive_region = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIOConsole Receive", Region::Access::Read | Region::Access::Write);
|
||||
if (m_receive_region) {
|
||||
supply_buffer_and_notify(RECEIVEQ, ScatterGatherList::create_from_physical(m_receive_region->physical_page(0)->paddr(), m_receive_region->size()), BufferType::DeviceWritable, m_receive_region->vaddr().as_ptr());
|
||||
supply_buffer_and_notify(RECEIVEQ, ScatterGatherRefList::create_from_physical(m_receive_region->physical_page(0)->paddr(), m_receive_region->size()), BufferType::DeviceWritable, m_receive_region->vaddr().as_ptr());
|
||||
}
|
||||
m_transmit_region = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIOConsole Transmit", Region::Access::Read | Region::Access::Write);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ KResultOr<size_t> VirtIOConsole::write(FileDescription&, u64, const UserOrKernel
|
|||
if (!size)
|
||||
return 0;
|
||||
|
||||
auto scatter_list = ScatterGatherList::create_from_buffer(static_cast<const u8*>(data.user_or_kernel_ptr()), size);
|
||||
auto scatter_list = ScatterGatherRefList::create_from_buffer(static_cast<const u8*>(data.user_or_kernel_ptr()), size);
|
||||
supply_buffer_and_notify(TRANSMITQ, scatter_list, BufferType::DeviceReadable, const_cast<void*>(data.user_or_kernel_ptr()));
|
||||
|
||||
return size;
|
||||
|
|
|
@ -48,7 +48,7 @@ void VirtIOQueue::disable_interrupts()
|
|||
m_driver->flags = 1;
|
||||
}
|
||||
|
||||
bool VirtIOQueue::supply_buffer(Badge<VirtIODevice>, const ScatterGatherList& scatter_list, BufferType buffer_type, void* token)
|
||||
bool VirtIOQueue::supply_buffer(Badge<VirtIODevice>, const ScatterGatherRefList& scatter_list, BufferType buffer_type, void* token)
|
||||
{
|
||||
VERIFY(scatter_list.length() && scatter_list.length() <= m_free_buffers);
|
||||
m_free_buffers -= scatter_list.length();
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
PhysicalAddress driver_area() const { return to_physical(m_driver.ptr()); }
|
||||
PhysicalAddress device_area() const { return to_physical(m_device.ptr()); }
|
||||
|
||||
bool supply_buffer(Badge<VirtIODevice>, const ScatterGatherList&, BufferType, void* token);
|
||||
bool supply_buffer(Badge<VirtIODevice>, const ScatterGatherRefList&, BufferType, void* token);
|
||||
bool new_data_available() const;
|
||||
bool can_write() const;
|
||||
void* get_buffer(size_t*);
|
||||
|
|
|
@ -23,7 +23,7 @@ VirtIORNG::VirtIORNG(PCI::Address address)
|
|||
m_entropy_buffer = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIORNG", Region::Access::Read | Region::Access::Write);
|
||||
if (m_entropy_buffer) {
|
||||
memset(m_entropy_buffer->vaddr().as_ptr(), 0, m_entropy_buffer->size());
|
||||
supply_buffer_and_notify(REQUESTQ, ScatterGatherList::create_from_physical(m_entropy_buffer->physical_page(0)->paddr(), m_entropy_buffer->size()), BufferType::DeviceWritable, m_entropy_buffer->vaddr().as_ptr());
|
||||
supply_buffer_and_notify(REQUESTQ, ScatterGatherRefList::create_from_physical(m_entropy_buffer->physical_page(0)->paddr(), m_entropy_buffer->size()), BufferType::DeviceWritable, m_entropy_buffer->vaddr().as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue