diff options
author | Pankaj Raghav <pankydev8@gmail.com> | 2022-01-08 22:04:09 +0530 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-09 00:45:38 +0100 |
commit | 59da9bd0bdf249108cb9628cb417a117c14f7e71 (patch) | |
tree | b5f4f11a3f3352dda89e1e026cb588e91c4e82f9 | |
parent | e79f94f9980351626f13d709a536390a4be701e2 (diff) | |
download | serenity-59da9bd0bdf249108cb9628cb417a117c14f7e71.zip |
Kernel: Overload DMA helper without Physical Page output parameter
Not all drivers need the PhysicalPage output parameter while creating
a DMA buffer. This overload will avoid creating a temporary variable
for the caller
-rw-r--r-- | Kernel/Memory/MemoryManager.cpp | 15 | ||||
-rw-r--r-- | Kernel/Memory/MemoryManager.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index b044b991b5..4719f1fc6e 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -753,6 +753,13 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_page(S return region_or_error; } +ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_page(StringView name, Memory::Region::Access access) +{ + RefPtr<Memory::PhysicalPage> dma_buffer_page; + + return allocate_dma_buffer_page(name, access, dma_buffer_page); +} + ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector<Memory::PhysicalPage>& dma_buffer_pages) { VERIFY(!(size % PAGE_SIZE)); @@ -764,6 +771,14 @@ ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages( return region_or_error; } +ErrorOr<NonnullOwnPtr<Memory::Region>> MemoryManager::allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access) +{ + VERIFY(!(size % PAGE_SIZE)); + NonnullRefPtrVector<Memory::PhysicalPage> dma_buffer_pages; + + return allocate_dma_buffer_pages(size, name, access, dma_buffer_pages); +} + ErrorOr<NonnullOwnPtr<Region>> MemoryManager::allocate_kernel_region(size_t size, StringView name, Region::Access access, AllocationStrategy strategy, Region::Cacheable cacheable) { VERIFY(!(size % PAGE_SIZE)); diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h index fb0892d833..8c53855de9 100644 --- a/Kernel/Memory/MemoryManager.h +++ b/Kernel/Memory/MemoryManager.h @@ -176,7 +176,9 @@ public: ErrorOr<NonnullOwnPtr<Region>> allocate_contiguous_kernel_region(size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes); ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_page(StringView name, Memory::Region::Access access, RefPtr<Memory::PhysicalPage>& dma_buffer_page); + ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_page(StringView name, Memory::Region::Access access); ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access, NonnullRefPtrVector<Memory::PhysicalPage>& dma_buffer_pages); + ErrorOr<NonnullOwnPtr<Memory::Region>> allocate_dma_buffer_pages(size_t size, StringView name, Memory::Region::Access access); ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(size_t, StringView name, Region::Access access, AllocationStrategy strategy = AllocationStrategy::Reserve, Region::Cacheable = Region::Cacheable::Yes); ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region(PhysicalAddress, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes); ErrorOr<NonnullOwnPtr<Region>> allocate_kernel_region_with_vmobject(VMObject&, size_t, StringView name, Region::Access access, Region::Cacheable = Region::Cacheable::Yes); |