mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-30 12:04:07 +00:00
Use a more obvious prefix for the USB control (endpoint 0) transfers rather
than default_*.
This commit is contained in:
parent
91cd92400f
commit
5b3bb704f7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=207080
@ -971,7 +971,7 @@ usb_linux_create_usb_device(struct usb_device *udev, device_t dev)
|
||||
udev->devnum = device_get_unit(dev);
|
||||
bcopy(&udev->ddesc, &udev->descriptor,
|
||||
sizeof(udev->descriptor));
|
||||
bcopy(udev->default_ep.edesc, &udev->ep0.desc,
|
||||
bcopy(udev->ctrl_ep.edesc, &udev->ep0.desc,
|
||||
sizeof(udev->ep0.desc));
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ usb_dev_get_ep(struct usb_device *udev, uint8_t ep_index, uint8_t dir)
|
||||
uint8_t ep_dir;
|
||||
|
||||
if (ep_index == 0) {
|
||||
ep = &udev->default_ep;
|
||||
ep = &udev->ctrl_ep;
|
||||
} else {
|
||||
if (dir == USB_FIFO_RX) {
|
||||
if (udev->flags.usb_mode == USB_MODE_HOST) {
|
||||
|
@ -179,9 +179,9 @@ usbd_get_ep_by_addr(struct usb_device *udev, uint8_t ea_val)
|
||||
/*
|
||||
* The default endpoint is always present and is checked separately:
|
||||
*/
|
||||
if ((udev->default_ep.edesc) &&
|
||||
((udev->default_ep.edesc->bEndpointAddress & EA_MASK) == ea_val)) {
|
||||
ep = &udev->default_ep;
|
||||
if ((udev->ctrl_ep.edesc) &&
|
||||
((udev->ctrl_ep.edesc->bEndpointAddress & EA_MASK) == ea_val)) {
|
||||
ep = &udev->ctrl_ep;
|
||||
goto found;
|
||||
}
|
||||
return (NULL);
|
||||
@ -297,11 +297,11 @@ usbd_get_endpoint(struct usb_device *udev, uint8_t iface_index,
|
||||
* address" and "any direction" returns the first endpoint of the
|
||||
* interface. "iface_index" and "direction" is ignored:
|
||||
*/
|
||||
if ((udev->default_ep.edesc) &&
|
||||
((udev->default_ep.edesc->bEndpointAddress & ea_mask) == ea_val) &&
|
||||
((udev->default_ep.edesc->bmAttributes & type_mask) == type_val) &&
|
||||
if ((udev->ctrl_ep.edesc) &&
|
||||
((udev->ctrl_ep.edesc->bEndpointAddress & ea_mask) == ea_val) &&
|
||||
((udev->ctrl_ep.edesc->bmAttributes & type_mask) == type_val) &&
|
||||
(!index)) {
|
||||
ep = &udev->default_ep;
|
||||
ep = &udev->ctrl_ep;
|
||||
goto found;
|
||||
}
|
||||
return (NULL);
|
||||
@ -1422,7 +1422,7 @@ usbd_clear_stall_proc(struct usb_proc_msg *_pm)
|
||||
mtx_lock(&udev->device_mtx);
|
||||
|
||||
/* Start clear stall callback */
|
||||
usbd_transfer_start(udev->default_xfer[1]);
|
||||
usbd_transfer_start(udev->ctrl_xfer[1]);
|
||||
|
||||
/* Change lock */
|
||||
mtx_unlock(&udev->device_mtx);
|
||||
@ -1529,13 +1529,13 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus,
|
||||
udev->refcount = 1;
|
||||
|
||||
/* set up default endpoint descriptor */
|
||||
udev->default_ep_desc.bLength = sizeof(udev->default_ep_desc);
|
||||
udev->default_ep_desc.bDescriptorType = UDESC_ENDPOINT;
|
||||
udev->default_ep_desc.bEndpointAddress = USB_CONTROL_ENDPOINT;
|
||||
udev->default_ep_desc.bmAttributes = UE_CONTROL;
|
||||
udev->default_ep_desc.wMaxPacketSize[0] = USB_MAX_IPACKET;
|
||||
udev->default_ep_desc.wMaxPacketSize[1] = 0;
|
||||
udev->default_ep_desc.bInterval = 0;
|
||||
udev->ctrl_ep_desc.bLength = sizeof(udev->ctrl_ep_desc);
|
||||
udev->ctrl_ep_desc.bDescriptorType = UDESC_ENDPOINT;
|
||||
udev->ctrl_ep_desc.bEndpointAddress = USB_CONTROL_ENDPOINT;
|
||||
udev->ctrl_ep_desc.bmAttributes = UE_CONTROL;
|
||||
udev->ctrl_ep_desc.wMaxPacketSize[0] = USB_MAX_IPACKET;
|
||||
udev->ctrl_ep_desc.wMaxPacketSize[1] = 0;
|
||||
udev->ctrl_ep_desc.bInterval = 0;
|
||||
udev->ddesc.bMaxPacketSize = USB_MAX_IPACKET;
|
||||
|
||||
udev->speed = speed;
|
||||
@ -1559,8 +1559,8 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus,
|
||||
|
||||
/* init the default endpoint */
|
||||
usb_init_endpoint(udev, 0,
|
||||
&udev->default_ep_desc,
|
||||
&udev->default_ep);
|
||||
&udev->ctrl_ep_desc,
|
||||
&udev->ctrl_ep);
|
||||
|
||||
/* set device index */
|
||||
udev->device_index = device_index;
|
||||
@ -1573,10 +1573,10 @@ usb_alloc_device(device_t parent_dev, struct usb_bus *bus,
|
||||
LIST_INIT(&udev->pd_list);
|
||||
|
||||
/* Create the control endpoint device */
|
||||
udev->default_dev = usb_make_dev(udev, 0, FREAD|FWRITE);
|
||||
udev->ctrl_dev = usb_make_dev(udev, 0, FREAD|FWRITE);
|
||||
|
||||
/* Create a link from /dev/ugenX.X to the default endpoint */
|
||||
make_dev_alias(udev->default_dev, udev->ugen_name);
|
||||
make_dev_alias(udev->ctrl_dev, udev->ugen_name);
|
||||
#endif
|
||||
if (udev->flags.usb_mode == USB_MODE_HOST) {
|
||||
|
||||
@ -2009,20 +2009,20 @@ usb_free_device(struct usb_device *udev, uint8_t flag)
|
||||
}
|
||||
mtx_unlock(&usb_ref_lock);
|
||||
|
||||
destroy_dev_sched_cb(udev->default_dev, usb_cdev_cleanup,
|
||||
udev->default_dev->si_drv1);
|
||||
destroy_dev_sched_cb(udev->ctrl_dev, usb_cdev_cleanup,
|
||||
udev->ctrl_dev->si_drv1);
|
||||
#endif
|
||||
|
||||
if (udev->flags.usb_mode == USB_MODE_DEVICE) {
|
||||
/* stop receiving any control transfers (Device Side Mode) */
|
||||
usbd_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX);
|
||||
usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX);
|
||||
}
|
||||
|
||||
/* the following will get the device unconfigured in software */
|
||||
usb_unconfigure(udev, USB_UNCFG_FLAG_FREE_EP0);
|
||||
|
||||
/* unsetup any leftover default USB transfers */
|
||||
usbd_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX);
|
||||
usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX);
|
||||
|
||||
/* template unsetup, if any */
|
||||
(usb_temp_unsetup_p) (udev);
|
||||
|
@ -30,7 +30,7 @@
|
||||
struct usb_symlink; /* UGEN */
|
||||
struct usb_device; /* linux compat */
|
||||
|
||||
#define USB_DEFAULT_XFER_MAX 2
|
||||
#define USB_CTRL_XFER_MAX 2
|
||||
|
||||
/* "usb_parse_config()" commands */
|
||||
|
||||
@ -119,7 +119,7 @@ struct usb_device {
|
||||
struct cv ctrlreq_cv;
|
||||
struct cv ref_cv;
|
||||
struct usb_interface *ifaces;
|
||||
struct usb_endpoint default_ep; /* Control Endpoint 0 */
|
||||
struct usb_endpoint ctrl_ep; /* Control Endpoint 0 */
|
||||
struct usb_endpoint *endpoints;
|
||||
struct usb_power_save pwr_save;/* power save data */
|
||||
struct usb_bus *bus; /* our USB BUS */
|
||||
@ -128,13 +128,13 @@ struct usb_device {
|
||||
struct usb_device *parent_hs_hub; /* high-speed parent HUB */
|
||||
struct usb_config_descriptor *cdesc; /* full config descr */
|
||||
struct usb_hub *hub; /* only if this is a hub */
|
||||
struct usb_xfer *default_xfer[USB_DEFAULT_XFER_MAX];
|
||||
struct usb_xfer *ctrl_xfer[USB_CTRL_XFER_MAX];
|
||||
struct usb_temp_data *usb_template_ptr;
|
||||
struct usb_endpoint *ep_curr; /* current clear stall endpoint */
|
||||
#if USB_HAVE_UGEN
|
||||
struct usb_fifo *fifo[USB_FIFO_MAX];
|
||||
struct usb_symlink *ugen_symlink; /* our generic symlink */
|
||||
struct cdev *default_dev; /* Control Endpoint 0 device node */
|
||||
struct cdev *ctrl_dev; /* Control Endpoint 0 device node */
|
||||
LIST_HEAD(,usb_fs_privdata) pd_list;
|
||||
char ugen_name[20]; /* name of ugenX.X device */
|
||||
#endif
|
||||
@ -166,7 +166,7 @@ struct usb_device {
|
||||
|
||||
struct usb_device_flags flags;
|
||||
|
||||
struct usb_endpoint_descriptor default_ep_desc; /* for endpoint 0 */
|
||||
struct usb_endpoint_descriptor ctrl_ep_desc; /* for endpoint 0 */
|
||||
struct usb_device_descriptor ddesc; /* device descriptor */
|
||||
|
||||
char *serial; /* serial number */
|
||||
|
@ -81,11 +81,11 @@
|
||||
|
||||
static usb_callback_t ugen_read_clear_stall_callback;
|
||||
static usb_callback_t ugen_write_clear_stall_callback;
|
||||
static usb_callback_t ugen_default_read_callback;
|
||||
static usb_callback_t ugen_default_write_callback;
|
||||
static usb_callback_t ugen_ctrl_read_callback;
|
||||
static usb_callback_t ugen_ctrl_write_callback;
|
||||
static usb_callback_t ugen_isoc_read_callback;
|
||||
static usb_callback_t ugen_isoc_write_callback;
|
||||
static usb_callback_t ugen_default_fs_callback;
|
||||
static usb_callback_t ugen_ctrl_fs_callback;
|
||||
|
||||
static usb_fifo_open_t ugen_open;
|
||||
static usb_fifo_close_t ugen_close;
|
||||
@ -265,7 +265,7 @@ ugen_open_pipe_write(struct usb_fifo *f)
|
||||
if (f->flag_short) {
|
||||
usb_config[0].flags.force_short_xfer = 1;
|
||||
}
|
||||
usb_config[0].callback = &ugen_default_write_callback;
|
||||
usb_config[0].callback = &ugen_ctrl_write_callback;
|
||||
usb_config[0].timeout = f->timeout;
|
||||
usb_config[0].frames = 1;
|
||||
usb_config[0].bufsize = f->bufsize;
|
||||
@ -335,7 +335,7 @@ ugen_open_pipe_read(struct usb_fifo *f)
|
||||
}
|
||||
usb_config[0].timeout = f->timeout;
|
||||
usb_config[0].frames = 1;
|
||||
usb_config[0].callback = &ugen_default_read_callback;
|
||||
usb_config[0].callback = &ugen_ctrl_read_callback;
|
||||
usb_config[0].bufsize = f->bufsize;
|
||||
|
||||
if (ugen_transfer_setup(f, usb_config, 2)) {
|
||||
@ -401,7 +401,7 @@ ugen_stop_io(struct usb_fifo *f)
|
||||
}
|
||||
|
||||
static void
|
||||
ugen_default_read_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
ugen_ctrl_read_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
{
|
||||
struct usb_fifo *f = usbd_xfer_softc(xfer);
|
||||
struct usb_mbuf *m;
|
||||
@ -453,7 +453,7 @@ ugen_default_read_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
}
|
||||
|
||||
static void
|
||||
ugen_default_write_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
ugen_ctrl_write_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
{
|
||||
struct usb_fifo *f = usbd_xfer_softc(xfer);
|
||||
usb_frlength_t actlen;
|
||||
@ -1480,7 +1480,7 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr, int fflags)
|
||||
usb_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN);
|
||||
usb_config[0].interval = USB_DEFAULT_INTERVAL;
|
||||
usb_config[0].flags.proxy_buffer = 1;
|
||||
usb_config[0].callback = &ugen_default_fs_callback;
|
||||
usb_config[0].callback = &ugen_ctrl_fs_callback;
|
||||
usb_config[0].timeout = 0; /* no timeout */
|
||||
usb_config[0].frames = u.popen->max_frames;
|
||||
usb_config[0].bufsize = u.popen->max_bufsize;
|
||||
@ -2201,7 +2201,7 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void *addr, int fflags)
|
||||
}
|
||||
|
||||
static void
|
||||
ugen_default_fs_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
ugen_ctrl_fs_callback(struct usb_xfer *xfer, usb_error_t error)
|
||||
{
|
||||
; /* workaround for a bug in "indent" */
|
||||
|
||||
|
@ -246,7 +246,7 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up)
|
||||
/* start control transfer, if device mode */
|
||||
|
||||
if (child->flags.usb_mode == USB_MODE_DEVICE) {
|
||||
usbd_default_transfer_setup(child);
|
||||
usbd_ctrl_transfer_setup(child);
|
||||
}
|
||||
/* if a HUB becomes present, do a recursive HUB explore */
|
||||
|
||||
|
@ -374,9 +374,9 @@ usbd_do_request_flags(struct usb_device *udev, struct mtx *mtx,
|
||||
/*
|
||||
* Setup a new USB transfer or use the existing one, if any:
|
||||
*/
|
||||
usbd_default_transfer_setup(udev);
|
||||
usbd_ctrl_transfer_setup(udev);
|
||||
|
||||
xfer = udev->default_xfer[0];
|
||||
xfer = udev->ctrl_xfer[0];
|
||||
if (xfer == NULL) {
|
||||
/* most likely out of memory */
|
||||
err = USB_ERR_NOMEM;
|
||||
|
@ -72,7 +72,7 @@ struct usb_std_packet_size {
|
||||
|
||||
static usb_callback_t usb_request_callback;
|
||||
|
||||
static const struct usb_config usb_control_ep_cfg[USB_DEFAULT_XFER_MAX] = {
|
||||
static const struct usb_config usb_control_ep_cfg[USB_CTRL_XFER_MAX] = {
|
||||
|
||||
/* This transfer is used for generic control endpoint transfers */
|
||||
|
||||
@ -2433,8 +2433,8 @@ usbd_pipe_start(struct usb_xfer_queue *pq)
|
||||
if (udev->flags.usb_mode == USB_MODE_DEVICE) {
|
||||
(udev->bus->methods->set_stall) (
|
||||
udev, NULL, ep, &did_stall);
|
||||
} else if (udev->default_xfer[1]) {
|
||||
info = udev->default_xfer[1]->xroot;
|
||||
} else if (udev->ctrl_xfer[1]) {
|
||||
info = udev->ctrl_xfer[1]->xroot;
|
||||
usb_proc_msignal(
|
||||
&info->bus->non_giant_callback_proc,
|
||||
&udev->cs_msg[0], &udev->cs_msg[1]);
|
||||
@ -2757,13 +2757,13 @@ usb_command_wrapper(struct usb_xfer_queue *pq, struct usb_xfer *xfer)
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*
|
||||
* usbd_default_transfer_setup
|
||||
* usbd_ctrl_transfer_setup
|
||||
*
|
||||
* This function is used to setup the default USB control endpoint
|
||||
* transfer.
|
||||
*------------------------------------------------------------------------*/
|
||||
void
|
||||
usbd_default_transfer_setup(struct usb_device *udev)
|
||||
usbd_ctrl_transfer_setup(struct usb_device *udev)
|
||||
{
|
||||
struct usb_xfer *xfer;
|
||||
uint8_t no_resetup;
|
||||
@ -2774,12 +2774,12 @@ usbd_default_transfer_setup(struct usb_device *udev)
|
||||
return;
|
||||
repeat:
|
||||
|
||||
xfer = udev->default_xfer[0];
|
||||
xfer = udev->ctrl_xfer[0];
|
||||
if (xfer) {
|
||||
USB_XFER_LOCK(xfer);
|
||||
no_resetup =
|
||||
((xfer->address == udev->address) &&
|
||||
(udev->default_ep_desc.wMaxPacketSize[0] ==
|
||||
(udev->ctrl_ep_desc.wMaxPacketSize[0] ==
|
||||
udev->ddesc.bMaxPacketSize));
|
||||
if (udev->flags.usb_mode == USB_MODE_DEVICE) {
|
||||
if (no_resetup) {
|
||||
@ -2806,13 +2806,13 @@ usbd_default_transfer_setup(struct usb_device *udev)
|
||||
/*
|
||||
* Update wMaxPacketSize for the default control endpoint:
|
||||
*/
|
||||
udev->default_ep_desc.wMaxPacketSize[0] =
|
||||
udev->ctrl_ep_desc.wMaxPacketSize[0] =
|
||||
udev->ddesc.bMaxPacketSize;
|
||||
|
||||
/*
|
||||
* Unsetup any existing USB transfer:
|
||||
*/
|
||||
usbd_transfer_unsetup(udev->default_xfer, USB_DEFAULT_XFER_MAX);
|
||||
usbd_transfer_unsetup(udev->ctrl_xfer, USB_CTRL_XFER_MAX);
|
||||
|
||||
/*
|
||||
* Try to setup a new USB transfer for the
|
||||
@ -2820,7 +2820,7 @@ usbd_default_transfer_setup(struct usb_device *udev)
|
||||
*/
|
||||
iface_index = 0;
|
||||
if (usbd_transfer_setup(udev, &iface_index,
|
||||
udev->default_xfer, usb_control_ep_cfg, USB_DEFAULT_XFER_MAX, NULL,
|
||||
udev->ctrl_xfer, usb_control_ep_cfg, USB_CTRL_XFER_MAX, NULL,
|
||||
&udev->device_mtx)) {
|
||||
DPRINTFN(0, "could not setup default "
|
||||
"USB transfer\n");
|
||||
@ -3001,13 +3001,13 @@ usbd_transfer_poll(struct usb_xfer **ppxfer, uint16_t max)
|
||||
USB_BUS_LOCK(xroot->bus);
|
||||
|
||||
/* check for clear stall */
|
||||
if (udev->default_xfer[1] != NULL) {
|
||||
if (udev->ctrl_xfer[1] != NULL) {
|
||||
|
||||
/* poll clear stall start */
|
||||
pm = &udev->cs_msg[0].hdr;
|
||||
(pm->pm_callback) (pm);
|
||||
/* poll clear stall done thread */
|
||||
pm = &udev->default_xfer[1]->
|
||||
pm = &udev->ctrl_xfer[1]->
|
||||
xroot->done_m[0].hdr;
|
||||
(pm->pm_callback) (pm);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ void usbd_transfer_done(struct usb_xfer *xfer, usb_error_t error);
|
||||
void usbd_transfer_enqueue(struct usb_xfer_queue *pq,
|
||||
struct usb_xfer *xfer);
|
||||
void usbd_transfer_setup_sub(struct usb_setup_params *parm);
|
||||
void usbd_default_transfer_setup(struct usb_device *udev);
|
||||
void usbd_ctrl_transfer_setup(struct usb_device *udev);
|
||||
void usbd_clear_data_toggle(struct usb_device *udev,
|
||||
struct usb_endpoint *ep);
|
||||
usb_callback_t usbd_do_request_callback;
|
||||
|
Loading…
Reference in New Issue
Block a user