aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2014-12-31 17:41:14 -0500
committerKevin O'Connor <kevin@koconnor.net>2015-01-07 10:13:46 -0500
commit2891a8323d4397a912123c066165ef9297b51607 (patch)
treeabf9dfba3fb232cb62bd5f46cd2a381e7a0f5ae0
parent65034a41325937681ea5c5db510b3193c129b62b (diff)
downloadseabios-2891a8323d4397a912123c066165ef9297b51607.zip
seabios-2891a8323d4397a912123c066165ef9297b51607.tar.gz
seabios-2891a8323d4397a912123c066165ef9297b51607.tar.bz2
usb: Control transfers always have an 8 byte command size
There is no need to pass 'cmdsize' to the usb drivers as the cmdsize is always 8 bytes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/hw/usb-ehci.c6
-rw-r--r--src/hw/usb-ehci.h2
-rw-r--r--src/hw/usb-ohci.c4
-rw-r--r--src/hw/usb-ohci.h2
-rw-r--r--src/hw/usb-uhci.c6
-rw-r--r--src/hw/usb-uhci.h2
-rw-r--r--src/hw/usb-xhci.c5
-rw-r--r--src/hw/usb-xhci.h2
-rw-r--r--src/hw/usb.c16
-rw-r--r--src/hw/usb.h2
10 files changed, 25 insertions, 22 deletions
diff --git a/src/hw/usb-ehci.c b/src/hw/usb-ehci.c
index a738316..41f8579 100644
--- a/src/hw/usb-ehci.c
+++ b/src/hw/usb-ehci.c
@@ -542,7 +542,7 @@ ehci_fill_tdbuf(struct ehci_qtd *td, u32 dest, int transfer)
#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)
@@ -563,9 +563,9 @@ ehci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
// 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;
}
diff --git a/src/hw/usb-ehci.h b/src/hw/usb-ehci.h
index 08ae046..88f7b6a 100644
--- a/src/hw/usb-ehci.h
+++ b/src/hw/usb-ehci.h
@@ -9,7 +9,7 @@ struct usb_pipe;
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);
diff --git a/src/hw/usb-ohci.c b/src/hw/usb-ohci.c
index 11fe9fa..42f8a06 100644
--- a/src/hw/usb-ohci.c
+++ b/src/hw/usb-ohci.c
@@ -459,7 +459,7 @@ wait_ed(struct ohci_ed *ed, int timeout)
#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();
@@ -481,7 +481,7 @@ ohci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
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;
diff --git a/src/hw/usb-ohci.h b/src/hw/usb-ohci.h
index 3dbc0e0..5a275a3 100644
--- a/src/hw/usb-ohci.h
+++ b/src/hw/usb-ohci.h
@@ -9,7 +9,7 @@ struct usb_pipe;
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);
diff --git a/src/hw/usb-uhci.c b/src/hw/usb-uhci.c
index 890b7d6..69c33ee 100644
--- a/src/hw/usb-uhci.c
+++ b/src/hw/usb-uhci.c
@@ -447,7 +447,7 @@ wait_td(struct uhci_td *td, u32 end)
#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)
@@ -478,8 +478,8 @@ uhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
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)
diff --git a/src/hw/usb-uhci.h b/src/hw/usb-uhci.h
index c5ba43d..bff70c6 100644
--- a/src/hw/usb-uhci.h
+++ b/src/hw/usb-uhci.h
@@ -9,7 +9,7 @@ struct usb_pipe;
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);
diff --git a/src/hw/usb-xhci.c b/src/hw/usb-xhci.c
index bacae11..fd58334 100644
--- a/src/hw/usb-xhci.c
+++ b/src/hw/usb-xhci.c
@@ -1069,7 +1069,7 @@ static void xhci_xfer_normal(struct xhci_pipe *pipe,
}
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)
@@ -1084,7 +1084,8 @@ xhci_send_pipe(struct usb_pipe *p, int dir, const void *cmd, int cmdsize
// 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)
diff --git a/src/hw/usb-xhci.h b/src/hw/usb-xhci.h
index fc1bf7f..c768c5b 100644
--- a/src/hw/usb-xhci.h
+++ b/src/hw/usb-xhci.h
@@ -12,7 +12,7 @@ void xhci_setup(void);
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);
diff --git a/src/hw/usb.c b/src/hw/usb.c
index 773057e..46e17df 100644
--- a/src/hw/usb.c
+++ b/src/hw/usb.c
@@ -46,23 +46,23 @@ usb_realloc_pipe(struct usbdevice_s *usbdev, struct usb_pipe *pipe
// 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);
}
}
@@ -118,15 +118,15 @@ int
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
diff --git a/src/hw/usb.h b/src/hw/usb.h
index 208d08f..efb5e6f 100644
--- a/src/hw/usb.h
+++ b/src/hw/usb.h
@@ -211,6 +211,8 @@ struct usb_endpoint_descriptor {
#define USB_ENDPOINT_XFER_INT 3
#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
+#define USB_CONTROL_SETUP_SIZE 8
+
/****************************************************************
* usb mass storage flags