2021-08-14 00:31:00 -03:00
|
|
|
/*
|
2022-04-22 04:04:37 -03:00
|
|
|
* Copyright (c) 2021-2022, Liav A. <liavalb@hotmail.co.il>
|
2021-08-14 00:31:00 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Kernel/Bus/USB/USBDevice.h>
|
2022-04-22 06:46:19 -03:00
|
|
|
#include <Kernel/FileSystem/SysFS/Component.h>
|
2021-09-04 10:23:45 -03:00
|
|
|
#include <Kernel/KBufferBuilder.h>
|
2022-04-22 04:04:37 -03:00
|
|
|
#include <Kernel/KString.h>
|
2021-09-04 10:23:45 -03:00
|
|
|
#include <Kernel/Locking/Mutex.h>
|
2021-08-14 00:31:00 -03:00
|
|
|
|
2022-04-22 04:04:37 -03:00
|
|
|
namespace Kernel {
|
2021-08-14 00:31:00 -03:00
|
|
|
|
|
|
|
|
class SysFSUSBDeviceInformation : public SysFSComponent {
|
|
|
|
|
friend class SysFSUSBBusDirectory;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual ~SysFSUSBDeviceInformation() override;
|
|
|
|
|
|
2022-08-19 15:53:40 -03:00
|
|
|
static ErrorOr<NonnullLockRefPtr<SysFSUSBDeviceInformation>> create(USB::Device&);
|
2021-12-12 11:33:08 -03:00
|
|
|
virtual StringView name() const override { return m_device_name->view(); }
|
2021-08-14 00:31:00 -03:00
|
|
|
|
|
|
|
|
protected:
|
2021-12-12 11:33:08 -03:00
|
|
|
SysFSUSBDeviceInformation(NonnullOwnPtr<KString> device_name, USB::Device& device);
|
2021-08-14 00:31:00 -03:00
|
|
|
|
2021-11-07 20:51:39 -03:00
|
|
|
virtual ErrorOr<size_t> read_bytes(off_t offset, size_t count, UserOrKernelBuffer& buffer, OpenFileDescription*) const override;
|
2021-08-14 00:31:00 -03:00
|
|
|
|
2022-08-19 15:53:40 -03:00
|
|
|
NonnullLockRefPtr<USB::Device> m_device;
|
2021-09-04 10:23:45 -03:00
|
|
|
|
|
|
|
|
private:
|
2021-11-07 20:51:39 -03:00
|
|
|
ErrorOr<void> try_generate(KBufferBuilder&);
|
|
|
|
|
virtual ErrorOr<void> refresh_data(OpenFileDescription& description) const override;
|
2022-07-11 14:32:29 -03:00
|
|
|
mutable Mutex m_lock { "SysFSUSBDeviceInformation"sv };
|
2021-12-12 11:33:08 -03:00
|
|
|
NonnullOwnPtr<KString> m_device_name;
|
2021-08-14 00:31:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|