Revision 376253ec usb-linux.c
b/usb-linux.c | ||
---|---|---|
32 | 32 |
|
33 | 33 |
#include "qemu-common.h" |
34 | 34 |
#include "qemu-timer.h" |
35 |
#include "console.h"
|
|
35 |
#include "monitor.h"
|
|
36 | 36 |
|
37 | 37 |
#include <dirent.h> |
38 | 38 |
#include <sys/ioctl.h> |
... | ... | |
985 | 985 |
|
986 | 986 |
USBDevice *usb_host_device_open(const char *devname) |
987 | 987 |
{ |
988 |
Monitor *mon = cur_mon; |
|
988 | 989 |
int bus_num, addr; |
989 | 990 |
char product_name[PRODUCT_NAME_SZ]; |
990 | 991 |
|
... | ... | |
998 | 999 |
return NULL; |
999 | 1000 |
|
1000 | 1001 |
if (hostdev_find(bus_num, addr)) { |
1001 |
term_printf("husb: host usb device %d.%d is already open\n", bus_num, addr); |
|
1002 |
monitor_printf(mon, "husb: host usb device %d.%d is already open\n", |
|
1003 |
bus_num, addr); |
|
1002 | 1004 |
return NULL; |
1003 | 1005 |
} |
1004 | 1006 |
|
... | ... | |
1149 | 1151 |
*/ |
1150 | 1152 |
static int usb_host_read_file(char *line, size_t line_size, const char *device_file, const char *device_name) |
1151 | 1153 |
{ |
1154 |
Monitor *mon = cur_mon; |
|
1152 | 1155 |
FILE *f; |
1153 | 1156 |
int ret = 0; |
1154 | 1157 |
char filename[PATH_MAX]; |
... | ... | |
1161 | 1164 |
fclose(f); |
1162 | 1165 |
ret = 1; |
1163 | 1166 |
} else { |
1164 |
term_printf("husb: could not open %s\n", filename);
|
|
1167 |
monitor_printf(mon, "husb: could not open %s\n", filename);
|
|
1165 | 1168 |
} |
1166 | 1169 |
|
1167 | 1170 |
return ret; |
... | ... | |
1254 | 1257 |
*/ |
1255 | 1258 |
static int usb_host_scan(void *opaque, USBScanFunc *func) |
1256 | 1259 |
{ |
1260 |
Monitor *mon = cur_mon; |
|
1257 | 1261 |
FILE *f = 0; |
1258 | 1262 |
DIR *dir = 0; |
1259 | 1263 |
int ret = 0; |
... | ... | |
1292 | 1296 |
} |
1293 | 1297 |
found_devices: |
1294 | 1298 |
if (!usb_fs_type) { |
1295 |
term_printf("husb: unable to access USB devices\n");
|
|
1299 |
monitor_printf(mon, "husb: unable to access USB devices\n");
|
|
1296 | 1300 |
return -ENOENT; |
1297 | 1301 |
} |
1298 | 1302 |
|
1299 | 1303 |
/* the module setting (used later for opening devices) */ |
1300 | 1304 |
usb_host_device_path = qemu_mallocz(strlen(devpath)+1); |
1301 | 1305 |
strcpy(usb_host_device_path, devpath); |
1302 |
term_printf("husb: using %s file-system with %s\n", fs_type[usb_fs_type], usb_host_device_path); |
|
1306 |
monitor_printf(mon, "husb: using %s file-system with %s\n", |
|
1307 |
fs_type[usb_fs_type], usb_host_device_path); |
|
1303 | 1308 |
} |
1304 | 1309 |
|
1305 | 1310 |
switch (usb_fs_type) { |
... | ... | |
1606 | 1611 |
const char *product_name, |
1607 | 1612 |
int speed) |
1608 | 1613 |
{ |
1614 |
Monitor *mon = cur_mon; |
|
1609 | 1615 |
const char *class_str, *speed_str; |
1610 | 1616 |
|
1611 | 1617 |
switch(speed) { |
... | ... | |
1623 | 1629 |
break; |
1624 | 1630 |
} |
1625 | 1631 |
|
1626 |
term_printf(" Device %d.%d, speed %s Mb/s\n",
|
|
1632 |
monitor_printf(mon, " Device %d.%d, speed %s Mb/s\n",
|
|
1627 | 1633 |
bus_num, addr, speed_str); |
1628 | 1634 |
class_str = usb_class_str(class_id); |
1629 | 1635 |
if (class_str) |
1630 |
term_printf(" %s:", class_str);
|
|
1636 |
monitor_printf(mon, " %s:", class_str);
|
|
1631 | 1637 |
else |
1632 |
term_printf(" Class %02x:", class_id);
|
|
1633 |
term_printf(" USB device %04x:%04x", vendor_id, product_id);
|
|
1638 |
monitor_printf(mon, " Class %02x:", class_id);
|
|
1639 |
monitor_printf(mon, " USB device %04x:%04x", vendor_id, product_id);
|
|
1634 | 1640 |
if (product_name[0] != '\0') |
1635 |
term_printf(", %s", product_name);
|
|
1636 |
term_printf("\n");
|
|
1641 |
monitor_printf(mon, ", %s", product_name);
|
|
1642 |
monitor_printf(mon, "\n");
|
|
1637 | 1643 |
} |
1638 | 1644 |
|
1639 | 1645 |
static int usb_host_info_device(void *opaque, int bus_num, int addr, |
... | ... | |
1663 | 1669 |
snprintf(str, size, "%x", val); |
1664 | 1670 |
} |
1665 | 1671 |
|
1666 |
void usb_host_info(void)
|
|
1672 |
void usb_host_info(Monitor *mon)
|
|
1667 | 1673 |
{ |
1668 | 1674 |
struct USBAutoFilter *f; |
1669 | 1675 |
|
1670 | 1676 |
usb_host_scan(NULL, usb_host_info_device); |
1671 | 1677 |
|
1672 | 1678 |
if (usb_auto_filter) |
1673 |
term_printf(" Auto filters:\n");
|
|
1679 |
monitor_printf(mon, " Auto filters:\n");
|
|
1674 | 1680 |
for (f = usb_auto_filter; f; f = f->next) { |
1675 | 1681 |
char bus[10], addr[10], vid[10], pid[10]; |
1676 | 1682 |
dec2str(f->bus_num, bus, sizeof(bus)); |
1677 | 1683 |
dec2str(f->addr, addr, sizeof(addr)); |
1678 | 1684 |
hex2str(f->vendor_id, vid, sizeof(vid)); |
1679 | 1685 |
hex2str(f->product_id, pid, sizeof(pid)); |
1680 |
term_printf(" Device %s.%s ID %s:%s\n", bus, addr, vid, pid); |
|
1686 |
monitor_printf(mon, " Device %s.%s ID %s:%s\n", |
|
1687 |
bus, addr, vid, pid); |
|
1681 | 1688 |
} |
1682 | 1689 |
} |
Also available in: Unified diff