20 #include "modules/system/usb/UsbPnP.h" 21 #include "modules/system/usb/UsbDevice.h" 22 #include "pedigree/kernel/machine/Device.h" 23 #include "pedigree/kernel/utilities/Iterator.h" 24 #include "pedigree/kernel/utilities/utility.h" 28 UsbPnP::UsbPnP() : m_Callbacks()
38 Device *pResult = doProbe(pDeviceBase);
39 return pResult == pDeviceBase;
58 else if (!m_Callbacks.count())
67 it != m_Callbacks.end(); it++)
76 if ((item->nProductId != ProductIdNone) &&
77 (item->nProductId != pDes->nProductId))
79 if ((item->
nClass != ClassNone) && (item->
nClass != pIface->nClass))
81 if ((item->nSubclass != SubclassNone) &&
82 (item->nSubclass != pIface->nSubclass))
84 if ((item->nProtocol != ProtocolNone) &&
85 (item->nProtocol != pIface->nProtocol))
100 if (pNewDevice->
getUsbState() == UsbDevice::HasDriver)
105 return pNewContainer;
117 auto performReprobe = [](
Device *p) {
127 auto c = pedigree_std::make_callable(performReprobe);
132 uint16_t nVendorId, uint16_t nProductId, callback_t callback)
137 item->nProductId = nProductId;
139 item->nSubclass = SubclassNone;
140 item->nProtocol = ProtocolNone;
142 m_Callbacks.pushBack(item);
144 reprobeDevices(
nullptr);
148 uint8_t nClass, uint8_t nSubclass, uint8_t nProtocol, callback_t callback)
153 item->nProductId = ProductIdNone;
155 item->nSubclass = nSubclass;
156 item->nProtocol = nProtocol;
158 m_Callbacks.pushBack(item);
160 reprobeDevices(
nullptr);
void reprobeDevices(Device *pParent)
Goes down the device tree, reprobing every USB device.
callback_t callback
The callback function.
uint16_t nVendorId
Vendor and product IDs.
Interface * getInterface()
Returns the interface in use.
virtual void initialiseDriver()
Implemented by the driver class, initialises driver-specific stuff.
Device * doProbe(Device *pDeviceBase)
bool probeDevice(Device *pDeviceBase)
Tries to find a suitable driver for the given USB device.
uint8_t nClass
Class, subclass and protocol numbers.
::Iterator< T, node_t > Iterator
static void foreach(Callback callback, Device *root=0)
DeviceDescriptor * getDescriptor()
Returns the device descriptor of the device.
static UsbPnP & instance()
Singleton design.
static UsbPnP m_Instance
Static instance.
UsbState getUsbState()
Returns the current state of the device.
void registerCallback(uint16_t nVendorId, uint16_t nProductId, callback_t callback)
Register a callback for the given vendor and product IDs.