summaryrefslogtreecommitdiffstats
path: root/reverse-engineering
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2010-03-21 15:31:21 +0100
committerMichael Buesch <mb@bu3sch.de>2010-03-21 15:31:21 +0100
commitf11801da91f0b667b141d55496f570bc91285b63 (patch)
treec1469ce9e4eb8dd415be9b63cac5d35456cf0b8b /reverse-engineering
parent768ba1b72c55ec4a228f2b0b0ffdf5351e2ab17f (diff)
downloadtoprammer-f11801da91f0b667b141d55496f570bc91285b63.tar.xz
toprammer-f11801da91f0b667b141d55496f570bc91285b63.zip
Add qemu patches
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Diffstat (limited to 'reverse-engineering')
-rw-r--r--reverse-engineering/qemu-patches/001-qemu-usb-dump.patch120
-rw-r--r--reverse-engineering/qemu-patches/002-qemu-usbdev-quirks.patch17
-rw-r--r--reverse-engineering/qemu-patches/series2
3 files changed, 139 insertions, 0 deletions
diff --git a/reverse-engineering/qemu-patches/001-qemu-usb-dump.patch b/reverse-engineering/qemu-patches/001-qemu-usb-dump.patch
new file mode 100644
index 0000000..d00abc8
--- /dev/null
+++ b/reverse-engineering/qemu-patches/001-qemu-usb-dump.patch
@@ -0,0 +1,120 @@
+---
+ usb-linux.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 67 insertions(+), 2 deletions(-)
+
+--- qemu-0.12.3.orig/usb-linux.c
++++ qemu-0.12.3/usb-linux.c
+@@ -150,6 +150,57 @@ static int usb_host_close(USBHostDevice
+ static int parse_filter(const char *spec, struct USBAutoFilter *f);
+ static void usb_host_auto_check(void *unused);
+
++static unsigned int get_vendor_id(USBHostDevice *dev)
++{
++ return dev->descr[9] | ((unsigned int)dev->descr[8] << 8);
++}
++
++static unsigned int get_device_id(USBHostDevice *dev)
++{
++ return dev->descr[11] | ((unsigned int)dev->descr[10] << 8);
++}
++
++static char toAscii(char c)
++{
++ if (c >= 32 && c <= 126)
++ return c;
++ return '.';
++}
++
++static void dump(USBHostDevice *dev, const char *prefix, unsigned int ep, char *buf, size_t size)
++{
++ size_t i;
++ char ascii[17];
++ char tmp[2] = { 0, };
++
++ printf("Dev %04X:%04X EP%02X %s len=%u\n",
++ get_vendor_id(dev), get_device_id(dev),
++ ep, prefix, (unsigned int)size);
++
++ memset(ascii, 0, sizeof(ascii));
++ for (i = 0; i < size; i++) {
++ if (i % 16 == 0) {
++ if (i != 0) {
++ printf(" |%s|\n", ascii);
++ memset(ascii, 0, sizeof(ascii));
++ }
++ printf("[%04X]: ", i);
++ }
++ if (i % 2 == 0)
++ printf(" %02X", buf[i]);
++ else
++ printf("%02X", buf[i]);
++ tmp[0] = toAscii(buf[i]);
++ strcat(ascii, tmp);
++ }
++ if (strlen(ascii)) {
++ for ( ; i % 16; i++)
++ printf(" %s", (i % 2 == 0) ? " " : "");
++ printf(" |%s|", ascii);
++ }
++ printf("\n\n");
++}
++
+ static int is_isoc(USBHostDevice *s, int ep)
+ {
+ return s->endp_table[ep - 1].type == USBDEVFS_URB_TYPE_ISO;
+@@ -247,8 +298,14 @@ static void async_complete(void *opaque)
+ switch (aurb->urb.status) {
+ case 0:
+ p->len = aurb->urb.actual_length;
+- if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL)
++ if (aurb->urb.type == USBDEVFS_URB_TYPE_CONTROL) {
++ if (((char *)aurb->urb.buffer)[0] & 0x80)
++ dump(s, "Control IN", 0, aurb->urb.buffer, aurb->urb.buffer_length);
+ async_complete_ctrl(s, p);
++ } else {
++ if (p->pid == USB_TOKEN_IN)
++ dump(s, "Bulk IN", aurb->urb.endpoint, aurb->urb.buffer, aurb->urb.buffer_length);
++ }
+ break;
+
+ case -EPIPE:
+@@ -447,6 +504,8 @@ static int usb_host_handle_data(USBHostD
+
+ urb->usercontext = s;
+
++ if (p->pid != USB_TOKEN_IN)
++ dump(s, "Bulk OUT", urb->endpoint, urb->buffer, urb->buffer_length);
+ ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
+
+ dprintf("husb: data submit. ep 0x%x len %u aurb %p\n", urb->endpoint, p->len, aurb);
+@@ -538,16 +597,20 @@ static int usb_host_handle_control(USBHo
+ if (s->ctrl.req.bRequestType == 0) {
+ switch (s->ctrl.req.bRequest) {
+ case USB_REQ_SET_ADDRESS:
++ printf("USB SET_ADDRESS %u\n", value);
+ return usb_host_set_address(s, value);
+
+ case USB_REQ_SET_CONFIGURATION:
++ printf("USB SET_CONFIGURATION %u\n", value & 0xFF);
+ return usb_host_set_config(s, value & 0xff);
+ }
+ }
+
+ if (s->ctrl.req.bRequestType == 1 &&
+- s->ctrl.req.bRequest == USB_REQ_SET_INTERFACE)
++ s->ctrl.req.bRequest == USB_REQ_SET_INTERFACE) {
++ printf("USB SET_INTERFACE %u %u\n", index, value);
+ return usb_host_set_interface(s, index, value);
++ }
+
+ /* The rest are asynchronous */
+
+@@ -578,6 +641,8 @@ static int usb_host_handle_control(USBHo
+
+ urb->usercontext = s;
+
++ if (!(((char *)urb->buffer)[0] & 0x80))
++ dump(s, "Control OUT", 0, urb->buffer, urb->buffer_length);
+ ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
+
+ dprintf("husb: submit ctrl. len %u aurb %p\n", urb->buffer_length, aurb);
diff --git a/reverse-engineering/qemu-patches/002-qemu-usbdev-quirks.patch b/reverse-engineering/qemu-patches/002-qemu-usbdev-quirks.patch
new file mode 100644
index 0000000..7e6b692
--- /dev/null
+++ b/reverse-engineering/qemu-patches/002-qemu-usbdev-quirks.patch
@@ -0,0 +1,17 @@
+---
+ usb-linux.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- qemu-0.12.3.orig/usb-linux.c
++++ qemu-0.12.3/usb-linux.c
+@@ -446,6 +446,10 @@ static void usb_host_handle_reset(USBDev
+
+ dprintf("husb: reset device %u.%u\n", s->bus_num, s->addr);
+
++ if (((s->descr[8] << 8) | s->descr[9]) == 0x2471 &&
++ ((s->descr[10] << 8) | s->descr[11]) == 0x0853)
++ return;
++
+ ioctl(s->fd, USBDEVFS_RESET);
+
+ usb_host_claim_interfaces(s, s->configuration);
diff --git a/reverse-engineering/qemu-patches/series b/reverse-engineering/qemu-patches/series
new file mode 100644
index 0000000..5c78888
--- /dev/null
+++ b/reverse-engineering/qemu-patches/series
@@ -0,0 +1,2 @@
+001-qemu-usb-dump.patch
+002-qemu-usbdev-quirks.patch
bues.ch cgit interface