23 #include "modules/system/usb/Usb.h" 24 #include "pedigree/kernel/compiler.h" 25 #include "pedigree/kernel/machine/Device.h" 26 #include "pedigree/kernel/processor/types.h" 27 #include "pedigree/kernel/utilities/String.h" 28 #include "pedigree/kernel/utilities/Vector.h" 29 #include "pedigree/kernel/utilities/utility.h" 45 uint8_t requestType, uint8_t request, uint16_t value,
46 uint16_t index, uint16_t length)
47 : nRequestType(requestType), nRequest(request), nValue(value),
48 nIndex(index), nLength(length)
62 : nType(type), nLength(length)
64 pDescriptor =
new uint8_t[nLength];
65 MemoryCopy(pDescriptor, pBuffer, nLength);
88 uint8_t nTransferType;
89 uint16_t nMaxPacketSize;
100 uint8_t nAlternateSetting;
114 void *pConfigBuffer,
size_t nConfigLength, UsbSpeed speed);
130 uint16_t nBcdUsbRelease;
134 uint8_t nMaxControlPacketSize;
137 uint16_t nBcdDeviceRelease;
138 uint8_t nVendorString;
139 uint8_t nProductString;
140 uint8_t nSerialString;
141 uint8_t nConfigurations;
155 uint8_t nMaxControlPacketSize;
156 uint8_t nConfigurations;
181 void initialise(uint8_t nAddress);
188 virtual void getUsbDeviceName(
String &str)
190 str =
"Generic USB Device";
220 return m_pDescriptor;
226 return m_pConfiguration;
236 void useConfiguration(uint8_t nConfig);
239 void useInterface(uint8_t nInterface);
263 Endpoint *pEndpoint, UsbPid pid, uintptr_t pBuffer,
size_t nBytes,
266 Endpoint *pEndpoint, uintptr_t pBuffer,
size_t nBytes,
267 size_t timeout = 5000);
269 Endpoint *pEndpoint, uintptr_t pBuffer,
size_t nBytes,
270 size_t timeout = 5000);
272 void addInterruptInHandler(
273 Endpoint *pEndpoint, uintptr_t pBuffer, uint16_t nBytes,
274 void (*pCallback)(uintptr_t, ssize_t), uintptr_t pParam = 0);
278 uint8_t nRequestType, uint8_t nRequest, uint16_t nValue,
279 uint16_t nIndex, uint16_t nLength = 0, uintptr_t pBuffer = 0);
282 uint16_t getStatus();
285 bool clearEndpointHalt(
Endpoint *pEndpoint);
289 uint8_t nDescriptorType, uint8_t nDescriptorIndex, uint16_t nBytes,
290 uint8_t requestType = 0);
293 uint8_t getDescriptorLength(
294 uint8_t nDescriptorType, uint8_t nDescriptorIndex,
295 uint8_t requestType = 0);
298 String getString(uint8_t nString);
340 virtual void getName(
String &str);
342 virtual Type getType();
344 virtual void dump(
String &str);
UsbSpeed getSpeed()
Returns the speed at which the device operates.
uint8_t m_nPort
The number of the port on which the device is connected.
ConfigDescriptor * m_pConfiguration
Configuration in use.
A vector / dynamic array.
ConfigDescriptor * getConfiguration()
Returns the configuration in use.
virtual bool hasSubtree() const
Do we expose our own Device tree?
Interface * getInterface()
Returns the interface in use.
UsbDeviceContainer * getContainer() const
Gets our Device container, for replacing parents on hubs etc.
UsbHub * m_pHub
Parent USB hub.
UsbSpeed m_Speed
The speed at which the device operates.
virtual void initialiseDriver()
Implemented by the driver class, initialises driver-specific stuff.
virtual Device * getDevice()
UsbState m_UsbState
The current state of the device.
uint8_t m_nAddress
The current address of the device.
UsbState
Possible states for an USB device.
DeviceDescriptor * m_pDescriptor
Device descriptor for this device.
uint8_t getAddress()
Returns the current address of the device.
DeviceDescriptor * getDescriptor()
Returns the device descriptor of the device.
uint8_t getPort()
Returns the number of the port on which the device is connected.
UsbState getUsbState()
Returns the current state of the device.
Interface * m_pInterface
Interface in use.
UsbDeviceContainer * m_pContainer
Our current container.