2 FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\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
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\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
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
62 #include <mb_interface.h>
\r
63 #include <xparameters.h>
\r
65 /*-----------------------------------------------------------
\r
66 * Port specific definitions.
\r
68 * The settings in this file configure FreeRTOS correctly for the
\r
69 * given hardware and compiler.
\r
71 * These settings should not be altered.
\r
72 *-----------------------------------------------------------
\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 portLONG
\r
82 #define portBASE_TYPE portLONG
\r
84 #if( configUSE_16_BIT_TICKS == 1 )
\r
85 typedef unsigned portSHORT portTickType;
\r
86 #define portMAX_DELAY ( portTickType ) 0xffff
\r
88 typedef unsigned portLONG portTickType;
\r
89 #define portMAX_DELAY ( portTickType ) 0xffffffff
\r
91 /*-----------------------------------------------------------*/
\r
93 /* Interrupt control macros and functions. */
\r
94 void microblaze_disable_interrupts( void );
\r
95 void microblaze_enable_interrupts( void );
\r
96 #define portDISABLE_INTERRUPTS() microblaze_disable_interrupts()
\r
97 #define portENABLE_INTERRUPTS() microblaze_enable_interrupts()
\r
100 * Installs pxHandler as the interrupt handler for the peripheral specified by
\r
101 * the ucInterruptID parameter.
\r
105 * The ID of the peripheral that will have pxHandler assigned as its interrupt
\r
106 * handler. Peripheral IDs are defined in the xparameters.h header file, which
\r
107 * is itself part of the BSP project. For example, in the official demo
\r
108 * application for this port, xparameters.h defines the following IDs for the
\r
109 * four possible interrupt sources:
\r
111 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
112 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
113 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
114 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
119 * A pointer to the interrupt handler function itself. This must be a void
\r
120 * function that takes a (void *) parameter.
\r
125 * The parameter passed into the handler function. In many cases this will not
\r
126 * be used and can be NULL. Some times it is used to pass in a reference to
\r
127 * the peripheral instance variable, so it can be accessed from inside the
\r
128 * handler function.
\r
131 * pdPASS is returned if the function executes successfully. Any other value
\r
132 * being returned indicates that the function did not execute correctly.
\r
134 portBASE_TYPE xPortInstallInterruptHandler( unsigned char ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );
\r
138 * Enables the interrupt, within the interrupt controller, for the peripheral
\r
139 * specified by the ucInterruptID parameter.
\r
143 * The ID of the peripheral that will have its interrupt enabled in the
\r
144 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
145 * file, which is itself part of the BSP project. For example, in the official
\r
146 * demo application for this port, xparameters.h defines the following IDs for
\r
147 * the four possible interrupt sources:
\r
149 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
150 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
151 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
152 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
155 void vPortEnableInterrupt( unsigned char ucInterruptID );
\r
158 * Disables the interrupt, within the interrupt controller, for the peripheral
\r
159 * specified by the ucInterruptID parameter.
\r
163 * The ID of the peripheral that will have its interrupt disabled in the
\r
164 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
165 * file, which is itself part of the BSP project. For example, in the official
\r
166 * demo application for this port, xparameters.h defines the following IDs for
\r
167 * the four possible interrupt sources:
\r
169 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
170 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
171 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
172 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
175 void vPortDisableInterrupt( unsigned char ucInterruptID );
\r
178 * This is an application defined callback function used to install the tick
\r
179 * interrupt handler. It is provided as an application callback because the
\r
180 * kernel will run on lots of different MicroBlaze and FPGA configurations - not
\r
181 * all of which will have the same timer peripherals defined or available. This
\r
182 * example uses the AXI Timer 0. If that is available on your hardware platform
\r
183 * then this example callback implementation should not require modification.
\r
184 * The name of the interrupt handler that should be installed is vPortTickISR(),
\r
185 * which the function below declares as an extern.
\r
187 void vApplicationSetupTimerInterrupt( void );
\r
190 * This is an application defined callback function used to clear whichever
\r
191 * interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
\r
192 * function - in this case the interrupt generated by the AXI timer. It is
\r
193 * provided as an application callback because the kernel will run on lots of
\r
194 * different MicroBlaze and FPGA configurations - not all of which will have the
\r
195 * same timer peripherals defined or available. This example uses the AXI Timer 0.
\r
196 * If that is available on your hardware platform then this example callback
\r
197 * implementation should not require modification provided the example definition
\r
198 * of vApplicationSetupTimerInterrupt() is also not modified.
\r
200 void vApplicationClearTimerInterrupt( void )
\r
203 * vPortExceptionsInstallHandlers() is only available when the MicroBlaze
\r
204 * is configured to include exception functionality, and
\r
205 * configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h.
\r
207 * vPortExceptionsInstallHandlers() installs the FreeRTOS exception handler
\r
208 * for every possible exception cause.
\r
210 * vPortExceptionsInstallHandlers() can be called explicitly from application
\r
211 * code. After that is done, the default FreeRTOS exception handler that will
\r
212 * have been installed can be replaced for any specific exception cause by using
\r
213 * the standard Xilinx library function microblaze_register_exception_handler().
\r
215 * If vPortExceptionsInstallHandlers() is not called explicitly by the
\r
216 * application, it will be called automatically by the kernel the first time
\r
217 * xPortInstallInterruptHandler() is called. At that time, any exception
\r
218 * handlers that may have already been installed will be replaced.
\r
220 * See the description of vApplicationExceptionRegisterDump() for information
\r
221 * on the processing performed by the FreeRTOS exception handler.
\r
223 void vPortExceptionsInstallHandlers( void );
\r
226 * The FreeRTOS exception handler fills an xPortRegisterDump structure (defined
\r
227 * in portmacro.h) with the MicroBlaze context, as it was at the time the
\r
228 * exception occurred. The exception handler then calls
\r
229 * vApplicationExceptionRegisterDump(), passing in the completed
\r
230 * xPortRegisterDump structure as its parameter.
\r
232 * The FreeRTOS kernel provides its own implementation of
\r
233 * vApplicationExceptionRegisterDump(), but the kernel provided implementation
\r
234 * is declared as being 'weak'. The weak definition allows the application
\r
235 * writer to provide their own implementation, should they wish to use the
\r
236 * register dump information. For example, an implementation could be provided
\r
237 * that wrote the register dump data to a display, or a UART port.
\r
239 void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump );
\r
242 /*-----------------------------------------------------------*/
\r
244 /* Critical section macros. */
\r
245 void vPortEnterCritical( void );
\r
246 void vPortExitCritical( void );
\r
247 #define portENTER_CRITICAL() { \
\r
248 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
249 microblaze_disable_interrupts(); \
\r
250 uxCriticalNesting++; \
\r
253 #define portEXIT_CRITICAL() { \
\r
254 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
255 /* Interrupts are disabled, so we can */ \
\r
256 /* access the variable directly. */ \
\r
257 uxCriticalNesting--; \
\r
258 if( uxCriticalNesting == 0 ) \
\r
260 /* The nesting has unwound and we \
\r
261 can enable interrupts again. */ \
\r
262 portENABLE_INTERRUPTS(); \
\r
266 /*-----------------------------------------------------------*/
\r
268 /* The yield macro maps directly to the vPortYield() function. */
\r
269 void vPortYield( void );
\r
270 #define portYIELD() vPortYield()
\r
272 /* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead
\r
273 sets a flag to say that a yield has been requested. The interrupt exit code
\r
274 then checks this flag, and calls vTaskSwitchContext() before restoring a task
\r
275 context, if the flag is not false. This is done to prevent multiple calls to
\r
276 vTaskSwitchContext() being made from a single interrupt, as a single interrupt
\r
277 can result in multiple peripherals being serviced. */
\r
278 extern volatile unsigned long ulTaskSwitchRequested;
\r
279 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1
\r
280 /*-----------------------------------------------------------*/
\r
282 /* Hardware specifics. */
\r
283 #define portBYTE_ALIGNMENT 4
\r
284 #define portSTACK_GROWTH ( -1 )
\r
285 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
\r
286 #define portNOP() asm volatile ( "NOP" )
\r
287 /*-----------------------------------------------------------*/
\r
289 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
290 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
291 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
292 /*-----------------------------------------------------------*/
\r
294 /* The following structure is used by the FreeRTOS exception handler. It is
\r
295 filled with the MicroBlaze context as it was at the time the exception occurred.
\r
296 This is done as an aid to debugging exception occurrences. */
\r
297 typedef struct PORT_REGISTER_DUMP
\r
299 /* The following structure members hold the values of the MicroBlaze
\r
300 registers at the time the exception was raised. */
\r
301 unsigned long ulR1_SP;
\r
302 unsigned long ulR2_small_data_area;
\r
303 unsigned long ulR3;
\r
304 unsigned long ulR4;
\r
305 unsigned long ulR5;
\r
306 unsigned long ulR6;
\r
307 unsigned long ulR7;
\r
308 unsigned long ulR8;
\r
309 unsigned long ulR9;
\r
310 unsigned long ulR10;
\r
311 unsigned long ulR11;
\r
312 unsigned long ulR12;
\r
313 unsigned long ulR13_read_write_small_data_area;
\r
314 unsigned long ulR14_return_address_from_interrupt;
\r
315 unsigned long ulR15_return_address_from_subroutine;
\r
316 unsigned long ulR16_return_address_from_trap;
\r
317 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
318 unsigned long ulR18;
\r
319 unsigned long ulR19;
\r
320 unsigned long ulR20;
\r
321 unsigned long ulR21;
\r
322 unsigned long ulR22;
\r
323 unsigned long ulR23;
\r
324 unsigned long ulR24;
\r
325 unsigned long ulR25;
\r
326 unsigned long ulR26;
\r
327 unsigned long ulR27;
\r
328 unsigned long ulR28;
\r
329 unsigned long ulR29;
\r
330 unsigned long ulR30;
\r
331 unsigned long ulR31;
\r
332 unsigned long ulPC;
\r
333 unsigned long ulESR;
\r
334 unsigned long ulMSR;
\r
335 unsigned long ulEAR;
\r
336 unsigned long ulFSR;
\r
337 unsigned long ulEDR;
\r
339 /* A human readable description of the exception cause. The strings used
\r
340 are the same as the #define constant names found in the
\r
341 microblaze_exceptions_i.h header file */
\r
342 signed char *pcExceptionCause;
\r
344 /* The human readable name of the task that was running at the time the
\r
345 exception occurred. This is the name that was given to the task when the
\r
346 task was created using the FreeRTOS xTaskCreate() API function. */
\r
347 signed char *pcCurrentTaskName;
\r
349 /* The handle of the task that was running a the time the exception
\r
351 void * xCurrentTaskHandle;
\r
353 } xPortRegisterDump;
\r
359 #endif /* PORTMACRO_H */
\r