diff options
author | b14ckcat <b14ckcat@protonmail.com> | 2022-10-17 01:22:54 -0400 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-11-12 09:08:02 -0700 |
commit | 7400eb36406f1e26ae55751aaa4c175630969402 (patch) | |
tree | c0215e58ea04f3c1825d1ecbe5bd75fc3c5a78c7 /Kernel/Bus/USB/USBTransfer.h | |
parent | 1aa16b4dd464e7c2b37e83eb077d1317479c8a9f (diff) | |
download | serenity-7400eb36406f1e26ae55751aaa4c175630969402.zip |
Kernel/USB: Add support for async & interrupt transfers
Add support for async transfers by using a separate kernel task to poll
a list of active async transfers on a set time interval, and invoke
their user-provided callback function when they are complete. Also add
support for the interrupt class of transfers, building off of this async
functionality.
Diffstat (limited to 'Kernel/Bus/USB/USBTransfer.h')
-rw-r--r-- | Kernel/Bus/USB/USBTransfer.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Kernel/Bus/USB/USBTransfer.h b/Kernel/Bus/USB/USBTransfer.h index 5923542d6c..c506650d9e 100644 --- a/Kernel/Bus/USB/USBTransfer.h +++ b/Kernel/Bus/USB/USBTransfer.h @@ -20,7 +20,7 @@ namespace Kernel::USB { class Transfer final : public AtomicRefCounted<Transfer> { public: - static ErrorOr<NonnullLockRefPtr<Transfer>> try_create(Pipe&, u16 length, Memory::Region& dma_buffer); + static ErrorOr<NonnullLockRefPtr<Transfer>> create(Pipe&, u16 length, Memory::Region& dma_buffer, USBAsyncCallback callback = nullptr); Transfer() = delete; ~Transfer(); @@ -41,14 +41,17 @@ public: bool complete() const { return m_complete; } bool error_occurred() const { return m_error_occurred; } + void invoke_async_callback(); + private: - Transfer(Pipe& pipe, u16 len, Memory::Region& dma_buffer); + Transfer(Pipe& pipe, u16 len, Memory::Region& dma_buffer, USBAsyncCallback callback); Pipe& m_pipe; // Pipe that initiated this transfer Memory::Region& m_dma_buffer; // DMA buffer USBRequestData m_request; // USB request u16 m_transfer_data_size { 0 }; // Size of the transfer's data stage bool m_complete { false }; // Has this transfer been completed? bool m_error_occurred { false }; // Did an error occur during this transfer? + USBAsyncCallback m_callback { nullptr }; }; } |