]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/GCC/MicroBlazeV8/portmacro.h
c6f55fa3f2fe9d827db76da96238dec744a9da51
[freertos] / FreeRTOS / Source / portable / GCC / MicroBlazeV8 / portmacro.h
1 /*\r
2     FreeRTOS V7.4.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
3 \r
4     FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
5     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     ***************************************************************************\r
8      *                                                                       *\r
9      *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
10      *    Complete, revised, and edited pdf reference manuals are also       *\r
11      *    available.                                                         *\r
12      *                                                                       *\r
13      *    Purchasing FreeRTOS documentation will not only help you, by       *\r
14      *    ensuring you get running as quickly as possible and with an        *\r
15      *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
16      *    the FreeRTOS project to continue with its mission of providing     *\r
17      *    professional grade, cross platform, de facto standard solutions    *\r
18      *    for microcontrollers - completely free of charge!                  *\r
19      *                                                                       *\r
20      *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
21      *                                                                       *\r
22      *    Thank you for using FreeRTOS, and thank you for your support!      *\r
23      *                                                                       *\r
24     ***************************************************************************\r
25 \r
26 \r
27     This file is part of the FreeRTOS distribution.\r
28 \r
29     FreeRTOS is free software; you can redistribute it and/or modify it under\r
30     the terms of the GNU General Public License (version 2) as published by the\r
31     Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
32 \r
33     >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to\r
34     distribute a combined work that includes FreeRTOS without being obliged to\r
35     provide the source code for proprietary components outside of the FreeRTOS\r
36     kernel.\r
37 \r
38     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
39     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
40     FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\r
41     details. You should have received a copy of the GNU General Public License\r
42     and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
43     viewed here: http://www.freertos.org/a00114.html and also obtained by\r
44     writing to Real Time Engineers Ltd., contact details for whom are available\r
45     on the FreeRTOS WEB site.\r
46 \r
47     1 tab == 4 spaces!\r
48 \r
49     ***************************************************************************\r
50      *                                                                       *\r
51      *    Having a problem?  Start by reading the FAQ "My application does   *\r
52      *    not run, what could be wrong?"                                     *\r
53      *                                                                       *\r
54      *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
55      *                                                                       *\r
56     ***************************************************************************\r
57 \r
58 \r
59     http://www.FreeRTOS.org - Documentation, books, training, latest versions, \r
60     license and Real Time Engineers Ltd. contact details.\r
61 \r
62     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
63     including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
64     fully thread aware and reentrant UDP/IP stack.\r
65 \r
66     http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High \r
67     Integrity Systems, who sell the code with commercial support, \r
68     indemnification and middleware, under the OpenRTOS brand.\r
69     \r
70     http://www.SafeRTOS.com - High Integrity Systems also provide a safety \r
71     engineered and independently SIL3 certified version for use in safety and \r
72     mission critical applications that require provable dependability.\r
73 */\r
74 \r
75 #ifndef PORTMACRO_H\r
76 #define PORTMACRO_H\r
77 \r
78 #ifdef __cplusplus\r
79 extern "C" {\r
80 #endif\r
81 \r
82 /* BSP includes. */\r
83 #include <mb_interface.h>\r
84 #include <xparameters.h>\r
85 \r
86 /*-----------------------------------------------------------\r
87  * Port specific definitions.  \r
88  *\r
89  * The settings in this file configure FreeRTOS correctly for the\r
90  * given hardware and compiler.\r
91  *\r
92  * These settings should not be altered.\r
93  *-----------------------------------------------------------\r
94  */\r
95 \r
96 /* Type definitions. */\r
97 #define portCHAR                char\r
98 #define portFLOAT               float\r
99 #define portDOUBLE              double\r
100 #define portLONG                long\r
101 #define portSHORT               short\r
102 #define portSTACK_TYPE  unsigned long\r
103 #define portBASE_TYPE   long\r
104 \r
105 #if( configUSE_16_BIT_TICKS == 1 )\r
106         typedef unsigned portSHORT portTickType;\r
107         #define portMAX_DELAY ( portTickType ) 0xffff\r
108 #else\r
109         typedef unsigned portLONG portTickType;\r
110         #define portMAX_DELAY ( portTickType ) 0xffffffff\r
111 #endif\r
112 /*-----------------------------------------------------------*/ \r
113 \r
114 /* Interrupt control macros and functions. */\r
115 void microblaze_disable_interrupts( void );\r
116 void microblaze_enable_interrupts( void );\r
117 #define portDISABLE_INTERRUPTS()        microblaze_disable_interrupts()\r
118 #define portENABLE_INTERRUPTS()         microblaze_enable_interrupts()\r
119 \r
120 /*-----------------------------------------------------------*/\r
121 \r
122 /* Critical section macros. */\r
123 void vPortEnterCritical( void );\r
124 void vPortExitCritical( void );\r
125 #define portENTER_CRITICAL()            {                                                                                                                               \\r
126                                                                                 extern volatile unsigned portBASE_TYPE uxCriticalNesting;       \\r
127                                                                                 microblaze_disable_interrupts();                                                        \\r
128                                                                                 uxCriticalNesting++;                                                                            \\r
129                                                                         }\r
130 \r
131 #define portEXIT_CRITICAL()                     {                                                                                                                               \\r
132                                                                                 extern volatile unsigned portBASE_TYPE uxCriticalNesting;       \\r
133                                                                                 /* Interrupts are disabled, so we can */                                        \\r
134                                                                                 /* access the variable directly. */                                                     \\r
135                                                                                 uxCriticalNesting--;                                                                            \\r
136                                                                                 if( uxCriticalNesting == 0 )                                                            \\r
137                                                                                 {                                                                                                                       \\r
138                                                                                         /* The nesting has unwound and we                                               \\r
139                                                                                         can enable interrupts again. */                                                 \\r
140                                                                                         portENABLE_INTERRUPTS();                                                                \\r
141                                                                                 }                                                                                                                       \\r
142                                                                         }\r
143 \r
144 /*-----------------------------------------------------------*/\r
145 \r
146 /* The yield macro maps directly to the vPortYield() function. */\r
147 void vPortYield( void );\r
148 #define portYIELD() vPortYield()\r
149 \r
150 /* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead\r
151 sets a flag to say that a yield has been requested.  The interrupt exit code\r
152 then checks this flag, and calls vTaskSwitchContext() before restoring a task\r
153 context, if the flag is not false.  This is done to prevent multiple calls to\r
154 vTaskSwitchContext() being made from a single interrupt, as a single interrupt\r
155 can result in multiple peripherals being serviced. */\r
156 extern volatile unsigned long ulTaskSwitchRequested;\r
157 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1\r
158 /*-----------------------------------------------------------*/\r
159 \r
160 /* Hardware specifics. */\r
161 #define portBYTE_ALIGNMENT                      4\r
162 #define portSTACK_GROWTH                        ( -1 )\r
163 #define portTICK_RATE_MS                        ( ( portTickType ) 1000 / configTICK_RATE_HZ )\r
164 #define portNOP()                                       asm volatile ( "NOP" )\r
165 /*-----------------------------------------------------------*/\r
166 \r
167 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
168 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
169 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
170 /*-----------------------------------------------------------*/\r
171 \r
172 /* The following structure is used by the FreeRTOS exception handler.  It is\r
173 filled with the MicroBlaze context as it was at the time the exception occurred.\r
174 This is done as an aid to debugging exception occurrences. */\r
175 typedef struct PORT_REGISTER_DUMP\r
176 {\r
177         /* The following structure members hold the values of the MicroBlaze\r
178         registers at the time the exception was raised. */\r
179         unsigned long ulR1_SP;\r
180         unsigned long ulR2_small_data_area;\r
181         unsigned long ulR3;\r
182         unsigned long ulR4;\r
183         unsigned long ulR5;\r
184         unsigned long ulR6;\r
185         unsigned long ulR7;\r
186         unsigned long ulR8;\r
187         unsigned long ulR9;\r
188         unsigned long ulR10;\r
189         unsigned long ulR11;\r
190         unsigned long ulR12;\r
191         unsigned long ulR13_read_write_small_data_area;\r
192         unsigned long ulR14_return_address_from_interrupt;\r
193         unsigned long ulR15_return_address_from_subroutine;\r
194         unsigned long ulR16_return_address_from_trap;\r
195         unsigned long ulR17_return_address_from_exceptions; /* The exception entry code will copy the BTR into R17 if the exception occurred in the delay slot of a branch instruction. */\r
196         unsigned long ulR18;\r
197         unsigned long ulR19;\r
198         unsigned long ulR20;\r
199         unsigned long ulR21;\r
200         unsigned long ulR22;\r
201         unsigned long ulR23;\r
202         unsigned long ulR24;\r
203         unsigned long ulR25;\r
204         unsigned long ulR26;\r
205         unsigned long ulR27;\r
206         unsigned long ulR28;\r
207         unsigned long ulR29;\r
208         unsigned long ulR30;\r
209         unsigned long ulR31;\r
210         unsigned long ulPC;\r
211         unsigned long ulESR;\r
212         unsigned long ulMSR;\r
213         unsigned long ulEAR;\r
214         unsigned long ulFSR;\r
215         unsigned long ulEDR;\r
216 \r
217         /* A human readable description of the exception cause.  The strings used\r
218         are the same as the #define constant names found in the\r
219         microblaze_exceptions_i.h header file */\r
220         signed char *pcExceptionCause;\r
221 \r
222         /* The human readable name of the task that was running at the time the\r
223         exception occurred.  This is the name that was given to the task when the\r
224         task was created using the FreeRTOS xTaskCreate() API function. */\r
225         signed char *pcCurrentTaskName;\r
226 \r
227         /* The handle of the task that was running a the time the exception\r
228         occurred. */\r
229         void * xCurrentTaskHandle;\r
230 \r
231 } xPortRegisterDump;\r
232 \r
233 \r
234 /*\r
235  * Installs pxHandler as the interrupt handler for the peripheral specified by \r
236  * the ucInterruptID parameter.\r
237  *\r
238  * ucInterruptID:\r
239  * \r
240  * The ID of the peripheral that will have pxHandler assigned as its interrupt\r
241  * handler.  Peripheral IDs are defined in the xparameters.h header file, which \r
242  * is itself part of the BSP project.  For example, in the official demo \r
243  * application for this port, xparameters.h defines the following IDs for the \r
244  * four possible interrupt sources:\r
245  *\r
246  * XPAR_INTC_0_UARTLITE_1_VEC_ID  -  for the UARTlite peripheral.\r
247  * XPAR_INTC_0_TMRCTR_0_VEC_ID    -  for the AXI Timer 0 peripheral.\r
248  * XPAR_INTC_0_EMACLITE_0_VEC_ID  -  for the Ethernet lite peripheral.\r
249  * XPAR_INTC_0_GPIO_1_VEC_ID      -  for the button inputs.\r
250  *\r
251  *\r
252  * pxHandler:\r
253  * \r
254  * A pointer to the interrupt handler function itself.  This must be a void\r
255  * function that takes a (void *) parameter.\r
256  *\r
257  *\r
258  * pvCallBackRef:\r
259  *\r
260  * The parameter passed into the handler function.  In many cases this will not\r
261  * be used and can be NULL.  Some times it is used to pass in a reference to\r
262  * the peripheral instance variable, so it can be accessed from inside the\r
263  * handler function.\r
264  *\r
265  * \r
266  * pdPASS is returned if the function executes successfully.  Any other value\r
267  * being returned indicates that the function did not execute correctly.\r
268  */\r
269 portBASE_TYPE xPortInstallInterruptHandler( unsigned char ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );\r
270 \r
271 \r
272 /*\r
273  * Enables the interrupt, within the interrupt controller, for the peripheral \r
274  * specified by the ucInterruptID parameter.\r
275  *\r
276  * ucInterruptID:\r
277  * \r
278  * The ID of the peripheral that will have its interrupt enabled in the\r
279  * interrupt controller.  Peripheral IDs are defined in the xparameters.h header \r
280  * file, which is itself part of the BSP project.  For example, in the official \r
281  * demo application for this port, xparameters.h defines the following IDs for \r
282  * the four possible interrupt sources:\r
283  *\r
284  * XPAR_INTC_0_UARTLITE_1_VEC_ID  -  for the UARTlite peripheral.\r
285  * XPAR_INTC_0_TMRCTR_0_VEC_ID    -  for the AXI Timer 0 peripheral.\r
286  * XPAR_INTC_0_EMACLITE_0_VEC_ID  -  for the Ethernet lite peripheral.\r
287  * XPAR_INTC_0_GPIO_1_VEC_ID      -  for the button inputs.\r
288  *\r
289  */\r
290 void vPortEnableInterrupt( unsigned char ucInterruptID );\r
291 \r
292 /*\r
293  * Disables the interrupt, within the interrupt controller, for the peripheral \r
294  * specified by the ucInterruptID parameter.\r
295  *\r
296  * ucInterruptID:\r
297  * \r
298  * The ID of the peripheral that will have its interrupt disabled in the\r
299  * interrupt controller.  Peripheral IDs are defined in the xparameters.h header \r
300  * file, which is itself part of the BSP project.  For example, in the official \r
301  * demo application for this port, xparameters.h defines the following IDs for \r
302  * the four possible interrupt sources:\r
303  *\r
304  * XPAR_INTC_0_UARTLITE_1_VEC_ID  -  for the UARTlite peripheral.\r
305  * XPAR_INTC_0_TMRCTR_0_VEC_ID    -  for the AXI Timer 0 peripheral.\r
306  * XPAR_INTC_0_EMACLITE_0_VEC_ID  -  for the Ethernet lite peripheral.\r
307  * XPAR_INTC_0_GPIO_1_VEC_ID      -  for the button inputs.\r
308  *\r
309  */\r
310 void vPortDisableInterrupt( unsigned char ucInterruptID );\r
311 \r
312 /*\r
313  * This is an application defined callback function used to install the tick\r
314  * interrupt handler.  It is provided as an application callback because the \r
315  * kernel will run on lots of different MicroBlaze and FPGA configurations - not \r
316  * all of which will have the same timer peripherals defined or available.  This \r
317  * example uses the AXI Timer 0.  If that is available on your hardware platform \r
318  * then this example callback implementation should not require modification.  \r
319  * The name of the interrupt handler that should be installed is vPortTickISR(), \r
320  * which the function below declares as an extern.\r
321  */ \r
322 void vApplicationSetupTimerInterrupt( void );\r
323 \r
324 /* \r
325  * This is an application defined callback function used to clear whichever\r
326  * interrupt was installed by the the vApplicationSetupTimerInterrupt() callback\r
327  * function - in this case the interrupt generated by the AXI timer.  It is \r
328  * provided as an application callback because the kernel will run on lots of \r
329  * different MicroBlaze and FPGA configurations - not all of which will have the \r
330  * same timer peripherals defined or available.  This example uses the AXI Timer 0.  \r
331  * If that is available on your hardware platform then this example callback \r
332  * implementation should not require modification provided the example definition\r
333  * of vApplicationSetupTimerInterrupt() is also not modified. \r
334  */\r
335 void vApplicationClearTimerInterrupt( void );\r
336 \r
337 /*\r
338  * vPortExceptionsInstallHandlers() is only available when the MicroBlaze\r
339  * is configured to include exception functionality, and \r
340  * configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h.\r
341  *\r
342  * vPortExceptionsInstallHandlers() installs the FreeRTOS exception handler\r
343  * for every possible exception cause.  \r
344  *\r
345  * vPortExceptionsInstallHandlers() can be called explicitly from application\r
346  * code.  After that is done, the default FreeRTOS exception handler that will\r
347  * have been installed can be replaced for any specific exception cause by using \r
348  * the standard Xilinx library function microblaze_register_exception_handler().\r
349  *\r
350  * If vPortExceptionsInstallHandlers() is not called explicitly by the \r
351  * application, it will be called automatically by the kernel the first time\r
352  * xPortInstallInterruptHandler() is called.  At that time, any exception \r
353  * handlers that may have already been installed will be replaced.\r
354  *\r
355  * See the description of vApplicationExceptionRegisterDump() for information\r
356  * on the processing performed by the FreeRTOS exception handler.\r
357  */\r
358 void vPortExceptionsInstallHandlers( void );\r
359 \r
360 /*\r
361  * The FreeRTOS exception handler fills an xPortRegisterDump structure (defined \r
362  * in portmacro.h) with the MicroBlaze context, as it was at the time the \r
363  * exception occurred.  The exception handler then calls\r
364  * vApplicationExceptionRegisterDump(), passing in the completed\r
365  * xPortRegisterDump structure as its parameter.\r
366  *\r
367  * The FreeRTOS kernel provides its own implementation of\r
368  * vApplicationExceptionRegisterDump(), but the kernel provided implementation \r
369  * is declared as being 'weak'.  The weak definition allows the application \r
370  * writer to provide their own implementation, should they wish to use the \r
371  * register dump information.  For example, an implementation could be provided\r
372  * that wrote the register dump data to a display, or a UART port.\r
373  */\r
374 void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump );\r
375 \r
376 \r
377 #ifdef __cplusplus\r
378 }\r
379 #endif\r
380 \r
381 #endif /* PORTMACRO_H */\r
382 \r