usb: plug and play -- hot-plug, unplug, every interface, real mice
Devices can now arrive and leave after boot. A "usbhotplug" kernel thread handles root-port changes, which it is told about by Port Status Change events and also checks for every quarter second. It also handles changes behind hubs, which each hub reports on its status-change endpoint. An unplugged device has its endpoints closed and any transfer in flight failed. Then its drivers' disconnect hooks run, the slot is disabled and its memory is freed. Everything behind a hub that goes goes with it. This needed the interrupt handler to file command and endpoint-0 completions for their waiters, so that enumeration can run while keyboards interrupt. On real hardware: the controller is taken from the firmware through USB Legacy Support before reset, with SMIs off. On Intel 7/8/9 series parts the ports are switched over from EHCI, which is where firmware leaves them. Every interface of a device is offered to the class drivers, not just the first, so a receiver's mouse on interface 1 gets a driver. Configure Endpoint now copies the slot context from the controller. Before, it rebuilt it and lost the route string and TT fields of devices behind hubs. HID: pointers are read in report protocol from their report descriptor. That covers buttons, X/Y and wheel, relative or absolute, and report IDs. Boot protocol is kept as the fallback for mice and for keyboards. Non-pointer HID interfaces are declined rather than treated as tablets. USB keyboards get software key repeat. Mass storage handles up to four sticks, each unregistered from the block layer when it is pulled out, along with its cached blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HH7xukt4aaiGj1nQEAoQf1
This commit is contained in:
parent
c1e52e172f
commit
fa7669254e
13 changed files with 1367 additions and 240 deletions
|
|
@ -222,6 +222,27 @@ blkdev_register(const char *name, const struct blkdev_ops *ops, void *priv,
|
|||
return dev;
|
||||
}
|
||||
|
||||
void
|
||||
blkdev_unregister(int dev)
|
||||
{
|
||||
struct blkdev *d = lookup(dev);
|
||||
if (!d)
|
||||
return;
|
||||
int disk = dev - BLKDEV_FIRST;
|
||||
|
||||
acquire(&blklock);
|
||||
for (int i = 0; i < NBLKDEV; i++) {
|
||||
if (devs[i].used && (i == disk || devs[i].parent == disk)) {
|
||||
devs[i].used = 0;
|
||||
kinfo("blkdev: %s removed\n", devs[i].name);
|
||||
release(&blklock);
|
||||
binval(BLKDEV_FIRST + i);
|
||||
acquire(&blklock);
|
||||
}
|
||||
}
|
||||
release(&blklock);
|
||||
}
|
||||
|
||||
// --- I/O ---------------------------------------------------------------------
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Reference in a new issue