mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-15 03:16:44 +02:00
For now we only support USB <3.0 devices, as we don't support streams. We also don't leverage the benefits of UAS, as we pretend to have a queue depth of 1, ie are single threaded. To test this driver, you can use the following command: ``` SERENITY_BOOT_DRIVE=usb-uas Meta/serenity.sh run x86_64 Clang ```
44 lines
1.3 KiB
C++
44 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2024, Leon Albrecht <leon.a@serenityos.org>
|
|
* Copyright (c) 2024, Sönke Holz <sholz8530@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/Devices/Storage/StorageDevice.h>
|
|
|
|
namespace Kernel::USB {
|
|
|
|
class UASInterface;
|
|
|
|
class UASStorageDevice : public StorageDevice {
|
|
public:
|
|
UASStorageDevice(UASInterface&, LUNAddress logical_unit_number_address, u32 hardware_relative_controller_id, size_t sector_size, u64 max_addressable_block);
|
|
|
|
private:
|
|
UASInterface& m_interface;
|
|
|
|
virtual void start_request(AsyncBlockDeviceRequest&) override;
|
|
virtual CommandSet command_set() const override { return CommandSet::SCSI; }
|
|
|
|
u32 optimal_block_count(u32 blocks);
|
|
|
|
ErrorOr<void> do_read(u32 block_index, u32 block_count, UserOrKernelBuffer& buffer, size_t buffer_size);
|
|
ErrorOr<void> do_write(u32 block_index, u32 block_count, UserOrKernelBuffer& buffer, size_t buffer_size);
|
|
|
|
ErrorOr<void> query_characteristics();
|
|
|
|
Optional<u16> m_optimal_transfer_length;
|
|
Optional<u32> m_optimal_transfer_length_granularity;
|
|
Optional<u32> m_maximum_transfer_length;
|
|
|
|
IntrusiveListNode<UASStorageDevice, NonnullLockRefPtr<UASStorageDevice>> m_list_node;
|
|
|
|
public:
|
|
using List = IntrusiveList<&UASStorageDevice::m_list_node>;
|
|
};
|
|
|
|
}
|