]> Zhao Yanbai Git Server - minix.git/commitdiff
Error checking for USB interrupt transfer
authorWojciech Zajac <wzajac@jpembedded.eu>
Mon, 2 Jun 2014 14:09:05 +0000 (16:09 +0200)
committerLionel Sambuc <lionel@minix3.org>
Mon, 28 Jul 2014 15:05:41 +0000 (17:05 +0200)
drivers/usbd/README.txt
drivers/usbd/hcd/hcd.c
drivers/usbd/hcd/musb/musb_core.c

index e18565bf9b5923fdba6343e067e709a120cfeb8e..c36055855c5508c350556e766463da1fdda4955a 100755 (executable)
@@ -3,7 +3,7 @@
 -------------------------------------------------------------------------------
 README file for "USBD" USB host controller driver.
 
-created march-may 2014, JPEmbedded (info@jpembedded.eu)
+created march-june 2014, JPEmbedded (info@jpembedded.eu)
 
 -------------------------------------------------------------------------------
 *                           KNOWN LIMITATIONS:                                *
@@ -13,4 +13,7 @@ created march-may 2014, JPEmbedded (info@jpembedded.eu)
 - DDEKit does not implement resource deallocation for corresponding thread
   creation (see ddekit_thread_terminate, ddekit_thread_create) thus resources
   are spilled
-- Driver assumes that there is no preemption for DDEKit threading
\ No newline at end of file
+- Driver assumes that there is no preemption for DDEKit threading
+- URBs are enqueued in DDEKit but not in USBD itself
+- DDEKit way of handling interface numbers is not explicitly defined, bitmask
+  formatting for it, is therefore hardcoded into USBD
index fcb2edf2456e272508b5dcbce657325a16492d9b..216eaa5282ee1d287f987f5033ee4a6e0a1d5ab8 100755 (executable)
@@ -804,8 +804,10 @@ hcd_data_transfer(hcd_device_state * this_device, hcd_datarequest * request)
                        request->data += transfer_len;
 
                        /* Total length shall not become negative */
-                       USB_ASSERT(request->size >= 0,
-                               "Invalid amount of data received");
+                       if (request->size < 0) {
+                               USB_MSG("Invalid amount of data received");
+                               return EXIT_FAILURE;
+                       }
 
 #ifdef DEBUG
                        /* TODO: REMOVEME (dumping of data transfer) */
@@ -813,7 +815,8 @@ hcd_data_transfer(hcd_device_state * this_device, hcd_datarequest * request)
                                int i;
                                USB_MSG("RECEIVED: %d", transfer_len);
                                for (i = 0; i < transfer_len; i++)
-                                       USB_MSG("%c",
+                                       USB_MSG("0x%02X: %c",
+                                       (request->data-transfer_len)[i],
                                        (request->data-transfer_len)[i]);
                        }
 #endif
@@ -835,7 +838,7 @@ hcd_data_transfer(hcd_device_state * this_device, hcd_datarequest * request)
 
                        /* Total length shall not become negative */
                        USB_ASSERT(request->size >= 0,
-                               "Invalid amount of data received");
+                               "Invalid amount of transfer data calculated");
 
                        /* Start actual data transfer */
                        d->tx_stage(d->private_data, &temp_req);
index 0c36e6ae370dd2d230fe8c814cb85c4d5d67e573..854d4769df12798f51be0ff3a82b6360d680acaa 100755 (executable)
@@ -795,13 +795,17 @@ musb_check_error(void * cfg, hcd_transfer transfer, hcd_direction dir)
 
        DEBUG_DUMP;
 
+       /* TODO: ISO transfer */
+       USB_ASSERT(HCD_TRANSFER_ISOCHRONOUS != transfer,
+               "ISO transfer not supported");
+
        r = ((musb_core_config *)cfg)->regs;
 
        /* Set EP and device address to be used in this command */
        musb_set_state((musb_core_config *)cfg);
 
-       /* TODO: In MUSB only EP0 is allowed to handle control transfers
-        * so there is no EP checking in this function */
+       /* TODO: More than one control EP? */
+       /* In MUSB EP0 has it's own registers for error handling */
        if (HCD_TRANSFER_CONTROL == transfer) {
                /* Get control status register */
                host_csr = HCD_RD2(r, MUSB_REG_HOST_CSR0);
@@ -831,7 +835,9 @@ musb_check_error(void * cfg, hcd_transfer transfer, hcd_direction dir)
                return EXIT_SUCCESS;
        }
 
-       if ((HCD_TRANSFER_BULK == transfer) && (HCD_DIRECTION_OUT == dir)) {
+       /* Non-control transfer error check,
+        * is based on transfer direction */
+       if (HCD_DIRECTION_OUT == dir) {
                /* Get RX status register */
                host_csr = HCD_RD2(r, MUSB_REG_HOST_TXCSR);
 
@@ -860,7 +866,7 @@ musb_check_error(void * cfg, hcd_transfer transfer, hcd_direction dir)
                return EXIT_SUCCESS;
        }
 
-       if ((HCD_TRANSFER_BULK == transfer) && (HCD_DIRECTION_IN == dir)) {
+       if (HCD_DIRECTION_IN == dir) {
                /* Get RX status register */
                host_csr = HCD_RD2(r, MUSB_REG_HOST_RXCSR);