1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** USBX Component */
16 /** */
17 /** Host Simulator Controller Driver */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define UX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "ux_api.h"
28 #include "ux_hcd_sim_host.h"
29
30
31 #if !defined(UX_HOST_STANDALONE)
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _ux_hcd_sim_host_request_transfer PORTABLE C */
37 /* 6.1.10 */
38 /* AUTHOR */
39 /* */
40 /* Chaoqiong Xiao, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function is the handler for all the transactions on the USB. */
45 /* The transfer request passed as parameter contains the endpoint and */
46 /* the device descriptors in addition to the type of transaction de */
47 /* be executed. This function routes the transfer request to */
48 /* according to the type of transfer to be executed. */
49 /* */
50 /* INPUT */
51 /* */
52 /* hcd_sim_host Pointer to host controller */
53 /* transfer_request Pointer to transfer request */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* Completion Status */
58 /* */
59 /* CALLS */
60 /* */
61 /* _ux_hcd_sim_host_request_bulk_transfer Request bulk transfer */
62 /* _ux_hcd_sim_host_request_control_transfer Request control */
63 /* transfer */
64 /* _ux_hcd_sim_host_request_interrupt_transfer Request interrupt */
65 /* transfer */
66 /* _ux_hcd_sim_host_request_isochronous_transfer Request isochronous */
67 /* transfer */
68 /* */
69 /* CALLED BY */
70 /* */
71 /* Host Simulator Controller Driver */
72 /* */
73 /* RELEASE HISTORY */
74 /* */
75 /* DATE NAME DESCRIPTION */
76 /* */
77 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
78 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
79 /* resulting in version 6.1 */
80 /* 01-31-2022 Chaoqiong Xiao Modified comment(s), */
81 /* added standalone support, */
82 /* resulting in version 6.1.10 */
83 /* */
84 /**************************************************************************/
_ux_hcd_sim_host_request_transfer(UX_HCD_SIM_HOST * hcd_sim_host,UX_TRANSFER * transfer_request)85 UINT _ux_hcd_sim_host_request_transfer(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER *transfer_request)
86 {
87
88 UX_ENDPOINT *endpoint;
89 UINT status = 0;
90
91
92 /* Get the pointer to the Endpoint. */
93 endpoint = (UX_ENDPOINT *) transfer_request -> ux_transfer_request_endpoint;
94
95 /* We reset the actual length field of the transfer request as a safety measure. */
96 transfer_request -> ux_transfer_request_actual_length = 0;
97
98 /* Isolate the endpoint type and route the transfer request. */
99 switch ((endpoint -> ux_endpoint_descriptor.bmAttributes) & UX_MASK_ENDPOINT_TYPE)
100 {
101
102 case UX_CONTROL_ENDPOINT:
103
104 status = _ux_hcd_sim_host_request_control_transfer(hcd_sim_host, transfer_request);
105 break;
106
107
108 case UX_BULK_ENDPOINT:
109
110 status = _ux_hcd_sim_host_request_bulk_transfer(hcd_sim_host, transfer_request);
111 break;
112
113 case UX_INTERRUPT_ENDPOINT:
114
115 status = _ux_hcd_sim_host_request_interrupt_transfer(hcd_sim_host, transfer_request);
116 break;
117
118 case UX_ISOCHRONOUS_ENDPOINT:
119
120 status = _ux_hcd_sim_host_request_isochronous_transfer(hcd_sim_host, 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 return(status);
128 }
129 #endif
130