DM USB: xHCI: support bulk and interrupt transfer for port mapper

Support USB mouse, USB keyboard and USB flash drive by enabling the
USB bulk and interrupt transfer for port mapper.

Change-Id: Ia202729e0cfb26fb44a6b278cf4306f2b0b6fa36
Signed-off-by: Wu, Xiaoguang <xiaoguang.wu@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Reviewed-by: Yu Wang <yu1.wang@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Wu, Xiaoguang
2018-04-15 23:52:31 +08:00
committed by lijinxia
parent 3b6392740e
commit 7687a3d0d7
5 changed files with 409 additions and 24 deletions

View File

@@ -34,7 +34,8 @@
#include <stdbool.h>
#include "types.h"
#define USB_MAX_XFER_BLOCKS 8
#define USB_MAX_XFER_BLOCKS 256
#define USB_XFER_OUT 0
#define USB_XFER_IN 1
@@ -64,6 +65,11 @@ enum token_type {
TOKEN_SETUP
};
enum usb_dev_type {
USB_DEV_STATIC = 0,
USB_DEV_PORT_MAPPER
};
struct usb_hci;
struct usb_device_request;
struct usb_data_xfer;
@@ -73,6 +79,7 @@ struct usb_devemu {
char *ue_emu; /* name of device emulation */
int ue_usbver; /* usb version: 2 or 3 */
int ue_usbspeed; /* usb device speed */
int ue_devtype;
/* instance creation */
void *(*ue_init)(void *pdata, char *opt);
@@ -134,6 +141,10 @@ struct usb_data_xfer {
int ndata; /* # of data items */
int head;
int tail;
void *dev; /* struct pci_xhci_dev_emu *dev */
int epid; /* related endpoint id */
int pid; /* token id */
int reset; /* detect ep reset */
int status;
pthread_mutex_t mtx;
};
@@ -153,15 +164,21 @@ enum USB_ERRCODE {
#define USB_DATA_OK(x, i) ((x)->data[(i)].buf != NULL)
#define USB_DATA_XFER_INIT(x) do { \
memset((x), 0, sizeof(*(x))); \
pthread_mutex_init(&((x)->mtx), NULL); \
} while (0)
#define USB_DATA_XFER_INIT(x) do { \
pthread_mutexattr_t attr; \
pthread_mutexattr_init(&attr); \
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
memset((x), 0, sizeof(*(x))); \
pthread_mutex_init(&((x)->mtx), &attr); \
} while (0)
#define USB_DATA_XFER_RESET(x) do { \
pthread_mutex_lock(&((x)->mtx)); \
memset((x)->data, 0, sizeof((x)->data)); \
(x)->ndata = 0; \
(x)->head = (x)->tail = 0; \
(x)->reset = 1; \
pthread_mutex_unlock((&(x)->mtx)); \
} while (0)
#define USB_DATA_XFER_LOCK(x) \