1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** USBX Component                                                        */
17 /**                                                                       */
18 /**   OHCI Controller Driver                                              */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /* Include necessary system files.  */
25 
26 #define UX_SOURCE_CODE
27 
28 #include "ux_api.h"
29 #include "ux_hcd_ohci.h"
30 #include "ux_host_stack.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_hcd_ohci_request_transfer                       PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Chaoqiong Xiao, Microsoft Corporation                               */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*     This function is the handler for all the transactions on the USB.  */
46 /*     The transfer request passed as parameter contains the endpoint and */
47 /*     the device descriptors in addition to the type of transaction to   */
48 /*     be executed.                                                       */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    hcd_ohci                              Pointer to OHCI controller    */
53 /*    transfer_request                      Pointer to transfer request   */
54 /*                                                                        */
55 /*  OUTPUT                                                                */
56 /*                                                                        */
57 /*    Completion Status                                                   */
58 /*                                                                        */
59 /*  CALLS                                                                 */
60 /*                                                                        */
61 /*    _ux_hcd_ohci_request_bulk_transfer        Start bulk transfer       */
62 /*    _ux_hcd_ohci_request_control_transfer     Start control transfer    */
63 /*    _ux_hcd_ohci_request_interrupt_transfer   Start interrupt transfer  */
64 /*    _ux_hcd_ohci_request_isochronous_transfer Start isochronous transfer*/
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    OHCI Controller Driver                                              */
69 /*                                                                        */
70 /*  RELEASE HISTORY                                                       */
71 /*                                                                        */
72 /*    DATE              NAME                      DESCRIPTION             */
73 /*                                                                        */
74 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
75 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
76 /*                                            resulting in version 6.1    */
77 /*                                                                        */
78 /**************************************************************************/
_ux_hcd_ohci_request_transfer(UX_HCD_OHCI * hcd_ohci,UX_TRANSFER * transfer_request)79 UINT  _ux_hcd_ohci_request_transfer(UX_HCD_OHCI *hcd_ohci, UX_TRANSFER *transfer_request)
80 {
81 
82 UX_ENDPOINT     *endpoint;
83 UINT            status;
84 
85 
86     /* Get the pointer to the Endpoint.  */
87     endpoint =  (UX_ENDPOINT *) transfer_request -> ux_transfer_request_endpoint;
88 
89     /* We reset the actual length field of the transfer request as a safety measure.  */
90     transfer_request -> ux_transfer_request_actual_length =  0;
91 
92     /* Isolate the endpoint type and route the transfer request.  */
93     switch ((endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE)
94     {
95 
96     case UX_CONTROL_ENDPOINT:
97 
98         /* Control transfer.  */
99         status =  _ux_hcd_ohci_request_control_transfer(hcd_ohci, transfer_request);
100         break;
101 
102 
103     case UX_BULK_ENDPOINT:
104 
105         /* Bulk transfer.  */
106         status =  _ux_hcd_ohci_request_bulk_transfer(hcd_ohci, transfer_request);
107         break;
108 
109 
110     case UX_INTERRUPT_ENDPOINT:
111 
112         /* Interrupt transfer.  */
113         status =  _ux_hcd_ohci_request_interrupt_transfer(hcd_ohci, transfer_request);
114         break;
115 
116 
117     case UX_ISOCHRONOUS_ENDPOINT:
118 
119         /* Isochronous transfer.  */
120         status =  _ux_hcd_ohci_request_isochronous_transfer(hcd_ohci, transfer_request);
121         break;
122 
123     }
124 
125     /* Note that it is physically impossible to have a wrong endpoint type here
126        so no error checking!  */
127 
128     /* Return completion status.  */
129     return(status);
130 }
131 
132