first commit
This commit is contained in:
728
ports/cortex_m3/ac5/inc/tx_port.h
Normal file
728
ports/cortex_m3/ac5/inc/tx_port.h
Normal file
@@ -0,0 +1,728 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Port Specific */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M3/AC5 */
|
||||
/* 6.1.12 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file contains data type definitions that make the ThreadX */
|
||||
/* real-time kernel function identically on a variety of different */
|
||||
/* processor architectures. For example, the size or number of bits */
|
||||
/* in an "int" data type vary between microprocessor architectures and */
|
||||
/* even C compilers for the same microprocessor. ThreadX does not */
|
||||
/* directly use native C data types. Instead, ThreadX creates its */
|
||||
/* own special types that can be mapped to actual data types by this */
|
||||
/* file to guarantee consistency in the interface and functionality. */
|
||||
/* */
|
||||
/* This file replaces the previous Cortex-M3/M4/M7 files. It unifies */
|
||||
/* the ARMv7-M architecture and compilers into one common file. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comments, updated */
|
||||
/* typedef to fix misra */
|
||||
/* violation, */
|
||||
/* fixed predefined macro, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 07-29-2022 Scott Larson Modified comments and */
|
||||
/* described BASEPRI usage, */
|
||||
/* resulting in version 6.1.12 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_PORT_H
|
||||
#define TX_PORT_H
|
||||
|
||||
|
||||
/* Determine if the optional ThreadX user define file should be used. */
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler library include files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#include <intrinsics.h> /* IAR Intrinsics */
|
||||
#define __asm__ __asm /* Define to make all inline asm look similar */
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
#endif /* __ICCARM__ */
|
||||
|
||||
#ifdef __ghs__
|
||||
#include <arm_ghs.h>
|
||||
#include "tx_ghs.h"
|
||||
#endif /* __ghs__ */
|
||||
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__CC_ARM)
|
||||
#define __get_control_value __get_CONTROL
|
||||
#define __set_control_value __set_CONTROL
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __get_ipsr_value __get_IPSR
|
||||
#endif
|
||||
|
||||
/* Define ThreadX basic types for this port. */
|
||||
|
||||
#define VOID void
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long long ULONG64;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
#define ULONG64_DEFINED
|
||||
|
||||
/* Define the priority levels for ThreadX. Legal values range
|
||||
from 32 to 1024 and MUST be evenly divisible by 32. */
|
||||
|
||||
#ifndef TX_MAX_PRIORITIES
|
||||
#define TX_MAX_PRIORITIES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
|
||||
thread creation is less than this value, the thread create call will return an error. */
|
||||
|
||||
#ifndef TX_MINIMUM_STACK
|
||||
#define TX_MINIMUM_STACK 200 /* Minimum stack size for this port */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the system timer thread's default stack size and priority. These are only applicable
|
||||
if TX_TIMER_PROCESS_IN_ISR is not defined. */
|
||||
|
||||
#ifndef TX_TIMER_THREAD_STACK_SIZE
|
||||
#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */
|
||||
#endif
|
||||
|
||||
#ifndef TX_TIMER_THREAD_PRIORITY
|
||||
#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
|
||||
#endif
|
||||
|
||||
/* By default, ThreadX for Cortex-M uses the PRIMASK register to enable/disable interrupts.
|
||||
If using BASEPRI is desired, define the following two symbols for both c and assembly files:
|
||||
TX_PORT_USE_BASEPRI - This tells ThreadX to use BASEPRI instead of PRIMASK.
|
||||
TX_PORT_BASEPRI = (priority_mask << (8 - number_priority_bits)) - this defines the maximum priority level to mask.
|
||||
Any interrupt with a higher priority than priority_mask will not be masked, thus the interrupt will run.
|
||||
*/
|
||||
|
||||
/* Define various constants for the ThreadX Cortex-M port. */
|
||||
|
||||
#define TX_INT_DISABLE 1 /* Disable interrupts */
|
||||
#define TX_INT_ENABLE 0 /* Enable interrupts */
|
||||
|
||||
|
||||
/* Define the clock source for trace event entry time stamp. The following two item are port specific.
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#else
|
||||
ULONG _tx_misra_time_stamp_get(VOID);
|
||||
#define TX_TRACE_TIME_SOURCE _tx_misra_time_stamp_get()
|
||||
#endif
|
||||
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
#endif
|
||||
|
||||
#ifdef __ghs__
|
||||
/* Define constants for Green Hills EventAnalyzer. */
|
||||
|
||||
/* Define the number of ticks per second. This informs the EventAnalyzer what the timestamps
|
||||
represent. By default, this is set to 1,000,000 i.e., one tick every microsecond. */
|
||||
|
||||
#define TX_EL_TICKS_PER_SECOND 1000000
|
||||
|
||||
/* Define the method of how to get the upper and lower 32-bits of the time stamp. By default, simply
|
||||
simulate the time-stamp source with a counter. */
|
||||
|
||||
#define read_tbu() _tx_el_time_base_upper
|
||||
#define read_tbl() ++_tx_el_time_base_lower
|
||||
#endif /* __ghs__ */
|
||||
|
||||
/* Define the port specific options for the _tx_build_options variable. This variable indicates
|
||||
how the ThreadX library was built. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_BUILD_OPTIONS (0)
|
||||
|
||||
|
||||
/* Define the in-line initialization constant so that modules with in-line
|
||||
initialization capabilities can prevent their initialization from being
|
||||
a function call. */
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
#define TX_DISABLE_INLINE
|
||||
#else
|
||||
#define TX_INLINE_INITIALIZATION
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
|
||||
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
|
||||
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
|
||||
define is negated, thereby forcing the stack fill which is necessary for the stack checking
|
||||
logic. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifdef TX_ENABLE_STACK_CHECKING
|
||||
#undef TX_DISABLE_STACK_FILLING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the TX_THREAD control block extensions for this port. The main reason
|
||||
for the multiple macros is so that backward compatibility can be maintained with
|
||||
existing ThreadX kernel awareness modules. */
|
||||
|
||||
#define TX_THREAD_EXTENSION_0
|
||||
#define TX_THREAD_EXTENSION_1
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#elif defined(__ghs__)
|
||||
#define TX_THREAD_EXTENSION_2 VOID * tx_thread_eh_globals; \
|
||||
int Errno; /* errno. */ \
|
||||
char * strtok_saved_pos; /* strtok() position. */
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
|
||||
#define TX_THREAD_EXTENSION_3
|
||||
|
||||
|
||||
|
||||
/* Define the port extensions of the remaining ThreadX objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_EXTENSION
|
||||
#define TX_BYTE_POOL_EXTENSION
|
||||
#define TX_EVENT_FLAGS_GROUP_EXTENSION
|
||||
#define TX_MUTEX_EXTENSION
|
||||
#define TX_QUEUE_EXTENSION
|
||||
#define TX_SEMAPHORE_EXTENSION
|
||||
#define TX_TIMER_EXTENSION
|
||||
|
||||
|
||||
/* Define the user extension field of the thread control block. Nothing
|
||||
additional is needed for this port so it is defined as white space. */
|
||||
|
||||
#ifndef TX_THREAD_USER_EXTENSION
|
||||
#define TX_THREAD_USER_EXTENSION
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
|
||||
tx_thread_shell_entry, and tx_thread_terminate. */
|
||||
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#if (__VER__ < 8000000)
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) __iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL;
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION __iar_dlib_perthread_access(0);
|
||||
#else
|
||||
void *_tx_iar_create_per_thread_tls_area(void);
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
void __iar_Initlocks(void);
|
||||
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = _tx_iar_create_per_thread_tls_area();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) do {_tx_iar_destroy_per_thread_tls_area(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL; } while(0);
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION do {__iar_Initlocks();} while(0);
|
||||
#endif
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__)
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
|
||||
ULONG _tx_misra_control_get(void);
|
||||
void _tx_misra_control_set(ULONG value);
|
||||
ULONG _tx_misra_fpccr_get(void);
|
||||
void _tx_misra_vfp_touch(void);
|
||||
|
||||
#else /* TX_MISRA_ENABLE not defined */
|
||||
|
||||
/* Define some helper functions (these are intrinsics in some compilers). */
|
||||
#ifdef __GNUC__ /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm__ volatile (" MRS %0,CONTROL ": "=r" (control_value) );
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile (" MSR CONTROL,%0": : "r" (control_value): "memory" );
|
||||
}
|
||||
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
|
||||
#elif defined(__CC_ARM) /* ARM Compiler 5 */
|
||||
|
||||
__attribute__( ( always_inline ) ) ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm volatile ("MRS control_value,CONTROL");
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile ("MSR CONTROL,control_value");
|
||||
}
|
||||
/* Can't access VFP registers with inline asm, so define this in tx_thread_schedule. */
|
||||
void _tx_vfp_access(void);
|
||||
#define TX_VFP_TOUCH() _tx_vfp_access();
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
#endif /* Helper functions for different compilers */
|
||||
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
|
||||
|
||||
/* A completed thread falls into _thread_shell_entry and we can simply deactivate the FPU via CONTROL.FPCA
|
||||
in order to ensure no lazy stacking will occur. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* A thread can be terminated by another thread, so we first check if it's self-terminating and not in an ISR.
|
||||
If so, deactivate the FPU via CONTROL.FPCA. Otherwise we are in an interrupt or another thread is terminating
|
||||
this one, so if the FPCCR.LSPACT bit is set, we need to save the CONTROL.FPCA state, touch the FPU to flush
|
||||
the lazy FPU save, then restore the CONTROL.FPCA state. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
TX_VFP_TOUCH(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = _tx_misra_fpccr_get(); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
_tx_misra_vfp_touch(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* No VFP in use */
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
|
||||
|
||||
#endif /* defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__) */
|
||||
|
||||
|
||||
/* Define the ThreadX object creation extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_CREATE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object deletion extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_DELETE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the get system state macro. */
|
||||
|
||||
#ifndef TX_THREAD_GET_SYSTEM_STATE
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#ifdef __CC_ARM /* ARM Compiler 5 */
|
||||
|
||||
register unsigned int _ipsr __asm("ipsr");
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _ipsr)
|
||||
|
||||
#elif defined(__GNUC__) /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_ipsr_value(void)
|
||||
{
|
||||
unsigned int ipsr_value;
|
||||
__asm__ volatile (" MRS %0,IPSR ": "=r" (ipsr_value) );
|
||||
return(ipsr_value);
|
||||
}
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_ipsr_value())
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_IPSR())
|
||||
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE for different compilers */
|
||||
|
||||
#else /* TX_MISRA_ENABLE is defined, use MISRA function. */
|
||||
ULONG _tx_misra_ipsr_get(VOID);
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _tx_misra_ipsr_get())
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE */
|
||||
|
||||
|
||||
/* Define the check for whether or not to call the _tx_thread_system_return function. A non-zero value
|
||||
indicates that _tx_thread_system_return should not be called. This overrides the definition in tx_thread.h
|
||||
for Cortex-M since so we don't waste time checking the _tx_thread_system_state variable that is always
|
||||
zero after initialization for Cortex-M ports. */
|
||||
|
||||
#ifndef TX_THREAD_SYSTEM_RETURN_CHECK
|
||||
#define TX_THREAD_SYSTEM_RETURN_CHECK(c) (c) = ((ULONG) _tx_thread_preempt_disable);
|
||||
#endif
|
||||
|
||||
/* Define the macro to ensure _tx_thread_preempt_disable is set early in initialization in order to
|
||||
prevent early scheduling on Cortex-M parts. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_POST_INITIALIZATION _tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef TX_DISABLE_INLINE
|
||||
|
||||
/* Define the TX_LOWEST_SET_BIT_CALCULATE macro for each compiler. */
|
||||
#ifdef __ICCARM__ /* IAR Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __CLZ(__RBIT((m)));
|
||||
#elif defined(__CC_ARM) /* AC5 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __clz(__rbit((m)));
|
||||
#elif defined(__GNUC__) /* GCC and AC6 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) __asm__ volatile (" RBIT %0,%1 ": "=r" (m) : "r" (m) ); \
|
||||
__asm__ volatile (" CLZ %0,%1 ": "=r" (b) : "r" (m) );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Define the interrupt disable/restore macros for each compiler. */
|
||||
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
|
||||
/*** GCC/AC6 and IAR ***/
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS %0, BASEPRI ": "=r" (posture));
|
||||
#else
|
||||
__asm__ volatile ("MRS %0, PRIMASK ": "=r" (posture));
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__attribute__( ( always_inline ) ) static inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value));
|
||||
}
|
||||
#else
|
||||
__attribute__( ( always_inline ) ) static inline void __enable_interrupts(void)
|
||||
{
|
||||
__asm__ volatile ("CPSIE i": : : "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
//__asm__ volatile ("MSR BASEPRI,%0": : "r" (int_posture): "memory");
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK,%0": : "r" (int_posture): "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i" : : : "memory");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(0);
|
||||
#else
|
||||
__enable_interrupts();
|
||||
#endif
|
||||
__restore_interrupt(interrupt_save);
|
||||
}
|
||||
}
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End GCC/AC6 and IAR ***/
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
|
||||
/*** AC5 ***/
|
||||
|
||||
static __inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS #posture, BASEPRI");
|
||||
#else
|
||||
__asm__ volatile ("MRS #posture, PRIMASK");
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
static __inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI, #basepri_value");
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
static __inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK, #int_posture");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (_ipsr == 0)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
__set_basepri_value(0);
|
||||
__set_basepri_value(interrupt_save);
|
||||
#else
|
||||
interrupt_save = __disable_irq();
|
||||
__enable_irq();
|
||||
if (interrupt_save != 0)
|
||||
__disable_irq();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End AC5 ***/
|
||||
|
||||
#endif /* Interrupt disable/restore macros for each compiler. */
|
||||
|
||||
/* Redefine _tx_thread_system_return for improved performance. */
|
||||
|
||||
#define _tx_thread_system_return _tx_thread_system_return_inline
|
||||
|
||||
|
||||
#else /* TX_DISABLE_INLINE is defined */
|
||||
|
||||
UINT _tx_thread_interrupt_disable(VOID);
|
||||
VOID _tx_thread_interrupt_restore(UINT previous_posture);
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register UINT interrupt_save;
|
||||
|
||||
#define TX_DISABLE interrupt_save = _tx_thread_interrupt_disable();
|
||||
#define TX_RESTORE _tx_thread_interrupt_restore(interrupt_save);
|
||||
#endif /* TX_DISABLE_INLINE */
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
void tx_thread_fpu_disable(void);
|
||||
|
||||
|
||||
/* Define the version ID of ThreadX. This may be utilized by the application. */
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) 2024 Microsoft Corporation. * ThreadX Cortex-M3/AC5 Version 6.4.2 *";
|
||||
#else
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
extern CHAR _tx_version_id[100];
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
88
ports/cortex_m3/ac5/src/tx_thread_context_restore.s
Normal file
88
ports/cortex_m3/ac5/src/tx_thread_context_restore.s
Normal file
@@ -0,0 +1,88 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
IMPORT _tx_execution_isr_exit
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_restore Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_exit] Execution profiling ISR exit */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs Interrupt Service Routines */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_restore(VOID)
|
||||
// {
|
||||
EXPORT _tx_thread_context_restore
|
||||
_tx_thread_context_restore
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR exit function to indicate an ISR is complete. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_exit // Call the ISR exit function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
BX lr
|
||||
// }
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
90
ports/cortex_m3/ac5/src/tx_thread_context_save.s
Normal file
90
ports/cortex_m3/ac5/src/tx_thread_context_save.s
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
IMPORT _tx_execution_isr_enter
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_save Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_enter] Execution profiling ISR enter */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_save(VOID)
|
||||
// {
|
||||
EXPORT _tx_thread_context_save
|
||||
_tx_thread_context_save
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR enter function to indicate an ISR is starting. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_enter // Call the ISR enter function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
/* Context is already saved - just return. */
|
||||
|
||||
BX lr
|
||||
// }
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
82
ports/cortex_m3/ac5/src/tx_thread_interrupt_control.s
Normal file
82
ports/cortex_m3/ac5/src/tx_thread_interrupt_control.s
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_control Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for changing the interrupt lockout */
|
||||
/* posture of the system. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* new_posture New interrupt lockout posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_control(UINT new_posture)
|
||||
// {
|
||||
EXPORT _tx_thread_interrupt_control
|
||||
_tx_thread_interrupt_control
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Pickup current interrupt posture
|
||||
MSR BASEPRI, r0 // Apply the new interrupt posture
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#else
|
||||
MRS r1, PRIMASK // Pickup current interrupt lockout
|
||||
MSR PRIMASK, r0 // Apply the new interrupt lockout
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#endif
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
END
|
||||
82
ports/cortex_m3/ac5/src/tx_thread_interrupt_disable.s
Normal file
82
ports/cortex_m3/ac5/src/tx_thread_interrupt_disable.s
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_disable Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for disabling interrupts and returning */
|
||||
/* the previous interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_disable(VOID)
|
||||
// {
|
||||
EXPORT _tx_thread_interrupt_disable
|
||||
_tx_thread_interrupt_disable
|
||||
/* Return current interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r0, BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
MRS r0, PRIMASK
|
||||
CPSID i
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
END
|
||||
80
ports/cortex_m3/ac5/src/tx_thread_interrupt_restore.s
Normal file
80
ports/cortex_m3/ac5/src/tx_thread_interrupt_restore.s
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_restore Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for restoring the previous */
|
||||
/* interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* previous_posture Previous interrupt posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_interrupt_restore(UINT previous_posture)
|
||||
// {
|
||||
EXPORT _tx_thread_interrupt_restore
|
||||
_tx_thread_interrupt_restore
|
||||
|
||||
/* Restore previous interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
MSR PRIMASK, r0
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
END
|
||||
330
ports/cortex_m3/ac5/src/tx_thread_schedule.s
Normal file
330
ports/cortex_m3/ac5/src/tx_thread_schedule.s
Normal file
@@ -0,0 +1,330 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
IMPORT _tx_thread_current_ptr
|
||||
IMPORT _tx_thread_execute_ptr
|
||||
IMPORT _tx_timer_time_slice
|
||||
IMPORT _tx_thread_system_stack_ptr
|
||||
IMPORT _tx_thread_preempt_disable
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
IMPORT _tx_execution_thread_enter
|
||||
IMPORT _tx_execution_thread_exit
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function waits for a thread control block pointer to appear in */
|
||||
/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
|
||||
/* in the variable, the corresponding thread is resumed. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 04-25-2022 Scott Larson Added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
// {
|
||||
EXPORT _tx_thread_schedule
|
||||
_tx_thread_schedule
|
||||
|
||||
/* This function should only ever be called on Cortex-M
|
||||
from the first schedule request. Subsequent scheduling occurs
|
||||
from the PendSV handling routine below. */
|
||||
|
||||
/* Clear the preempt-disable flag to enable rescheduling after initialization on Cortex-M targets. */
|
||||
|
||||
MOV r0, #0 // Build value for TX_FALSE
|
||||
LDR r2, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
STR r0, [r2, #0] // Clear preempt disable flag
|
||||
|
||||
/* Clear CONTROL.FPCA bit so VFP registers aren't unnecessarily stacked. */
|
||||
|
||||
#ifdef __TARGET_FPU_VFP
|
||||
MRS r0, CONTROL // Pickup current CONTROL register
|
||||
BIC r0, r0, #4 // Clear the FPCA bit
|
||||
MSR CONTROL, r0 // Setup new CONTROL register
|
||||
#endif
|
||||
|
||||
/* Enable interrupts */
|
||||
CPSIE i
|
||||
|
||||
/* Enter the scheduler for the first time. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
DSB // Complete all memory accesses
|
||||
ISB // Flush pipeline
|
||||
|
||||
/* Wait here for the PendSV to take place. */
|
||||
|
||||
__tx_wait_here
|
||||
B __tx_wait_here // Wait for the PendSV to happen
|
||||
// }
|
||||
|
||||
/* Generic context switching PendSV handler. */
|
||||
|
||||
EXPORT __tx_PendSVHandler
|
||||
EXPORT PendSV_Handler
|
||||
__tx_PendSVHandler
|
||||
PendSV_Handler
|
||||
|
||||
/* Get current thread value and new thread pointer. */
|
||||
|
||||
__tx_ts_handler
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
MOV r3, #0 // Build NULL value
|
||||
LDR r1, [r0] // Pickup current thread pointer
|
||||
|
||||
/* Determine if there is a current thread to finish preserving. */
|
||||
|
||||
CBZ r1, __tx_ts_new // If NULL, skip preservation
|
||||
|
||||
/* Recover PSP and preserve current thread context. */
|
||||
|
||||
STR r3, [r0] // Set _tx_thread_current_ptr to NULL
|
||||
MRS r12, PSP // Pickup PSP pointer (thread's stack pointer)
|
||||
STMDB r12!, {r4-r11} // Save its remaining registers
|
||||
#ifdef __TARGET_FPU_VFP
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_save
|
||||
VSTMDB r12!,{s16-s31} // Yes, save additional VFP registers
|
||||
_skip_vfp_save
|
||||
#endif
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
STMDB r12!, {LR} // Save LR on the stack
|
||||
|
||||
/* Determine if time-slice is active. If it isn't, skip time handling processing. */
|
||||
|
||||
LDR r5, [r4] // Pickup current time-slice
|
||||
STR r12, [r1, #8] // Save the thread stack pointer
|
||||
CBZ r5, __tx_ts_new // If not active, skip processing
|
||||
|
||||
/* Time-slice is active, save the current thread's time-slice and clear the global time-slice variable. */
|
||||
|
||||
STR r5, [r1, #24] // Save current time-slice
|
||||
|
||||
/* Clear the global time-slice. */
|
||||
|
||||
STR r3, [r4] // Clear time-slice
|
||||
|
||||
/* Executing thread is now completely preserved!!! */
|
||||
|
||||
__tx_ts_new
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBZ r1, __tx_ts_wait // No, skip to the wait processing
|
||||
|
||||
/* Yes, another thread is ready for else, make the current thread the new thread. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
__tx_ts_restore
|
||||
LDR r7, [r1, #4] // Pickup the current thread run count
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
LDR r5, [r1, #24] // Pickup thread's current time-slice
|
||||
ADD r7, r7, #1 // Increment the thread run count
|
||||
STR r7, [r1, #4] // Store the new run count
|
||||
|
||||
/* Setup global time-slice with thread's current time-slice. */
|
||||
|
||||
STR r5, [r4] // Setup global time-slice
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread entry function to indicate the thread is executing. */
|
||||
PUSH {r0, r1} // Save r0 and r1
|
||||
BL _tx_execution_thread_enter // Call the thread execution enter function
|
||||
POP {r0, r1} // Recover r0 and r1
|
||||
#endif
|
||||
|
||||
/* Restore the thread context and PSP. */
|
||||
|
||||
LDR r12, [r1, #8] // Pickup thread's stack pointer
|
||||
LDMIA r12!, {LR} // Pickup LR
|
||||
#ifdef __TARGET_FPU_VFP
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_restore // If not, skip VFP restore
|
||||
VLDMIA r12!, {s16-s31} // Yes, restore additional VFP registers
|
||||
_skip_vfp_restore
|
||||
#endif
|
||||
LDMIA r12!, {r4-r11} // Recover thread's registers
|
||||
MSR PSP, r12 // Setup the thread's stack pointer
|
||||
|
||||
/* Return to thread. */
|
||||
|
||||
BX lr // Return to thread!
|
||||
|
||||
/* The following is the idle wait processing... in this case, no threads are ready for execution and the
|
||||
system will simply be idle until an interrupt occurs that makes a thread ready. Note that interrupts
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
STR r1, [r0] // Store it in the current pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_enter // Possibly enter low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_WFI
|
||||
DSB // Ensure no outstanding memory transactions
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_exit // Exit low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
already in the handler! */
|
||||
|
||||
__tx_ts_ready
|
||||
MOV r7, #0x08000000 // Build clear PendSV value
|
||||
MOV r8, #0xE000E000 // Build base NVIC address
|
||||
STR r7, [r8, #0xD04] // Clear any PendSV
|
||||
|
||||
/* Re-enable interrupts and restore new thread. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_restore // Restore the thread
|
||||
// }
|
||||
|
||||
#ifdef __TARGET_FPU_VFP
|
||||
EXPORT tx_thread_fpu_enable
|
||||
tx_thread_fpu_enable
|
||||
EXPORT tx_thread_fpu_disable
|
||||
tx_thread_fpu_disable
|
||||
|
||||
/* Automatic VPF logic is supported, this function is present only for
|
||||
backward compatibility purposes and therefore simply returns. */
|
||||
|
||||
BX LR // Return to caller
|
||||
|
||||
EXPORT _tx_vfp_access
|
||||
_tx_vfp_access
|
||||
VMOV.F32 s0, s0 // Simply access the VFP
|
||||
BX lr // Return to caller
|
||||
|
||||
#endif
|
||||
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
136
ports/cortex_m3/ac5/src/tx_thread_stack_build.s
Normal file
136
ports/cortex_m3/ac5/src/tx_thread_stack_build.s
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_stack_build Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function builds a stack frame on the supplied thread's stack. */
|
||||
/* The stack frame results in a fake interrupt return to the supplied */
|
||||
/* function pointer. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* thread_ptr Pointer to thread control blk */
|
||||
/* function_ptr Pointer to return function */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_thread_create Create thread service */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
|
||||
// {
|
||||
EXPORT _tx_thread_stack_build
|
||||
_tx_thread_stack_build
|
||||
|
||||
/* Build a fake interrupt frame. The form of the fake interrupt stack
|
||||
on the Cortex-M should look like the following after it is built:
|
||||
|
||||
Stack Top:
|
||||
LR Interrupted LR (LR at time of PENDSV)
|
||||
r4 Initial value for r4
|
||||
r5 Initial value for r5
|
||||
r6 Initial value for r6
|
||||
r7 Initial value for r7
|
||||
r8 Initial value for r8
|
||||
r9 Initial value for r9
|
||||
r10 Initial value for r10
|
||||
r11 Initial value for r11
|
||||
r0 Initial value for r0 (Hardware stack starts here!!)
|
||||
r1 Initial value for r1
|
||||
r2 Initial value for r2
|
||||
r3 Initial value for r3
|
||||
r12 Initial value for r12
|
||||
lr Initial value for lr
|
||||
pc Initial value for pc
|
||||
xPSR Initial value for xPSR
|
||||
|
||||
Stack Bottom: (higher memory address) */
|
||||
|
||||
LDR r2, [r0, #16] // Pickup end of stack area
|
||||
BIC r2, r2, #0x7 // Align frame for 8-byte alignment
|
||||
SUB r2, r2, #68 // Subtract frame size
|
||||
LDR r3, =0xFFFFFFFD // Build initial LR value
|
||||
STR r3, [r2, #0] // Save on the stack
|
||||
|
||||
/* Actually build the stack frame. */
|
||||
|
||||
MOV r3, #0 // Build initial register value
|
||||
STR r3, [r2, #4] // Store initial r4
|
||||
STR r3, [r2, #8] // Store initial r5
|
||||
STR r3, [r2, #12] // Store initial r6
|
||||
STR r3, [r2, #16] // Store initial r7
|
||||
STR r3, [r2, #20] // Store initial r8
|
||||
STR r3, [r2, #24] // Store initial r9
|
||||
STR r3, [r2, #28] // Store initial r10
|
||||
STR r3, [r2, #32] // Store initial r11
|
||||
|
||||
/* Hardware stack follows. */
|
||||
|
||||
STR r3, [r2, #36] // Store initial r0
|
||||
STR r3, [r2, #40] // Store initial r1
|
||||
STR r3, [r2, #44] // Store initial r2
|
||||
STR r3, [r2, #48] // Store initial r3
|
||||
STR r3, [r2, #52] // Store initial r12
|
||||
MOV r3, #0xFFFFFFFF // Poison EXC_RETURN value
|
||||
STR r3, [r2, #56] // Store initial lr
|
||||
STR r1, [r2, #60] // Store initial pc
|
||||
MOV r3, #0x01000000 // Only T-bit need be set
|
||||
STR r3, [r2, #64] // Store initial xPSR
|
||||
|
||||
/* Setup stack pointer. */
|
||||
// thread_ptr -> tx_thread_stack_ptr = r2;
|
||||
|
||||
STR r2, [r0, #8] // Save stack pointer in thread's
|
||||
// control block
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
END
|
||||
96
ports/cortex_m3/ac5/src/tx_thread_system_return.s
Normal file
96
ports/cortex_m3/ac5/src/tx_thread_system_return.s
Normal file
@@ -0,0 +1,96 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_system_return Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is target processor specific. It is used to transfer */
|
||||
/* control from a thread back to the ThreadX system. Only a */
|
||||
/* minimal context is saved since the compiler assumes temp registers */
|
||||
/* are going to get slicked by a function call anyway. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_thread_schedule Thread scheduling loop */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ThreadX components */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_system_return(VOID)
|
||||
// {
|
||||
EXPORT _tx_thread_system_return
|
||||
_tx_thread_system_return
|
||||
|
||||
/* Return to real scheduler via PendSV. Note that this routine is often
|
||||
replaced with in-line assembly in tx_port.h to improved performance. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
MRS r0, IPSR // Pickup IPSR
|
||||
CMP r0, #0 // Is it a thread returning?
|
||||
BNE _isr_context // If ISR, skip interrupt enable
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Thread context returning, pickup BASEPRI
|
||||
MOV r0, #0
|
||||
MSR BASEPRI, r0 // Enable interrupts
|
||||
MSR BASEPRI, r1 // Restore original interrupt posture
|
||||
#else
|
||||
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
|
||||
CPSIE i // Enable interrupts
|
||||
MSR PRIMASK, r1 // Restore original interrupt posture
|
||||
#endif
|
||||
_isr_context
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
END
|
||||
264
ports/cortex_m3/ac5/src/tx_timer_interrupt.s
Normal file
264
ports/cortex_m3/ac5/src/tx_timer_interrupt.s
Normal file
@@ -0,0 +1,264 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Timer */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
IMPORT _tx_timer_time_slice
|
||||
IMPORT _tx_timer_system_clock
|
||||
IMPORT _tx_timer_current_ptr
|
||||
IMPORT _tx_timer_list_start
|
||||
IMPORT _tx_timer_list_end
|
||||
IMPORT _tx_timer_expired_time_slice
|
||||
IMPORT _tx_timer_expired
|
||||
IMPORT _tx_thread_time_slice
|
||||
IMPORT _tx_timer_expiration_process
|
||||
IMPORT _tx_thread_preempt_disable
|
||||
IMPORT _tx_thread_current_ptr
|
||||
IMPORT _tx_thread_execute_ptr
|
||||
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_timer_interrupt Cortex-M3/AC5 */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function processes the hardware timer interrupt. This */
|
||||
/* processing includes incrementing the system clock and checking for */
|
||||
/* time slice and/or timer expiration. If either is found, the */
|
||||
/* expiration functions are called. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_timer_expiration_process Timer expiration processing */
|
||||
/* _tx_thread_time_slice Time slice interrupted thread */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* interrupt vector */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comment(s), added */
|
||||
/* TX_NO_TIMER support, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_timer_interrupt(VOID)
|
||||
// {
|
||||
#ifndef TX_NO_TIMER
|
||||
EXPORT _tx_timer_interrupt
|
||||
_tx_timer_interrupt
|
||||
|
||||
/* Upon entry to this routine, it is assumed that the compiler scratch registers are available
|
||||
for use. */
|
||||
|
||||
/* Increment the system clock. */
|
||||
// _tx_timer_system_clock++;
|
||||
|
||||
LDR r1, =_tx_timer_system_clock // Pickup address of system clock
|
||||
LDR r0, [r1, #0] // Pickup system clock
|
||||
ADD r0, r0, #1 // Increment system clock
|
||||
STR r0, [r1, #0] // Store new system clock
|
||||
|
||||
/* Test for time-slice expiration. */
|
||||
// if (_tx_timer_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_time_slice // Pickup address of time-slice
|
||||
LDR r2, [r3, #0] // Pickup time-slice
|
||||
CBZ r2, __tx_timer_no_time_slice // Is it non-active?
|
||||
// Yes, skip time-slice processing
|
||||
|
||||
/* Decrement the time_slice. */
|
||||
// _tx_timer_time_slice--;
|
||||
|
||||
SUB r2, r2, #1 // Decrement the time-slice
|
||||
STR r2, [r3, #0] // Store new time-slice value
|
||||
|
||||
/* Check for expiration. */
|
||||
// if (__tx_timer_time_slice == 0)
|
||||
|
||||
CBNZ r2, __tx_timer_no_time_slice // Has it expired?
|
||||
// No, skip expiration processing
|
||||
|
||||
/* Set the time-slice expired flag. */
|
||||
// _tx_timer_expired_time_slice = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup address of expired flag
|
||||
MOV r0, #1 // Build expired value
|
||||
STR r0, [r3, #0] // Set time-slice expiration flag
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_no_time_slice
|
||||
|
||||
/* Test for timer expiration. */
|
||||
// if (*_tx_timer_current_ptr)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_current_ptr // Pickup current timer pointer address
|
||||
LDR r0, [r1, #0] // Pickup current timer
|
||||
LDR r2, [r0, #0] // Pickup timer list entry
|
||||
CBZ r2, __tx_timer_no_timer // Is there anything in the list?
|
||||
// No, just increment the timer
|
||||
|
||||
/* Set expiration flag. */
|
||||
// _tx_timer_expired = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired // Pickup expiration flag address
|
||||
MOV r2, #1 // Build expired value
|
||||
STR r2, [r3, #0] // Set expired flag
|
||||
B __tx_timer_done // Finished timer processing
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
__tx_timer_no_timer
|
||||
|
||||
/* No timer expired, increment the timer pointer. */
|
||||
// _tx_timer_current_ptr++;
|
||||
|
||||
ADD r0, r0, #4 // Move to next timer
|
||||
|
||||
/* Check for wrap-around. */
|
||||
// if (_tx_timer_current_ptr == _tx_timer_list_end)
|
||||
|
||||
LDR r3, =_tx_timer_list_end // Pickup addr of timer list end
|
||||
LDR r2, [r3, #0] // Pickup list end
|
||||
CMP r0, r2 // Are we at list end?
|
||||
BNE __tx_timer_skip_wrap // No, skip wrap-around logic
|
||||
|
||||
/* Wrap to beginning of list. */
|
||||
// _tx_timer_current_ptr = _tx_timer_list_start;
|
||||
|
||||
LDR r3, =_tx_timer_list_start // Pickup addr of timer list start
|
||||
LDR r0, [r3, #0] // Set current pointer to list start
|
||||
|
||||
__tx_timer_skip_wrap
|
||||
|
||||
STR r0, [r1, #0] // Store new current timer pointer
|
||||
// }
|
||||
|
||||
__tx_timer_done
|
||||
|
||||
/* See if anything has expired. */
|
||||
// if ((_tx_timer_expired_time_slice) || (_tx_timer_expired))
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of expired flag
|
||||
LDR r2, [r3, #0] // Pickup time-slice expired flag
|
||||
CBNZ r2, __tx_something_expired // Did a time-slice expire?
|
||||
// If non-zero, time-slice expired
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of other expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_nothing_expired // Did a timer expire?
|
||||
// No, nothing expired
|
||||
|
||||
__tx_something_expired
|
||||
|
||||
STMDB sp!, {r0, lr} // Save the lr register on the stack
|
||||
// and save r0 just to keep 8-byte alignment
|
||||
|
||||
/* Did a timer expire? */
|
||||
// if (_tx_timer_expired)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_dont_activate // Check for timer expiration
|
||||
// If not set, skip timer activation
|
||||
|
||||
/* Process timer expiration. */
|
||||
// _tx_timer_expiration_process();
|
||||
|
||||
BL _tx_timer_expiration_process // Call the timer expiration handling routine
|
||||
|
||||
// }
|
||||
__tx_timer_dont_activate
|
||||
|
||||
/* Did time slice expire? */
|
||||
// if (_tx_timer_expired_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of time-slice expired
|
||||
LDR r2, [r3, #0] // Pickup the actual flag
|
||||
CBZ r2, __tx_timer_not_ts_expiration // See if the flag is set
|
||||
// No, skip time-slice processing
|
||||
|
||||
/* Time slice interrupted thread. */
|
||||
// _tx_thread_time_slice();
|
||||
|
||||
BL _tx_thread_time_slice // Call time-slice processing
|
||||
LDR r0, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
LDR r1, [r0] // Is the preempt disable flag set?
|
||||
CBNZ r1, __tx_timer_skip_time_slice // Yes, skip the PendSV logic
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r1, [r0] // Pickup the current thread pointer
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
LDR r3, [r2] // Pickup the execute thread pointer
|
||||
LDR r0, =0xE000ED04 // Build address of control register
|
||||
LDR r2, =0x10000000 // Build value for PendSV bit
|
||||
CMP r1, r3 // Are they the same?
|
||||
BEQ __tx_timer_skip_time_slice // If the same, there was no time-slice performed
|
||||
STR r2, [r0] // Not the same, issue the PendSV for preemption
|
||||
__tx_timer_skip_time_slice
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_not_ts_expiration
|
||||
|
||||
LDMIA sp!, {r0, lr} // Recover lr register (r0 is just there for
|
||||
// the 8-byte stack alignment
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_nothing_expired
|
||||
|
||||
DSB // Complete all memory access
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
#endif
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
728
ports/cortex_m3/ac6/inc/tx_port.h
Normal file
728
ports/cortex_m3/ac6/inc/tx_port.h
Normal file
@@ -0,0 +1,728 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Port Specific */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M3/AC6 */
|
||||
/* 6.1.12 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file contains data type definitions that make the ThreadX */
|
||||
/* real-time kernel function identically on a variety of different */
|
||||
/* processor architectures. For example, the size or number of bits */
|
||||
/* in an "int" data type vary between microprocessor architectures and */
|
||||
/* even C compilers for the same microprocessor. ThreadX does not */
|
||||
/* directly use native C data types. Instead, ThreadX creates its */
|
||||
/* own special types that can be mapped to actual data types by this */
|
||||
/* file to guarantee consistency in the interface and functionality. */
|
||||
/* */
|
||||
/* This file replaces the previous Cortex-M3/M4/M7 files. It unifies */
|
||||
/* the ARMv7-M architecture and compilers into one common file. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comments, updated */
|
||||
/* typedef to fix misra */
|
||||
/* violation, */
|
||||
/* fixed predefined macro, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 07-29-2022 Scott Larson Modified comments and */
|
||||
/* described BASEPRI usage, */
|
||||
/* resulting in version 6.1.12 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_PORT_H
|
||||
#define TX_PORT_H
|
||||
|
||||
|
||||
/* Determine if the optional ThreadX user define file should be used. */
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler library include files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#include <intrinsics.h> /* IAR Intrinsics */
|
||||
#define __asm__ __asm /* Define to make all inline asm look similar */
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
#endif /* __ICCARM__ */
|
||||
|
||||
#ifdef __ghs__
|
||||
#include <arm_ghs.h>
|
||||
#include "tx_ghs.h"
|
||||
#endif /* __ghs__ */
|
||||
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__CC_ARM)
|
||||
#define __get_control_value __get_CONTROL
|
||||
#define __set_control_value __set_CONTROL
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __get_ipsr_value __get_IPSR
|
||||
#endif
|
||||
|
||||
/* Define ThreadX basic types for this port. */
|
||||
|
||||
#define VOID void
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long long ULONG64;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
#define ULONG64_DEFINED
|
||||
|
||||
/* Define the priority levels for ThreadX. Legal values range
|
||||
from 32 to 1024 and MUST be evenly divisible by 32. */
|
||||
|
||||
#ifndef TX_MAX_PRIORITIES
|
||||
#define TX_MAX_PRIORITIES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
|
||||
thread creation is less than this value, the thread create call will return an error. */
|
||||
|
||||
#ifndef TX_MINIMUM_STACK
|
||||
#define TX_MINIMUM_STACK 200 /* Minimum stack size for this port */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the system timer thread's default stack size and priority. These are only applicable
|
||||
if TX_TIMER_PROCESS_IN_ISR is not defined. */
|
||||
|
||||
#ifndef TX_TIMER_THREAD_STACK_SIZE
|
||||
#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */
|
||||
#endif
|
||||
|
||||
#ifndef TX_TIMER_THREAD_PRIORITY
|
||||
#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
|
||||
#endif
|
||||
|
||||
/* By default, ThreadX for Cortex-M uses the PRIMASK register to enable/disable interrupts.
|
||||
If using BASEPRI is desired, define the following two symbols for both c and assembly files:
|
||||
TX_PORT_USE_BASEPRI - This tells ThreadX to use BASEPRI instead of PRIMASK.
|
||||
TX_PORT_BASEPRI = (priority_mask << (8 - number_priority_bits)) - this defines the maximum priority level to mask.
|
||||
Any interrupt with a higher priority than priority_mask will not be masked, thus the interrupt will run.
|
||||
*/
|
||||
|
||||
/* Define various constants for the ThreadX Cortex-M port. */
|
||||
|
||||
#define TX_INT_DISABLE 1 /* Disable interrupts */
|
||||
#define TX_INT_ENABLE 0 /* Enable interrupts */
|
||||
|
||||
|
||||
/* Define the clock source for trace event entry time stamp. The following two item are port specific.
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#else
|
||||
ULONG _tx_misra_time_stamp_get(VOID);
|
||||
#define TX_TRACE_TIME_SOURCE _tx_misra_time_stamp_get()
|
||||
#endif
|
||||
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
#endif
|
||||
|
||||
#ifdef __ghs__
|
||||
/* Define constants for Green Hills EventAnalyzer. */
|
||||
|
||||
/* Define the number of ticks per second. This informs the EventAnalyzer what the timestamps
|
||||
represent. By default, this is set to 1,000,000 i.e., one tick every microsecond. */
|
||||
|
||||
#define TX_EL_TICKS_PER_SECOND 1000000
|
||||
|
||||
/* Define the method of how to get the upper and lower 32-bits of the time stamp. By default, simply
|
||||
simulate the time-stamp source with a counter. */
|
||||
|
||||
#define read_tbu() _tx_el_time_base_upper
|
||||
#define read_tbl() ++_tx_el_time_base_lower
|
||||
#endif /* __ghs__ */
|
||||
|
||||
/* Define the port specific options for the _tx_build_options variable. This variable indicates
|
||||
how the ThreadX library was built. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_BUILD_OPTIONS (0)
|
||||
|
||||
|
||||
/* Define the in-line initialization constant so that modules with in-line
|
||||
initialization capabilities can prevent their initialization from being
|
||||
a function call. */
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
#define TX_DISABLE_INLINE
|
||||
#else
|
||||
#define TX_INLINE_INITIALIZATION
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
|
||||
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
|
||||
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
|
||||
define is negated, thereby forcing the stack fill which is necessary for the stack checking
|
||||
logic. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifdef TX_ENABLE_STACK_CHECKING
|
||||
#undef TX_DISABLE_STACK_FILLING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the TX_THREAD control block extensions for this port. The main reason
|
||||
for the multiple macros is so that backward compatibility can be maintained with
|
||||
existing ThreadX kernel awareness modules. */
|
||||
|
||||
#define TX_THREAD_EXTENSION_0
|
||||
#define TX_THREAD_EXTENSION_1
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#elif defined(__ghs__)
|
||||
#define TX_THREAD_EXTENSION_2 VOID * tx_thread_eh_globals; \
|
||||
int Errno; /* errno. */ \
|
||||
char * strtok_saved_pos; /* strtok() position. */
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
|
||||
#define TX_THREAD_EXTENSION_3
|
||||
|
||||
|
||||
|
||||
/* Define the port extensions of the remaining ThreadX objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_EXTENSION
|
||||
#define TX_BYTE_POOL_EXTENSION
|
||||
#define TX_EVENT_FLAGS_GROUP_EXTENSION
|
||||
#define TX_MUTEX_EXTENSION
|
||||
#define TX_QUEUE_EXTENSION
|
||||
#define TX_SEMAPHORE_EXTENSION
|
||||
#define TX_TIMER_EXTENSION
|
||||
|
||||
|
||||
/* Define the user extension field of the thread control block. Nothing
|
||||
additional is needed for this port so it is defined as white space. */
|
||||
|
||||
#ifndef TX_THREAD_USER_EXTENSION
|
||||
#define TX_THREAD_USER_EXTENSION
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
|
||||
tx_thread_shell_entry, and tx_thread_terminate. */
|
||||
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#if (__VER__ < 8000000)
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) __iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL;
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION __iar_dlib_perthread_access(0);
|
||||
#else
|
||||
void *_tx_iar_create_per_thread_tls_area(void);
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
void __iar_Initlocks(void);
|
||||
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = _tx_iar_create_per_thread_tls_area();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) do {_tx_iar_destroy_per_thread_tls_area(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL; } while(0);
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION do {__iar_Initlocks();} while(0);
|
||||
#endif
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__)
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
|
||||
ULONG _tx_misra_control_get(void);
|
||||
void _tx_misra_control_set(ULONG value);
|
||||
ULONG _tx_misra_fpccr_get(void);
|
||||
void _tx_misra_vfp_touch(void);
|
||||
|
||||
#else /* TX_MISRA_ENABLE not defined */
|
||||
|
||||
/* Define some helper functions (these are intrinsics in some compilers). */
|
||||
#ifdef __GNUC__ /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm__ volatile (" MRS %0,CONTROL ": "=r" (control_value) );
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile (" MSR CONTROL,%0": : "r" (control_value): "memory" );
|
||||
}
|
||||
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
|
||||
#elif defined(__CC_ARM) /* ARM Compiler 5 */
|
||||
|
||||
__attribute__( ( always_inline ) ) ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm volatile ("MRS control_value,CONTROL");
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile ("MSR CONTROL,control_value");
|
||||
}
|
||||
/* Can't access VFP registers with inline asm, so define this in tx_thread_schedule. */
|
||||
void _tx_vfp_access(void);
|
||||
#define TX_VFP_TOUCH() _tx_vfp_access();
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
#endif /* Helper functions for different compilers */
|
||||
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
|
||||
|
||||
/* A completed thread falls into _thread_shell_entry and we can simply deactivate the FPU via CONTROL.FPCA
|
||||
in order to ensure no lazy stacking will occur. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* A thread can be terminated by another thread, so we first check if it's self-terminating and not in an ISR.
|
||||
If so, deactivate the FPU via CONTROL.FPCA. Otherwise we are in an interrupt or another thread is terminating
|
||||
this one, so if the FPCCR.LSPACT bit is set, we need to save the CONTROL.FPCA state, touch the FPU to flush
|
||||
the lazy FPU save, then restore the CONTROL.FPCA state. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
TX_VFP_TOUCH(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = _tx_misra_fpccr_get(); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
_tx_misra_vfp_touch(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* No VFP in use */
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
|
||||
|
||||
#endif /* defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__) */
|
||||
|
||||
|
||||
/* Define the ThreadX object creation extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_CREATE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object deletion extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_DELETE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the get system state macro. */
|
||||
|
||||
#ifndef TX_THREAD_GET_SYSTEM_STATE
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#ifdef __CC_ARM /* ARM Compiler 5 */
|
||||
|
||||
register unsigned int _ipsr __asm("ipsr");
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _ipsr)
|
||||
|
||||
#elif defined(__GNUC__) /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_ipsr_value(void)
|
||||
{
|
||||
unsigned int ipsr_value;
|
||||
__asm__ volatile (" MRS %0,IPSR ": "=r" (ipsr_value) );
|
||||
return(ipsr_value);
|
||||
}
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_ipsr_value())
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_IPSR())
|
||||
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE for different compilers */
|
||||
|
||||
#else /* TX_MISRA_ENABLE is defined, use MISRA function. */
|
||||
ULONG _tx_misra_ipsr_get(VOID);
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _tx_misra_ipsr_get())
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE */
|
||||
|
||||
|
||||
/* Define the check for whether or not to call the _tx_thread_system_return function. A non-zero value
|
||||
indicates that _tx_thread_system_return should not be called. This overrides the definition in tx_thread.h
|
||||
for Cortex-M since so we don't waste time checking the _tx_thread_system_state variable that is always
|
||||
zero after initialization for Cortex-M ports. */
|
||||
|
||||
#ifndef TX_THREAD_SYSTEM_RETURN_CHECK
|
||||
#define TX_THREAD_SYSTEM_RETURN_CHECK(c) (c) = ((ULONG) _tx_thread_preempt_disable);
|
||||
#endif
|
||||
|
||||
/* Define the macro to ensure _tx_thread_preempt_disable is set early in initialization in order to
|
||||
prevent early scheduling on Cortex-M parts. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_POST_INITIALIZATION _tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef TX_DISABLE_INLINE
|
||||
|
||||
/* Define the TX_LOWEST_SET_BIT_CALCULATE macro for each compiler. */
|
||||
#ifdef __ICCARM__ /* IAR Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __CLZ(__RBIT((m)));
|
||||
#elif defined(__CC_ARM) /* AC5 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __clz(__rbit((m)));
|
||||
#elif defined(__GNUC__) /* GCC and AC6 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) __asm__ volatile (" RBIT %0,%1 ": "=r" (m) : "r" (m) ); \
|
||||
__asm__ volatile (" CLZ %0,%1 ": "=r" (b) : "r" (m) );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Define the interrupt disable/restore macros for each compiler. */
|
||||
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
|
||||
/*** GCC/AC6 and IAR ***/
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS %0, BASEPRI ": "=r" (posture));
|
||||
#else
|
||||
__asm__ volatile ("MRS %0, PRIMASK ": "=r" (posture));
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__attribute__( ( always_inline ) ) static inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value));
|
||||
}
|
||||
#else
|
||||
__attribute__( ( always_inline ) ) static inline void __enable_interrupts(void)
|
||||
{
|
||||
__asm__ volatile ("CPSIE i": : : "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
//__asm__ volatile ("MSR BASEPRI,%0": : "r" (int_posture): "memory");
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK,%0": : "r" (int_posture): "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i" : : : "memory");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(0);
|
||||
#else
|
||||
__enable_interrupts();
|
||||
#endif
|
||||
__restore_interrupt(interrupt_save);
|
||||
}
|
||||
}
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End GCC/AC6 and IAR ***/
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
|
||||
/*** AC5 ***/
|
||||
|
||||
static __inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS #posture, BASEPRI");
|
||||
#else
|
||||
__asm__ volatile ("MRS #posture, PRIMASK");
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
static __inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI, #basepri_value");
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
static __inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK, #int_posture");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (_ipsr == 0)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
__set_basepri_value(0);
|
||||
__set_basepri_value(interrupt_save);
|
||||
#else
|
||||
interrupt_save = __disable_irq();
|
||||
__enable_irq();
|
||||
if (interrupt_save != 0)
|
||||
__disable_irq();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End AC5 ***/
|
||||
|
||||
#endif /* Interrupt disable/restore macros for each compiler. */
|
||||
|
||||
/* Redefine _tx_thread_system_return for improved performance. */
|
||||
|
||||
#define _tx_thread_system_return _tx_thread_system_return_inline
|
||||
|
||||
|
||||
#else /* TX_DISABLE_INLINE is defined */
|
||||
|
||||
UINT _tx_thread_interrupt_disable(VOID);
|
||||
VOID _tx_thread_interrupt_restore(UINT previous_posture);
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register UINT interrupt_save;
|
||||
|
||||
#define TX_DISABLE interrupt_save = _tx_thread_interrupt_disable();
|
||||
#define TX_RESTORE _tx_thread_interrupt_restore(interrupt_save);
|
||||
#endif /* TX_DISABLE_INLINE */
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
void tx_thread_fpu_disable(void);
|
||||
|
||||
|
||||
/* Define the version ID of ThreadX. This may be utilized by the application. */
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) 2024 Microsoft Corporation. * ThreadX Cortex-M3/AC6 Version 6.4.2 *";
|
||||
#else
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
extern CHAR _tx_version_id[100];
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
722
ports/cortex_m3/ac6/src/tx_misra.S
Normal file
722
ports/cortex_m3/ac6/src/tx_misra.S
Normal file
@@ -0,0 +1,722 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** ThreadX MISRA Compliance */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#define SHT_PROGBITS 0x1
|
||||
|
||||
.global __aeabi_memset
|
||||
.global _tx_thread_current_ptr
|
||||
.global _tx_thread_interrupt_disable
|
||||
.global _tx_thread_interrupt_restore
|
||||
.global _tx_thread_stack_analyze
|
||||
.global _tx_thread_stack_error_handler
|
||||
.global _tx_thread_system_state
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_trace_buffer_current_ptr
|
||||
.global _tx_trace_buffer_end_ptr
|
||||
.global _tx_trace_buffer_start_ptr
|
||||
.global _tx_trace_event_enable_bits
|
||||
.global _tx_trace_full_notify_function
|
||||
.global _tx_trace_header_ptr
|
||||
#endif
|
||||
|
||||
.global _tx_misra_always_true
|
||||
.global _tx_misra_block_pool_to_uchar_pointer_convert
|
||||
.global _tx_misra_byte_pool_to_uchar_pointer_convert
|
||||
.global _tx_misra_char_to_uchar_pointer_convert
|
||||
.global _tx_misra_const_char_to_char_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_entry_to_uchar_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_indirect_void_to_uchar_pointer_convert
|
||||
.global _tx_misra_memset
|
||||
.global _tx_misra_message_copy
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_object_to_uchar_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_pointer_to_ulong_convert
|
||||
.global _tx_misra_status_get
|
||||
.global _tx_misra_thread_stack_check
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_time_stamp_get
|
||||
#endif
|
||||
.global _tx_misra_timer_indirect_to_void_pointer_convert
|
||||
.global _tx_misra_timer_pointer_add
|
||||
.global _tx_misra_timer_pointer_dif
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_trace_event_insert
|
||||
#endif
|
||||
.global _tx_misra_uchar_pointer_add
|
||||
.global _tx_misra_uchar_pointer_dif
|
||||
.global _tx_misra_uchar_pointer_sub
|
||||
.global _tx_misra_uchar_to_align_type_pointer_convert
|
||||
.global _tx_misra_uchar_to_block_pool_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_uchar_to_entry_pointer_convert
|
||||
.global _tx_misra_uchar_to_header_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_uchar_to_indirect_byte_pool_pointer_convert
|
||||
.global _tx_misra_uchar_to_indirect_uchar_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_uchar_to_object_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_uchar_to_void_pointer_convert
|
||||
.global _tx_misra_ulong_pointer_add
|
||||
.global _tx_misra_ulong_pointer_dif
|
||||
.global _tx_misra_ulong_pointer_sub
|
||||
.global _tx_misra_ulong_to_pointer_convert
|
||||
.global _tx_misra_ulong_to_thread_pointer_convert
|
||||
.global _tx_misra_user_timer_pointer_get
|
||||
.global _tx_misra_void_to_block_pool_pointer_convert
|
||||
.global _tx_misra_void_to_byte_pool_pointer_convert
|
||||
.global _tx_misra_void_to_event_flags_pointer_convert
|
||||
.global _tx_misra_void_to_indirect_uchar_pointer_convert
|
||||
.global _tx_misra_void_to_mutex_pointer_convert
|
||||
.global _tx_misra_void_to_queue_pointer_convert
|
||||
.global _tx_misra_void_to_semaphore_pointer_convert
|
||||
.global _tx_misra_void_to_thread_pointer_convert
|
||||
.global _tx_misra_void_to_uchar_pointer_convert
|
||||
.global _tx_misra_void_to_ulong_pointer_convert
|
||||
.global _tx_misra_ipsr_get
|
||||
.global _tx_misra_control_get
|
||||
.global _tx_misra_control_set
|
||||
#ifdef __ARM_FP
|
||||
.global _tx_misra_fpccr_get
|
||||
.global _tx_misra_vfp_touch
|
||||
#endif
|
||||
|
||||
.global _tx_misra_event_flags_group_not_used
|
||||
.global _tx_misra_event_flags_set_notify_not_used
|
||||
.global _tx_misra_queue_not_used
|
||||
.global _tx_misra_queue_send_notify_not_used
|
||||
.global _tx_misra_semaphore_not_used
|
||||
.global _tx_misra_semaphore_put_notify_not_used
|
||||
.global _tx_misra_thread_entry_exit_notify_not_used
|
||||
.global _tx_misra_thread_not_used
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_memset(VOID *ptr, UINT value, UINT size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
.thumb_func
|
||||
_tx_misra_memset:
|
||||
PUSH {R4,LR}
|
||||
MOVS R4,R0
|
||||
MOVS R0,R2
|
||||
MOVS R2,R1
|
||||
MOVS R1,R0
|
||||
MOVS R0,R4
|
||||
BL __aeabi_memset
|
||||
POP {R4,PC} // return
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UCHAR *_tx_misra_uchar_pointer_add(UCHAR *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_uchar_pointer_add:
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UCHAR *_tx_misra_uchar_pointer_sub(UCHAR *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_uchar_pointer_sub:
|
||||
RSBS R1,R1,#+0
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_uchar_pointer_dif(UCHAR *ptr1, UCHAR *ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_uchar_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/************************************************************************************************************************************/
|
||||
/************************************************************************************************************************************/
|
||||
/** */
|
||||
/** This single function serves all of the below prototypes. */
|
||||
/** */
|
||||
/** ULONG _tx_misra_pointer_to_ulong_convert(VOID *ptr); */
|
||||
/** VOID *_tx_misra_ulong_to_pointer_convert(ULONG input); */
|
||||
/** UCHAR **_tx_misra_indirect_void_to_uchar_pointer_convert(VOID **return_ptr); */
|
||||
/** UCHAR **_tx_misra_uchar_to_indirect_uchar_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR *_tx_misra_block_pool_to_uchar_pointer_convert(TX_BLOCK_POOL *pool); */
|
||||
/** TX_BLOCK_POOL *_tx_misra_void_to_block_pool_pointer_convert(VOID *pointer); */
|
||||
/** UCHAR *_tx_misra_void_to_uchar_pointer_convert(VOID *pointer); */
|
||||
/** TX_BLOCK_POOL *_tx_misra_uchar_to_block_pool_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR **_tx_misra_void_to_indirect_uchar_pointer_convert(VOID *pointer); */
|
||||
/** TX_BYTE_POOL *_tx_misra_void_to_byte_pool_pointer_convert(VOID *pointer); */
|
||||
/** UCHAR *_tx_misra_byte_pool_to_uchar_pointer_convert(TX_BYTE_POOL *pool); */
|
||||
/** ALIGN_TYPE *_tx_misra_uchar_to_align_type_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_BYTE_POOL **_tx_misra_uchar_to_indirect_byte_pool_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_EVENT_FLAGS_GROUP *_tx_misra_void_to_event_flags_pointer_convert(VOID *pointer); */
|
||||
/** ULONG *_tx_misra_void_to_ulong_pointer_convert(VOID *pointer); */
|
||||
/** TX_MUTEX *_tx_misra_void_to_mutex_pointer_convert(VOID *pointer); */
|
||||
/** TX_QUEUE *_tx_misra_void_to_queue_pointer_convert(VOID *pointer); */
|
||||
/** TX_SEMAPHORE *_tx_misra_void_to_semaphore_pointer_convert(VOID *pointer); */
|
||||
/** VOID *_tx_misra_uchar_to_void_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_THREAD *_tx_misra_ulong_to_thread_pointer_convert(ULONG value); */
|
||||
/** VOID *_tx_misra_timer_indirect_to_void_pointer_convert(TX_TIMER_INTERNAL **pointer); */
|
||||
/** CHAR *_tx_misra_const_char_to_char_pointer_convert(const char *pointer); */
|
||||
/** TX_THREAD *_tx_misra_void_to_thread_pointer_convert(void *pointer); */
|
||||
/** UCHAR *_tx_misra_object_to_uchar_pointer_convert(TX_TRACE_OBJECT_ENTRY *pointer); */
|
||||
/** TX_TRACE_OBJECT_ENTRY *_tx_misra_uchar_to_object_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_TRACE_HEADER *_tx_misra_uchar_to_header_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_TRACE_BUFFER_ENTRY *_tx_misra_uchar_to_entry_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR *_tx_misra_entry_to_uchar_pointer_convert(TX_TRACE_BUFFER_ENTRY *pointer); */
|
||||
/** UCHAR *_tx_misra_char_to_uchar_pointer_convert(CHAR *pointer); */
|
||||
/** VOID _tx_misra_event_flags_group_not_used(TX_EVENT_FLAGS_GROUP *group_ptr); */
|
||||
/** VOID _tx_misra_event_flags_set_notify_not_used(VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr)); */
|
||||
/** VOID _tx_misra_queue_not_used(TX_QUEUE *queue_ptr); */
|
||||
/** VOID _tx_misra_queue_send_notify_not_used(VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr)); */
|
||||
/** VOID _tx_misra_semaphore_not_used(TX_SEMAPHORE *semaphore_ptr); */
|
||||
/** VOID _tx_misra_semaphore_put_notify_not_used(VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr)); */
|
||||
/** VOID _tx_misra_thread_not_used(TX_THREAD *thread_ptr); */
|
||||
/** VOID _tx_misra_thread_entry_exit_notify_not_used(VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT id)); */
|
||||
/** */
|
||||
/************************************************************************************************************************************/
|
||||
/************************************************************************************************************************************/
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_pointer_to_ulong_convert:
|
||||
_tx_misra_ulong_to_pointer_convert:
|
||||
_tx_misra_indirect_void_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_indirect_uchar_pointer_convert:
|
||||
_tx_misra_block_pool_to_uchar_pointer_convert:
|
||||
_tx_misra_void_to_block_pool_pointer_convert:
|
||||
_tx_misra_void_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_block_pool_pointer_convert:
|
||||
_tx_misra_void_to_indirect_uchar_pointer_convert:
|
||||
_tx_misra_void_to_byte_pool_pointer_convert:
|
||||
_tx_misra_byte_pool_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_align_type_pointer_convert:
|
||||
_tx_misra_uchar_to_indirect_byte_pool_pointer_convert:
|
||||
_tx_misra_void_to_event_flags_pointer_convert:
|
||||
_tx_misra_void_to_ulong_pointer_convert:
|
||||
_tx_misra_void_to_mutex_pointer_convert:
|
||||
_tx_misra_void_to_queue_pointer_convert:
|
||||
_tx_misra_void_to_semaphore_pointer_convert:
|
||||
_tx_misra_uchar_to_void_pointer_convert:
|
||||
_tx_misra_ulong_to_thread_pointer_convert:
|
||||
_tx_misra_timer_indirect_to_void_pointer_convert:
|
||||
_tx_misra_const_char_to_char_pointer_convert:
|
||||
_tx_misra_void_to_thread_pointer_convert:
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
_tx_misra_object_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_object_pointer_convert:
|
||||
_tx_misra_uchar_to_header_pointer_convert:
|
||||
_tx_misra_uchar_to_entry_pointer_convert:
|
||||
_tx_misra_entry_to_uchar_pointer_convert:
|
||||
#endif
|
||||
_tx_misra_char_to_uchar_pointer_convert:
|
||||
_tx_misra_event_flags_group_not_used:
|
||||
_tx_misra_event_flags_set_notify_not_used:
|
||||
_tx_misra_queue_not_used:
|
||||
_tx_misra_queue_send_notify_not_used:
|
||||
_tx_misra_semaphore_not_used:
|
||||
_tx_misra_semaphore_put_notify_not_used:
|
||||
_tx_misra_thread_entry_exit_notify_not_used:
|
||||
_tx_misra_thread_not_used:
|
||||
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG *_tx_misra_ulong_pointer_add(ULONG *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ulong_pointer_add:
|
||||
ADD R0,R0,R1, LSL #+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG *_tx_misra_ulong_pointer_sub(ULONG *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ulong_pointer_sub:
|
||||
MVNS R2,#+3
|
||||
MULS R1,R2,R1
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_ulong_pointer_dif(ULONG *ptr1, ULONG *ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ulong_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
ASRS R0,R0,#+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_message_copy(ULONG **source, ULONG **destination, */
|
||||
/** UINT size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_message_copy:
|
||||
PUSH {R4,R5}
|
||||
LDR R3,[R0, #+0]
|
||||
LDR R4,[R1, #+0]
|
||||
LDR R5,[R3, #+0]
|
||||
STR R5,[R4, #+0]
|
||||
ADDS R4,R4,#+4
|
||||
ADDS R3,R3,#+4
|
||||
CMP R2,#+2
|
||||
BCC.N _tx_misra_message_copy_0
|
||||
SUBS R2,R2,#+1
|
||||
B.N _tx_misra_message_copy_1
|
||||
_tx_misra_message_copy_2:
|
||||
LDR R5,[R3, #+0]
|
||||
STR R5,[R4, #+0]
|
||||
ADDS R4,R4,#+4
|
||||
ADDS R3,R3,#+4
|
||||
SUBS R2,R2,#+1
|
||||
_tx_misra_message_copy_1:
|
||||
CMP R2,#+0
|
||||
BNE.N _tx_misra_message_copy_2
|
||||
_tx_misra_message_copy_0:
|
||||
STR R3,[R0, #+0]
|
||||
STR R4,[R1, #+0]
|
||||
POP {R4,R5}
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_timer_pointer_dif(TX_TIMER_INTERNAL **ptr1, */
|
||||
/** TX_TIMER_INTERNAL **ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_timer_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
ASRS R0,R0,#+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** TX_TIMER_INTERNAL **_tx_misra_timer_pointer_add(TX_TIMER_INTERNAL */
|
||||
/** **ptr1, ULONG size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_timer_pointer_add:
|
||||
ADD R0,R0,R1, LSL #+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_user_timer_pointer_get(TX_TIMER_INTERNAL */
|
||||
/** *internal_timer, TX_TIMER **user_timer); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_user_timer_pointer_get:
|
||||
SUBS R0,#8
|
||||
STR R0,[R1, #+0]
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_thread_stack_check(TX_THREAD *thread_ptr, */
|
||||
/** VOID **highest_stack); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_thread_stack_check:
|
||||
PUSH {R3-R5,LR}
|
||||
MOVS R4,R0
|
||||
MOVS R5,R1
|
||||
BL _tx_thread_interrupt_disable
|
||||
CMP R4,#+0
|
||||
BEQ.N _tx_misra_thread_stack_check_0
|
||||
LDR R1,[R4, #+0]
|
||||
LDR R2,=0x54485244
|
||||
CMP R1,R2
|
||||
BNE.N _tx_misra_thread_stack_check_0
|
||||
LDR R1,[R4, #+8]
|
||||
LDR R2,[R5, #+0]
|
||||
CMP R1,R2
|
||||
BCS.N _tx_misra_thread_stack_check_1
|
||||
LDR R1,[R4, #+8]
|
||||
STR R1,[R5, #+0]
|
||||
_tx_misra_thread_stack_check_1:
|
||||
LDR R1,[R4, #+12]
|
||||
LDR R1,[R1, #+0]
|
||||
CMP R1,#-269488145
|
||||
BNE.N _tx_misra_thread_stack_check_2
|
||||
LDR R1,[R4, #+16]
|
||||
LDR R1,[R1, #+1]
|
||||
CMP R1,#-269488145
|
||||
BNE.N _tx_misra_thread_stack_check_2
|
||||
LDR R1,[R5, #+0]
|
||||
LDR R2,[R4, #+12]
|
||||
CMP R1,R2
|
||||
BCS.N _tx_misra_thread_stack_check_3
|
||||
_tx_misra_thread_stack_check_2:
|
||||
BL _tx_thread_interrupt_restore
|
||||
MOVS R0,R4
|
||||
BL _tx_thread_stack_error_handler
|
||||
BL _tx_thread_interrupt_disable
|
||||
_tx_misra_thread_stack_check_3:
|
||||
LDR R1,[R5, #+0]
|
||||
LDR R1,[R1, #-4]
|
||||
CMP R1,#-269488145
|
||||
BEQ.N _tx_misra_thread_stack_check_0
|
||||
BL _tx_thread_interrupt_restore
|
||||
MOVS R0,R4
|
||||
BL _tx_thread_stack_analyze
|
||||
BL _tx_thread_interrupt_disable
|
||||
_tx_misra_thread_stack_check_0:
|
||||
BL _tx_thread_interrupt_restore
|
||||
POP {R0,R4,R5,PC} // return
|
||||
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_trace_event_insert(ULONG event_id, */
|
||||
/** VOID *info_field_1, ULONG info_field_2, ULONG info_field_3, */
|
||||
/** ULONG info_field_4, ULONG filter, ULONG time_stamp); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_trace_event_insert:
|
||||
PUSH {R3-R7,LR}
|
||||
LDR.N R4,DataTable2_1
|
||||
LDR R4,[R4, #+0]
|
||||
CMP R4,#+0
|
||||
BEQ.N _tx_misra_trace_event_insert_0
|
||||
LDR.N R5,DataTable2_2
|
||||
LDR R5,[R5, #+0]
|
||||
LDR R6,[SP, #+28]
|
||||
TST R5,R6
|
||||
BEQ.N _tx_misra_trace_event_insert_0
|
||||
LDR.N R5,DataTable2_3
|
||||
LDR R5,[R5, #+0]
|
||||
LDR.N R6,DataTable2_4
|
||||
LDR R6,[R6, #+0]
|
||||
CMP R5,#+0
|
||||
BNE.N _tx_misra_trace_event_insert_1
|
||||
LDR R5,[R6, #+44]
|
||||
LDR R7,[R6, #+60]
|
||||
LSLS R7,R7,#+16
|
||||
ORRS R7,R7,#0x80000000
|
||||
ORRS R5,R7,R5
|
||||
B.N _tx_misra_trace_event_insert_2
|
||||
_tx_misra_trace_event_insert_1:
|
||||
CMP R5,#-252645136
|
||||
BCS.N _tx_misra_trace_event_insert_3
|
||||
MOVS R5,R6
|
||||
MOVS R6,#-1
|
||||
B.N _tx_misra_trace_event_insert_2
|
||||
_tx_misra_trace_event_insert_3:
|
||||
MOVS R6,#-252645136
|
||||
MOVS R5,#+0
|
||||
_tx_misra_trace_event_insert_2:
|
||||
STR R6,[R4, #+0]
|
||||
STR R5,[R4, #+4]
|
||||
STR R0,[R4, #+8]
|
||||
LDR R0,[SP, #+32]
|
||||
STR R0,[R4, #+12]
|
||||
STR R1,[R4, #+16]
|
||||
STR R2,[R4, #+20]
|
||||
STR R3,[R4, #+24]
|
||||
LDR R0,[SP, #+24]
|
||||
STR R0,[R4, #+28]
|
||||
ADDS R4,R4,#+32
|
||||
LDR.N R0,DataTable2_5
|
||||
LDR R0,[R0, #+0]
|
||||
CMP R4,R0
|
||||
BCC.N _tx_misra_trace_event_insert_4
|
||||
LDR.N R0,DataTable2_6
|
||||
LDR R4,[R0, #+0]
|
||||
LDR.N R0,DataTable2_1
|
||||
STR R4,[R0, #+0]
|
||||
LDR.N R0,DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
STR R4,[R0, #+32]
|
||||
LDR.N R0,DataTable2_8
|
||||
LDR R0,[R0, #+0]
|
||||
CMP R0,#+0
|
||||
BEQ.N _tx_misra_trace_event_insert_0
|
||||
LDR.N R0,DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
LDR.N R1,DataTable2_8
|
||||
LDR R1,[R1, #+0]
|
||||
BLX R1
|
||||
B.N _tx_misra_trace_event_insert_0
|
||||
_tx_misra_trace_event_insert_4:
|
||||
LDR.N R0,DataTable2_1
|
||||
STR R4,[R0, #+0]
|
||||
LDR.N R0,DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
STR R4,[R0, #+32]
|
||||
_tx_misra_trace_event_insert_0:
|
||||
POP {R0,R4-R7,PC} // return
|
||||
|
||||
|
||||
.data
|
||||
DataTable2_1:
|
||||
.word _tx_trace_buffer_current_ptr
|
||||
|
||||
.data
|
||||
DataTable2_2:
|
||||
.word _tx_trace_event_enable_bits
|
||||
|
||||
.data
|
||||
DataTable2_5:
|
||||
.word _tx_trace_buffer_end_ptr
|
||||
|
||||
.data
|
||||
DataTable2_6:
|
||||
.word _tx_trace_buffer_start_ptr
|
||||
|
||||
.data
|
||||
DataTable2_7:
|
||||
.word _tx_trace_header_ptr
|
||||
|
||||
.data
|
||||
DataTable2_8:
|
||||
.word _tx_trace_full_notify_function
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_time_stamp_get(VOID); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_time_stamp_get:
|
||||
MOVS R0,#+0
|
||||
BX LR // return
|
||||
|
||||
#endif
|
||||
|
||||
.data
|
||||
DataTable2_3:
|
||||
.word _tx_thread_system_state
|
||||
|
||||
.data
|
||||
DataTable2_4:
|
||||
.word _tx_thread_current_ptr
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UINT _tx_misra_always_true(void); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_always_true:
|
||||
MOVS R0,#+1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UINT _tx_misra_status_get(UINT status); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_status_get:
|
||||
MOVS R0,#+0
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_ipsr_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ipsr_get:
|
||||
MRS R0, IPSR
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_control_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_control_get:
|
||||
MRS R0, CONTROL
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** void _tx_misra_control_set(ULONG value); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_control_set:
|
||||
MSR CONTROL, R0
|
||||
BX LR // return
|
||||
|
||||
|
||||
#ifdef __ARM_FP
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_fpccr_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_fpccr_get:
|
||||
LDR r0, =0xE000EF34 // Build FPCCR address
|
||||
LDR r0, [r0] // Load FPCCR value
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** void _tx_misra_vfp_touch(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_vfp_touch:
|
||||
vmov.f32 s0, s0
|
||||
BX LR // return
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
.data
|
||||
.word 0
|
||||
87
ports/cortex_m3/ac6/src/tx_thread_context_restore.S
Normal file
87
ports/cortex_m3/ac6/src/tx_thread_context_restore.S
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
.global _tx_execution_isr_exit
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_restore Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_exit] Execution profiling ISR exit */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs Interrupt Service Routines */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_restore(VOID)
|
||||
// {
|
||||
.global _tx_thread_context_restore
|
||||
.thumb_func
|
||||
_tx_thread_context_restore:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR exit function to indicate an ISR is complete. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_exit // Call the ISR exit function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
BX lr
|
||||
// }
|
||||
88
ports/cortex_m3/ac6/src/tx_thread_context_save.S
Normal file
88
ports/cortex_m3/ac6/src/tx_thread_context_save.S
Normal file
@@ -0,0 +1,88 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
.global _tx_execution_isr_enter
|
||||
#endif
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_save Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_enter] Execution profiling ISR enter */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_save(VOID)
|
||||
// {
|
||||
.global _tx_thread_context_save
|
||||
.thumb_func
|
||||
_tx_thread_context_save:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR enter function to indicate an ISR is starting. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_enter // Call the ISR enter function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
/* Context is already saved - just return. */
|
||||
|
||||
BX lr
|
||||
// }
|
||||
84
ports/cortex_m3/ac6/src/tx_thread_interrupt_control.S
Normal file
84
ports/cortex_m3/ac6/src/tx_thread_interrupt_control.S
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_control Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for changing the interrupt lockout */
|
||||
/* posture of the system. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* new_posture New interrupt lockout posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_control(UINT new_posture)
|
||||
// {
|
||||
.global _tx_thread_interrupt_control
|
||||
.thumb_func
|
||||
_tx_thread_interrupt_control:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Pickup current interrupt posture
|
||||
MSR BASEPRI, r0 // Apply the new interrupt posture
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#else
|
||||
MRS r1, PRIMASK // Pickup current interrupt lockout
|
||||
MSR PRIMASK, r0 // Apply the new interrupt lockout
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#endif
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
84
ports/cortex_m3/ac6/src/tx_thread_interrupt_disable.S
Normal file
84
ports/cortex_m3/ac6/src/tx_thread_interrupt_disable.S
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_disable Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for disabling interrupts and returning */
|
||||
/* the previous interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_disable(VOID)
|
||||
// {
|
||||
.global _tx_thread_interrupt_disable
|
||||
.thumb_func
|
||||
_tx_thread_interrupt_disable:
|
||||
/* Return current interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r0, BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
MRS r0, PRIMASK
|
||||
CPSID i
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
81
ports/cortex_m3/ac6/src/tx_thread_interrupt_restore.S
Normal file
81
ports/cortex_m3/ac6/src/tx_thread_interrupt_restore.S
Normal file
@@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_restore Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for restoring the previous */
|
||||
/* interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* previous_posture Previous interrupt posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_interrupt_restore(UINT previous_posture)
|
||||
// {
|
||||
.global _tx_thread_interrupt_restore
|
||||
.thumb_func
|
||||
_tx_thread_interrupt_restore:
|
||||
/* Restore previous interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
MSR PRIMASK, r0
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
330
ports/cortex_m3/ac6/src/tx_thread_schedule.S
Normal file
330
ports/cortex_m3/ac6/src/tx_thread_schedule.S
Normal file
@@ -0,0 +1,330 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.global _tx_thread_current_ptr
|
||||
.global _tx_thread_execute_ptr
|
||||
.global _tx_timer_time_slice
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
.global _tx_execution_thread_enter
|
||||
.global _tx_execution_thread_exit
|
||||
#endif
|
||||
#ifdef TX_LOW_POWER
|
||||
.global tx_low_power_enter
|
||||
.global tx_low_power_exit
|
||||
#endif
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function waits for a thread control block pointer to appear in */
|
||||
/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
|
||||
/* in the variable, the corresponding thread is resumed. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 04-25-2022 Scott Larson Added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
// {
|
||||
.global _tx_thread_schedule
|
||||
.thumb_func
|
||||
_tx_thread_schedule:
|
||||
|
||||
/* This function should only ever be called on Cortex-M
|
||||
from the first schedule request. Subsequent scheduling occurs
|
||||
from the PendSV handling routine below. */
|
||||
|
||||
/* Clear the preempt-disable flag to enable rescheduling after initialization on Cortex-M targets. */
|
||||
|
||||
MOV r0, #0 // Build value for TX_FALSE
|
||||
LDR r2, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
STR r0, [r2, #0] // Clear preempt disable flag
|
||||
|
||||
/* Clear CONTROL.FPCA bit so VFP registers aren't unnecessarily stacked. */
|
||||
|
||||
#ifdef __ARM_PCS_VFP
|
||||
MRS r0, CONTROL // Pickup current CONTROL register
|
||||
BIC r0, r0, #4 // Clear the FPCA bit
|
||||
MSR CONTROL, r0 // Setup new CONTROL register
|
||||
#endif
|
||||
|
||||
/* Enable interrupts */
|
||||
CPSIE i
|
||||
|
||||
/* Enter the scheduler for the first time. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
DSB // Complete all memory accesses
|
||||
ISB // Flush pipeline
|
||||
|
||||
/* Wait here for the PendSV to take place. */
|
||||
|
||||
__tx_wait_here:
|
||||
B __tx_wait_here // Wait for the PendSV to happen
|
||||
// }
|
||||
|
||||
/* Generic context switching PendSV handler. */
|
||||
|
||||
.global PendSV_Handler
|
||||
.global __tx_PendSVHandler
|
||||
.syntax unified
|
||||
.thumb_func
|
||||
PendSV_Handler:
|
||||
.thumb_func
|
||||
__tx_PendSVHandler:
|
||||
|
||||
/* Get current thread value and new thread pointer. */
|
||||
|
||||
__tx_ts_handler:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
MOV r3, #0 // Build NULL value
|
||||
LDR r1, [r0] // Pickup current thread pointer
|
||||
|
||||
/* Determine if there is a current thread to finish preserving. */
|
||||
|
||||
CBZ r1, __tx_ts_new // If NULL, skip preservation
|
||||
|
||||
/* Recover PSP and preserve current thread context. */
|
||||
|
||||
STR r3, [r0] // Set _tx_thread_current_ptr to NULL
|
||||
MRS r12, PSP // Pickup PSP pointer (thread's stack pointer)
|
||||
STMDB r12!, {r4-r11} // Save its remaining registers
|
||||
#ifdef __ARM_PCS_VFP
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_save
|
||||
VSTMDB r12!,{s16-s31} // Yes, save additional VFP registers
|
||||
_skip_vfp_save:
|
||||
#endif
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
STMDB r12!, {LR} // Save LR on the stack
|
||||
|
||||
/* Determine if time-slice is active. If it isn't, skip time handling processing. */
|
||||
|
||||
LDR r5, [r4] // Pickup current time-slice
|
||||
STR r12, [r1, #8] // Save the thread stack pointer
|
||||
CBZ r5, __tx_ts_new // If not active, skip processing
|
||||
|
||||
/* Time-slice is active, save the current thread's time-slice and clear the global time-slice variable. */
|
||||
|
||||
STR r5, [r1, #24] // Save current time-slice
|
||||
|
||||
/* Clear the global time-slice. */
|
||||
|
||||
STR r3, [r4] // Clear time-slice
|
||||
|
||||
/* Executing thread is now completely preserved!!! */
|
||||
|
||||
__tx_ts_new:
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBZ r1, __tx_ts_wait // No, skip to the wait processing
|
||||
|
||||
/* Yes, another thread is ready for else, make the current thread the new thread. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
__tx_ts_restore:
|
||||
LDR r7, [r1, #4] // Pickup the current thread run count
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
LDR r5, [r1, #24] // Pickup thread's current time-slice
|
||||
ADD r7, r7, #1 // Increment the thread run count
|
||||
STR r7, [r1, #4] // Store the new run count
|
||||
|
||||
/* Setup global time-slice with thread's current time-slice. */
|
||||
|
||||
STR r5, [r4] // Setup global time-slice
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread entry function to indicate the thread is executing. */
|
||||
PUSH {r0, r1} // Save r0 and r1
|
||||
BL _tx_execution_thread_enter // Call the thread execution enter function
|
||||
POP {r0, r1} // Recover r0 and r1
|
||||
#endif
|
||||
|
||||
/* Restore the thread context and PSP. */
|
||||
|
||||
LDR r12, [r1, #8] // Pickup thread's stack pointer
|
||||
LDMIA r12!, {LR} // Pickup LR
|
||||
#ifdef __ARM_PCS_VFP
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_restore // If not, skip VFP restore
|
||||
VLDMIA r12!, {s16-s31} // Yes, restore additional VFP registers
|
||||
_skip_vfp_restore:
|
||||
#endif
|
||||
LDMIA r12!, {r4-r11} // Recover thread's registers
|
||||
MSR PSP, r12 // Setup the thread's stack pointer
|
||||
|
||||
/* Return to thread. */
|
||||
|
||||
BX lr // Return to thread!
|
||||
|
||||
/* The following is the idle wait processing... in this case, no threads are ready for execution and the
|
||||
system will simply be idle until an interrupt occurs that makes a thread ready. Note that interrupts
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
STR r1, [r0] // Store it in the current pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_enter // Possibly enter low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_WFI
|
||||
DSB // Ensure no outstanding memory transactions
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_exit // Exit low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
already in the handler! */
|
||||
|
||||
__tx_ts_ready:
|
||||
MOV r7, #0x08000000 // Build clear PendSV value
|
||||
MOV r8, #0xE000E000 // Build base NVIC address
|
||||
STR r7, [r8, #0xD04] // Clear any PendSV
|
||||
|
||||
/* Re-enable interrupts and restore new thread. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_restore // Restore the thread
|
||||
// }
|
||||
|
||||
#ifdef __ARM_PCS_VFP
|
||||
|
||||
.global tx_thread_fpu_enable
|
||||
.thumb_func
|
||||
tx_thread_fpu_enable:
|
||||
.global tx_thread_fpu_disable
|
||||
.thumb_func
|
||||
tx_thread_fpu_disable:
|
||||
|
||||
/* Automatic VPF logic is supported, this function is present only for
|
||||
backward compatibility purposes and therefore simply returns. */
|
||||
|
||||
BX LR // Return to caller
|
||||
|
||||
#endif
|
||||
138
ports/cortex_m3/ac6/src/tx_thread_stack_build.S
Normal file
138
ports/cortex_m3/ac6/src/tx_thread_stack_build.S
Normal file
@@ -0,0 +1,138 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_stack_build Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function builds a stack frame on the supplied thread's stack. */
|
||||
/* The stack frame results in a fake interrupt return to the supplied */
|
||||
/* function pointer. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* thread_ptr Pointer to thread control blk */
|
||||
/* function_ptr Pointer to return function */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_thread_create Create thread service */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
|
||||
// {
|
||||
.global _tx_thread_stack_build
|
||||
.thumb_func
|
||||
_tx_thread_stack_build:
|
||||
|
||||
/* Build a fake interrupt frame. The form of the fake interrupt stack
|
||||
on the Cortex-M should look like the following after it is built:
|
||||
|
||||
Stack Top:
|
||||
LR Interrupted LR (LR at time of PENDSV)
|
||||
r4 Initial value for r4
|
||||
r5 Initial value for r5
|
||||
r6 Initial value for r6
|
||||
r7 Initial value for r7
|
||||
r8 Initial value for r8
|
||||
r9 Initial value for r9
|
||||
r10 Initial value for r10
|
||||
r11 Initial value for r11
|
||||
r0 Initial value for r0 (Hardware stack starts here!!)
|
||||
r1 Initial value for r1
|
||||
r2 Initial value for r2
|
||||
r3 Initial value for r3
|
||||
r12 Initial value for r12
|
||||
lr Initial value for lr
|
||||
pc Initial value for pc
|
||||
xPSR Initial value for xPSR
|
||||
|
||||
Stack Bottom: (higher memory address) */
|
||||
|
||||
LDR r2, [r0, #16] // Pickup end of stack area
|
||||
BIC r2, r2, #0x7 // Align frame for 8-byte alignment
|
||||
SUB r2, r2, #68 // Subtract frame size
|
||||
LDR r3, =0xFFFFFFFD // Build initial LR value
|
||||
STR r3, [r2, #0] // Save on the stack
|
||||
|
||||
/* Actually build the stack frame. */
|
||||
|
||||
MOV r3, #0 // Build initial register value
|
||||
STR r3, [r2, #4] // Store initial r4
|
||||
STR r3, [r2, #8] // Store initial r5
|
||||
STR r3, [r2, #12] // Store initial r6
|
||||
STR r3, [r2, #16] // Store initial r7
|
||||
STR r3, [r2, #20] // Store initial r8
|
||||
STR r3, [r2, #24] // Store initial r9
|
||||
STR r3, [r2, #28] // Store initial r10
|
||||
STR r3, [r2, #32] // Store initial r11
|
||||
|
||||
/* Hardware stack follows. */
|
||||
|
||||
STR r3, [r2, #36] // Store initial r0
|
||||
STR r3, [r2, #40] // Store initial r1
|
||||
STR r3, [r2, #44] // Store initial r2
|
||||
STR r3, [r2, #48] // Store initial r3
|
||||
STR r3, [r2, #52] // Store initial r12
|
||||
MOV r3, #0xFFFFFFFF // Poison EXC_RETURN value
|
||||
STR r3, [r2, #56] // Store initial lr
|
||||
STR r1, [r2, #60] // Store initial pc
|
||||
MOV r3, #0x01000000 // Only T-bit need be set
|
||||
STR r3, [r2, #64] // Store initial xPSR
|
||||
|
||||
/* Setup stack pointer. */
|
||||
// thread_ptr -> tx_thread_stack_ptr = r2;
|
||||
|
||||
STR r2, [r0, #8] // Save stack pointer in thread's
|
||||
// control block
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
98
ports/cortex_m3/ac6/src/tx_thread_system_return.S
Normal file
98
ports/cortex_m3/ac6/src/tx_thread_system_return.S
Normal file
@@ -0,0 +1,98 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_system_return Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is target processor specific. It is used to transfer */
|
||||
/* control from a thread back to the ThreadX system. Only a */
|
||||
/* minimal context is saved since the compiler assumes temp registers */
|
||||
/* are going to get slicked by a function call anyway. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_thread_schedule Thread scheduling loop */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ThreadX components */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_system_return(VOID)
|
||||
// {
|
||||
.thumb_func
|
||||
.global _tx_thread_system_return
|
||||
_tx_thread_system_return:
|
||||
|
||||
/* Return to real scheduler via PendSV. Note that this routine is often
|
||||
replaced with in-line assembly in tx_port.h to improved performance. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
MRS r0, IPSR // Pickup IPSR
|
||||
CMP r0, #0 // Is it a thread returning?
|
||||
BNE _isr_context // If ISR, skip interrupt enable
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Thread context returning, pickup BASEPRI
|
||||
MOV r0, #0
|
||||
MSR BASEPRI, r0 // Enable interrupts
|
||||
MSR BASEPRI, r1 // Restore original interrupt posture
|
||||
#else
|
||||
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
|
||||
CPSIE i // Enable interrupts
|
||||
MSR PRIMASK, r1 // Restore original interrupt posture
|
||||
#endif
|
||||
_isr_context:
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
260
ports/cortex_m3/ac6/src/tx_timer_interrupt.S
Normal file
260
ports/cortex_m3/ac6/src/tx_timer_interrupt.S
Normal file
@@ -0,0 +1,260 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Timer */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.global _tx_timer_time_slice
|
||||
.global _tx_timer_system_clock
|
||||
.global _tx_timer_current_ptr
|
||||
.global _tx_timer_list_start
|
||||
.global _tx_timer_list_end
|
||||
.global _tx_timer_expired_time_slice
|
||||
.global _tx_timer_expired
|
||||
.global _tx_thread_time_slice
|
||||
.global _tx_timer_expiration_process
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_timer_interrupt Cortex-M3/AC6 */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function processes the hardware timer interrupt. This */
|
||||
/* processing includes incrementing the system clock and checking for */
|
||||
/* time slice and/or timer expiration. If either is found, the */
|
||||
/* expiration functions are called. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_timer_expiration_process Timer expiration processing */
|
||||
/* _tx_thread_time_slice Time slice interrupted thread */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* interrupt vector */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comment(s), added */
|
||||
/* TX_NO_TIMER support, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_timer_interrupt(VOID)
|
||||
// {
|
||||
#ifndef TX_NO_TIMER
|
||||
.global _tx_timer_interrupt
|
||||
.thumb_func
|
||||
_tx_timer_interrupt:
|
||||
|
||||
/* Upon entry to this routine, it is assumed that the compiler scratch registers are available
|
||||
for use. */
|
||||
|
||||
/* Increment the system clock. */
|
||||
// _tx_timer_system_clock++;
|
||||
|
||||
LDR r1, =_tx_timer_system_clock // Pickup address of system clock
|
||||
LDR r0, [r1, #0] // Pickup system clock
|
||||
ADD r0, r0, #1 // Increment system clock
|
||||
STR r0, [r1, #0] // Store new system clock
|
||||
|
||||
/* Test for time-slice expiration. */
|
||||
// if (_tx_timer_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_time_slice // Pickup address of time-slice
|
||||
LDR r2, [r3, #0] // Pickup time-slice
|
||||
CBZ r2, __tx_timer_no_time_slice // Is it non-active?
|
||||
// Yes, skip time-slice processing
|
||||
|
||||
/* Decrement the time_slice. */
|
||||
// _tx_timer_time_slice--;
|
||||
|
||||
SUB r2, r2, #1 // Decrement the time-slice
|
||||
STR r2, [r3, #0] // Store new time-slice value
|
||||
|
||||
/* Check for expiration. */
|
||||
// if (__tx_timer_time_slice == 0)
|
||||
|
||||
CBNZ r2, __tx_timer_no_time_slice // Has it expired?
|
||||
// No, skip expiration processing
|
||||
|
||||
/* Set the time-slice expired flag. */
|
||||
// _tx_timer_expired_time_slice = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup address of expired flag
|
||||
MOV r0, #1 // Build expired value
|
||||
STR r0, [r3, #0] // Set time-slice expiration flag
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_no_time_slice:
|
||||
|
||||
/* Test for timer expiration. */
|
||||
// if (*_tx_timer_current_ptr)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_current_ptr // Pickup current timer pointer address
|
||||
LDR r0, [r1, #0] // Pickup current timer
|
||||
LDR r2, [r0, #0] // Pickup timer list entry
|
||||
CBZ r2, __tx_timer_no_timer // Is there anything in the list?
|
||||
// No, just increment the timer
|
||||
|
||||
/* Set expiration flag. */
|
||||
// _tx_timer_expired = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired // Pickup expiration flag address
|
||||
MOV r2, #1 // Build expired value
|
||||
STR r2, [r3, #0] // Set expired flag
|
||||
B __tx_timer_done // Finished timer processing
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
__tx_timer_no_timer:
|
||||
|
||||
/* No timer expired, increment the timer pointer. */
|
||||
// _tx_timer_current_ptr++;
|
||||
|
||||
ADD r0, r0, #4 // Move to next timer
|
||||
|
||||
/* Check for wrap-around. */
|
||||
// if (_tx_timer_current_ptr == _tx_timer_list_end)
|
||||
|
||||
LDR r3, =_tx_timer_list_end // Pickup addr of timer list end
|
||||
LDR r2, [r3, #0] // Pickup list end
|
||||
CMP r0, r2 // Are we at list end?
|
||||
BNE __tx_timer_skip_wrap // No, skip wrap-around logic
|
||||
|
||||
/* Wrap to beginning of list. */
|
||||
// _tx_timer_current_ptr = _tx_timer_list_start;
|
||||
|
||||
LDR r3, =_tx_timer_list_start // Pickup addr of timer list start
|
||||
LDR r0, [r3, #0] // Set current pointer to list start
|
||||
|
||||
__tx_timer_skip_wrap:
|
||||
|
||||
STR r0, [r1, #0] // Store new current timer pointer
|
||||
// }
|
||||
|
||||
__tx_timer_done:
|
||||
|
||||
/* See if anything has expired. */
|
||||
// if ((_tx_timer_expired_time_slice) || (_tx_timer_expired))
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of expired flag
|
||||
LDR r2, [r3, #0] // Pickup time-slice expired flag
|
||||
CBNZ r2, __tx_something_expired // Did a time-slice expire?
|
||||
// If non-zero, time-slice expired
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of other expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_nothing_expired // Did a timer expire?
|
||||
// No, nothing expired
|
||||
|
||||
__tx_something_expired:
|
||||
|
||||
STMDB sp!, {r0, lr} // Save the lr register on the stack
|
||||
// and save r0 just to keep 8-byte alignment
|
||||
|
||||
/* Did a timer expire? */
|
||||
// if (_tx_timer_expired)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_dont_activate // Check for timer expiration
|
||||
// If not set, skip timer activation
|
||||
|
||||
/* Process timer expiration. */
|
||||
// _tx_timer_expiration_process();
|
||||
|
||||
BL _tx_timer_expiration_process // Call the timer expiration handling routine
|
||||
|
||||
// }
|
||||
__tx_timer_dont_activate:
|
||||
|
||||
/* Did time slice expire? */
|
||||
// if (_tx_timer_expired_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of time-slice expired
|
||||
LDR r2, [r3, #0] // Pickup the actual flag
|
||||
CBZ r2, __tx_timer_not_ts_expiration // See if the flag is set
|
||||
// No, skip time-slice processing
|
||||
|
||||
/* Time slice interrupted thread. */
|
||||
// _tx_thread_time_slice();
|
||||
|
||||
BL _tx_thread_time_slice // Call time-slice processing
|
||||
LDR r0, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
LDR r1, [r0] // Is the preempt disable flag set?
|
||||
CBNZ r1, __tx_timer_skip_time_slice // Yes, skip the PendSV logic
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r1, [r0] // Pickup the current thread pointer
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
LDR r3, [r2] // Pickup the execute thread pointer
|
||||
LDR r0, =0xE000ED04 // Build address of control register
|
||||
LDR r2, =0x10000000 // Build value for PendSV bit
|
||||
CMP r1, r3 // Are they the same?
|
||||
BEQ __tx_timer_skip_time_slice // If the same, there was no time-slice performed
|
||||
STR r2, [r0] // Not the same, issue the PendSV for preemption
|
||||
__tx_timer_skip_time_slice:
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_not_ts_expiration:
|
||||
|
||||
LDMIA sp!, {r0, lr} // Recover lr register (r0 is just there for
|
||||
// the 8-byte stack alignment
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_nothing_expired:
|
||||
|
||||
DSB // Complete all memory access
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
#endif
|
||||
764
ports/cortex_m3/ghs/inc/tx_el.h
Normal file
764
ports/cortex_m3/ghs/inc/tx_el.h
Normal file
@@ -0,0 +1,764 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** ThreadX/GHS Event Log (EL) */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* COMPONENT DEFINITION RELEASE */
|
||||
/* */
|
||||
/* tx_el.h PORTABLE C/GHS */
|
||||
/* 6.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file defines the ThreadX event log functions for the GHS MULTI */
|
||||
/* EventAnalyzer. It is assumed that tx_api.h and tx_port.h have */
|
||||
/* already been included. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_EL_H
|
||||
#define TX_EL_H
|
||||
|
||||
|
||||
/* Define Event Log specific data definitions. */
|
||||
|
||||
#define TX_EL_VERSION_ID 2 /* Event log version ID */
|
||||
#define TX_EL_HEADER_SIZE 24 /* Event log header size */
|
||||
#define TX_EL_TNIS 16 /* Number of thread names supported */
|
||||
/* If the application needs to */
|
||||
/* track more thread names, just */
|
||||
/* increase this number and re- */
|
||||
/* build the ThreadX library. */
|
||||
#define TX_EL_TNI_ENTRY_SIZE 44 /* Thread name entries are 44 bytes */
|
||||
#define TX_EL_TNI_NAME_SIZE 34 /* Thread name size in TNI */
|
||||
#define TX_EL_NO_MORE_TNI_ROOM 1 /* Error return from thread register*/
|
||||
#define TX_EL_NAME_NOT_FOUND 2 /* Error return from un-register */
|
||||
#define TX_EL_EVENT_SIZE 32 /* Number of bytes in each event */
|
||||
#define TX_EL_VALID_ENTRY 1 /* Valid log entry */
|
||||
#define TX_EL_INVALID_ENTRY 0 /* Invalid log entry */
|
||||
|
||||
|
||||
/* Define necessary offsets. */
|
||||
|
||||
#define TX_EL_TNI_VALID_OFFSET 34
|
||||
#define TX_EL_TNI_THREAD_ID_OFFSET 36
|
||||
#define TX_EL_TNI_THREAD_PRIORITY_OFF 40
|
||||
#define TX_EL_EVENT_TYPE_OFFSET 0
|
||||
#define TX_EL_EVENT_SUBTYPE_OFFSET 2
|
||||
#define TX_EL_EVENT_TIME_UPPER_OFFSET 4
|
||||
#define TX_EL_EVENT_TIME_LOWER_OFFSET 8
|
||||
#define TX_EL_EVENT_THREAD_OFFSET 12
|
||||
#define TX_EL_EVENT_INFO_1_OFFSET 16
|
||||
#define TX_EL_EVENT_INFO_2_OFFSET 20
|
||||
#define TX_EL_EVENT_INFO_3_OFFSET 24
|
||||
#define TX_EL_EVENT_INFO_4_OFFSET 28
|
||||
|
||||
|
||||
/* Undefine constants that might be been defined previously by tx_api.h. */
|
||||
|
||||
#undef TX_EL_INITIALIZE
|
||||
#undef TX_EL_THREAD_REGISTER
|
||||
#undef TX_EL_THREAD_UNREGISTER
|
||||
#undef TX_EL_THREAD_STATUS_CHANGE_INSERT
|
||||
#undef TX_EL_BYTE_ALLOCATE_INSERT
|
||||
#undef TX_EL_BYTE_POOL_CREATE_INSERT
|
||||
#undef TX_EL_BYTE_POOL_DELETE_INSERT
|
||||
#undef TX_EL_BYTE_RELEASE_INSERT
|
||||
#undef TX_EL_BLOCK_ALLOCATE_INSERT
|
||||
#undef TX_EL_BLOCK_POOL_CREATE_INSERT
|
||||
#undef TX_EL_BLOCK_POOL_DELETE_INSERT
|
||||
#undef TX_EL_BLOCK_RELEASE_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_CREATE_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_DELETE_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_GET_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_SET_INSERT
|
||||
#undef TX_EL_INTERRUPT_CONTROL_INSERT
|
||||
#undef TX_EL_QUEUE_CREATE_INSERT
|
||||
#undef TX_EL_QUEUE_DELETE_INSERT
|
||||
#undef TX_EL_QUEUE_FLUSH_INSERT
|
||||
#undef TX_EL_QUEUE_RECEIVE_INSERT
|
||||
#undef TX_EL_QUEUE_SEND_INSERT
|
||||
#undef TX_EL_SEMAPHORE_CREATE_INSERT
|
||||
#undef TX_EL_SEMAPHORE_DELETE_INSERT
|
||||
#undef TX_EL_SEMAPHORE_GET_INSERT
|
||||
#undef TX_EL_SEMAPHORE_PUT_INSERT
|
||||
#undef TX_EL_THREAD_CREATE_INSERT
|
||||
#undef TX_EL_THREAD_DELETE_INSERT
|
||||
#undef TX_EL_THREAD_IDENTIFY_INSERT
|
||||
#undef TX_EL_THREAD_PREEMPTION_CHANGE_INSERT
|
||||
#undef TX_EL_THREAD_PRIORITY_CHANGE_INSERT
|
||||
#undef TX_EL_THREAD_RELINQUISH_INSERT
|
||||
#undef TX_EL_THREAD_RESUME_INSERT
|
||||
#undef TX_EL_THREAD_SLEEP_INSERT
|
||||
#undef TX_EL_THREAD_SUSPEND_INSERT
|
||||
#undef TX_EL_THREAD_TERMINATE_INSERT
|
||||
#undef TX_EL_THREAD_TIME_SLICE_CHANGE_INSERT
|
||||
#undef TX_EL_TIME_GET_INSERT
|
||||
#undef TX_EL_TIME_SET_INSERT
|
||||
#undef TX_EL_TIMER_ACTIVATE_INSERT
|
||||
#undef TX_EL_TIMER_CHANGE_INSERT
|
||||
#undef TX_EL_TIMER_CREATE_INSERT
|
||||
#undef TX_EL_TIMER_DEACTIVATE_INSERT
|
||||
#undef TX_EL_TIMER_DELETE_INSERT
|
||||
#undef TX_EL_BLOCK_POOL_INFO_GET_INSERT
|
||||
#undef TX_EL_BLOCK_POOL_PRIORITIZE_INSERT
|
||||
#undef TX_EL_BYTE_POOL_INFO_GET_INSERT
|
||||
#undef TX_EL_BYTE_POOL_PRIORITIZE_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_INFO_GET_INSERT
|
||||
#undef TX_EL_MUTEX_CREATE_INSERT
|
||||
#undef TX_EL_MUTEX_DELETE_INSERT
|
||||
#undef TX_EL_MUTEX_GET_INSERT
|
||||
#undef TX_EL_MUTEX_INFO_GET_INSERT
|
||||
#undef TX_EL_MUTEX_PRIORITIZE_INSERT
|
||||
#undef TX_EL_MUTEX_PUT_INSERT
|
||||
#undef TX_EL_QUEUE_INFO_GET_INSERT
|
||||
#undef TX_EL_QUEUE_FRONT_SEND_INSERT
|
||||
#undef TX_EL_QUEUE_PRIORITIZE_INSERT
|
||||
#undef TX_EL_SEMAPHORE_INFO_GET_INSERT
|
||||
#undef TX_EL_SEMAPHORE_PRIORITIZE_INSERT
|
||||
#undef TX_EL_THREAD_INFO_GET_INSERT
|
||||
#undef TX_EL_THREAD_WAIT_ABORT_INSERT
|
||||
#undef TX_EL_TIMER_INFO_GET_INSERT
|
||||
#undef TX_EL_BLOCK_POOL_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_BLOCK_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_BYTE_POOL_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_BYTE_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_EVENT_FLAGS_SET_NOTIFY_INSERT
|
||||
#undef TX_EL_MUTEX_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_MUTEX_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_QUEUE_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_QUEUE_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_QUEUE_SEND_NOTIFY_INSERT
|
||||
#undef TX_EL_SEMAPHORE_CEILING_PUT_INSERT
|
||||
#undef TX_EL_SEMAPHORE_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_SEMAPHORE_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_SEMAPHORE_PUT_NOTIFY_INSERT
|
||||
#undef TX_EL_THREAD_ENTRY_EXIT_NOTIFY_INSERT
|
||||
#undef TX_EL_THREAD_RESET_INSERT
|
||||
#undef TX_EL_THREAD_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_THREAD_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
#undef TX_EL_THREAD_STACK_ERROR_NOTIFY_INSERT
|
||||
#undef TX_EL_TIMER_PERFORMANCE_INFO_GET_INSERT
|
||||
#undef TX_EL_TIMER_PERFORMANCE_SYSTEM_INFO_GET_INSERT
|
||||
|
||||
|
||||
/* Define Event Types. */
|
||||
|
||||
#define TX_EL_THREAD_CHANGE 1
|
||||
#define TX_EL_INTERRUPT 2
|
||||
#define TX_EL_THREADX_CALL 3
|
||||
#define TX_EL_USER_EVENT 4
|
||||
#define TX_EL_THREAD_STATUS_CHANGE 5
|
||||
#define TX_EL_REFRESH 6 /* Not implemented */
|
||||
#define TX_EL_TIMER 7 /* Not implemented */
|
||||
#define TX_EL_TIMESOURCE_DELTA 8 /* Not implemented */
|
||||
|
||||
|
||||
/* Define TX_EL_THREADX_CALL event sub-types. */
|
||||
|
||||
#define TX_EL_BYTE_ALLOCATE 0
|
||||
#define TX_EL_BYTE_POOL_CREATE 1
|
||||
#define TX_EL_BYTE_POOL_DELETE 2
|
||||
#define TX_EL_BYTE_RELEASE 3
|
||||
#define TX_EL_BLOCK_ALLOCATE 4
|
||||
#define TX_EL_BLOCK_POOL_CREATE 5
|
||||
#define TX_EL_BLOCK_POOL_DELETE 6
|
||||
#define TX_EL_BLOCK_RELEASE 7
|
||||
#define TX_EL_EVENT_FLAGS_CREATE 8
|
||||
#define TX_EL_EVENT_FLAGS_DELETE 9
|
||||
#define TX_EL_EVENT_FLAGS_GET 10
|
||||
#define TX_EL_EVENT_FLAGS_SET 11
|
||||
#define TX_EL_INTERRUPT_CONTROL 12
|
||||
#define TX_EL_QUEUE_CREATE 13
|
||||
#define TX_EL_QUEUE_DELETE 14
|
||||
#define TX_EL_QUEUE_FLUSH 15
|
||||
#define TX_EL_QUEUE_RECEIVE 16
|
||||
#define TX_EL_QUEUE_SEND 17
|
||||
#define TX_EL_SEMAPHORE_CREATE 18
|
||||
#define TX_EL_SEMAPHORE_DELETE 19
|
||||
#define TX_EL_SEMAPHORE_GET 20
|
||||
#define TX_EL_SEMAPHORE_PUT 21
|
||||
#define TX_EL_THREAD_CREATE 22
|
||||
#define TX_EL_THREAD_DELETE 23
|
||||
#define TX_EL_THREAD_IDENTIFY 24
|
||||
#define TX_EL_THREAD_PREEMPTION_CHANGE 25
|
||||
#define TX_EL_THREAD_PRIORITY_CHANGE 26
|
||||
#define TX_EL_THREAD_RELINQUISH 27
|
||||
#define TX_EL_THREAD_RESUME 28
|
||||
#define TX_EL_THREAD_SLEEP 29
|
||||
#define TX_EL_THREAD_SUSPEND 30
|
||||
#define TX_EL_THREAD_TERMINATE 31
|
||||
#define TX_EL_THREAD_TIME_SLICE_CHANGE 32
|
||||
#define TX_EL_TIME_GET 33
|
||||
#define TX_EL_TIME_SET 34
|
||||
#define TX_EL_TIMER_ACTIVATE 35
|
||||
#define TX_EL_TIMER_CHANGE 36
|
||||
#define TX_EL_TIMER_CREATE 37
|
||||
#define TX_EL_TIMER_DEACTIVATE 38
|
||||
#define TX_EL_TIMER_DELETE 39
|
||||
#define TX_EL_BLOCK_POOL_INFO_GET 40
|
||||
#define TX_EL_BLOCK_POOL_PRIORITIZE 41
|
||||
#define TX_EL_BYTE_POOL_INFO_GET 42
|
||||
#define TX_EL_BYTE_POOL_PRIORITIZE 43
|
||||
#define TX_EL_EVENT_FLAGS_INFO_GET 44
|
||||
#define TX_EL_MUTEX_CREATE 45
|
||||
#define TX_EL_MUTEX_DELETE 46
|
||||
#define TX_EL_MUTEX_GET 47
|
||||
#define TX_EL_MUTEX_INFO_GET 48
|
||||
#define TX_EL_MUTEX_PRIORITIZE 49
|
||||
#define TX_EL_MUTEX_PUT 50
|
||||
#define TX_EL_QUEUE_INFO_GET 51
|
||||
#define TX_EL_QUEUE_FRONT_SEND 52
|
||||
#define TX_EL_QUEUE_PRIORITIZE 53
|
||||
#define TX_EL_SEMAPHORE_INFO_GET 54
|
||||
#define TX_EL_SEMAPHORE_PRIORITIZE 55
|
||||
#define TX_EL_THREAD_INFO_GET 56
|
||||
#define TX_EL_THREAD_WAIT_ABORT 57
|
||||
#define TX_EL_TIMER_INFO_GET 58
|
||||
#define TX_EL_BLOCK_POOL_PERFORMANCE_INFO_GET 59
|
||||
#define TX_EL_BLOCK_POOL_PERFORMANCE_SYSTEM_INFO_GET 60
|
||||
#define TX_EL_BYTE_POOL_PERFORMANCE_INFO_GET 61
|
||||
#define TX_EL_BYTE_POOL_PERFORMANCE_SYSTEM_INFO_GET 62
|
||||
#define TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET 63
|
||||
#define TX_EL_EVENT_FLAGS_PERFORMANCE_SYSTEM_INFO_GET 64
|
||||
#define TX_EL_EVENT_FLAGS_SET_NOTIFY 65
|
||||
#define TX_EL_MUTEX_PERFORMANCE_INFO_GET 66
|
||||
#define TX_EL_MUTEX_PERFORMANCE_SYSTEM_INFO_GET 67
|
||||
#define TX_EL_QUEUE_PERFORMANCE_INFO_GET 68
|
||||
#define TX_EL_QUEUE_PERFORMANCE_SYSTEM_INFO_GET 69
|
||||
#define TX_EL_QUEUE_SEND_NOTIFY 70
|
||||
#define TX_EL_SEMAPHORE_CEILING_PUT 71
|
||||
#define TX_EL_SEMAPHORE_PERFORMANCE_INFO_GET 72
|
||||
#define TX_EL_SEMAPHORE_PERFORMANCE_SYSTEM_INFO_GET 73
|
||||
#define TX_EL_SEMAPHORE_PUT_NOTIFY 74
|
||||
#define TX_EL_THREAD_ENTRY_EXIT_NOTIFY 75
|
||||
#define TX_EL_THREAD_RESET 76
|
||||
#define TX_EL_THREAD_PERFORMANCE_INFO_GET 77
|
||||
#define TX_EL_THREAD_PERFORMANCE_SYSTEM_INFO_GET 78
|
||||
#define TX_EL_THREAD_STACK_ERROR_NOTIFY 79
|
||||
#define TX_EL_TIMER_PERFORMANCE_INFO_GET 80
|
||||
#define TX_EL_TIMER_PERFORMANCE_SYSTEM_INFO_GET 81
|
||||
|
||||
|
||||
/* Define ThreadX sub-types. */
|
||||
|
||||
#define TX_EL_INTERRUPT_SUB_TYPE 1
|
||||
#define TX_EL_END_OF_INTERRUPT 3
|
||||
|
||||
|
||||
/* Define event logging filters, which may be used by the application program to
|
||||
dynamically enable/disable events in run-time. */
|
||||
|
||||
#define TX_EL_FILTER_STATUS_CHANGE 0x0001
|
||||
#define TX_EL_FILTER_INTERRUPTS 0x0002
|
||||
#define TX_EL_FILTER_THREAD_CALLS 0x0004
|
||||
#define TX_EL_FILTER_TIMER_CALLS 0x0008
|
||||
#define TX_EL_FILTER_EVENT_FLAG_CALLS 0x0010
|
||||
#define TX_EL_FILTER_SEMAPHORE_CALLS 0x0020
|
||||
#define TX_EL_FILTER_QUEUE_CALLS 0x0040
|
||||
#define TX_EL_FILTER_BLOCK_CALLS 0x0080
|
||||
#define TX_EL_FILTER_BYTE_CALLS 0x0100
|
||||
#define TX_EL_FILTER_MUTEX_CALLS 0x0200
|
||||
#define TX_EL_FILTER_ALL_EVENTS 0xFFFF
|
||||
#define TX_EL_ENABLE_ALL_EVENTS 0x0000
|
||||
|
||||
|
||||
/* Define filter macros that are inserted in-line with the other macros below. */
|
||||
|
||||
#ifdef TX_ENABLE_EVENT_FILTERS
|
||||
#define TX_EL_NO_STATUS_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_STATUS_CHANGE)) {
|
||||
#define TX_EL_NO_INTERRUPT_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_INTERRUPTS)) {
|
||||
#define TX_EL_NO_THREAD_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_THREAD_CALLS)) {
|
||||
#define TX_EL_NO_TIMER_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_TIMER_CALLS)) {
|
||||
#define TX_EL_NO_EVENT_FLAG_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_EVENT_FLAG_CALLS)) {
|
||||
#define TX_EL_NO_SEMAPHORE_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_SEMAPHORE_CALLS)) {
|
||||
#define TX_EL_NO_QUEUE_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_QUEUE_CALLS)) {
|
||||
#define TX_EL_NO_BLOCK_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_BLOCK_CALLS)) {
|
||||
#define TX_EL_NO_BYTE_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_BYTE_CALLS)) {
|
||||
#define TX_EL_NO_MUTEX_EVENTS if (!(_tx_el_event_filter & TX_EL_FILTER_MUTEX_CALLS)) {
|
||||
#define TX_EL_END_FILTER }
|
||||
#else
|
||||
#define TX_EL_NO_STATUS_EVENTS
|
||||
#define TX_EL_NO_INTERRUPT_EVENTS
|
||||
#define TX_EL_NO_THREAD_EVENTS
|
||||
#define TX_EL_NO_TIMER_EVENTS
|
||||
#define TX_EL_NO_EVENT_FLAG_EVENTS
|
||||
#define TX_EL_NO_SEMAPHORE_EVENTS
|
||||
#define TX_EL_NO_QUEUE_EVENTS
|
||||
#define TX_EL_NO_BLOCK_EVENTS
|
||||
#define TX_EL_NO_BYTE_EVENTS
|
||||
#define TX_EL_NO_MUTEX_EVENTS
|
||||
#define TX_EL_END_FILTER
|
||||
#endif
|
||||
|
||||
/* Define externs and constants for non-event log source modules. This is for
|
||||
the in-line macros below. */
|
||||
|
||||
#ifndef TX_EL_SOURCE_CODE
|
||||
extern UCHAR *_tx_el_tni_start;
|
||||
extern UCHAR **_tx_el_current_event;
|
||||
extern UCHAR *_tx_el_event_area_start;
|
||||
extern UCHAR *_tx_el_event_area_end;
|
||||
extern UINT _tx_el_maximum_events;
|
||||
extern ULONG _tx_el_total_events;
|
||||
extern TX_THREAD *_tx_thread_current_ptr;
|
||||
extern UINT _tx_el_event_filter;
|
||||
extern ULONG _tx_el_time_base_upper;
|
||||
extern ULONG _tx_el_time_base_lower;
|
||||
|
||||
|
||||
/* Define macros for event logging functions. */
|
||||
|
||||
#define TX_EL_THREAD_CREATE_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(TX_EL_THREAD_CREATE, thread_ptr, stack_start, stack_size, priority); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_SET_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_EVENT_FLAGS_SET, group_ptr, flags_to_set, set_option); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_DELETE_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_DELETE, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_INFO_GET_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_INFO_GET, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_TIME_SLICE_CHANGE_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_THREAD_TIME_SLICE_CHANGE, thread_ptr, thread_ptr -> tx_thread_new_time_slice, new_time_slice); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_TERMINATE_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_TERMINATE, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_SLEEP_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_SLEEP, timer_ticks); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_SUSPEND_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_SUSPEND, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_RELINQUISH_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_THREAD_RELINQUISH); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_RESUME_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_RESUME, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_PRIORITY_CHANGE_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_THREAD_PRIORITY_CHANGE, thread_ptr, thread_ptr -> tx_thread_priority, new_priority); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_PREEMPTION_CHANGE_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_THREAD_PREEMPTION_CHANGE, thread_ptr, thread_ptr -> tx_thread_preempt_threshold, new_threshold); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_WAIT_ABORT_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_WAIT_ABORT, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_ENTRY_EXIT_NOTIFY_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_THREAD_ENTRY_EXIT_NOTIFY, thread_ptr, thread_entry_exit_notify); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_RESET_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_RESET, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_PERFORMANCE_INFO_GET, thread_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_THREAD_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_STACK_ERROR_NOTIFY_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_THREAD_STACK_ERROR_NOTIFY, stack_error_handler); TX_EL_END_FILTER
|
||||
#define TX_EL_TIME_SET_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIME_SET, new_time); TX_EL_END_FILTER
|
||||
#define TX_EL_TIME_GET_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIME_GET, _tx_timer_system_clock); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_DELETE_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIMER_DELETE, timer_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_CREATE_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(TX_EL_TIMER_CREATE, timer_ptr, initial_ticks, reschedule_ticks, auto_activate); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_CHANGE_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_TIMER_CHANGE, timer_ptr, initial_ticks, reschedule_ticks); TX_EL_END_FILTER
|
||||
#define TX_EL_THREAD_IDENTIFY_INSERT TX_EL_NO_THREAD_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_THREAD_IDENTIFY); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_DEACTIVATE_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIMER_DEACTIVATE, timer_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_ACTIVATE_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIMER_ACTIVATE, timer_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_INFO_GET_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIMER_INFO_GET, timer_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_TIMER_PERFORMANCE_INFO_GET, timer_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_TIMER_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_TIMER_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_TIMER_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_PUT_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_SEMAPHORE_PUT, semaphore_ptr, semaphore_ptr -> tx_semaphore_count); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_GET_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_SEMAPHORE_GET, semaphore_ptr, semaphore_ptr -> tx_semaphore_count); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_DELETE_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_SEMAPHORE_DELETE, semaphore_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_CREATE_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_SEMAPHORE_CREATE, semaphore_ptr, initial_count); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_INFO_GET_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_SEMAPHORE_INFO_GET, semaphore_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_PRIORITIZE_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_SEMAPHORE_PRIORITIZE, semaphore_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_CEILING_PUT_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_SEMAPHORE_CEILING_PUT, semaphore_ptr, semaphore_ptr -> tx_semaphore_count, ceiling); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_SEMAPHORE_PERFORMANCE_INFO_GET, semaphore_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_SEMAPHORE_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_SEMAPHORE_PUT_NOTIFY_INSERT TX_EL_NO_SEMAPHORE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_SEMAPHORE_PUT_NOTIFY, semaphore_ptr, semaphore_put_notify); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_FRONT_SEND_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_QUEUE_FRONT_SEND, queue_ptr, source_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_SEND_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_QUEUE_SEND, queue_ptr, source_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_RECEIVE_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_QUEUE_RECEIVE, queue_ptr, destination_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_FLUSH_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_QUEUE_FLUSH, queue_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_DELETE_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_QUEUE_DELETE, queue_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_CREATE_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(TX_EL_QUEUE_CREATE, queue_ptr, queue_start, queue_size, message_size); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_INFO_GET_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_QUEUE_INFO_GET, queue_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_PRIORITIZE_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_QUEUE_PRIORITIZE, queue_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_QUEUE_PERFORMANCE_INFO_GET, queue_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_QUEUE_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_QUEUE_SEND_NOTIFY_INSERT TX_EL_NO_QUEUE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_QUEUE_SEND_NOTIFY, queue_ptr, queue_send_notify); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_GET_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_EVENT_FLAGS_GET, group_ptr, requested_flags, get_option); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_DELETE_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_EVENT_FLAGS_DELETE, group_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_CREATE_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_EVENT_FLAGS_CREATE, group_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_INFO_GET_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_EVENT_FLAGS_INFO_GET, group_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET, group_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_EVENT_FLAGS_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_EVENT_FLAGS_SET_NOTIFY_INSERT TX_EL_NO_EVENT_FLAG_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_EVENT_FLAGS_SET_NOTIFY, group_ptr, events_set_notify); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_RELEASE_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_BYTE_RELEASE, pool_ptr, memory_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_POOL_DELETE_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BYTE_POOL_DELETE, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_POOL_CREATE_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_BYTE_POOL_CREATE, pool_ptr, pool_start, pool_size); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_POOL_INFO_GET_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BYTE_POOL_INFO_GET, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_POOL_PRIORITIZE_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BYTE_POOL_PRIORITIZE, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_ALLOCATE_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_BYTE_ALLOCATE, pool_ptr, memory_ptr, memory_size); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_POOL_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BYTE_POOL_PERFORMANCE_INFO_GET, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BYTE_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_BYTE_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_BYTE_POOL_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_RELEASE_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_BLOCK_RELEASE, pool_ptr, block_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_POOL_DELETE_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BLOCK_POOL_DELETE, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_POOL_CREATE_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(TX_EL_BLOCK_POOL_CREATE, pool_ptr, pool_start, pool_size, block_size); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_POOL_INFO_GET_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BLOCK_POOL_INFO_GET, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_POOL_PRIORITIZE_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BLOCK_POOL_PRIORITIZE, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_ALLOCATE_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_BLOCK_ALLOCATE, pool_ptr, block_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_POOL_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_BLOCK_POOL_PERFORMANCE_INFO_GET, pool_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_BLOCK_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_BLOCK_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_BLOCK_POOL_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_CREATE_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(TX_EL_MUTEX_CREATE, mutex_ptr, inherit); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_DELETE_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_MUTEX_DELETE, mutex_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_GET_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_MUTEX_GET, mutex_ptr, mutex_ptr -> tx_mutex_owner, mutex_ptr -> tx_mutex_ownership_count); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_INFO_GET_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_MUTEX_INFO_GET, mutex_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_PRIORITIZE_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_MUTEX_PRIORITIZE, mutex_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_PUT_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(TX_EL_MUTEX_PUT, mutex_ptr, mutex_ptr -> tx_mutex_owner, mutex_ptr -> tx_mutex_ownership_count); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_PERFORMANCE_INFO_GET_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(TX_EL_MUTEX_PERFORMANCE_INFO_GET, mutex_ptr); TX_EL_END_FILTER
|
||||
#define TX_EL_MUTEX_PERFORMANCE_SYSTEM_INFO_GET_INSERT TX_EL_NO_MUTEX_EVENTS TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(TX_EL_MUTEX_PERFORMANCE_SYSTEM_INFO_GET); TX_EL_END_FILTER
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Define Event Log function prototypes. */
|
||||
|
||||
VOID _tx_el_initialize(VOID);
|
||||
UINT _tx_el_thread_register(TX_THREAD *thread_ptr);
|
||||
UINT _tx_el_thread_unregister(TX_THREAD *thread_ptr);
|
||||
VOID _tx_el_user_event_insert(UINT sub_type, ULONG info_1, ULONG info_2,
|
||||
ULONG info_3, ULONG info_4);
|
||||
VOID _tx_el_thread_running(TX_THREAD *thread_ptr);
|
||||
VOID _tx_el_thread_preempted(TX_THREAD *thread_ptr);
|
||||
VOID _tx_el_interrupt(UINT interrupt_number);
|
||||
VOID _tx_el_interrupt_end(UINT interrupt_number);
|
||||
VOID _tx_el_interrupt_control_call(void);
|
||||
VOID _tx_el_event_log_on(void);
|
||||
VOID _tx_el_event_log_off(void);
|
||||
VOID _tx_el_event_filter_set(UINT filter);
|
||||
|
||||
|
||||
/* Define macros that are used inside the ThreadX source code.
|
||||
If event logging is disabled, these macros will be defined
|
||||
as white space. */
|
||||
|
||||
#ifdef TX_ENABLE_EVENT_LOGGING
|
||||
#ifndef TX_NO_EVENT_INFO
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(a, b, c, d, e) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_1_OFFSET)) =\
|
||||
(ULONG) b;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_2_OFFSET)) =\
|
||||
(ULONG) c;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_3_OFFSET)) =\
|
||||
(ULONG) d;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_4_OFFSET)) =\
|
||||
(ULONG) e;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(a, b, c, d) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_1_OFFSET)) =\
|
||||
(ULONG) b;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_2_OFFSET)) =\
|
||||
(ULONG) c;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_3_OFFSET)) =\
|
||||
(ULONG) d;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(a, b, c) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_1_OFFSET)) =\
|
||||
(ULONG) b;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_2_OFFSET)) =\
|
||||
(ULONG) c;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(a, b) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_INFO_1_OFFSET)) =\
|
||||
(ULONG) b;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(a) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_THREAD_STATUS_CHANGE_INSERT(a, b) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
TX_EL_NO_STATUS_EVENTS \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREAD_STATUS_CHANGE; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) b; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) a;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
TX_EL_END_FILTER \
|
||||
}
|
||||
#define TX_EL_THREAD_REGISTER(a) \
|
||||
_tx_el_thread_register(a);
|
||||
#define TX_EL_THREAD_UNREGISTER(a) \
|
||||
_tx_el_thread_unregister(a);
|
||||
#define TX_EL_INITIALIZE _tx_el_initialize();
|
||||
#else
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(a, b, c, d, e) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(a, b, c, d) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(a, b, c) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(a, b) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(a) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREADX_CALL; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) a; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) _tx_thread_current_ptr;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
}
|
||||
#define TX_EL_THREAD_STATUS_CHANGE_INSERT(a, b) \
|
||||
{ \
|
||||
UCHAR *entry_ptr; \
|
||||
ULONG upper_tbu; \
|
||||
TX_EL_NO_STATUS_EVENTS \
|
||||
entry_ptr = *_tx_el_current_event; \
|
||||
*((unsigned short *) entry_ptr) = TX_EL_THREAD_STATUS_CHANGE; \
|
||||
*((unsigned short *) (entry_ptr + TX_EL_EVENT_SUBTYPE_OFFSET)) = (unsigned short) b; \
|
||||
do { \
|
||||
upper_tbu = read_tbu(); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_UPPER_OFFSET)) = upper_tbu; \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_TIME_LOWER_OFFSET)) =\
|
||||
(ULONG) read_tbl();\
|
||||
} while (upper_tbu != read_tbu()); \
|
||||
*((ULONG *) (entry_ptr + TX_EL_EVENT_THREAD_OFFSET)) =\
|
||||
(ULONG) a;\
|
||||
entry_ptr = entry_ptr + TX_EL_EVENT_SIZE;\
|
||||
if (entry_ptr >= _tx_el_event_area_end) \
|
||||
{\
|
||||
entry_ptr = _tx_el_event_area_start;\
|
||||
}\
|
||||
*_tx_el_current_event = entry_ptr;\
|
||||
TX_EL_END_FILTER \
|
||||
}
|
||||
#define TX_EL_THREAD_REGISTER(a) \
|
||||
_tx_el_thread_register(a);
|
||||
#define TX_EL_THREAD_UNREGISTER(a) \
|
||||
_tx_el_thread_unregister(a);
|
||||
#define TX_EL_INITIALIZE _tx_el_initialize();
|
||||
#endif
|
||||
#else
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO4(a, b, c, d, e)
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO3(a, b, c, d)
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO2(a, b, c)
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO1(a, b)
|
||||
#define TX_EL_KERNEL_CALL_EVENT_INSERT_INFO0(a)
|
||||
#define TX_EL_THREAD_STATUS_CHANGE_INSERT(a, b)
|
||||
#define TX_EL_THREAD_REGISTER(a)
|
||||
#define TX_EL_THREAD_UNREGISTER(a)
|
||||
#define TX_EL_INITIALIZE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
77
ports/cortex_m3/ghs/inc/tx_ghs.h
Normal file
77
ports/cortex_m3/ghs/inc/tx_ghs.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* ThreadX C/C++ Library Support
|
||||
*
|
||||
* Copyright 1983-2019 Green Hills Software LLC.
|
||||
*
|
||||
* This program is the property of Green Hills Software LLC.,
|
||||
* its contents are proprietary information and no part of it
|
||||
* is to be disclosed to anyone except employees of Green Hills
|
||||
* Software LLC., or as agreed in writing signed by the President
|
||||
* of Green Hills Software LLC.
|
||||
*/
|
||||
|
||||
#ifndef _TX_GHS_H_
|
||||
#define _TX_GHS_H_
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#if defined(__ghs) && (__GHS_VERSION_NUMBER >= 500)
|
||||
extern void *__ghs_GetThreadLocalStorageItem(int specifier);
|
||||
|
||||
/* Thread-local storage routines for Green Hills releases 5.x and beyond.
|
||||
The following specifiers are used when calling
|
||||
__ghs_GetThreadLocalStorageItem.
|
||||
|
||||
If __ghs_GetThreadLocalStorageItem is customized to
|
||||
return a per-thread errno value, define the preprocessor symbol
|
||||
USE_THREAD_LOCAL_ERRNO in ind_errn.c.
|
||||
*/
|
||||
|
||||
enum __ghs_ThreadLocalStorage_specifier {
|
||||
__ghs_TLS_asctime_buff,
|
||||
__ghs_TLS_tmpnam_space,
|
||||
__ghs_TLS_strtok_saved_pos,
|
||||
__ghs_TLS_Errno,
|
||||
__ghs_TLS_gmtime_temp,
|
||||
__ghs_TLS___eh_globals,
|
||||
__ghs_TLS_SignalHandlers
|
||||
};
|
||||
#else
|
||||
/* Thread-local storage routines for Green Hills releases 4.x and 3.x . */
|
||||
typedef void (*SignalHandler)(int);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int Errno; /* errno. */
|
||||
SignalHandler SignalHandlers[_SIGMAX]; /* signal() buffer. */
|
||||
char tmpnam_space[L_tmpnam]; /* tmpnam(NULL) buffer. */
|
||||
char asctime_buff[30]; /* . */
|
||||
char *strtok_saved_pos; /* strtok() position. */
|
||||
struct tm gmtime_temp; /* gmtime() and localtime() buffer. */
|
||||
void *__eh_globals; /* Pointer for C++ exception handling. */
|
||||
} ThreadLocalStorage;
|
||||
|
||||
ThreadLocalStorage *GetThreadLocalStorage(void);
|
||||
#endif
|
||||
|
||||
|
||||
void __ghsLock(void);
|
||||
void __ghsUnlock(void);
|
||||
|
||||
int __ghs_SaveSignalContext(jmp_buf);
|
||||
void __ghs_RestoreSignalContext(jmp_buf);
|
||||
|
||||
/* prototypes for FILE lock routines. */
|
||||
void __ghs_flock_file(void *);
|
||||
void __ghs_funlock_file(void *);
|
||||
int __ghs_ftrylock_file(void *);
|
||||
void __ghs_flock_create(void **);
|
||||
void __ghs_flock_destroy(void *);
|
||||
|
||||
/* prototype for GHS/ThreadX error shell checking. */
|
||||
void __ghs_rnerr(char *errMsg, int stackLevels, int stackTraceDisplay, void *hexVal);
|
||||
|
||||
#endif /* _TX_GHS_H_ */
|
||||
391
ports/cortex_m3/ghs/inc/tx_port.h
Normal file
391
ports/cortex_m3/ghs/inc/tx_port.h
Normal file
@@ -0,0 +1,391 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Port Specific */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M3/GHS */
|
||||
/* 6.1.10 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file contains data type definitions that make the ThreadX */
|
||||
/* real-time kernel function identically on a variety of different */
|
||||
/* processor architectures. For example, the size or number of bits */
|
||||
/* in an "int" data type vary between microprocessor architectures and */
|
||||
/* even C compilers for the same microprocessor. ThreadX does not */
|
||||
/* directly use native C data types. Instead, ThreadX creates its */
|
||||
/* own special types that can be mapped to actual data types by this */
|
||||
/* file to guarantee consistency in the interface and functionality. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
/* 01-31-2022 Bhupendra Naphade Modified comment(s),updated */
|
||||
/* macro definition, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_PORT_H
|
||||
#define TX_PORT_H
|
||||
|
||||
|
||||
/* Determine if the optional ThreadX user define file should be used. */
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler library include files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <arm_ghs.h>
|
||||
#include "tx_ghs.h"
|
||||
|
||||
|
||||
/* Define ThreadX basic types for this port. */
|
||||
|
||||
#define VOID void
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
|
||||
|
||||
/* Define the priority levels for ThreadX. Legal values range
|
||||
from 32 to 1024 and MUST be evenly divisible by 32. */
|
||||
|
||||
#ifndef TX_MAX_PRIORITIES
|
||||
#define TX_MAX_PRIORITIES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
|
||||
thread creation is less than this value, the thread create call will return an error. */
|
||||
|
||||
#ifndef TX_MINIMUM_STACK
|
||||
#define TX_MINIMUM_STACK 200 /* Minimum stack size for this port */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the system timer thread's default stack size and priority. These are only applicable
|
||||
if TX_TIMER_PROCESS_IN_ISR is not defined. */
|
||||
|
||||
#ifndef TX_TIMER_THREAD_STACK_SIZE
|
||||
#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */
|
||||
#endif
|
||||
|
||||
#ifndef TX_TIMER_THREAD_PRIORITY
|
||||
#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define various constants for the ThreadX ARM Cortex-M port. */
|
||||
|
||||
#define TX_INT_DISABLE 1 /* Disable interrupts */
|
||||
#define TX_INT_ENABLE 0 /* Enable interrupts */
|
||||
|
||||
|
||||
/* Define the clock source for trace event entry time stamp. The following two item are port specific.
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
#endif
|
||||
|
||||
|
||||
/* Define constants for Green Hills EventAnalyzer. */
|
||||
|
||||
/* Define the number of ticks per second. This informs the EventAnalyzer what the timestamps
|
||||
represent. By default, this is set to 1,000,000 i.e., one tick every microsecond. */
|
||||
|
||||
#define TX_EL_TICKS_PER_SECOND 1000000
|
||||
|
||||
/* Define the method of how to get the upper and lower 32-bits of the time stamp. By default, simply
|
||||
simulate the time-stamp source with a counter. */
|
||||
|
||||
#define read_tbu() _tx_el_time_base_upper
|
||||
#define read_tbl() ++_tx_el_time_base_lower
|
||||
|
||||
|
||||
/* Define the port specific options for the _tx_build_options variable. This variable indicates
|
||||
how the ThreadX library was built. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_BUILD_OPTIONS (0)
|
||||
|
||||
|
||||
/* Define the in-line initialization constant so that modules with in-line
|
||||
initialization capabilities can prevent their initialization from being
|
||||
a function call. */
|
||||
|
||||
#define TX_INLINE_INITIALIZATION
|
||||
|
||||
|
||||
/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
|
||||
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
|
||||
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
|
||||
define is negated, thereby forcing the stack fill which is necessary for the stack checking
|
||||
logic. */
|
||||
|
||||
#ifdef TX_ENABLE_STACK_CHECKING
|
||||
#undef TX_DISABLE_STACK_FILLING
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the TX_THREAD control block extensions for this port. The main reason
|
||||
for the multiple macros is so that backward compatibility can be maintained with
|
||||
existing ThreadX kernel awareness modules. */
|
||||
|
||||
#define TX_THREAD_EXTENSION_0
|
||||
#define TX_THREAD_EXTENSION_1
|
||||
#define TX_THREAD_EXTENSION_2 VOID * tx_thread_eh_globals; \
|
||||
int Errno; /* errno. */ \
|
||||
char * strtok_saved_pos; /* strtok() position. */
|
||||
#ifndef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
#define TX_THREAD_EXTENSION_3
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_3 unsigned long long tx_thread_execution_time_total; \
|
||||
unsigned long long tx_thread_execution_time_last_start;
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the port extensions of the remaining ThreadX objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_EXTENSION
|
||||
#define TX_BYTE_POOL_EXTENSION
|
||||
#define TX_EVENT_FLAGS_GROUP_EXTENSION
|
||||
#define TX_MUTEX_EXTENSION
|
||||
#define TX_QUEUE_EXTENSION
|
||||
#define TX_SEMAPHORE_EXTENSION
|
||||
#define TX_TIMER_EXTENSION
|
||||
|
||||
|
||||
/* Define the user extension field of the thread control block. Nothing
|
||||
additional is needed for this port so it is defined as white space. */
|
||||
|
||||
#ifndef TX_THREAD_USER_EXTENSION
|
||||
#define TX_THREAD_USER_EXTENSION
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
|
||||
tx_thread_shell_entry, and tx_thread_terminate. */
|
||||
|
||||
#if (__GHS_VERSION_NUMBER >= 500)
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) \
|
||||
{ \
|
||||
extern void __tx_cpp_exception_init(TX_THREAD *thread_ptr); \
|
||||
__tx_cpp_exception_init(thread_ptr); \
|
||||
}
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) \
|
||||
{ \
|
||||
#pragma weak __cpp_exception_init \
|
||||
extern void __cpp_exception_init(void **); \
|
||||
static void (*const cpp_init_funcp)(void **) = __cpp_exception_init; \
|
||||
if (cpp_init_funcp) \
|
||||
__cpp_exception_init(&(thread_ptr -> tx_thread_eh_globals)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (__GHS_VERSION_NUMBER >= 500)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) \
|
||||
{ \
|
||||
extern void __tx_cpp_exception_cleanup(TX_THREAD *thread_ptr); \
|
||||
__tx_cpp_exception_cleanup(thread_ptr); \
|
||||
}
|
||||
#else
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) \
|
||||
{ \
|
||||
#pragma weak __cpp_exception_cleanup \
|
||||
extern void __cpp_exception_cleanup(void **); \
|
||||
static void (*const cpp_cleanup_funcp)(void **) = \
|
||||
__cpp_exception_cleanup; \
|
||||
if (cpp_cleanup_funcp) \
|
||||
__cpp_exception_cleanup(&(thread_ptr -> tx_thread_eh_globals)); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object creation extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_CREATE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object deletion extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_DELETE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the get system state macro. */
|
||||
|
||||
#ifndef TX_THREAD_GET_SYSTEM_STATE
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __MRS(__IPSR))
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the check for whether or not to call the _tx_thread_system_return function. A non-zero value
|
||||
indicates that _tx_thread_system_return should not be called. This overrides the definition in tx_thread.h
|
||||
for Cortex-M since so we don't waste time checking the _tx_thread_system_state variable that is always
|
||||
zero after initialization for Cortex-M ports. */
|
||||
|
||||
#ifndef TX_THREAD_SYSTEM_RETURN_CHECK
|
||||
#define TX_THREAD_SYSTEM_RETURN_CHECK(c) (c) = ((ULONG) _tx_thread_preempt_disable);
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macro to ensure _tx_thread_preempt_disable is set early in initialization in order to
|
||||
prevent early scheduling on Cortex-M parts. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_POST_INITIALIZATION _tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
/* Determine if the ARM architecture has the CLZ instruction. This is available on
|
||||
architectures v5 and above. If available, redefine the macro for calculating the
|
||||
lowest bit set. */
|
||||
|
||||
#ifndef TX_DISABLE_INLINE
|
||||
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) m = m & ((ULONG) (-((LONG) m))); \
|
||||
b = __CLZ32(m); \
|
||||
b = 31 - b;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Define ThreadX interrupt lockout and restore macros for protection on
|
||||
access of critical kernel information. The restore interrupt macro must
|
||||
restore the interrupt posture of the running thread prior to the value
|
||||
present prior to the disable macro. In most cases, the save area macro
|
||||
is used to define a local function save area for the disable and restore
|
||||
macros. */
|
||||
|
||||
#ifdef TX_DISABLE_INLINE
|
||||
|
||||
UINT _tx_thread_interrupt_disable(VOID);
|
||||
VOID _tx_thread_interrupt_restore(UINT previous_posture);
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register int interrupt_save;
|
||||
|
||||
#define TX_DISABLE interrupt_save = _tx_thread_interrupt_control(TX_INT_DISABLE);
|
||||
|
||||
#define TX_RESTORE _tx_thread_interrupt_control(interrupt_save);
|
||||
|
||||
#else
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register int interrupt_save;
|
||||
|
||||
/* Define ThreadX interrupt lockout and restore macros using
|
||||
asm macros. */
|
||||
|
||||
asm int disable_ints(void)
|
||||
{
|
||||
%
|
||||
MRS r0,PRIMASK
|
||||
MOV r1,1
|
||||
MSR PRIMASK,r1
|
||||
%error
|
||||
}
|
||||
|
||||
asm void restore_ints(int a)
|
||||
{
|
||||
%reg a
|
||||
MSR PRIMASK,a
|
||||
%mem a
|
||||
LDR r0,a
|
||||
MSR PRIMASK,r0
|
||||
%error
|
||||
}
|
||||
|
||||
#define TX_DISABLE interrupt_save = disable_ints();
|
||||
|
||||
#define TX_RESTORE restore_ints(interrupt_save);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the interrupt lockout macros for each ThreadX object. */
|
||||
|
||||
#define TX_BLOCK_POOL_DISABLE TX_DISABLE
|
||||
#define TX_BYTE_POOL_DISABLE TX_DISABLE
|
||||
#define TX_EVENT_FLAGS_GROUP_DISABLE TX_DISABLE
|
||||
#define TX_MUTEX_DISABLE TX_DISABLE
|
||||
#define TX_QUEUE_DISABLE TX_DISABLE
|
||||
#define TX_SEMAPHORE_DISABLE TX_DISABLE
|
||||
|
||||
|
||||
/* Define the version ID of ThreadX. This may be utilized by the application. */
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) 2024 Microsoft Corporation. * ThreadX Cortex-M3/GHS Version 6.4.2 *";
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
1164
ports/cortex_m3/ghs/src/tx_el.c
Normal file
1164
ports/cortex_m3/ghs/src/tx_el.c
Normal file
File diff suppressed because it is too large
Load Diff
485
ports/cortex_m3/ghs/src/tx_ghs.c
Normal file
485
ports/cortex_m3/ghs/src/tx_ghs.c
Normal file
@@ -0,0 +1,485 @@
|
||||
/*
|
||||
* ThreadX C/C++ Library Support
|
||||
*
|
||||
* Copyright 1983-2019 Green Hills Software LLC.
|
||||
*
|
||||
* This program is the property of Green Hills Software LLC.,
|
||||
* its contents are proprietary information and no part of it
|
||||
* is to be disclosed to anyone except employees of Green Hills
|
||||
* Software LLC., or as agreed in writing signed by the President
|
||||
* of Green Hills Software LLC.
|
||||
*/
|
||||
|
||||
#include "tx_ghs.h"
|
||||
#ifndef TX_DISABLE_ERROR_CHECKING
|
||||
#define TX_DISABLE_ERROR_CHECKING
|
||||
#endif
|
||||
#include "tx_api.h"
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Allow these routines to access the following ThreadX global variables. */
|
||||
extern ULONG _tx_thread_created_count;
|
||||
extern TX_THREAD *_tx_thread_created_ptr;
|
||||
extern TX_THREAD *_tx_thread_current_ptr;
|
||||
|
||||
#if defined(__ghs) && (__GHS_VERSION_NUMBER >= 500)
|
||||
/* Thread-local storage routines for Green Hills releases 5.x and above. */
|
||||
/*
|
||||
Thread-Local (Per-Thread) Library Data Retrieval
|
||||
================================================
|
||||
|
||||
__ghs_ThreadLocalStorage_specifier defines all library data items
|
||||
that the Green Hills libraries allow to be allocated per-thread.
|
||||
|
||||
An implementation can choose which of these data items to allocate
|
||||
for each thread. For example, an implementation may choose to
|
||||
allocate an errno value for each thread, but not the strtok_saved_pos
|
||||
pointer. The application could then use strtok_r instead of strtok for
|
||||
correct operation.
|
||||
|
||||
To add per-thread library data, define one of the
|
||||
TX_THREAD_EXTENSION_* macros in tx_port.h to include the data item
|
||||
or items in each thread control block TX_THREAD.
|
||||
|
||||
If C++ with exceptions is being used, the __eh_globals entry must be
|
||||
allocated for each thread. This is typically done by default using
|
||||
TX_THREAD_EXTENSION_1 in tx_port.h.
|
||||
|
||||
If __ghs_GetThreadLocalStorageItem is customized to return a
|
||||
per-thread errno value, you should also:
|
||||
|
||||
* Customize the System Library for your project
|
||||
* Define the preprocessor symbol USE_THREAD_LOCAL_ERRNO in
|
||||
src/libsys/ind_errn.c
|
||||
|
||||
If you customize the System Library, you should remove ind_thrd.c
|
||||
from the libsys.gpj subproject.
|
||||
|
||||
*/
|
||||
|
||||
/* Provide global __eh_globals value to support C++ exception handling
|
||||
outside a thread context. This name also forces this module to be
|
||||
included in the linked program instead of the ind_thrd.o module from
|
||||
the System Library libsys.a.
|
||||
*/
|
||||
static void *__eh_globals;
|
||||
|
||||
#pragma ghs startnomisra
|
||||
void *__ghs_GetThreadLocalStorageItem(int specifier)
|
||||
{
|
||||
void *ptlsitem = (void *)0;
|
||||
switch (specifier) {
|
||||
case (int)__ghs_TLS_Errno:
|
||||
/* Set ptslsitem to the address of the per-thread errno value.
|
||||
The per-thread errno value should have the type int.
|
||||
|
||||
If returning a per-thread errno value, follow the steps
|
||||
above.
|
||||
|
||||
This item is used by numerous library functions.
|
||||
*/
|
||||
break;
|
||||
case (int)__ghs_TLS_SignalHandlers:
|
||||
/* Set ptslsitem to the address of the per-thread SignalHandlers
|
||||
array. The per-thread SignalHandlers array should have the
|
||||
array type as in the following declaration:
|
||||
SignalHandler SignalHandlers[_SIGMAX];
|
||||
The SignalHandler type and _SIGMAX constant are defined in
|
||||
ind_thrd.h.
|
||||
|
||||
This item is used by the library functions signal() and
|
||||
raise().
|
||||
*/
|
||||
break;
|
||||
case (int)__ghs_TLS_asctime_buff:
|
||||
/* Set ptslsitem to the address of the per-thread asctime_buff
|
||||
array. The per-thread asctime_buff array should have the
|
||||
array type as in the following declaration:
|
||||
char asctime_buff[30];
|
||||
|
||||
This item is used by the library functions asctime() and
|
||||
ctime(). The library provides asctime_r() and ctime_r(),
|
||||
inherently thread-safe versions of these functions.
|
||||
*/
|
||||
break;
|
||||
case (int)__ghs_TLS_tmpnam_space:
|
||||
/* Set ptslsitem to the address of the per-thread tmpnam_space
|
||||
array. The per-thread tmpnam_space array should have the
|
||||
array type as in the following declaration:
|
||||
char tmpnam_space[L_tmpnam];
|
||||
The constant is defined in <stdio.h>
|
||||
|
||||
This item is used by the library function tmpnam() when
|
||||
passed NULL. The library provides tmpnam_r(), an
|
||||
inherently thread-safe version of tmpnam().
|
||||
*/
|
||||
break;
|
||||
case (int)__ghs_TLS_strtok_saved_pos:
|
||||
/* Set ptslsitem to the address of the per-thread
|
||||
strtok_saved_pos pointer. The per-thread strtok_saved_pos
|
||||
pointer should have the type "char *".
|
||||
|
||||
This item is used by the library function strtok().
|
||||
The library provides strtok_r(), an inherently thread-safe
|
||||
version of strtok().
|
||||
*/
|
||||
break;
|
||||
case (int)__ghs_TLS_gmtime_temp:
|
||||
/* Set ptslsitem to the address of the per-thread gmtime_temp
|
||||
value. The per-thread gmtime_temp value should have the
|
||||
type "struct tm" defined in time.h, included by indos.h.
|
||||
|
||||
This item is used by the library functions gmtime() and
|
||||
localtime(). The library provides gmtime_r() and
|
||||
localtime_r(), inherently thread-safe versions of these
|
||||
functions.
|
||||
*/
|
||||
break;
|
||||
case (int)__ghs_TLS___eh_globals:
|
||||
/* Set ptslsitem to the address of the per-thread __eh_globals
|
||||
value. The per-thread __eh_globals value should have the
|
||||
type "void *".
|
||||
|
||||
This item is used by C++ exception handling.
|
||||
*/
|
||||
if (_tx_thread_current_ptr)
|
||||
ptlsitem = (void *)&(_tx_thread_current_ptr->tx_thread_eh_globals);
|
||||
else
|
||||
/* Use the global __eh_globals pointer. */
|
||||
ptlsitem = (void *)&__eh_globals;
|
||||
break;
|
||||
}
|
||||
return ptlsitem;
|
||||
}
|
||||
#pragma ghs endnomisra
|
||||
#else
|
||||
/* Thread-local storage routines for Green Hills releases 4.x and 3.x . */
|
||||
|
||||
/*
|
||||
* ThreadX C and C++ thread-safe library support routines.
|
||||
*
|
||||
* This implementation merely tries to guarantee thread safety within
|
||||
* individual C library calls such as malloc() and free(), but it does
|
||||
* not attempt to solve the problems associated with the following
|
||||
* multithreaded issues:
|
||||
*
|
||||
* 1. Use of errno. This can be made thread-safe by adding errno
|
||||
* to TX_THREAD_PORT_EXTENSION and using that within a modified
|
||||
* version of libsys/ind_errno.c.
|
||||
*
|
||||
* 2. Thread safety ACROSS library calls. Certain C library calls either
|
||||
* return pointers to statically-allocated data structures or maintain
|
||||
* state across calls. These include strtok(), asctime(), gmtime(),
|
||||
* tmpnam(NULL), signal(). To make such C library routines thread-safe
|
||||
* would require adding a ThreadLocalStorage struct to the thread control
|
||||
* block TX_THREAD. Since relatively few applications make use of these
|
||||
* library routines, the implementation provided here uses a single, global
|
||||
* ThreadLocalStorage data structure rather than greatly increasing the size
|
||||
* of the thread control block TX_THREAD.
|
||||
*
|
||||
* The ThreadX global variable _tx_thread_current_ptr points to the
|
||||
* current thread's control block TX_THREAD. If a ThreadLocalStorage struct
|
||||
* called tx_tls is placed in TX_THREAD, the function GetThreadLocalStorage
|
||||
* should be modified to return &(_tx_thread_current_ptr->tx_tls).
|
||||
*/
|
||||
|
||||
static ThreadLocalStorage GlobalTLS;
|
||||
|
||||
ThreadLocalStorage *GetThreadLocalStorage()
|
||||
{
|
||||
return &GlobalTLS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use a global ThreadX mutex to implement thread safety within C and C++
|
||||
* library routines.
|
||||
*
|
||||
*/
|
||||
TX_MUTEX __ghLockMutex;
|
||||
|
||||
/*
|
||||
* Acquire general lock. Blocks until the lock becomes available.
|
||||
* Use tx_mutex_get to implement __ghsLock
|
||||
*/
|
||||
void __ghsLock(void)
|
||||
{
|
||||
tx_mutex_get(&__ghLockMutex, TX_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
/*
|
||||
* Release general lock
|
||||
* Use tx_mutex_put to implement __ghsUnlock
|
||||
*/
|
||||
void __ghsUnlock(void)
|
||||
{
|
||||
tx_mutex_put(&__ghLockMutex);
|
||||
}
|
||||
|
||||
/* ThreadX Initialization function prototype. */
|
||||
void _tx_initialize_kernel_setup(void);
|
||||
|
||||
void __gh_lock_init(void)
|
||||
{
|
||||
/* Initialize the low-level portions of ThreadX. */
|
||||
_tx_initialize_kernel_setup();
|
||||
|
||||
/* Create the global thread lock mutex. */
|
||||
tx_mutex_create(&__ghLockMutex, "__ghLockMutex", TX_NO_INHERIT);
|
||||
}
|
||||
|
||||
/*
|
||||
Saving State Across setjmp() Calls
|
||||
==================================
|
||||
|
||||
These routines can be used to save and restore arbitrary state
|
||||
across calls to setjmp() and longjmp().
|
||||
*/
|
||||
int __ghs_SaveSignalContext(jmp_buf jmpbuf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restore arbitrary state across a longjmp() */
|
||||
void __ghs_RestoreSignalContext(jmp_buf jmpbuf)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 560)
|
||||
/*
|
||||
C++ Exception Handling
|
||||
======================
|
||||
|
||||
These routines allow C++ exceptions to be used in multiple threads.
|
||||
The default implementation uses __ghs_GetThreadLocalStorageItem
|
||||
to return a thread-specific __eh_globals pointer.
|
||||
|
||||
*/
|
||||
|
||||
/* Must be called after __cpp_exception_init() is called to allocate
|
||||
* and initialize the per-thread exception handling structure */
|
||||
void *__get_eh_globals(void)
|
||||
{
|
||||
#if defined(__ghs) && (__GHS_VERSION_NUMBER >= 500)
|
||||
return *(void **)__ghs_GetThreadLocalStorageItem(__ghs_TLS___eh_globals);
|
||||
#else
|
||||
if (_tx_thread_current_ptr)
|
||||
|
||||
/* Return thread-specific __eh_globals pointer. */
|
||||
return _tx_thread_current_ptr->tx_thread_eh_globals;
|
||||
else
|
||||
/* Return the global __eh_globals pointer. */
|
||||
return GlobalTLS.__eh_globals;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__ghs) && (__GHS_VERSION_NUMBER >= 500)
|
||||
#pragma weak __cpp_exception_init
|
||||
extern void __cpp_exception_init(void **);
|
||||
#pragma weak __cpp_exception_cleanup
|
||||
extern void __cpp_exception_cleanup(void **);
|
||||
|
||||
/* __tx_cpp_exception_init retrieves the eh_globals field from
|
||||
thread-local storage and calls __cpp_exception_init.
|
||||
*/
|
||||
void __tx_cpp_exception_init(TX_THREAD *thread_ptr) {
|
||||
void **peh_globals;
|
||||
if(__cpp_exception_init) {
|
||||
if (thread_ptr)
|
||||
peh_globals = &(thread_ptr->tx_thread_eh_globals);
|
||||
else
|
||||
/* Use the global __eh_globals pointer. */
|
||||
peh_globals = &__eh_globals;
|
||||
__cpp_exception_init(peh_globals);
|
||||
}
|
||||
}
|
||||
|
||||
/* __tx_cpp_exception_cleanup retrieves the eh_globals field from
|
||||
thread-local storage and calls __cpp_exception_cleanup.
|
||||
*/
|
||||
void __tx_cpp_exception_cleanup(TX_THREAD *thread_ptr) {
|
||||
void **peh_globals;
|
||||
if(__cpp_exception_cleanup) {
|
||||
if (thread_ptr)
|
||||
peh_globals = &(thread_ptr->tx_thread_eh_globals);
|
||||
else
|
||||
/* Use the global __eh_globals pointer. */
|
||||
peh_globals = &__eh_globals;
|
||||
__cpp_exception_cleanup(peh_globals);
|
||||
}
|
||||
}
|
||||
|
||||
/* __ghs_cpp_exception_init is called from ind_crt1.o to initialize
|
||||
exceptions for the global context.
|
||||
*/
|
||||
void __ghs_cpp_exception_init() {
|
||||
__tx_cpp_exception_init((void *)0);
|
||||
}
|
||||
|
||||
/* __ghs_cpp_exception_cleanup is called from ind_exit.o to clean up
|
||||
exceptions for the global context.
|
||||
*/
|
||||
void __ghs_cpp_exception_cleanup(TX_THREAD *thread_ptr) {
|
||||
__tx_cpp_exception_cleanup((void *)0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
File Locks
|
||||
======================
|
||||
|
||||
These routines can be customized to implement per-file locks to allow
|
||||
thread-safe I/O.
|
||||
|
||||
*/
|
||||
|
||||
/* Acquire lock for FILE *addr */
|
||||
void __ghs_flock_file(void *addr)
|
||||
{
|
||||
tx_mutex_get((TX_MUTEX *)addr, TX_WAIT_FOREVER);
|
||||
}
|
||||
|
||||
/* Release lock for FILE *addr */
|
||||
void __ghs_funlock_file(void *addr)
|
||||
{
|
||||
tx_mutex_put((TX_MUTEX *)addr);
|
||||
}
|
||||
|
||||
/* Non blocking acquire lock for FILE *addr. May return -1 if */
|
||||
/* not implemented. Returns 0 on success and nonzero otherwise. */
|
||||
int __ghs_ftrylock_file(void *addr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Calls to initialize local lock data structures before they */
|
||||
/* are used. */
|
||||
void __ghs_flock_create(void **addr)
|
||||
{
|
||||
*addr = (void *)(&__ghLockMutex);
|
||||
}
|
||||
void __ghs_flock_destroy(void *addr) {}
|
||||
|
||||
|
||||
/*
|
||||
* ThreadX Peak Stack Checking support routines.
|
||||
*
|
||||
* All of these routines are called by MULTI's ThreadX-aware debugging
|
||||
* package to determine the peak stack use for one thread or for all threads.
|
||||
*
|
||||
* These routines are included in this file in order to guarantee that they will
|
||||
* be available while debugging with MULTI. These routines are not referenced by
|
||||
* any other part of the ThreadX system.
|
||||
*
|
||||
* _txs_thread_stack_check: return the peak stack usage for a thread.
|
||||
*
|
||||
* _txs_thread_stack_check_2: store the peak stack usage for all threads
|
||||
* in the tx_thread_stack_size field of each thread
|
||||
* control block, TX_THREAD. This routine takes
|
||||
* advantage of the redundancy within the TX_THREAD
|
||||
* structure since tx_thread_stack_size can be computed
|
||||
* from the tx_thread_stack_start and tx_thread_stack_end
|
||||
* fields of TX_THREAD.
|
||||
*
|
||||
* _txs_thread_stack_check_2_fixup: clean up from the _txs_thread_stack_check_2
|
||||
* call by computing the stack size for each
|
||||
* thread and storing the result in the
|
||||
* tx_thread_stack_size field of each thread control
|
||||
* block TX_THREAD.
|
||||
*
|
||||
* These three routines do not support architectures such as i960 or StarCore
|
||||
* where the stack grows up instead of down.
|
||||
*
|
||||
*/
|
||||
#ifndef TX_DISABLE_STACK_CHECKING
|
||||
|
||||
ULONG _txs_thread_stack_check(TX_THREAD *thread_ptr)
|
||||
{
|
||||
CHAR *cp; /* Pointer inside thread's stack. */
|
||||
|
||||
/* Search through the thread's stack to find the highest address modified. */
|
||||
for ( cp = (CHAR *)thread_ptr->tx_thread_stack_start;
|
||||
cp <= (CHAR *)thread_ptr->tx_thread_stack_end; ++cp ) {
|
||||
|
||||
/* Check if this byte in the stack contains something other than TX_STACK_FILL. */
|
||||
if (*cp != (char)TX_STACK_FILL) {
|
||||
|
||||
/* Assume cp points to the locating marking the peak stack use.
|
||||
Return the number of bytes from cp up to and including the
|
||||
end of the stack. */
|
||||
return (((ULONG)thread_ptr->tx_thread_stack_end) - (ULONG)cp + 1);
|
||||
}
|
||||
}
|
||||
return thread_ptr->tx_thread_stack_size;
|
||||
}
|
||||
|
||||
|
||||
int _txs_thread_stack_check_2(void) {
|
||||
CHAR * cp; /* Pointer inside thread's stack. */
|
||||
TX_THREAD * tp; /* Pointer to each thread. */
|
||||
|
||||
/* If no threads are created, return immediately. */
|
||||
if (!_tx_thread_created_count)
|
||||
return 0;
|
||||
|
||||
/* Start iterating through the threads in the system. Assume that we always
|
||||
have at least one thread (the system timer thread) in the system. */
|
||||
tp = _tx_thread_created_ptr;
|
||||
|
||||
do {
|
||||
|
||||
/* Search through the thread's stack to find the highest address modified. */
|
||||
for ( cp = (CHAR *)tp->tx_thread_stack_start; cp <= (CHAR *)tp->tx_thread_stack_end;
|
||||
++cp ) {
|
||||
|
||||
/* Check if this byte in the stack contains something other than TX_STACK_FILL. */
|
||||
if (*cp != (char)TX_STACK_FILL) {
|
||||
|
||||
/* Assume cp points to the locating marking the peak stack use.
|
||||
Store the number of bytes from cp up to and including the
|
||||
end of the stack in the tx_thread_stack_size field. */
|
||||
tp->tx_thread_stack_size = ((ULONG)tp->tx_thread_stack_end) - (ULONG)cp + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Continue with the next thread. */
|
||||
tp = tp->tx_thread_created_next;
|
||||
|
||||
/* Loop until we point to the first thread again. */
|
||||
} while ( tp != _tx_thread_created_ptr );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _txs_thread_stack_check_2_fixup(void) {
|
||||
TX_THREAD * tp; /* Pointer to each thread. */
|
||||
|
||||
/* If no threads are created, return immediately. */
|
||||
if (!_tx_thread_created_count)
|
||||
return 0;
|
||||
|
||||
/* Start iterating through the threads in the system. Assume that we always
|
||||
have at least one thread (the system timer thread) in the system. */
|
||||
tp = _tx_thread_created_ptr;
|
||||
|
||||
do {
|
||||
|
||||
/* Compute the tx_thread_stack_size field by using the tx_thread_stack_end and
|
||||
tx_thread_stack_start fields. */
|
||||
tp->tx_thread_stack_size = (ULONG)tp->tx_thread_stack_end-(ULONG)tp->tx_thread_stack_start+1;
|
||||
|
||||
/* Continue with the next thread. */
|
||||
tp = tp->tx_thread_created_next;
|
||||
|
||||
/* Loop until we point to the first thread again. */
|
||||
} while ( tp != _tx_thread_created_ptr );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* TX_DISABLE_STACK_CHECKING */
|
||||
49
ports/cortex_m3/ghs/src/tx_ghse.c
Normal file
49
ports/cortex_m3/ghs/src/tx_ghse.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* ThreadX C++ Library Support
|
||||
*
|
||||
* Copyright 1983-2019 Green Hills Software LLC.
|
||||
*
|
||||
* This program is the property of Green Hills Software LLC.,
|
||||
* its contents are proprietary information and no part of it
|
||||
* is to be disclosed to anyone except employees of Green Hills
|
||||
* Software LLC., or as agreed in writing signed by the President
|
||||
* of Green Hills Software LLC.
|
||||
*/
|
||||
#include "tx_ghs.h"
|
||||
#ifndef TX_DISABLE_ERROR_CHECKING
|
||||
#define TX_DISABLE_ERROR_CHECKING
|
||||
#endif
|
||||
#include "tx_api.h"
|
||||
|
||||
/*
|
||||
C++ Exception Handling
|
||||
======================
|
||||
|
||||
These routines allow C++ exceptions to be used in multiple threads.
|
||||
The default implementation uses __ghs_GetThreadLocalStorageItem
|
||||
to return a thread-specific __eh_globals pointer.
|
||||
|
||||
*/
|
||||
|
||||
#if defined(__ghs) && (__GHS_VERSION_NUMBER >= 560)
|
||||
#ifdef _WIN32
|
||||
/* Windows uses a different linker, so include a stub routine, never called,
|
||||
to pull in __cpp_exception_init and __cpp_exception_cleanup */
|
||||
extern void __cpp_exception_init(void **);
|
||||
extern void __cpp_exception_cleanup(void **);
|
||||
void __tx_win32_pull_in_exceptions(void) {
|
||||
__cpp_exception_init(0);
|
||||
__cpp_exception_cleanup(0);
|
||||
}
|
||||
#else
|
||||
#pragma ghs reference __cpp_exception_init
|
||||
#pragma ghs reference __cpp_exception_cleanup
|
||||
#endif
|
||||
|
||||
/* Must be called after __cpp_exception_init() is called to allocate
|
||||
* and initialize the per-thread exception handling structure */
|
||||
void *__get_eh_globals(void)
|
||||
{
|
||||
return *(void **)__ghs_GetThreadLocalStorageItem(__ghs_TLS___eh_globals);
|
||||
}
|
||||
#endif
|
||||
86
ports/cortex_m3/ghs/src/tx_thread_context_restore.arm
Normal file
86
ports/cortex_m3/ghs/src/tx_thread_context_restore.arm
Normal file
@@ -0,0 +1,86 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_context_restore Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is only needed for legacy applications and it should */
|
||||
;/* not be called in any new development on a Cortex-M. */
|
||||
;/* This function restores the interrupt context if it is processing a */
|
||||
;/* nested interrupt. If not, it returns to the interrupt thread if no */
|
||||
;/* preemption is necessary. Otherwise, if preemption is necessary or */
|
||||
;/* if no thread was running, the function returns to the scheduler. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* [_tx_execution_isr_exit] Execution profiling ISR exit */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* ISRs Interrupt Service Routines */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_context_restore(VOID)
|
||||
;{
|
||||
.globl _tx_thread_context_restore
|
||||
_tx_thread_context_restore:
|
||||
|
||||
#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the ISR exit function to indicate an ISR is complete. */
|
||||
;
|
||||
PUSH {r0, lr} ; Save return address
|
||||
BL _tx_execution_isr_exit ; Call the ISR exit function
|
||||
POP {r0, lr} ; Save return address
|
||||
#endif
|
||||
;
|
||||
POP {lr}
|
||||
BX lr
|
||||
;
|
||||
;}
|
||||
.type _tx_thread_context_restore,$function
|
||||
.size _tx_thread_context_restore,.-_tx_thread_context_restore
|
||||
84
ports/cortex_m3/ghs/src/tx_thread_context_save.arm
Normal file
84
ports/cortex_m3/ghs/src/tx_thread_context_save.arm
Normal file
@@ -0,0 +1,84 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_context_save Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is only needed for legacy applications and it should */
|
||||
;/* not be called in any new development on a Cortex-M. */
|
||||
;/* This function saves the context of an executing thread in the */
|
||||
;/* beginning of interrupt processing. The function also ensures that */
|
||||
;/* the system stack is used upon return to the calling ISR. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* ISRs */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_context_save(VOID)
|
||||
;{
|
||||
.globl _tx_thread_context_save
|
||||
_tx_thread_context_save:
|
||||
#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the ISR enter function to indicate an ISR is starting. */
|
||||
;
|
||||
PUSH {r0, lr} ; Save return address
|
||||
BL _tx_execution_isr_enter ; Call the ISR enter function
|
||||
POP {r0, lr} ; Recover return address
|
||||
#endif
|
||||
;
|
||||
; /* Context is already saved - just return! */
|
||||
;
|
||||
BX lr
|
||||
;}
|
||||
.type _tx_thread_context_save,$function
|
||||
.size _tx_thread_context_save,.-_tx_thread_context_save
|
||||
74
ports/cortex_m3/ghs/src/tx_thread_interrupt_control.arm
Normal file
74
ports/cortex_m3/ghs/src/tx_thread_interrupt_control.arm
Normal file
@@ -0,0 +1,74 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_interrupt_control Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is responsible for changing the interrupt lockout */
|
||||
;/* posture of the system. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* new_posture New interrupt lockout posture */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* old_posture Old interrupt lockout posture */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* Application Code */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;UINT _tx_thread_interrupt_control(UINT new_posture)
|
||||
;{
|
||||
.globl _tx_thread_interrupt_control
|
||||
_tx_thread_interrupt_control:
|
||||
MRS r1, PRIMASK ; Pickup current interrupt lockout
|
||||
MSR PRIMASK, r0 ; Apply the new interrupt lockout
|
||||
MOV r0, r1 ; Transfer old to return register
|
||||
BX lr ; Return to caller
|
||||
;
|
||||
;}
|
||||
.type _tx_thread_interrupt_control,$function
|
||||
.size _tx_thread_interrupt_control,.-_tx_thread_interrupt_control
|
||||
84
ports/cortex_m3/ghs/src/tx_thread_interrupt_disable.arm
Normal file
84
ports/cortex_m3/ghs/src/tx_thread_interrupt_disable.arm
Normal file
@@ -0,0 +1,84 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;#define TX_SOURCE_CODE
|
||||
;
|
||||
;
|
||||
;/* Include necessary system files. */
|
||||
;
|
||||
;#include "tx_api.h"
|
||||
;#include "tx_thread.h"
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_interrupt_restore Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is responsible for disabling interrupts and returning */
|
||||
;/* the previous interrupt lockout posture. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* old_posture Old interrupt lockout posture */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* Application Code */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;UINT _tx_thread_interrupt_disable(UINT new_posture)
|
||||
;{
|
||||
.globl _tx_thread_interrupt_disable
|
||||
_tx_thread_interrupt_disable:
|
||||
;
|
||||
; /* Return current interrupt lockout posture. */
|
||||
;
|
||||
MRS r0, PRIMASK
|
||||
CPSID i
|
||||
BX lr
|
||||
;
|
||||
;}
|
||||
.type _tx_thread_interrupt_disable,$function
|
||||
.size _tx_thread_interrupt_disable,.-_tx_thread_interrupt_disable
|
||||
75
ports/cortex_m3/ghs/src/tx_thread_interrupt_restore.arm
Normal file
75
ports/cortex_m3/ghs/src/tx_thread_interrupt_restore.arm
Normal file
@@ -0,0 +1,75 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_interrupt_restore Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is responsible for restoring the previous */
|
||||
;/* interrupt lockout posture. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* previous_posture Previous interrupt posture */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* Application Code */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_interrupt_restore(UINT new_posture)
|
||||
;{
|
||||
.globl _tx_thread_interrupt_restore
|
||||
_tx_thread_interrupt_restore:
|
||||
;
|
||||
; /* Restore previous interrupt lockout posture. */
|
||||
;
|
||||
MSR PRIMASK, r0
|
||||
BX lr
|
||||
;
|
||||
;}
|
||||
.type _tx_thread_interrupt_restore,$function
|
||||
.size _tx_thread_interrupt_restore,.-_tx_thread_interrupt_restore
|
||||
252
ports/cortex_m3/ghs/src/tx_thread_schedule.arm
Normal file
252
ports/cortex_m3/ghs/src/tx_thread_schedule.arm
Normal file
@@ -0,0 +1,252 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_schedule Cortex-M3/GHS */
|
||||
;/* 6.1.10 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function waits for a thread control block pointer to appear in */
|
||||
;/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
|
||||
;/* in the variable, the corresponding thread is resumed. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
;/* _tx_thread_system_return Return to system from thread */
|
||||
;/* _tx_thread_context_restore Restore thread's context */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* 01-31-2022 Scott Larson Modified comment(s), add */
|
||||
;/* low power code, */
|
||||
;/* resulting in version 6.1.10 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_schedule(VOID)
|
||||
;{
|
||||
.globl _tx_thread_schedule
|
||||
_tx_thread_schedule:
|
||||
;
|
||||
; /* This function should only ever be called on Cortex-M
|
||||
; from the first schedule request. Subsequent scheduling occurs
|
||||
; from the PendSV handling routines below. */
|
||||
;
|
||||
; /* Clear the preempt-disable flag to enable rescheduling after initialization on Cortex-M targets. */
|
||||
;
|
||||
MOV r0, #0 ; Build value for TX_FALSE
|
||||
LDR r2, =_tx_thread_preempt_disable ; Build address of preempt disable flag
|
||||
STR r0, [r2, #0] ; Clear preempt disable flag
|
||||
;
|
||||
; /* Enable interrupts */
|
||||
;
|
||||
CPSIE i
|
||||
;
|
||||
; /* Enter the scheduler for the first time. */
|
||||
;
|
||||
MOV r0, #0x10000000 ; Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 ; Load NVIC base
|
||||
STR r0, [r1, #0xD04] ; Set PENDSVBIT in ICSR
|
||||
DSB ; Complete all memory accesses
|
||||
ISB ; Flush pipeline
|
||||
;
|
||||
; /* Wait here for the PendSV to take place. */
|
||||
;
|
||||
__tx_wait_here:
|
||||
B __tx_wait_here ; Wait for the PendSV to happen
|
||||
|
||||
.type _tx_thread_schedule,$function
|
||||
.size _tx_thread_schedule,.-_tx_thread_schedule
|
||||
;}
|
||||
;
|
||||
; /* Generic context PendSV handler. */
|
||||
;
|
||||
.globl PendSV_Handler
|
||||
.globl __tx_PendSVHandler
|
||||
PendSV_Handler:
|
||||
__tx_PendSVHandler:
|
||||
;
|
||||
; /* Get current thread value and new thread pointer. */
|
||||
;
|
||||
__tx_ts_handler:
|
||||
|
||||
#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
;
|
||||
CPSID i ; Disable interrupts
|
||||
PUSH {r0, lr} ; Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit ; Call the thread exit function
|
||||
POP {r0, lr} ; Recover LR
|
||||
CPSIE i ; Enable interrupts
|
||||
#endif
|
||||
LDR r0, =_tx_thread_current_ptr ; Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr ; Build execute thread pointer address
|
||||
MOV r3, #0 ; Build NULL value
|
||||
LDR r1, [r0] ; Pickup current thread pointer
|
||||
;
|
||||
; /* Determine if there is a current thread to finish preserving. */
|
||||
;
|
||||
CBZ r1, __tx_ts_new ; If NULL, skip preservation
|
||||
;
|
||||
; /* Recover PSP and preserve current thread context. */
|
||||
;
|
||||
STR r3, [r0] ; Set _tx_thread_current_ptr to NULL
|
||||
MRS r12, PSP ; Pickup PSP pointer (thread's stack pointer)
|
||||
STMDB r12!, {r4-r11} ; Save its remaining registers
|
||||
LDR r4, =_tx_timer_time_slice ; Build address of time-slice variable
|
||||
STR.W LR, [r12, #-0x4]! ; Save LR on the stack
|
||||
;
|
||||
; /* Determine if time-slice is active. If it isn't, skip time handling processing. */
|
||||
;
|
||||
LDR r5, [r4] ; Pickup current time-slice
|
||||
STR r12, [r1, #8] ; Save the thread stack pointer
|
||||
CBZ r5, __tx_ts_new ; If not active, skip processing
|
||||
;
|
||||
; /* Time-slice is active, save the current thread's time-slice and clear the global time-slice variable. */
|
||||
;
|
||||
STR r5, [r1, #24] ; Save current time-slice
|
||||
;
|
||||
; /* Clear the global time-slice. */
|
||||
;
|
||||
STR r3, [r4] ; Clear time-slice
|
||||
;
|
||||
;
|
||||
; /* Executing thread is now completely preserved!!! */
|
||||
;
|
||||
__tx_ts_new:
|
||||
;
|
||||
; /* Now we are looking for a new thread to execute! */
|
||||
;
|
||||
CPSID i ; Disable interrupts
|
||||
LDR r1, [r2] ; Is there another thread ready to execute?
|
||||
CBZ r1, __tx_ts_wait ; No, skip to the wait processing
|
||||
;
|
||||
; /* Yes, another thread is ready for else, make the current thread the new thread. */
|
||||
;
|
||||
STR r1, [r0] ; Setup the current thread pointer to the new thread
|
||||
CPSIE i ; Enable interrupts
|
||||
;
|
||||
; /* Increment the thread run count. */
|
||||
;
|
||||
__tx_ts_restore:
|
||||
LDR r7, [r1, #4] ; Pickup the current thread run count
|
||||
LDR r4, =_tx_timer_time_slice ; Build address of time-slice variable
|
||||
LDR r5, [r1, #24] ; Pickup thread's current time-slice
|
||||
ADD r7, r7, #1 ; Increment the thread run count
|
||||
STR r7, [r1, #4] ; Store the new run count
|
||||
;
|
||||
; /* Setup global time-slice with thread's current time-slice. */
|
||||
;
|
||||
STR r5, [r4] ; Setup global time-slice
|
||||
|
||||
#ifdef TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the thread entry function to indicate the thread is executing. */
|
||||
;
|
||||
PUSH {r0, r1} ; Save r0/r1
|
||||
BL _tx_execution_thread_enter ; Call the thread execution enter function
|
||||
POP {r0, r1} ; Recover r3
|
||||
#endif
|
||||
;
|
||||
; /* Restore the thread context and PSP. */
|
||||
;
|
||||
LDR r12, [r1, #8] ; Pickup thread's stack pointer
|
||||
LDR.W LR, [r12], #4 ; Pickup LR
|
||||
LDMIA r12!, {r4-r11} ; Recover thread's registers
|
||||
MSR PSP, r12 ; Setup the thread's stack pointer
|
||||
;
|
||||
; /* Return to thread. */
|
||||
;
|
||||
BX lr ; Return to thread!
|
||||
;
|
||||
; /* The following is the idle wait processing... in this case, no threads are ready for execution and the
|
||||
; system will simply be idle until an interrupt occurs that makes a thread ready. Note that interrupts
|
||||
; are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
;
|
||||
__tx_ts_wait:
|
||||
CPSID i ; Disable interrupts
|
||||
LDR r1, [r2] ; Pickup the next thread to execute pointer
|
||||
STR r1, [r0] ; Store it in the current pointer
|
||||
CBNZ r1, __tx_ts_ready ; If non-NULL, a new thread is ready!
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_enter ; Possibly enter low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_WFI
|
||||
DSB ; Ensure no outstanding memory transactions
|
||||
WFI ; Wait for interrupt
|
||||
ISB ; Ensure pipeline is flushed
|
||||
#endif
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_exit ; Exit low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
CPSIE i ; Enable interrupts
|
||||
B __tx_ts_wait ; Loop to continue waiting
|
||||
;
|
||||
; /* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
; already in the handler! */
|
||||
;
|
||||
__tx_ts_ready:
|
||||
MOV r7, #0x08000000 ; Build clear PendSV value
|
||||
MOV r8, #0xE000E000 ; Build base NVIC address
|
||||
STR r7, [r8, #0xD04] ; Clear any PendSV
|
||||
;
|
||||
; /* Re-enable interrupts and restore new thread. */
|
||||
;
|
||||
CPSIE i ; Enable interrupts
|
||||
B __tx_ts_restore ; Restore the thread
|
||||
;}
|
||||
;
|
||||
.type __tx_PendSVHandler,$function
|
||||
.size __tx_PendSVHandler,.-__tx_PendSVHandler
|
||||
134
ports/cortex_m3/ghs/src/tx_thread_stack_build.arm
Normal file
134
ports/cortex_m3/ghs/src/tx_thread_stack_build.arm
Normal file
@@ -0,0 +1,134 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_stack_build Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function builds a stack frame on the supplied thread's stack. */
|
||||
;/* The stack frame results in a fake interrupt return to the supplied */
|
||||
;/* function pointer. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* thread_ptr Pointer to thread control blk */
|
||||
;/* function_ptr Pointer to return function */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* _tx_thread_create Create thread service */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
|
||||
;{
|
||||
.globl _tx_thread_stack_build
|
||||
_tx_thread_stack_build:
|
||||
;
|
||||
;
|
||||
; /* Build a fake interrupt frame. The form of the fake interrupt stack
|
||||
; on the Cortex-M should look like the following after it is built:
|
||||
;
|
||||
; Stack Top:
|
||||
; LR Interrupted LR (LR at time of PENDSV)
|
||||
; r4 Initial value for r4
|
||||
; r5 Initial value for r5
|
||||
; r6 Initial value for r6
|
||||
; r7 Initial value for r7
|
||||
; r8 Initial value for r8
|
||||
; r9 Initial value for r9
|
||||
; r10 Initial value for r10
|
||||
; r11 Initial value for r11
|
||||
; r0 Initial value for r0 (Hardware stack starts here!!)
|
||||
; r1 Initial value for r1
|
||||
; r2 Initial value for r2
|
||||
; r3 Initial value for r3
|
||||
; r12 Initial value for r12
|
||||
; lr Initial value for lr
|
||||
; pc Initial value for pc
|
||||
; xPSR Initial value for xPSR
|
||||
;
|
||||
; Stack Bottom: (higher memory address) */
|
||||
;
|
||||
LDR r2, [r0, #16] ; Pickup end of stack area
|
||||
BIC r2, r2, #0x7 ; Align frame for 8-byte alignment
|
||||
SUB r2, r2, #68 ; Subtract frame size
|
||||
LDR r3, =0xFFFFFFFD ; Build initial LR value
|
||||
STR r3, [r2, #0] ; Save on the stack
|
||||
;
|
||||
; /* Actually build the stack frame. */
|
||||
;
|
||||
MOV r3, #0 ; Build initial register value
|
||||
STR r3, [r2, #4] ; Store initial r4
|
||||
STR r3, [r2, #8] ; Store initial r5
|
||||
STR r3, [r2, #12] ; Store initial r6
|
||||
STR r3, [r2, #16] ; Store initial r7
|
||||
STR r3, [r2, #20] ; Store initial r8
|
||||
STR r3, [r2, #24] ; Store initial r9
|
||||
STR r3, [r2, #28] ; Store initial r10
|
||||
STR r3, [r2, #32] ; Store initial r11
|
||||
;
|
||||
; /* Hardware stack follows. */
|
||||
;
|
||||
STR r3, [r2, #36] ; Store initial r0
|
||||
STR r3, [r2, #40] ; Store initial r1
|
||||
STR r3, [r2, #44] ; Store initial r2
|
||||
STR r3, [r2, #48] ; Store initial r3
|
||||
STR r3, [r2, #52] ; Store initial r12
|
||||
MOV r3, #0xFFFFFFFF ; Poison EXC_RETURN value
|
||||
STR r3, [r2, #56] ; Store initial lr
|
||||
STR r1, [r2, #60] ; Store initial pc
|
||||
MOV r3, #0x01000000 ; Only T-bit need be set
|
||||
STR r3, [r2, #64] ; Store initial xPSR
|
||||
;
|
||||
; /* Setup stack pointer. */
|
||||
; thread_ptr -> tx_thread_stack_ptr = r2;
|
||||
;
|
||||
STR r2, [r0, #8] ; Save stack pointer in thread's
|
||||
; control block
|
||||
BX lr ; Return to caller
|
||||
;}
|
||||
.type _tx_thread_stack_build,$function
|
||||
.size _tx_thread_stack_build,.-_tx_thread_stack_build
|
||||
86
ports/cortex_m3/ghs/src/tx_thread_system_return.arm
Normal file
86
ports/cortex_m3/ghs/src/tx_thread_system_return.arm
Normal file
@@ -0,0 +1,86 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_system_return Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is target processor specific. It is used to transfer */
|
||||
;/* control from a thread back to the ThreadX system. Only a */
|
||||
;/* minimal context is saved since the compiler assumes temp registers */
|
||||
;/* are going to get slicked by a function call anyway. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* _tx_thread_schedule Thread scheduling loop */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* ThreadX components */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_system_return(VOID)
|
||||
;{
|
||||
.globl _tx_thread_system_return
|
||||
_tx_thread_system_return:
|
||||
;
|
||||
; /* Return to real scheduler via PendSV. Note that this routine is often
|
||||
; replaced with in-line assembly in tx_port.h to improved performance. */
|
||||
;
|
||||
MOV r0, #0x10000000 ; Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 ; Load NVIC base
|
||||
STR r0, [r1, #0xD04] ; Set PENDSVBIT in ICSR
|
||||
MRS r0, IPSR ; Pickup IPSR
|
||||
CMP r0, #0 ; Is it a thread returning?
|
||||
BNE _isr_context ; If ISR, skip interrupt enable
|
||||
MRS r1, PRIMASK ; Thread context returning, pickup PRIMASK
|
||||
CPSIE i ; Enable interrupts
|
||||
MSR PRIMASK, r1 ; Restore original interrupt posture
|
||||
_isr_context:
|
||||
BX lr ; Return to caller
|
||||
;}
|
||||
.type _tx_thread_system_return,$function
|
||||
.size _tx_thread_system_return,.-_tx_thread_system_return
|
||||
242
ports/cortex_m3/ghs/src/tx_timer_interrupt.arm
Normal file
242
ports/cortex_m3/ghs/src/tx_timer_interrupt.arm
Normal file
@@ -0,0 +1,242 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Timer */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
.text
|
||||
.align 4
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_timer_interrupt Cortex-M3/GHS */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function processes the hardware timer interrupt. This */
|
||||
;/* processing includes incrementing the system clock and checking for */
|
||||
;/* time slice and/or timer expiration. If either is found, the */
|
||||
;/* expiration functions are called. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* _tx_timer_expiration_process Timer expiration processing */
|
||||
;/* _tx_thread_time_slice Time slice interrupted thread */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* interrupt vector */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_timer_interrupt(VOID)
|
||||
;{
|
||||
.globl _tx_timer_interrupt
|
||||
_tx_timer_interrupt:
|
||||
;
|
||||
; /* Upon entry to this routine, it is assumed that the compiler scratch registers are available
|
||||
; for use. */
|
||||
;
|
||||
; /* Increment the system clock. */
|
||||
; _tx_timer_system_clock++;
|
||||
;
|
||||
LDR r1, =_tx_timer_system_clock ; Pickup address of system clock
|
||||
LDR r0, [r1, #0] ; Pickup system clock
|
||||
ADD r0, r0, #1 ; Increment system clock
|
||||
STR r0, [r1, #0] ; Store new system clock
|
||||
;
|
||||
; /* Test for time-slice expiration. */
|
||||
; if (_tx_timer_time_slice)
|
||||
; {
|
||||
;
|
||||
LDR r3, =_tx_timer_time_slice ; Pickup address of time-slice
|
||||
LDR r2, [r3, #0] ; Pickup time-slice
|
||||
CBZ r2, __tx_timer_no_time_slice ; Is it non-active?
|
||||
; Yes, skip time-slice processing
|
||||
;
|
||||
; /* Decrement the time_slice. */
|
||||
; _tx_timer_time_slice--;
|
||||
;
|
||||
SUB r2, r2, #1 ; Decrement the time-slice
|
||||
STR r2, [r3, #0] ; Store new time-slice value
|
||||
;
|
||||
; /* Check for expiration. */
|
||||
; if (__tx_timer_time_slice == 0)
|
||||
;
|
||||
CBNZ r2, __tx_timer_no_time_slice ; Has it expired?
|
||||
;
|
||||
; /* Set the time-slice expired flag. */
|
||||
; _tx_timer_expired_time_slice = TX_TRUE;
|
||||
;
|
||||
LDR r3, =_tx_timer_expired_time_slice ; Pickup address of expired flag
|
||||
MOV r0, #1 ; Build expired value
|
||||
STR r0, [r3, #0] ; Set time-slice expiration flag
|
||||
;
|
||||
; }
|
||||
;
|
||||
__tx_timer_no_time_slice:
|
||||
;
|
||||
; /* Test for timer expiration. */
|
||||
; if (*_tx_timer_current_ptr)
|
||||
; {
|
||||
;
|
||||
LDR r1, =_tx_timer_current_ptr ; Pickup current timer pointer addr
|
||||
LDR r0, [r1, #0] ; Pickup current timer
|
||||
LDR r2, [r0, #0] ; Pickup timer list entry
|
||||
CBZ r2, __tx_timer_no_timer ; Is there anything in the list?
|
||||
; No, just increment the timer
|
||||
;
|
||||
; /* Set expiration flag. */
|
||||
; _tx_timer_expired = TX_TRUE;
|
||||
;
|
||||
LDR r3, =_tx_timer_expired ; Pickup expiration flag address
|
||||
MOV r2, #1 ; Build expired value
|
||||
STR r2, [r3, #0] ; Set expired flag
|
||||
B __tx_timer_done ; Finished timer processing
|
||||
;
|
||||
; }
|
||||
; else
|
||||
; {
|
||||
__tx_timer_no_timer:
|
||||
;
|
||||
; /* No timer expired, increment the timer pointer. */
|
||||
; _tx_timer_current_ptr++;
|
||||
;
|
||||
ADD r0, r0, #4 ; Move to next timer
|
||||
;
|
||||
; /* Check for wrap-around. */
|
||||
; if (_tx_timer_current_ptr == _tx_timer_list_end)
|
||||
;
|
||||
LDR r3, =_tx_timer_list_end ; Pickup addr of timer list end
|
||||
LDR r2, [r3, #0] ; Pickup list end
|
||||
CMP r0, r2 ; Are we at list end?
|
||||
BNE __tx_timer_skip_wrap ; No, skip wrap-around logic
|
||||
;
|
||||
; /* Wrap to beginning of list. */
|
||||
; _tx_timer_current_ptr = _tx_timer_list_start;
|
||||
;
|
||||
LDR r3, =_tx_timer_list_start ; Pickup addr of timer list start
|
||||
LDR r0, [r3, #0] ; Set current pointer to list start
|
||||
;
|
||||
__tx_timer_skip_wrap:
|
||||
;
|
||||
STR r0, [r1, #0] ; Store new current timer pointer
|
||||
; }
|
||||
;
|
||||
__tx_timer_done:
|
||||
;
|
||||
;
|
||||
; /* See if anything has expired. */
|
||||
; if ((_tx_timer_expired_time_slice) || (_tx_timer_expired))
|
||||
; {
|
||||
;
|
||||
LDR r3, =_tx_timer_expired_time_slice ; Pickup addr of expired flag
|
||||
LDR r2, [r3, #0] ; Pickup time-slice expired flag
|
||||
CBNZ r2, __tx_something_expired ; Did a time-slice expire?
|
||||
; If non-zero, time-slice expired
|
||||
LDR r1, =_tx_timer_expired ; Pickup addr of other expired flag
|
||||
LDR r0, [r1, #0] ; Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_nothing_expired ; Did a timer expire?
|
||||
; No, nothing expired
|
||||
;
|
||||
__tx_something_expired:
|
||||
;
|
||||
;
|
||||
STMDB sp!, {r0, lr} ; Save the lr register on the stack
|
||||
; and save r0 just to keep 8-byte alignment
|
||||
;
|
||||
; /* Did a timer expire? */
|
||||
; if (_tx_timer_expired)
|
||||
; {
|
||||
;
|
||||
LDR r1, =_tx_timer_expired ; Pickup addr of expired flag
|
||||
LDR r0, [r1, #0] ; Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_dont_activate ; Check for timer expiration
|
||||
; If not set, skip timer activation
|
||||
;
|
||||
; /* Process timer expiration. */
|
||||
; _tx_timer_expiration_process();
|
||||
;
|
||||
BL _tx_timer_expiration_process ; Call the timer expiration handling routine
|
||||
;
|
||||
; }
|
||||
__tx_timer_dont_activate:
|
||||
;
|
||||
; /* Did time slice expire? */
|
||||
; if (_tx_timer_expired_time_slice)
|
||||
; {
|
||||
;
|
||||
LDR r3, =_tx_timer_expired_time_slice ; Pickup addr of time-slice expired
|
||||
LDR r2, [r3, #0] ; Pickup the actual flag
|
||||
CBZ r2, __tx_timer_not_ts_expiration ; See if the flag is set
|
||||
; No, skip time-slice processing
|
||||
;
|
||||
; /* Time slice interrupted thread. */
|
||||
; _tx_thread_time_slice();
|
||||
|
||||
BL _tx_thread_time_slice ; Call time-slice processing
|
||||
LDR r0, =_tx_thread_preempt_disable ; Build address of preempt disable flag
|
||||
LDR r1, [r0] ; Is the preempt disable flag set?
|
||||
CBNZ r1, __tx_timer_skip_time_slice ; Yes, skip the PendSV logic
|
||||
LDR r0, =_tx_thread_current_ptr ; Build current thread pointer address
|
||||
LDR r1, [r0] ; Pickup the current thread pointer
|
||||
LDR r2, =_tx_thread_execute_ptr ; Build execute thread pointer address
|
||||
LDR r3, [r2] ; Pickup the execute thread pointer
|
||||
LDR r0, =0xE000ED04 ; Build address of control register
|
||||
LDR r2, =0x10000000 ; Build value for PendSV bit
|
||||
CMP r1, r3 ; Are they the same?
|
||||
BEQ __tx_timer_skip_time_slice ; If the same, there was no time-slice performed
|
||||
STR r2, [r0] ; Not the same, issue the PendSV for preemption
|
||||
__tx_timer_skip_time_slice:
|
||||
;
|
||||
; }
|
||||
;
|
||||
__tx_timer_not_ts_expiration:
|
||||
;
|
||||
LDMIA sp!, {r0, lr} ; Recover lr register (r0 is just there for
|
||||
; the 8-byte stack alignment
|
||||
;
|
||||
; }
|
||||
;
|
||||
__tx_timer_nothing_expired:
|
||||
|
||||
DSB ; Complete all memory access
|
||||
BX lr ; Return to caller
|
||||
;
|
||||
;}
|
||||
.type _tx_timer_interrupt,$function
|
||||
.size _tx_timer_interrupt,.-_tx_timer_interrupt
|
||||
84
ports/cortex_m3/ghs/src/txr_ghs.c
Normal file
84
ports/cortex_m3/ghs/src/txr_ghs.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* ThreadX API Runtime Error Support
|
||||
*
|
||||
* Copyright 1983-2019 Green Hills Software LLC.
|
||||
*
|
||||
* This program is the property of Green Hills Software LLC.,
|
||||
* its contents are proprietary information and no part of it
|
||||
* is to be disclosed to anyone except employees of Green Hills
|
||||
* Software LLC., or as agreed in writing signed by the President
|
||||
* of Green Hills Software LLC.
|
||||
*/
|
||||
|
||||
/* #include "tx_ghs.h" */
|
||||
#ifndef TX_DISABLE_ERROR_CHECKING
|
||||
#define TX_DISABLE_ERROR_CHECKING
|
||||
#endif
|
||||
#include "tx_api.h"
|
||||
|
||||
/* Customized ThreadX API runtime error support routine. */
|
||||
|
||||
void _rnerr(int num, int linenum, const char*str, void*ptr, ...);
|
||||
|
||||
/* __ghs_rnerr()
|
||||
This is the custom runtime error checking routine.
|
||||
This implementation uses the existing __rnerr() routine.
|
||||
Another implementation could use the .syscall mechanism,
|
||||
provided MULTI was modified to understand that.
|
||||
*/
|
||||
void __ghs_rnerr(char *errMsg, int stackLevels, int stackTraceDisplay, void *hexVal) {
|
||||
TX_INTERRUPT_SAVE_AREA
|
||||
int num;
|
||||
/*
|
||||
Initialize the stack levels value.
|
||||
|
||||
Add 3 to account for the calls to _rnerr, __rnerr, and
|
||||
__ghs_rnerr.
|
||||
|
||||
If the implementation changes, calls to __ghs_rnerr
|
||||
will not need to be changed.
|
||||
|
||||
Zero is not permitted, so substitute 3 in that case.
|
||||
*/
|
||||
num = (stackLevels+3) & 0xf;
|
||||
if (!num) {
|
||||
num = 3;
|
||||
}
|
||||
/*
|
||||
Shift the stack levels value to bits 12..15 and
|
||||
insert the stack trace display value in bit 11.
|
||||
Bits 0..10 are unused.
|
||||
*/
|
||||
num = (num << 12) | (stackTraceDisplay ? 0x800 : 0);
|
||||
|
||||
/* This will mask all interrupts in the RTEC code, which is probably
|
||||
unacceptable for many targets. */
|
||||
TX_DISABLE
|
||||
_rnerr(num, -1, (const char *)hexVal, (void *)errMsg);
|
||||
TX_RESTORE
|
||||
}
|
||||
|
||||
|
||||
/* ThreadX thread stack checking runtime support routine. */
|
||||
|
||||
extern char __ghsbegin_stack[];
|
||||
extern TX_THREAD *_tx_thread_current_ptr;
|
||||
|
||||
void __stkchk(void) {
|
||||
int i;
|
||||
if(_tx_thread_current_ptr)
|
||||
{
|
||||
if((unsigned)(&i) <=
|
||||
(unsigned)(_tx_thread_current_ptr -> tx_thread_stack_start))
|
||||
{
|
||||
_rnerr(21, -1, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((unsigned)(&i) <= (unsigned)__ghsbegin_stack)
|
||||
{
|
||||
_rnerr(21, -1, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
728
ports/cortex_m3/gnu/inc/tx_port.h
Normal file
728
ports/cortex_m3/gnu/inc/tx_port.h
Normal file
@@ -0,0 +1,728 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Port Specific */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M3/GNU */
|
||||
/* 6.1.12 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file contains data type definitions that make the ThreadX */
|
||||
/* real-time kernel function identically on a variety of different */
|
||||
/* processor architectures. For example, the size or number of bits */
|
||||
/* in an "int" data type vary between microprocessor architectures and */
|
||||
/* even C compilers for the same microprocessor. ThreadX does not */
|
||||
/* directly use native C data types. Instead, ThreadX creates its */
|
||||
/* own special types that can be mapped to actual data types by this */
|
||||
/* file to guarantee consistency in the interface and functionality. */
|
||||
/* */
|
||||
/* This file replaces the previous Cortex-M3/M4/M7 files. It unifies */
|
||||
/* the ARMv7-M architecture and compilers into one common file. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comments, updated */
|
||||
/* typedef to fix misra */
|
||||
/* violation, */
|
||||
/* fixed predefined macro, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 07-29-2022 Scott Larson Modified comments and */
|
||||
/* described BASEPRI usage, */
|
||||
/* resulting in version 6.1.12 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_PORT_H
|
||||
#define TX_PORT_H
|
||||
|
||||
|
||||
/* Determine if the optional ThreadX user define file should be used. */
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler library include files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#include <intrinsics.h> /* IAR Intrinsics */
|
||||
#define __asm__ __asm /* Define to make all inline asm look similar */
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
#endif /* __ICCARM__ */
|
||||
|
||||
#ifdef __ghs__
|
||||
#include <arm_ghs.h>
|
||||
#include "tx_ghs.h"
|
||||
#endif /* __ghs__ */
|
||||
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__CC_ARM)
|
||||
#define __get_control_value __get_CONTROL
|
||||
#define __set_control_value __set_CONTROL
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __get_ipsr_value __get_IPSR
|
||||
#endif
|
||||
|
||||
/* Define ThreadX basic types for this port. */
|
||||
|
||||
#define VOID void
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long long ULONG64;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
#define ULONG64_DEFINED
|
||||
|
||||
/* Define the priority levels for ThreadX. Legal values range
|
||||
from 32 to 1024 and MUST be evenly divisible by 32. */
|
||||
|
||||
#ifndef TX_MAX_PRIORITIES
|
||||
#define TX_MAX_PRIORITIES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
|
||||
thread creation is less than this value, the thread create call will return an error. */
|
||||
|
||||
#ifndef TX_MINIMUM_STACK
|
||||
#define TX_MINIMUM_STACK 200 /* Minimum stack size for this port */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the system timer thread's default stack size and priority. These are only applicable
|
||||
if TX_TIMER_PROCESS_IN_ISR is not defined. */
|
||||
|
||||
#ifndef TX_TIMER_THREAD_STACK_SIZE
|
||||
#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */
|
||||
#endif
|
||||
|
||||
#ifndef TX_TIMER_THREAD_PRIORITY
|
||||
#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
|
||||
#endif
|
||||
|
||||
/* By default, ThreadX for Cortex-M uses the PRIMASK register to enable/disable interrupts.
|
||||
If using BASEPRI is desired, define the following two symbols for both c and assembly files:
|
||||
TX_PORT_USE_BASEPRI - This tells ThreadX to use BASEPRI instead of PRIMASK.
|
||||
TX_PORT_BASEPRI = (priority_mask << (8 - number_priority_bits)) - this defines the maximum priority level to mask.
|
||||
Any interrupt with a higher priority than priority_mask will not be masked, thus the interrupt will run.
|
||||
*/
|
||||
|
||||
/* Define various constants for the ThreadX Cortex-M port. */
|
||||
|
||||
#define TX_INT_DISABLE 1 /* Disable interrupts */
|
||||
#define TX_INT_ENABLE 0 /* Enable interrupts */
|
||||
|
||||
|
||||
/* Define the clock source for trace event entry time stamp. The following two item are port specific.
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#else
|
||||
ULONG _tx_misra_time_stamp_get(VOID);
|
||||
#define TX_TRACE_TIME_SOURCE _tx_misra_time_stamp_get()
|
||||
#endif
|
||||
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
#endif
|
||||
|
||||
#ifdef __ghs__
|
||||
/* Define constants for Green Hills EventAnalyzer. */
|
||||
|
||||
/* Define the number of ticks per second. This informs the EventAnalyzer what the timestamps
|
||||
represent. By default, this is set to 1,000,000 i.e., one tick every microsecond. */
|
||||
|
||||
#define TX_EL_TICKS_PER_SECOND 1000000
|
||||
|
||||
/* Define the method of how to get the upper and lower 32-bits of the time stamp. By default, simply
|
||||
simulate the time-stamp source with a counter. */
|
||||
|
||||
#define read_tbu() _tx_el_time_base_upper
|
||||
#define read_tbl() ++_tx_el_time_base_lower
|
||||
#endif /* __ghs__ */
|
||||
|
||||
/* Define the port specific options for the _tx_build_options variable. This variable indicates
|
||||
how the ThreadX library was built. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_BUILD_OPTIONS (0)
|
||||
|
||||
|
||||
/* Define the in-line initialization constant so that modules with in-line
|
||||
initialization capabilities can prevent their initialization from being
|
||||
a function call. */
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
#define TX_DISABLE_INLINE
|
||||
#else
|
||||
#define TX_INLINE_INITIALIZATION
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
|
||||
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
|
||||
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
|
||||
define is negated, thereby forcing the stack fill which is necessary for the stack checking
|
||||
logic. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifdef TX_ENABLE_STACK_CHECKING
|
||||
#undef TX_DISABLE_STACK_FILLING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the TX_THREAD control block extensions for this port. The main reason
|
||||
for the multiple macros is so that backward compatibility can be maintained with
|
||||
existing ThreadX kernel awareness modules. */
|
||||
|
||||
#define TX_THREAD_EXTENSION_0
|
||||
#define TX_THREAD_EXTENSION_1
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#elif defined(__ghs__)
|
||||
#define TX_THREAD_EXTENSION_2 VOID * tx_thread_eh_globals; \
|
||||
int Errno; /* errno. */ \
|
||||
char * strtok_saved_pos; /* strtok() position. */
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
|
||||
#define TX_THREAD_EXTENSION_3
|
||||
|
||||
|
||||
|
||||
/* Define the port extensions of the remaining ThreadX objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_EXTENSION
|
||||
#define TX_BYTE_POOL_EXTENSION
|
||||
#define TX_EVENT_FLAGS_GROUP_EXTENSION
|
||||
#define TX_MUTEX_EXTENSION
|
||||
#define TX_QUEUE_EXTENSION
|
||||
#define TX_SEMAPHORE_EXTENSION
|
||||
#define TX_TIMER_EXTENSION
|
||||
|
||||
|
||||
/* Define the user extension field of the thread control block. Nothing
|
||||
additional is needed for this port so it is defined as white space. */
|
||||
|
||||
#ifndef TX_THREAD_USER_EXTENSION
|
||||
#define TX_THREAD_USER_EXTENSION
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
|
||||
tx_thread_shell_entry, and tx_thread_terminate. */
|
||||
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#if (__VER__ < 8000000)
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) __iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL;
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION __iar_dlib_perthread_access(0);
|
||||
#else
|
||||
void *_tx_iar_create_per_thread_tls_area(void);
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
void __iar_Initlocks(void);
|
||||
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = _tx_iar_create_per_thread_tls_area();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) do {_tx_iar_destroy_per_thread_tls_area(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL; } while(0);
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION do {__iar_Initlocks();} while(0);
|
||||
#endif
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__)
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
|
||||
ULONG _tx_misra_control_get(void);
|
||||
void _tx_misra_control_set(ULONG value);
|
||||
ULONG _tx_misra_fpccr_get(void);
|
||||
void _tx_misra_vfp_touch(void);
|
||||
|
||||
#else /* TX_MISRA_ENABLE not defined */
|
||||
|
||||
/* Define some helper functions (these are intrinsics in some compilers). */
|
||||
#ifdef __GNUC__ /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm__ volatile (" MRS %0,CONTROL ": "=r" (control_value) );
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile (" MSR CONTROL,%0": : "r" (control_value): "memory" );
|
||||
}
|
||||
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
|
||||
#elif defined(__CC_ARM) /* ARM Compiler 5 */
|
||||
|
||||
__attribute__( ( always_inline ) ) ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm volatile ("MRS control_value,CONTROL");
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile ("MSR CONTROL,control_value");
|
||||
}
|
||||
/* Can't access VFP registers with inline asm, so define this in tx_thread_schedule. */
|
||||
void _tx_vfp_access(void);
|
||||
#define TX_VFP_TOUCH() _tx_vfp_access();
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
#endif /* Helper functions for different compilers */
|
||||
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
|
||||
|
||||
/* A completed thread falls into _thread_shell_entry and we can simply deactivate the FPU via CONTROL.FPCA
|
||||
in order to ensure no lazy stacking will occur. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* A thread can be terminated by another thread, so we first check if it's self-terminating and not in an ISR.
|
||||
If so, deactivate the FPU via CONTROL.FPCA. Otherwise we are in an interrupt or another thread is terminating
|
||||
this one, so if the FPCCR.LSPACT bit is set, we need to save the CONTROL.FPCA state, touch the FPU to flush
|
||||
the lazy FPU save, then restore the CONTROL.FPCA state. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
TX_VFP_TOUCH(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = _tx_misra_fpccr_get(); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
_tx_misra_vfp_touch(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* No VFP in use */
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
|
||||
|
||||
#endif /* defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__) */
|
||||
|
||||
|
||||
/* Define the ThreadX object creation extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_CREATE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object deletion extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_DELETE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the get system state macro. */
|
||||
|
||||
#ifndef TX_THREAD_GET_SYSTEM_STATE
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#ifdef __CC_ARM /* ARM Compiler 5 */
|
||||
|
||||
register unsigned int _ipsr __asm("ipsr");
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _ipsr)
|
||||
|
||||
#elif defined(__GNUC__) /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_ipsr_value(void)
|
||||
{
|
||||
unsigned int ipsr_value;
|
||||
__asm__ volatile (" MRS %0,IPSR ": "=r" (ipsr_value) );
|
||||
return(ipsr_value);
|
||||
}
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_ipsr_value())
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_IPSR())
|
||||
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE for different compilers */
|
||||
|
||||
#else /* TX_MISRA_ENABLE is defined, use MISRA function. */
|
||||
ULONG _tx_misra_ipsr_get(VOID);
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _tx_misra_ipsr_get())
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE */
|
||||
|
||||
|
||||
/* Define the check for whether or not to call the _tx_thread_system_return function. A non-zero value
|
||||
indicates that _tx_thread_system_return should not be called. This overrides the definition in tx_thread.h
|
||||
for Cortex-M since so we don't waste time checking the _tx_thread_system_state variable that is always
|
||||
zero after initialization for Cortex-M ports. */
|
||||
|
||||
#ifndef TX_THREAD_SYSTEM_RETURN_CHECK
|
||||
#define TX_THREAD_SYSTEM_RETURN_CHECK(c) (c) = ((ULONG) _tx_thread_preempt_disable);
|
||||
#endif
|
||||
|
||||
/* Define the macro to ensure _tx_thread_preempt_disable is set early in initialization in order to
|
||||
prevent early scheduling on Cortex-M parts. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_POST_INITIALIZATION _tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef TX_DISABLE_INLINE
|
||||
|
||||
/* Define the TX_LOWEST_SET_BIT_CALCULATE macro for each compiler. */
|
||||
#ifdef __ICCARM__ /* IAR Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __CLZ(__RBIT((m)));
|
||||
#elif defined(__CC_ARM) /* AC5 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __clz(__rbit((m)));
|
||||
#elif defined(__GNUC__) /* GCC and AC6 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) __asm__ volatile (" RBIT %0,%1 ": "=r" (m) : "r" (m) ); \
|
||||
__asm__ volatile (" CLZ %0,%1 ": "=r" (b) : "r" (m) );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Define the interrupt disable/restore macros for each compiler. */
|
||||
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
|
||||
/*** GCC/AC6 and IAR ***/
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS %0, BASEPRI ": "=r" (posture));
|
||||
#else
|
||||
__asm__ volatile ("MRS %0, PRIMASK ": "=r" (posture));
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__attribute__( ( always_inline ) ) static inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value));
|
||||
}
|
||||
#else
|
||||
__attribute__( ( always_inline ) ) static inline void __enable_interrupts(void)
|
||||
{
|
||||
__asm__ volatile ("CPSIE i": : : "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
//__asm__ volatile ("MSR BASEPRI,%0": : "r" (int_posture): "memory");
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK,%0": : "r" (int_posture): "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i" : : : "memory");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(0);
|
||||
#else
|
||||
__enable_interrupts();
|
||||
#endif
|
||||
__restore_interrupt(interrupt_save);
|
||||
}
|
||||
}
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End GCC/AC6 and IAR ***/
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
|
||||
/*** AC5 ***/
|
||||
|
||||
static __inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS #posture, BASEPRI");
|
||||
#else
|
||||
__asm__ volatile ("MRS #posture, PRIMASK");
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
static __inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI, #basepri_value");
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
static __inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK, #int_posture");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (_ipsr == 0)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
__set_basepri_value(0);
|
||||
__set_basepri_value(interrupt_save);
|
||||
#else
|
||||
interrupt_save = __disable_irq();
|
||||
__enable_irq();
|
||||
if (interrupt_save != 0)
|
||||
__disable_irq();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End AC5 ***/
|
||||
|
||||
#endif /* Interrupt disable/restore macros for each compiler. */
|
||||
|
||||
/* Redefine _tx_thread_system_return for improved performance. */
|
||||
|
||||
#define _tx_thread_system_return _tx_thread_system_return_inline
|
||||
|
||||
|
||||
#else /* TX_DISABLE_INLINE is defined */
|
||||
|
||||
UINT _tx_thread_interrupt_disable(VOID);
|
||||
VOID _tx_thread_interrupt_restore(UINT previous_posture);
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register UINT interrupt_save;
|
||||
|
||||
#define TX_DISABLE interrupt_save = _tx_thread_interrupt_disable();
|
||||
#define TX_RESTORE _tx_thread_interrupt_restore(interrupt_save);
|
||||
#endif /* TX_DISABLE_INLINE */
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
void tx_thread_fpu_disable(void);
|
||||
|
||||
|
||||
/* Define the version ID of ThreadX. This may be utilized by the application. */
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) 2024 Microsoft Corporation. * ThreadX Cortex-M3/GNU Version 6.4.2 *";
|
||||
#else
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
extern CHAR _tx_version_id[100];
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
722
ports/cortex_m3/gnu/src/tx_misra.S
Normal file
722
ports/cortex_m3/gnu/src/tx_misra.S
Normal file
@@ -0,0 +1,722 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** ThreadX MISRA Compliance */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#define SHT_PROGBITS 0x1
|
||||
|
||||
.global __aeabi_memset
|
||||
.global _tx_thread_current_ptr
|
||||
.global _tx_thread_interrupt_disable
|
||||
.global _tx_thread_interrupt_restore
|
||||
.global _tx_thread_stack_analyze
|
||||
.global _tx_thread_stack_error_handler
|
||||
.global _tx_thread_system_state
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_trace_buffer_current_ptr
|
||||
.global _tx_trace_buffer_end_ptr
|
||||
.global _tx_trace_buffer_start_ptr
|
||||
.global _tx_trace_event_enable_bits
|
||||
.global _tx_trace_full_notify_function
|
||||
.global _tx_trace_header_ptr
|
||||
#endif
|
||||
|
||||
.global _tx_misra_always_true
|
||||
.global _tx_misra_block_pool_to_uchar_pointer_convert
|
||||
.global _tx_misra_byte_pool_to_uchar_pointer_convert
|
||||
.global _tx_misra_char_to_uchar_pointer_convert
|
||||
.global _tx_misra_const_char_to_char_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_entry_to_uchar_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_indirect_void_to_uchar_pointer_convert
|
||||
.global _tx_misra_memset
|
||||
.global _tx_misra_message_copy
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_object_to_uchar_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_pointer_to_ulong_convert
|
||||
.global _tx_misra_status_get
|
||||
.global _tx_misra_thread_stack_check
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_time_stamp_get
|
||||
#endif
|
||||
.global _tx_misra_timer_indirect_to_void_pointer_convert
|
||||
.global _tx_misra_timer_pointer_add
|
||||
.global _tx_misra_timer_pointer_dif
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_trace_event_insert
|
||||
#endif
|
||||
.global _tx_misra_uchar_pointer_add
|
||||
.global _tx_misra_uchar_pointer_dif
|
||||
.global _tx_misra_uchar_pointer_sub
|
||||
.global _tx_misra_uchar_to_align_type_pointer_convert
|
||||
.global _tx_misra_uchar_to_block_pool_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_uchar_to_entry_pointer_convert
|
||||
.global _tx_misra_uchar_to_header_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_uchar_to_indirect_byte_pool_pointer_convert
|
||||
.global _tx_misra_uchar_to_indirect_uchar_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
.global _tx_misra_uchar_to_object_pointer_convert
|
||||
#endif
|
||||
.global _tx_misra_uchar_to_void_pointer_convert
|
||||
.global _tx_misra_ulong_pointer_add
|
||||
.global _tx_misra_ulong_pointer_dif
|
||||
.global _tx_misra_ulong_pointer_sub
|
||||
.global _tx_misra_ulong_to_pointer_convert
|
||||
.global _tx_misra_ulong_to_thread_pointer_convert
|
||||
.global _tx_misra_user_timer_pointer_get
|
||||
.global _tx_misra_void_to_block_pool_pointer_convert
|
||||
.global _tx_misra_void_to_byte_pool_pointer_convert
|
||||
.global _tx_misra_void_to_event_flags_pointer_convert
|
||||
.global _tx_misra_void_to_indirect_uchar_pointer_convert
|
||||
.global _tx_misra_void_to_mutex_pointer_convert
|
||||
.global _tx_misra_void_to_queue_pointer_convert
|
||||
.global _tx_misra_void_to_semaphore_pointer_convert
|
||||
.global _tx_misra_void_to_thread_pointer_convert
|
||||
.global _tx_misra_void_to_uchar_pointer_convert
|
||||
.global _tx_misra_void_to_ulong_pointer_convert
|
||||
.global _tx_misra_ipsr_get
|
||||
.global _tx_misra_control_get
|
||||
.global _tx_misra_control_set
|
||||
#ifdef __ARM_FP
|
||||
.global _tx_misra_fpccr_get
|
||||
.global _tx_misra_vfp_touch
|
||||
#endif
|
||||
|
||||
.global _tx_misra_event_flags_group_not_used
|
||||
.global _tx_misra_event_flags_set_notify_not_used
|
||||
.global _tx_misra_queue_not_used
|
||||
.global _tx_misra_queue_send_notify_not_used
|
||||
.global _tx_misra_semaphore_not_used
|
||||
.global _tx_misra_semaphore_put_notify_not_used
|
||||
.global _tx_misra_thread_entry_exit_notify_not_used
|
||||
.global _tx_misra_thread_not_used
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_memset(VOID *ptr, UINT value, UINT size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
.thumb_func
|
||||
_tx_misra_memset:
|
||||
PUSH {R4,LR}
|
||||
MOVS R4,R0
|
||||
MOVS R0,R2
|
||||
MOVS R2,R1
|
||||
MOVS R1,R0
|
||||
MOVS R0,R4
|
||||
BL __aeabi_memset
|
||||
POP {R4,PC} // return
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UCHAR *_tx_misra_uchar_pointer_add(UCHAR *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_uchar_pointer_add:
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UCHAR *_tx_misra_uchar_pointer_sub(UCHAR *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_uchar_pointer_sub:
|
||||
RSBS R1,R1,#+0
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_uchar_pointer_dif(UCHAR *ptr1, UCHAR *ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_uchar_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/************************************************************************************************************************************/
|
||||
/************************************************************************************************************************************/
|
||||
/** */
|
||||
/** This single function serves all of the below prototypes. */
|
||||
/** */
|
||||
/** ULONG _tx_misra_pointer_to_ulong_convert(VOID *ptr); */
|
||||
/** VOID *_tx_misra_ulong_to_pointer_convert(ULONG input); */
|
||||
/** UCHAR **_tx_misra_indirect_void_to_uchar_pointer_convert(VOID **return_ptr); */
|
||||
/** UCHAR **_tx_misra_uchar_to_indirect_uchar_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR *_tx_misra_block_pool_to_uchar_pointer_convert(TX_BLOCK_POOL *pool); */
|
||||
/** TX_BLOCK_POOL *_tx_misra_void_to_block_pool_pointer_convert(VOID *pointer); */
|
||||
/** UCHAR *_tx_misra_void_to_uchar_pointer_convert(VOID *pointer); */
|
||||
/** TX_BLOCK_POOL *_tx_misra_uchar_to_block_pool_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR **_tx_misra_void_to_indirect_uchar_pointer_convert(VOID *pointer); */
|
||||
/** TX_BYTE_POOL *_tx_misra_void_to_byte_pool_pointer_convert(VOID *pointer); */
|
||||
/** UCHAR *_tx_misra_byte_pool_to_uchar_pointer_convert(TX_BYTE_POOL *pool); */
|
||||
/** ALIGN_TYPE *_tx_misra_uchar_to_align_type_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_BYTE_POOL **_tx_misra_uchar_to_indirect_byte_pool_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_EVENT_FLAGS_GROUP *_tx_misra_void_to_event_flags_pointer_convert(VOID *pointer); */
|
||||
/** ULONG *_tx_misra_void_to_ulong_pointer_convert(VOID *pointer); */
|
||||
/** TX_MUTEX *_tx_misra_void_to_mutex_pointer_convert(VOID *pointer); */
|
||||
/** TX_QUEUE *_tx_misra_void_to_queue_pointer_convert(VOID *pointer); */
|
||||
/** TX_SEMAPHORE *_tx_misra_void_to_semaphore_pointer_convert(VOID *pointer); */
|
||||
/** VOID *_tx_misra_uchar_to_void_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_THREAD *_tx_misra_ulong_to_thread_pointer_convert(ULONG value); */
|
||||
/** VOID *_tx_misra_timer_indirect_to_void_pointer_convert(TX_TIMER_INTERNAL **pointer); */
|
||||
/** CHAR *_tx_misra_const_char_to_char_pointer_convert(const char *pointer); */
|
||||
/** TX_THREAD *_tx_misra_void_to_thread_pointer_convert(void *pointer); */
|
||||
/** UCHAR *_tx_misra_object_to_uchar_pointer_convert(TX_TRACE_OBJECT_ENTRY *pointer); */
|
||||
/** TX_TRACE_OBJECT_ENTRY *_tx_misra_uchar_to_object_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_TRACE_HEADER *_tx_misra_uchar_to_header_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_TRACE_BUFFER_ENTRY *_tx_misra_uchar_to_entry_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR *_tx_misra_entry_to_uchar_pointer_convert(TX_TRACE_BUFFER_ENTRY *pointer); */
|
||||
/** UCHAR *_tx_misra_char_to_uchar_pointer_convert(CHAR *pointer); */
|
||||
/** VOID _tx_misra_event_flags_group_not_used(TX_EVENT_FLAGS_GROUP *group_ptr); */
|
||||
/** VOID _tx_misra_event_flags_set_notify_not_used(VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr)); */
|
||||
/** VOID _tx_misra_queue_not_used(TX_QUEUE *queue_ptr); */
|
||||
/** VOID _tx_misra_queue_send_notify_not_used(VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr)); */
|
||||
/** VOID _tx_misra_semaphore_not_used(TX_SEMAPHORE *semaphore_ptr); */
|
||||
/** VOID _tx_misra_semaphore_put_notify_not_used(VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr)); */
|
||||
/** VOID _tx_misra_thread_not_used(TX_THREAD *thread_ptr); */
|
||||
/** VOID _tx_misra_thread_entry_exit_notify_not_used(VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT id)); */
|
||||
/** */
|
||||
/************************************************************************************************************************************/
|
||||
/************************************************************************************************************************************/
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_pointer_to_ulong_convert:
|
||||
_tx_misra_ulong_to_pointer_convert:
|
||||
_tx_misra_indirect_void_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_indirect_uchar_pointer_convert:
|
||||
_tx_misra_block_pool_to_uchar_pointer_convert:
|
||||
_tx_misra_void_to_block_pool_pointer_convert:
|
||||
_tx_misra_void_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_block_pool_pointer_convert:
|
||||
_tx_misra_void_to_indirect_uchar_pointer_convert:
|
||||
_tx_misra_void_to_byte_pool_pointer_convert:
|
||||
_tx_misra_byte_pool_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_align_type_pointer_convert:
|
||||
_tx_misra_uchar_to_indirect_byte_pool_pointer_convert:
|
||||
_tx_misra_void_to_event_flags_pointer_convert:
|
||||
_tx_misra_void_to_ulong_pointer_convert:
|
||||
_tx_misra_void_to_mutex_pointer_convert:
|
||||
_tx_misra_void_to_queue_pointer_convert:
|
||||
_tx_misra_void_to_semaphore_pointer_convert:
|
||||
_tx_misra_uchar_to_void_pointer_convert:
|
||||
_tx_misra_ulong_to_thread_pointer_convert:
|
||||
_tx_misra_timer_indirect_to_void_pointer_convert:
|
||||
_tx_misra_const_char_to_char_pointer_convert:
|
||||
_tx_misra_void_to_thread_pointer_convert:
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
_tx_misra_object_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_object_pointer_convert:
|
||||
_tx_misra_uchar_to_header_pointer_convert:
|
||||
_tx_misra_uchar_to_entry_pointer_convert:
|
||||
_tx_misra_entry_to_uchar_pointer_convert:
|
||||
#endif
|
||||
_tx_misra_char_to_uchar_pointer_convert:
|
||||
_tx_misra_event_flags_group_not_used:
|
||||
_tx_misra_event_flags_set_notify_not_used:
|
||||
_tx_misra_queue_not_used:
|
||||
_tx_misra_queue_send_notify_not_used:
|
||||
_tx_misra_semaphore_not_used:
|
||||
_tx_misra_semaphore_put_notify_not_used:
|
||||
_tx_misra_thread_entry_exit_notify_not_used:
|
||||
_tx_misra_thread_not_used:
|
||||
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG *_tx_misra_ulong_pointer_add(ULONG *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ulong_pointer_add:
|
||||
ADD R0,R0,R1, LSL #+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG *_tx_misra_ulong_pointer_sub(ULONG *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ulong_pointer_sub:
|
||||
MVNS R2,#+3
|
||||
MULS R1,R2,R1
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_ulong_pointer_dif(ULONG *ptr1, ULONG *ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ulong_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
ASRS R0,R0,#+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_message_copy(ULONG **source, ULONG **destination, */
|
||||
/** UINT size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_message_copy:
|
||||
PUSH {R4,R5}
|
||||
LDR R3,[R0, #+0]
|
||||
LDR R4,[R1, #+0]
|
||||
LDR R5,[R3, #+0]
|
||||
STR R5,[R4, #+0]
|
||||
ADDS R4,R4,#+4
|
||||
ADDS R3,R3,#+4
|
||||
CMP R2,#+2
|
||||
BCC.N _tx_misra_message_copy_0
|
||||
SUBS R2,R2,#+1
|
||||
B.N _tx_misra_message_copy_1
|
||||
_tx_misra_message_copy_2:
|
||||
LDR R5,[R3, #+0]
|
||||
STR R5,[R4, #+0]
|
||||
ADDS R4,R4,#+4
|
||||
ADDS R3,R3,#+4
|
||||
SUBS R2,R2,#+1
|
||||
_tx_misra_message_copy_1:
|
||||
CMP R2,#+0
|
||||
BNE.N _tx_misra_message_copy_2
|
||||
_tx_misra_message_copy_0:
|
||||
STR R3,[R0, #+0]
|
||||
STR R4,[R1, #+0]
|
||||
POP {R4,R5}
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_timer_pointer_dif(TX_TIMER_INTERNAL **ptr1, */
|
||||
/** TX_TIMER_INTERNAL **ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_timer_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
ASRS R0,R0,#+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** TX_TIMER_INTERNAL **_tx_misra_timer_pointer_add(TX_TIMER_INTERNAL */
|
||||
/** **ptr1, ULONG size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_timer_pointer_add:
|
||||
ADD R0,R0,R1, LSL #+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_user_timer_pointer_get(TX_TIMER_INTERNAL */
|
||||
/** *internal_timer, TX_TIMER **user_timer); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_user_timer_pointer_get:
|
||||
SUBS R0,#8
|
||||
STR R0,[R1, #+0]
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_thread_stack_check(TX_THREAD *thread_ptr, */
|
||||
/** VOID **highest_stack); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_thread_stack_check:
|
||||
PUSH {R3-R5,LR}
|
||||
MOVS R4,R0
|
||||
MOVS R5,R1
|
||||
BL _tx_thread_interrupt_disable
|
||||
CMP R4,#+0
|
||||
BEQ.N _tx_misra_thread_stack_check_0
|
||||
LDR R1,[R4, #+0]
|
||||
LDR R2,=0x54485244
|
||||
CMP R1,R2
|
||||
BNE.N _tx_misra_thread_stack_check_0
|
||||
LDR R1,[R4, #+8]
|
||||
LDR R2,[R5, #+0]
|
||||
CMP R1,R2
|
||||
BCS.N _tx_misra_thread_stack_check_1
|
||||
LDR R1,[R4, #+8]
|
||||
STR R1,[R5, #+0]
|
||||
_tx_misra_thread_stack_check_1:
|
||||
LDR R1,[R4, #+12]
|
||||
LDR R1,[R1, #+0]
|
||||
CMP R1,#-269488145
|
||||
BNE.N _tx_misra_thread_stack_check_2
|
||||
LDR R1,[R4, #+16]
|
||||
LDR R1,[R1, #+1]
|
||||
CMP R1,#-269488145
|
||||
BNE.N _tx_misra_thread_stack_check_2
|
||||
LDR R1,[R5, #+0]
|
||||
LDR R2,[R4, #+12]
|
||||
CMP R1,R2
|
||||
BCS.N _tx_misra_thread_stack_check_3
|
||||
_tx_misra_thread_stack_check_2:
|
||||
BL _tx_thread_interrupt_restore
|
||||
MOVS R0,R4
|
||||
BL _tx_thread_stack_error_handler
|
||||
BL _tx_thread_interrupt_disable
|
||||
_tx_misra_thread_stack_check_3:
|
||||
LDR R1,[R5, #+0]
|
||||
LDR R1,[R1, #-4]
|
||||
CMP R1,#-269488145
|
||||
BEQ.N _tx_misra_thread_stack_check_0
|
||||
BL _tx_thread_interrupt_restore
|
||||
MOVS R0,R4
|
||||
BL _tx_thread_stack_analyze
|
||||
BL _tx_thread_interrupt_disable
|
||||
_tx_misra_thread_stack_check_0:
|
||||
BL _tx_thread_interrupt_restore
|
||||
POP {R0,R4,R5,PC} // return
|
||||
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_trace_event_insert(ULONG event_id, */
|
||||
/** VOID *info_field_1, ULONG info_field_2, ULONG info_field_3, */
|
||||
/** ULONG info_field_4, ULONG filter, ULONG time_stamp); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_trace_event_insert:
|
||||
PUSH {R3-R7,LR}
|
||||
LDR.N R4,DataTable2_1
|
||||
LDR R4,[R4, #+0]
|
||||
CMP R4,#+0
|
||||
BEQ.N _tx_misra_trace_event_insert_0
|
||||
LDR.N R5,DataTable2_2
|
||||
LDR R5,[R5, #+0]
|
||||
LDR R6,[SP, #+28]
|
||||
TST R5,R6
|
||||
BEQ.N _tx_misra_trace_event_insert_0
|
||||
LDR.N R5,DataTable2_3
|
||||
LDR R5,[R5, #+0]
|
||||
LDR.N R6,DataTable2_4
|
||||
LDR R6,[R6, #+0]
|
||||
CMP R5,#+0
|
||||
BNE.N _tx_misra_trace_event_insert_1
|
||||
LDR R5,[R6, #+44]
|
||||
LDR R7,[R6, #+60]
|
||||
LSLS R7,R7,#+16
|
||||
ORRS R7,R7,#0x80000000
|
||||
ORRS R5,R7,R5
|
||||
B.N _tx_misra_trace_event_insert_2
|
||||
_tx_misra_trace_event_insert_1:
|
||||
CMP R5,#-252645136
|
||||
BCS.N _tx_misra_trace_event_insert_3
|
||||
MOVS R5,R6
|
||||
MOVS R6,#-1
|
||||
B.N _tx_misra_trace_event_insert_2
|
||||
_tx_misra_trace_event_insert_3:
|
||||
MOVS R6,#-252645136
|
||||
MOVS R5,#+0
|
||||
_tx_misra_trace_event_insert_2:
|
||||
STR R6,[R4, #+0]
|
||||
STR R5,[R4, #+4]
|
||||
STR R0,[R4, #+8]
|
||||
LDR R0,[SP, #+32]
|
||||
STR R0,[R4, #+12]
|
||||
STR R1,[R4, #+16]
|
||||
STR R2,[R4, #+20]
|
||||
STR R3,[R4, #+24]
|
||||
LDR R0,[SP, #+24]
|
||||
STR R0,[R4, #+28]
|
||||
ADDS R4,R4,#+32
|
||||
LDR.N R0,DataTable2_5
|
||||
LDR R0,[R0, #+0]
|
||||
CMP R4,R0
|
||||
BCC.N _tx_misra_trace_event_insert_4
|
||||
LDR.N R0,DataTable2_6
|
||||
LDR R4,[R0, #+0]
|
||||
LDR.N R0,DataTable2_1
|
||||
STR R4,[R0, #+0]
|
||||
LDR.N R0,DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
STR R4,[R0, #+32]
|
||||
LDR.N R0,DataTable2_8
|
||||
LDR R0,[R0, #+0]
|
||||
CMP R0,#+0
|
||||
BEQ.N _tx_misra_trace_event_insert_0
|
||||
LDR.N R0,DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
LDR.N R1,DataTable2_8
|
||||
LDR R1,[R1, #+0]
|
||||
BLX R1
|
||||
B.N _tx_misra_trace_event_insert_0
|
||||
_tx_misra_trace_event_insert_4:
|
||||
LDR.N R0,DataTable2_1
|
||||
STR R4,[R0, #+0]
|
||||
LDR.N R0,DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
STR R4,[R0, #+32]
|
||||
_tx_misra_trace_event_insert_0:
|
||||
POP {R0,R4-R7,PC} // return
|
||||
|
||||
|
||||
.data
|
||||
DataTable2_1:
|
||||
.word _tx_trace_buffer_current_ptr
|
||||
|
||||
.data
|
||||
DataTable2_2:
|
||||
.word _tx_trace_event_enable_bits
|
||||
|
||||
.data
|
||||
DataTable2_5:
|
||||
.word _tx_trace_buffer_end_ptr
|
||||
|
||||
.data
|
||||
DataTable2_6:
|
||||
.word _tx_trace_buffer_start_ptr
|
||||
|
||||
.data
|
||||
DataTable2_7:
|
||||
.word _tx_trace_header_ptr
|
||||
|
||||
.data
|
||||
DataTable2_8:
|
||||
.word _tx_trace_full_notify_function
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_time_stamp_get(VOID); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_time_stamp_get:
|
||||
MOVS R0,#+0
|
||||
BX LR // return
|
||||
|
||||
#endif
|
||||
|
||||
.data
|
||||
DataTable2_3:
|
||||
.word _tx_thread_system_state
|
||||
|
||||
.data
|
||||
DataTable2_4:
|
||||
.word _tx_thread_current_ptr
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UINT _tx_misra_always_true(void); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_always_true:
|
||||
MOVS R0,#+1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UINT _tx_misra_status_get(UINT status); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_status_get:
|
||||
MOVS R0,#+0
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_ipsr_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_ipsr_get:
|
||||
MRS R0, IPSR
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_control_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_control_get:
|
||||
MRS R0, CONTROL
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** void _tx_misra_control_set(ULONG value); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_control_set:
|
||||
MSR CONTROL, R0
|
||||
BX LR // return
|
||||
|
||||
|
||||
#ifdef __ARM_FP
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_fpccr_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_fpccr_get:
|
||||
LDR r0, =0xE000EF34 // Build FPCCR address
|
||||
LDR r0, [r0] // Load FPCCR value
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** void _tx_misra_vfp_touch(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
.text
|
||||
.thumb_func
|
||||
_tx_misra_vfp_touch:
|
||||
vmov.f32 s0, s0
|
||||
BX LR // return
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
.data
|
||||
.word 0
|
||||
87
ports/cortex_m3/gnu/src/tx_thread_context_restore.S
Normal file
87
ports/cortex_m3/gnu/src/tx_thread_context_restore.S
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
.global _tx_execution_isr_exit
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_restore Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_exit] Execution profiling ISR exit */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs Interrupt Service Routines */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_restore(VOID)
|
||||
// {
|
||||
.global _tx_thread_context_restore
|
||||
.thumb_func
|
||||
_tx_thread_context_restore:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR exit function to indicate an ISR is complete. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_exit // Call the ISR exit function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
BX lr
|
||||
// }
|
||||
85
ports/cortex_m3/gnu/src/tx_thread_context_save.S
Normal file
85
ports/cortex_m3/gnu/src/tx_thread_context_save.S
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_save Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_enter] Execution profiling ISR enter */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_save(VOID)
|
||||
// {
|
||||
.global _tx_thread_context_save
|
||||
.thumb_func
|
||||
_tx_thread_context_save:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR enter function to indicate an ISR is starting. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_enter // Call the ISR enter function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
/* Context is already saved - just return. */
|
||||
|
||||
BX lr
|
||||
// }
|
||||
84
ports/cortex_m3/gnu/src/tx_thread_interrupt_control.S
Normal file
84
ports/cortex_m3/gnu/src/tx_thread_interrupt_control.S
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_control Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for changing the interrupt lockout */
|
||||
/* posture of the system. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* new_posture New interrupt lockout posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_control(UINT new_posture)
|
||||
// {
|
||||
.global _tx_thread_interrupt_control
|
||||
.thumb_func
|
||||
_tx_thread_interrupt_control:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Pickup current interrupt posture
|
||||
MSR BASEPRI, r0 // Apply the new interrupt posture
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#else
|
||||
MRS r1, PRIMASK // Pickup current interrupt lockout
|
||||
MSR PRIMASK, r0 // Apply the new interrupt lockout
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#endif
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
84
ports/cortex_m3/gnu/src/tx_thread_interrupt_disable.S
Normal file
84
ports/cortex_m3/gnu/src/tx_thread_interrupt_disable.S
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_disable Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for disabling interrupts and returning */
|
||||
/* the previous interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_disable(VOID)
|
||||
// {
|
||||
.global _tx_thread_interrupt_disable
|
||||
.thumb_func
|
||||
_tx_thread_interrupt_disable:
|
||||
/* Return current interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r0, BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
MRS r0, PRIMASK
|
||||
CPSID i
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
81
ports/cortex_m3/gnu/src/tx_thread_interrupt_restore.S
Normal file
81
ports/cortex_m3/gnu/src/tx_thread_interrupt_restore.S
Normal file
@@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_restore Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for restoring the previous */
|
||||
/* interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* previous_posture Previous interrupt posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_interrupt_restore(UINT previous_posture)
|
||||
// {
|
||||
.global _tx_thread_interrupt_restore
|
||||
.thumb_func
|
||||
_tx_thread_interrupt_restore:
|
||||
/* Restore previous interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
MSR PRIMASK, r0
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
330
ports/cortex_m3/gnu/src/tx_thread_schedule.S
Normal file
330
ports/cortex_m3/gnu/src/tx_thread_schedule.S
Normal file
@@ -0,0 +1,330 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.global _tx_thread_current_ptr
|
||||
.global _tx_thread_execute_ptr
|
||||
.global _tx_timer_time_slice
|
||||
.global _tx_execution_thread_enter
|
||||
.global _tx_execution_thread_exit
|
||||
#ifdef TX_LOW_POWER
|
||||
.global tx_low_power_enter
|
||||
.global tx_low_power_exit
|
||||
#endif
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function waits for a thread control block pointer to appear in */
|
||||
/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
|
||||
/* in the variable, the corresponding thread is resumed. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Fixed predefined macro name, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
// {
|
||||
.global _tx_thread_schedule
|
||||
.thumb_func
|
||||
_tx_thread_schedule:
|
||||
|
||||
/* This function should only ever be called on Cortex-M
|
||||
from the first schedule request. Subsequent scheduling occurs
|
||||
from the PendSV handling routine below. */
|
||||
|
||||
/* Clear the preempt-disable flag to enable rescheduling after initialization on Cortex-M targets. */
|
||||
|
||||
MOV r0, #0 // Build value for TX_FALSE
|
||||
LDR r2, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
STR r0, [r2, #0] // Clear preempt disable flag
|
||||
|
||||
/* Clear CONTROL.FPCA bit so VFP registers aren't unnecessarily stacked. */
|
||||
|
||||
#ifdef __ARM_FP
|
||||
MRS r0, CONTROL // Pickup current CONTROL register
|
||||
BIC r0, r0, #4 // Clear the FPCA bit
|
||||
MSR CONTROL, r0 // Setup new CONTROL register
|
||||
#endif
|
||||
|
||||
/* Enable interrupts */
|
||||
CPSIE i
|
||||
|
||||
/* Enter the scheduler for the first time. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
DSB // Complete all memory accesses
|
||||
ISB // Flush pipeline
|
||||
|
||||
/* Wait here for the PendSV to take place. */
|
||||
|
||||
__tx_wait_here:
|
||||
B __tx_wait_here // Wait for the PendSV to happen
|
||||
// }
|
||||
|
||||
/* Generic context switching PendSV handler. */
|
||||
|
||||
.global PendSV_Handler
|
||||
.global __tx_PendSVHandler
|
||||
.syntax unified
|
||||
.thumb_func
|
||||
PendSV_Handler:
|
||||
.thumb_func
|
||||
__tx_PendSVHandler:
|
||||
|
||||
/* Get current thread value and new thread pointer. */
|
||||
|
||||
__tx_ts_handler:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
MOV r3, #0 // Build NULL value
|
||||
LDR r1, [r0] // Pickup current thread pointer
|
||||
|
||||
/* Determine if there is a current thread to finish preserving. */
|
||||
|
||||
CBZ r1, __tx_ts_new // If NULL, skip preservation
|
||||
|
||||
/* Recover PSP and preserve current thread context. */
|
||||
|
||||
STR r3, [r0] // Set _tx_thread_current_ptr to NULL
|
||||
MRS r12, PSP // Pickup PSP pointer (thread's stack pointer)
|
||||
STMDB r12!, {r4-r11} // Save its remaining registers
|
||||
#ifdef __ARM_FP
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_save
|
||||
VSTMDB r12!,{s16-s31} // Yes, save additional VFP registers
|
||||
_skip_vfp_save:
|
||||
#endif
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
STMDB r12!, {LR} // Save LR on the stack
|
||||
|
||||
/* Determine if time-slice is active. If it isn't, skip time handling processing. */
|
||||
|
||||
LDR r5, [r4] // Pickup current time-slice
|
||||
STR r12, [r1, #8] // Save the thread stack pointer
|
||||
CBZ r5, __tx_ts_new // If not active, skip processing
|
||||
|
||||
/* Time-slice is active, save the current thread's time-slice and clear the global time-slice variable. */
|
||||
|
||||
STR r5, [r1, #24] // Save current time-slice
|
||||
|
||||
/* Clear the global time-slice. */
|
||||
|
||||
STR r3, [r4] // Clear time-slice
|
||||
|
||||
/* Executing thread is now completely preserved!!! */
|
||||
|
||||
__tx_ts_new:
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBZ r1, __tx_ts_wait // No, skip to the wait processing
|
||||
|
||||
/* Yes, another thread is ready for else, make the current thread the new thread. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
__tx_ts_restore:
|
||||
LDR r7, [r1, #4] // Pickup the current thread run count
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
LDR r5, [r1, #24] // Pickup thread's current time-slice
|
||||
ADD r7, r7, #1 // Increment the thread run count
|
||||
STR r7, [r1, #4] // Store the new run count
|
||||
|
||||
/* Setup global time-slice with thread's current time-slice. */
|
||||
|
||||
STR r5, [r4] // Setup global time-slice
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread entry function to indicate the thread is executing. */
|
||||
PUSH {r0, r1} // Save r0 and r1
|
||||
BL _tx_execution_thread_enter // Call the thread execution enter function
|
||||
POP {r0, r1} // Recover r0 and r1
|
||||
#endif
|
||||
|
||||
/* Restore the thread context and PSP. */
|
||||
|
||||
LDR r12, [r1, #8] // Pickup thread's stack pointer
|
||||
LDMIA r12!, {LR} // Pickup LR
|
||||
#ifdef __ARM_FP
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_restore // If not, skip VFP restore
|
||||
VLDMIA r12!, {s16-s31} // Yes, restore additional VFP registers
|
||||
_skip_vfp_restore:
|
||||
#endif
|
||||
LDMIA r12!, {r4-r11} // Recover thread's registers
|
||||
MSR PSP, r12 // Setup the thread's stack pointer
|
||||
|
||||
/* Return to thread. */
|
||||
|
||||
BX lr // Return to thread!
|
||||
|
||||
/* The following is the idle wait processing... in this case, no threads are ready for execution and the
|
||||
system will simply be idle until an interrupt occurs that makes a thread ready. Note that interrupts
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
STR r1, [r0] // Store it in the current pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_enter // Possibly enter low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_WFI
|
||||
DSB // Ensure no outstanding memory transactions
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_exit // Exit low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
already in the handler! */
|
||||
|
||||
__tx_ts_ready:
|
||||
MOV r7, #0x08000000 // Build clear PendSV value
|
||||
MOV r8, #0xE000E000 // Build base NVIC address
|
||||
STR r7, [r8, #0xD04] // Clear any PendSV
|
||||
|
||||
/* Re-enable interrupts and restore new thread. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_restore // Restore the thread
|
||||
// }
|
||||
|
||||
#ifdef __ARM_FP
|
||||
|
||||
.global tx_thread_fpu_enable
|
||||
.thumb_func
|
||||
tx_thread_fpu_enable:
|
||||
.global tx_thread_fpu_disable
|
||||
.thumb_func
|
||||
tx_thread_fpu_disable:
|
||||
|
||||
/* Automatic VPF logic is supported, this function is present only for
|
||||
backward compatibility purposes and therefore simply returns. */
|
||||
|
||||
BX LR // Return to caller
|
||||
|
||||
#endif
|
||||
138
ports/cortex_m3/gnu/src/tx_thread_stack_build.S
Normal file
138
ports/cortex_m3/gnu/src/tx_thread_stack_build.S
Normal file
@@ -0,0 +1,138 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_stack_build Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function builds a stack frame on the supplied thread's stack. */
|
||||
/* The stack frame results in a fake interrupt return to the supplied */
|
||||
/* function pointer. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* thread_ptr Pointer to thread control blk */
|
||||
/* function_ptr Pointer to return function */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_thread_create Create thread service */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
|
||||
// {
|
||||
.global _tx_thread_stack_build
|
||||
.thumb_func
|
||||
_tx_thread_stack_build:
|
||||
|
||||
/* Build a fake interrupt frame. The form of the fake interrupt stack
|
||||
on the Cortex-M should look like the following after it is built:
|
||||
|
||||
Stack Top:
|
||||
LR Interrupted LR (LR at time of PENDSV)
|
||||
r4 Initial value for r4
|
||||
r5 Initial value for r5
|
||||
r6 Initial value for r6
|
||||
r7 Initial value for r7
|
||||
r8 Initial value for r8
|
||||
r9 Initial value for r9
|
||||
r10 Initial value for r10
|
||||
r11 Initial value for r11
|
||||
r0 Initial value for r0 (Hardware stack starts here!!)
|
||||
r1 Initial value for r1
|
||||
r2 Initial value for r2
|
||||
r3 Initial value for r3
|
||||
r12 Initial value for r12
|
||||
lr Initial value for lr
|
||||
pc Initial value for pc
|
||||
xPSR Initial value for xPSR
|
||||
|
||||
Stack Bottom: (higher memory address) */
|
||||
|
||||
LDR r2, [r0, #16] // Pickup end of stack area
|
||||
BIC r2, r2, #0x7 // Align frame for 8-byte alignment
|
||||
SUB r2, r2, #68 // Subtract frame size
|
||||
LDR r3, =0xFFFFFFFD // Build initial LR value
|
||||
STR r3, [r2, #0] // Save on the stack
|
||||
|
||||
/* Actually build the stack frame. */
|
||||
|
||||
MOV r3, #0 // Build initial register value
|
||||
STR r3, [r2, #4] // Store initial r4
|
||||
STR r3, [r2, #8] // Store initial r5
|
||||
STR r3, [r2, #12] // Store initial r6
|
||||
STR r3, [r2, #16] // Store initial r7
|
||||
STR r3, [r2, #20] // Store initial r8
|
||||
STR r3, [r2, #24] // Store initial r9
|
||||
STR r3, [r2, #28] // Store initial r10
|
||||
STR r3, [r2, #32] // Store initial r11
|
||||
|
||||
/* Hardware stack follows. */
|
||||
|
||||
STR r3, [r2, #36] // Store initial r0
|
||||
STR r3, [r2, #40] // Store initial r1
|
||||
STR r3, [r2, #44] // Store initial r2
|
||||
STR r3, [r2, #48] // Store initial r3
|
||||
STR r3, [r2, #52] // Store initial r12
|
||||
MOV r3, #0xFFFFFFFF // Poison EXC_RETURN value
|
||||
STR r3, [r2, #56] // Store initial lr
|
||||
STR r1, [r2, #60] // Store initial pc
|
||||
MOV r3, #0x01000000 // Only T-bit need be set
|
||||
STR r3, [r2, #64] // Store initial xPSR
|
||||
|
||||
/* Setup stack pointer. */
|
||||
// thread_ptr -> tx_thread_stack_ptr = r2;
|
||||
|
||||
STR r2, [r0, #8] // Save stack pointer in thread's
|
||||
// control block
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
98
ports/cortex_m3/gnu/src/tx_thread_system_return.S
Normal file
98
ports/cortex_m3/gnu/src/tx_thread_system_return.S
Normal file
@@ -0,0 +1,98 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.text 32
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_system_return Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is target processor specific. It is used to transfer */
|
||||
/* control from a thread back to the ThreadX system. Only a */
|
||||
/* minimal context is saved since the compiler assumes temp registers */
|
||||
/* are going to get slicked by a function call anyway. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_thread_schedule Thread scheduling loop */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ThreadX components */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_system_return(VOID)
|
||||
// {
|
||||
.thumb_func
|
||||
.global _tx_thread_system_return
|
||||
_tx_thread_system_return:
|
||||
|
||||
/* Return to real scheduler via PendSV. Note that this routine is often
|
||||
replaced with in-line assembly in tx_port.h to improved performance. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
MRS r0, IPSR // Pickup IPSR
|
||||
CMP r0, #0 // Is it a thread returning?
|
||||
BNE _isr_context // If ISR, skip interrupt enable
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Thread context returning, pickup BASEPRI
|
||||
MOV r0, #0
|
||||
MSR BASEPRI, r0 // Enable interrupts
|
||||
MSR BASEPRI, r1 // Restore original interrupt posture
|
||||
#else
|
||||
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
|
||||
CPSIE i // Enable interrupts
|
||||
MSR PRIMASK, r1 // Restore original interrupt posture
|
||||
#endif
|
||||
_isr_context:
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
260
ports/cortex_m3/gnu/src/tx_timer_interrupt.S
Normal file
260
ports/cortex_m3/gnu/src/tx_timer_interrupt.S
Normal file
@@ -0,0 +1,260 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Timer */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
.global _tx_timer_time_slice
|
||||
.global _tx_timer_system_clock
|
||||
.global _tx_timer_current_ptr
|
||||
.global _tx_timer_list_start
|
||||
.global _tx_timer_list_end
|
||||
.global _tx_timer_expired_time_slice
|
||||
.global _tx_timer_expired
|
||||
.global _tx_thread_time_slice
|
||||
.global _tx_timer_expiration_process
|
||||
|
||||
.text
|
||||
.align 4
|
||||
.syntax unified
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_timer_interrupt Cortex-M3/GNU */
|
||||
/* 6.2.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function processes the hardware timer interrupt. This */
|
||||
/* processing includes incrementing the system clock and checking for */
|
||||
/* time slice and/or timer expiration. If either is found, the */
|
||||
/* expiration functions are called. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_timer_expiration_process Timer expiration processing */
|
||||
/* _tx_thread_time_slice Time slice interrupted thread */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* interrupt vector */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comment(s), added */
|
||||
/* TX_NO_TIMER support, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 03-08-2023 Scott Larson Include tx_user.h, */
|
||||
/* resulting in version 6.2.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_timer_interrupt(VOID)
|
||||
// {
|
||||
#ifndef TX_NO_TIMER
|
||||
.global _tx_timer_interrupt
|
||||
.thumb_func
|
||||
_tx_timer_interrupt:
|
||||
|
||||
/* Upon entry to this routine, it is assumed that the compiler scratch registers are available
|
||||
for use. */
|
||||
|
||||
/* Increment the system clock. */
|
||||
// _tx_timer_system_clock++;
|
||||
|
||||
LDR r1, =_tx_timer_system_clock // Pickup address of system clock
|
||||
LDR r0, [r1, #0] // Pickup system clock
|
||||
ADD r0, r0, #1 // Increment system clock
|
||||
STR r0, [r1, #0] // Store new system clock
|
||||
|
||||
/* Test for time-slice expiration. */
|
||||
// if (_tx_timer_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_time_slice // Pickup address of time-slice
|
||||
LDR r2, [r3, #0] // Pickup time-slice
|
||||
CBZ r2, __tx_timer_no_time_slice // Is it non-active?
|
||||
// Yes, skip time-slice processing
|
||||
|
||||
/* Decrement the time_slice. */
|
||||
// _tx_timer_time_slice--;
|
||||
|
||||
SUB r2, r2, #1 // Decrement the time-slice
|
||||
STR r2, [r3, #0] // Store new time-slice value
|
||||
|
||||
/* Check for expiration. */
|
||||
// if (__tx_timer_time_slice == 0)
|
||||
|
||||
CBNZ r2, __tx_timer_no_time_slice // Has it expired?
|
||||
// No, skip expiration processing
|
||||
|
||||
/* Set the time-slice expired flag. */
|
||||
// _tx_timer_expired_time_slice = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup address of expired flag
|
||||
MOV r0, #1 // Build expired value
|
||||
STR r0, [r3, #0] // Set time-slice expiration flag
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_no_time_slice:
|
||||
|
||||
/* Test for timer expiration. */
|
||||
// if (*_tx_timer_current_ptr)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_current_ptr // Pickup current timer pointer address
|
||||
LDR r0, [r1, #0] // Pickup current timer
|
||||
LDR r2, [r0, #0] // Pickup timer list entry
|
||||
CBZ r2, __tx_timer_no_timer // Is there anything in the list?
|
||||
// No, just increment the timer
|
||||
|
||||
/* Set expiration flag. */
|
||||
// _tx_timer_expired = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired // Pickup expiration flag address
|
||||
MOV r2, #1 // Build expired value
|
||||
STR r2, [r3, #0] // Set expired flag
|
||||
B __tx_timer_done // Finished timer processing
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
__tx_timer_no_timer:
|
||||
|
||||
/* No timer expired, increment the timer pointer. */
|
||||
// _tx_timer_current_ptr++;
|
||||
|
||||
ADD r0, r0, #4 // Move to next timer
|
||||
|
||||
/* Check for wrap-around. */
|
||||
// if (_tx_timer_current_ptr == _tx_timer_list_end)
|
||||
|
||||
LDR r3, =_tx_timer_list_end // Pickup addr of timer list end
|
||||
LDR r2, [r3, #0] // Pickup list end
|
||||
CMP r0, r2 // Are we at list end?
|
||||
BNE __tx_timer_skip_wrap // No, skip wrap-around logic
|
||||
|
||||
/* Wrap to beginning of list. */
|
||||
// _tx_timer_current_ptr = _tx_timer_list_start;
|
||||
|
||||
LDR r3, =_tx_timer_list_start // Pickup addr of timer list start
|
||||
LDR r0, [r3, #0] // Set current pointer to list start
|
||||
|
||||
__tx_timer_skip_wrap:
|
||||
|
||||
STR r0, [r1, #0] // Store new current timer pointer
|
||||
// }
|
||||
|
||||
__tx_timer_done:
|
||||
|
||||
/* See if anything has expired. */
|
||||
// if ((_tx_timer_expired_time_slice) || (_tx_timer_expired))
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of expired flag
|
||||
LDR r2, [r3, #0] // Pickup time-slice expired flag
|
||||
CBNZ r2, __tx_something_expired // Did a time-slice expire?
|
||||
// If non-zero, time-slice expired
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of other expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_nothing_expired // Did a timer expire?
|
||||
// No, nothing expired
|
||||
|
||||
__tx_something_expired:
|
||||
|
||||
STMDB sp!, {r0, lr} // Save the lr register on the stack
|
||||
// and save r0 just to keep 8-byte alignment
|
||||
|
||||
/* Did a timer expire? */
|
||||
// if (_tx_timer_expired)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_dont_activate // Check for timer expiration
|
||||
// If not set, skip timer activation
|
||||
|
||||
/* Process timer expiration. */
|
||||
// _tx_timer_expiration_process();
|
||||
|
||||
BL _tx_timer_expiration_process // Call the timer expiration handling routine
|
||||
|
||||
// }
|
||||
__tx_timer_dont_activate:
|
||||
|
||||
/* Did time slice expire? */
|
||||
// if (_tx_timer_expired_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of time-slice expired
|
||||
LDR r2, [r3, #0] // Pickup the actual flag
|
||||
CBZ r2, __tx_timer_not_ts_expiration // See if the flag is set
|
||||
// No, skip time-slice processing
|
||||
|
||||
/* Time slice interrupted thread. */
|
||||
// _tx_thread_time_slice();
|
||||
|
||||
BL _tx_thread_time_slice // Call time-slice processing
|
||||
LDR r0, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
LDR r1, [r0] // Is the preempt disable flag set?
|
||||
CBNZ r1, __tx_timer_skip_time_slice // Yes, skip the PendSV logic
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r1, [r0] // Pickup the current thread pointer
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
LDR r3, [r2] // Pickup the execute thread pointer
|
||||
LDR r0, =0xE000ED04 // Build address of control register
|
||||
LDR r2, =0x10000000 // Build value for PendSV bit
|
||||
CMP r1, r3 // Are they the same?
|
||||
BEQ __tx_timer_skip_time_slice // If the same, there was no time-slice performed
|
||||
STR r2, [r0] // Not the same, issue the PendSV for preemption
|
||||
__tx_timer_skip_time_slice:
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_not_ts_expiration:
|
||||
|
||||
LDMIA sp!, {r0, lr} // Recover lr register (r0 is just there for
|
||||
// the 8-byte stack alignment
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_nothing_expired:
|
||||
|
||||
DSB // Complete all memory access
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
#endif
|
||||
728
ports/cortex_m3/iar/inc/tx_port.h
Normal file
728
ports/cortex_m3/iar/inc/tx_port.h
Normal file
@@ -0,0 +1,728 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Port Specific */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M3/IAR */
|
||||
/* 6.1.12 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file contains data type definitions that make the ThreadX */
|
||||
/* real-time kernel function identically on a variety of different */
|
||||
/* processor architectures. For example, the size or number of bits */
|
||||
/* in an "int" data type vary between microprocessor architectures and */
|
||||
/* even C compilers for the same microprocessor. ThreadX does not */
|
||||
/* directly use native C data types. Instead, ThreadX creates its */
|
||||
/* own special types that can be mapped to actual data types by this */
|
||||
/* file to guarantee consistency in the interface and functionality. */
|
||||
/* */
|
||||
/* This file replaces the previous Cortex-M3/M4/M7 files. It unifies */
|
||||
/* the ARMv7-M architecture and compilers into one common file. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comments, updated */
|
||||
/* typedef to fix misra */
|
||||
/* violation, */
|
||||
/* fixed predefined macro, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 07-29-2022 Scott Larson Modified comments and */
|
||||
/* described BASEPRI usage, */
|
||||
/* resulting in version 6.1.12 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_PORT_H
|
||||
#define TX_PORT_H
|
||||
|
||||
|
||||
/* Determine if the optional ThreadX user define file should be used. */
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler library include files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#include <intrinsics.h> /* IAR Intrinsics */
|
||||
#define __asm__ __asm /* Define to make all inline asm look similar */
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
#endif /* __ICCARM__ */
|
||||
|
||||
#ifdef __ghs__
|
||||
#include <arm_ghs.h>
|
||||
#include "tx_ghs.h"
|
||||
#endif /* __ghs__ */
|
||||
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__CC_ARM)
|
||||
#define __get_control_value __get_CONTROL
|
||||
#define __set_control_value __set_CONTROL
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __get_ipsr_value __get_IPSR
|
||||
#endif
|
||||
|
||||
/* Define ThreadX basic types for this port. */
|
||||
|
||||
#define VOID void
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long long ULONG64;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
#define ULONG64_DEFINED
|
||||
|
||||
/* Define the priority levels for ThreadX. Legal values range
|
||||
from 32 to 1024 and MUST be evenly divisible by 32. */
|
||||
|
||||
#ifndef TX_MAX_PRIORITIES
|
||||
#define TX_MAX_PRIORITIES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
|
||||
thread creation is less than this value, the thread create call will return an error. */
|
||||
|
||||
#ifndef TX_MINIMUM_STACK
|
||||
#define TX_MINIMUM_STACK 200 /* Minimum stack size for this port */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the system timer thread's default stack size and priority. These are only applicable
|
||||
if TX_TIMER_PROCESS_IN_ISR is not defined. */
|
||||
|
||||
#ifndef TX_TIMER_THREAD_STACK_SIZE
|
||||
#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */
|
||||
#endif
|
||||
|
||||
#ifndef TX_TIMER_THREAD_PRIORITY
|
||||
#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
|
||||
#endif
|
||||
|
||||
/* By default, ThreadX for Cortex-M uses the PRIMASK register to enable/disable interrupts.
|
||||
If using BASEPRI is desired, define the following two symbols for both c and assembly files:
|
||||
TX_PORT_USE_BASEPRI - This tells ThreadX to use BASEPRI instead of PRIMASK.
|
||||
TX_PORT_BASEPRI = (priority_mask << (8 - number_priority_bits)) - this defines the maximum priority level to mask.
|
||||
Any interrupt with a higher priority than priority_mask will not be masked, thus the interrupt will run.
|
||||
*/
|
||||
|
||||
/* Define various constants for the ThreadX Cortex-M port. */
|
||||
|
||||
#define TX_INT_DISABLE 1 /* Disable interrupts */
|
||||
#define TX_INT_ENABLE 0 /* Enable interrupts */
|
||||
|
||||
|
||||
/* Define the clock source for trace event entry time stamp. The following two item are port specific.
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#else
|
||||
ULONG _tx_misra_time_stamp_get(VOID);
|
||||
#define TX_TRACE_TIME_SOURCE _tx_misra_time_stamp_get()
|
||||
#endif
|
||||
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
#endif
|
||||
|
||||
#ifdef __ghs__
|
||||
/* Define constants for Green Hills EventAnalyzer. */
|
||||
|
||||
/* Define the number of ticks per second. This informs the EventAnalyzer what the timestamps
|
||||
represent. By default, this is set to 1,000,000 i.e., one tick every microsecond. */
|
||||
|
||||
#define TX_EL_TICKS_PER_SECOND 1000000
|
||||
|
||||
/* Define the method of how to get the upper and lower 32-bits of the time stamp. By default, simply
|
||||
simulate the time-stamp source with a counter. */
|
||||
|
||||
#define read_tbu() _tx_el_time_base_upper
|
||||
#define read_tbl() ++_tx_el_time_base_lower
|
||||
#endif /* __ghs__ */
|
||||
|
||||
/* Define the port specific options for the _tx_build_options variable. This variable indicates
|
||||
how the ThreadX library was built. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_BUILD_OPTIONS (0)
|
||||
|
||||
|
||||
/* Define the in-line initialization constant so that modules with in-line
|
||||
initialization capabilities can prevent their initialization from being
|
||||
a function call. */
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
#define TX_DISABLE_INLINE
|
||||
#else
|
||||
#define TX_INLINE_INITIALIZATION
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
|
||||
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
|
||||
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
|
||||
define is negated, thereby forcing the stack fill which is necessary for the stack checking
|
||||
logic. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifdef TX_ENABLE_STACK_CHECKING
|
||||
#undef TX_DISABLE_STACK_FILLING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the TX_THREAD control block extensions for this port. The main reason
|
||||
for the multiple macros is so that backward compatibility can be maintained with
|
||||
existing ThreadX kernel awareness modules. */
|
||||
|
||||
#define TX_THREAD_EXTENSION_0
|
||||
#define TX_THREAD_EXTENSION_1
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#elif defined(__ghs__)
|
||||
#define TX_THREAD_EXTENSION_2 VOID * tx_thread_eh_globals; \
|
||||
int Errno; /* errno. */ \
|
||||
char * strtok_saved_pos; /* strtok() position. */
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
|
||||
#define TX_THREAD_EXTENSION_3
|
||||
|
||||
|
||||
|
||||
/* Define the port extensions of the remaining ThreadX objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_EXTENSION
|
||||
#define TX_BYTE_POOL_EXTENSION
|
||||
#define TX_EVENT_FLAGS_GROUP_EXTENSION
|
||||
#define TX_MUTEX_EXTENSION
|
||||
#define TX_QUEUE_EXTENSION
|
||||
#define TX_SEMAPHORE_EXTENSION
|
||||
#define TX_TIMER_EXTENSION
|
||||
|
||||
|
||||
/* Define the user extension field of the thread control block. Nothing
|
||||
additional is needed for this port so it is defined as white space. */
|
||||
|
||||
#ifndef TX_THREAD_USER_EXTENSION
|
||||
#define TX_THREAD_USER_EXTENSION
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
|
||||
tx_thread_shell_entry, and tx_thread_terminate. */
|
||||
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#if (__VER__ < 8000000)
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) __iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL;
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION __iar_dlib_perthread_access(0);
|
||||
#else
|
||||
void *_tx_iar_create_per_thread_tls_area(void);
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
void __iar_Initlocks(void);
|
||||
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = _tx_iar_create_per_thread_tls_area();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) do {_tx_iar_destroy_per_thread_tls_area(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL; } while(0);
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION do {__iar_Initlocks();} while(0);
|
||||
#endif
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__)
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
|
||||
ULONG _tx_misra_control_get(void);
|
||||
void _tx_misra_control_set(ULONG value);
|
||||
ULONG _tx_misra_fpccr_get(void);
|
||||
void _tx_misra_vfp_touch(void);
|
||||
|
||||
#else /* TX_MISRA_ENABLE not defined */
|
||||
|
||||
/* Define some helper functions (these are intrinsics in some compilers). */
|
||||
#ifdef __GNUC__ /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm__ volatile (" MRS %0,CONTROL ": "=r" (control_value) );
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile (" MSR CONTROL,%0": : "r" (control_value): "memory" );
|
||||
}
|
||||
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
|
||||
#elif defined(__CC_ARM) /* ARM Compiler 5 */
|
||||
|
||||
__attribute__( ( always_inline ) ) ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm volatile ("MRS control_value,CONTROL");
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile ("MSR CONTROL,control_value");
|
||||
}
|
||||
/* Can't access VFP registers with inline asm, so define this in tx_thread_schedule. */
|
||||
void _tx_vfp_access(void);
|
||||
#define TX_VFP_TOUCH() _tx_vfp_access();
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
#endif /* Helper functions for different compilers */
|
||||
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
|
||||
|
||||
/* A completed thread falls into _thread_shell_entry and we can simply deactivate the FPU via CONTROL.FPCA
|
||||
in order to ensure no lazy stacking will occur. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* A thread can be terminated by another thread, so we first check if it's self-terminating and not in an ISR.
|
||||
If so, deactivate the FPU via CONTROL.FPCA. Otherwise we are in an interrupt or another thread is terminating
|
||||
this one, so if the FPCCR.LSPACT bit is set, we need to save the CONTROL.FPCA state, touch the FPU to flush
|
||||
the lazy FPU save, then restore the CONTROL.FPCA state. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
TX_VFP_TOUCH(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = _tx_misra_fpccr_get(); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
_tx_misra_vfp_touch(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* No VFP in use */
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
|
||||
|
||||
#endif /* defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__) */
|
||||
|
||||
|
||||
/* Define the ThreadX object creation extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_CREATE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object deletion extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_DELETE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the get system state macro. */
|
||||
|
||||
#ifndef TX_THREAD_GET_SYSTEM_STATE
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#ifdef __CC_ARM /* ARM Compiler 5 */
|
||||
|
||||
register unsigned int _ipsr __asm("ipsr");
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _ipsr)
|
||||
|
||||
#elif defined(__GNUC__) /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_ipsr_value(void)
|
||||
{
|
||||
unsigned int ipsr_value;
|
||||
__asm__ volatile (" MRS %0,IPSR ": "=r" (ipsr_value) );
|
||||
return(ipsr_value);
|
||||
}
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_ipsr_value())
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_IPSR())
|
||||
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE for different compilers */
|
||||
|
||||
#else /* TX_MISRA_ENABLE is defined, use MISRA function. */
|
||||
ULONG _tx_misra_ipsr_get(VOID);
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _tx_misra_ipsr_get())
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE */
|
||||
|
||||
|
||||
/* Define the check for whether or not to call the _tx_thread_system_return function. A non-zero value
|
||||
indicates that _tx_thread_system_return should not be called. This overrides the definition in tx_thread.h
|
||||
for Cortex-M since so we don't waste time checking the _tx_thread_system_state variable that is always
|
||||
zero after initialization for Cortex-M ports. */
|
||||
|
||||
#ifndef TX_THREAD_SYSTEM_RETURN_CHECK
|
||||
#define TX_THREAD_SYSTEM_RETURN_CHECK(c) (c) = ((ULONG) _tx_thread_preempt_disable);
|
||||
#endif
|
||||
|
||||
/* Define the macro to ensure _tx_thread_preempt_disable is set early in initialization in order to
|
||||
prevent early scheduling on Cortex-M parts. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_POST_INITIALIZATION _tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef TX_DISABLE_INLINE
|
||||
|
||||
/* Define the TX_LOWEST_SET_BIT_CALCULATE macro for each compiler. */
|
||||
#ifdef __ICCARM__ /* IAR Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __CLZ(__RBIT((m)));
|
||||
#elif defined(__CC_ARM) /* AC5 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __clz(__rbit((m)));
|
||||
#elif defined(__GNUC__) /* GCC and AC6 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) __asm__ volatile (" RBIT %0,%1 ": "=r" (m) : "r" (m) ); \
|
||||
__asm__ volatile (" CLZ %0,%1 ": "=r" (b) : "r" (m) );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Define the interrupt disable/restore macros for each compiler. */
|
||||
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
|
||||
/*** GCC/AC6 and IAR ***/
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS %0, BASEPRI ": "=r" (posture));
|
||||
#else
|
||||
__asm__ volatile ("MRS %0, PRIMASK ": "=r" (posture));
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__attribute__( ( always_inline ) ) static inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value));
|
||||
}
|
||||
#else
|
||||
__attribute__( ( always_inline ) ) static inline void __enable_interrupts(void)
|
||||
{
|
||||
__asm__ volatile ("CPSIE i": : : "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
//__asm__ volatile ("MSR BASEPRI,%0": : "r" (int_posture): "memory");
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK,%0": : "r" (int_posture): "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i" : : : "memory");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(0);
|
||||
#else
|
||||
__enable_interrupts();
|
||||
#endif
|
||||
__restore_interrupt(interrupt_save);
|
||||
}
|
||||
}
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End GCC/AC6 and IAR ***/
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
|
||||
/*** AC5 ***/
|
||||
|
||||
static __inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS #posture, BASEPRI");
|
||||
#else
|
||||
__asm__ volatile ("MRS #posture, PRIMASK");
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
static __inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI, #basepri_value");
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
static __inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK, #int_posture");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (_ipsr == 0)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
__set_basepri_value(0);
|
||||
__set_basepri_value(interrupt_save);
|
||||
#else
|
||||
interrupt_save = __disable_irq();
|
||||
__enable_irq();
|
||||
if (interrupt_save != 0)
|
||||
__disable_irq();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End AC5 ***/
|
||||
|
||||
#endif /* Interrupt disable/restore macros for each compiler. */
|
||||
|
||||
/* Redefine _tx_thread_system_return for improved performance. */
|
||||
|
||||
#define _tx_thread_system_return _tx_thread_system_return_inline
|
||||
|
||||
|
||||
#else /* TX_DISABLE_INLINE is defined */
|
||||
|
||||
UINT _tx_thread_interrupt_disable(VOID);
|
||||
VOID _tx_thread_interrupt_restore(UINT previous_posture);
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register UINT interrupt_save;
|
||||
|
||||
#define TX_DISABLE interrupt_save = _tx_thread_interrupt_disable();
|
||||
#define TX_RESTORE _tx_thread_interrupt_restore(interrupt_save);
|
||||
#endif /* TX_DISABLE_INLINE */
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
void tx_thread_fpu_disable(void);
|
||||
|
||||
|
||||
/* Define the version ID of ThreadX. This may be utilized by the application. */
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) 2024 Microsoft Corporation. * ThreadX Cortex-M3/IAR Version 6.4.2 *";
|
||||
#else
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
extern CHAR _tx_version_id[100];
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
803
ports/cortex_m3/iar/src/tx_iar.c
Normal file
803
ports/cortex_m3/iar/src/tx_iar.c
Normal file
@@ -0,0 +1,803 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** IAR Multithreaded Library Support */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#define TX_SOURCE_CODE
|
||||
|
||||
|
||||
/* Define IAR library for tools prior to version 8. */
|
||||
|
||||
#if (__VER__ < 8000000)
|
||||
|
||||
|
||||
/* IAR version 7 and below. */
|
||||
|
||||
/* Include necessary system files. */
|
||||
|
||||
#include "tx_api.h"
|
||||
#include "tx_initialize.h"
|
||||
#include "tx_thread.h"
|
||||
#include "tx_mutex.h"
|
||||
|
||||
|
||||
/* This implementation requires that the following macros are defined in the
|
||||
tx_port.h file and <yvals.h> is included with the following code segments:
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) __iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL;
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION __iar_dlib_perthread_access(0);
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
This should be done automatically if TX_ENABLE_IAR_LIBRARY_SUPPORT is defined while building the ThreadX library and the
|
||||
application.
|
||||
|
||||
Finally, the project options General Options -> Library Configuration should have the "Enable thread support in library" box selected.
|
||||
*/
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
|
||||
#include <yvals.h>
|
||||
|
||||
|
||||
#if _MULTI_THREAD
|
||||
|
||||
TX_MUTEX __tx_iar_system_lock_mutexes[_MAX_LOCK];
|
||||
UINT __tx_iar_system_lock_next_free_mutex = 0;
|
||||
|
||||
|
||||
/* Define error counters, just for debug purposes. */
|
||||
|
||||
UINT __tx_iar_system_lock_no_mutexes;
|
||||
UINT __tx_iar_system_lock_internal_errors;
|
||||
UINT __tx_iar_system_lock_isr_caller;
|
||||
|
||||
|
||||
/* Define the TLS access function for the IAR library. */
|
||||
|
||||
void _DLIB_TLS_MEMORY *__iar_dlib_perthread_access(void _DLIB_TLS_MEMORY *symbp)
|
||||
{
|
||||
|
||||
char _DLIB_TLS_MEMORY *p = 0;
|
||||
|
||||
/* Is there a current thread? */
|
||||
if (_tx_thread_current_ptr)
|
||||
p = (char _DLIB_TLS_MEMORY *) _tx_thread_current_ptr -> tx_thread_iar_tls_pointer;
|
||||
else
|
||||
p = (void _DLIB_TLS_MEMORY *) __segment_begin("__DLIB_PERTHREAD");
|
||||
p += __IAR_DLIB_PERTHREAD_SYMBOL_OFFSET(symbp);
|
||||
return (void _DLIB_TLS_MEMORY *) p;
|
||||
}
|
||||
|
||||
|
||||
/* Define mutexes for IAR library. */
|
||||
|
||||
void __iar_system_Mtxinit(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT i;
|
||||
UINT status;
|
||||
TX_MUTEX *mutex_ptr;
|
||||
|
||||
|
||||
/* First, find a free mutex in the list. */
|
||||
for (i = 0; i < _MAX_LOCK; i++)
|
||||
{
|
||||
|
||||
/* Setup a pointer to the start of the next free mutex. */
|
||||
mutex_ptr = &__tx_iar_system_lock_mutexes[__tx_iar_system_lock_next_free_mutex++];
|
||||
|
||||
/* Check for wrap-around on the next free mutex. */
|
||||
if (__tx_iar_system_lock_next_free_mutex >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Yes, set the free index back to 0. */
|
||||
__tx_iar_system_lock_next_free_mutex = 0;
|
||||
}
|
||||
|
||||
/* Is this mutex free? */
|
||||
if (mutex_ptr -> tx_mutex_id != TX_MUTEX_ID)
|
||||
{
|
||||
|
||||
/* Yes, this mutex is free, get out of the loop! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if a free mutex was found. */
|
||||
if (i >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Error! No more free mutexes! */
|
||||
|
||||
/* Increment the no mutexes error counter. */
|
||||
__tx_iar_system_lock_no_mutexes++;
|
||||
|
||||
/* Set return pointer to NULL. */
|
||||
*m = TX_NULL;
|
||||
|
||||
/* Return. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now create the ThreadX mutex for the IAR library. */
|
||||
status = _tx_mutex_create(mutex_ptr, "IAR System Library Lock", TX_NO_INHERIT);
|
||||
|
||||
/* Determine if the creation was successful. */
|
||||
if (status == TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Yes, successful creation, return mutex pointer. */
|
||||
*m = (VOID *) mutex_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the internal error counter. */
|
||||
__tx_iar_system_lock_internal_errors++;
|
||||
|
||||
/* Return a NULL pointer to indicate an error. */
|
||||
*m = TX_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_system_Mtxdst(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
/* Simply delete the mutex. */
|
||||
_tx_mutex_delete((TX_MUTEX *) *m);
|
||||
}
|
||||
|
||||
void __iar_system_Mtxlock(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Determine the caller's context. Mutex locks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Get the mutex. */
|
||||
status = _tx_mutex_get((TX_MUTEX *) *m, TX_WAIT_FOREVER);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_system_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_system_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_system_Mtxunlock(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Determine the caller's context. Mutex unlocks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Release the mutex. */
|
||||
status = _tx_mutex_put((TX_MUTEX *) *m);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_system_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_system_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if _DLIB_FILE_DESCRIPTOR
|
||||
|
||||
TX_MUTEX __tx_iar_file_lock_mutexes[_MAX_FLOCK];
|
||||
UINT __tx_iar_file_lock_next_free_mutex = 0;
|
||||
|
||||
|
||||
/* Define error counters, just for debug purposes. */
|
||||
|
||||
UINT __tx_iar_file_lock_no_mutexes;
|
||||
UINT __tx_iar_file_lock_internal_errors;
|
||||
UINT __tx_iar_file_lock_isr_caller;
|
||||
|
||||
|
||||
void __iar_file_Mtxinit(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT i;
|
||||
UINT status;
|
||||
TX_MUTEX *mutex_ptr;
|
||||
|
||||
|
||||
/* First, find a free mutex in the list. */
|
||||
for (i = 0; i < _MAX_FLOCK; i++)
|
||||
{
|
||||
|
||||
/* Setup a pointer to the start of the next free mutex. */
|
||||
mutex_ptr = &__tx_iar_file_lock_mutexes[__tx_iar_file_lock_next_free_mutex++];
|
||||
|
||||
/* Check for wrap-around on the next free mutex. */
|
||||
if (__tx_iar_file_lock_next_free_mutex >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Yes, set the free index back to 0. */
|
||||
__tx_iar_file_lock_next_free_mutex = 0;
|
||||
}
|
||||
|
||||
/* Is this mutex free? */
|
||||
if (mutex_ptr -> tx_mutex_id != TX_MUTEX_ID)
|
||||
{
|
||||
|
||||
/* Yes, this mutex is free, get out of the loop! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if a free mutex was found. */
|
||||
if (i >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Error! No more free mutexes! */
|
||||
|
||||
/* Increment the no mutexes error counter. */
|
||||
__tx_iar_file_lock_no_mutexes++;
|
||||
|
||||
/* Set return pointer to NULL. */
|
||||
*m = TX_NULL;
|
||||
|
||||
/* Return. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now create the ThreadX mutex for the IAR library. */
|
||||
status = _tx_mutex_create(mutex_ptr, "IAR File Library Lock", TX_NO_INHERIT);
|
||||
|
||||
/* Determine if the creation was successful. */
|
||||
if (status == TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Yes, successful creation, return mutex pointer. */
|
||||
*m = (VOID *) mutex_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the internal error counter. */
|
||||
__tx_iar_file_lock_internal_errors++;
|
||||
|
||||
/* Return a NULL pointer to indicate an error. */
|
||||
*m = TX_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_file_Mtxdst(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
/* Simply delete the mutex. */
|
||||
_tx_mutex_delete((TX_MUTEX *) *m);
|
||||
}
|
||||
|
||||
void __iar_file_Mtxlock(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Determine the caller's context. Mutex locks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Get the mutex. */
|
||||
status = _tx_mutex_get((TX_MUTEX *) *m, TX_WAIT_FOREVER);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_file_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_file_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_file_Mtxunlock(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Determine the caller's context. Mutex unlocks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Release the mutex. */
|
||||
status = _tx_mutex_put((TX_MUTEX *) *m);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_file_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_file_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
#endif /* _DLIB_FILE_DESCRIPTOR */
|
||||
|
||||
#endif /* _MULTI_THREAD */
|
||||
|
||||
#endif /* TX_ENABLE_IAR_LIBRARY_SUPPORT */
|
||||
|
||||
#else /* IAR version 8 and above. */
|
||||
|
||||
|
||||
/* Include necessary system files. */
|
||||
|
||||
#include "tx_api.h"
|
||||
#include "tx_initialize.h"
|
||||
#include "tx_thread.h"
|
||||
#include "tx_mutex.h"
|
||||
|
||||
/* This implementation requires that the following macros are defined in the
|
||||
tx_port.h file and <yvals.h> is included with the following code segments:
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
void *_tx_iar_create_per_thread_tls_area(void);
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
void __iar_Initlocks(void);
|
||||
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) do {__iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL; } while(0);
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION do {__iar_Initlocks();} while(0);
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
This should be done automatically if TX_ENABLE_IAR_LIBRARY_SUPPORT is defined while building the ThreadX library and the
|
||||
application.
|
||||
|
||||
Finally, the project options General Options -> Library Configuration should have the "Enable thread support in library" box selected.
|
||||
*/
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
|
||||
#include <DLib_threads.h>
|
||||
|
||||
|
||||
void * __aeabi_read_tp();
|
||||
|
||||
void* _tx_iar_create_per_thread_tls_area();
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
|
||||
#pragma section="__iar_tls$$DATA"
|
||||
|
||||
/* Define the TLS access function for the IAR library. */
|
||||
void * __aeabi_read_tp(void)
|
||||
{
|
||||
void *p = 0;
|
||||
TX_THREAD *thread_ptr = _tx_thread_current_ptr;
|
||||
if (thread_ptr)
|
||||
{
|
||||
p = thread_ptr->tx_thread_iar_tls_pointer;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = __section_begin("__iar_tls$$DATA");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Define the TLS creation and destruction to use malloc/free. */
|
||||
|
||||
void* _tx_iar_create_per_thread_tls_area()
|
||||
{
|
||||
UINT tls_size = __iar_tls_size();
|
||||
|
||||
/* Get memory for TLS. */
|
||||
void *p = malloc(tls_size);
|
||||
|
||||
/* Initialize TLS-area and run constructors for objects in TLS */
|
||||
__iar_tls_init(p);
|
||||
return p;
|
||||
}
|
||||
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr)
|
||||
{
|
||||
/* Destroy objects living in TLS */
|
||||
__call_thread_dtors();
|
||||
free(tls_ptr);
|
||||
}
|
||||
|
||||
#ifndef _MAX_LOCK
|
||||
#define _MAX_LOCK 4
|
||||
#endif
|
||||
|
||||
static TX_MUTEX __tx_iar_system_lock_mutexes[_MAX_LOCK];
|
||||
static UINT __tx_iar_system_lock_next_free_mutex = 0;
|
||||
|
||||
|
||||
/* Define error counters, just for debug purposes. */
|
||||
|
||||
UINT __tx_iar_system_lock_no_mutexes;
|
||||
UINT __tx_iar_system_lock_internal_errors;
|
||||
UINT __tx_iar_system_lock_isr_caller;
|
||||
|
||||
|
||||
/* Define mutexes for IAR library. */
|
||||
|
||||
void __iar_system_Mtxinit(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT i;
|
||||
UINT status;
|
||||
TX_MUTEX *mutex_ptr;
|
||||
|
||||
|
||||
/* First, find a free mutex in the list. */
|
||||
for (i = 0; i < _MAX_LOCK; i++)
|
||||
{
|
||||
|
||||
/* Setup a pointer to the start of the next free mutex. */
|
||||
mutex_ptr = &__tx_iar_system_lock_mutexes[__tx_iar_system_lock_next_free_mutex++];
|
||||
|
||||
/* Check for wrap-around on the next free mutex. */
|
||||
if (__tx_iar_system_lock_next_free_mutex >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Yes, set the free index back to 0. */
|
||||
__tx_iar_system_lock_next_free_mutex = 0;
|
||||
}
|
||||
|
||||
/* Is this mutex free? */
|
||||
if (mutex_ptr -> tx_mutex_id != TX_MUTEX_ID)
|
||||
{
|
||||
|
||||
/* Yes, this mutex is free, get out of the loop! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if a free mutex was found. */
|
||||
if (i >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Error! No more free mutexes! */
|
||||
|
||||
/* Increment the no mutexes error counter. */
|
||||
__tx_iar_system_lock_no_mutexes++;
|
||||
|
||||
/* Set return pointer to NULL. */
|
||||
*m = TX_NULL;
|
||||
|
||||
/* Return. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now create the ThreadX mutex for the IAR library. */
|
||||
status = _tx_mutex_create(mutex_ptr, "IAR System Library Lock", TX_NO_INHERIT);
|
||||
|
||||
/* Determine if the creation was successful. */
|
||||
if (status == TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Yes, successful creation, return mutex pointer. */
|
||||
*m = (VOID *) mutex_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the internal error counter. */
|
||||
__tx_iar_system_lock_internal_errors++;
|
||||
|
||||
/* Return a NULL pointer to indicate an error. */
|
||||
*m = TX_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_system_Mtxdst(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
/* Simply delete the mutex. */
|
||||
_tx_mutex_delete((TX_MUTEX *) *m);
|
||||
}
|
||||
|
||||
void __iar_system_Mtxlock(__iar_Rmtx *m)
|
||||
{
|
||||
if (*m)
|
||||
{
|
||||
UINT status;
|
||||
|
||||
/* Determine the caller's context. Mutex locks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Get the mutex. */
|
||||
status = _tx_mutex_get((TX_MUTEX *) *m, TX_WAIT_FOREVER);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_system_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_system_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_system_Mtxunlock(__iar_Rmtx *m)
|
||||
{
|
||||
if (*m)
|
||||
{
|
||||
UINT status;
|
||||
|
||||
/* Determine the caller's context. Mutex unlocks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Release the mutex. */
|
||||
status = _tx_mutex_put((TX_MUTEX *) *m);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_system_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_system_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if _DLIB_FILE_DESCRIPTOR
|
||||
|
||||
#include <stdio.h> /* Added to get access to FOPEN_MAX */
|
||||
#ifndef _MAX_FLOCK
|
||||
#define _MAX_FLOCK FOPEN_MAX /* Define _MAX_FLOCK as the maximum number of open files */
|
||||
#endif
|
||||
|
||||
|
||||
TX_MUTEX __tx_iar_file_lock_mutexes[_MAX_FLOCK];
|
||||
UINT __tx_iar_file_lock_next_free_mutex = 0;
|
||||
|
||||
|
||||
/* Define error counters, just for debug purposes. */
|
||||
|
||||
UINT __tx_iar_file_lock_no_mutexes;
|
||||
UINT __tx_iar_file_lock_internal_errors;
|
||||
UINT __tx_iar_file_lock_isr_caller;
|
||||
|
||||
|
||||
void __iar_file_Mtxinit(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT i;
|
||||
UINT status;
|
||||
TX_MUTEX *mutex_ptr;
|
||||
|
||||
|
||||
/* First, find a free mutex in the list. */
|
||||
for (i = 0; i < _MAX_FLOCK; i++)
|
||||
{
|
||||
|
||||
/* Setup a pointer to the start of the next free mutex. */
|
||||
mutex_ptr = &__tx_iar_file_lock_mutexes[__tx_iar_file_lock_next_free_mutex++];
|
||||
|
||||
/* Check for wrap-around on the next free mutex. */
|
||||
if (__tx_iar_file_lock_next_free_mutex >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Yes, set the free index back to 0. */
|
||||
__tx_iar_file_lock_next_free_mutex = 0;
|
||||
}
|
||||
|
||||
/* Is this mutex free? */
|
||||
if (mutex_ptr -> tx_mutex_id != TX_MUTEX_ID)
|
||||
{
|
||||
|
||||
/* Yes, this mutex is free, get out of the loop! */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if a free mutex was found. */
|
||||
if (i >= _MAX_LOCK)
|
||||
{
|
||||
|
||||
/* Error! No more free mutexes! */
|
||||
|
||||
/* Increment the no mutexes error counter. */
|
||||
__tx_iar_file_lock_no_mutexes++;
|
||||
|
||||
/* Set return pointer to NULL. */
|
||||
*m = TX_NULL;
|
||||
|
||||
/* Return. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Now create the ThreadX mutex for the IAR library. */
|
||||
status = _tx_mutex_create(mutex_ptr, "IAR File Library Lock", TX_NO_INHERIT);
|
||||
|
||||
/* Determine if the creation was successful. */
|
||||
if (status == TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Yes, successful creation, return mutex pointer. */
|
||||
*m = (VOID *) mutex_ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the internal error counter. */
|
||||
__tx_iar_file_lock_internal_errors++;
|
||||
|
||||
/* Return a NULL pointer to indicate an error. */
|
||||
*m = TX_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_file_Mtxdst(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
/* Simply delete the mutex. */
|
||||
_tx_mutex_delete((TX_MUTEX *) *m);
|
||||
}
|
||||
|
||||
void __iar_file_Mtxlock(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Determine the caller's context. Mutex locks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Get the mutex. */
|
||||
status = _tx_mutex_get((TX_MUTEX *) *m, TX_WAIT_FOREVER);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_file_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_file_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
|
||||
void __iar_file_Mtxunlock(__iar_Rmtx *m)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Determine the caller's context. Mutex unlocks are only available from initialization and
|
||||
threads. */
|
||||
if ((_tx_thread_system_state == 0) || (_tx_thread_system_state >= TX_INITIALIZE_IN_PROGRESS))
|
||||
{
|
||||
|
||||
/* Release the mutex. */
|
||||
status = _tx_mutex_put((TX_MUTEX *) *m);
|
||||
|
||||
/* Check the status of the mutex release. */
|
||||
if (status)
|
||||
{
|
||||
|
||||
/* Internal error, increment the counter. */
|
||||
__tx_iar_file_lock_internal_errors++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Increment the ISR caller error. */
|
||||
__tx_iar_file_lock_isr_caller++;
|
||||
}
|
||||
}
|
||||
#endif /* _DLIB_FILE_DESCRIPTOR */
|
||||
|
||||
#endif /* TX_ENABLE_IAR_LIBRARY_SUPPORT */
|
||||
|
||||
#endif /* IAR version 8 and above. */
|
||||
766
ports/cortex_m3/iar/src/tx_misra.s
Normal file
766
ports/cortex_m3/iar/src/tx_misra.s
Normal file
@@ -0,0 +1,766 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** ThreadX MISRA Compliance */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
#define SHT_PROGBITS 0x1
|
||||
|
||||
EXTERN __aeabi_memset
|
||||
EXTERN _tx_thread_current_ptr
|
||||
EXTERN _tx_thread_interrupt_disable
|
||||
EXTERN _tx_thread_interrupt_restore
|
||||
EXTERN _tx_thread_stack_analyze
|
||||
EXTERN _tx_thread_stack_error_handler
|
||||
EXTERN _tx_thread_system_state
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
EXTERN _tx_trace_buffer_current_ptr
|
||||
EXTERN _tx_trace_buffer_end_ptr
|
||||
EXTERN _tx_trace_buffer_start_ptr
|
||||
EXTERN _tx_trace_event_enable_bits
|
||||
EXTERN _tx_trace_full_notify_function
|
||||
EXTERN _tx_trace_header_ptr
|
||||
#endif
|
||||
|
||||
PUBLIC _tx_misra_always_true
|
||||
PUBLIC _tx_misra_block_pool_to_uchar_pointer_convert
|
||||
PUBLIC _tx_misra_byte_pool_to_uchar_pointer_convert
|
||||
PUBLIC _tx_misra_char_to_uchar_pointer_convert
|
||||
PUBLIC _tx_misra_const_char_to_char_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
PUBLIC _tx_misra_entry_to_uchar_pointer_convert
|
||||
#endif
|
||||
PUBLIC _tx_misra_indirect_void_to_uchar_pointer_convert
|
||||
PUBLIC _tx_misra_memset
|
||||
PUBLIC _tx_misra_message_copy
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
PUBLIC _tx_misra_object_to_uchar_pointer_convert
|
||||
#endif
|
||||
PUBLIC _tx_misra_pointer_to_ulong_convert
|
||||
PUBLIC _tx_misra_status_get
|
||||
PUBLIC _tx_misra_thread_stack_check
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
PUBLIC _tx_misra_time_stamp_get
|
||||
#endif
|
||||
PUBLIC _tx_misra_timer_indirect_to_void_pointer_convert
|
||||
PUBLIC _tx_misra_timer_pointer_add
|
||||
PUBLIC _tx_misra_timer_pointer_dif
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
PUBLIC _tx_misra_trace_event_insert
|
||||
#endif
|
||||
PUBLIC _tx_misra_uchar_pointer_add
|
||||
PUBLIC _tx_misra_uchar_pointer_dif
|
||||
PUBLIC _tx_misra_uchar_pointer_sub
|
||||
PUBLIC _tx_misra_uchar_to_align_type_pointer_convert
|
||||
PUBLIC _tx_misra_uchar_to_block_pool_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
PUBLIC _tx_misra_uchar_to_entry_pointer_convert
|
||||
PUBLIC _tx_misra_uchar_to_header_pointer_convert
|
||||
#endif
|
||||
PUBLIC _tx_misra_uchar_to_indirect_byte_pool_pointer_convert
|
||||
PUBLIC _tx_misra_uchar_to_indirect_uchar_pointer_convert
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
PUBLIC _tx_misra_uchar_to_object_pointer_convert
|
||||
#endif
|
||||
PUBLIC _tx_misra_uchar_to_void_pointer_convert
|
||||
PUBLIC _tx_misra_ulong_pointer_add
|
||||
PUBLIC _tx_misra_ulong_pointer_dif
|
||||
PUBLIC _tx_misra_ulong_pointer_sub
|
||||
PUBLIC _tx_misra_ulong_to_pointer_convert
|
||||
PUBLIC _tx_misra_ulong_to_thread_pointer_convert
|
||||
PUBLIC _tx_misra_user_timer_pointer_get
|
||||
PUBLIC _tx_misra_void_to_block_pool_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_byte_pool_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_event_flags_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_indirect_uchar_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_mutex_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_queue_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_semaphore_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_thread_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_uchar_pointer_convert
|
||||
PUBLIC _tx_misra_void_to_ulong_pointer_convert
|
||||
PUBLIC _tx_misra_ipsr_get
|
||||
PUBLIC _tx_misra_control_get
|
||||
PUBLIC _tx_misra_control_set
|
||||
#ifdef __ARMVFP__
|
||||
PUBLIC _tx_misra_fpccr_get
|
||||
PUBLIC _tx_misra_vfp_touch
|
||||
#endif
|
||||
|
||||
PUBLIC _tx_misra_event_flags_group_not_used
|
||||
PUBLIC _tx_misra_event_flags_set_notify_not_used
|
||||
PUBLIC _tx_misra_queue_not_used
|
||||
PUBLIC _tx_misra_queue_send_notify_not_used
|
||||
PUBLIC _tx_misra_semaphore_not_used
|
||||
PUBLIC _tx_misra_semaphore_put_notify_not_used
|
||||
PUBLIC _tx_misra_thread_entry_exit_notify_not_used
|
||||
PUBLIC _tx_misra_thread_not_used
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
PUBLIC _tx_version_id
|
||||
|
||||
SECTION `.data`:DATA:REORDER:NOROOT(2)
|
||||
DATA
|
||||
// 51 CHAR _tx_version_id[100] = "Copyright (c) 2024 Microsoft Corporation. * ThreadX 6.1 MISRA C Compliant *";
|
||||
_tx_version_id:
|
||||
DC8 43H, 6FH, 70H, 79H, 72H, 69H, 67H, 68H
|
||||
DC8 74H, 20H, 28H, 63H, 29H, 20H, 31H, 39H
|
||||
DC8 39H, 36H, 2DH, 32H, 30H, 31H, 38H, 20H
|
||||
DC8 45H, 78H, 70H, 72H, 65H, 73H, 73H, 20H
|
||||
DC8 4CH, 6FH, 67H, 69H, 63H, 20H, 49H, 6EH
|
||||
DC8 63H, 2EH, 20H, 2AH, 20H, 54H, 68H, 72H
|
||||
DC8 65H, 61H, 64H, 58H, 20H, 36H, 2EH, 31H
|
||||
DC8 20H, 4DH, 49H, 53H, 52H, 41H, 20H, 43H
|
||||
DC8 20H, 43H, 6FH, 6DH, 70H, 6CH, 69H, 61H
|
||||
DC8 6EH, 74H, 20H, 2AH, 0
|
||||
DC8 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
#endif //TX_MISRA_ENABLE
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_memset(VOID *ptr, UINT value, UINT size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_memset:
|
||||
PUSH {R4,LR}
|
||||
MOVS R4,R0
|
||||
MOVS R0,R2
|
||||
MOVS R2,R1
|
||||
MOVS R1,R0
|
||||
MOVS R0,R4
|
||||
BL __aeabi_memset
|
||||
POP {R4,PC} // return
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UCHAR *_tx_misra_uchar_pointer_add(UCHAR *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_uchar_pointer_add:
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UCHAR *_tx_misra_uchar_pointer_sub(UCHAR *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_uchar_pointer_sub:
|
||||
RSBS R1,R1,#+0
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_uchar_pointer_dif(UCHAR *ptr1, UCHAR *ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_uchar_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/************************************************************************************************************************************/
|
||||
/************************************************************************************************************************************/
|
||||
/** */
|
||||
/** This single function serves all of the below prototypes. */
|
||||
/** */
|
||||
/** ULONG _tx_misra_pointer_to_ulong_convert(VOID *ptr); */
|
||||
/** VOID *_tx_misra_ulong_to_pointer_convert(ULONG input); */
|
||||
/** UCHAR **_tx_misra_indirect_void_to_uchar_pointer_convert(VOID **return_ptr); */
|
||||
/** UCHAR **_tx_misra_uchar_to_indirect_uchar_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR *_tx_misra_block_pool_to_uchar_pointer_convert(TX_BLOCK_POOL *pool); */
|
||||
/** TX_BLOCK_POOL *_tx_misra_void_to_block_pool_pointer_convert(VOID *pointer); */
|
||||
/** UCHAR *_tx_misra_void_to_uchar_pointer_convert(VOID *pointer); */
|
||||
/** TX_BLOCK_POOL *_tx_misra_uchar_to_block_pool_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR **_tx_misra_void_to_indirect_uchar_pointer_convert(VOID *pointer); */
|
||||
/** TX_BYTE_POOL *_tx_misra_void_to_byte_pool_pointer_convert(VOID *pointer); */
|
||||
/** UCHAR *_tx_misra_byte_pool_to_uchar_pointer_convert(TX_BYTE_POOL *pool); */
|
||||
/** ALIGN_TYPE *_tx_misra_uchar_to_align_type_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_BYTE_POOL **_tx_misra_uchar_to_indirect_byte_pool_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_EVENT_FLAGS_GROUP *_tx_misra_void_to_event_flags_pointer_convert(VOID *pointer); */
|
||||
/** ULONG *_tx_misra_void_to_ulong_pointer_convert(VOID *pointer); */
|
||||
/** TX_MUTEX *_tx_misra_void_to_mutex_pointer_convert(VOID *pointer); */
|
||||
/** TX_QUEUE *_tx_misra_void_to_queue_pointer_convert(VOID *pointer); */
|
||||
/** TX_SEMAPHORE *_tx_misra_void_to_semaphore_pointer_convert(VOID *pointer); */
|
||||
/** VOID *_tx_misra_uchar_to_void_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_THREAD *_tx_misra_ulong_to_thread_pointer_convert(ULONG value); */
|
||||
/** VOID *_tx_misra_timer_indirect_to_void_pointer_convert(TX_TIMER_INTERNAL **pointer); */
|
||||
/** CHAR *_tx_misra_const_char_to_char_pointer_convert(const char *pointer); */
|
||||
/** TX_THREAD *_tx_misra_void_to_thread_pointer_convert(void *pointer); */
|
||||
/** UCHAR *_tx_misra_object_to_uchar_pointer_convert(TX_TRACE_OBJECT_ENTRY *pointer); */
|
||||
/** TX_TRACE_OBJECT_ENTRY *_tx_misra_uchar_to_object_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_TRACE_HEADER *_tx_misra_uchar_to_header_pointer_convert(UCHAR *pointer); */
|
||||
/** TX_TRACE_BUFFER_ENTRY *_tx_misra_uchar_to_entry_pointer_convert(UCHAR *pointer); */
|
||||
/** UCHAR *_tx_misra_entry_to_uchar_pointer_convert(TX_TRACE_BUFFER_ENTRY *pointer); */
|
||||
/** UCHAR *_tx_misra_char_to_uchar_pointer_convert(CHAR *pointer); */
|
||||
/** VOID _tx_misra_event_flags_group_not_used(TX_EVENT_FLAGS_GROUP *group_ptr); */
|
||||
/** VOID _tx_misra_event_flags_set_notify_not_used(VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr)); */
|
||||
/** VOID _tx_misra_queue_not_used(TX_QUEUE *queue_ptr); */
|
||||
/** VOID _tx_misra_queue_send_notify_not_used(VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr)); */
|
||||
/** VOID _tx_misra_semaphore_not_used(TX_SEMAPHORE *semaphore_ptr); */
|
||||
/** VOID _tx_misra_semaphore_put_notify_not_used(VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr)); */
|
||||
/** VOID _tx_misra_thread_not_used(TX_THREAD *thread_ptr); */
|
||||
/** VOID _tx_misra_thread_entry_exit_notify_not_used(VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT id)); */
|
||||
/** */
|
||||
/************************************************************************************************************************************/
|
||||
/************************************************************************************************************************************/
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_pointer_to_ulong_convert:
|
||||
_tx_misra_ulong_to_pointer_convert:
|
||||
_tx_misra_indirect_void_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_indirect_uchar_pointer_convert:
|
||||
_tx_misra_block_pool_to_uchar_pointer_convert:
|
||||
_tx_misra_void_to_block_pool_pointer_convert:
|
||||
_tx_misra_void_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_block_pool_pointer_convert:
|
||||
_tx_misra_void_to_indirect_uchar_pointer_convert:
|
||||
_tx_misra_void_to_byte_pool_pointer_convert:
|
||||
_tx_misra_byte_pool_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_align_type_pointer_convert:
|
||||
_tx_misra_uchar_to_indirect_byte_pool_pointer_convert:
|
||||
_tx_misra_void_to_event_flags_pointer_convert:
|
||||
_tx_misra_void_to_ulong_pointer_convert:
|
||||
_tx_misra_void_to_mutex_pointer_convert:
|
||||
_tx_misra_void_to_queue_pointer_convert:
|
||||
_tx_misra_void_to_semaphore_pointer_convert:
|
||||
_tx_misra_uchar_to_void_pointer_convert:
|
||||
_tx_misra_ulong_to_thread_pointer_convert:
|
||||
_tx_misra_timer_indirect_to_void_pointer_convert:
|
||||
_tx_misra_const_char_to_char_pointer_convert:
|
||||
_tx_misra_void_to_thread_pointer_convert:
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
_tx_misra_object_to_uchar_pointer_convert:
|
||||
_tx_misra_uchar_to_object_pointer_convert:
|
||||
_tx_misra_uchar_to_header_pointer_convert:
|
||||
_tx_misra_uchar_to_entry_pointer_convert:
|
||||
_tx_misra_entry_to_uchar_pointer_convert:
|
||||
#endif
|
||||
_tx_misra_char_to_uchar_pointer_convert:
|
||||
_tx_misra_event_flags_group_not_used:
|
||||
_tx_misra_event_flags_set_notify_not_used:
|
||||
_tx_misra_queue_not_used:
|
||||
_tx_misra_queue_send_notify_not_used:
|
||||
_tx_misra_semaphore_not_used:
|
||||
_tx_misra_semaphore_put_notify_not_used:
|
||||
_tx_misra_thread_entry_exit_notify_not_used:
|
||||
_tx_misra_thread_not_used:
|
||||
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG *_tx_misra_ulong_pointer_add(ULONG *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_ulong_pointer_add:
|
||||
ADD R0,R0,R1, LSL #+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG *_tx_misra_ulong_pointer_sub(ULONG *ptr, ULONG amount); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_ulong_pointer_sub:
|
||||
MVNS R2,#+3
|
||||
MULS R1,R2,R1
|
||||
ADD R0,R0,R1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_ulong_pointer_dif(ULONG *ptr1, ULONG *ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_ulong_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
ASRS R0,R0,#+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_message_copy(ULONG **source, ULONG **destination, */
|
||||
/** UINT size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_message_copy:
|
||||
PUSH {R4,R5}
|
||||
LDR R3,[R0, #+0]
|
||||
LDR R4,[R1, #+0]
|
||||
LDR R5,[R3, #+0]
|
||||
STR R5,[R4, #+0]
|
||||
ADDS R4,R4,#+4
|
||||
ADDS R3,R3,#+4
|
||||
CMP R2,#+2
|
||||
BCC.N ??_tx_misra_message_copy_0
|
||||
SUBS R2,R2,#+1
|
||||
B.N ??_tx_misra_message_copy_1
|
||||
??_tx_misra_message_copy_2:
|
||||
LDR R5,[R3, #+0]
|
||||
STR R5,[R4, #+0]
|
||||
ADDS R4,R4,#+4
|
||||
ADDS R3,R3,#+4
|
||||
SUBS R2,R2,#+1
|
||||
??_tx_misra_message_copy_1:
|
||||
CMP R2,#+0
|
||||
BNE.N ??_tx_misra_message_copy_2
|
||||
??_tx_misra_message_copy_0:
|
||||
STR R3,[R0, #+0]
|
||||
STR R4,[R1, #+0]
|
||||
POP {R4,R5}
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_timer_pointer_dif(TX_TIMER_INTERNAL **ptr1, */
|
||||
/** TX_TIMER_INTERNAL **ptr2); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_timer_pointer_dif:
|
||||
SUBS R0,R0,R1
|
||||
ASRS R0,R0,#+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** TX_TIMER_INTERNAL **_tx_misra_timer_pointer_add(TX_TIMER_INTERNAL */
|
||||
/** **ptr1, ULONG size); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_timer_pointer_add:
|
||||
ADD R0,R0,R1, LSL #+2
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_user_timer_pointer_get(TX_TIMER_INTERNAL */
|
||||
/** *internal_timer, TX_TIMER **user_timer); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_user_timer_pointer_get:
|
||||
SUBS R0,#8
|
||||
STR R0,[R1, #+0]
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_thread_stack_check(TX_THREAD *thread_ptr, */
|
||||
/** VOID **highest_stack); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_thread_stack_check:
|
||||
PUSH {R3-R5,LR}
|
||||
MOVS R4,R0
|
||||
MOVS R5,R1
|
||||
BL _tx_thread_interrupt_disable
|
||||
CMP R4,#+0
|
||||
BEQ.N ??_tx_misra_thread_stack_check_0
|
||||
LDR R1,[R4, #+0]
|
||||
LDR.N R2,??DataTable2 // 0x54485244
|
||||
CMP R1,R2
|
||||
BNE.N ??_tx_misra_thread_stack_check_0
|
||||
LDR R1,[R4, #+8]
|
||||
LDR R2,[R5, #+0]
|
||||
CMP R1,R2
|
||||
BCS.N ??_tx_misra_thread_stack_check_1
|
||||
LDR R1,[R4, #+8]
|
||||
STR R1,[R5, #+0]
|
||||
??_tx_misra_thread_stack_check_1:
|
||||
LDR R1,[R4, #+12]
|
||||
LDR R1,[R1, #+0]
|
||||
CMP R1,#-269488145
|
||||
BNE.N ??_tx_misra_thread_stack_check_2
|
||||
LDR R1,[R4, #+16]
|
||||
LDR R1,[R1, #+1]
|
||||
CMP R1,#-269488145
|
||||
BNE.N ??_tx_misra_thread_stack_check_2
|
||||
LDR R1,[R5, #+0]
|
||||
LDR R2,[R4, #+12]
|
||||
CMP R1,R2
|
||||
BCS.N ??_tx_misra_thread_stack_check_3
|
||||
??_tx_misra_thread_stack_check_2:
|
||||
BL _tx_thread_interrupt_restore
|
||||
MOVS R0,R4
|
||||
BL _tx_thread_stack_error_handler
|
||||
BL _tx_thread_interrupt_disable
|
||||
??_tx_misra_thread_stack_check_3:
|
||||
LDR R1,[R5, #+0]
|
||||
LDR R1,[R1, #-4]
|
||||
CMP R1,#-269488145
|
||||
BEQ.N ??_tx_misra_thread_stack_check_0
|
||||
BL _tx_thread_interrupt_restore
|
||||
MOVS R0,R4
|
||||
BL _tx_thread_stack_analyze
|
||||
BL _tx_thread_interrupt_disable
|
||||
??_tx_misra_thread_stack_check_0:
|
||||
BL _tx_thread_interrupt_restore
|
||||
POP {R0,R4,R5,PC} // return
|
||||
|
||||
#ifdef TX_ENABLE_EVENT_TRACE
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** VOID _tx_misra_trace_event_insert(ULONG event_id, */
|
||||
/** VOID *info_field_1, ULONG info_field_2, ULONG info_field_3, */
|
||||
/** ULONG info_field_4, ULONG filter, ULONG time_stamp); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_trace_event_insert:
|
||||
PUSH {R3-R7,LR}
|
||||
LDR.N R4,??DataTable2_1
|
||||
LDR R4,[R4, #+0]
|
||||
CMP R4,#+0
|
||||
BEQ.N ??_tx_misra_trace_event_insert_0
|
||||
LDR.N R5,??DataTable2_2
|
||||
LDR R5,[R5, #+0]
|
||||
LDR R6,[SP, #+28]
|
||||
TST R5,R6
|
||||
BEQ.N ??_tx_misra_trace_event_insert_0
|
||||
LDR.N R5,??DataTable2_3
|
||||
LDR R5,[R5, #+0]
|
||||
LDR.N R6,??DataTable2_4
|
||||
LDR R6,[R6, #+0]
|
||||
CMP R5,#+0
|
||||
BNE.N ??_tx_misra_trace_event_insert_1
|
||||
LDR R5,[R6, #+44]
|
||||
LDR R7,[R6, #+60]
|
||||
LSLS R7,R7,#+16
|
||||
ORRS R7,R7,#0x80000000
|
||||
ORRS R5,R7,R5
|
||||
B.N ??_tx_misra_trace_event_insert_2
|
||||
??_tx_misra_trace_event_insert_1:
|
||||
CMP R5,#-252645136
|
||||
BCS.N ??_tx_misra_trace_event_insert_3
|
||||
MOVS R5,R6
|
||||
MOVS R6,#-1
|
||||
B.N ??_tx_misra_trace_event_insert_2
|
||||
??_tx_misra_trace_event_insert_3:
|
||||
MOVS R6,#-252645136
|
||||
MOVS R5,#+0
|
||||
??_tx_misra_trace_event_insert_2:
|
||||
STR R6,[R4, #+0]
|
||||
STR R5,[R4, #+4]
|
||||
STR R0,[R4, #+8]
|
||||
LDR R0,[SP, #+32]
|
||||
STR R0,[R4, #+12]
|
||||
STR R1,[R4, #+16]
|
||||
STR R2,[R4, #+20]
|
||||
STR R3,[R4, #+24]
|
||||
LDR R0,[SP, #+24]
|
||||
STR R0,[R4, #+28]
|
||||
ADDS R4,R4,#+32
|
||||
LDR.N R0,??DataTable2_5
|
||||
LDR R0,[R0, #+0]
|
||||
CMP R4,R0
|
||||
BCC.N ??_tx_misra_trace_event_insert_4
|
||||
LDR.N R0,??DataTable2_6
|
||||
LDR R4,[R0, #+0]
|
||||
LDR.N R0,??DataTable2_1
|
||||
STR R4,[R0, #+0]
|
||||
LDR.N R0,??DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
STR R4,[R0, #+32]
|
||||
LDR.N R0,??DataTable2_8
|
||||
LDR R0,[R0, #+0]
|
||||
CMP R0,#+0
|
||||
BEQ.N ??_tx_misra_trace_event_insert_0
|
||||
LDR.N R0,??DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
LDR.N R1,??DataTable2_8
|
||||
LDR R1,[R1, #+0]
|
||||
BLX R1
|
||||
B.N ??_tx_misra_trace_event_insert_0
|
||||
??_tx_misra_trace_event_insert_4:
|
||||
LDR.N R0,??DataTable2_1
|
||||
STR R4,[R0, #+0]
|
||||
LDR.N R0,??DataTable2_7
|
||||
LDR R0,[R0, #+0]
|
||||
STR R4,[R0, #+32]
|
||||
??_tx_misra_trace_event_insert_0:
|
||||
POP {R0,R4-R7,PC} // return
|
||||
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_1:
|
||||
DC32 _tx_trace_buffer_current_ptr
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_2:
|
||||
DC32 _tx_trace_event_enable_bits
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_5:
|
||||
DC32 _tx_trace_buffer_end_ptr
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_6:
|
||||
DC32 _tx_trace_buffer_start_ptr
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_7:
|
||||
DC32 _tx_trace_header_ptr
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_8:
|
||||
DC32 _tx_trace_full_notify_function
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_time_stamp_get(VOID); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_time_stamp_get:
|
||||
MOVS R0,#+0
|
||||
BX LR // return
|
||||
|
||||
#endif
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2:
|
||||
DC32 0x54485244
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_3:
|
||||
DC32 _tx_thread_system_state
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
??DataTable2_4:
|
||||
DC32 _tx_thread_current_ptr
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UINT _tx_misra_always_true(void); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_always_true:
|
||||
MOVS R0,#+1
|
||||
BX LR // return
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** UINT _tx_misra_status_get(UINT status); */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_status_get:
|
||||
MOVS R0,#+0
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_ipsr_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_ipsr_get:
|
||||
MRS R0, IPSR
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_control_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_control_get:
|
||||
MRS R0, CONTROL
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** void _tx_misra_control_set(ULONG value); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_control_set:
|
||||
MSR CONTROL, R0
|
||||
BX LR // return
|
||||
|
||||
|
||||
#ifdef __ARMVFP__
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** ULONG _tx_misra_fpccr_get(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
_tx_misra_fpccr_get:
|
||||
LDR r0, =0xE000EF34 // Build FPCCR address
|
||||
LDR r0, [r0] // Load FPCCR value
|
||||
BX LR // return
|
||||
|
||||
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
/** */
|
||||
/** void _tx_misra_vfp_touch(void); */
|
||||
/** */
|
||||
/***********************************************************************************************/
|
||||
/***********************************************************************************************/
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(1)
|
||||
THUMB
|
||||
_tx_misra_vfp_touch:
|
||||
vmov.f32 s0, s0
|
||||
BX LR // return
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
SECTION `.iar_vfe_header`:DATA:NOALLOC:NOROOT(2)
|
||||
SECTION_TYPE SHT_PROGBITS, 0
|
||||
DATA
|
||||
DC32 0
|
||||
|
||||
END
|
||||
83
ports/cortex_m3/iar/src/tx_thread_context_restore.s
Normal file
83
ports/cortex_m3/iar/src/tx_thread_context_restore.s
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
EXTERN _tx_execution_isr_exit
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_restore Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_exit] Execution profiling ISR exit */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs Interrupt Service Routines */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_restore(VOID)
|
||||
// {
|
||||
PUBLIC _tx_thread_context_restore
|
||||
_tx_thread_context_restore:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR exit function to indicate an ISR is complete. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_exit // Call the ISR exit function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
BX lr
|
||||
// }
|
||||
END
|
||||
85
ports/cortex_m3/iar/src/tx_thread_context_save.s
Normal file
85
ports/cortex_m3/iar/src/tx_thread_context_save.s
Normal file
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
EXTERN _tx_execution_isr_enter
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_context_save Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is only needed for legacy applications and it should */
|
||||
/* not be called in any new development on a Cortex-M. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* [_tx_execution_isr_enter] Execution profiling ISR enter */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ISRs */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_context_save(VOID)
|
||||
// {
|
||||
PUBLIC _tx_thread_context_save
|
||||
_tx_thread_context_save:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the ISR enter function to indicate an ISR is starting. */
|
||||
PUSH {r0, lr} // Save return address
|
||||
BL _tx_execution_isr_enter // Call the ISR enter function
|
||||
POP {r0, lr} // Recover return address
|
||||
#endif
|
||||
|
||||
/* Context is already saved - just return. */
|
||||
|
||||
BX lr
|
||||
// }
|
||||
END
|
||||
83
ports/cortex_m3/iar/src/tx_thread_interrupt_control.s
Normal file
83
ports/cortex_m3/iar/src/tx_thread_interrupt_control.s
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_control Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for changing the interrupt lockout */
|
||||
/* posture of the system. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* new_posture New interrupt lockout posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_control(UINT new_posture)
|
||||
// {
|
||||
PUBLIC _tx_thread_interrupt_control
|
||||
_tx_thread_interrupt_control:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Pickup current interrupt posture
|
||||
MSR BASEPRI, r0 // Apply the new interrupt posture
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#else
|
||||
MRS r1, PRIMASK // Pickup current interrupt lockout
|
||||
MSR PRIMASK, r0 // Apply the new interrupt lockout
|
||||
MOV r0, r1 // Transfer old to return register
|
||||
#endif
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
END
|
||||
83
ports/cortex_m3/iar/src/tx_thread_interrupt_disable.s
Normal file
83
ports/cortex_m3/iar/src/tx_thread_interrupt_disable.s
Normal file
@@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_disable Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for disabling interrupts and returning */
|
||||
/* the previous interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* old_posture Old interrupt lockout posture */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// UINT _tx_thread_interrupt_disable(VOID)
|
||||
// {
|
||||
PUBLIC _tx_thread_interrupt_disable
|
||||
_tx_thread_interrupt_disable:
|
||||
/* Return current interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r0, BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
MRS r0, PRIMASK
|
||||
CPSID i
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
END
|
||||
80
ports/cortex_m3/iar/src/tx_thread_interrupt_restore.s
Normal file
80
ports/cortex_m3/iar/src/tx_thread_interrupt_restore.s
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_interrupt_restore Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is responsible for restoring the previous */
|
||||
/* interrupt lockout posture. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* previous_posture Previous interrupt posture */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_interrupt_restore(UINT previous_posture)
|
||||
// {
|
||||
PUBLIC _tx_thread_interrupt_restore
|
||||
_tx_thread_interrupt_restore:
|
||||
/* Restore previous interrupt lockout posture. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
MSR PRIMASK, r0
|
||||
#endif
|
||||
BX lr
|
||||
// }
|
||||
END
|
||||
323
ports/cortex_m3/iar/src/tx_thread_schedule.s
Normal file
323
ports/cortex_m3/iar/src/tx_thread_schedule.s
Normal file
@@ -0,0 +1,323 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
EXTERN _tx_thread_current_ptr
|
||||
EXTERN _tx_thread_execute_ptr
|
||||
EXTERN _tx_timer_time_slice
|
||||
EXTERN _tx_thread_preempt_disable
|
||||
EXTERN _tx_execution_thread_enter
|
||||
EXTERN _tx_execution_thread_exit
|
||||
#ifdef TX_LOW_POWER
|
||||
EXTERN tx_low_power_enter
|
||||
EXTERN tx_low_power_exit
|
||||
#endif
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_schedule Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function waits for a thread control block pointer to appear in */
|
||||
/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
|
||||
/* in the variable, the corresponding thread is resumed. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
/* _tx_thread_system_return Return to system from thread */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 04-25-2022 Scott Larson Added BASEPRI support, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_schedule(VOID)
|
||||
// {
|
||||
PUBLIC _tx_thread_schedule
|
||||
_tx_thread_schedule:
|
||||
|
||||
/* This function should only ever be called on Cortex-M
|
||||
from the first schedule request. Subsequent scheduling occurs
|
||||
from the PendSV handling routine below. */
|
||||
|
||||
/* Clear the preempt-disable flag to enable rescheduling after initialization on Cortex-M targets. */
|
||||
|
||||
MOV r0, #0 // Build value for TX_FALSE
|
||||
LDR r2, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
STR r0, [r2, #0] // Clear preempt disable flag
|
||||
|
||||
/* Clear CONTROL.FPCA bit so VFP registers aren't unnecessarily stacked. */
|
||||
|
||||
#ifdef __ARMVFP__
|
||||
MRS r0, CONTROL // Pickup current CONTROL register
|
||||
BIC r0, r0, #4 // Clear the FPCA bit
|
||||
MSR CONTROL, r0 // Setup new CONTROL register
|
||||
#endif
|
||||
|
||||
/* Enable interrupts */
|
||||
CPSIE i
|
||||
|
||||
/* Enter the scheduler for the first time. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
DSB // Complete all memory accesses
|
||||
ISB // Flush pipeline
|
||||
|
||||
/* Wait here for the PendSV to take place. */
|
||||
|
||||
__tx_wait_here:
|
||||
B __tx_wait_here // Wait for the PendSV to happen
|
||||
// }
|
||||
|
||||
/* Generic context switching PendSV handler. */
|
||||
|
||||
PUBLIC PendSV_Handler
|
||||
PUBLIC __tx_PendSVHandler
|
||||
PendSV_Handler:
|
||||
__tx_PendSVHandler:
|
||||
|
||||
/* Get current thread value and new thread pointer. */
|
||||
|
||||
__tx_ts_handler:
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
PUSH {r0, lr} // Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit // Call the thread exit function
|
||||
POP {r0, lr} // Recover LR
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r0, 0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r0
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif /* TX_PORT_USE_BASEPRI */
|
||||
#endif /* EXECUTION PROFILE */
|
||||
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
MOV r3, #0 // Build NULL value
|
||||
LDR r1, [r0] // Pickup current thread pointer
|
||||
|
||||
/* Determine if there is a current thread to finish preserving. */
|
||||
|
||||
CBZ r1, __tx_ts_new // If NULL, skip preservation
|
||||
|
||||
/* Recover PSP and preserve current thread context. */
|
||||
|
||||
STR r3, [r0] // Set _tx_thread_current_ptr to NULL
|
||||
MRS r12, PSP // Pickup PSP pointer (thread's stack pointer)
|
||||
STMDB r12!, {r4-r11} // Save its remaining registers
|
||||
#ifdef __ARMVFP__
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_save
|
||||
VSTMDB r12!,{s16-s31} // Yes, save additional VFP registers
|
||||
_skip_vfp_save:
|
||||
#endif
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
STMDB r12!, {LR} // Save LR on the stack
|
||||
|
||||
/* Determine if time-slice is active. If it isn't, skip time handling processing. */
|
||||
|
||||
LDR r5, [r4] // Pickup current time-slice
|
||||
STR r12, [r1, #8] // Save the thread stack pointer
|
||||
CBZ r5, __tx_ts_new // If not active, skip processing
|
||||
|
||||
/* Time-slice is active, save the current thread's time-slice and clear the global time-slice variable. */
|
||||
|
||||
STR r5, [r1, #24] // Save current time-slice
|
||||
|
||||
/* Clear the global time-slice. */
|
||||
|
||||
STR r3, [r4] // Clear time-slice
|
||||
|
||||
/* Executing thread is now completely preserved!!! */
|
||||
|
||||
__tx_ts_new:
|
||||
|
||||
/* Now we are looking for a new thread to execute! */
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Is there another thread ready to execute?
|
||||
CBZ r1, __tx_ts_wait // No, skip to the wait processing
|
||||
|
||||
/* Yes, another thread is ready for else, make the current thread the new thread. */
|
||||
|
||||
STR r1, [r0] // Setup the current thread pointer to the new thread
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
|
||||
/* Increment the thread run count. */
|
||||
|
||||
__tx_ts_restore:
|
||||
LDR r7, [r1, #4] // Pickup the current thread run count
|
||||
LDR r4, =_tx_timer_time_slice // Build address of time-slice variable
|
||||
LDR r5, [r1, #24] // Pickup thread's current time-slice
|
||||
ADD r7, r7, #1 // Increment the thread run count
|
||||
STR r7, [r1, #4] // Store the new run count
|
||||
|
||||
/* Setup global time-slice with thread's current time-slice. */
|
||||
|
||||
STR r5, [r4] // Setup global time-slice
|
||||
|
||||
#if (defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY) || defined(TX_EXECUTION_PROFILE_ENABLE))
|
||||
/* Call the thread entry function to indicate the thread is executing. */
|
||||
PUSH {r0, r1} // Save r0 and r1
|
||||
BL _tx_execution_thread_enter // Call the thread execution enter function
|
||||
POP {r0, r1} // Recover r0 and r1
|
||||
#endif
|
||||
|
||||
/* Restore the thread context and PSP. */
|
||||
|
||||
LDR r12, [r1, #8] // Pickup thread's stack pointer
|
||||
LDMIA r12!, {LR} // Pickup LR
|
||||
#ifdef __ARMVFP__
|
||||
TST LR, #0x10 // Determine if the VFP extended frame is present
|
||||
BNE _skip_vfp_restore // If not, skip VFP restore
|
||||
VLDMIA r12!, {s16-s31} // Yes, restore additional VFP registers
|
||||
_skip_vfp_restore:
|
||||
#endif
|
||||
LDMIA r12!, {r4-r11} // Recover thread's registers
|
||||
MSR PSP, r12 // Setup the thread's stack pointer
|
||||
|
||||
/* Return to thread. */
|
||||
|
||||
BX lr // Return to thread!
|
||||
|
||||
/* The following is the idle wait processing... in this case, no threads are ready for execution and the
|
||||
system will simply be idle until an interrupt occurs that makes a thread ready. Note that interrupts
|
||||
are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
|
||||
__tx_ts_wait:
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
LDR r1, =TX_PORT_BASEPRI // Mask interrupt priorities =< TX_PORT_BASEPRI
|
||||
MSR BASEPRI, r1
|
||||
#else
|
||||
CPSID i // Disable interrupts
|
||||
#endif
|
||||
LDR r1, [r2] // Pickup the next thread to execute pointer
|
||||
STR r1, [r0] // Store it in the current pointer
|
||||
CBNZ r1, __tx_ts_ready // If non-NULL, a new thread is ready!
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_enter // Possibly enter low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_ENABLE_WFI
|
||||
DSB // Ensure no outstanding memory transactions
|
||||
WFI // Wait for interrupt
|
||||
ISB // Ensure pipeline is flushed
|
||||
#endif
|
||||
|
||||
#ifdef TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_exit // Exit low power mode
|
||||
POP {r0-r3}
|
||||
#endif
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_wait // Loop to continue waiting
|
||||
|
||||
/* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
already in the handler! */
|
||||
|
||||
__tx_ts_ready:
|
||||
MOV r7, #0x08000000 // Build clear PendSV value
|
||||
MOV r8, #0xE000E000 // Build base NVIC address
|
||||
STR r7, [r8, #0xD04] // Clear any PendSV
|
||||
|
||||
/* Re-enable interrupts and restore new thread. */
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MOV r4, #0 // Disable BASEPRI masking (enable interrupts)
|
||||
MSR BASEPRI, r4
|
||||
#else
|
||||
CPSIE i // Enable interrupts
|
||||
#endif
|
||||
B __tx_ts_restore // Restore the thread
|
||||
// }
|
||||
|
||||
#ifdef __ARMVFP__
|
||||
|
||||
PUBLIC tx_thread_fpu_enable
|
||||
tx_thread_fpu_enable:
|
||||
PUBLIC tx_thread_fpu_disable
|
||||
tx_thread_fpu_disable:
|
||||
|
||||
/* Automatic VPF logic is supported, this function is present only for
|
||||
backward compatibility purposes and therefore simply returns. */
|
||||
|
||||
BX LR // Return to caller
|
||||
|
||||
#endif
|
||||
END
|
||||
137
ports/cortex_m3/iar/src/tx_thread_stack_build.s
Normal file
137
ports/cortex_m3/iar/src/tx_thread_stack_build.s
Normal file
@@ -0,0 +1,137 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_stack_build Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function builds a stack frame on the supplied thread's stack. */
|
||||
/* The stack frame results in a fake interrupt return to the supplied */
|
||||
/* function pointer. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* thread_ptr Pointer to thread control blk */
|
||||
/* function_ptr Pointer to return function */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* _tx_thread_create Create thread service */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
|
||||
// {
|
||||
PUBLIC _tx_thread_stack_build
|
||||
_tx_thread_stack_build:
|
||||
|
||||
/* Build a fake interrupt frame. The form of the fake interrupt stack
|
||||
on the Cortex-M should look like the following after it is built:
|
||||
|
||||
Stack Top:
|
||||
LR Interrupted LR (LR at time of PENDSV)
|
||||
r4 Initial value for r4
|
||||
r5 Initial value for r5
|
||||
r6 Initial value for r6
|
||||
r7 Initial value for r7
|
||||
r8 Initial value for r8
|
||||
r9 Initial value for r9
|
||||
r10 Initial value for r10
|
||||
r11 Initial value for r11
|
||||
r0 Initial value for r0 (Hardware stack starts here!!)
|
||||
r1 Initial value for r1
|
||||
r2 Initial value for r2
|
||||
r3 Initial value for r3
|
||||
r12 Initial value for r12
|
||||
lr Initial value for lr
|
||||
pc Initial value for pc
|
||||
xPSR Initial value for xPSR
|
||||
|
||||
Stack Bottom: (higher memory address) */
|
||||
|
||||
LDR r2, [r0, #16] // Pickup end of stack area
|
||||
BIC r2, r2, #0x7 // Align frame for 8-byte alignment
|
||||
SUB r2, r2, #68 // Subtract frame size
|
||||
LDR r3, =0xFFFFFFFD // Build initial LR value
|
||||
STR r3, [r2, #0] // Save on the stack
|
||||
|
||||
/* Actually build the stack frame. */
|
||||
|
||||
MOV r3, #0 // Build initial register value
|
||||
STR r3, [r2, #4] // Store initial r4
|
||||
STR r3, [r2, #8] // Store initial r5
|
||||
STR r3, [r2, #12] // Store initial r6
|
||||
STR r3, [r2, #16] // Store initial r7
|
||||
STR r3, [r2, #20] // Store initial r8
|
||||
STR r3, [r2, #24] // Store initial r9
|
||||
STR r3, [r2, #28] // Store initial r10
|
||||
STR r3, [r2, #32] // Store initial r11
|
||||
|
||||
/* Hardware stack follows. */
|
||||
|
||||
STR r3, [r2, #36] // Store initial r0
|
||||
STR r3, [r2, #40] // Store initial r1
|
||||
STR r3, [r2, #44] // Store initial r2
|
||||
STR r3, [r2, #48] // Store initial r3
|
||||
STR r3, [r2, #52] // Store initial r12
|
||||
MOV r3, #0xFFFFFFFF // Poison EXC_RETURN value
|
||||
STR r3, [r2, #56] // Store initial lr
|
||||
STR r1, [r2, #60] // Store initial pc
|
||||
MOV r3, #0x01000000 // Only T-bit need be set
|
||||
STR r3, [r2, #64] // Store initial xPSR
|
||||
|
||||
/* Setup stack pointer. */
|
||||
// thread_ptr -> tx_thread_stack_ptr = r2;
|
||||
|
||||
STR r2, [r0, #8] // Save stack pointer in thread's
|
||||
// control block
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
END
|
||||
97
ports/cortex_m3/iar/src/tx_thread_system_return.s
Normal file
97
ports/cortex_m3/iar/src/tx_thread_system_return.s
Normal file
@@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Thread */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_thread_system_return Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function is target processor specific. It is used to transfer */
|
||||
/* control from a thread back to the ThreadX system. Only a */
|
||||
/* minimal context is saved since the compiler assumes temp registers */
|
||||
/* are going to get slicked by a function call anyway. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_thread_schedule Thread scheduling loop */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* ThreadX components */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_thread_system_return(VOID)
|
||||
// {
|
||||
PUBLIC _tx_thread_system_return
|
||||
_tx_thread_system_return:
|
||||
|
||||
/* Return to real scheduler via PendSV. Note that this routine is often
|
||||
replaced with in-line assembly in tx_port.h to improved performance. */
|
||||
|
||||
MOV r0, #0x10000000 // Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 // Load NVIC base
|
||||
STR r0, [r1, #0xD04] // Set PENDSVBIT in ICSR
|
||||
MRS r0, IPSR // Pickup IPSR
|
||||
CMP r0, #0 // Is it a thread returning?
|
||||
BNE _isr_context // If ISR, skip interrupt enable
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
MRS r1, BASEPRI // Thread context returning, pickup BASEPRI
|
||||
MOV r0, #0
|
||||
MSR BASEPRI, r0 // Enable interrupts
|
||||
MSR BASEPRI, r1 // Restore original interrupt posture
|
||||
#else
|
||||
MRS r1, PRIMASK // Thread context returning, pickup PRIMASK
|
||||
CPSIE i // Enable interrupts
|
||||
MSR PRIMASK, r1 // Restore original interrupt posture
|
||||
#endif
|
||||
_isr_context:
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
END
|
||||
262
ports/cortex_m3/iar/src/tx_timer_interrupt.s
Normal file
262
ports/cortex_m3/iar/src/tx_timer_interrupt.s
Normal file
@@ -0,0 +1,262 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Timer */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
EXTERN _tx_timer_time_slice
|
||||
EXTERN _tx_timer_system_clock
|
||||
EXTERN _tx_timer_current_ptr
|
||||
EXTERN _tx_timer_list_start
|
||||
EXTERN _tx_timer_list_end
|
||||
EXTERN _tx_timer_expired_time_slice
|
||||
EXTERN _tx_timer_expired
|
||||
EXTERN _tx_thread_time_slice
|
||||
EXTERN _tx_timer_expiration_process
|
||||
EXTERN _tx_thread_current_ptr
|
||||
EXTERN _tx_thread_execute_ptr
|
||||
EXTERN _tx_thread_preempt_disable
|
||||
|
||||
SECTION `.text`:CODE:NOROOT(2)
|
||||
THUMB
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_timer_interrupt Cortex-M3/IAR */
|
||||
/* 6.3.0 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function processes the hardware timer interrupt. This */
|
||||
/* processing includes incrementing the system clock and checking for */
|
||||
/* time slice and/or timer expiration. If either is found, the */
|
||||
/* expiration functions are called. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* None */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_timer_expiration_process Timer expiration processing */
|
||||
/* _tx_thread_time_slice Time slice interrupted thread */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* interrupt vector */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comment(s), added */
|
||||
/* TX_NO_TIMER support, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 10-31-2023 Tiejun Zhou Included tx_user.h, */
|
||||
/* resulting in version 6.3.0 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
// VOID _tx_timer_interrupt(VOID)
|
||||
// {
|
||||
#ifndef TX_NO_TIMER
|
||||
PUBLIC _tx_timer_interrupt
|
||||
_tx_timer_interrupt:
|
||||
|
||||
/* Upon entry to this routine, it is assumed that the compiler scratch registers are available
|
||||
for use. */
|
||||
|
||||
/* Increment the system clock. */
|
||||
// _tx_timer_system_clock++;
|
||||
|
||||
LDR r1, =_tx_timer_system_clock // Pickup address of system clock
|
||||
LDR r0, [r1, #0] // Pickup system clock
|
||||
ADD r0, r0, #1 // Increment system clock
|
||||
STR r0, [r1, #0] // Store new system clock
|
||||
|
||||
/* Test for time-slice expiration. */
|
||||
// if (_tx_timer_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_time_slice // Pickup address of time-slice
|
||||
LDR r2, [r3, #0] // Pickup time-slice
|
||||
CBZ r2, __tx_timer_no_time_slice // Is it non-active?
|
||||
// Yes, skip time-slice processing
|
||||
|
||||
/* Decrement the time_slice. */
|
||||
// _tx_timer_time_slice--;
|
||||
|
||||
SUB r2, r2, #1 // Decrement the time-slice
|
||||
STR r2, [r3, #0] // Store new time-slice value
|
||||
|
||||
/* Check for expiration. */
|
||||
// if (__tx_timer_time_slice == 0)
|
||||
|
||||
CBNZ r2, __tx_timer_no_time_slice // Has it expired?
|
||||
// No, skip expiration processing
|
||||
|
||||
/* Set the time-slice expired flag. */
|
||||
// _tx_timer_expired_time_slice = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup address of expired flag
|
||||
MOV r0, #1 // Build expired value
|
||||
STR r0, [r3, #0] // Set time-slice expiration flag
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_no_time_slice:
|
||||
|
||||
/* Test for timer expiration. */
|
||||
// if (*_tx_timer_current_ptr)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_current_ptr // Pickup current timer pointer address
|
||||
LDR r0, [r1, #0] // Pickup current timer
|
||||
LDR r2, [r0, #0] // Pickup timer list entry
|
||||
CBZ r2, __tx_timer_no_timer // Is there anything in the list?
|
||||
// No, just increment the timer
|
||||
|
||||
/* Set expiration flag. */
|
||||
// _tx_timer_expired = TX_TRUE;
|
||||
|
||||
LDR r3, =_tx_timer_expired // Pickup expiration flag address
|
||||
MOV r2, #1 // Build expired value
|
||||
STR r2, [r3, #0] // Set expired flag
|
||||
B __tx_timer_done // Finished timer processing
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
__tx_timer_no_timer:
|
||||
|
||||
/* No timer expired, increment the timer pointer. */
|
||||
// _tx_timer_current_ptr++;
|
||||
|
||||
ADD r0, r0, #4 // Move to next timer
|
||||
|
||||
/* Check for wrap-around. */
|
||||
// if (_tx_timer_current_ptr == _tx_timer_list_end)
|
||||
|
||||
LDR r3, =_tx_timer_list_end // Pickup addr of timer list end
|
||||
LDR r2, [r3, #0] // Pickup list end
|
||||
CMP r0, r2 // Are we at list end?
|
||||
BNE __tx_timer_skip_wrap // No, skip wrap-around logic
|
||||
|
||||
/* Wrap to beginning of list. */
|
||||
// _tx_timer_current_ptr = _tx_timer_list_start;
|
||||
|
||||
LDR r3, =_tx_timer_list_start // Pickup addr of timer list start
|
||||
LDR r0, [r3, #0] // Set current pointer to list start
|
||||
|
||||
__tx_timer_skip_wrap:
|
||||
|
||||
STR r0, [r1, #0] // Store new current timer pointer
|
||||
// }
|
||||
|
||||
__tx_timer_done:
|
||||
|
||||
/* See if anything has expired. */
|
||||
// if ((_tx_timer_expired_time_slice) || (_tx_timer_expired))
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of expired flag
|
||||
LDR r2, [r3, #0] // Pickup time-slice expired flag
|
||||
CBNZ r2, __tx_something_expired // Did a time-slice expire?
|
||||
// If non-zero, time-slice expired
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of other expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_nothing_expired // Did a timer expire?
|
||||
// No, nothing expired
|
||||
|
||||
__tx_something_expired:
|
||||
|
||||
STMDB sp!, {r0, lr} // Save the lr register on the stack
|
||||
// and save r0 just to keep 8-byte alignment
|
||||
|
||||
/* Did a timer expire? */
|
||||
// if (_tx_timer_expired)
|
||||
// {
|
||||
|
||||
LDR r1, =_tx_timer_expired // Pickup addr of expired flag
|
||||
LDR r0, [r1, #0] // Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_dont_activate // Check for timer expiration
|
||||
// If not set, skip timer activation
|
||||
|
||||
/* Process timer expiration. */
|
||||
// _tx_timer_expiration_process();
|
||||
|
||||
BL _tx_timer_expiration_process // Call the timer expiration handling routine
|
||||
|
||||
// }
|
||||
__tx_timer_dont_activate:
|
||||
|
||||
/* Did time slice expire? */
|
||||
// if (_tx_timer_expired_time_slice)
|
||||
// {
|
||||
|
||||
LDR r3, =_tx_timer_expired_time_slice // Pickup addr of time-slice expired
|
||||
LDR r2, [r3, #0] // Pickup the actual flag
|
||||
CBZ r2, __tx_timer_not_ts_expiration // See if the flag is set
|
||||
// No, skip time-slice processing
|
||||
|
||||
/* Time slice interrupted thread. */
|
||||
// _tx_thread_time_slice();
|
||||
|
||||
BL _tx_thread_time_slice // Call time-slice processing
|
||||
LDR r0, =_tx_thread_preempt_disable // Build address of preempt disable flag
|
||||
LDR r1, [r0] // Is the preempt disable flag set?
|
||||
CBNZ r1, __tx_timer_skip_time_slice // Yes, skip the PendSV logic
|
||||
LDR r0, =_tx_thread_current_ptr // Build current thread pointer address
|
||||
LDR r1, [r0] // Pickup the current thread pointer
|
||||
LDR r2, =_tx_thread_execute_ptr // Build execute thread pointer address
|
||||
LDR r3, [r2] // Pickup the execute thread pointer
|
||||
LDR r0, =0xE000ED04 // Build address of control register
|
||||
LDR r2, =0x10000000 // Build value for PendSV bit
|
||||
CMP r1, r3 // Are they the same?
|
||||
BEQ __tx_timer_skip_time_slice // If the same, there was no time-slice performed
|
||||
STR r2, [r0] // Not the same, issue the PendSV for preemption
|
||||
__tx_timer_skip_time_slice:
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_not_ts_expiration:
|
||||
|
||||
LDMIA sp!, {r0, lr} // Recover lr register (r0 is just there for
|
||||
// the 8-byte stack alignment
|
||||
|
||||
// }
|
||||
|
||||
__tx_timer_nothing_expired:
|
||||
|
||||
DSB // Complete all memory access
|
||||
BX lr // Return to caller
|
||||
// }
|
||||
#endif
|
||||
END
|
||||
728
ports/cortex_m3/keil/inc/tx_port.h
Normal file
728
ports/cortex_m3/keil/inc/tx_port.h
Normal file
@@ -0,0 +1,728 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Microsoft Corporation
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the MIT License which is available at
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Port Specific */
|
||||
/** */
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* PORT SPECIFIC C INFORMATION RELEASE */
|
||||
/* */
|
||||
/* tx_port.h Cortex-M3/Keil */
|
||||
/* 6.1.12 */
|
||||
/* */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* Scott Larson, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This file contains data type definitions that make the ThreadX */
|
||||
/* real-time kernel function identically on a variety of different */
|
||||
/* processor architectures. For example, the size or number of bits */
|
||||
/* in an "int" data type vary between microprocessor architectures and */
|
||||
/* even C compilers for the same microprocessor. ThreadX does not */
|
||||
/* directly use native C data types. Instead, ThreadX creates its */
|
||||
/* own special types that can be mapped to actual data types by this */
|
||||
/* file to guarantee consistency in the interface and functionality. */
|
||||
/* */
|
||||
/* This file replaces the previous Cortex-M3/M4/M7 files. It unifies */
|
||||
/* the ARMv7-M architecture and compilers into one common file. */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 06-02-2021 Scott Larson Initial Version 6.1.7 */
|
||||
/* 01-31-2022 Scott Larson Modified comments, updated */
|
||||
/* typedef to fix misra */
|
||||
/* violation, */
|
||||
/* fixed predefined macro, */
|
||||
/* resulting in version 6.1.10 */
|
||||
/* 04-25-2022 Scott Larson Modified comments and added */
|
||||
/* volatile to registers, */
|
||||
/* resulting in version 6.1.11 */
|
||||
/* 07-29-2022 Scott Larson Modified comments and */
|
||||
/* described BASEPRI usage, */
|
||||
/* resulting in version 6.1.12 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TX_PORT_H
|
||||
#define TX_PORT_H
|
||||
|
||||
|
||||
/* Determine if the optional ThreadX user define file should be used. */
|
||||
|
||||
#ifdef TX_INCLUDE_USER_DEFINE_FILE
|
||||
|
||||
/* Yes, include the user defines in tx_user.h. The defines in this file may
|
||||
alternately be defined on the command line. */
|
||||
|
||||
#include "tx_user.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler library include files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __ICCARM__
|
||||
#include <intrinsics.h> /* IAR Intrinsics */
|
||||
#define __asm__ __asm /* Define to make all inline asm look similar */
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#include <yvals.h>
|
||||
#endif
|
||||
#endif /* __ICCARM__ */
|
||||
|
||||
#ifdef __ghs__
|
||||
#include <arm_ghs.h>
|
||||
#include "tx_ghs.h"
|
||||
#endif /* __ghs__ */
|
||||
|
||||
|
||||
#if !defined(__GNUC__) && !defined(__CC_ARM)
|
||||
#define __get_control_value __get_CONTROL
|
||||
#define __set_control_value __set_CONTROL
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __get_ipsr_value __get_IPSR
|
||||
#endif
|
||||
|
||||
/* Define ThreadX basic types for this port. */
|
||||
|
||||
#define VOID void
|
||||
typedef char CHAR;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
typedef long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long long ULONG64;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
#define ULONG64_DEFINED
|
||||
|
||||
/* Define the priority levels for ThreadX. Legal values range
|
||||
from 32 to 1024 and MUST be evenly divisible by 32. */
|
||||
|
||||
#ifndef TX_MAX_PRIORITIES
|
||||
#define TX_MAX_PRIORITIES 32
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
|
||||
thread creation is less than this value, the thread create call will return an error. */
|
||||
|
||||
#ifndef TX_MINIMUM_STACK
|
||||
#define TX_MINIMUM_STACK 200 /* Minimum stack size for this port */
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the system timer thread's default stack size and priority. These are only applicable
|
||||
if TX_TIMER_PROCESS_IN_ISR is not defined. */
|
||||
|
||||
#ifndef TX_TIMER_THREAD_STACK_SIZE
|
||||
#define TX_TIMER_THREAD_STACK_SIZE 1024 /* Default timer thread stack size */
|
||||
#endif
|
||||
|
||||
#ifndef TX_TIMER_THREAD_PRIORITY
|
||||
#define TX_TIMER_THREAD_PRIORITY 0 /* Default timer thread priority */
|
||||
#endif
|
||||
|
||||
/* By default, ThreadX for Cortex-M uses the PRIMASK register to enable/disable interrupts.
|
||||
If using BASEPRI is desired, define the following two symbols for both c and assembly files:
|
||||
TX_PORT_USE_BASEPRI - This tells ThreadX to use BASEPRI instead of PRIMASK.
|
||||
TX_PORT_BASEPRI = (priority_mask << (8 - number_priority_bits)) - this defines the maximum priority level to mask.
|
||||
Any interrupt with a higher priority than priority_mask will not be masked, thus the interrupt will run.
|
||||
*/
|
||||
|
||||
/* Define various constants for the ThreadX Cortex-M port. */
|
||||
|
||||
#define TX_INT_DISABLE 1 /* Disable interrupts */
|
||||
#define TX_INT_ENABLE 0 /* Enable interrupts */
|
||||
|
||||
|
||||
/* Define the clock source for trace event entry time stamp. The following two item are port specific.
|
||||
For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
|
||||
source constants would be:
|
||||
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0x0a800024)
|
||||
#define TX_TRACE_TIME_MASK 0x0000FFFFUL
|
||||
|
||||
*/
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifndef TX_TRACE_TIME_SOURCE
|
||||
#define TX_TRACE_TIME_SOURCE *((volatile ULONG *) 0xE0001004)
|
||||
#endif
|
||||
#else
|
||||
ULONG _tx_misra_time_stamp_get(VOID);
|
||||
#define TX_TRACE_TIME_SOURCE _tx_misra_time_stamp_get()
|
||||
#endif
|
||||
|
||||
#ifndef TX_TRACE_TIME_MASK
|
||||
#define TX_TRACE_TIME_MASK 0xFFFFFFFFUL
|
||||
#endif
|
||||
|
||||
#ifdef __ghs__
|
||||
/* Define constants for Green Hills EventAnalyzer. */
|
||||
|
||||
/* Define the number of ticks per second. This informs the EventAnalyzer what the timestamps
|
||||
represent. By default, this is set to 1,000,000 i.e., one tick every microsecond. */
|
||||
|
||||
#define TX_EL_TICKS_PER_SECOND 1000000
|
||||
|
||||
/* Define the method of how to get the upper and lower 32-bits of the time stamp. By default, simply
|
||||
simulate the time-stamp source with a counter. */
|
||||
|
||||
#define read_tbu() _tx_el_time_base_upper
|
||||
#define read_tbl() ++_tx_el_time_base_lower
|
||||
#endif /* __ghs__ */
|
||||
|
||||
/* Define the port specific options for the _tx_build_options variable. This variable indicates
|
||||
how the ThreadX library was built. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_BUILD_OPTIONS (0)
|
||||
|
||||
|
||||
/* Define the in-line initialization constant so that modules with in-line
|
||||
initialization capabilities can prevent their initialization from being
|
||||
a function call. */
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
#define TX_DISABLE_INLINE
|
||||
#else
|
||||
#define TX_INLINE_INITIALIZATION
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
|
||||
disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack
|
||||
checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
|
||||
define is negated, thereby forcing the stack fill which is necessary for the stack checking
|
||||
logic. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
#ifdef TX_ENABLE_STACK_CHECKING
|
||||
#undef TX_DISABLE_STACK_FILLING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the TX_THREAD control block extensions for this port. The main reason
|
||||
for the multiple macros is so that backward compatibility can be maintained with
|
||||
existing ThreadX kernel awareness modules. */
|
||||
|
||||
#define TX_THREAD_EXTENSION_0
|
||||
#define TX_THREAD_EXTENSION_1
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#define TX_THREAD_EXTENSION_2 VOID *tx_thread_iar_tls_pointer;
|
||||
#elif defined(__ghs__)
|
||||
#define TX_THREAD_EXTENSION_2 VOID * tx_thread_eh_globals; \
|
||||
int Errno; /* errno. */ \
|
||||
char * strtok_saved_pos; /* strtok() position. */
|
||||
#else
|
||||
#define TX_THREAD_EXTENSION_2
|
||||
#endif
|
||||
|
||||
|
||||
#define TX_THREAD_EXTENSION_3
|
||||
|
||||
|
||||
|
||||
/* Define the port extensions of the remaining ThreadX objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_EXTENSION
|
||||
#define TX_BYTE_POOL_EXTENSION
|
||||
#define TX_EVENT_FLAGS_GROUP_EXTENSION
|
||||
#define TX_MUTEX_EXTENSION
|
||||
#define TX_QUEUE_EXTENSION
|
||||
#define TX_SEMAPHORE_EXTENSION
|
||||
#define TX_TIMER_EXTENSION
|
||||
|
||||
|
||||
/* Define the user extension field of the thread control block. Nothing
|
||||
additional is needed for this port so it is defined as white space. */
|
||||
|
||||
#ifndef TX_THREAD_USER_EXTENSION
|
||||
#define TX_THREAD_USER_EXTENSION
|
||||
#endif
|
||||
|
||||
|
||||
/* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
|
||||
tx_thread_shell_entry, and tx_thread_terminate. */
|
||||
|
||||
|
||||
#ifdef TX_ENABLE_IAR_LIBRARY_SUPPORT
|
||||
#if (__VER__ < 8000000)
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = __iar_dlib_perthread_allocate();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) __iar_dlib_perthread_deallocate(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL;
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION __iar_dlib_perthread_access(0);
|
||||
#else
|
||||
void *_tx_iar_create_per_thread_tls_area(void);
|
||||
void _tx_iar_destroy_per_thread_tls_area(void *tls_ptr);
|
||||
void __iar_Initlocks(void);
|
||||
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr) thread_ptr -> tx_thread_iar_tls_pointer = _tx_iar_create_per_thread_tls_area();
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr) do {_tx_iar_destroy_per_thread_tls_area(thread_ptr -> tx_thread_iar_tls_pointer); \
|
||||
thread_ptr -> tx_thread_iar_tls_pointer = TX_NULL; } while(0);
|
||||
#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION do {__iar_Initlocks();} while(0);
|
||||
#endif
|
||||
#else
|
||||
#define TX_THREAD_CREATE_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_DELETE_EXTENSION(thread_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__)
|
||||
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
|
||||
ULONG _tx_misra_control_get(void);
|
||||
void _tx_misra_control_set(ULONG value);
|
||||
ULONG _tx_misra_fpccr_get(void);
|
||||
void _tx_misra_vfp_touch(void);
|
||||
|
||||
#else /* TX_MISRA_ENABLE not defined */
|
||||
|
||||
/* Define some helper functions (these are intrinsics in some compilers). */
|
||||
#ifdef __GNUC__ /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm__ volatile (" MRS %0,CONTROL ": "=r" (control_value) );
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile (" MSR CONTROL,%0": : "r" (control_value): "memory" );
|
||||
}
|
||||
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
|
||||
#elif defined(__CC_ARM) /* ARM Compiler 5 */
|
||||
|
||||
__attribute__( ( always_inline ) ) ULONG __get_control_value(void)
|
||||
{
|
||||
ULONG control_value;
|
||||
|
||||
__asm volatile ("MRS control_value,CONTROL");
|
||||
return(control_value);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) void __set_control_value(ULONG control_value)
|
||||
{
|
||||
__asm__ volatile ("MSR CONTROL,control_value");
|
||||
}
|
||||
/* Can't access VFP registers with inline asm, so define this in tx_thread_schedule. */
|
||||
void _tx_vfp_access(void);
|
||||
#define TX_VFP_TOUCH() _tx_vfp_access();
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
#define TX_VFP_TOUCH() __asm__ volatile ("VMOV.F32 s0, s0");
|
||||
#endif /* Helper functions for different compilers */
|
||||
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
|
||||
|
||||
/* A completed thread falls into _thread_shell_entry and we can simply deactivate the FPU via CONTROL.FPCA
|
||||
in order to ensure no lazy stacking will occur. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* A thread can be terminated by another thread, so we first check if it's self-terminating and not in an ISR.
|
||||
If so, deactivate the FPU via CONTROL.FPCA. Otherwise we are in an interrupt or another thread is terminating
|
||||
this one, so if the FPCCR.LSPACT bit is set, we need to save the CONTROL.FPCA state, touch the FPU to flush
|
||||
the lazy FPU save, then restore the CONTROL.FPCA state. */
|
||||
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = *((volatile ULONG *) 0xE000EF34); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
TX_VFP_TOUCH(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = __get_control_value(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
__set_control_value(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr) { \
|
||||
ULONG _tx_system_state; \
|
||||
_tx_system_state = TX_THREAD_GET_SYSTEM_STATE(); \
|
||||
if ((_tx_system_state == ((ULONG) 0)) && ((thread_ptr) == _tx_thread_current_ptr)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ULONG _tx_fpccr; \
|
||||
_tx_fpccr = _tx_misra_fpccr_get(); \
|
||||
_tx_fpccr = _tx_fpccr & ((ULONG) 0x01); \
|
||||
if (_tx_fpccr == ((ULONG) 0x01)) \
|
||||
{ \
|
||||
ULONG _tx_vfp_state; \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ((ULONG) 0x4); \
|
||||
_tx_misra_vfp_touch(); \
|
||||
if (_tx_vfp_state == ((ULONG) 0)) \
|
||||
{ \
|
||||
_tx_vfp_state = _tx_misra_control_get(); \
|
||||
_tx_vfp_state = _tx_vfp_state & ~((ULONG) 0x4); \
|
||||
_tx_misra_control_set(_tx_vfp_state); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* No VFP in use */
|
||||
|
||||
#define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
|
||||
#define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
|
||||
|
||||
#endif /* defined(__ARMVFP__) || defined(__ARM_PCS_VFP) || defined(__ARM_FP) || defined(__TARGET_FPU_VFP) || defined(__VFP__) */
|
||||
|
||||
|
||||
/* Define the ThreadX object creation extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_CREATE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the ThreadX object deletion extensions for the remaining objects. */
|
||||
|
||||
#define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
|
||||
#define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
|
||||
#define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
|
||||
#define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
|
||||
#define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
|
||||
#define TX_TIMER_DELETE_EXTENSION(timer_ptr)
|
||||
|
||||
|
||||
/* Define the get system state macro. */
|
||||
|
||||
#ifndef TX_THREAD_GET_SYSTEM_STATE
|
||||
#ifndef TX_MISRA_ENABLE
|
||||
|
||||
#ifdef __CC_ARM /* ARM Compiler 5 */
|
||||
|
||||
register unsigned int _ipsr __asm("ipsr");
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _ipsr)
|
||||
|
||||
#elif defined(__GNUC__) /* GCC and ARM Compiler 6 */
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_ipsr_value(void)
|
||||
{
|
||||
unsigned int ipsr_value;
|
||||
__asm__ volatile (" MRS %0,IPSR ": "=r" (ipsr_value) );
|
||||
return(ipsr_value);
|
||||
}
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_ipsr_value())
|
||||
|
||||
#elif defined(__ICCARM__) /* IAR */
|
||||
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | __get_IPSR())
|
||||
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE for different compilers */
|
||||
|
||||
#else /* TX_MISRA_ENABLE is defined, use MISRA function. */
|
||||
ULONG _tx_misra_ipsr_get(VOID);
|
||||
#define TX_THREAD_GET_SYSTEM_STATE() (_tx_thread_system_state | _tx_misra_ipsr_get())
|
||||
#endif /* TX_MISRA_ENABLE */
|
||||
#endif /* TX_THREAD_GET_SYSTEM_STATE */
|
||||
|
||||
|
||||
/* Define the check for whether or not to call the _tx_thread_system_return function. A non-zero value
|
||||
indicates that _tx_thread_system_return should not be called. This overrides the definition in tx_thread.h
|
||||
for Cortex-M since so we don't waste time checking the _tx_thread_system_state variable that is always
|
||||
zero after initialization for Cortex-M ports. */
|
||||
|
||||
#ifndef TX_THREAD_SYSTEM_RETURN_CHECK
|
||||
#define TX_THREAD_SYSTEM_RETURN_CHECK(c) (c) = ((ULONG) _tx_thread_preempt_disable);
|
||||
#endif
|
||||
|
||||
/* Define the macro to ensure _tx_thread_preempt_disable is set early in initialization in order to
|
||||
prevent early scheduling on Cortex-M parts. */
|
||||
|
||||
#define TX_PORT_SPECIFIC_POST_INITIALIZATION _tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef TX_DISABLE_INLINE
|
||||
|
||||
/* Define the TX_LOWEST_SET_BIT_CALCULATE macro for each compiler. */
|
||||
#ifdef __ICCARM__ /* IAR Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __CLZ(__RBIT((m)));
|
||||
#elif defined(__CC_ARM) /* AC5 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) (b) = (UINT) __clz(__rbit((m)));
|
||||
#elif defined(__GNUC__) /* GCC and AC6 Compiler */
|
||||
#define TX_LOWEST_SET_BIT_CALCULATE(m, b) __asm__ volatile (" RBIT %0,%1 ": "=r" (m) : "r" (m) ); \
|
||||
__asm__ volatile (" CLZ %0,%1 ": "=r" (b) : "r" (m) );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Define the interrupt disable/restore macros for each compiler. */
|
||||
|
||||
#if defined(__GNUC__) || defined(__ICCARM__)
|
||||
|
||||
/*** GCC/AC6 and IAR ***/
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS %0, BASEPRI ": "=r" (posture));
|
||||
#else
|
||||
__asm__ volatile ("MRS %0, PRIMASK ": "=r" (posture));
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__attribute__( ( always_inline ) ) static inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI,%0 ": : "r" (basepri_value));
|
||||
}
|
||||
#else
|
||||
__attribute__( ( always_inline ) ) static inline void __enable_interrupts(void)
|
||||
{
|
||||
__asm__ volatile ("CPSIE i": : : "memory");
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
//__asm__ volatile ("MSR BASEPRI,%0": : "r" (int_posture): "memory");
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK,%0": : "r" (int_posture): "memory");
|
||||
#endif
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i" : : : "memory");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
__attribute__( ( always_inline ) ) static inline void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (__get_ipsr_value() == 0)
|
||||
{
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(0);
|
||||
#else
|
||||
__enable_interrupts();
|
||||
#endif
|
||||
__restore_interrupt(interrupt_save);
|
||||
}
|
||||
}
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End GCC/AC6 and IAR ***/
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
|
||||
/*** AC5 ***/
|
||||
|
||||
static __inline unsigned int __get_interrupt_posture(void)
|
||||
{
|
||||
unsigned int posture;
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__asm__ volatile ("MRS #posture, BASEPRI");
|
||||
#else
|
||||
__asm__ volatile ("MRS #posture, PRIMASK");
|
||||
#endif
|
||||
return(posture);
|
||||
}
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
static __inline void __set_basepri_value(unsigned int basepri_value)
|
||||
{
|
||||
__asm__ volatile ("MSR BASEPRI, #basepri_value");
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline unsigned int __disable_interrupts(void)
|
||||
{
|
||||
unsigned int int_posture;
|
||||
|
||||
int_posture = __get_interrupt_posture();
|
||||
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(TX_PORT_BASEPRI);
|
||||
#else
|
||||
__asm__ volatile ("CPSID i");
|
||||
#endif
|
||||
return(int_posture);
|
||||
}
|
||||
|
||||
static __inline void __restore_interrupt(unsigned int int_posture)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
__set_basepri_value(int_posture);
|
||||
#else
|
||||
__asm__ volatile ("MSR PRIMASK, #int_posture");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void _tx_thread_system_return_inline(void)
|
||||
{
|
||||
unsigned int interrupt_save;
|
||||
|
||||
/* Set PendSV to invoke ThreadX scheduler. */
|
||||
*((volatile ULONG *) 0xE000ED04) = ((ULONG) 0x10000000);
|
||||
if (_ipsr == 0)
|
||||
{
|
||||
#ifdef TX_PORT_USE_BASEPRI
|
||||
interrupt_save = __get_interrupt_posture();
|
||||
__set_basepri_value(0);
|
||||
__set_basepri_value(interrupt_save);
|
||||
#else
|
||||
interrupt_save = __disable_irq();
|
||||
__enable_irq();
|
||||
if (interrupt_save != 0)
|
||||
__disable_irq();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA UINT interrupt_save;
|
||||
#define TX_DISABLE interrupt_save = __disable_interrupts();
|
||||
#define TX_RESTORE __restore_interrupt(interrupt_save);
|
||||
|
||||
/*** End AC5 ***/
|
||||
|
||||
#endif /* Interrupt disable/restore macros for each compiler. */
|
||||
|
||||
/* Redefine _tx_thread_system_return for improved performance. */
|
||||
|
||||
#define _tx_thread_system_return _tx_thread_system_return_inline
|
||||
|
||||
|
||||
#else /* TX_DISABLE_INLINE is defined */
|
||||
|
||||
UINT _tx_thread_interrupt_disable(VOID);
|
||||
VOID _tx_thread_interrupt_restore(UINT previous_posture);
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA register UINT interrupt_save;
|
||||
|
||||
#define TX_DISABLE interrupt_save = _tx_thread_interrupt_disable();
|
||||
#define TX_RESTORE _tx_thread_interrupt_restore(interrupt_save);
|
||||
#endif /* TX_DISABLE_INLINE */
|
||||
|
||||
|
||||
/* Define FPU extension for the Cortex-M. Each is assumed to be called in the context of the executing
|
||||
thread. These are no longer needed, but are preserved for backward compatibility only. */
|
||||
|
||||
void tx_thread_fpu_enable(void);
|
||||
void tx_thread_fpu_disable(void);
|
||||
|
||||
|
||||
/* Define the version ID of ThreadX. This may be utilized by the application. */
|
||||
|
||||
#ifdef TX_THREAD_INIT
|
||||
CHAR _tx_version_id[] =
|
||||
"Copyright (c) 2024 Microsoft Corporation. * ThreadX Cortex-M3/Keil Version 6.4.2 *";
|
||||
#else
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
extern CHAR _tx_version_id[100];
|
||||
#else
|
||||
extern CHAR _tx_version_id[];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
90
ports/cortex_m3/keil/src/tx_thread_context_restore.s
Normal file
90
ports/cortex_m3/keil/src/tx_thread_context_restore.s
Normal file
@@ -0,0 +1,90 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
IMPORT _tx_execution_isr_exit
|
||||
ENDIF
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_context_restore Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is only needed for legacy applications and it should */
|
||||
;/* not be called in any new development on a Cortex-M. */
|
||||
;/* This function restores the interrupt context if it is processing a */
|
||||
;/* nested interrupt. If not, it returns to the interrupt thread if no */
|
||||
;/* preemption is necessary. Otherwise, if preemption is necessary or */
|
||||
;/* if no thread was running, the function returns to the scheduler. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* _tx_thread_schedule Thread scheduling routine */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* ISRs Interrupt Service Routines */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_context_restore(VOID)
|
||||
;{
|
||||
EXPORT _tx_thread_context_restore
|
||||
_tx_thread_context_restore
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the ISR exit function to indicate an ISR is complete. */
|
||||
;
|
||||
PUSH {r0,lr} ; Save ISR lr
|
||||
BL _tx_execution_isr_exit ; Call the ISR exit function
|
||||
POP {r0,lr} ; Restore ISR lr
|
||||
ENDIF
|
||||
;
|
||||
POP {lr}
|
||||
BX lr
|
||||
;}
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
90
ports/cortex_m3/keil/src/tx_thread_context_save.s
Normal file
90
ports/cortex_m3/keil/src/tx_thread_context_save.s
Normal file
@@ -0,0 +1,90 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
IMPORT _tx_execution_isr_enter
|
||||
ENDIF
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_context_save Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is only needed for legacy applications and it should */
|
||||
;/* not be called in any new development on a Cortex-M. */
|
||||
;/* This function saves the context of an executing thread in the */
|
||||
;/* beginning of interrupt processing. The function also ensures that */
|
||||
;/* the system stack is used upon return to the calling ISR. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* ISRs */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_context_save(VOID)
|
||||
;{
|
||||
EXPORT _tx_thread_context_save
|
||||
_tx_thread_context_save
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the ISR enter function to indicate an ISR is executing. */
|
||||
;
|
||||
PUSH {r0, lr} ; Save ISR lr
|
||||
BL _tx_execution_isr_enter ; Call the ISR enter function
|
||||
POP {r0, lr} ; Recover ISR lr
|
||||
ENDIF
|
||||
;
|
||||
; /* Return to interrupt processing. */
|
||||
;
|
||||
BX lr ; Return to interrupt processing caller
|
||||
;}
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
75
ports/cortex_m3/keil/src/tx_thread_interrupt_control.s
Normal file
75
ports/cortex_m3/keil/src/tx_thread_interrupt_control.s
Normal file
@@ -0,0 +1,75 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_interrupt_control Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is responsible for changing the interrupt lockout */
|
||||
;/* posture of the system. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* new_posture New interrupt lockout posture */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* old_posture Old interrupt lockout posture */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* Application Code */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;UINT _tx_thread_interrupt_control(UINT new_posture)
|
||||
;{
|
||||
EXPORT _tx_thread_interrupt_control
|
||||
_tx_thread_interrupt_control
|
||||
;
|
||||
; /* Pickup current interrupt lockout posture. */
|
||||
;
|
||||
MRS r1, PRIMASK
|
||||
MSR PRIMASK, r0
|
||||
MOV r0, r1
|
||||
BX lr
|
||||
;
|
||||
;}
|
||||
END
|
||||
74
ports/cortex_m3/keil/src/tx_thread_interrupt_disable.s
Normal file
74
ports/cortex_m3/keil/src/tx_thread_interrupt_disable.s
Normal file
@@ -0,0 +1,74 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_interrupt_disable Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is responsible for disabling interrupts and returning */
|
||||
;/* the previous interrupt lockout posture. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* old_posture Old interrupt lockout posture */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* Application Code */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;UINT _tx_thread_interrupt_disable(UINT new_posture)
|
||||
;{
|
||||
EXPORT _tx_thread_interrupt_disable
|
||||
_tx_thread_interrupt_disable
|
||||
;
|
||||
; /* Return current interrupt lockout posture. */
|
||||
;
|
||||
MRS r0, PRIMASK
|
||||
CPSID i
|
||||
BX lr
|
||||
;
|
||||
;}
|
||||
END
|
||||
73
ports/cortex_m3/keil/src/tx_thread_interrupt_restore.s
Normal file
73
ports/cortex_m3/keil/src/tx_thread_interrupt_restore.s
Normal file
@@ -0,0 +1,73 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_interrupt_restore Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is responsible for restoring the previous */
|
||||
;/* interrupt lockout posture. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* previous_posture Previous interrupt posture */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* Application Code */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_interrupt_restore(UINT new_posture)
|
||||
;{
|
||||
EXPORT _tx_thread_interrupt_restore
|
||||
_tx_thread_interrupt_restore
|
||||
;
|
||||
; /* Restore previous interrupt lockout posture. */
|
||||
;
|
||||
MSR PRIMASK, r0
|
||||
BX lr
|
||||
;
|
||||
;}
|
||||
END
|
||||
263
ports/cortex_m3/keil/src/tx_thread_schedule.s
Normal file
263
ports/cortex_m3/keil/src/tx_thread_schedule.s
Normal file
@@ -0,0 +1,263 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
IMPORT _tx_thread_current_ptr
|
||||
IMPORT _tx_thread_execute_ptr
|
||||
IMPORT _tx_timer_time_slice
|
||||
IMPORT _tx_thread_system_stack_ptr
|
||||
IMPORT _tx_thread_preempt_disable
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
IMPORT _tx_execution_thread_enter
|
||||
IMPORT _tx_execution_thread_exit
|
||||
ENDIF
|
||||
IF :DEF:TX_LOW_POWER
|
||||
IMPORT tx_low_power_enter
|
||||
IMPORT tx_low_power_exit
|
||||
ENDIF
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_schedule Cortex-M3/AC5 */
|
||||
;/* 6.1.5 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function waits for a thread control block pointer to appear in */
|
||||
;/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
|
||||
;/* in the variable, the corresponding thread is resumed. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* _tx_initialize_kernel_enter ThreadX entry function */
|
||||
;/* _tx_thread_system_return Return to system from thread */
|
||||
;/* _tx_thread_context_restore Restore thread's context */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* 03-02-2021 Scott Larson Modified comment(s), add */
|
||||
;/* low power code, */
|
||||
;/* resulting in version 6.1.5 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_schedule(VOID)
|
||||
;{
|
||||
EXPORT _tx_thread_schedule
|
||||
_tx_thread_schedule
|
||||
;
|
||||
; /* This function should only ever be called on Cortex-M
|
||||
; from the first schedule request. Subsequent scheduling occurs
|
||||
; from the PendSV handling routines below. */
|
||||
;
|
||||
; /* Clear the preempt-disable flag to enable rescheduling after initialization on Cortex-M targets. */
|
||||
;
|
||||
MOV r0, #0 ; Build value for TX_FALSE
|
||||
LDR r2, =_tx_thread_preempt_disable ; Build address of preempt disable flag
|
||||
STR r0, [r2, #0] ; Clear preempt disable flag
|
||||
;
|
||||
; /* Enable the interrupts */
|
||||
;
|
||||
CPSIE i
|
||||
;
|
||||
; /* Enter the scheduler for the first time. */
|
||||
;
|
||||
MOV r0, #0x10000000 ; Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 ; Load NVIC base
|
||||
STR r0, [r1, #0xD04] ; Set PENDSVBIT in ICSR
|
||||
DSB ; Complete all memory accesses
|
||||
ISB ; Flush pipeline
|
||||
;
|
||||
; /* Wait here for the PendSV to take place. */
|
||||
;
|
||||
__tx_wait_here
|
||||
B __tx_wait_here ; Wait for the PendSV to happen
|
||||
;}
|
||||
;
|
||||
; /* Generic context switching PendSV handler. */
|
||||
;
|
||||
EXPORT __tx_PendSVHandler
|
||||
EXPORT PendSV_Handler
|
||||
__tx_PendSVHandler
|
||||
PendSV_Handler
|
||||
;
|
||||
; /* Get current thread value and new thread pointer. */
|
||||
;
|
||||
__tx_ts_handler
|
||||
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the thread exit function to indicate the thread is no longer executing. */
|
||||
;
|
||||
CPSID i ; Disable interrupts
|
||||
PUSH {r0, lr} ; Save LR (and r0 just for alignment)
|
||||
BL _tx_execution_thread_exit ; Call the thread exit function
|
||||
POP {r0, lr} ; Recover LR
|
||||
CPSIE i ; Enable interrupts
|
||||
ENDIF
|
||||
MOV32 r0, _tx_thread_current_ptr ; Build current thread pointer address
|
||||
MOV32 r2, _tx_thread_execute_ptr ; Build execute thread pointer address
|
||||
MOV r3, #0 ; Build NULL value
|
||||
LDR r1, [r0] ; Pickup current thread pointer
|
||||
;
|
||||
; /* Determine if there is a current thread to finish preserving. */
|
||||
;
|
||||
CBZ r1, __tx_ts_new ; If NULL, skip preservation
|
||||
;
|
||||
; /* Recover PSP and preserve current thread context. */
|
||||
;
|
||||
STR r3, [r0] ; Set _tx_thread_current_ptr to NULL
|
||||
MRS r12, PSP ; Pickup PSP pointer (thread's stack pointer)
|
||||
STMDB r12!, {r4-r11} ; Save its remaining registers
|
||||
MOV32 r4, _tx_timer_time_slice ; Build address of time-slice variable
|
||||
STMDB r12!, {LR} ; Save LR on the stack
|
||||
;
|
||||
; /* Determine if time-slice is active. If it isn't, skip time handling processing. */
|
||||
;
|
||||
LDR r5, [r4] ; Pickup current time-slice
|
||||
STR r12, [r1, #8] ; Save the thread stack pointer
|
||||
CBZ r5, __tx_ts_new ; If not active, skip processing
|
||||
;
|
||||
; /* Time-slice is active, save the current thread's time-slice and clear the global time-slice variable. */
|
||||
;
|
||||
STR r5, [r1, #24] ; Save current time-slice
|
||||
;
|
||||
; /* Clear the global time-slice. */
|
||||
;
|
||||
STR r3, [r4] ; Clear time-slice
|
||||
;
|
||||
; /* Executing thread is now completely preserved!!! */
|
||||
;
|
||||
__tx_ts_new
|
||||
;
|
||||
; /* Now we are looking for a new thread to execute! */
|
||||
;
|
||||
CPSID i ; Disable interrupts
|
||||
LDR r1, [r2] ; Is there another thread ready to execute?
|
||||
CBZ r1, __tx_ts_wait ; No, skip to the wait processing
|
||||
;
|
||||
; /* Yes, another thread is ready for else, make the current thread the new thread. */
|
||||
;
|
||||
STR r1, [r0] ; Setup the current thread pointer to the new thread
|
||||
CPSIE i ; Enable interrupts
|
||||
;
|
||||
; /* Increment the thread run count. */
|
||||
;
|
||||
__tx_ts_restore
|
||||
LDR r7, [r1, #4] ; Pickup the current thread run count
|
||||
MOV32 r4, _tx_timer_time_slice ; Build address of time-slice variable
|
||||
LDR r5, [r1, #24] ; Pickup thread's current time-slice
|
||||
ADD r7, r7, #1 ; Increment the thread run count
|
||||
STR r7, [r1, #4] ; Store the new run count
|
||||
;
|
||||
; /* Setup global time-slice with thread's current time-slice. */
|
||||
;
|
||||
STR r5, [r4] ; Setup global time-slice
|
||||
|
||||
IF :DEF:TX_ENABLE_EXECUTION_CHANGE_NOTIFY
|
||||
;
|
||||
; /* Call the thread entry function to indicate the thread is executing. */
|
||||
;
|
||||
PUSH {r0, r1} ; Save r0/r1
|
||||
BL _tx_execution_thread_enter ; Call the thread execution enter function
|
||||
POP {r0, r1} ; Recover r3
|
||||
ENDIF
|
||||
;
|
||||
; /* Restore the thread context and PSP. */
|
||||
;
|
||||
LDR r12, [r1, #8] ; Pickup thread's stack pointer
|
||||
LDMIA r12!, {LR} ; Pickup LR
|
||||
LDMIA r12!, {r4-r11} ; Recover thread's registers
|
||||
MSR PSP, r12 ; Setup the thread's stack pointer
|
||||
;
|
||||
; /* Return to thread. */
|
||||
;
|
||||
BX lr ; Return to thread!
|
||||
;
|
||||
; /* The following is the idle wait processing... in this case, no threads are ready for execution and the
|
||||
; system will simply be idle until an interrupt occurs that makes a thread ready. Note that interrupts
|
||||
; are disabled to allow use of WFI for waiting for a thread to arrive. */
|
||||
;
|
||||
__tx_ts_wait
|
||||
CPSID i ; Disable interrupts
|
||||
LDR r1, [r2] ; Pickup the next thread to execute pointer
|
||||
STR r1, [r0] ; Store it in the current pointer
|
||||
CBNZ r1, __tx_ts_ready ; If non-NULL, a new thread is ready!
|
||||
|
||||
IF :DEF:TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_enter ; Possibly enter low power mode
|
||||
POP {r0-r3}
|
||||
ENDIF
|
||||
|
||||
IF :DEF:TX_ENABLE_WFI
|
||||
DSB ; Ensure no outstanding memory transactions
|
||||
WFI ; Wait for interrupt
|
||||
ISB ; Ensure pipeline is flushed
|
||||
ENDIF
|
||||
|
||||
IF :DEF:TX_LOW_POWER
|
||||
PUSH {r0-r3}
|
||||
BL tx_low_power_exit ; Exit low power mode
|
||||
POP {r0-r3}
|
||||
ENDIF
|
||||
|
||||
CPSIE i ; Enable interrupts
|
||||
B __tx_ts_wait ; Loop to continue waiting
|
||||
;
|
||||
; /* At this point, we have a new thread ready to go. Clear any newly pended PendSV - since we are
|
||||
; already in the handler! */
|
||||
;
|
||||
__tx_ts_ready
|
||||
MOV r7, #0x08000000 ; Build clear PendSV value
|
||||
MOV r8, #0xE000E000 ; Build base NVIC address
|
||||
STR r7, [r8, #0xD04] ; Clear any PendSV
|
||||
;
|
||||
; /* Re-enable interrupts and restore new thread. */
|
||||
;
|
||||
CPSIE i ; Enable interrupts
|
||||
B __tx_ts_restore ; Restore the thread
|
||||
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
132
ports/cortex_m3/keil/src/tx_thread_stack_build.s
Normal file
132
ports/cortex_m3/keil/src/tx_thread_stack_build.s
Normal file
@@ -0,0 +1,132 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_stack_build Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function builds a stack frame on the supplied thread's stack. */
|
||||
;/* The stack frame results in a fake interrupt return to the supplied */
|
||||
;/* function pointer. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* thread_ptr Pointer to thread control blk */
|
||||
;/* function_ptr Pointer to return function */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* _tx_thread_create Create thread service */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
|
||||
;{
|
||||
EXPORT _tx_thread_stack_build
|
||||
_tx_thread_stack_build
|
||||
;
|
||||
;
|
||||
; /* Build a fake interrupt frame. The form of the fake interrupt stack
|
||||
; on the Cortex-M3 should look like the following after it is built:
|
||||
;
|
||||
; Stack Top:
|
||||
; LR Interrupted LR (LR at time of PENDSV)
|
||||
; r4 Initial value for r4
|
||||
; r5 Initial value for r5
|
||||
; r6 Initial value for r6
|
||||
; r7 Initial value for r7
|
||||
; r8 Initial value for r8
|
||||
; r9 Initial value for r9
|
||||
; r10 Initial value for r10
|
||||
; r11 Initial value for r11
|
||||
; r0 Initial value for r0 (Hardware stack starts here!!)
|
||||
; r1 Initial value for r1
|
||||
; r2 Initial value for r2
|
||||
; r3 Initial value for r3
|
||||
; r12 Initial value for r12
|
||||
; lr Initial value for lr
|
||||
; pc Initial value for pc
|
||||
; xPSR Initial value for xPSR
|
||||
;
|
||||
; Stack Bottom: (higher memory address) */
|
||||
;
|
||||
LDR r2, [r0, #16] ; Pickup end of stack area
|
||||
BIC r2, r2, #0x7 ; Align frame for 8-byte alignment
|
||||
SUB r2, r2, #68 ; Subtract frame size
|
||||
LDR r3, =0xFFFFFFFD ; Build initial LR value
|
||||
STR r3, [r2, #0] ; Save on the stack
|
||||
;
|
||||
; /* Actually build the stack frame. */
|
||||
;
|
||||
MOV r3, #0 ; Build initial register value
|
||||
STR r3, [r2, #4] ; Store initial r4
|
||||
STR r3, [r2, #8] ; Store initial r5
|
||||
STR r3, [r2, #12] ; Store initial r6
|
||||
STR r3, [r2, #16] ; Store initial r7
|
||||
STR r3, [r2, #20] ; Store initial r8
|
||||
STR r3, [r2, #24] ; Store initial r9
|
||||
STR r3, [r2, #28] ; Store initial r10
|
||||
STR r3, [r2, #32] ; Store initial r11
|
||||
;
|
||||
; /* Hardware stack follows. */
|
||||
;
|
||||
STR r3, [r2, #36] ; Store initial r0
|
||||
STR r3, [r2, #40] ; Store initial r1
|
||||
STR r3, [r2, #44] ; Store initial r2
|
||||
STR r3, [r2, #48] ; Store initial r3
|
||||
STR r3, [r2, #52] ; Store initial r12
|
||||
MOV r3, #0xFFFFFFFF ; Poison EXC_RETURN value
|
||||
STR r3, [r2, #56] ; Store initial lr
|
||||
STR r1, [r2, #60] ; Store initial pc
|
||||
MOV r3, #0x01000000 ; Only T-bit need be set
|
||||
STR r3, [r2, #64] ; Store initial xPSR
|
||||
;
|
||||
; /* Setup stack pointer. */
|
||||
; thread_ptr -> tx_thread_stack_ptr = r2;
|
||||
;
|
||||
STR r2, [r0, #8] ; Save stack pointer in thread's
|
||||
; control block
|
||||
BX lr ; Return to caller
|
||||
;}
|
||||
END
|
||||
84
ports/cortex_m3/keil/src/tx_thread_system_return.s
Normal file
84
ports/cortex_m3/keil/src/tx_thread_system_return.s
Normal file
@@ -0,0 +1,84 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Thread */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_thread_system_return Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function is target processor specific. It is used to transfer */
|
||||
;/* control from a thread back to the ThreadX system. Only a */
|
||||
;/* minimal context is saved since the compiler assumes temp registers */
|
||||
;/* are going to get slicked by a function call anyway. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* _tx_thread_schedule Thread scheduling loop */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* ThreadX components */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_thread_system_return(VOID)
|
||||
;{
|
||||
EXPORT _tx_thread_system_return
|
||||
_tx_thread_system_return
|
||||
;
|
||||
; /* Return to real scheduler via PendSV. Note that this routine is often
|
||||
; replaced with in-line assembly in tx_port.h to improved performance. */
|
||||
;
|
||||
MOV r0, #0x10000000 ; Load PENDSVSET bit
|
||||
MOV r1, #0xE000E000 ; Load NVIC base
|
||||
STR r0, [r1, #0xD04] ; Set PENDSVBIT in ICSR
|
||||
MRS r0, IPSR ; Pickup IPSR
|
||||
CMP r0, #0 ; Is it a thread returning?
|
||||
BNE _isr_context ; If ISR, skip interrupt enable
|
||||
MRS r1, PRIMASK ; Thread context returning, pickup PRIMASK
|
||||
CPSIE i ; Enable interrupts
|
||||
MSR PRIMASK, r1 ; Restore original interrupt posture
|
||||
_isr_context
|
||||
BX lr ; Return to caller
|
||||
;}
|
||||
END
|
||||
258
ports/cortex_m3/keil/src/tx_timer_interrupt.s
Normal file
258
ports/cortex_m3/keil/src/tx_timer_interrupt.s
Normal file
@@ -0,0 +1,258 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
; * https://opensource.org/licenses/MIT.
|
||||
; *
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;/** */
|
||||
;/** ThreadX Component */
|
||||
;/** */
|
||||
;/** Timer */
|
||||
;/** */
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
;
|
||||
;
|
||||
IMPORT _tx_timer_time_slice
|
||||
IMPORT _tx_timer_system_clock
|
||||
IMPORT _tx_timer_current_ptr
|
||||
IMPORT _tx_timer_list_start
|
||||
IMPORT _tx_timer_list_end
|
||||
IMPORT _tx_timer_expired_time_slice
|
||||
IMPORT _tx_timer_expired
|
||||
IMPORT _tx_thread_time_slice
|
||||
IMPORT _tx_timer_expiration_process
|
||||
IMPORT _tx_thread_preempt_disable
|
||||
IMPORT _tx_thread_current_ptr
|
||||
IMPORT _tx_thread_execute_ptr
|
||||
;
|
||||
;
|
||||
AREA ||.text||, CODE, READONLY
|
||||
PRESERVE8
|
||||
;/**************************************************************************/
|
||||
;/* */
|
||||
;/* FUNCTION RELEASE */
|
||||
;/* */
|
||||
;/* _tx_timer_interrupt Cortex-M3/AC5 */
|
||||
;/* 6.1 */
|
||||
;/* AUTHOR */
|
||||
;/* */
|
||||
;/* William E. Lamie, Microsoft Corporation */
|
||||
;/* */
|
||||
;/* DESCRIPTION */
|
||||
;/* */
|
||||
;/* This function processes the hardware timer interrupt. This */
|
||||
;/* processing includes incrementing the system clock and checking for */
|
||||
;/* time slice and/or timer expiration. If either is found, the */
|
||||
;/* interrupt context save/restore functions are called along with the */
|
||||
;/* expiration functions. */
|
||||
;/* */
|
||||
;/* INPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* OUTPUT */
|
||||
;/* */
|
||||
;/* None */
|
||||
;/* */
|
||||
;/* CALLS */
|
||||
;/* */
|
||||
;/* _tx_timer_expiration_process Timer expiration processing */
|
||||
;/* _tx_thread_time_slice Time slice interrupted thread */
|
||||
;/* */
|
||||
;/* CALLED BY */
|
||||
;/* */
|
||||
;/* interrupt vector */
|
||||
;/* */
|
||||
;/* RELEASE HISTORY */
|
||||
;/* */
|
||||
;/* DATE NAME DESCRIPTION */
|
||||
;/* */
|
||||
;/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
;/* */
|
||||
;/**************************************************************************/
|
||||
;VOID _tx_timer_interrupt(VOID)
|
||||
;{
|
||||
EXPORT _tx_timer_interrupt
|
||||
_tx_timer_interrupt
|
||||
;
|
||||
; /* Upon entry to this routine, it is assumed that context save has already
|
||||
; been called, and therefore the compiler scratch registers are available
|
||||
; for use. */
|
||||
;
|
||||
; /* Increment the system clock. */
|
||||
; _tx_timer_system_clock++;
|
||||
;
|
||||
MOV32 r1, _tx_timer_system_clock ; Pickup address of system clock
|
||||
LDR r0, [r1, #0] ; Pickup system clock
|
||||
ADD r0, r0, #1 ; Increment system clock
|
||||
STR r0, [r1, #0] ; Store new system clock
|
||||
;
|
||||
; /* Test for time-slice expiration. */
|
||||
; if (_tx_timer_time_slice)
|
||||
; {
|
||||
;
|
||||
MOV32 r3, _tx_timer_time_slice ; Pickup address of time-slice
|
||||
LDR r2, [r3, #0] ; Pickup time-slice
|
||||
CBZ r2, __tx_timer_no_time_slice ; Is it non-active?
|
||||
; Yes, skip time-slice processing
|
||||
;
|
||||
; /* Decrement the time_slice. */
|
||||
; _tx_timer_time_slice--;
|
||||
;
|
||||
SUB r2, r2, #1 ; Decrement the time-slice
|
||||
STR r2, [r3, #0] ; Store new time-slice value
|
||||
;
|
||||
; /* Check for expiration. */
|
||||
; if (__tx_timer_time_slice == 0)
|
||||
;
|
||||
CBNZ r2, __tx_timer_no_time_slice ; Has it expired?
|
||||
;
|
||||
; /* Set the time-slice expired flag. */
|
||||
; _tx_timer_expired_time_slice = TX_TRUE;
|
||||
;
|
||||
MOV32 r3, _tx_timer_expired_time_slice ; Pickup address of expired flag
|
||||
MOV r0, #1 ; Build expired value
|
||||
STR r0, [r3, #0] ; Set time-slice expiration flag
|
||||
;
|
||||
; }
|
||||
;
|
||||
__tx_timer_no_time_slice
|
||||
;
|
||||
; /* Test for timer expiration. */
|
||||
; if (*_tx_timer_current_ptr)
|
||||
; {
|
||||
;
|
||||
MOV32 r1, _tx_timer_current_ptr ; Pickup current timer pointer address
|
||||
LDR r0, [r1, #0] ; Pickup current timer
|
||||
LDR r2, [r0, #0] ; Pickup timer list entry
|
||||
CBZ r2, __tx_timer_no_timer ; Is there anything in the list?
|
||||
; No, just increment the timer
|
||||
;
|
||||
; /* Set expiration flag. */
|
||||
; _tx_timer_expired = TX_TRUE;
|
||||
;
|
||||
MOV32 r3, _tx_timer_expired ; Pickup expiration flag address
|
||||
MOV r2, #1 ; Build expired value
|
||||
STR r2, [r3, #0] ; Set expired flag
|
||||
B __tx_timer_done ; Finished timer processing
|
||||
;
|
||||
; }
|
||||
; else
|
||||
; {
|
||||
__tx_timer_no_timer
|
||||
;
|
||||
; /* No timer expired, increment the timer pointer. */
|
||||
; _tx_timer_current_ptr++;
|
||||
;
|
||||
ADD r0, r0, #4 ; Move to next timer
|
||||
;
|
||||
; /* Check for wrap-around. */
|
||||
; if (_tx_timer_current_ptr == _tx_timer_list_end)
|
||||
;
|
||||
MOV32 r3, _tx_timer_list_end ; Pickup addr of timer list end
|
||||
LDR r2, [r3, #0] ; Pickup list end
|
||||
CMP r0, r2 ; Are we at list end?
|
||||
BNE __tx_timer_skip_wrap ; No, skip wrap-around logic
|
||||
;
|
||||
; /* Wrap to beginning of list. */
|
||||
; _tx_timer_current_ptr = _tx_timer_list_start;
|
||||
;
|
||||
MOV32 r3, _tx_timer_list_start ; Pickup addr of timer list start
|
||||
LDR r0, [r3, #0] ; Set current pointer to list start
|
||||
;
|
||||
__tx_timer_skip_wrap
|
||||
;
|
||||
STR r0, [r1, #0] ; Store new current timer pointer
|
||||
; }
|
||||
;
|
||||
__tx_timer_done
|
||||
;
|
||||
;
|
||||
; /* See if anything has expired. */
|
||||
; if ((_tx_timer_expired_time_slice) || (_tx_timer_expired))
|
||||
; {
|
||||
;
|
||||
MOV32 r3, _tx_timer_expired_time_slice ; Pickup addr of expired flag
|
||||
LDR r2, [r3, #0] ; Pickup time-slice expired flag
|
||||
CBNZ r2, __tx_something_expired ; Did a time-slice expire?
|
||||
; If non-zero, time-slice expired
|
||||
MOV32 r1, _tx_timer_expired ; Pickup addr of other expired flag
|
||||
LDR r0, [r1, #0] ; Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_nothing_expired ; Did a timer expire?
|
||||
; No, nothing expired
|
||||
;
|
||||
__tx_something_expired
|
||||
;
|
||||
;
|
||||
STMDB sp!, {r0, lr} ; Save the lr register on the stack
|
||||
; and save r0 just to keep 8-byte alignment
|
||||
;
|
||||
; /* Did a timer expire? */
|
||||
; if (_tx_timer_expired)
|
||||
; {
|
||||
;
|
||||
MOV32 r1, _tx_timer_expired ; Pickup addr of expired flag
|
||||
LDR r0, [r1, #0] ; Pickup timer expired flag
|
||||
CBZ r0, __tx_timer_dont_activate ; Check for timer expiration
|
||||
; If not set, skip timer activation
|
||||
;
|
||||
; /* Process timer expiration. */
|
||||
; _tx_timer_expiration_process();
|
||||
;
|
||||
BL _tx_timer_expiration_process ; Call the timer expiration handling routine
|
||||
;
|
||||
; }
|
||||
__tx_timer_dont_activate
|
||||
;
|
||||
; /* Did time slice expire? */
|
||||
; if (_tx_timer_expired_time_slice)
|
||||
; {
|
||||
;
|
||||
MOV32 r3, _tx_timer_expired_time_slice ; Pickup addr of time-slice expired
|
||||
LDR r2, [r3, #0] ; Pickup the actual flag
|
||||
CBZ r2, __tx_timer_not_ts_expiration ; See if the flag is set
|
||||
; No, skip time-slice processing
|
||||
;
|
||||
; /* Time slice interrupted thread. */
|
||||
; _tx_thread_time_slice();
|
||||
|
||||
BL _tx_thread_time_slice ; Call time-slice processing
|
||||
MOV32 r0, _tx_thread_preempt_disable ; Build address of preempt disable flag
|
||||
LDR r1, [r0] ; Is the preempt disable flag set?
|
||||
CBNZ r1, __tx_timer_skip_time_slice ; Yes, skip the PendSV logic
|
||||
MOV32 r0, _tx_thread_current_ptr ; Build current thread pointer address
|
||||
LDR r1, [r0] ; Pickup the current thread pointer
|
||||
MOV32 r2, _tx_thread_execute_ptr ; Build execute thread pointer address
|
||||
LDR r3, [r2] ; Pickup the execute thread pointer
|
||||
MOV32 r0, 0xE000ED04 ; Build address of control register
|
||||
MOV32 r2, 0x10000000 ; Build value for PendSV bit
|
||||
CMP r1, r3 ; Are they the same?
|
||||
BEQ __tx_timer_skip_time_slice ; If the same, there was no time-slice performed
|
||||
STR r2, [r0] ; Not the same, issue the PendSV for preemption
|
||||
__tx_timer_skip_time_slice
|
||||
;
|
||||
; }
|
||||
;
|
||||
__tx_timer_not_ts_expiration
|
||||
;
|
||||
LDMIA sp!, {r0, lr} ; Recover lr register (r0 is just there for
|
||||
;
|
||||
; }
|
||||
;
|
||||
__tx_timer_nothing_expired
|
||||
|
||||
DSB ; Complete all memory access
|
||||
BX lr ; Return to caller
|
||||
;
|
||||
;}
|
||||
ALIGN
|
||||
LTORG
|
||||
END
|
||||
Reference in New Issue
Block a user