1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:08:12 +00:00

Kernel: Implement an asynchronous device request stack

This allows issuing asynchronous requests for devices and waiting
on the completion of the request. The requests can cascade into
multiple sub-requests.

Since IRQs may complete at any time, if the current process is no
longer the same that started the process, we need to swich the
paging context before accessing user buffers.

Change the PATA driver to use this model.
This commit is contained in:
Tom 2020-11-02 11:16:01 -07:00 committed by Andreas Kling
parent 91db31880f
commit e445ff670d
17 changed files with 814 additions and 250 deletions

View file

@ -48,6 +48,12 @@ DiskPartition::~DiskPartition()
{
}
void DiskPartition::start_request(AsyncBlockDeviceRequest& request)
{
request.add_sub_request(m_device->make_request<AsyncBlockDeviceRequest>(request.request_type(),
request.block_index() + m_block_offset, request.block_count(), request.buffer(), request.buffer_size()));
}
KResultOr<size_t> DiskPartition::read(FileDescription& fd, size_t offset, UserOrKernelBuffer& outbuf, size_t len)
{
unsigned adjust = m_block_offset * block_size();
@ -92,24 +98,6 @@ bool DiskPartition::can_write(const FileDescription& fd, size_t offset) const
return m_device->can_write(fd, offset + adjust);
}
bool DiskPartition::read_blocks(unsigned index, u16 count, UserOrKernelBuffer& out)
{
#ifdef OFFD_DEBUG
klog() << "DiskPartition::read_blocks " << index << " (really: " << (m_block_offset + index) << ") count=" << count;
#endif
return m_device->read_blocks(m_block_offset + index, count, out);
}
bool DiskPartition::write_blocks(unsigned index, u16 count, const UserOrKernelBuffer& data)
{
#ifdef OFFD_DEBUG
klog() << "DiskPartition::write_blocks " << index << " (really: " << (m_block_offset + index) << ") count=" << count;
#endif
return m_device->write_blocks(m_block_offset + index, count, data);
}
const char* DiskPartition::class_name() const
{
return "DiskPartition";