X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=usb%2Fcore%2Fcore.c;h=34a853798119dc19125ae54804a8514988b4551d;hb=5e7b3fe7025e9b039c5ab8d4cd9b4af088b70303;hp=5a7c45ef9c5fc1f2e0416ccdfd9f68687cca0f6c;hpb=a9dd904d3fb1eace1230e71ff73c1d43e39b9f7f;p=ppcskel.git diff --git a/usb/core/core.c b/usb/core/core.c index 5a7c45e..34a8537 100644 --- a/usb/core/core.c +++ b/usb/core/core.c @@ -45,12 +45,12 @@ /** * Initialize USB stack. */ -void usb_init() +void usb_init(u32 reg) { core.drivers = list_create(); core.devices = list_create(); core.nextaddress = 1; - hcdi_init(); + hcdi_init(reg); } /** @@ -86,13 +86,17 @@ void usb_periodic() * for the core. usb_add_device expected that * the device answers to address zero. */ -struct usb_device *usb_add_device() +struct usb_device *usb_add_device(u8 lowspeed, u32 reg) { struct usb_device *dev = (struct usb_device *) malloc(sizeof(struct usb_device)); dev->conf = (struct usb_conf *) malloc(sizeof(struct usb_conf)); dev->address = 0; - /* send at first time only 8 bytes */ - dev->bMaxPacketSize0 = 8; + dev->fullspeed = lowspeed ? 0 : 1; + /* send at first time only 8 bytes for lowspeed devices + * 64 bytes for fullspeed + */ + dev->bMaxPacketSize0 = lowspeed ? 8 : 64; + dev->ohci = reg; dev->epSize[0] = 64; dev->epSize[1] = 64; @@ -108,7 +112,6 @@ struct usb_device *usb_add_device() return (void*) -1; } - u8 buf[8]; //#define WTF #ifdef WTF printf("lololololool PADDING WTF :O lolololololo \n"); @@ -157,20 +160,25 @@ struct usb_device *usb_add_device() /* print device info */ lsusb(dev); +#if 0 /* select configuration */ ret = usb_set_configuration(dev, dev->conf->bConfigurationValue); printf("=============\nusb_set_configuration(ret: %d) %d\n", ret, dev->conf->bConfigurationValue); printf("=============\nusb_get_configuration: %d\n", usb_get_configuration(dev)); +#endif +#if 0 + u8 buf[8]; memset(buf, 0, 8); - usb_control_msg(dev, 0x00, SET_INTERFACE, 0, dev->conf->intf->bInterfaceNumber, 8, buf, 0); + usb_control_msg(dev, 0x00, SET_INTERFACE, 0, dev->conf->intf->bInterfaceNumber, 0, buf, 0); printf("=============\nusb_set_interface: %d\n", dev->conf->intf->bInterfaceNumber); hexdump((void*)buf, 8); memset(buf, 0, 8); - usb_control_msg(dev, 0x80, GET_INTERFACE, 0, 0, 8, buf, 0); + usb_control_msg(dev, 0x81, GET_INTERFACE, 0, dev->conf->intf->bInterfaceNumber, 8, buf, 0); printf("=============\nusb_get_interface: %d\n", buf[0]); hexdump((void*)buf, 8); +#endif #if 0 /* add device to device list */ @@ -200,7 +208,7 @@ void lsusb(struct usb_device *dev) printf("iProduct(0x%02X): \"%s\"\n", dev->iProduct, dev->iProduct ? usb_get_string_simple(dev, dev->iProduct) : "no String"); printf("iSerialNumber(0x%02X): \"%s\"\n", dev->iSerialNumber, dev->iSerialNumber ? usb_get_string_simple(dev, dev->iSerialNumber) : "no String"); printf("bNumConfigurations 0x%02X\n", dev->bNumConfigurations); - + u8 c, i, e; struct usb_conf *conf = dev->conf; for(c=0; c <= dev->bNumConfigurations; c++) { @@ -239,7 +247,7 @@ void lsusb(struct usb_device *dev) ed = ed->next; } //endpoint - + ifs = ifs->next; } //interface @@ -355,7 +363,7 @@ u16 usb_submit_irp(struct usb_irp *irp) togl = togl ? 0 : 1; /**** send token ****/ - hcdi_enqueue(td); + hcdi_enqueue(td, irp->dev->ohci); /***************** Data Stage ***********************/ /** @@ -413,7 +421,7 @@ u16 usb_submit_irp(struct usb_irp *irp) } /**** send token ****/ - hcdi_enqueue(td); + hcdi_enqueue(td, irp->dev->ohci); /* pruefe ob noch weitere Pakete vom Device abgeholt werden muessen */ restlength = restlength - irp->epsize; @@ -440,7 +448,7 @@ u16 usb_submit_irp(struct usb_irp *irp) td->pid = USB_PID_IN; } /**** send token ****/ - hcdi_enqueue(td); + hcdi_enqueue(td, irp->dev->ohci); free(td); break; @@ -482,7 +490,7 @@ u16 usb_submit_irp(struct usb_irp *irp) else togl = 0; /**** send token ****/ - hcdi_enqueue(td); + hcdi_enqueue(td, irp->dev->ohci); free(td); } /* next togl */ @@ -493,7 +501,7 @@ u16 usb_submit_irp(struct usb_irp *irp) break; } - hcdi_fire(); + hcdi_fire(irp->dev->ohci); return 1; } @@ -513,6 +521,7 @@ struct usb_transfer_descriptor *usb_create_transfer_descriptor(struct usb_irp * td->iso = 0; td->state = USB_TRANSFER_DESCR_NONE; td->maxp = irp->epsize; + td->fullspeed = irp->dev->fullspeed; return td; }