2 * FreeRTOS Kernel V10.5.1
\r
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * SPDX-License-Identifier: MIT
\r
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
8 * this software and associated documentation files (the "Software"), to deal in
\r
9 * the Software without restriction, including without limitation the rights to
\r
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
11 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
12 * subject to the following conditions:
\r
14 * The above copyright notice and this permission notice shall be included in all
\r
15 * copies or substantial portions of the Software.
\r
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 * https://www.FreeRTOS.org
\r
25 * https://github.com/FreeRTOS
\r
32 #ifdef __IAR_SYSTEMS_ICC__
\r
38 /*-----------------------------------------------------------
\r
39 * Port specific definitions.
\r
41 * The settings in this file configure FreeRTOS correctly for the
\r
42 * given hardware and compiler.
\r
44 * These settings should not be altered.
\r
45 *-----------------------------------------------------------
\r
48 #if __DATA_MODEL__ == __DATA_MODEL_FAR__ && __CODE_MODEL__ == __CODE_MODEL_NEAR__
\r
49 #warning This port has not been tested with your selected memory model combination. If a far data model is required it is recommended to also use a far code model.
\r
52 #if __DATA_MODEL__ == __DATA_MODEL_NEAR__ && __CODE_MODEL__ == __CODE_MODEL_FAR__
\r
53 #warning This port has not been tested with your selected memory model combination. If a far code model is required it is recommended to also use a far data model.
\r
56 /* Type definitions. */
\r
58 #define portCHAR char
\r
59 #define portFLOAT float
\r
60 #define portDOUBLE double
\r
61 #define portLONG long
\r
62 #define portSHORT short
\r
63 #define portSTACK_TYPE uint16_t
\r
64 #define portBASE_TYPE short
\r
66 typedef portSTACK_TYPE StackType_t;
\r
67 typedef short BaseType_t;
\r
68 typedef unsigned short UBaseType_t;
\r
71 #if __DATA_MODEL__ == __DATA_MODEL_FAR__
\r
72 #define portPOINTER_SIZE_TYPE uint32_t
\r
74 #define portPOINTER_SIZE_TYPE uint16_t
\r
78 #if ( configUSE_16_BIT_TICKS == 1 )
\r
79 typedef unsigned int TickType_t;
\r
80 #define portMAX_DELAY ( TickType_t ) 0xffff
\r
82 typedef uint32_t TickType_t;
\r
83 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
\r
85 /*-----------------------------------------------------------*/
\r
87 /* Interrupt control macros. */
\r
88 #define portDISABLE_INTERRUPTS() __asm ( "DI" )
\r
89 #define portENABLE_INTERRUPTS() __asm ( "EI" )
\r
90 /*-----------------------------------------------------------*/
\r
92 /* Critical section control macros. */
\r
93 #define portNO_CRITICAL_SECTION_NESTING ( ( uint16_t ) 0 )
\r
95 #define portENTER_CRITICAL() \
\r
97 extern volatile uint16_t usCriticalNesting; \
\r
99 portDISABLE_INTERRUPTS(); \
\r
101 /* Now interrupts are disabled ulCriticalNesting can be accessed */ \
\r
102 /* directly. Increment ulCriticalNesting to keep a count of how many */ \
\r
103 /* times portENTER_CRITICAL() has been called. */ \
\r
104 usCriticalNesting++; \
\r
107 #define portEXIT_CRITICAL() \
\r
109 extern volatile uint16_t usCriticalNesting; \
\r
111 if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \
\r
113 /* Decrement the nesting count when leaving a critical section. */ \
\r
114 usCriticalNesting--; \
\r
116 /* If the nesting level has reached zero then interrupts should be */ \
\r
117 /* re-enabled. */ \
\r
118 if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \
\r
120 portENABLE_INTERRUPTS(); \
\r
124 /*-----------------------------------------------------------*/
\r
126 /* Task utilities. */
\r
127 #define portNOP() __asm( "NOP" )
\r
128 #define portYIELD() __asm( "BRK" )
\r
129 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken ) vTaskSwitchContext(); } while( 0 )
\r
130 /*-----------------------------------------------------------*/
\r
132 /* Hardwware specifics. */
\r
133 #define portBYTE_ALIGNMENT 2
\r
134 #define portSTACK_GROWTH ( -1 )
\r
135 #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
\r
136 /*-----------------------------------------------------------*/
\r
138 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
139 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
140 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
144 #endif /* __cplusplus */
\r
146 #endif /* __IAR_SYSTEMS_ICC__ */
\r
148 ;//-----------------------------------------------------------------------------
\r
149 ;// The macros below are processed for asm sources which include portmacro.h.
\r
150 ;//-----------------------------------------------------------------------------
\r
151 #ifdef __IAR_SYSTEMS_ASM__
\r
153 ;/* Functions and variables used by this file. */
\r
154 ;//-----------------------------------------------------------------------------
\r
155 EXTERN _pxCurrentTCB
\r
156 EXTERN _usCriticalNesting
\r
158 ;/* Macro used to declutter calls, depends on the selected code model. */
\r
159 ;//-----------------------------------------------------------------------------
\r
160 #if __CODE_MODEL__ == __CODE_MODEL_FAR__
\r
161 #define RCALL(X) CALL F:X
\r
163 #define RCALL(X) CALL X
\r
167 ;/*-----------------------------------------------------------------------------
\r
168 ; * portSAVE_CONTEXT MACRO
\r
169 ; * Saves the context of the general purpose registers, CS and ES (only in __far
\r
170 ; * memory mode) registers the _usCriticalNesting value and the Stack Pointer
\r
171 ; * of the active Task onto the task stack.
\r
172 ; *---------------------------------------------------------------------------*/
\r
173 portSAVE_CONTEXT MACRO
\r
174 PUSH AX ; // Save AX Register to stack.
\r
176 #if __CODE_MODEL__ == __CODE_MODEL_FAR__
\r
177 MOV A, CS ; // Save CS register.
\r
179 MOV A, ES ; // Save ES register.
\r
182 MOV A, CS ; // Save CS register.
\r
185 PUSH DE ; // Save the remaining general purpose registers.
\r
187 MOVW AX, _usCriticalNesting ; // Save the _usCriticalNesting value.
\r
189 MOVW AX, _pxCurrentTCB ; // Save the Task stack pointer.
\r
194 ;//-----------------------------------------------------------------------------
\r
197 ;/*-----------------------------------------------------------------------------
\r
198 ; * portRESTORE_CONTEXT MACRO
\r
199 ; * Restores the task Stack Pointer then use this to restore _usCriticalNesting,
\r
200 ; * general purpose registers and the CS and ES (only in __far memory mode)
\r
201 ; * of the selected task from the task stack.
\r
202 ; *---------------------------------------------------------------------------*/
\r
203 portRESTORE_CONTEXT MACRO
\r
204 MOVW AX, _pxCurrentTCB ; // Restore the Task stack pointer.
\r
208 POP AX ; // Restore _usCriticalNesting value.
\r
209 MOVW _usCriticalNesting, AX
\r
210 POP BC ; // Restore the necessary general purpose registers.
\r
212 #if __CODE_MODEL__ == __CODE_MODEL_FAR__
\r
213 POP AX ; // Restore the ES register.
\r
215 XCH A, X ; // Restore the CS register.
\r
219 MOV CS, A ; // Restore CS register.
\r
221 POP HL ; // Restore general purpose register HL.
\r
222 POP AX ; // Restore AX.
\r
224 ;//-----------------------------------------------------------------------------
\r
226 #endif /* __IAR_SYSTEMS_ASM__ */
\r
228 #endif /* PORTMACRO_H */
\r