ScatterGatherList.h 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Vector.h>
  8. #include <Kernel/Devices/BlockDevice.h>
  9. #include <Kernel/Memory/AnonymousVMObject.h>
  10. #include <Kernel/Memory/MemoryManager.h>
  11. #include <Kernel/PhysicalAddress.h>
  12. namespace Kernel::Memory {
  13. // A Scatter-Gather List type that owns its buffers
  14. class ScatterGatherList : public RefCounted<ScatterGatherList> {
  15. public:
  16. static RefPtr<ScatterGatherList> try_create(AsyncBlockDeviceRequest&, Span<NonnullRefPtr<PhysicalPage>> allocated_pages, size_t device_block_size);
  17. const VMObject& vmobject() const { return m_vm_object; }
  18. VirtualAddress dma_region() const { return m_dma_region->vaddr(); }
  19. size_t scatters_count() const { return m_vm_object->physical_pages().size(); }
  20. private:
  21. ScatterGatherList(NonnullRefPtr<AnonymousVMObject>, AsyncBlockDeviceRequest&, size_t device_block_size);
  22. NonnullRefPtr<AnonymousVMObject> m_vm_object;
  23. OwnPtr<Region> m_dma_region;
  24. };
  25. }