2021-01-20 18:34:16 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, the SerenityOS developers.
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-20 18:34:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-08-19 17:26:07 +02:00
|
|
|
#include <AK/AtomicRefCounted.h>
|
2021-01-20 18:34:16 +02:00
|
|
|
#include <AK/Vector.h>
|
2021-04-24 11:30:27 +10:00
|
|
|
#include <Kernel/Devices/BlockDevice.h>
|
2021-08-06 10:45:34 +02:00
|
|
|
#include <Kernel/Memory/AnonymousVMObject.h>
|
|
|
|
#include <Kernel/Memory/MemoryManager.h>
|
2021-01-20 18:34:16 +02:00
|
|
|
#include <Kernel/PhysicalAddress.h>
|
|
|
|
|
2021-08-06 13:49:36 +02:00
|
|
|
namespace Kernel::Memory {
|
2021-01-20 18:34:16 +02:00
|
|
|
|
2021-07-11 11:41:17 -07:00
|
|
|
// A Scatter-Gather List type that owns its buffers
|
2021-04-24 11:30:27 +10:00
|
|
|
|
2022-08-19 17:26:07 +02:00
|
|
|
class ScatterGatherList final : public AtomicRefCounted<ScatterGatherList> {
|
2021-04-24 11:30:27 +10:00
|
|
|
public:
|
2022-08-24 15:56:26 +02:00
|
|
|
static LockRefPtr<ScatterGatherList> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size);
|
2022-04-01 20:58:27 +03:00
|
|
|
VMObject const& vmobject() const { return m_vm_object; }
|
2021-04-24 11:30:27 +10:00
|
|
|
VirtualAddress dma_region() const { return m_dma_region->vaddr(); }
|
|
|
|
size_t scatters_count() const { return m_vm_object->physical_pages().size(); }
|
|
|
|
|
|
|
|
private:
|
2022-08-19 20:53:40 +02:00
|
|
|
ScatterGatherList(NonnullLockRefPtr<AnonymousVMObject>, AsyncBlockDeviceRequest&, size_t device_block_size);
|
|
|
|
NonnullLockRefPtr<AnonymousVMObject> m_vm_object;
|
2021-04-24 11:30:27 +10:00
|
|
|
OwnPtr<Region> m_dma_region;
|
|
|
|
};
|
|
|
|
|
2021-01-20 18:34:16 +02:00
|
|
|
}
|