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