]> begriffs open source - cmsis-freertos/blob - Source/portable/GCC/TriCore_1782/portmacro.h
Updated pack to FreeRTOS 10.3.1
[cmsis-freertos] / Source / portable / GCC / TriCore_1782 / portmacro.h
1 /*
2  * FreeRTOS Kernel V10.3.1
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://www.FreeRTOS.org
23  * http://aws.amazon.com/freertos
24  *
25  * 1 tab == 4 spaces!
26  */
27
28 #ifndef PORTMACRO_H
29 #define PORTMACRO_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /* System Includes. */
36 #include <tc1782.h>
37 #include <machine/intrinsics.h>
38
39 /*-----------------------------------------------------------
40  * Port specific definitions.
41  *
42  * The settings in this file configure FreeRTOS correctly for the
43  * given hardware and compiler.
44  *
45  * These settings should not be altered.
46  *-----------------------------------------------------------
47  */
48
49 /* Type definitions. */
50 #define portCHAR                char
51 #define portFLOAT               float
52 #define portDOUBLE              double
53 #define portLONG                long
54 #define portSHORT               short
55 #define portSTACK_TYPE  uint32_t
56 #define portBASE_TYPE   long
57
58 typedef portSTACK_TYPE StackType_t;
59 typedef long BaseType_t;
60 typedef unsigned long UBaseType_t;
61
62 #if( configUSE_16_BIT_TICKS == 1 )
63         typedef uint16_t TickType_t;
64         #define portMAX_DELAY ( TickType_t ) 0xffff
65 #else
66         typedef uint32_t TickType_t;
67         #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
68
69         /* 32-bit tick type on a 32-bit architecture, so reads of the tick count do
70         not need to be guarded with a critical section. */
71         #define portTICK_TYPE_IS_ATOMIC 1
72 #endif
73 /*---------------------------------------------------------------------------*/
74
75 /* Architecture specifics. */
76 #define portSTACK_GROWTH                                                        ( -1 )
77 #define portTICK_PERIOD_MS                                                      ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
78 #define portBYTE_ALIGNMENT                                                      4
79 #define portNOP()                                                                       __asm volatile( " nop " )
80 #define portCRITICAL_NESTING_IN_TCB                                     1
81 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL           1
82
83
84 /*---------------------------------------------------------------------------*/
85
86 typedef struct MPU_SETTINGS { uint32_t ulNotUsed; } xMPU_SETTINGS;
87
88 /* Define away the instruction from the Restore Context Macro. */
89 #define portPRIVILEGE_BIT                                                       0x0UL
90
91 #define portCCPN_MASK                                           ( 0x000000FFUL )
92
93 extern void vTaskEnterCritical( void );
94 extern void vTaskExitCritical( void );
95 #define portENTER_CRITICAL()                    vTaskEnterCritical()
96 #define portEXIT_CRITICAL()                             vTaskExitCritical()
97 /*---------------------------------------------------------------------------*/
98
99 /* CSA Manipulation. */
100 #define portCSA_TO_ADDRESS( pCSA )                      ( ( uint32_t * )( ( ( ( pCSA ) & 0x000F0000 ) << 12 ) | ( ( ( pCSA ) & 0x0000FFFF ) << 6 ) ) )
101 #define portADDRESS_TO_CSA( pAddress )          ( ( uint32_t )( ( ( ( (uint32_t)( pAddress ) ) & 0xF0000000 ) >> 12 ) | ( ( ( uint32_t )( pAddress ) & 0x003FFFC0 ) >> 6 ) ) )
102 /*---------------------------------------------------------------------------*/
103
104 #define portYIELD()                                                             _syscall( 0 )
105 /* Port Restore is implicit in the platform when the function is returned from the original PSW is automatically replaced. */
106 #define portSYSCALL_TASK_YIELD                                  0
107 #define portSYSCALL_RAISE_PRIORITY                              1
108 /*---------------------------------------------------------------------------*/
109
110 /* Critical section management. */
111
112 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
113 #define portDISABLE_INTERRUPTS()        {                                                                                                                                                                                                       \
114                                                                                 uint32_t ulICR;                                                                                                                                                 \
115                                                                                 _disable();                                                                                                                                                                             \
116                                                                                 ulICR = __MFCR( $ICR );                 /* Get current ICR value. */                                                                            \
117                                                                                 ulICR &= ~portCCPN_MASK;        /* Clear down mask bits. */                                                                                     \
118                                                                                 ulICR |= configMAX_SYSCALL_INTERRUPT_PRIORITY; /* Set mask bits to required priority mask. */   \
119                                                                                 _mtcr( $ICR, ulICR );           /* Write back updated ICR. */                                                                           \
120                                                                                 _isync();                                                                                                                                                                               \
121                                                                                 _enable();                                                                                                                                                                              \
122                                                                         }
123
124 /* Clear ICR.CCPN to allow all interrupt priorities. */
125 #define portENABLE_INTERRUPTS()         {                                                                                                                                       \
126                                                                                 uint32_t ulICR;                                                                                 \
127                                                                                 _disable();                                                                                                             \
128                                                                                 ulICR = __MFCR( $ICR );         /* Get current ICR value. */            \
129                                                                                 ulICR &= ~portCCPN_MASK;        /* Clear down mask bits. */                     \
130                                                                                 _mtcr( $ICR, ulICR );           /* Write back updated ICR. */           \
131                                                                                 _isync();                                                                                                               \
132                                                                                 _enable();                                                                                                              \
133                                                                         }
134
135 /* Set ICR.CCPN to uxSavedMaskValue. */
136 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedMaskValue )   {                                                                                                                                                                               \
137                                                                                                                                         uint32_t ulICR;                                                                                                                         \
138                                                                                                                                         _disable();                                                                                                                                                     \
139                                                                                                                                         ulICR = __MFCR( $ICR );         /* Get current ICR value. */                                                    \
140                                                                                                                                         ulICR &= ~portCCPN_MASK;        /* Clear down mask bits. */                                                             \
141                                                                                                                                         ulICR |= uxSavedMaskValue;      /* Set mask bits to previously saved mask value. */             \
142                                                                                                                                         _mtcr( $ICR, ulICR );           /* Write back updated ICR. */                                                   \
143                                                                                                                                         _isync();                                                                                                                                                       \
144                                                                                                                                         _enable();                                                                                                                                                      \
145                                                                                                                                 }
146
147
148 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY */
149 extern uint32_t uxPortSetInterruptMaskFromISR( void );
150 #define portSET_INTERRUPT_MASK_FROM_ISR()       uxPortSetInterruptMaskFromISR()
151
152 /* Pend a priority 1 interrupt, which will take care of the context switch. */
153 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken )          if( xHigherPriorityTaskWoken != pdFALSE ) {     CPU_SRC0.bits.SETR = 1; _isync(); }
154
155 /*---------------------------------------------------------------------------*/
156
157 /* Task function macros as described on the FreeRTOS.org WEB site. */
158 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
159 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
160 /*---------------------------------------------------------------------------*/
161
162 /*
163  * Port specific clean up macro required to free the CSAs that were consumed by
164  * a task that has since been deleted.
165  */
166 void vPortReclaimCSA( uint32_t *pxTCB );
167 #define portCLEAN_UP_TCB( pxTCB )               vPortReclaimCSA( ( uint32_t * ) ( pxTCB ) )
168
169 #ifdef __cplusplus
170 }
171 #endif
172
173 #endif /* PORTMACRO_H */