From 13045751903eda77421fbd71fddc89a1ddb1bb10 Mon Sep 17 00:00:00 2001 From: b14ckcat Date: Sat, 15 Oct 2022 18:30:37 -0400 Subject: [PATCH] Kernel/USB: Adjust USB Pipe buffer Allocate DMA buffer pages for use within the USBD Pipe class, and allow for the user to specify the size of this buffer, rounding up to the next page boundary. --- Kernel/Bus/USB/USBPipe.cpp | 4 ++-- Kernel/Bus/USB/USBPipe.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/Bus/USB/USBPipe.cpp b/Kernel/Bus/USB/USBPipe.cpp index b8153cfe2a..ab1cd8bb3b 100644 --- a/Kernel/Bus/USB/USBPipe.cpp +++ b/Kernel/Bus/USB/USBPipe.cpp @@ -12,9 +12,9 @@ namespace Kernel::USB { -ErrorOr> Pipe::try_create_pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, i8 device_address, u8 poll_interval) +ErrorOr> Pipe::try_create_pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, i8 device_address, size_t buffer_size, u8 poll_interval) { - auto dma_region = TRY(MM.allocate_kernel_region(PAGE_SIZE, "USB device DMA buffer"sv, Memory::Region::Access::ReadWrite)); + auto dma_region = TRY(MM.allocate_dma_buffer_pages(TRY(Memory::page_round_up(buffer_size)), "USB device DMA buffer"sv, Memory::Region::Access::ReadWrite)); return adopt_nonnull_own_or_enomem(new (nothrow) Pipe(controller, type, direction, endpoint_address, max_packet_size, poll_interval, device_address, move(dma_region))); } diff --git a/Kernel/Bus/USB/USBPipe.h b/Kernel/Bus/USB/USBPipe.h index a91de384ab..73c423b2d2 100644 --- a/Kernel/Bus/USB/USBPipe.h +++ b/Kernel/Bus/USB/USBPipe.h @@ -41,7 +41,7 @@ public: FullSpeed }; - static ErrorOr> try_create_pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, i8 device_address, u8 poll_interval = 0); + static ErrorOr> try_create_pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, i8 device_address, size_t buffer_size = PAGE_SIZE, u8 poll_interval = 0); Type type() const { return m_type; } Direction direction() const { return m_direction; }