2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\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
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\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
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\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 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
77 #include <mb_interface.h>
\r
78 #include <xparameters.h>
\r
80 /*-----------------------------------------------------------
\r
81 * Port specific definitions.
\r
83 * The settings in this file configure FreeRTOS correctly for the
\r
84 * given hardware and compiler.
\r
86 * These settings should not be altered.
\r
87 *-----------------------------------------------------------
\r
90 /* Type definitions. */
\r
91 #define portCHAR char
\r
92 #define portFLOAT float
\r
93 #define portDOUBLE double
\r
94 #define portLONG long
\r
95 #define portSHORT short
\r
96 #define portSTACK_TYPE unsigned long
\r
97 #define portBASE_TYPE long
\r
99 #if( configUSE_16_BIT_TICKS == 1 )
\r
100 typedef unsigned portSHORT portTickType;
\r
101 #define portMAX_DELAY ( portTickType ) 0xffff
\r
103 typedef unsigned portLONG portTickType;
\r
104 #define portMAX_DELAY ( portTickType ) 0xffffffff
\r
106 /*-----------------------------------------------------------*/
\r
108 /* Interrupt control macros and functions. */
\r
109 void microblaze_disable_interrupts( void );
\r
110 void microblaze_enable_interrupts( void );
\r
111 #define portDISABLE_INTERRUPTS() microblaze_disable_interrupts()
\r
112 #define portENABLE_INTERRUPTS() microblaze_enable_interrupts()
\r
114 /*-----------------------------------------------------------*/
\r
116 /* Critical section macros. */
\r
117 void vPortEnterCritical( void );
\r
118 void vPortExitCritical( void );
\r
119 #define portENTER_CRITICAL() { \
\r
120 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
121 microblaze_disable_interrupts(); \
\r
122 uxCriticalNesting++; \
\r
125 #define portEXIT_CRITICAL() { \
\r
126 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
127 /* Interrupts are disabled, so we can */ \
\r
128 /* access the variable directly. */ \
\r
129 uxCriticalNesting--; \
\r
130 if( uxCriticalNesting == 0 ) \
\r
132 /* The nesting has unwound and we \
\r
133 can enable interrupts again. */ \
\r
134 portENABLE_INTERRUPTS(); \
\r
138 /*-----------------------------------------------------------*/
\r
140 /* The yield macro maps directly to the vPortYield() function. */
\r
141 void vPortYield( void );
\r
142 #define portYIELD() vPortYield()
\r
144 /* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead
\r
145 sets a flag to say that a yield has been requested. The interrupt exit code
\r
146 then checks this flag, and calls vTaskSwitchContext() before restoring a task
\r
147 context, if the flag is not false. This is done to prevent multiple calls to
\r
148 vTaskSwitchContext() being made from a single interrupt, as a single interrupt
\r
149 can result in multiple peripherals being serviced. */
\r
150 extern volatile unsigned long ulTaskSwitchRequested;
\r
151 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1
\r
152 /*-----------------------------------------------------------*/
\r
154 /* Hardware specifics. */
\r
155 #define portBYTE_ALIGNMENT 4
\r
156 #define portSTACK_GROWTH ( -1 )
\r
157 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
\r
158 #define portNOP() asm volatile ( "NOP" )
\r
159 /*-----------------------------------------------------------*/
\r
161 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
162 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
163 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
164 /*-----------------------------------------------------------*/
\r
166 /* The following structure is used by the FreeRTOS exception handler. It is
\r
167 filled with the MicroBlaze context as it was at the time the exception occurred.
\r
168 This is done as an aid to debugging exception occurrences. */
\r
169 typedef struct PORT_REGISTER_DUMP
\r
171 /* The following structure members hold the values of the MicroBlaze
\r
172 registers at the time the exception was raised. */
\r
173 unsigned long ulR1_SP;
\r
174 unsigned long ulR2_small_data_area;
\r
175 unsigned long ulR3;
\r
176 unsigned long ulR4;
\r
177 unsigned long ulR5;
\r
178 unsigned long ulR6;
\r
179 unsigned long ulR7;
\r
180 unsigned long ulR8;
\r
181 unsigned long ulR9;
\r
182 unsigned long ulR10;
\r
183 unsigned long ulR11;
\r
184 unsigned long ulR12;
\r
185 unsigned long ulR13_read_write_small_data_area;
\r
186 unsigned long ulR14_return_address_from_interrupt;
\r
187 unsigned long ulR15_return_address_from_subroutine;
\r
188 unsigned long ulR16_return_address_from_trap;
\r
189 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
190 unsigned long ulR18;
\r
191 unsigned long ulR19;
\r
192 unsigned long ulR20;
\r
193 unsigned long ulR21;
\r
194 unsigned long ulR22;
\r
195 unsigned long ulR23;
\r
196 unsigned long ulR24;
\r
197 unsigned long ulR25;
\r
198 unsigned long ulR26;
\r
199 unsigned long ulR27;
\r
200 unsigned long ulR28;
\r
201 unsigned long ulR29;
\r
202 unsigned long ulR30;
\r
203 unsigned long ulR31;
\r
204 unsigned long ulPC;
\r
205 unsigned long ulESR;
\r
206 unsigned long ulMSR;
\r
207 unsigned long ulEAR;
\r
208 unsigned long ulFSR;
\r
209 unsigned long ulEDR;
\r
211 /* A human readable description of the exception cause. The strings used
\r
212 are the same as the #define constant names found in the
\r
213 microblaze_exceptions_i.h header file */
\r
214 signed char *pcExceptionCause;
\r
216 /* The human readable name of the task that was running at the time the
\r
217 exception occurred. This is the name that was given to the task when the
\r
218 task was created using the FreeRTOS xTaskCreate() API function. */
\r
219 signed char *pcCurrentTaskName;
\r
221 /* The handle of the task that was running a the time the exception
\r
223 void * xCurrentTaskHandle;
\r
225 } xPortRegisterDump;
\r
229 * Installs pxHandler as the interrupt handler for the peripheral specified by
\r
230 * the ucInterruptID parameter.
\r
234 * The ID of the peripheral that will have pxHandler assigned as its interrupt
\r
235 * handler. Peripheral IDs are defined in the xparameters.h header file, which
\r
236 * is itself part of the BSP project. For example, in the official demo
\r
237 * application for this port, xparameters.h defines the following IDs for the
\r
238 * four possible interrupt sources:
\r
240 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
241 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
242 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
243 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
248 * A pointer to the interrupt handler function itself. This must be a void
\r
249 * function that takes a (void *) parameter.
\r
254 * The parameter passed into the handler function. In many cases this will not
\r
255 * be used and can be NULL. Some times it is used to pass in a reference to
\r
256 * the peripheral instance variable, so it can be accessed from inside the
\r
257 * handler function.
\r
260 * pdPASS is returned if the function executes successfully. Any other value
\r
261 * being returned indicates that the function did not execute correctly.
\r
263 portBASE_TYPE xPortInstallInterruptHandler( unsigned char ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );
\r
267 * Enables the interrupt, within the interrupt controller, for the peripheral
\r
268 * specified by the ucInterruptID parameter.
\r
272 * The ID of the peripheral that will have its interrupt enabled in the
\r
273 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
274 * file, which is itself part of the BSP project. For example, in the official
\r
275 * demo application for this port, xparameters.h defines the following IDs for
\r
276 * the four possible interrupt sources:
\r
278 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
279 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
280 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
281 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
284 void vPortEnableInterrupt( unsigned char ucInterruptID );
\r
287 * Disables the interrupt, within the interrupt controller, for the peripheral
\r
288 * specified by the ucInterruptID parameter.
\r
292 * The ID of the peripheral that will have its interrupt disabled in the
\r
293 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
294 * file, which is itself part of the BSP project. For example, in the official
\r
295 * demo application for this port, xparameters.h defines the following IDs for
\r
296 * the four possible interrupt sources:
\r
298 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
299 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
300 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
301 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
304 void vPortDisableInterrupt( unsigned char ucInterruptID );
\r
307 * This is an application defined callback function used to install the tick
\r
308 * interrupt handler. It is provided as an application callback because the
\r
309 * kernel will run on lots of different MicroBlaze and FPGA configurations - not
\r
310 * all of which will have the same timer peripherals defined or available. This
\r
311 * example uses the AXI Timer 0. If that is available on your hardware platform
\r
312 * then this example callback implementation should not require modification.
\r
313 * The name of the interrupt handler that should be installed is vPortTickISR(),
\r
314 * which the function below declares as an extern.
\r
316 void vApplicationSetupTimerInterrupt( void );
\r
319 * This is an application defined callback function used to clear whichever
\r
320 * interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
\r
321 * function - in this case the interrupt generated by the AXI timer. It is
\r
322 * provided as an application callback because the kernel will run on lots of
\r
323 * different MicroBlaze and FPGA configurations - not all of which will have the
\r
324 * same timer peripherals defined or available. This example uses the AXI Timer 0.
\r
325 * If that is available on your hardware platform then this example callback
\r
326 * implementation should not require modification provided the example definition
\r
327 * of vApplicationSetupTimerInterrupt() is also not modified.
\r
329 void vApplicationClearTimerInterrupt( void );
\r
332 * vPortExceptionsInstallHandlers() is only available when the MicroBlaze
\r
333 * is configured to include exception functionality, and
\r
334 * configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h.
\r
336 * vPortExceptionsInstallHandlers() installs the FreeRTOS exception handler
\r
337 * for every possible exception cause.
\r
339 * vPortExceptionsInstallHandlers() can be called explicitly from application
\r
340 * code. After that is done, the default FreeRTOS exception handler that will
\r
341 * have been installed can be replaced for any specific exception cause by using
\r
342 * the standard Xilinx library function microblaze_register_exception_handler().
\r
344 * If vPortExceptionsInstallHandlers() is not called explicitly by the
\r
345 * application, it will be called automatically by the kernel the first time
\r
346 * xPortInstallInterruptHandler() is called. At that time, any exception
\r
347 * handlers that may have already been installed will be replaced.
\r
349 * See the description of vApplicationExceptionRegisterDump() for information
\r
350 * on the processing performed by the FreeRTOS exception handler.
\r
352 void vPortExceptionsInstallHandlers( void );
\r
355 * The FreeRTOS exception handler fills an xPortRegisterDump structure (defined
\r
356 * in portmacro.h) with the MicroBlaze context, as it was at the time the
\r
357 * exception occurred. The exception handler then calls
\r
358 * vApplicationExceptionRegisterDump(), passing in the completed
\r
359 * xPortRegisterDump structure as its parameter.
\r
361 * The FreeRTOS kernel provides its own implementation of
\r
362 * vApplicationExceptionRegisterDump(), but the kernel provided implementation
\r
363 * is declared as being 'weak'. The weak definition allows the application
\r
364 * writer to provide their own implementation, should they wish to use the
\r
365 * register dump information. For example, an implementation could be provided
\r
366 * that wrote the register dump data to a display, or a UART port.
\r
368 void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump );
\r
375 #endif /* PORTMACRO_H */
\r