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-08-06 11:45:34 +03:00
|
|
|
#include <Kernel/Memory/AnonymousVMObject.h>
|
|
|
|
#include <Kernel/Memory/MemoryManager.h>
|
2021-01-20 19:34:16 +03:00
|
|
|
#include <Kernel/PhysicalAddress.h>
|
|
|
|
|
2021-08-06 14:49:36 +03:00
|
|
|
namespace Kernel::Memory {
|
2021-01-20 19:34:16 +03:00
|
|
|
|
2021-07-11 21:41:17 +03:00
|
|
|
// A Scatter-Gather List type that owns its buffers
|
2021-04-24 04:30:27 +03:00
|
|
|
|
|
|
|
class ScatterGatherList : public RefCounted<ScatterGatherList> {
|
|
|
|
public:
|
2021-07-22 10:03:13 +03:00
|
|
|
static RefPtr<ScatterGatherList> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<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
|
|
|
}
|