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