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 long
\r
82 #define portBASE_TYPE long
\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
99 /*-----------------------------------------------------------*/
\r
101 /* Critical section macros. */
\r
102 void vPortEnterCritical( void );
\r
103 void vPortExitCritical( void );
\r
104 #define portENTER_CRITICAL() { \
\r
105 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
106 microblaze_disable_interrupts(); \
\r
107 uxCriticalNesting++; \
\r
110 #define portEXIT_CRITICAL() { \
\r
111 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
112 /* Interrupts are disabled, so we can */ \
\r
113 /* access the variable directly. */ \
\r
114 uxCriticalNesting--; \
\r
115 if( uxCriticalNesting == 0 ) \
\r
117 /* The nesting has unwound and we \
\r
118 can enable interrupts again. */ \
\r
119 portENABLE_INTERRUPTS(); \
\r
123 /*-----------------------------------------------------------*/
\r
125 /* The yield macro maps directly to the vPortYield() function. */
\r
126 void vPortYield( void );
\r
127 #define portYIELD() vPortYield()
\r
129 /* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead
\r
130 sets a flag to say that a yield has been requested. The interrupt exit code
\r
131 then checks this flag, and calls vTaskSwitchContext() before restoring a task
\r
132 context, if the flag is not false. This is done to prevent multiple calls to
\r
133 vTaskSwitchContext() being made from a single interrupt, as a single interrupt
\r
134 can result in multiple peripherals being serviced. */
\r
135 extern volatile unsigned long ulTaskSwitchRequested;
\r
136 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1
\r
137 /*-----------------------------------------------------------*/
\r
139 /* Hardware specifics. */
\r
140 #define portBYTE_ALIGNMENT 4
\r
141 #define portSTACK_GROWTH ( -1 )
\r
142 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
\r
143 #define portNOP() asm volatile ( "NOP" )
\r
144 /*-----------------------------------------------------------*/
\r
146 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
147 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
148 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
149 /*-----------------------------------------------------------*/
\r
151 /* The following structure is used by the FreeRTOS exception handler. It is
\r
152 filled with the MicroBlaze context as it was at the time the exception occurred.
\r
153 This is done as an aid to debugging exception occurrences. */
\r
154 typedef struct PORT_REGISTER_DUMP
\r
156 /* The following structure members hold the values of the MicroBlaze
\r
157 registers at the time the exception was raised. */
\r
158 unsigned long ulR1_SP;
\r
159 unsigned long ulR2_small_data_area;
\r
160 unsigned long ulR3;
\r
161 unsigned long ulR4;
\r
162 unsigned long ulR5;
\r
163 unsigned long ulR6;
\r
164 unsigned long ulR7;
\r
165 unsigned long ulR8;
\r
166 unsigned long ulR9;
\r
167 unsigned long ulR10;
\r
168 unsigned long ulR11;
\r
169 unsigned long ulR12;
\r
170 unsigned long ulR13_read_write_small_data_area;
\r
171 unsigned long ulR14_return_address_from_interrupt;
\r
172 unsigned long ulR15_return_address_from_subroutine;
\r
173 unsigned long ulR16_return_address_from_trap;
\r
174 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
175 unsigned long ulR18;
\r
176 unsigned long ulR19;
\r
177 unsigned long ulR20;
\r
178 unsigned long ulR21;
\r
179 unsigned long ulR22;
\r
180 unsigned long ulR23;
\r
181 unsigned long ulR24;
\r
182 unsigned long ulR25;
\r
183 unsigned long ulR26;
\r
184 unsigned long ulR27;
\r
185 unsigned long ulR28;
\r
186 unsigned long ulR29;
\r
187 unsigned long ulR30;
\r
188 unsigned long ulR31;
\r
189 unsigned long ulPC;
\r
190 unsigned long ulESR;
\r
191 unsigned long ulMSR;
\r
192 unsigned long ulEAR;
\r
193 unsigned long ulFSR;
\r
194 unsigned long ulEDR;
\r
196 /* A human readable description of the exception cause. The strings used
\r
197 are the same as the #define constant names found in the
\r
198 microblaze_exceptions_i.h header file */
\r
199 signed char *pcExceptionCause;
\r
201 /* The human readable name of the task that was running at the time the
\r
202 exception occurred. This is the name that was given to the task when the
\r
203 task was created using the FreeRTOS xTaskCreate() API function. */
\r
204 signed char *pcCurrentTaskName;
\r
206 /* The handle of the task that was running a the time the exception
\r
208 void * xCurrentTaskHandle;
\r
210 } xPortRegisterDump;
\r
214 * Installs pxHandler as the interrupt handler for the peripheral specified by
\r
215 * the ucInterruptID parameter.
\r
219 * The ID of the peripheral that will have pxHandler assigned as its interrupt
\r
220 * handler. Peripheral IDs are defined in the xparameters.h header file, which
\r
221 * is itself part of the BSP project. For example, in the official demo
\r
222 * application for this port, xparameters.h defines the following IDs for the
\r
223 * four possible interrupt sources:
\r
225 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
226 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
227 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
228 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
233 * A pointer to the interrupt handler function itself. This must be a void
\r
234 * function that takes a (void *) parameter.
\r
239 * The parameter passed into the handler function. In many cases this will not
\r
240 * be used and can be NULL. Some times it is used to pass in a reference to
\r
241 * the peripheral instance variable, so it can be accessed from inside the
\r
242 * handler function.
\r
245 * pdPASS is returned if the function executes successfully. Any other value
\r
246 * being returned indicates that the function did not execute correctly.
\r
248 portBASE_TYPE xPortInstallInterruptHandler( unsigned char ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );
\r
252 * Enables the interrupt, within the interrupt controller, for the peripheral
\r
253 * specified by the ucInterruptID parameter.
\r
257 * The ID of the peripheral that will have its interrupt enabled in the
\r
258 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
259 * file, which is itself part of the BSP project. For example, in the official
\r
260 * demo application for this port, xparameters.h defines the following IDs for
\r
261 * the four possible interrupt sources:
\r
263 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
264 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
265 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
266 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
269 void vPortEnableInterrupt( unsigned char ucInterruptID );
\r
272 * Disables the interrupt, within the interrupt controller, for the peripheral
\r
273 * specified by the ucInterruptID parameter.
\r
277 * The ID of the peripheral that will have its interrupt disabled in the
\r
278 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
279 * file, which is itself part of the BSP project. For example, in the official
\r
280 * demo application for this port, xparameters.h defines the following IDs for
\r
281 * the four possible interrupt sources:
\r
283 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
284 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
285 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
286 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
289 void vPortDisableInterrupt( unsigned char ucInterruptID );
\r
292 * This is an application defined callback function used to install the tick
\r
293 * interrupt handler. It is provided as an application callback because the
\r
294 * kernel will run on lots of different MicroBlaze and FPGA configurations - not
\r
295 * all of which will have the same timer peripherals defined or available. This
\r
296 * example uses the AXI Timer 0. If that is available on your hardware platform
\r
297 * then this example callback implementation should not require modification.
\r
298 * The name of the interrupt handler that should be installed is vPortTickISR(),
\r
299 * which the function below declares as an extern.
\r
301 void vApplicationSetupTimerInterrupt( void );
\r
304 * This is an application defined callback function used to clear whichever
\r
305 * interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
\r
306 * function - in this case the interrupt generated by the AXI timer. It is
\r
307 * provided as an application callback because the kernel will run on lots of
\r
308 * different MicroBlaze and FPGA configurations - not all of which will have the
\r
309 * same timer peripherals defined or available. This example uses the AXI Timer 0.
\r
310 * If that is available on your hardware platform then this example callback
\r
311 * implementation should not require modification provided the example definition
\r
312 * of vApplicationSetupTimerInterrupt() is also not modified.
\r
314 void vApplicationClearTimerInterrupt( void );
\r
317 * vPortExceptionsInstallHandlers() is only available when the MicroBlaze
\r
318 * is configured to include exception functionality, and
\r
319 * configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h.
\r
321 * vPortExceptionsInstallHandlers() installs the FreeRTOS exception handler
\r
322 * for every possible exception cause.
\r
324 * vPortExceptionsInstallHandlers() can be called explicitly from application
\r
325 * code. After that is done, the default FreeRTOS exception handler that will
\r
326 * have been installed can be replaced for any specific exception cause by using
\r
327 * the standard Xilinx library function microblaze_register_exception_handler().
\r
329 * If vPortExceptionsInstallHandlers() is not called explicitly by the
\r
330 * application, it will be called automatically by the kernel the first time
\r
331 * xPortInstallInterruptHandler() is called. At that time, any exception
\r
332 * handlers that may have already been installed will be replaced.
\r
334 * See the description of vApplicationExceptionRegisterDump() for information
\r
335 * on the processing performed by the FreeRTOS exception handler.
\r
337 void vPortExceptionsInstallHandlers( void );
\r
340 * The FreeRTOS exception handler fills an xPortRegisterDump structure (defined
\r
341 * in portmacro.h) with the MicroBlaze context, as it was at the time the
\r
342 * exception occurred. The exception handler then calls
\r
343 * vApplicationExceptionRegisterDump(), passing in the completed
\r
344 * xPortRegisterDump structure as its parameter.
\r
346 * The FreeRTOS kernel provides its own implementation of
\r
347 * vApplicationExceptionRegisterDump(), but the kernel provided implementation
\r
348 * is declared as being 'weak'. The weak definition allows the application
\r
349 * writer to provide their own implementation, should they wish to use the
\r
350 * register dump information. For example, an implementation could be provided
\r
351 * that wrote the register dump data to a display, or a UART port.
\r
353 void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump );
\r
360 #endif /* PORTMACRO_H */
\r