Addition of new fields to the usb_devinfo struct to enable the new

and shiny usbd daemon to handle events.

usb_port.h:
- Add a macro to retrieve the unit number from a USBBASEDEVICE

usb.h, usb_subr.c:
- Add fields to the device_info struct.

usb_subr.c:
- Fill in the new fields.
- Remove the notification of the event up a bit to make sure all the
  information is still available to fill the usb_devinfo struct.

This requires recompilation of usbdevs (src/usr.sbin/usbdevs) and the
ezdownload/ezupload (ports/misc/ezload) utilities in any case.
This commit is contained in:
Nick Hibma 1999-11-21 17:30:42 +00:00
parent 88ea580e34
commit 937791192a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53515
3 changed files with 26 additions and 13 deletions

View File

@ -477,17 +477,21 @@ struct usb_ctl_report_desc {
};
struct usb_device_info {
u_int8_t addr; /* device address */
char product[USB_MAX_STRING_LEN];
char vendor[USB_MAX_STRING_LEN];
char release[8];
u_int16_t productNo;
u_int16_t vendorNo;
u_int8_t class;
u_int8_t config;
u_int8_t lowspeed;
u_int8_t bus; /* bus number */
u_int8_t addr; /* device address */
char product[USB_MAX_STRING_LEN]; /* iProduct */
char vendor[USB_MAX_STRING_LEN]; /* iManufacturer */
char release[8]; /* string of releaseNo*/
u_int16_t productNo; /* idProduct */
u_int16_t vendorNo; /* idVendor */
u_int16_t releaseNo; /* bcdDevice */
u_int8_t class; /* bDeviceClass */
u_int8_t subclass; /* bDeviceSubclass */
u_int8_t protocol; /* bDeviceProtocol */
u_int8_t config; /* config index */
u_int8_t lowspeed; /* lowsped yes/no */
int power; /* power consumption in mA, 0 if selfpowered */
int nports;
int nports; /* 0 if not hub */
u_int8_t ports[16];/* hub only: addresses of devices on ports */
#define USB_PORT_ENABLED 0xff
#define USB_PORT_SUSPENDED 0xfe

View File

@ -65,6 +65,7 @@ typedef struct device *device_ptr_t;
#define USBDEV(bdev) (&(bdev))
#define USBDEVNAME(bdev) ((bdev).dv_xname)
#define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
#define USBDEVUNIT(bdev) ((bdev).dv_unit)
#define DECLARE_USB_DMA_T \
struct usb_dma_block; \
@ -177,6 +178,7 @@ typedef struct device device_ptr_t;
#define USBDEV(bdev) (&(bdev))
#define USBDEVNAME(bdev) ((bdev).dv_xname)
#define USBDEVPTRNAME(bdevptr) ((bdevptr)->dv_xname)
#define USBDEVUNIT(bdev) ((bdev).dv_unit)
#define DECLARE_USB_DMA_T \
struct usb_dma_block; \
@ -271,6 +273,7 @@ __CONCAT(dname,_detach)(self, flags) \
#define USBDEV(bdev) (bdev)
#define USBDEVNAME(bdev) device_get_nameunit(bdev)
#define USBDEVPTRNAME(bdev) device_get_nameunit(bdev)
#define USBDEVUNIT(bdev) device_get_unit(bdev)
#define DECLARE_USB_DMA_T typedef void * usb_dma_t

View File

@ -1138,15 +1138,20 @@ usbd_fill_deviceinfo(dev, di)
struct usbd_port *p;
int i, err, s;
di->config = dev->config;
di->bus = USBDEVUNIT(dev->bus->bdev);
di->addr = dev->address;
usbd_devinfo_vp(dev, di->vendor, di->product);
usbd_printBCD(di->release, UGETW(dev->ddesc.bcdDevice));
di->vendorNo = UGETW(dev->ddesc.idVendor);
di->productNo = UGETW(dev->ddesc.idProduct);
di->releaseNo = UGETW(dev->ddesc.bcdDevice);
di->class = dev->ddesc.bDeviceClass;
di->subclass = dev->ddesc.bDeviceSubClass;
di->protocol = dev->ddesc.bDeviceProtocol;
di->config = dev->config;
di->power = dev->self_powered ? 0 : dev->power;
di->lowspeed = dev->lowspeed;
di->addr = dev->address;
if (dev->hub) {
for (i = 0;
i < sizeof(di->ports) / sizeof(di->ports[0]) &&
@ -1237,6 +1242,8 @@ usb_disconnect_port(up, parent)
return;
}
usbd_add_event(USB_EVENT_DETACH, dev);
if (dev->subdevs != NULL) {
for (i = 0; dev->subdevs[i]; i++) {
if (!dev->subdevs[i]) /* skip empty elements */
@ -1257,7 +1264,6 @@ usb_disconnect_port(up, parent)
}
}
usbd_add_event(USB_EVENT_DETACH, dev);
dev->bus->devices[dev->address] = 0;
up->device = 0;
usb_free_device(dev);