*/\r
#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )\r
\r
+/**\r
+ * semphr. h\r
+ * <pre>void vSemaphoreDelete( xSemaphoreHandle xSemaphore );</pre>\r
+ *\r
+ * Delete a semaphore. This function must be used with care. For example,\r
+ * do not delete a mutex type semaphore if the mutex is held by a task.\r
+ *\r
+ * @param xSemaphore A handle to the semaphore to be deleted.\r
+ *\r
+ * \page vSemaphoreDelete vSemaphoreDelete\r
+ * \ingroup Semaphores\r
+ */\r
+#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( xQueueHandle ) xSemaphore )\r
\r
#endif /* SEMAPHORE_H */\r
\r
*<pre>\r
portBASE_TYPE xTaskCreate(\r
pdTASK_CODE pvTaskCode,\r
- const char * const pcName,\r
+ const signed char * const pcName,\r
unsigned short usStackDepth,\r
void *pvParameters,\r
unsigned portBASE_TYPE uxPriority,\r
*/\r
portBASE_TYPE xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter ) PRIVILEGED_FUNCTION;\r
\r
+/**\r
+ * xTaskGetIdleTaskHandle() is only available if \r
+ * INCLUDE_xTaskGetIdleTaskHandle is set to 1 in FreeRTOSConfig.h.\r
+ *\r
+ * Simply returns the handle of the idle task. It is not valid to call\r
+ * xTaskGetIdleTaskHandle() before the scheduler has been started.\r
+ */\r
+xTaskHandle xTaskGetIdleTaskHandle( void );\r
\r
/*-----------------------------------------------------------\r
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
*/\r
portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION;\r
\r
+/**\r
+ * xTimerGetTimerTaskHandle() is only available if \r
+ * INCLUDE_xTimerGetTimerTaskHandle is set to 1 in FreeRTOSConfig.h.\r
+ *\r
+ * Simply returns the handle of the timer service/daemon task. It it not valid\r
+ * to call xTimerGetTimerTaskHandle() before the scheduler has been started.\r
+ */\r
+xTaskHandle xTimerGetTimerTaskHandle( void );\r
+\r
/**\r
* portBASE_TYPE xTimerStart( xTimerHandle xTimer, portTickType xBlockTime );\r
*\r
* Handler for the timer interrupt. This is the handler that the application\r
* defined callback function vApplicationSetupTimerInterrupt() should install.\r
*/\r
-void vTickISR( void *pvUnused )\r
+void vPortTickISR( void *pvUnused )\r
{\r
extern void vApplicationClearTimerInterrupt( void );\r
\r
#define portDISABLE_INTERRUPTS() microblaze_disable_interrupts()\r
#define portENABLE_INTERRUPTS() microblaze_enable_interrupts()\r
\r
+/*\r
+ * Installs pxHandler as the interrupt handler for the peripheral specified by \r
+ * the ucInterruptID parameter.\r
+ *\r
+ * ucInterruptID:\r
+ * \r
+ * The ID of the peripheral that will have pxHandler assigned as its interrupt\r
+ * handler. Peripheral IDs are defined in the xparameters.h header file, which \r
+ * is itself part of the BSP project. For example, in the official demo \r
+ * application for this port, xparameters.h defines the following IDs for the \r
+ * four possible interrupt sources:\r
+ *\r
+ * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.\r
+ * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.\r
+ * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.\r
+ * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.\r
+ *\r
+ *\r
+ * pxHandler:\r
+ * \r
+ * A pointer to the interrupt handler function itself. This must be a void\r
+ * function that takes a (void *) parameter.\r
+ *\r
+ *\r
+ * pvCallBackRef:\r
+ *\r
+ * The parameter passed into the handler function. In many cases this will not\r
+ * be used and can be NULL. Some times it is used to pass in a reference to\r
+ * the peripheral instance variable, so it can be accessed from inside the\r
+ * handler function.\r
+ *\r
+ * \r
+ * pdPASS is returned if the function executes successfully. Any other value\r
+ * being returned indicates that the function did not execute correctly.\r
+ */\r
portBASE_TYPE xPortInstallInterruptHandler( unsigned char ucInterruptID, XInterruptHandler pxHandler, void *pvCallBackRef );\r
+\r
+\r
+/*\r
+ * Enables the interrupt, within the interrupt controller, for the peripheral \r
+ * specified by the ucInterruptID parameter.\r
+ *\r
+ * ucInterruptID:\r
+ * \r
+ * The ID of the peripheral that will have its interrupt enabled in the\r
+ * interrupt controller. Peripheral IDs are defined in the xparameters.h header \r
+ * file, which is itself part of the BSP project. For example, in the official \r
+ * demo application for this port, xparameters.h defines the following IDs for \r
+ * the four possible interrupt sources:\r
+ *\r
+ * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.\r
+ * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.\r
+ * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.\r
+ * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.\r
+ *\r
+ */\r
void vPortEnableInterrupt( unsigned char ucInterruptID );\r
+\r
+/*\r
+ * Disables the interrupt, within the interrupt controller, for the peripheral \r
+ * specified by the ucInterruptID parameter.\r
+ *\r
+ * ucInterruptID:\r
+ * \r
+ * The ID of the peripheral that will have its interrupt disabled in the\r
+ * interrupt controller. Peripheral IDs are defined in the xparameters.h header \r
+ * file, which is itself part of the BSP project. For example, in the official \r
+ * demo application for this port, xparameters.h defines the following IDs for \r
+ * the four possible interrupt sources:\r
+ *\r
+ * XPAR_INTC_0_UARTLITE_1_VEC_ID - for the UARTlite peripheral.\r
+ * XPAR_INTC_0_TMRCTR_0_VEC_ID - for the AXI Timer 0 peripheral.\r
+ * XPAR_INTC_0_EMACLITE_0_VEC_ID - for the Ethernet lite peripheral.\r
+ * XPAR_INTC_0_GPIO_1_VEC_ID - for the button inputs.\r
+ *\r
+ */\r
void vPortDisableInterrupt( unsigned char ucInterruptID );\r
\r
void vApplicationSetupTimerInterrupt( void );\r
\r
/*-----------------------------------------------------------*/\r
\r
-/* Task utilities. */\r
+/* The yield macro maps directly to the vPortYield() function. */\r
void vPortYield( void );\r
#define portYIELD() vPortYield()\r
\r
-void vTaskSwitchContext();\r
+/* portYIELD_FROM_ISR() does not directly call vTaskSwitchContext(), but instead\r
+sets a flag to say that a yield has been requested. The interrupt exit code\r
+then checks this flag, and calls vTaskSwitchContext() before restoring a task\r
+context, if the flag is not false. This is done to prevent multiple calls to\r
+vTaskSwitchContext() being made from a single interrupt, as a single interrupt\r
+can result in multiple peripherals being serviced. */\r
extern volatile unsigned long ulTaskSwitchRequested;\r
#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) ulTaskSwitchRequested = 1\r
/*-----------------------------------------------------------*/\r
/* Task function macros as described on the FreeRTOS.org WEB site. */\r
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+/*-----------------------------------------------------------*/\r
\r
+/* The following structure is used by the FreeRTOS exception handler. It is\r
+filled with the MicroBlaze context as it was at the time the exception occurred.\r
+This is done as an aid to debugging exception occurrences. */\r
typedef struct PORT_REGISTER_DUMP\r
{\r
/* The following structure members hold the values of the MicroBlaze\r
unsigned long ulR14_return_address_from_interrupt;\r
unsigned long ulR15_return_address_from_subroutine;\r
unsigned long ulR16_return_address_from_trap;\r
- unsigned long ulR17_return_address_from_exceptions; /* The exception entry code can copy the BTR in here for exceptions that occur in the delay slot of branch instructions. */\r
+ 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
unsigned long ulR18;\r
unsigned long ulR19;\r
unsigned long ulR20;\r
\r
#endif\r
\r
+#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
+ \r
+ PRIVILEGED_DATA static xTaskHandle xIdleTaskHandle = NULL;\r
+ \r
+#endif\r
+\r
/* File private variables. --------------------------------*/\r
PRIVILEGED_DATA static volatile unsigned portBASE_TYPE uxCurrentNumberOfTasks = ( unsigned portBASE_TYPE ) 0;\r
PRIVILEGED_DATA static volatile portTickType xTickCount = ( portTickType ) 0;\r
portBASE_TYPE xReturn;\r
\r
/* Add the idle task at the lowest priority. */\r
- xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), ( xTaskHandle * ) NULL );\r
+ #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
+ {\r
+ /* Create the idle task, storing its handle in xIdleTaskHandle so it can\r
+ be returned by the xTaskGetIdleTaskhandle() function. */\r
+ xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), &xIdleTaskHandle );\r
+ }\r
+ #else\r
+ {\r
+ /* Create the idle task without storing its handle. */\r
+ xReturn = xTaskCreate( prvIdleTask, ( signed char * ) "IDLE", tskIDLE_STACK_SIZE, ( void * ) NULL, ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), NULL );\r
+ }\r
+ #endif\r
\r
#if ( configUSE_TIMERS == 1 )\r
{\r
}\r
\r
#endif\r
+/*----------------------------------------------------------*/\r
\r
+#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
\r
+ xTaskHandle xTaskGetIdleTaskHandle( void )\r
+ {\r
+ /* If xTaskGetIdleTaskHandle() is called before the scheduler has been\r
+ started, then xIdleTaskHandle will be NULL. */\r
+ configASSERT( ( xIdleTaskHandle != NULL ) );\r
+ return xIdleTaskHandle;\r
+ }\r
+ \r
+#endif\r
\r
/*-----------------------------------------------------------\r
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
/* A queue that is used to send commands to the timer service task. */\r
PRIVILEGED_DATA static xQueueHandle xTimerQueue = NULL;\r
\r
+#if ( INCLUDE_xTimerGetTimerTaskHandle == 1 )\r
+ \r
+ PRIVILEGED_DATA static xTaskHandle xTimerTaskHandle = NULL;\r
+ \r
+#endif\r
+\r
/*-----------------------------------------------------------*/\r
\r
/*\r
\r
if( xTimerQueue != NULL )\r
{\r
- xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, NULL);\r
+ #if ( INCLUDE_xTimerGetTimerTaskHandle == 1 )\r
+ {\r
+ /* Create the timer task, storing its handle in xTimerTaskHandle so\r
+ it can be returned by the xTimerGetTimerTaskHandle() function. */\r
+ xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, &xTimerTaskHandle ); \r
+ }\r
+ #else\r
+ {\r
+ /* Create the timer task without storing its handle. */\r
+ xReturn = xTaskCreate( prvTimerTask, ( const signed char * ) "Tmr Svc", ( unsigned short ) configTIMER_TASK_STACK_DEPTH, NULL, ( unsigned portBASE_TYPE ) configTIMER_TASK_PRIORITY, NULL);\r
+ }\r
+ #endif\r
}\r
\r
configASSERT( xReturn );\r
}\r
/*-----------------------------------------------------------*/\r
\r
+#if ( INCLUDE_xTimerGetTimerTaskHandle == 1 )\r
+\r
+ xTaskHandle xTimerGetTimerTaskHandle( void )\r
+ {\r
+ /* If xTimerGetTimerTaskHandle() is called before the scheduler has been\r
+ started, then xTimerTaskHandle will be NULL. */\r
+ configASSERT( ( xTimerTaskHandle != NULL ) );\r
+ return xTimerTaskHandle;\r
+ }\r
+ \r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
static void prvProcessExpiredTimer( portTickType xNextExpireTime, portTickType xTimeNow )\r
{\r
xTIMER *pxTimer;\r