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