mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 14:33:38 +00:00
DM USB: xHCI: add log level switch
Support log level options, which could change the related log level without code change. The new usage: -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x] eg: -s 8,xhci,1-2,2-2:log=D eg: -s 7,xhci,tablet eg: -s 7,xhci,1-2,2-2:tablet Note: please follow the board hardware design, assign the ports according to the receptacle connection Change-Id: I44639c7b076d21a40eb8f7b99cea8decc5c13c0c 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:
parent
be4406c8d9
commit
9f56364cad
@ -334,9 +334,11 @@ static int pci_xhci_xfer_complete(struct pci_xhci_vdev *xdev,
|
||||
int *do_intr);
|
||||
static inline int pci_xhci_is_valid_portnum(int n);
|
||||
static int pci_xhci_parse_tablet(struct pci_xhci_vdev *xdev, char *opts);
|
||||
static int pci_xhci_parse_log_level(struct pci_xhci_vdev *xdev, char *opts);
|
||||
|
||||
static struct pci_xhci_option_elem xhci_option_table[] = {
|
||||
{"tablet", pci_xhci_parse_tablet}
|
||||
{"tablet", pci_xhci_parse_tablet},
|
||||
{"log", pci_xhci_parse_log_level}
|
||||
};
|
||||
|
||||
static int
|
||||
@ -3071,9 +3073,9 @@ static void
|
||||
pci_xhci_device_usage(char *opt)
|
||||
{
|
||||
static const char *usage_str = "usage:\r\n"
|
||||
" -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]\r\n"
|
||||
" -s <n>,xhci,[bus1-port1,bus2-port2]:[tablet]:[log=x]\r\n"
|
||||
" eg: -s 8,xhci,1-2,2-2\r\n"
|
||||
" eg: -s 7,xhci,tablet\r\n"
|
||||
" eg: -s 7,xhci,tablet:log=D\r\n"
|
||||
" eg: -s 7,xhci,1-2,2-2:tablet\r\n"
|
||||
" Note: please follow the board hardware design, assign the "
|
||||
" ports according to the receptacle connection\r\n";
|
||||
@ -3082,6 +3084,37 @@ pci_xhci_device_usage(char *opt)
|
||||
UPRINTF(LFTL, "%s", usage_str);
|
||||
}
|
||||
|
||||
static int
|
||||
pci_xhci_parse_log_level(struct pci_xhci_vdev *xdev, char *opts)
|
||||
{
|
||||
char level;
|
||||
char *s, *o;
|
||||
int rc = 0;
|
||||
|
||||
assert(opts);
|
||||
|
||||
o = s = strdup(opts);
|
||||
if (!(s && s[0] == 'l' && s[1] == 'o' && s[2] == 'g')) {
|
||||
rc = -1;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
s = strchr(opts, '=');
|
||||
if (!s) {
|
||||
rc = -2;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
level = *(s+1);
|
||||
usb_parse_log_level(level);
|
||||
|
||||
errout:
|
||||
if (rc)
|
||||
printf("USB: fail to set log level, rc=%d\r\n", rc);
|
||||
free(o);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
pci_xhci_parse_bus_port(struct pci_xhci_vdev *xdev, char *opts)
|
||||
{
|
||||
@ -3322,11 +3355,6 @@ pci_xhci_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
||||
else
|
||||
error = 0;
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Will add command line option in subsequent patches for calling
|
||||
* usb_dev_sys_init if new parameters are used.
|
||||
*/
|
||||
if (usb_dev_sys_init(pci_xhci_native_usb_dev_conn_cb,
|
||||
pci_xhci_native_usb_dev_disconn_cb,
|
||||
pci_xhci_usb_dev_notify_cb,
|
||||
|
@ -219,3 +219,31 @@ usb_native_is_port_existed(uint8_t bus_num, uint8_t port_num)
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void usb_parse_log_level(char level)
|
||||
{
|
||||
switch (level) {
|
||||
case 'F':
|
||||
case 'f':
|
||||
usb_set_log_level(LFTL);
|
||||
break;
|
||||
case 'W':
|
||||
case 'w':
|
||||
usb_set_log_level(LWRN);
|
||||
break;
|
||||
case 'I':
|
||||
case 'i':
|
||||
usb_set_log_level(LINF);
|
||||
break;
|
||||
case 'D':
|
||||
case 'd':
|
||||
usb_set_log_level(LDBG);
|
||||
break;
|
||||
case 'V':
|
||||
case 'v':
|
||||
usb_set_log_level(LVRB);
|
||||
break;
|
||||
default:
|
||||
usb_set_log_level(LFTL);
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,7 @@ enum USB_ERRCODE {
|
||||
extern int usb_log_level;
|
||||
inline int usb_get_log_level(void) { return usb_log_level; }
|
||||
inline void usb_set_log_level(int level) { usb_log_level = level; }
|
||||
void usb_parse_log_level(char level);
|
||||
struct usb_devemu *usb_emu_finddev(char *name);
|
||||
int usb_native_is_bus_existed(uint8_t bus_num);
|
||||
int usb_native_is_ss_port(uint8_t bus_of_port);
|
||||
|
Loading…
Reference in New Issue
Block a user