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 /**   Port Specific                                                       */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  PORT SPECIFIC C INFORMATION                            RELEASE        */
27 /*                                                                        */
28 /*    ux_port.h                                            Generic        */
29 /*                                                           6.3.0        */
30 /*                                                                        */
31 /*  AUTHOR                                                                */
32 /*                                                                        */
33 /*    Chaoqiong Xiao, Microsoft Corporation                               */
34 /*                                                                        */
35 /*  DESCRIPTION                                                           */
36 /*                                                                        */
37 /*    This file contains data type definitions that make USBX function    */
38 /*    identically on a variety of different processor architectures.      */
39 /*                                                                        */
40 /*  RELEASE HISTORY                                                       */
41 /*                                                                        */
42 /*    DATE              NAME                      DESCRIPTION             */
43 /*                                                                        */
44 /*  12-31-2020     Chaoqiong Xiao           Initial Version 6.1.3         */
45 /*  01-31-2022     Chaoqiong Xiao           Modified comment(s),          */
46 /*                                            moved tx_api.h include and  */
47 /*                                            typedefs from ux_api.h,     */
48 /*                                            resulting in version 6.1.10 */
49 /*  10-31-2023     Chaoqiong Xiao           Modified comment(s),          */
50 /*                                            added basic types guards,   */
51 /*                                            improved SLONG typedef,     */
52 /*                                            resulting in version 6.3.0  */
53 /*                                                                        */
54 /**************************************************************************/
55 
56 #ifndef UX_PORT_H
57 #define UX_PORT_H
58 
59 
60 /* Determine if the optional USBX user define file should be used.  */
61 
62 #ifdef UX_INCLUDE_USER_DEFINE_FILE
63 
64 
65 /* Yes, include the user defines in ux_user.h. The defines in this file may
66    alternately be defined on the command line.  */
67 
68 #include "ux_user.h"
69 #endif
70 
71 
72 /* Include library header files.  */
73 
74 #include <stdio.h>
75 #include <string.h>
76 
77 
78 #if !defined(UX_STANDALONE)
79 #include "tx_api.h"
80 #else
81 
82 /* VAR types used in UX,
83    if TX still used, expects tx_api.h included before include this.  */
84 #if !defined(TX_API_H) && !defined(TX_PORT_H)
85 
86 #include <stdint.h>
87 
88 #ifndef VOID
89 #define VOID                                      void
90 typedef char                                      CHAR;
91 typedef unsigned char                             UCHAR;
92 typedef int                                       INT;
93 typedef unsigned int                              UINT;
94 typedef long                                      LONG;
95 typedef unsigned long                             ULONG;
96 typedef short                                     SHORT;
97 typedef unsigned short                            USHORT;
98 #endif
99 
100 #ifndef ULONG64_DEFINED
101 typedef uint64_t                                ULONG64;
102 #define ULONG64_DEFINED
103 #endif
104 
105 #ifndef ALIGN_TYPE_DEFINED
106 #define ALIGN_TYPE                              ULONG
107 #define ALIGN_TYPE_DEFINED
108 #endif
109 
110 #endif
111 #endif
112 
113 
114 /* CPU definition for X86 systems without preemptive timer function.
115    This will make USBX uses the controller for the timer. */
116 
117 #undef THREADX_X86_NO_PTIMER
118 
119 
120 /* For X86 systems, the define #define UX_USE_IO_INSTRUCTIONS should be used.  */
121 
122 
123 /* Define additional generic USBX types.  */
124 
125 #ifndef SLONG_DEFINED
126 typedef LONG                        SLONG;
127 #define SLONG_DEFINED
128 #endif
129 
130 
131 /*  Generic USBX Project constants follow.  */
132 
133 #ifndef UX_PERIODIC_RATE
134 #define UX_PERIODIC_RATE                                    100
135 #endif
136 
137 #ifndef UX_MAX_CLASS_DRIVER
138 #define UX_MAX_CLASS_DRIVER                                 2
139 #endif
140 
141 #ifndef UX_MAX_SLAVE_CLASS_DRIVER
142 #define UX_MAX_SLAVE_CLASS_DRIVER                           2
143 #endif
144 
145 #ifndef UX_MAX_HCD
146 #define UX_MAX_HCD                                          1
147 #endif
148 
149 #ifndef UX_MAX_DEVICES
150 #define UX_MAX_DEVICES                                      2
151 #endif
152 
153 #ifndef UX_MAX_ED
154 #define UX_MAX_ED                                           80
155 #endif
156 
157 #ifndef UX_MAX_TD
158 #define UX_MAX_TD                                           32
159 #endif
160 
161 #ifndef UX_MAX_ISO_TD
162 #define UX_MAX_ISO_TD                                       2
163 #endif
164 
165 #ifndef UX_HOST_ENUM_THREAD_STACK_SIZE
166 #define UX_HOST_ENUM_THREAD_STACK_SIZE                      (2*1024)
167 #endif
168 
169 #ifndef UX_THREAD_STACK_SIZE
170 #define UX_THREAD_STACK_SIZE                                (1*1024)
171 #endif
172 
173 #ifndef UX_THREAD_PRIORITY_ENUM
174 #define UX_THREAD_PRIORITY_ENUM                             20
175 #endif
176 
177 #ifndef UX_THREAD_PRIORITY_CLASS
178 #define UX_THREAD_PRIORITY_CLASS                            20
179 #endif
180 
181 #ifndef UX_THREAD_PRIORITY_KEYBOARD
182 #define UX_THREAD_PRIORITY_KEYBOARD                         20
183 #endif
184 
185 #ifndef UX_THREAD_PRIORITY_HCD
186 #define UX_THREAD_PRIORITY_HCD                              2
187 #endif
188 
189 #ifndef UX_THREAD_PRIORITY_DCD
190 #define UX_THREAD_PRIORITY_DCD                              2
191 #endif
192 
193 #ifndef UX_NO_TIME_SLICE
194 #define UX_NO_TIME_SLICE                                    0
195 #endif
196 
197 #ifndef UX_MAX_SLAVE_LUN
198 #define UX_MAX_SLAVE_LUN                                    1
199 #endif
200 
201 #ifndef UX_MAX_HOST_LUN
202 #define UX_MAX_HOST_LUN                                     1
203 #endif
204 
205 #ifndef UX_HOST_CLASS_STORAGE_MAX_MEDIA
206 #define UX_HOST_CLASS_STORAGE_MAX_MEDIA                     1
207 #endif
208 
209 #ifndef UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH
210 #define UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH                 256
211 #endif
212 
213 
214 #ifndef UX_SLAVE_REQUEST_DATA_MAX_LENGTH
215 #define UX_SLAVE_REQUEST_DATA_MAX_LENGTH                    2048
216 #endif
217 
218 #ifndef UX_USE_IO_INSTRUCTIONS
219 
220 /* Don't use IO instructions if this define is not set.  Default to memory mapped.  */
221 
222 #define inpb(a)                                            *((UCHAR *)  (a))
223 #define inpw(a)                                            *((USHORT *) (a))
224 #define inpl(a)                                            *((ULONG *)  (a))
225 #define outpb(a, b)                                        *((UCHAR *)  (a)) =  ((UCHAR)  (b))
226 #define outpw(a, b)                                        *((USHORT *) (a)) =  ((USHORT) (b))
227 #define outpl(a, b)                                        *((ULONG *)  (a)) =  ((ULONG)  (b))
228 #else
229 
230 
231 /* Define simple prototypes for non-memory mapped hardware access.  */
232 
233 UCHAR   inpb(ULONG);
234 USHORT  inpw(ULONG);
235 ULONG   inpl(ULONG);
236 
237 VOID    outpb(ULONG,UCHAR);
238 VOID    outpw(ULONG,USHORT);
239 VOID    outpl(ULONG,ULONG);
240 
241 #endif
242 /* Define local delay function for board specific bsps.  */
243 #ifdef TI_AM335
244     #define UX_BSP_SPECIFIC_DELAY_FUNCTION
245 #endif
246 
247 
248 /* Define interrupt lockout constructs to protect the memory allocation/release which could happen
249    under ISR in the device stack.  */
250 
251 #define UX_INT_SAVE_AREA        unsigned int  old_interrupt_posture;
252 #define UX_DISABLE_INTS         old_interrupt_posture =  tx_interrupt_control(TX_INT_DISABLE);
253 #define UX_RESTORE_INTS         tx_interrupt_control(old_interrupt_posture);
254 
255 
256 /* Define the version ID of USBX.  This may be utilized by the application.  */
257 
258 #ifdef  UX_SYSTEM_INIT
259 CHAR                            _ux_version_id[] =
260                                     "Copyright (c) Microsoft Corporation. All rights reserved. * USBX Generic Version 6.3.0 *";
261 #else
262 extern  CHAR                    _ux_version_id[];
263 #endif
264 
265 #endif
266 
267