2 FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\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
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
19 ***************************************************************************
\r
21 This file is part of the FreeRTOS distribution.
\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
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
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
39 ***************************************************************************
\r
41 * Having a problem? Start by reading the FAQ "My application does *
\r
42 * not run, what could be wrong?" *
\r
44 * http://www.FreeRTOS.org/FAQHelp.html *
\r
46 ***************************************************************************
\r
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
49 license and Real Time Engineers Ltd. contact details.
\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
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
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
74 #include <mb_interface.h>
\r
75 #include <xparameters.h>
\r
77 /*-----------------------------------------------------------
\r
78 * Port specific definitions.
\r
80 * The settings in this file configure FreeRTOS correctly for the
\r
81 * given hardware and compiler.
\r
83 * These settings should not be altered.
\r
84 *-----------------------------------------------------------
\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 unsigned long
\r
94 #define portBASE_TYPE long
\r
96 #if( configUSE_16_BIT_TICKS == 1 )
\r
97 typedef unsigned portSHORT portTickType;
\r
98 #define portMAX_DELAY ( portTickType ) 0xffff
\r
100 typedef unsigned portLONG portTickType;
\r
101 #define portMAX_DELAY ( portTickType ) 0xffffffff
\r
103 /*-----------------------------------------------------------*/
\r
105 /* Interrupt control macros and functions. */
\r
106 void microblaze_disable_interrupts( void );
\r
107 void microblaze_enable_interrupts( void );
\r
108 #define portDISABLE_INTERRUPTS() microblaze_disable_interrupts()
\r
109 #define portENABLE_INTERRUPTS() microblaze_enable_interrupts()
\r
111 /*-----------------------------------------------------------*/
\r
113 /* Critical section macros. */
\r
114 void vPortEnterCritical( void );
\r
115 void vPortExitCritical( void );
\r
116 #define portENTER_CRITICAL() { \
\r
117 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
118 microblaze_disable_interrupts(); \
\r
119 uxCriticalNesting++; \
\r
122 #define portEXIT_CRITICAL() { \
\r
123 extern volatile unsigned portBASE_TYPE uxCriticalNesting; \
\r
124 /* Interrupts are disabled, so we can */ \
\r
125 /* access the variable directly. */ \
\r
126 uxCriticalNesting--; \
\r
127 if( uxCriticalNesting == 0 ) \
\r
129 /* The nesting has unwound and we \
\r
130 can enable interrupts again. */ \
\r
131 portENABLE_INTERRUPTS(); \
\r
135 /*-----------------------------------------------------------*/
\r
137 /* The yield macro maps directly to the vPortYield() function. */
\r
138 void vPortYield( void );
\r
139 #define portYIELD() vPortYield()
\r
141 /* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead
\r
142 sets a flag to say that a yield has been requested. The interrupt exit code
\r
143 then checks this flag, and calls vTaskSwitchContext() before restoring a task
\r
144 context, if the flag is not false. This is done to prevent multiple calls to
\r
145 vTaskSwitchContext() being made from a single interrupt, as a single interrupt
\r
146 can result in multiple peripherals being serviced. */
\r
147 extern volatile unsigned long ulTaskSwitchRequested;
\r
148 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1
\r
149 /*-----------------------------------------------------------*/
\r
151 /* Hardware specifics. */
\r
152 #define portBYTE_ALIGNMENT 4
\r
153 #define portSTACK_GROWTH ( -1 )
\r
154 #define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
\r
155 #define portNOP() asm volatile ( "NOP" )
\r
156 /*-----------------------------------------------------------*/
\r
158 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
159 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
160 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
161 /*-----------------------------------------------------------*/
\r
163 /* The following structure is used by the FreeRTOS exception handler. It is
\r
164 filled with the MicroBlaze context as it was at the time the exception occurred.
\r
165 This is done as an aid to debugging exception occurrences. */
\r
166 typedef struct PORT_REGISTER_DUMP
\r
168 /* The following structure members hold the values of the MicroBlaze
\r
169 registers at the time the exception was raised. */
\r
170 unsigned long ulR1_SP;
\r
171 unsigned long ulR2_small_data_area;
\r
172 unsigned long ulR3;
\r
173 unsigned long ulR4;
\r
174 unsigned long ulR5;
\r
175 unsigned long ulR6;
\r
176 unsigned long ulR7;
\r
177 unsigned long ulR8;
\r
178 unsigned long ulR9;
\r
179 unsigned long ulR10;
\r
180 unsigned long ulR11;
\r
181 unsigned long ulR12;
\r
182 unsigned long ulR13_read_write_small_data_area;
\r
183 unsigned long ulR14_return_address_from_interrupt;
\r
184 unsigned long ulR15_return_address_from_subroutine;
\r
185 unsigned long ulR16_return_address_from_trap;
\r
186 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
187 unsigned long ulR18;
\r
188 unsigned long ulR19;
\r
189 unsigned long ulR20;
\r
190 unsigned long ulR21;
\r
191 unsigned long ulR22;
\r
192 unsigned long ulR23;
\r
193 unsigned long ulR24;
\r
194 unsigned long ulR25;
\r
195 unsigned long ulR26;
\r
196 unsigned long ulR27;
\r
197 unsigned long ulR28;
\r
198 unsigned long ulR29;
\r
199 unsigned long ulR30;
\r
200 unsigned long ulR31;
\r
201 unsigned long ulPC;
\r
202 unsigned long ulESR;
\r
203 unsigned long ulMSR;
\r
204 unsigned long ulEAR;
\r
205 unsigned long ulFSR;
\r
206 unsigned long ulEDR;
\r
208 /* A human readable description of the exception cause. The strings used
\r
209 are the same as the #define constant names found in the
\r
210 microblaze_exceptions_i.h header file */
\r
211 signed char *pcExceptionCause;
\r
213 /* The human readable name of the task that was running at the time the
\r
214 exception occurred. This is the name that was given to the task when the
\r
215 task was created using the FreeRTOS xTaskCreate() API function. */
\r
216 signed char *pcCurrentTaskName;
\r
218 /* The handle of the task that was running a the time the exception
\r
220 void * xCurrentTaskHandle;
\r
222 } xPortRegisterDump;
\r
226 * Installs pxHandler as the interrupt handler for the peripheral specified by
\r
227 * the ucInterruptID parameter.
\r
231 * The ID of the peripheral that will have pxHandler assigned as its interrupt
\r
232 * handler. Peripheral IDs are defined in the xparameters.h header file, which
\r
233 * is itself part of the BSP project. For example, in the official demo
\r
234 * application for this port, xparameters.h defines the following IDs for the
\r
235 * four possible interrupt sources:
\r
237 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
238 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
239 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
240 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
245 * A pointer to the interrupt handler function itself. This must be a void
\r
246 * function that takes a (void *) parameter.
\r
251 * The parameter passed into the handler function. In many cases this will not
\r
252 * be used and can be NULL. Some times it is used to pass in a reference to
\r
253 * the peripheral instance variable, so it can be accessed from inside the
\r
254 * handler function.
\r
257 * pdPASS is returned if the function executes successfully. Any other value
\r
258 * being returned indicates that the function did not execute correctly.
\r
260 portBASE_TYPE xPortInstallInterruptHandler( unsigned char ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );
\r
264 * Enables the interrupt, within the interrupt controller, for the peripheral
\r
265 * specified by the ucInterruptID parameter.
\r
269 * The ID of the peripheral that will have its interrupt enabled in the
\r
270 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
271 * file, which is itself part of the BSP project. For example, in the official
\r
272 * demo application for this port, xparameters.h defines the following IDs for
\r
273 * the four possible interrupt sources:
\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
281 void vPortEnableInterrupt( unsigned char ucInterruptID );
\r
284 * Disables the interrupt, within the interrupt controller, for the peripheral
\r
285 * specified by the ucInterruptID parameter.
\r
289 * The ID of the peripheral that will have its interrupt disabled in the
\r
290 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
291 * file, which is itself part of the BSP project. For example, in the official
\r
292 * demo application for this port, xparameters.h defines the following IDs for
\r
293 * the four possible interrupt sources:
\r
295 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
296 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
297 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
298 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
301 void vPortDisableInterrupt( unsigned char ucInterruptID );
\r
304 * This is an application defined callback function used to install the tick
\r
305 * interrupt handler. It is provided as an application callback because the
\r
306 * kernel will run on lots of different MicroBlaze and FPGA configurations - not
\r
307 * all of which will have the same timer peripherals defined or available. This
\r
308 * example uses the AXI Timer 0. If that is available on your hardware platform
\r
309 * then this example callback implementation should not require modification.
\r
310 * The name of the interrupt handler that should be installed is vPortTickISR(),
\r
311 * which the function below declares as an extern.
\r
313 void vApplicationSetupTimerInterrupt( void );
\r
316 * This is an application defined callback function used to clear whichever
\r
317 * interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
\r
318 * function - in this case the interrupt generated by the AXI timer. It is
\r
319 * provided as an application callback because the kernel will run on lots of
\r
320 * different MicroBlaze and FPGA configurations - not all of which will have the
\r
321 * same timer peripherals defined or available. This example uses the AXI Timer 0.
\r
322 * If that is available on your hardware platform then this example callback
\r
323 * implementation should not require modification provided the example definition
\r
324 * of vApplicationSetupTimerInterrupt() is also not modified.
\r
326 void vApplicationClearTimerInterrupt( void );
\r
329 * vPortExceptionsInstallHandlers() is only available when the MicroBlaze
\r
330 * is configured to include exception functionality, and
\r
331 * configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h.
\r
333 * vPortExceptionsInstallHandlers() installs the FreeRTOS exception handler
\r
334 * for every possible exception cause.
\r
336 * vPortExceptionsInstallHandlers() can be called explicitly from application
\r
337 * code. After that is done, the default FreeRTOS exception handler that will
\r
338 * have been installed can be replaced for any specific exception cause by using
\r
339 * the standard Xilinx library function microblaze_register_exception_handler().
\r
341 * If vPortExceptionsInstallHandlers() is not called explicitly by the
\r
342 * application, it will be called automatically by the kernel the first time
\r
343 * xPortInstallInterruptHandler() is called. At that time, any exception
\r
344 * handlers that may have already been installed will be replaced.
\r
346 * See the description of vApplicationExceptionRegisterDump() for information
\r
347 * on the processing performed by the FreeRTOS exception handler.
\r
349 void vPortExceptionsInstallHandlers( void );
\r
352 * The FreeRTOS exception handler fills an xPortRegisterDump structure (defined
\r
353 * in portmacro.h) with the MicroBlaze context, as it was at the time the
\r
354 * exception occurred. The exception handler then calls
\r
355 * vApplicationExceptionRegisterDump(), passing in the completed
\r
356 * xPortRegisterDump structure as its parameter.
\r
358 * The FreeRTOS kernel provides its own implementation of
\r
359 * vApplicationExceptionRegisterDump(), but the kernel provided implementation
\r
360 * is declared as being 'weak'. The weak definition allows the application
\r
361 * writer to provide their own implementation, should they wish to use the
\r
362 * register dump information. For example, an implementation could be provided
\r
363 * that wrote the register dump data to a display, or a UART port.
\r
365 void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump );
\r
372 #endif /* PORTMACRO_H */
\r