|
| 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 | +/** ThreadX Component */ |
| 17 | +/** */ |
| 18 | +/** Port Specific */ |
| 19 | +/** */ |
| 20 | +/**************************************************************************/ |
| 21 | +/**************************************************************************/ |
| 22 | + |
| 23 | + |
| 24 | +/**************************************************************************/ |
| 25 | +/* */ |
| 26 | +/* PORT SPECIFIC C INFORMATION RELEASE */ |
| 27 | +/* */ |
| 28 | +/* tx_port.h RXv1/CCRX */ |
| 29 | +/* 6.1.8 */ |
| 30 | +/* */ |
| 31 | +/* AUTHOR */ |
| 32 | +/* */ |
| 33 | +/* William E. Lamie, Microsoft Corporation */ |
| 34 | +/* */ |
| 35 | +/* DESCRIPTION */ |
| 36 | +/* */ |
| 37 | +/* This file contains data type definitions that make the ThreadX */ |
| 38 | +/* real-time kernel function identically on a variety of different */ |
| 39 | +/* processor architectures. For example, the size or number of bits */ |
| 40 | +/* in an "int" data type vary between microprocessor architectures and */ |
| 41 | +/* even C compilers for the same microprocessor. ThreadX does not */ |
| 42 | +/* directly use native C data types. Instead, ThreadX creates its */ |
| 43 | +/* own special types that can be mapped to actual data types by this */ |
| 44 | +/* file to guarantee consistency in the interface and functionality. */ |
| 45 | +/* */ |
| 46 | +/* RELEASE HISTORY */ |
| 47 | +/* */ |
| 48 | +/* DATE NAME DESCRIPTION */ |
| 49 | +/* */ |
| 50 | +/* 08-02-2021 William E. Lamie Initial Version 6.1.8 */ |
| 51 | +/* */ |
| 52 | +/**************************************************************************/ |
| 53 | + |
| 54 | +#ifndef TX_PORT_H |
| 55 | +#define TX_PORT_H |
| 56 | + |
| 57 | +/* Determine if the optional ThreadX user define file should be used. */ |
| 58 | + |
| 59 | +#ifdef TX_INCLUDE_USER_DEFINE_FILE |
| 60 | + |
| 61 | + |
| 62 | +/* Yes, include the user defines in tx_user.h. The defines in this file may |
| 63 | + alternately be defined on the command line. */ |
| 64 | + |
| 65 | +#include "tx_user.h" |
| 66 | +#endif |
| 67 | + |
| 68 | +/* Define ThreadX basic types for this port. */ |
| 69 | + |
| 70 | +#define VOID void |
| 71 | +typedef char CHAR; |
| 72 | +typedef unsigned char UCHAR; |
| 73 | +typedef int INT; |
| 74 | +typedef unsigned int UINT; |
| 75 | +typedef long LONG; |
| 76 | +typedef unsigned long ULONG; |
| 77 | +typedef short SHORT; |
| 78 | +typedef unsigned short USHORT; |
| 79 | + |
| 80 | + |
| 81 | +/* Define the priority levels for ThreadX. Legal values range |
| 82 | + from 32 to 1024 and MUST be evenly divisible by 32. */ |
| 83 | + |
| 84 | +#ifndef TX_MAX_PRIORITIES |
| 85 | +#define TX_MAX_PRIORITIES 32 |
| 86 | +#endif |
| 87 | + |
| 88 | + |
| 89 | +/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during |
| 90 | + thread creation is less than this value, the thread create call will return an error. */ |
| 91 | + |
| 92 | +#ifndef TX_MINIMUM_STACK |
| 93 | +#define TX_MINIMUM_STACK 256 /* Minimum stack size for this port */ |
| 94 | +#endif |
| 95 | + |
| 96 | + |
| 97 | +/* Define the system timer thread's default stack size and priority. These are only applicable |
| 98 | + if TX_TIMER_PROCESS_IN_ISR is not defined. */ |
| 99 | + |
| 100 | +#ifndef TX_TIMER_THREAD_STACK_SIZE |
| 101 | +#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */ |
| 102 | +#endif |
| 103 | + |
| 104 | +#ifndef TX_TIMER_THREAD_PRIORITY |
| 105 | +#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */ |
| 106 | +#endif |
| 107 | + |
| 108 | +#ifndef TX_TRACE_TIME_SOURCE |
| 109 | +#define TX_TRACE_TIME_SOURCE ++_tx_trace_simulated_time |
| 110 | +#endif |
| 111 | +#ifndef TX_TRACE_TIME_MASK |
| 112 | +#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL |
| 113 | +#endif |
| 114 | + |
| 115 | + |
| 116 | +/* Define the port specific options for the _tx_build_options variable. This variable indicates |
| 117 | + how the ThreadX library was built. */ |
| 118 | + |
| 119 | +#define TX_PORT_SPECIFIC_BUILD_OPTIONS 0 |
| 120 | + |
| 121 | + |
| 122 | +/* Define the in-line initialization constant so that modules with in-line |
| 123 | + initialization capabilities can prevent their initialization from being |
| 124 | + a function call. */ |
| 125 | + |
| 126 | +#define TX_INLINE_INITIALIZATION |
| 127 | + |
| 128 | + |
| 129 | +/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is |
| 130 | + disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack |
| 131 | + checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING |
| 132 | + define is negated, thereby forcing the stack fill which is necessary for the stack checking |
| 133 | + logic. */ |
| 134 | + |
| 135 | +#ifdef TX_ENABLE_STACK_CHECKING |
| 136 | +#undef TX_DISABLE_STACK_FILLING |
| 137 | +#endif |
| 138 | + |
| 139 | + |
| 140 | +/* Define the TX_THREAD control block extensions for this port. The main reason |
| 141 | + for the multiple macros is so that backward compatibility can be maintained with |
| 142 | + existing ThreadX kernel awareness modules. */ |
| 143 | + |
| 144 | +#define TX_THREAD_EXTENSION_0 |
| 145 | +#define TX_THREAD_EXTENSION_1 |
| 146 | +#define TX_THREAD_EXTENSION_2 |
| 147 | +#define TX_THREAD_EXTENSION_3 |
| 148 | + |
| 149 | + |
| 150 | +/* Define the port extensions of the remaining ThreadX objects. */ |
| 151 | + |
| 152 | +#define TX_BLOCK_POOL_EXTENSION |
| 153 | +#define TX_BYTE_POOL_EXTENSION |
| 154 | +#define TX_EVENT_FLAGS_GROUP_EXTENSION |
| 155 | +#define TX_MUTEX_EXTENSION |
| 156 | +#define TX_QUEUE_EXTENSION |
| 157 | +#define TX_SEMAPHORE_EXTENSION |
| 158 | +#define TX_TIMER_EXTENSION |
| 159 | + |
| 160 | + |
| 161 | +/* Define the user extension field of the thread control block. Nothing |
| 162 | + additional is needed for this port so it is defined as white space. */ |
| 163 | + |
| 164 | +#ifndef TX_THREAD_USER_EXTENSION |
| 165 | +#define TX_THREAD_USER_EXTENSION |
| 166 | +#endif |
| 167 | + |
| 168 | + |
| 169 | +/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete, |
| 170 | + tx_thread_shell_entry, and tx_thread_terminate. */ |
| 171 | + |
| 172 | + |
| 173 | +#define TX_THREAD_CREATE_EXTENSION(thread_ptr) |
| 174 | +#define TX_THREAD_DELETE_EXTENSION(thread_ptr) |
| 175 | +#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) |
| 176 | +#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) |
| 177 | + |
| 178 | + |
| 179 | +/* Define the ThreadX object creation extensions for the remaining objects. */ |
| 180 | + |
| 181 | +#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr) |
| 182 | +#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr) |
| 183 | +#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr) |
| 184 | +#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr) |
| 185 | +#define TX_QUEUE_CREATE_EXTENSION(queue_ptr) |
| 186 | +#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr) |
| 187 | +#define TX_TIMER_CREATE_EXTENSION(timer_ptr) |
| 188 | + |
| 189 | + |
| 190 | +/* Define the ThreadX object deletion extensions for the remaining objects. */ |
| 191 | + |
| 192 | +#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr) |
| 193 | +#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr) |
| 194 | +#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr) |
| 195 | +#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr) |
| 196 | +#define TX_QUEUE_DELETE_EXTENSION(queue_ptr) |
| 197 | +#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr) |
| 198 | +#define TX_TIMER_DELETE_EXTENSION(timer_ptr) |
| 199 | + |
| 200 | + |
| 201 | +/* Define ThreadX interrupt lockout and restore macros for protection on |
| 202 | + access of critical kernel information. The restore interrupt macro must |
| 203 | + restore the interrupt posture of the running thread prior to the value |
| 204 | + present prior to the disable macro. In most cases, the save area macro |
| 205 | + is used to define a local function save area for the disable and restore |
| 206 | + macros. */ |
| 207 | + |
| 208 | +/* UINT _tx_thread_interrupt_control(UINT new_posture); */ |
| 209 | + |
| 210 | +#pragma inline_asm _tx_thread_interrupt_disable |
| 211 | +static UINT _tx_thread_interrupt_disable(void){ |
| 212 | + MVFC PSW,R1 ; |
| 213 | + CLRPSW I ; |
| 214 | +} |
| 215 | + |
| 216 | + |
| 217 | +#pragma inline_asm _tx_thread_interrupt_restore |
| 218 | +static void _tx_thread_interrupt_restore(UINT old_posture){ |
| 219 | + MVFC PSW, R2 ; |
| 220 | + BTST #16,r1 ; |
| 221 | + BMC #16,r2 ; |
| 222 | + MVTC r2,PSW ; |
| 223 | +} |
| 224 | + |
| 225 | +#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save; |
| 226 | + |
| 227 | +#define TX_DISABLE interrupt_save = _tx_thread_interrupt_disable(); |
| 228 | + |
| 229 | + |
| 230 | +#define TX_RESTORE _tx_thread_interrupt_restore(interrupt_save); |
| 231 | + |
| 232 | + |
| 233 | +#define _tx_thread_system_return _tx_thread_system_return_inline |
| 234 | + |
| 235 | +static void _tx_thread_system_return_inline(void) |
| 236 | +{ |
| 237 | + UINT interrupt_save; |
| 238 | + |
| 239 | + interrupt_save = _tx_thread_interrupt_disable(); |
| 240 | + |
| 241 | + *((volatile UCHAR *)(0x872E0u)) = 1u; |
| 242 | + |
| 243 | + _tx_thread_interrupt_restore(interrupt_save); |
| 244 | +} |
| 245 | + |
| 246 | + |
| 247 | +#ifndef TX_THREAD_GET_SYSTEM_STATE |
| 248 | + |
| 249 | +#pragma inline_asm _get_psw |
| 250 | +static UINT _get_psw(void){ |
| 251 | + MVFC PSW,R1 ; |
| 252 | +} |
| 253 | + |
| 254 | +extern volatile ULONG _tx_thread_system_state; |
| 255 | +#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | ((~_get_psw()) & (1u << 17u))) |
| 256 | +#endif |
| 257 | + |
| 258 | + |
| 259 | + |
| 260 | +/* Define the interrupt lockout macros for each ThreadX object. */ |
| 261 | + |
| 262 | +#define TX_BLOCK_POOL_DISABLE TX_DISABLE |
| 263 | +#define TX_BYTE_POOL_DISABLE TX_DISABLE |
| 264 | +#define TX_EVENT_FLAGS_GROUP_DISABLE TX_DISABLE |
| 265 | +#define TX_MUTEX_DISABLE TX_DISABLE |
| 266 | +#define TX_QUEUE_DISABLE TX_DISABLE |
| 267 | +#define TX_SEMAPHORE_DISABLE TX_DISABLE |
| 268 | + |
| 269 | + |
| 270 | +/* Define the version ID of ThreadX. This may be utilized by the application. */ |
| 271 | + |
| 272 | +#ifdef TX_THREAD_INIT |
| 273 | +CHAR _tx_version_id[] = |
| 274 | + "Copyright (c) Microsoft Corporation. All rights reserved. * ThreadX RXv1/CCRX Version 6.1.8 *"; |
| 275 | +#else |
| 276 | +extern CHAR _tx_version_id[]; |
| 277 | +#endif |
| 278 | + |
| 279 | + |
| 280 | +#endif |
| 281 | + |
0 commit comments