#define STACKQTDS 6
int
-ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize)
{
if (! CONFIG_USB_EHCI)
// Send setup pid on control transfers
td->qtd_next = (u32)MAKE_FLATPTR(GET_SEG(SS), td+1);
td->alt_next = EHCI_PTR_TERM;
- td->token = (ehci_explen(cmdsize) | QTD_STS_ACTIVE
+ td->token = (ehci_explen(USB_CONTROL_SETUP_SIZE) | QTD_STS_ACTIVE
| QTD_PID_SETUP | ehci_maxerr(3));
- ehci_fill_tdbuf(td, (u32)cmd, cmdsize);
+ ehci_fill_tdbuf(td, (u32)cmd, USB_CONTROL_SETUP_SIZE);
td++;
toggle = QTD_TOGGLE;
}
struct usb_pipe *ehci_realloc_pipe(struct usbdevice_s *usbdev
, struct usb_pipe *upipe
, struct usb_endpoint_descriptor *epdesc);
-int ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize);
int ehci_poll_intr(struct usb_pipe *p, void *data);
#define OHCI_TD_ALIGN 16
int
-ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize)
{
ASSERT32FLAT();
td->hwINFO = TD_DP_SETUP | TD_T_DATA0 | TD_CC;
td->hwCBP = (u32)cmd;
td->hwNextTD = (u32)&td[1];
- td->hwBE = (u32)cmd + cmdsize - 1;
+ td->hwBE = (u32)cmd + USB_CONTROL_SETUP_SIZE - 1;
td++;
toggle = TD_T_DATA1;
statuscmd = OHCI_CLF;
struct usb_pipe *ohci_realloc_pipe(struct usbdevice_s *usbdev
, struct usb_pipe *upipe
, struct usb_endpoint_descriptor *epdesc);
-int ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize);
int ohci_poll_intr(struct usb_pipe *p, void *data);
#define TDALIGN 16
int
-uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize)
{
if (! CONFIG_USB_UHCI)
struct uhci_td *td = &tds[tdpos++ % STACKTDS];
u32 nexttd = (u32)MAKE_FLATPTR(GET_SEG(SS), &tds[tdpos % STACKTDS]);
td->link = nexttd | UHCI_PTR_DEPTH;
- td->token = (uhci_explen(cmdsize) | (devaddr << TD_TOKEN_DEVADDR_SHIFT)
- | USB_PID_SETUP);
+ td->token = (uhci_explen(USB_CONTROL_SETUP_SIZE)
+ | (devaddr << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_SETUP);
td->buffer = (void*)cmd;
barrier();
td->status = (uhci_maxerr(3) | (lowspeed ? TD_CTRL_LS : 0)
struct usb_pipe *uhci_realloc_pipe(struct usbdevice_s *usbdev
, struct usb_pipe *upipe
, struct usb_endpoint_descriptor *epdesc);
-int uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize);
int uhci_poll_intr(struct usb_pipe *p, void *data);
}
int
-xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datalen)
{
if (!CONFIG_USB_XHCI)
// Set address command sent during xhci_alloc_pipe.
return 0;
- xhci_xfer_queue(pipe, (void*)req, 8, (TR_SETUP << 10) | TRB_TR_IDT
+ xhci_xfer_queue(pipe, (void*)req, USB_CONTROL_SETUP_SIZE
+ , (TR_SETUP << 10) | TRB_TR_IDT
| ((datalen ? (dir ? 3 : 2) : 0) << 16));
if (datalen)
xhci_xfer_queue(pipe, data, datalen, (TR_DATA << 10)
struct usb_pipe *xhci_realloc_pipe(struct usbdevice_s *usbdev
, struct usb_pipe *upipe
, struct usb_endpoint_descriptor *epdesc);
-int xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
+int xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd
, void *data, int datasize);
int xhci_poll_intr(struct usb_pipe *p, void *data);
// Send a message on a control pipe using the default control descriptor.
static int
-usb_send_pipe(struct usb_pipe *pipe_fl, int dir, const void *cmd, int cmdsize
+usb_send_pipe(struct usb_pipe *pipe_fl, int dir, const void *cmd
, void *data, int datasize)
{
switch (GET_LOWFLAT(pipe_fl->type)) {
default:
case USB_TYPE_UHCI:
- return uhci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+ return uhci_send_pipe(pipe_fl, dir, cmd, data, datasize);
case USB_TYPE_OHCI:
if (MODESEGMENT)
return -1;
- return ohci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+ return ohci_send_pipe(pipe_fl, dir, cmd, data, datasize);
case USB_TYPE_EHCI:
- return ehci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+ return ehci_send_pipe(pipe_fl, dir, cmd, data, datasize);
case USB_TYPE_XHCI:
if (MODESEGMENT)
return -1;
- return xhci_send_pipe(pipe_fl, dir, cmd, cmdsize, data, datasize);
+ return xhci_send_pipe(pipe_fl, dir, cmd, data, datasize);
}
}
usb_send_default_control(struct usb_pipe *pipe, const struct usb_ctrlrequest *req
, void *data)
{
- return usb_send_pipe(pipe, req->bRequestType & USB_DIR_IN
- , req, sizeof(*req), data, req->wLength);
+ return usb_send_pipe(pipe, req->bRequestType & USB_DIR_IN, req
+ , data, req->wLength);
}
// Send a message to a bulk endpoint
int
usb_send_bulk(struct usb_pipe *pipe_fl, int dir, void *data, int datasize)
{
- return usb_send_pipe(pipe_fl, dir, NULL, 0, data, datasize);
+ return usb_send_pipe(pipe_fl, dir, NULL, data, datasize);
}
// Check if a pipe for a given controller is on the freelist
#define USB_ENDPOINT_XFER_INT 3
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
+#define USB_CONTROL_SETUP_SIZE 8
+
/****************************************************************
* usb mass storage flags