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 /**   Host Simulator Controller Driver                                    */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define UX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "ux_api.h"
29 #include "ux_hcd_sim_host.h"
30 
31 
32 #if !defined(UX_HOST_STANDALONE)
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _ux_hcd_sim_host_request_transfer                   PORTABLE C      */
38 /*                                                           6.1.10       */
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 de   */
48 /*     be executed. This function routes the transfer request to          */
49 /*     according to the type of transfer to be executed.                  */
50 /*                                                                        */
51 /*  INPUT                                                                 */
52 /*                                                                        */
53 /*    hcd_sim_host                          Pointer to host controller    */
54 /*    transfer_request                      Pointer to transfer request   */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    Completion Status                                                   */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    _ux_hcd_sim_host_request_bulk_transfer        Request bulk transfer */
63 /*    _ux_hcd_sim_host_request_control_transfer     Request control       */
64 /*                                                  transfer              */
65 /*    _ux_hcd_sim_host_request_interrupt_transfer   Request interrupt     */
66 /*                                                  transfer              */
67 /*    _ux_hcd_sim_host_request_isochronous_transfer Request isochronous   */
68 /*                                                  transfer              */
69 /*                                                                        */
70 /*  CALLED BY                                                             */
71 /*                                                                        */
72 /*    Host Simulator Controller Driver                                    */
73 /*                                                                        */
74 /*  RELEASE HISTORY                                                       */
75 /*                                                                        */
76 /*    DATE              NAME                      DESCRIPTION             */
77 /*                                                                        */
78 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
79 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
80 /*                                            resulting in version 6.1    */
81 /*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
82 /*                                            added standalone support,   */
83 /*                                            resulting in version 6.1.10 */
84 /*                                                                        */
85 /**************************************************************************/
_ux_hcd_sim_host_request_transfer(UX_HCD_SIM_HOST * hcd_sim_host,UX_TRANSFER * transfer_request)86 UINT  _ux_hcd_sim_host_request_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request)
87 {
88 
89 UX_ENDPOINT     *endpoint;
90 UINT            status = 0;
91 
92 
93     /* Get the pointer to the Endpoint.  */
94     endpoint =  (UX_ENDPOINT *) transfer_request -> ux_transfer_request_endpoint;
95 
96     /* We reset the actual length field of the transfer request as a safety measure.  */
97     transfer_request -> ux_transfer_request_actual_length =  0;
98 
99     /* Isolate the endpoint type and route the transfer request.  */
100     switch ((endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE)
101     {
102 
103     case UX_CONTROL_ENDPOINT:
104 
105         status =  _ux_hcd_sim_host_request_control_transfer(hcd_sim_host, transfer_request);
106         break;
107 
108 
109     case UX_BULK_ENDPOINT:
110 
111         status =  _ux_hcd_sim_host_request_bulk_transfer(hcd_sim_host, transfer_request);
112         break;
113 
114     case UX_INTERRUPT_ENDPOINT:
115 
116         status =  _ux_hcd_sim_host_request_interrupt_transfer(hcd_sim_host, transfer_request);
117         break;
118 
119     case UX_ISOCHRONOUS_ENDPOINT:
120 
121         status =  _ux_hcd_sim_host_request_isochronous_transfer(hcd_sim_host, transfer_request);
122         break;
123 
124     }
125 
126     /* Note that it is physically impossible to have a wrong endpoint type here
127        so no error checking.  */
128     return(status);
129 }
130 #endif
131