]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/TriCore_1782/portmacro.h
Add additional critical section to the default tickless implementations.
[freertos] / FreeRTOS / Source / portable / GCC / TriCore_1782 / portmacro.h
1 /*\r
2     FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3 \r
4     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
5 \r
6     ***************************************************************************\r
7      *                                                                       *\r
8      *    FreeRTOS provides completely free yet professionally developed,    *\r
9      *    robust, strictly quality controlled, supported, and cross          *\r
10      *    platform software that has become a de facto standard.             *\r
11      *                                                                       *\r
12      *    Help yourself get started quickly and support the FreeRTOS         *\r
13      *    project by purchasing a FreeRTOS tutorial book, reference          *\r
14      *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
15      *                                                                       *\r
16      *    Thank you!                                                         *\r
17      *                                                                       *\r
18     ***************************************************************************\r
19 \r
20     This file is part of the FreeRTOS distribution.\r
21 \r
22     FreeRTOS is free software; you can redistribute it and/or modify it under\r
23     the terms of the GNU General Public License (version 2) as published by the\r
24     Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
25 \r
26     >>! NOTE: The modification to the GPL is included to allow you to distribute\r
27     >>! a combined work that includes FreeRTOS without being obliged to provide\r
28     >>! the source code for proprietary components outside of the FreeRTOS\r
29     >>! kernel.\r
30 \r
31     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
32     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
33     FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
34     link: http://www.freertos.org/a00114.html\r
35 \r
36     1 tab == 4 spaces!\r
37 \r
38     ***************************************************************************\r
39      *                                                                       *\r
40      *    Having a problem?  Start by reading the FAQ "My application does   *\r
41      *    not run, what could be wrong?"                                     *\r
42      *                                                                       *\r
43      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
44      *                                                                       *\r
45     ***************************************************************************\r
46 \r
47     http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
48     license and Real Time Engineers Ltd. contact details.\r
49 \r
50     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
51     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
52     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
53 \r
54     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
55     Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
56     licenses offer ticketed support, indemnification and middleware.\r
57 \r
58     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
59     engineered and independently SIL3 certified version for use in safety and\r
60     mission critical applications that require provable dependability.\r
61 \r
62     1 tab == 4 spaces!\r
63 */\r
64 \r
65 #ifndef PORTMACRO_H\r
66 #define PORTMACRO_H\r
67 \r
68 #ifdef __cplusplus\r
69 extern "C" {\r
70 #endif\r
71 \r
72 /* System Includes. */\r
73 #include <tc1782.h>\r
74 #include <machine/intrinsics.h>\r
75 \r
76 /*-----------------------------------------------------------\r
77  * Port specific definitions.\r
78  *\r
79  * The settings in this file configure FreeRTOS correctly for the\r
80  * given hardware and compiler.\r
81  *\r
82  * These settings should not be altered.\r
83  *-----------------------------------------------------------\r
84  */\r
85 \r
86 /* Type definitions. */\r
87 #define portCHAR                char\r
88 #define portFLOAT               float\r
89 #define portDOUBLE              double\r
90 #define portLONG                long\r
91 #define portSHORT               short\r
92 #define portSTACK_TYPE  unsigned long\r
93 #define portBASE_TYPE   long\r
94 \r
95 #if( configUSE_16_BIT_TICKS == 1 )\r
96         typedef unsigned portSHORT portTickType;\r
97         #define portMAX_DELAY ( portTickType ) 0xffff\r
98 #else\r
99         typedef unsigned portLONG portTickType;\r
100         #define portMAX_DELAY ( portTickType ) 0xffffffff\r
101 #endif\r
102 /*---------------------------------------------------------------------------*/\r
103 \r
104 /* Architecture specifics. */\r
105 #define portSTACK_GROWTH                                                        ( -1 )\r
106 #define portTICK_RATE_MS                                                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )\r
107 #define portBYTE_ALIGNMENT                                                      4\r
108 #define portNOP()                                                                       __asm volatile( " nop " )\r
109 #define portCRITICAL_NESTING_IN_TCB                                     1\r
110 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL           1\r
111 \r
112 \r
113 /*---------------------------------------------------------------------------*/\r
114 \r
115 typedef struct MPU_SETTINGS { unsigned long ulNotUsed; } xMPU_SETTINGS;\r
116 \r
117 /* Define away the instruction from the Restore Context Macro. */\r
118 #define portPRIVILEGE_BIT                                                       0x0UL\r
119 \r
120 #define portCCPN_MASK                                           ( 0x000000FFUL )\r
121 \r
122 extern void vTaskEnterCritical( void );\r
123 extern void vTaskExitCritical( void );\r
124 #define portENTER_CRITICAL()                    vTaskEnterCritical()\r
125 #define portEXIT_CRITICAL()                             vTaskExitCritical()\r
126 /*---------------------------------------------------------------------------*/\r
127 \r
128 /* CSA Manipulation. */\r
129 #define portCSA_TO_ADDRESS( pCSA )                      ( ( unsigned long * )( ( ( ( pCSA ) & 0x000F0000 ) << 12 ) | ( ( ( pCSA ) & 0x0000FFFF ) << 6 ) ) )\r
130 #define portADDRESS_TO_CSA( pAddress )          ( ( unsigned long )( ( ( ( (unsigned long)( pAddress ) ) & 0xF0000000 ) >> 12 ) | ( ( ( unsigned long )( pAddress ) & 0x003FFFC0 ) >> 6 ) ) )\r
131 /*---------------------------------------------------------------------------*/\r
132 \r
133 #define portYIELD()                                                             _syscall( 0 )\r
134 /* Port Restore is implicit in the platform when the function is returned from the original PSW is automatically replaced. */\r
135 #define portSYSCALL_TASK_YIELD                                  0\r
136 #define portSYSCALL_RAISE_PRIORITY                              1\r
137 /*---------------------------------------------------------------------------*/\r
138 \r
139 /* Critical section management. */\r
140 \r
141 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY. */\r
142 #define portDISABLE_INTERRUPTS()        {                                                                                                                                                                                                       \\r
143                                                                                 unsigned long ulICR;                                                                                                                                                    \\r
144                                                                                 _disable();                                                                                                                                                                             \\r
145                                                                                 ulICR = _mfcr( $ICR );          /* Get current ICR value. */                                                                            \\r
146                                                                                 ulICR &= ~portCCPN_MASK;        /* Clear down mask bits. */                                                                                     \\r
147                                                                                 ulICR |= configMAX_SYSCALL_INTERRUPT_PRIORITY; /* Set mask bits to required priority mask. */   \\r
148                                                                                 _mtcr( $ICR, ulICR );           /* Write back updated ICR. */                                                                           \\r
149                                                                                 _isync();                                                                                                                                                                               \\r
150                                                                                 _enable();                                                                                                                                                                              \\r
151                                                                         }\r
152 \r
153 /* Clear ICR.CCPN to allow all interrupt priorities. */\r
154 #define portENABLE_INTERRUPTS()         {                                                                                                                                       \\r
155                                                                                 unsigned long ulICR;                                                                                    \\r
156                                                                                 _disable();                                                                                                             \\r
157                                                                                 ulICR = _mfcr( $ICR );          /* Get current ICR value. */            \\r
158                                                                                 ulICR &= ~portCCPN_MASK;        /* Clear down mask bits. */                     \\r
159                                                                                 _mtcr( $ICR, ulICR );           /* Write back updated ICR. */           \\r
160                                                                                 _isync();                                                                                                               \\r
161                                                                                 _enable();                                                                                                              \\r
162                                                                         }\r
163 \r
164 /* Set ICR.CCPN to uxSavedMaskValue. */\r
165 #define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedMaskValue )   {                                                                                                                                                                               \\r
166                                                                                                                                         unsigned long ulICR;                                                                                                                            \\r
167                                                                                                                                         _disable();                                                                                                                                                     \\r
168                                                                                                                                         ulICR = _mfcr( $ICR );          /* Get current ICR value. */                                                    \\r
169                                                                                                                                         ulICR &= ~portCCPN_MASK;        /* Clear down mask bits. */                                                             \\r
170                                                                                                                                         ulICR |= uxSavedMaskValue;      /* Set mask bits to previously saved mask value. */             \\r
171                                                                                                                                         _mtcr( $ICR, ulICR );           /* Write back updated ICR. */                                                   \\r
172                                                                                                                                         _isync();                                                                                                                                                       \\r
173                                                                                                                                         _enable();                                                                                                                                                      \\r
174                                                                                                                                 }\r
175 \r
176 \r
177 /* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY */\r
178 extern unsigned long uxPortSetInterruptMaskFromISR( void );\r
179 #define portSET_INTERRUPT_MASK_FROM_ISR()       uxPortSetInterruptMaskFromISR()\r
180 \r
181 /* Pend a priority 1 interrupt, which will take care of the context switch. */\r
182 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken )          if( xHigherPriorityTaskWoken != pdFALSE ) {     CPU_SRC0.bits.SETR = 1; _isync(); }\r
183 \r
184 /*---------------------------------------------------------------------------*/\r
185 \r
186 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
187 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
188 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
189 /*---------------------------------------------------------------------------*/\r
190 \r
191 /*\r
192  * Port specific clean up macro required to free the CSAs that were consumed by\r
193  * a task that has since been deleted.\r
194  */\r
195 void vPortReclaimCSA( unsigned long *pxTCB );\r
196 #define portCLEAN_UP_TCB( pxTCB )               vPortReclaimCSA( ( unsigned long * ) ( pxTCB ) )\r
197 \r
198 #ifdef __cplusplus\r
199 }\r
200 #endif\r
201 \r
202 #endif /* PORTMACRO_H */\r