mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
Kernel/USB: Get all interface descriptors on enumeration
This creates all interfaces when the device is enumerated, with a link to the configuration that it is a part of. As such, a new class, `USBInterface` has been introduced to express this state.
This commit is contained in:
parent
d313fa98ec
commit
300dcb6f5e
5 changed files with 121 additions and 4 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <AK/Vector.h>
|
||||
#include <Kernel/Bus/USB/USBDescriptors.h>
|
||||
#include <Kernel/Bus/USB/USBDevice.h>
|
||||
#include <Kernel/Bus/USB/USBInterface.h>
|
||||
|
||||
namespace Kernel::USB {
|
||||
|
||||
|
@ -17,22 +18,27 @@ class Device;
|
|||
class USBConfiguration {
|
||||
public:
|
||||
USBConfiguration() = delete;
|
||||
USBConfiguration(Device& device, USBConfigurationDescriptor const configuration_descriptor)
|
||||
USBConfiguration(Device& device, USBConfigurationDescriptor const descriptor)
|
||||
: m_device(device)
|
||||
, m_descriptor(configuration_descriptor)
|
||||
, m_descriptor(descriptor)
|
||||
{
|
||||
m_interfaces.ensure_capacity(descriptor.number_of_interfaces);
|
||||
}
|
||||
|
||||
Device const& device() const { return m_device; }
|
||||
USBConfigurationDescriptor const& descriptor() const { return m_descriptor; }
|
||||
|
||||
u8 interface_count() const { return m_descriptor.number_of_interfaces; }
|
||||
u8 configuration_id() const { return m_descriptor.configuration_value; }
|
||||
u8 attributes() const { return m_descriptor.attributes_bitmap; }
|
||||
u16 max_power_ma() const { return m_descriptor.max_power_in_ma * 2u; } // Note: "Power" is used incorrectly here, however it's what it's called in the descriptor/documentation
|
||||
|
||||
ErrorOr<void> get_interfaces();
|
||||
|
||||
private:
|
||||
Device& m_device; // Reference to the device linked to this configuration
|
||||
USBConfigurationDescriptor m_descriptor; // Descriptor that backs this configuration
|
||||
Device& m_device; // Reference to the device linked to this configuration
|
||||
USBConfigurationDescriptor const m_descriptor; // Descriptor that backs this configuration
|
||||
Vector<USBInterface> m_interfaces; // Interfaces for this device
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue