|
| 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 | +/** Port Specific */ |
| 18 | +/** */ |
| 19 | +/**************************************************************************/ |
| 20 | +/**************************************************************************/ |
| 21 | + |
| 22 | + |
| 23 | +/**************************************************************************/ |
| 24 | +/* */ |
| 25 | +/* PORT SPECIFIC C INFORMATION RELEASE */ |
| 26 | +/* */ |
| 27 | +/* ux_port.h Cortex-M33/GNU */ |
| 28 | +/* 6.3.0 */ |
| 29 | +/* */ |
| 30 | +/* AUTHOR */ |
| 31 | +/* */ |
| 32 | +/* Chaoqiong Xiao, Microsoft Corporation */ |
| 33 | +/* */ |
| 34 | +/* DESCRIPTION */ |
| 35 | +/* */ |
| 36 | +/* This file contains data type definitions that make USBX function */ |
| 37 | +/* identically on a variety of different processor architectures. */ |
| 38 | +/* */ |
| 39 | +/* RELEASE HISTORY */ |
| 40 | +/* */ |
| 41 | +/* DATE NAME DESCRIPTION */ |
| 42 | +/* */ |
| 43 | +/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */ |
| 44 | +/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */ |
| 45 | +/* resulting in version 6.1 */ |
| 46 | +/* 01-31-2022 Chaoqiong Xiao Modified comment(s), */ |
| 47 | +/* moved tx_api.h include and */ |
| 48 | +/* typedefs from ux_api.h, */ |
| 49 | +/* resulting in version 6.1.10 */ |
| 50 | +/* 10-31-2023 Chaoqiong Xiao Modified comment(s), */ |
| 51 | +/* added basic types guards, */ |
| 52 | +/* improved SLONG typedef, */ |
| 53 | +/* resulting in version 6.3.0 */ |
| 54 | +/* */ |
| 55 | +/**************************************************************************/ |
| 56 | + |
| 57 | +#ifndef UX_PORT_H |
| 58 | +#define UX_PORT_H |
| 59 | + |
| 60 | + |
| 61 | +/* Determine if the optional USBX user define file should be used. */ |
| 62 | + |
| 63 | +#ifdef UX_INCLUDE_USER_DEFINE_FILE |
| 64 | + |
| 65 | + |
| 66 | +/* Yes, include the user defines in ux_user.h. The defines in this file may |
| 67 | + alternately be defined on the command line. */ |
| 68 | + |
| 69 | +#include "ux_user.h" |
| 70 | +#endif |
| 71 | + |
| 72 | + |
| 73 | +/* Include library header files. */ |
| 74 | + |
| 75 | +#include <stdio.h> |
| 76 | +#include <string.h> |
| 77 | + |
| 78 | + |
| 79 | +#if !defined(UX_STANDALONE) |
| 80 | +#include "tx_api.h" |
| 81 | +#else |
| 82 | + |
| 83 | +/* VAR types used in UX, |
| 84 | + if TX still used, expects tx_api.h included before include this. */ |
| 85 | +#if !defined(TX_API_H) && !defined(TX_PORT_H) |
| 86 | + |
| 87 | +#include <stdint.h> |
| 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 | + |
| 243 | + |
| 244 | +/* Define interrupt lockout constructs to protect the memory allocation/release which could happen |
| 245 | + under ISR in the device stack. */ |
| 246 | + |
| 247 | +#define UX_INT_SAVE_AREA unsigned int old_interrupt_posture; |
| 248 | +#define UX_DISABLE_INTS old_interrupt_posture = tx_interrupt_control(TX_INT_DISABLE); |
| 249 | +#define UX_RESTORE_INTS tx_interrupt_control(old_interrupt_posture); |
| 250 | + |
| 251 | + |
| 252 | +/* Define the version ID of USBX. This may be utilized by the application. */ |
| 253 | + |
| 254 | +#ifdef UX_SYSTEM_INIT |
| 255 | +CHAR _ux_version_id[] = |
| 256 | + "Copyright (c) 2024 Microsoft Corporation. * USBX Cortex-M33/GNU Version 6.4.1 *"; |
| 257 | +#else |
| 258 | +extern CHAR _ux_version_id[]; |
| 259 | +#endif |
| 260 | + |
| 261 | +#endif |
| 262 | + |
0 commit comments