mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:57:35 +00:00
Kernel/USB: Move buffer allocation from USB transfer to USB pipe
Currently when allocating buffers for USB transfers, it is done once for every transfer rather than once upon creation of the USB device. This commit changes that by moving allocation of buffers to the USB Pipe class where they can be reused.
This commit is contained in:
parent
5f726ace53
commit
143339767b
4 changed files with 37 additions and 27 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Bus/USB/USBDescriptors.h>
|
||||
#include <Kernel/Locking/Mutex.h>
|
||||
#include <Kernel/Memory/Region.h>
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
@ -59,9 +60,9 @@ public:
|
|||
ErrorOr<size_t> control_transfer(u8 request_type, u8 request, u16 value, u16 index, u16 length, void* data);
|
||||
ErrorOr<size_t> bulk_transfer(u16 length, void* data);
|
||||
|
||||
Pipe(USBController const& controller, Type type, Direction direction, u16 max_packet_size);
|
||||
Pipe(USBController const& controller, Type type, Direction direction, USBEndpointDescriptor& endpoint);
|
||||
Pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, u8 poll_interval, i8 device_address);
|
||||
Pipe(USBController const& controller, Type type, Direction direction, u16 max_packet_size, NonnullOwnPtr<Memory::Region> dma_buffer);
|
||||
Pipe(USBController const& controller, Type type, Direction direction, USBEndpointDescriptor& endpoint, NonnullOwnPtr<Memory::Region> dma_buffer);
|
||||
Pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, u8 poll_interval, i8 device_address, NonnullOwnPtr<Memory::Region> dma_buffer);
|
||||
|
||||
private:
|
||||
friend class Device;
|
||||
|
@ -77,5 +78,9 @@ private:
|
|||
u16 m_max_packet_size { 0 }; // Max packet size for this pipe
|
||||
u8 m_poll_interval { 0 }; // Polling interval (in frames)
|
||||
bool m_data_toggle { false }; // Data toggle for stuffing bit
|
||||
|
||||
Mutex m_dma_buffer_lock { "USB pipe mutex" };
|
||||
|
||||
NonnullOwnPtr<Memory::Region> m_dma_buffer;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue