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