]> git.sur5r.net Git - freertos/blob - Source/portable/GCC/TriCore_1782/portmacro.h
First commit with TriCore port and demo - still a work in progress.
[freertos] / Source / portable / GCC / TriCore_1782 / portmacro.h
1 /*\r
2     FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.\r
3 \r
4 \r
5     ***************************************************************************\r
6      *                                                                       *\r
7      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
8      *    Complete, revised, and edited pdf reference manuals are also       *\r
9      *    available.                                                         *\r
10      *                                                                       *\r
11      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
12      *    ensuring you get running as quickly as possible and with an        *\r
13      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
14      *    the FreeRTOS project to continue with its mission of providing     *\r
15      *    professional grade, cross platform, de facto standard solutions    *\r
16      *    for microcontrollers - completely free of charge!                  *\r
17      *                                                                       *\r
18      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
19      *                                                                       *\r
20      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
21      *                                                                       *\r
22     ***************************************************************************\r
23 \r
24 \r
25     This file is part of the FreeRTOS distribution.\r
26 \r
27     FreeRTOS is free software; you can redistribute it and/or modify it under\r
28     the terms of the GNU General Public License (version 2) as published by the\r
29     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
30     >>>NOTE<<< The modification to the GPL is included to allow you to\r
31     distribute a combined work that includes FreeRTOS without being obliged to\r
32     provide the source code for proprietary components outside of the FreeRTOS\r
33     kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
34     WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
35     or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
36     more details. You should have received a copy of the GNU General Public\r
37     License and the FreeRTOS license exception along with FreeRTOS; if not it\r
38     can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
39     by writing to Richard Barry, contact details for whom are available on the\r
40     FreeRTOS WEB site.\r
41 \r
42     1 tab == 4 spaces!\r
43 \r
44     http://www.FreeRTOS.org - Documentation, latest information, license and\r
45     contact details.\r
46 \r
47     http://www.SafeRTOS.com - A version that is certified for use in safety\r
48     critical systems.\r
49 \r
50     http://www.OpenRTOS.com - Commercial support, development, porting,\r
51     licensing and training services.\r
52 */\r
53 \r
54 #ifndef PORTMACRO_H\r
55 #define PORTMACRO_H\r
56 \r
57 #ifdef __cplusplus\r
58 extern "C" {\r
59 #endif\r
60 \r
61 /* System Includes. */\r
62 #include <tc1782.h>\r
63 #include <machine/intrinsics.h>\r
64 \r
65 /*-----------------------------------------------------------\r
66  * Port specific definitions.\r
67  *\r
68  * The settings in this file configure FreeRTOS correctly for the\r
69  * given hardware and compiler.\r
70  *\r
71  * These settings should not be altered.\r
72  *-----------------------------------------------------------\r
73  */\r
74 \r
75 /* Type definitions. */\r
76 #define portCHAR                char\r
77 #define portFLOAT               float\r
78 #define portDOUBLE              double\r
79 #define portLONG                long\r
80 #define portSHORT               short\r
81 #define portSTACK_TYPE  unsigned long\r
82 #define portBASE_TYPE   long\r
83 \r
84 #if( configUSE_16_BIT_TICKS == 1 )\r
85         typedef unsigned portSHORT portTickType;\r
86         #define portMAX_DELAY ( portTickType ) 0xffff\r
87 #else\r
88         typedef unsigned portLONG portTickType;\r
89         #define portMAX_DELAY ( portTickType ) 0xffffffff\r
90 #endif\r
91 /*---------------------------------------------------------------------------*/\r
92 \r
93 /* Architecture specifics. */\r
94 #define portSTACK_GROWTH                                                        ( -1 )\r
95 #define portTICK_RATE_MS                                                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )\r
96 #define portBYTE_ALIGNMENT                                                      4\r
97 #define portNOP()                                                                       __asm volatile( " nop " )\r
98 #define portCRITICAL_NESTING_IN_TCB                                     1\r
99 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL           1\r
100 #define portKERNEL_INTERRUPT_PRIORITY_LEVEL                     4\r
101 #define portSYSTEM_INTERRUPT_PRIORITY_LEVEL                     64\r
102 /*---------------------------------------------------------------------------*/\r
103 \r
104 typedef struct MPU_SETTINGS { unsigned long ulNotUsed; } xMPU_SETTINGS;\r
105 \r
106 /* Define away the instruction from the Restore Context Macro. */\r
107 #define portPRIVILEGE_BIT                                                       0x0UL\r
108 \r
109 extern void vTaskEnterCritical( void );\r
110 extern void vTaskExitCritical( void );\r
111 #define portENTER_CRITICAL()                    vTaskEnterCritical()\r
112 #define portEXIT_CRITICAL()                             vTaskExitCritical()\r
113 /*---------------------------------------------------------------------------*/\r
114 \r
115 /* Task utilities. */\r
116 \r
117 extern void vPortReclaimCSA( unsigned portBASE_TYPE *pxTCB );\r
118 \r
119 /* CSA Manipulation. */\r
120 #define portCSA_TO_ADDRESS( pCSA )                      ( ( unsigned portBASE_TYPE * )( ( ( ( pCSA ) & 0x000F0000 ) << 12 ) | ( ( ( pCSA ) & 0x0000FFFF ) << 6 ) ) )\r
121 #define portADDRESS_TO_CSA( pAddress )          ( ( unsigned portBASE_TYPE )( ( ( ( (unsigned portBASE_TYPE)( pAddress ) ) & 0xF0000000 ) >> 12 ) | ( ( (unsigned portBASE_TYPE)( pAddress ) & 0x003FFFC0 ) >> 6 ) ) )\r
122 /*---------------------------------------------------------------------------*/\r
123 \r
124 #define portYIELD()                                                             _syscall(0)\r
125 /* Port Restore is implicit in the platform when the function is returned from the original PSW is automatically replaced. */\r
126 #define portSYSCALL_TASK_YIELD                                  0\r
127 #define portSYSCALL_RAISE_PRIORITY                              1\r
128 /*---------------------------------------------------------------------------*/\r
129 \r
130 /* Critical section management. */\r
131 \r
132 /* Clear the ICR.IE bit. */             /* Or set ICR.CCPN to portSYSTEM_INTERRUPT_PRIORITY_LEVEL */\r
133 #define portDISABLE_INTERRUPTS()                        _disable()\r
134 /* Set the ICR.IE bit. */               /* Or set ICR.CCPN to 0 */\r
135 #define portENABLE_INTERRUPTS()                         _enable()\r
136 \r
137 #define portINTERRUPT_ENTER_CRITICAL()          _disable()\r
138 #define portINTERRUPT_EXIT_CRITICAL()           _enable()\r
139 \r
140 /*---------------------------------------------------------------------------*/\r
141 \r
142 /*\r
143  * Save the context of a task.\r
144  * The upper context is automatically saved when entering a trap or interrupt.\r
145  * Need to save the lower context as well and copy the PCXI CSA ID into\r
146  * pxCurrentTCB->pxTopOfStack. Only Lower Context CSA IDs may be saved to the\r
147  * TCB of a task.\r
148  *\r
149  * Call vTaskSwitchContext to select the next task, note that this changes the\r
150  * value of pxCurrentTCB so that it needs to be reloaded.\r
151  *\r
152  * Call vPortSetMPURegisterSetOne to change the MPU mapping for the task\r
153  * that has just been switched in.\r
154  *\r
155  * Load the context of the task.\r
156  * Need to restore the lower context by loading the CSA from\r
157  * pxCurrentTCB->pxTopOfStack into PCXI (effectively changing the call stack).\r
158  * In the Interrupt handler post-amble, RSLCX will restore the lower context\r
159  * of the task. RFE will restore the upper context of the task, jump to the\r
160  * return address and restore the previous state of interrupts being\r
161  * enabled/disabled.\r
162  */\r
163 #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken )                  \\r
164 {                                                                                                                               \\r
165 unsigned portBASE_TYPE *pxUpperCSA = NULL;                                              \\r
166 unsigned portBASE_TYPE xUpperCSA = 0UL;                                                 \\r
167         if ( pdTRUE == xHigherPriorityTaskWoken )                                       \\r
168         {                                                                                                                       \\r
169                 /*_disable();*/                                                                                 \\r
170                 portINTERRUPT_ENTER_CRITICAL();                                                 \\r
171                 _isync();                                                                                               \\r
172                 xUpperCSA = _mfcr( $PCXI );                                                             \\r
173                 pxUpperCSA = portCSA_TO_ADDRESS( xUpperCSA );                   \\r
174                 *pxCurrentTCB = pxUpperCSA[0];                                                  \\r
175                 vTaskSwitchContext();                                                                   \\r
176                 pxUpperCSA[0] = *pxCurrentTCB;                                                  \\r
177                 _dsync();                                                                                               \\r
178                 _isync();                                                                                               \\r
179                 _nop();                                                                                                 \\r
180                 _nop();                                                                                                 \\r
181         }                                                                                                                       \\r
182 }\r
183 /*---------------------------------------------------------------------------*/\r
184 \r
185 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
186 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
187 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
188 /*---------------------------------------------------------------------------*/\r
189 \r
190 #ifdef __cplusplus\r
191 }\r
192 #endif\r
193 \r
194 #endif /* PORTMACRO_H */\r