|
|
|
|
|
|
|
|
|
|
|
|
|
|
// first check if any driver wishes to claim the entire device |
|
|
// first check if any driver wishes to claim the entire device |
|
|
for (driver=available_drivers; driver != NULL; driver = driver->next) { |
|
|
for (driver=available_drivers; driver != NULL; driver = driver->next) { |
|
|
|
|
|
if (driver->device != NULL) continue; |
|
|
if (driver->claim(dev, 0, enumbuf + 9, enumlen - 9)) { |
|
|
if (driver->claim(dev, 0, enumbuf + 9, enumlen - 9)) { |
|
|
if (prev) { |
|
|
if (prev) { |
|
|
prev->next = driver->next; |
|
|
prev->next = driver->next; |
|
|
|
|
|
|
|
|
// found an interface, ask available drivers if they want it |
|
|
// found an interface, ask available drivers if they want it |
|
|
prev = NULL; |
|
|
prev = NULL; |
|
|
for (driver=available_drivers; driver != NULL; driver = driver->next) { |
|
|
for (driver=available_drivers; driver != NULL; driver = driver->next) { |
|
|
|
|
|
if (driver->device != NULL) continue; |
|
|
// TODO: should parse ahead and give claim() |
|
|
// TODO: should parse ahead and give claim() |
|
|
// an accurate length. (end - p) is the rest |
|
|
// an accurate length. (end - p) is the rest |
|
|
// of ALL descriptors, likely more interfaces |
|
|
// of ALL descriptors, likely more interfaces |
|
|
|
|
|
|
|
|
for (USBDriver *p = dev->drivers; p; ) { |
|
|
for (USBDriver *p = dev->drivers; p; ) { |
|
|
println("disconnect driver ", (uint32_t)p, HEX); |
|
|
println("disconnect driver ", (uint32_t)p, HEX); |
|
|
p->disconnect(); |
|
|
p->disconnect(); |
|
|
|
|
|
p->device = NULL; |
|
|
USBDriver *next = p->next; |
|
|
USBDriver *next = p->next; |
|
|
p->next = available_drivers; |
|
|
p->next = available_drivers; |
|
|
available_drivers = p; |
|
|
available_drivers = p; |