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 uint32_t
\r
94 #define portBASE_TYPE long
\r
96 typedef portSTACK_TYPE StackType_t;
\r
97 typedef long BaseType_t;
\r
98 typedef unsigned long UBaseType_t;
\r
100 #if( configUSE_16_BIT_TICKS == 1 )
\r
101 typedef uint16_t TickType_t;
\r
102 #define portMAX_DELAY ( TickType_t ) 0xffff
\r
104 typedef uint32_t TickType_t;
\r
105 #define portMAX_DELAY ( TickType_t ) 0xffffffffUL
\r
107 /*-----------------------------------------------------------*/
\r
109 /* Interrupt control macros and functions. */
\r
110 void microblaze_disable_interrupts( void );
\r
111 void microblaze_enable_interrupts( void );
\r
112 #define portDISABLE_INTERRUPTS() microblaze_disable_interrupts()
\r
113 #define portENABLE_INTERRUPTS() microblaze_enable_interrupts()
\r
115 /*-----------------------------------------------------------*/
\r
117 /* Critical section macros. */
\r
118 void vPortEnterCritical( void );
\r
119 void vPortExitCritical( void );
\r
120 #define portENTER_CRITICAL() { \
\r
121 extern volatile UBaseType_t uxCriticalNesting; \
\r
122 microblaze_disable_interrupts(); \
\r
123 uxCriticalNesting++; \
\r
126 #define portEXIT_CRITICAL() { \
\r
127 extern volatile UBaseType_t uxCriticalNesting; \
\r
128 /* Interrupts are disabled, so we can */ \
\r
129 /* access the variable directly. */ \
\r
130 uxCriticalNesting--; \
\r
131 if( uxCriticalNesting == 0 ) \
\r
133 /* The nesting has unwound and we \
\r
134 can enable interrupts again. */ \
\r
135 portENABLE_INTERRUPTS(); \
\r
139 /*-----------------------------------------------------------*/
\r
141 /* The yield macro maps directly to the vPortYield() function. */
\r
142 void vPortYield( void );
\r
143 #define portYIELD() vPortYield()
\r
145 /* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead
\r
146 sets a flag to say that a yield has been requested. The interrupt exit code
\r
147 then checks this flag, and calls vTaskSwitchContext() before restoring a task
\r
148 context, if the flag is not false. This is done to prevent multiple calls to
\r
149 vTaskSwitchContext() being made from a single interrupt, as a single interrupt
\r
150 can result in multiple peripherals being serviced. */
\r
151 extern volatile uint32_t ulTaskSwitchRequested;
\r
152 #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1
\r
153 /*-----------------------------------------------------------*/
\r
155 /* Hardware specifics. */
\r
156 #define portBYTE_ALIGNMENT 4
\r
157 #define portSTACK_GROWTH ( -1 )
\r
158 #define portTICK_RATE_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
\r
159 #define portNOP() asm volatile ( "NOP" )
\r
160 /*-----------------------------------------------------------*/
\r
162 /* Task function macros as described on the FreeRTOS.org WEB site. */
\r
163 #define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
164 #define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )
\r
165 /*-----------------------------------------------------------*/
\r
167 /* The following structure is used by the FreeRTOS exception handler. It is
\r
168 filled with the MicroBlaze context as it was at the time the exception occurred.
\r
169 This is done as an aid to debugging exception occurrences. */
\r
170 typedef struct PORT_REGISTER_DUMP
\r
172 /* The following structure members hold the values of the MicroBlaze
\r
173 registers at the time the exception was raised. */
\r
175 uint32_t ulR2_small_data_area;
\r
186 uint32_t ulR13_read_write_small_data_area;
\r
187 uint32_t ulR14_return_address_from_interrupt;
\r
188 uint32_t ulR15_return_address_from_subroutine;
\r
189 uint32_t ulR16_return_address_from_trap;
\r
190 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
212 /* A human readable description of the exception cause. The strings used
\r
213 are the same as the #define constant names found in the
\r
214 microblaze_exceptions_i.h header file */
\r
215 int8_t *pcExceptionCause;
\r
217 /* The human readable name of the task that was running at the time the
\r
218 exception occurred. This is the name that was given to the task when the
\r
219 task was created using the FreeRTOS xTaskCreate() API function. */
\r
220 int8_t *pcCurrentTaskName;
\r
222 /* The handle of the task that was running a the time the exception
\r
224 void * xCurrentTaskHandle;
\r
226 } xPortRegisterDump;
\r
230 * Installs pxHandler as the interrupt handler for the peripheral specified by
\r
231 * the ucInterruptID parameter.
\r
235 * The ID of the peripheral that will have pxHandler assigned as its interrupt
\r
236 * handler. Peripheral IDs are defined in the xparameters.h header file, which
\r
237 * is itself part of the BSP project. For example, in the official demo
\r
238 * application for this port, xparameters.h defines the following IDs for the
\r
239 * four possible interrupt sources:
\r
241 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
242 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
243 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
244 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
249 * A pointer to the interrupt handler function itself. This must be a void
\r
250 * function that takes a (void *) parameter.
\r
255 * The parameter passed into the handler function. In many cases this will not
\r
256 * be used and can be NULL. Some times it is used to pass in a reference to
\r
257 * the peripheral instance variable, so it can be accessed from inside the
\r
258 * handler function.
\r
261 * pdPASS is returned if the function executes successfully. Any other value
\r
262 * being returned indicates that the function did not execute correctly.
\r
264 BaseType_t xPortInstallInterruptHandler( uint8_t ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );
\r
268 * Enables the interrupt, within the interrupt controller, for the peripheral
\r
269 * specified by the ucInterruptID parameter.
\r
273 * The ID of the peripheral that will have its interrupt enabled in the
\r
274 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
275 * file, which is itself part of the BSP project. For example, in the official
\r
276 * demo application for this port, xparameters.h defines the following IDs for
\r
277 * the four possible interrupt sources:
\r
279 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
280 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
281 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
282 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
285 void vPortEnableInterrupt( uint8_t ucInterruptID );
\r
288 * Disables the interrupt, within the interrupt controller, for the peripheral
\r
289 * specified by the ucInterruptID parameter.
\r
293 * The ID of the peripheral that will have its interrupt disabled in the
\r
294 * interrupt controller. Peripheral IDs are defined in the xparameters.h header
\r
295 * file, which is itself part of the BSP project. For example, in the official
\r
296 * demo application for this port, xparameters.h defines the following IDs for
\r
297 * the four possible interrupt sources:
\r
299 * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.
\r
300 * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.
\r
301 * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.
\r
302 * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.
\r
305 void vPortDisableInterrupt( uint8_t ucInterruptID );
\r
308 * This is an application defined callback function used to install the tick
\r
309 * interrupt handler. It is provided as an application callback because the
\r
310 * kernel will run on lots of different MicroBlaze and FPGA configurations - not
\r
311 * all of which will have the same timer peripherals defined or available. This
\r
312 * example uses the AXI Timer 0. If that is available on your hardware platform
\r
313 * then this example callback implementation should not require modification.
\r
314 * The name of the interrupt handler that should be installed is vPortTickISR(),
\r
315 * which the function below declares as an extern.
\r
317 void vApplicationSetupTimerInterrupt( void );
\r
320 * This is an application defined callback function used to clear whichever
\r
321 * interrupt was installed by the the vApplicationSetupTimerInterrupt() callback
\r
322 * function - in this case the interrupt generated by the AXI timer. It is
\r
323 * provided as an application callback because the kernel will run on lots of
\r
324 * different MicroBlaze and FPGA configurations - not all of which will have the
\r
325 * same timer peripherals defined or available. This example uses the AXI Timer 0.
\r
326 * If that is available on your hardware platform then this example callback
\r
327 * implementation should not require modification provided the example definition
\r
328 * of vApplicationSetupTimerInterrupt() is also not modified.
\r
330 void vApplicationClearTimerInterrupt( void );
\r
333 * vPortExceptionsInstallHandlers() is only available when the MicroBlaze
\r
334 * is configured to include exception functionality, and
\r
335 * configINSTALL_EXCEPTION_HANDLERS is set to 1 in FreeRTOSConfig.h.
\r
337 * vPortExceptionsInstallHandlers() installs the FreeRTOS exception handler
\r
338 * for every possible exception cause.
\r
340 * vPortExceptionsInstallHandlers() can be called explicitly from application
\r
341 * code. After that is done, the default FreeRTOS exception handler that will
\r
342 * have been installed can be replaced for any specific exception cause by using
\r
343 * the standard Xilinx library function microblaze_register_exception_handler().
\r
345 * If vPortExceptionsInstallHandlers() is not called explicitly by the
\r
346 * application, it will be called automatically by the kernel the first time
\r
347 * xPortInstallInterruptHandler() is called. At that time, any exception
\r
348 * handlers that may have already been installed will be replaced.
\r
350 * See the description of vApplicationExceptionRegisterDump() for information
\r
351 * on the processing performed by the FreeRTOS exception handler.
\r
353 void vPortExceptionsInstallHandlers( void );
\r
356 * The FreeRTOS exception handler fills an xPortRegisterDump structure (defined
\r
357 * in portmacro.h) with the MicroBlaze context, as it was at the time the
\r
358 * exception occurred. The exception handler then calls
\r
359 * vApplicationExceptionRegisterDump(), passing in the completed
\r
360 * xPortRegisterDump structure as its parameter.
\r
362 * The FreeRTOS kernel provides its own implementation of
\r
363 * vApplicationExceptionRegisterDump(), but the kernel provided implementation
\r
364 * is declared as being 'weak'. The weak definition allows the application
\r
365 * writer to provide their own implementation, should they wish to use the
\r
366 * register dump information. For example, an implementation could be provided
\r
367 * that wrote the register dump data to a display, or a UART port.
\r
369 void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump );
\r
376 #endif /* PORTMACRO_H */
\r