From a553702c41879a83bb8931372d06e377fe88181d Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Wed, 23 Sep 2009 12:59:10 +0200 Subject: [PATCH] BLEH, WTF :( {s,g}et_configuration still won't work and I fucking don't know anything why added usb capture of linux when config my usb keyboard --- usb/4u.out | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ usb/core/core.c | 54 ++++++++++++++++------- usb/core/usb.c | 7 ++- usb/host/ohci.c | 5 +-- 4 files changed, 159 insertions(+), 20 deletions(-) create mode 100644 usb/4u.out diff --git a/usb/4u.out b/usb/4u.out new file mode 100644 index 0000000..d5a8495 --- /dev/null +++ b/usb/4u.out @@ -0,0 +1,113 @@ +read linux/Documentation/usb/usbmon.txt for details + +f4825500 2607204048 S Ci:4:001:0 s a3 00 0000 0001 0004 4 < +f4825500 2607204065 C Ci:4:001:0 0 4 = 01030100 +f4825500 2607204070 S Co:4:001:0 s 23 01 0010 0001 0000 0 +f4825500 2607204073 C Co:4:001:0 0 0 +f4825500 2607204075 S Ci:4:001:0 s a3 00 0000 0002 0004 4 < +f4825500 2607204080 C Ci:4:001:0 0 4 = 00010000 +f682c080 2607307372 S Ii:4:001:1 -115:128 2 < +f4825500 2607307392 S Ci:4:001:0 s a3 00 0000 0001 0004 4 < +f4825500 2607307399 C Ci:4:001:0 0 4 = 01030000 + +wtf?? out +f4825500 2607307412 S Co:4:001:0 s 23 03 0004 0001 0000 0 +f4825500 2607307416 C Co:4:001:0 0 0 + +wtf? in +f4825500 2607360706 S Ci:4:001:0 s a3 00 0000 0001 0004 4 < +f4825500 2607360732 C Ci:4:001:0 0 4 = 01030000 +f4825500 2607414040 S Ci:4:001:0 s a3 00 0000 0001 0004 4 < +f4825500 2607414050 C Ci:4:001:0 0 4 = 03030000 + +wtf?? out +f4825e00 2607467374 S Co:4:001:0 s 23 01 0014 0001 0000 0 +f4825e00 2607467380 C Co:4:001:0 0 0 + +get desc +f4825e00 2607467400 S Ci:4:000:0 s 80 06 0100 0000 0040 64 < +f4825e00 2607473739 C Ci:4:000:0 0 18 = 12011001 00000008 9f040e00 00010102 0001 +f4825e00 2607473751 S Co:4:001:0 s 23 03 0004 0001 0000 0 +f4825e00 2607473756 C Co:4:001:0 0 0 +f4825d00 2607527373 S Ci:4:001:0 s a3 00 0000 0001 0004 4 < +f4825d00 2607527400 C Ci:4:001:0 0 4 = 03030000 +f4825d00 2607580708 S Co:4:001:0 s 23 01 0014 0001 0000 0 +f4825d00 2607580714 C Co:4:001:0 0 0 + +mit 9 addressiert +f4825d00 2607580723 S Co:4:000:0 s 00 05 0009 0000 0000 0 +f4825d00 2607582747 C Co:4:000:0 0 0 + +get descriptor +f4825d00 2607600707 S Ci:4:009:0 s 80 06 0100 0000 0012 18 < +f4825d00 2607605749 C Ci:4:009:0 0 18 = 12011001 00000008 9f040e00 00010102 0001 +f4825d00 2607605763 S Ci:4:009:0 s 80 06 0200 0000 0009 9 < +f4825d00 2607610747 C Ci:4:009:0 0 9 = 09023b00 020102a0 19 +f4825d00 2607610755 S Ci:4:009:0 s 80 06 0200 0000 003b 59 < +f4825d00 2607621751 C Ci:4:009:0 0 59 = 09023b00 020102a0 19090400 00010301 01030921 00010001 22410007 05810308 + + +f4825d00 2607621768 S Ci:4:009:0 s 80 06 0300 0000 00ff 255 < +f4825d00 2607626747 C Ci:4:009:0 0 4 = 04030904 +f4825d00 2607626754 S Ci:4:009:0 s 80 06 0302 0409 00ff 255 < +f4825d00 2607637749 C Ci:4:009:0 0 50 = 32034300 6f006d00 70006100 71002000 49006e00 74006500 72006e00 65007400 +f4825d00 2607637759 S Ci:4:009:0 s 80 06 0301 0409 00ff 255 < +f4825d00 2607643751 C Ci:4:009:0 0 14 = 0e034300 6f006d00 70006100 7100 + +set config +f4825d00 2607643943 S Co:4:009:0 s 00 09 0001 0000 0000 0 +f4825d00 2607646750 C Co:4:009:0 0 0 + + +getstring +f4825d00 2607646771 S Ci:4:009:0 s 80 06 0302 0409 00ff 255 < +f4825d00 2607657755 C Ci:4:009:0 0 50 = 32034300 6f006d00 70006100 71002000 49006e00 74006500 72006e00 65007400 +getstring +f5abaf00 2607657825 S Ci:4:009:0 s 80 06 0303 0409 00ff 255 < +f5abaf00 2607668752 C Ci:4:009:0 0 50 = 32034300 6f006d00 70006100 71002000 49006e00 74006500 72006e00 65007400 + +set idle +f5abaf00 2607668869 S Co:4:009:0 s 21 0a 0000 0000 0000 0 +f5abaf00 2607671751 C Co:4:009:0 0 0 + +get?? +f5abaf00 2607671758 S Ci:4:009:0 s 81 06 2200 0000 0041 65 < +f5abaf00 2607683759 C Ci:4:009:0 0 65 = 05010906 a1010507 19e029e7 15002501 75019508 81027508 95018101 05081901 + + +f6273300 2607684009 S Co:4:009:0 s 21 09 0200 0000 0004 4 = 00000000 +f5abaf00 2607684216 S Ii:4:009:1 -115:16 8 < +f6273680 2607684488 S Ci:4:009:0 s 80 06 0304 0409 00ff 255 < +f6273300 2607687760 C Co:4:009:0 0 4 > +f6273680 2607697756 C Ci:4:009:0 0 50 = 32034300 6f006d00 70006100 71002000 49006e00 74006500 72006e00 65007400 +e5cf9d80 2607697888 S Co:4:009:0 s 21 0a 0000 0001 0000 0 +e5cf9d80 2607700758 C Co:4:009:0 0 0 +d9094380 2607701211 S Ci:4:009:0 s 81 06 2200 0001 01f3 499 < +d9094380 2607766777 C Ci:4:009:0 0 499 = 050c0901 a1018501 15002501 1ae9002a ea007501 95028106 95010ae2 00810675 +f4ae4000 2607768308 S Ci:4:009:0 s a1 01 0101 0001 0002 8 < +f4ae4000 2607771759 C Ci:4:009:0 0 4 = 00000000 +f4ae4000 2607771762 S Ci:4:009:0 s a1 01 0102 0001 0002 8 < +f4ae4000 2607775759 C Ci:4:009:0 0 4 = 00000000 +f4ae4000 2607775763 S Ci:4:009:0 s a1 01 0103 0001 0006 8 < +f4ae4000 2607779760 C Ci:4:009:0 0 4 = 00000000 +f4ae4000 2607779762 S Ci:4:009:0 s a1 01 0104 0001 0006 8 < +f4ae4000 2607783760 C Ci:4:009:0 0 5 = 04000000 00 +f4ae4000 2607783770 S Ci:4:009:0 s a1 01 0304 0001 0005 8 < +f4ae4000 2607787760 C Ci:4:009:0 0 5 = 04000000 00 +f4ae4000 2607787763 S Ci:4:009:0 s a1 01 0306 0001 0005 8 < +f4ae4000 2607791761 C Ci:4:009:0 0 5 = 06000000 00 +f4ae4000 2607791764 S Ci:4:009:0 s a1 01 0307 0001 0005 8 < +f4ae4000 2607795763 C Ci:4:009:0 0 5 = 07000000 00 +f4ae4000 2607795770 S Ci:4:009:0 s a1 01 0308 0001 0005 8 < +f4ae4000 2607799761 C Ci:4:009:0 0 5 = 08000000 00 +f4ae4000 2607799764 S Ci:4:009:0 s a1 01 0309 0001 0005 8 < +f4ae4000 2607803761 C Ci:4:009:0 0 5 = 09000000 00 +f4ae4800 2607803929 S Ii:4:009:2 -115:2 6 < +f5abaf00 2610182933 C Ii:4:009:1 0:16 8 = 00000700 00000000 +f5abaf00 2610182978 S Ii:4:009:1 -115:16 8 < +f5abaf00 2610310941 C Ii:4:009:1 0:16 8 = 00000000 00000000 +f5abaf00 2610310982 S Ii:4:009:1 -115:16 8 < +f5abaf00 2610694969 C Ii:4:009:1 0:16 8 = 00000700 00000000 +f5abaf00 2610695012 S Ii:4:009:1 -115:16 8 < +f5abaf00 2610758972 C Ii:4:009:1 0:16 8 = 00000000 00000000 +f5abaf00 2610759013 S Ii:4:009:1 -115:16 8 < diff --git a/usb/core/core.c b/usb/core/core.c index f279a89..d50c22b 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -112,26 +112,34 @@ struct usb_device *usb_add_device(u8 lowspeed, u32 reg) return (void*) -1; } -#define WTF +//#define WTF #ifdef WTF printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADING WTF :O lolololololo \n"); + printf("loolololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDNG WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDINGWTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDING WTF :Ololololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDING WTF :O llololololo \n"); + printf("lololololool PADDING WTF :O loololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDING WTF :O loloooloo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDING WTF :O lolololoolo \n"); + printf("lololololool PADDING WTF :O lololooolo \n"); + printf("lololololool PADDING WTF :O loloolololo \n"); printf("lololol PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lolololool PADDING WTF :O lolololololo \n"); + printf("lolololool PADDING WTF :O lololoololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lolololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); @@ -142,8 +150,8 @@ struct usb_device *usb_add_device(u8 lowspeed, u32 reg) printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); - printf("lololololool PADDING WTF :O lolololololo \n"); + printf("lololololool PADDING WTF :O loloolololo \n"); + printf("lololololool PADDING WTF lololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); printf("lololololool PADDING WTF :O lolololololo \n"); #endif @@ -160,31 +168,46 @@ struct usb_device *usb_add_device(u8 lowspeed, u32 reg) /* print device info */ lsusb(dev); + //HID only! +#define GET_PROTOCOL 0x03 +#define SET_PROTOCOL 0x0b +#define GETit 0xa1 +#define SETit 0x21 + + u8 buf[255]; #if 1 /* select configuration */ + wait_ms(500); ret = usb_set_configuration(dev, 1); printf("=============\nusb_set_configuration(ret: %d): %d\n", ret, dev->conf->bConfigurationValue); + wait_ms(500); printf("=============\nusb_get_configuration: %d (should be 1 here)\n", usb_get_configuration(dev)); #endif +#if 0 + memset(buf, 0, 0xff); + usb_control_msg(dev, 0x81, GET_DESCRIPTOR, 0x2200, 0x0, 0x41, buf, 0); + printf("wtf request\n"); + hexdump((void*)buf, 0x41); +#endif - u8 buf[8]; -#if 1 - /* select interface */ +#if 0 + /* set protocol */ + /* see p48 in HID spec */ memset(buf, 0, 8); - printf("interfacenumber: %d\n", dev->conf->intf->bInterfaceNumber); - usb_control_msg(dev, 0x01, SET_INTERFACE, 0, 0, 0, buf, 0); - printf("=============\nusb_set_interface: %d\n", 0); + usb_control_msg(dev, SETit, SET_PROTOCOL, 0, 0, 0, buf, 0); + printf("=============\nhid_set_protocol %d\n", 0); hexdump((void*)buf, 8); +#endif #if 0 memset(buf, 0, 8); - usb_control_msg(dev, 0x81, GET_INTERFACE, 0, 0, 4, buf, 0); + usb_control_msg(dev, GETit, GET_PROTOCOL, 0, 0, 4, buf, 0); printf("=============\nusb_get_interface: %d\n", buf[0]); hexdump((void*)buf, 8); -#endif #endif +#if 0 /* I just don't know why on some devices * {s,g}et_{configuration,interface} won't work. * may the setter works and getter are poorly implemented? @@ -201,6 +224,7 @@ struct usb_device *usb_add_device(u8 lowspeed, u32 reg) hexdump((void*)buf, 8); udelay(2000000); } +#endif #if 0 /* add device to device list */ diff --git a/usb/core/usb.c b/usb/core/usb.c index b73a33d..935e36f 100644 --- a/usb/core/usb.c +++ b/usb/core/usb.c @@ -292,6 +292,7 @@ s8 usb_set_address(struct usb_device *dev, u8 address) { cleargbuf(); usb_control_msg(dev, 0x00, SET_ADDRESS, address, 0, 0, gbuf, 0); + hexdump((void*) gbuf, 8); wait_ms(210); return 0; } @@ -309,8 +310,10 @@ u8 usb_get_configuration(struct usb_device *dev) s8 usb_set_configuration(struct usb_device *dev, u8 configuration) { cleargbuf(); - usb_control_msg(dev, 0x00, SET_CONFIGURATION, configuration, 0, 0, gbuf, 0); - wait_ms(50); + usb_control_msg(dev, 0x00, SET_CONFIGURATION, configuration<<8, 0, 0, gbuf, 0); + printf("=============\nafter usb_set_configuration:\n"); + hexdump((void*) gbuf, 8); + wait_ms(20); return 0; } diff --git a/usb/host/ohci.c b/usb/host/ohci.c index a7ef894..6feff77 100644 --- a/usb/host/ohci.c +++ b/usb/host/ohci.c @@ -191,10 +191,9 @@ void hcdi_fire(u32 reg) /* poll until edhead->headp is null */ do { sync_before_read(edhead, sizeof(struct endpoint_descriptor)); -//#ifdef _DU_OHCI_F +#ifdef _DU_OHCI_F printf("edhead->headp: 0x%08X\n", LE(edhead->headp)); -//#endif - udelay(10000); +#endif /* if halted, debug output plz. will break the transfer */ if((LE(edhead->headp) & OHCI_ENDPOINT_HALTED)) { -- 2.25.1