2021-01-20 19:34:16 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-20 19:34:16 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
2021-04-24 04:30:27 +03:00
|
|
|
#include <Kernel/Devices/BlockDevice.h>
|
2021-01-20 19:34:16 +03:00
|
|
|
#include <Kernel/PhysicalAddress.h>
|
2021-04-24 04:30:27 +03:00
|
|
|
#include <Kernel/VM/AnonymousVMObject.h>
|
2021-01-20 19:34:16 +03:00
|
|
|
#include <Kernel/VM/MemoryManager.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-04-24 04:30:27 +03:00
|
|
|
/// A Scatter-Gather List type that owns its buffers
|
|
|
|
|
|
|
|
class ScatterGatherList : public RefCounted<ScatterGatherList> {
|
|
|
|
public:
|
2021-05-14 15:06:29 +03:00
|
|
|
static RefPtr<ScatterGatherList> create(AsyncBlockDeviceRequest&, NonnullRefPtrVector<PhysicalPage> allocated_pages, size_t device_block_size);
|
2021-04-24 04:30:27 +03:00
|
|
|
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:
|
2021-05-14 15:06:29 +03:00
|
|
|
ScatterGatherList(NonnullRefPtr<AnonymousVMObject>, AsyncBlockDeviceRequest&, size_t device_block_size);
|
2021-04-24 04:30:27 +03:00
|
|
|
NonnullRefPtr<AnonymousVMObject> m_vm_object;
|
|
|
|
OwnPtr<Region> m_dma_region;
|
|
|
|
};
|
|
|
|
|
2021-01-20 19:34:16 +03:00
|
|
|
}
|