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