mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 03:25:06 +00:00

Currently, when passing buffers into VirtIOQueues, we use scatter-gather lists, which contain an internal vector of buffers. This vector is allocated, filled and the destroy whenever we try to provide buffers into a virtqueue, which would happen a lot in performance cricital code (the main transport mechanism for certain paravirtualized devices). This commit moves it over to using VirtIOQueueChains and building the chain in place in the VirtIOQueue. Also included are a bunch of fixups for the VirtIO Console device, making it use an internal VM::RingBuffer instead.
32 lines
1 KiB
C++
32 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Vector.h>
|
|
#include <Kernel/Devices/BlockDevice.h>
|
|
#include <Kernel/PhysicalAddress.h>
|
|
#include <Kernel/VM/AnonymousVMObject.h>
|
|
#include <Kernel/VM/MemoryManager.h>
|
|
|
|
namespace Kernel {
|
|
|
|
/// A Scatter-Gather List type that owns its buffers
|
|
|
|
class ScatterGatherList : public RefCounted<ScatterGatherList> {
|
|
public:
|
|
static NonnullRefPtr<ScatterGatherList> create(AsyncBlockDeviceRequest&, NonnullRefPtrVector<PhysicalPage> allocated_pages, size_t device_block_size);
|
|
const VMObject& vmobject() const { return m_vm_object; }
|
|
VirtualAddress dma_region() const { return m_dma_region->vaddr(); }
|
|
size_t scatters_count() const { return m_vm_object->physical_pages().size(); }
|
|
|
|
private:
|
|
ScatterGatherList(AsyncBlockDeviceRequest&, NonnullRefPtrVector<PhysicalPage> allocated_pages, size_t device_block_size);
|
|
NonnullRefPtr<AnonymousVMObject> m_vm_object;
|
|
OwnPtr<Region> m_dma_region;
|
|
};
|
|
|
|
}
|