23#include "pedigree/kernel/compiler.h"
24#include "pedigree/kernel/processor/types.h"
25#include "pedigree/kernel/utilities/String.h"
27#include "modules/system/usb/Usb.h"
28#include "modules/system/usb/UsbConstants.h"
29#include "modules/system/usb/UsbDevice.h"
30#include "modules/system/usb/UsbHub.h"
40 str.assign(
"USB Hub Device", 15);
54 uintptr_t pBuffer,
size_t nBytes);
57 void (*pCallback)(uintptr_t, ssize_t) = 0,
58 uintptr_t pParam = 0);
61 void (*pCallback)(uintptr_t, ssize_t),
63 uintptr_t pParam = 0);
65 virtual bool portReset(uint8_t nPort,
bool bErrorResponse =
false);
68 virtual void cancelAsyncAndDrain(uintptr_t pTransaction,
void (*pCallback)(uintptr_t, ssize_t),
71 void (*callback)(uintptr_t, ssize_t),
73 bool producerAlreadyStopped)
override;
76 enum HubFeatureSelectors {
81 enum PortFeatureSelectors {
92 CPortOverCurrent = 19,
99 HubPortRequest =
static_cast<uint8_t
>(
static_cast<uint8_t
>(UsbRequestType::Class) |
100 static_cast<uint8_t
>(UsbRequestRecipient::Other))
103 bool setPortFeature(
size_t port, PortFeatureSelectors feature);
104 bool clearPortFeature(
size_t port, PortFeatureSelectors feature);
111 : pDescriptor(
static_cast<Descriptor*
>(pBuffer)),
112 nPorts(pDescriptor->nPorts),
113 hubCharacteristics(pDescriptor->hubCharacteristics) {}
116 delete[]
reinterpret_cast<uint8_t*
>(pDescriptor);
123 uint16_t hubCharacteristics;
127 uint16_t hubCharacteristics;
bool getPortStatus(size_t port, uint32_t &status)
Top 16 bits of status hold the port-change flags.
Device * getDevice() override
virtual void cancelAsyncAndDrain(uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t), uintptr_t pParam)
MUST_USE_RESULT bool cancelInterruptInAndDrain(const UsbInterruptInToken &token, void(*callback)(uintptr_t, ssize_t), uintptr_t parameter, bool producerAlreadyStopped) override
virtual void getName(String &str)
void prepareForDriverRetirement() override
virtual MUST_USE_RESULT bool doAsync(uintptr_t pTransaction, void(*pCallback)(uintptr_t, ssize_t)=0, uintptr_t pParam=0)
virtual bool portReset(uint8_t nPort, bool bErrorResponse=false)
Gets a UsbDevice from a given vendor:product pair.
bool hasSubtree() const override
Do we expose our own Device tree?
virtual void addTransferToTransaction(uintptr_t pTransaction, bool bToggle, UsbPid pid, uintptr_t pBuffer, size_t nBytes)
Adds a new transfer to an existent transaction.
virtual void initialiseDriver()
Implemented by the driver class, initialises driver-specific stuff.
virtual MUST_USE_RESULT bool addInterruptInHandler(UsbEndpoint endpointInfo, uintptr_t pBuffer, uint16_t nBytes, void(*pCallback)(uintptr_t, ssize_t), UsbInterruptInHandle &handle, uintptr_t pParam=0)
Adds an owned recurring interrupt-IN transaction.
virtual uintptr_t createTransaction(UsbEndpoint endpointInfo)
Creates a new transaction with the given endpoint data.