]> git.sur5r.net Git - freertos/commitdiff
Update TriCore GCC port layer.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 27 Oct 2011 10:44:31 +0000 (10:44 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 27 Oct 2011 10:44:31 +0000 (10:44 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1626 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/GCC/TriCore_1782/MPU_Wrappers.c [deleted file]
Source/portable/GCC/TriCore_1782/port.c
Source/portable/GCC/TriCore_1782/portmacro.h
Source/portable/GCC/TriCore_1782/porttrap.c

diff --git a/Source/portable/GCC/TriCore_1782/MPU_Wrappers.c b/Source/portable/GCC/TriCore_1782/MPU_Wrappers.c
deleted file mode 100644 (file)
index 178cd57..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/*\r
-    FreeRTOS V7.0.2 - Copyright (C) 2011 Real Time Engineers Ltd.\r
-\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
-     *    Complete, revised, and edited pdf reference manuals are also       *\r
-     *    available.                                                         *\r
-     *                                                                       *\r
-     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
-     *    ensuring you get running as quickly as possible and with an        *\r
-     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
-     *    the FreeRTOS project to continue with its mission of providing     *\r
-     *    professional grade, cross platform, de facto standard solutions    *\r
-     *    for microcontrollers - completely free of charge!                  *\r
-     *                                                                       *\r
-     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
-     *                                                                       *\r
-     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-\r
-    This file is part of the FreeRTOS distribution.\r
-\r
-    FreeRTOS is free software; you can redistribute it and/or modify it under\r
-    the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
-    >>>NOTE<<< The modification to the GPL is included to allow you to\r
-    distribute a combined work that includes FreeRTOS without being obliged to\r
-    provide the source code for proprietary components outside of the FreeRTOS\r
-    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
-    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
-    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-    more details. You should have received a copy of the GNU General Public\r
-    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
-    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
-    by writing to Richard Barry, contact details for whom are available on the\r
-    FreeRTOS WEB site.\r
-\r
-    1 tab == 4 spaces!\r
-\r
-    http://www.FreeRTOS.org - Documentation, latest information, license and\r
-    contact details.\r
-\r
-    http://www.SafeRTOS.com - A version that is certified for use in safety\r
-    critical systems.\r
-\r
-    http://www.OpenRTOS.com - Commercial support, development, porting,\r
-    licensing and training services.\r
-*/\r
-\r
-/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining\r
-all the API functions to use the MPU wrappers.  That should only be done when\r
-task.h is included from an application file. */\r
-#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
-\r
-#include "FreeRTOS.h"\r
-#include "task.h"\r
-#include "queue.h"\r
-\r
-#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE\r
-\r
-#if configUSE_MPU == 1\r
-\r
-/* Function for raising the privilege of a task. */\r
-extern portBASE_TYPE xPortRaisePrivilege( void );\r
-\r
-/*\r
- * Prototypes for all the MPU wrappers.\r
- */\r
-signed portBASE_TYPE MPU_xTaskGenericCreate( pdTASK_CODE pvTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions );\r
-void MPU_vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const xRegions );\r
-void MPU_vTaskDelete( xTaskHandle pxTaskToDelete );\r
-void MPU_vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement );\r
-void MPU_vTaskDelay( portTickType xTicksToDelay );\r
-unsigned portBASE_TYPE MPU_uxTaskPriorityGet( xTaskHandle pxTask );\r
-void MPU_vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority );\r
-void MPU_vTaskSuspend( xTaskHandle pxTaskToSuspend );\r
-signed portBASE_TYPE MPU_xTaskIsTaskSuspended( xTaskHandle xTask );\r
-void MPU_vTaskResume( xTaskHandle pxTaskToResume );\r
-void MPU_vTaskSuspendAll( void );\r
-signed portBASE_TYPE MPU_xTaskResumeAll( void );\r
-portTickType MPU_xTaskGetTickCount( void );\r
-unsigned portBASE_TYPE MPU_uxTaskGetNumberOfTasks( void );\r
-void MPU_vTaskList( signed char *pcWriteBuffer );\r
-void MPU_vTaskGetRunTimeStats( signed char *pcWriteBuffer );\r
-void MPU_vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize );\r
-unsigned long MPU_ulTaskEndTrace( void );\r
-void MPU_vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxTagValue );\r
-pdTASK_HOOK_CODE MPU_xTaskGetApplicationTaskTag( xTaskHandle xTask );\r
-portBASE_TYPE MPU_xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter );\r
-unsigned portBASE_TYPE MPU_uxTaskGetStackHighWaterMark( xTaskHandle xTask );\r
-xTaskHandle MPU_xTaskGetCurrentTaskHandle( void );\r
-portBASE_TYPE MPU_xTaskGetSchedulerState( void );\r
-xQueueHandle MPU_xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize );\r
-signed portBASE_TYPE MPU_xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
-unsigned portBASE_TYPE MPU_uxQueueMessagesWaiting( const xQueueHandle pxQueue );\r
-signed portBASE_TYPE MPU_xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
-xQueueHandle MPU_xQueueCreateMutex( void );\r
-xQueueHandle MPU_xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount );\r
-portBASE_TYPE MPU_xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime );\r
-portBASE_TYPE MPU_xQueueGiveMutexRecursive( xQueueHandle xMutex );\r
-signed portBASE_TYPE MPU_xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
-signed portBASE_TYPE MPU_xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
-void MPU_vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName );\r
-void *MPU_pvPortMalloc( size_t xSize );\r
-void MPU_vPortFree( void *pv );\r
-void MPU_vPortInitialiseBlocks( void );\r
-size_t MPU_xPortGetFreeHeapSize( void );\r
-/*---------------------------------------------------------------------------*/\r
-\r
-signed portBASE_TYPE MPU_xTaskGenericCreate( pdTASK_CODE pvTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions )\r
-{\r
-signed portBASE_TYPE xReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       xReturn = xTaskGenericCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, puxStackBuffer, xRegions );\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return xReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void MPU_vTaskAllocateMPURegions( xTaskHandle xTask, const xMemoryRegion * const xRegions )\r
-{\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       vTaskAllocateMPURegions( xTask, xRegions );\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskDelete == 1 )\r
-       void MPU_vTaskDelete( xTaskHandle pxTaskToDelete )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskDelete( pxTaskToDelete );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskDelayUntil == 1 )\r
-       void MPU_vTaskDelayUntil( portTickType * const pxPreviousWakeTime, portTickType xTimeIncrement )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskDelay == 1 )\r
-       void MPU_vTaskDelay( portTickType xTicksToDelay )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskDelay( xTicksToDelay );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_uxTaskPriorityGet == 1 )\r
-       unsigned portBASE_TYPE MPU_uxTaskPriorityGet( xTaskHandle pxTask )\r
-       {\r
-       unsigned portBASE_TYPE uxReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               uxReturn = uxTaskPriorityGet( pxTask );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return uxReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskPrioritySet == 1 )\r
-       void MPU_vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskPrioritySet( pxTask, uxNewPriority );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskSuspend == 1 )\r
-       void MPU_vTaskSuspend( xTaskHandle pxTaskToSuspend )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskSuspend( pxTaskToSuspend );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskSuspend == 1 )\r
-       signed portBASE_TYPE MPU_xTaskIsTaskSuspended( xTaskHandle xTask )\r
-       {\r
-       signed portBASE_TYPE xReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xTaskIsTaskSuspended( xTask );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_vTaskSuspend == 1 )\r
-       void MPU_vTaskResume( xTaskHandle pxTaskToResume )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskResume( pxTaskToResume );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-void MPU_vTaskSuspendAll( void )\r
-{\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       vTaskSuspendAll();\r
-    portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-signed portBASE_TYPE MPU_xTaskResumeAll( void )\r
-{\r
-signed portBASE_TYPE xReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       xReturn = xTaskResumeAll();\r
-    portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-    return xReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-portTickType MPU_xTaskGetTickCount( void )\r
-{\r
-portTickType xReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       xReturn = xTaskGetTickCount();\r
-    portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return xReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-unsigned portBASE_TYPE MPU_uxTaskGetNumberOfTasks( void )\r
-{\r
-unsigned portBASE_TYPE uxReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       uxReturn = uxTaskGetNumberOfTasks();\r
-    portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return uxReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
-       void MPU_vTaskList( signed char *pcWriteBuffer )\r
-       {\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskList( pcWriteBuffer );\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configGENERATE_RUN_TIME_STATS == 1 )\r
-       void MPU_vTaskGetRunTimeStats( signed char *pcWriteBuffer )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskGetRunTimeStats( pcWriteBuffer );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
-       void MPU_vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskStartTrace( pcBuffer, ulBufferSize );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_TRACE_FACILITY == 1 )\r
-       unsigned long MPU_ulTaskEndTrace( void )\r
-       {\r
-       unsigned long ulReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               ulReturn = ulTaskEndTrace();\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return ulReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
-       void MPU_vTaskSetApplicationTaskTag( xTaskHandle xTask, pdTASK_HOOK_CODE pxTagValue )\r
-       {\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vTaskSetApplicationTaskTag( xTask, pxTagValue );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
-       pdTASK_HOOK_CODE MPU_xTaskGetApplicationTaskTag( xTaskHandle xTask )\r
-       {\r
-       pdTASK_HOOK_CODE xReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xTaskGetApplicationTaskTag( xTask );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_APPLICATION_TASK_TAG == 1 )\r
-       portBASE_TYPE MPU_xTaskCallApplicationTaskHook( xTaskHandle xTask, void *pvParameter )\r
-       {\r
-       portBASE_TYPE xReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )\r
-       unsigned portBASE_TYPE MPU_uxTaskGetStackHighWaterMark( xTaskHandle xTask )\r
-       {\r
-       unsigned portBASE_TYPE uxReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               uxReturn = uxTaskGetStackHighWaterMark( xTask );\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return uxReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 )\r
-       xTaskHandle MPU_xTaskGetCurrentTaskHandle( void )\r
-       {\r
-       xTaskHandle xReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xTaskGetCurrentTaskHandle();\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( INCLUDE_xTaskGetSchedulerState == 1 )\r
-       portBASE_TYPE MPU_xTaskGetSchedulerState( void )\r
-       {\r
-       portBASE_TYPE xReturn;\r
-    portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xTaskGetSchedulerState();\r
-        portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-void MPU_vTaskEnterCritical( void )\r
-{\r
-extern void vTaskEnterCritical( void );\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       vTaskEnterCritical();\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void MPU_vTaskExitCritical( void )\r
-{\r
-extern void vTaskExitCritical( void );\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       vTaskExitCritical();\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-xQueueHandle MPU_xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize )\r
-{\r
-xQueueHandle xReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       xReturn = xQueueCreate( uxQueueLength, uxItemSize );\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return xReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-signed portBASE_TYPE MPU_xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )\r
-{\r
-signed portBASE_TYPE xReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return xReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-unsigned portBASE_TYPE MPU_uxQueueMessagesWaiting( const xQueueHandle pxQueue )\r
-{\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-unsigned portBASE_TYPE uxReturn;\r
-\r
-       uxReturn = uxQueueMessagesWaiting( pxQueue );\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return uxReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-signed portBASE_TYPE MPU_xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
-{\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-signed portBASE_TYPE xReturn;\r
-\r
-       xReturn = xQueueGenericReceive( pxQueue, pvBuffer, xTicksToWait, xJustPeeking );\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       return xReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_MUTEXES == 1 )\r
-       xQueueHandle MPU_xQueueCreateMutex( void )\r
-       {\r
-    xQueueHandle xReturn;\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xQueueCreateMutex();\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if configUSE_COUNTING_SEMAPHORES == 1\r
-       xQueueHandle MPU_xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount )\r
-       {\r
-    xQueueHandle xReturn;\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = (xQueueHandle) xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_MUTEXES == 1 )\r
-       portBASE_TYPE MPU_xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime )\r
-       {\r
-       portBASE_TYPE xReturn;\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if ( configUSE_MUTEXES == 1 )\r
-       portBASE_TYPE MPU_xQueueGiveMutexRecursive( xQueueHandle xMutex )\r
-       {\r
-       portBASE_TYPE xReturn;\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xQueueGiveMutexRecursive( xMutex );\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if configUSE_ALTERNATIVE_API == 1\r
-       signed portBASE_TYPE MPU_xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )\r
-       {\r
-       signed portBASE_TYPE xReturn;\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn =       signed portBASE_TYPE xQueueAltGenericSend( pxQueue, pvItemToQueue, xTicksToWait, xCopyPosition );\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if configUSE_ALTERNATIVE_API == 1\r
-       signed portBASE_TYPE MPU_xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking )\r
-       {\r
-    signed portBASE_TYPE xReturn;\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               xReturn = xQueueAltGenericReceive( pxQueue, pvBuffer, xTicksToWait, xJustPeeking );\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-               return xReturn;\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-#if configQUEUE_REGISTRY_SIZE > 0\r
-       void MPU_vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName )\r
-       {\r
-       portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-               vQueueAddToRegistry( xQueue, pcName );\r
-\r
-               portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-       }\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
-void *MPU_pvPortMalloc( size_t xSize )\r
-{\r
-void *pvReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       pvReturn = pvPortMalloc( xSize );\r
-\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-\r
-       return pvReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void MPU_vPortFree( void *pv )\r
-{\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       vPortFree( pv );\r
-\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-size_t xPortGetFreeHeapSize( void )\r
-{\r
-       /* This just exists to keep the linker quiet. */\r
-extern unsigned long _lc_ub_heap[];            /* Heap */\r
-extern unsigned long _lc_ue_heap[];            /* Heap end */\r
-       return (size_t)( _lc_ue_heap - _lc_ub_heap );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vPortInitialiseBlocks( void )\r
-{\r
-       /* This just exists to keep the linker quiet. */\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void MPU_vPortInitialiseBlocks( void )\r
-{\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       vPortInitialiseBlocks();\r
-\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-size_t MPU_xPortGetFreeHeapSize( void )\r
-{\r
-size_t xReturn;\r
-portBASE_TYPE xRunningPrivileged = xPortRaisePrivilege();\r
-\r
-       xReturn = xPortGetFreeHeapSize();\r
-\r
-       portMPU_RESTORE_PRIORITY( xRunningPrivileged );\r
-\r
-       return xReturn;\r
-}\r
-\r
-#endif /* configUSE_MPU */\r
index 4f4dc4d27031ff6ae88a68fd497336655a52bdda..cc33450445771fb6d5c8f6ad0c2ba5c639bf33bf 100644 (file)
@@ -54,6 +54,8 @@
 /* Standard includes. */\r
 #include <stdlib.h>\r
 #include <string.h>\r
+\r
+/* TriCore specific includes. */\r
 #include <tc1782.h>\r
 #include <machine/intrinsics.h>\r
 #include <machine/cint.h>\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
 #include "list.h"\r
+\r
+#if configCHECK_FOR_STACK_OVERFLOW > 0\r
+       #error "Stack checking cannot be used with this port, as, unlike most ports, the pxTopOfStack member of the TCB is consumed CSA.  CSA starvation, loosely equivalent to stack overflow, will result in a trap exception."\r
+       /* The stack pointer is accessible using portCSA_TO_ADDRESS( portCSA_TO_ADDRESS( pxCurrentTCB->pxTopOfStack )[ 0 ] )[ 2 ]; */\r
+#endif /* configCHECK_FOR_STACK_OVERFLOW */\r
+\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* System register Definitions. */\r
 #define portINITIAL_PRIVILEGED_PROGRAM_STATUS_WORD             ( (unsigned portBASE_TYPE) 0x000014FF ) /* IO Level 1, MPU Register Set 1 and Call Depth Counting disabled. */\r
 #define portINITIAL_UNPRIVILEGED_PROGRAM_STATUS_WORD   ( (unsigned portBASE_TYPE) 0x000010FF ) /* IO Level 0, MPU Register Set 1 and Call Depth Counting disabled. */\r
 #define portINITIAL_PCXI_UPPER_CONTEXT_WORD                            ( (unsigned portBASE_TYPE) 0x00C00000 ) /* The lower 20 bits identify the CSA address. */\r
-#define portINITIAL_PCXI_LOWER_CONTEXT_WORD                            ( (unsigned portBASE_TYPE) 0x00000000 ) /* The lower 20 bits identify the CSA address. */\r
-#define portUPPER_CONTEXT_BIT                                                  ( (unsigned portBASE_TYPE) 0x00400000 ) /* Bit that indicates whether the context is upper or lower. */\r
-\r
 #define portINITIAL_SYSCON                                                             ( (unsigned portBASE_TYPE) 0x00000000 ) /* MPU Disable. */\r
 \r
-/* This macro should be used when the MPU is being used. */\r
-#define portSELECT_PROGRAM_STATUS_WORD( xRunPrivileged )               ( ( xRunPrivileged ) ? portINITIAL_PRIVILEGED_PROGRAM_STATUS_WORD : portINITIAL_UNPRIVILEGED_PROGRAM_STATUS_WORD )\r
-\r
 /* CSA manipulation macros. */\r
 #define portCSA_FCX_MASK                                       ( 0x000FFFFFUL )\r
 \r
 /* OS Interrupt and Trap mechanisms. */\r
 #define portRESTORE_PSW_MASK                           ( ~( 0x000000FFUL ) )\r
-#define portSYSCALL_TRAP                                       6\r
-#define portCCPN_MASK                                          ( 0x000000FFUL )\r
-\r
-#define portSYSTEM_DATA_PRIVILEGES                     ( 0xC0C0C0C0UL )\r
-#define portSYSTEM_CODE_PRIVILEGES                     ( 0x00008080UL )\r
-\r
-#define portSYSTEM_PRIVILEGE_PROGRAM_STATUS_WORD       ( (unsigned portBASE_TYPE) 0x00000800 ) /* Supervisor Mode. */\r
-/*-----------------------------------------------------------*/\r
-\r
-#if configCHECK_FOR_STACK_OVERFLOW > 0\r
-       #error "pxTopOfStack is used to store the last used CSA so it is not appropriate to enable stack checking."\r
-       /* The stack pointer is accessible using portCSA_TO_ADDRESS( portCSA_TO_ADDRESS( pxCurrentTCB->pxTopOfStack )[ 0 ] )[ 2 ]; */\r
-#endif /* configCHECK_FOR_STACK_OVERFLOW */\r
-/*-----------------------------------------------------------*/\r
+#define portSYSCALL_TRAP                                       ( 6 )\r
 \r
-/*\r
- * This reference is required by the Save/Restore Context Macros.\r
- */\r
-extern volatile unsigned portBASE_TYPE * pxCurrentTCB;\r
+/* Each CSA contains 16 words of data. */\r
+#define portNUM_WORDS_IN_CSA                           ( 16 )\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -109,84 +97,91 @@ extern volatile unsigned portBASE_TYPE * pxCurrentTCB;
  */\r
 void vPortSystemTickHandler( int ) __attribute__((longcall));\r
 static void prvSetupTimerInterrupt( void );\r
-/*-----------------------------------------------------------*/\r
 \r
 /*\r
- * The Yield Handler and Syscalls when using the MPU build.\r
+ * Trap handler for yields.\r
  */\r
-void vPortYield( int iTrapIdentification );\r
+static void prvPortYield( int iTrapIdentification );\r
+/*-----------------------------------------------------------*/\r
+\r
+/* This reference is required by the save/restore context macros. */\r
+extern volatile unsigned long *pxCurrentTCB;\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
 {\r
-unsigned portBASE_TYPE *pxUpperCSA = NULL;\r
-unsigned portBASE_TYPE *pxLowerCSA = NULL;\r
-\r
-       /* 16 Address Registers (4 Address registers are global) and 16 Data Registers. */\r
-       /* 3 System Registers */\r
-\r
-       /* There are 3 registers that track the CSAs. */\r
-       /* FCX points to the head of globally free set of CSAs.\r
-        * PCX for the task needs to point to Lower->Upper->NULL arrangement.\r
-        * LCX points to the last free CSA so that corrective action can be taken.\r
-        */\r
-\r
-       /* Need two CSAs to store the context of a task.\r
-        * The upper context contains D8-D15, A10-A15, PSW and PCXI->NULL.\r
-        * The lower context contains D0-D7, A2-A7, A11 and PCXI->UpperContext.\r
-        * The pxCurrentTCB->pxTopOfStack points to the Lower Context RSLCX matching the initial BISR.\r
-        * The Lower Context points to the Upper Context ready for the ready return from the interrupt handler.\r
-        * The Real stack pointer for the task is stored in the A10 which is restored with the upper context.\r
-        */\r
-\r
-       /* Have to disable interrupts here because we are manipulating the CSAs. */\r
+unsigned long *pulUpperCSA = NULL;\r
+unsigned long *pulLowerCSA = NULL;\r
+\r
+       /* 16 Address Registers (4 Address registers are global), 16 Data\r
+       Registers, and 3 System Registers.\r
+\r
+       There are 3 registers that track the CSAs.\r
+               FCX points to the head of globally free set of CSAs.\r
+               PCX for the task needs to point to Lower->Upper->NULL arrangement.\r
+               LCX points to the last free CSA so that corrective action can be taken.\r
+\r
+       Need two CSAs to store the context of a task.\r
+               The upper context contains D8-D15, A10-A15, PSW and PCXI->NULL.\r
+               The lower context contains D0-D7, A2-A7, A11 and PCXI->UpperContext.\r
+               The pxCurrentTCB->pxTopOfStack points to the Lower Context RSLCX matching the initial BISR.\r
+               The Lower Context points to the Upper Context ready for the return from the interrupt handler.\r
+\r
+        The Real stack pointer for the task is stored in the A10 which is restored\r
+        with the upper context. */\r
+\r
+       /* Have to disable interrupts here because the CSAs are going to be\r
+       manipulated. */\r
        portENTER_CRITICAL();\r
        {\r
                /* DSync to ensure that buffering is not a problem. */\r
                _dsync();\r
 \r
-               /* Consume two Free CSAs. */\r
-               pxLowerCSA = portCSA_TO_ADDRESS( _mfcr( $FCX ) );\r
-               if ( NULL != pxLowerCSA )\r
+               /* Consume two free CSAs. */\r
+               pulLowerCSA = portCSA_TO_ADDRESS( _mfcr( $FCX ) );\r
+               if( NULL != pulLowerCSA )\r
                {\r
                        /* The Lower Links to the Upper. */\r
-                       pxUpperCSA = portCSA_TO_ADDRESS( pxLowerCSA[ 0 ] );\r
+                       pulUpperCSA = portCSA_TO_ADDRESS( pulLowerCSA[ 0 ] );\r
                }\r
 \r
                /* Check that we have successfully reserved two CSAs. */\r
-               if ( ( NULL != pxLowerCSA ) && ( NULL != pxUpperCSA ) )\r
+               if( ( NULL != pulLowerCSA ) && ( NULL != pulUpperCSA ) )\r
                {\r
-                       /* Remove the two consumed CSAs from the Free List. */\r
-                       _mtcr( $FCX, pxUpperCSA[ 0 ] );\r
+                       /* Remove the two consumed CSAs from the free CSA list. */\r
+                       _mtcr( $FCX, pulUpperCSA[ 0 ] );\r
+\r
                        /* ISync to commit the change to the FCX. */\r
                        _isync();\r
                }\r
                else\r
                {\r
-                       /* For the time being, simply trigger a context list depletion trap. */\r
+                       /* Simply trigger a context list depletion trap. */\r
                        _svlcx();\r
                }\r
        }\r
        portEXIT_CRITICAL();\r
 \r
-       /* Clear the CSA. */\r
-       memset( pxUpperCSA, 0, 16 * sizeof( unsigned portBASE_TYPE ) );\r
+       /* Clear the upper CSA. */\r
+       memset( pulUpperCSA, 0, portNUM_WORDS_IN_CSA * sizeof( unsigned portBASE_TYPE ) );\r
 \r
        /* Upper Context. */\r
-       pxUpperCSA[ 2 ] = (unsigned portBASE_TYPE)pxTopOfStack;                         /* A10; Stack Return aka Stack Pointer */\r
-       pxUpperCSA[ 1 ] = portSYSTEM_PROGRAM_STATUS_WORD;                                       /* PSW  */\r
+       pulUpperCSA[ 2 ] = ( unsigned long )pxTopOfStack;               /* A10; Stack Return aka Stack Pointer */\r
+       pulUpperCSA[ 1 ] = portSYSTEM_PROGRAM_STATUS_WORD;              /* PSW  */\r
 \r
-       /* Clear the CSA. */\r
-       memset( pxLowerCSA, 0, 16 * sizeof( unsigned portBASE_TYPE ) );\r
+       /* Clear the lower CSA. */\r
+       memset( pulLowerCSA, 0, portNUM_WORDS_IN_CSA * sizeof( unsigned portBASE_TYPE ) );\r
 \r
        /* Lower Context. */\r
-       pxLowerCSA[ 8 ] = (unsigned portBASE_TYPE)pvParameters;                 /* A4;  Address Type Parameter Register */\r
-       pxLowerCSA[ 1 ] = (unsigned portBASE_TYPE)pxCode;                               /* A11; Return Address aka RA */\r
+       pulLowerCSA[ 8 ] = ( unsigned long ) pvParameters;              /* A4;  Address Type Parameter Register */\r
+       pulLowerCSA[ 1 ] = ( unsigned long ) pxCode;                    /* A11; Return Address aka RA */\r
+\r
        /* PCXI pointing to the Upper context. */\r
-       pxLowerCSA[ 0 ] = ( portINITIAL_PCXI_UPPER_CONTEXT_WORD | (unsigned portBASE_TYPE)portADDRESS_TO_CSA( pxUpperCSA ) );\r
+       pulLowerCSA[ 0 ] = ( portINITIAL_PCXI_UPPER_CONTEXT_WORD | ( unsigned long ) portADDRESS_TO_CSA( pulUpperCSA ) );\r
 \r
-       /* Save the link to the CSA in the Top of Stack. */\r
-       pxTopOfStack = (unsigned portBASE_TYPE *)portADDRESS_TO_CSA( pxLowerCSA );\r
+       /* Save the link to the CSA in the top of stack. */\r
+       pxTopOfStack = (unsigned long * ) portADDRESS_TO_CSA( pulLowerCSA );\r
 \r
        /* DSync to ensure that buffering is not a problem. */\r
        _dsync();\r
@@ -197,21 +192,22 @@ unsigned portBASE_TYPE *pxLowerCSA = NULL;
 \r
 portBASE_TYPE xPortStartScheduler( void )\r
 {\r
-unsigned portBASE_TYPE uxMFCR = 0UL;\r
-unsigned portBASE_TYPE *pxUpperCSA = NULL;\r
-unsigned portBASE_TYPE *pxLowerCSA = NULL;\r
+extern void vTrapInstallHandlers( void );\r
+unsigned long ulMFCR = 0UL;\r
+unsigned long *pulUpperCSA = NULL;\r
+unsigned long *pulLowerCSA = NULL;\r
+\r
        /* Set-up the timer interrupt. */\r
        prvSetupTimerInterrupt();\r
 \r
        /* Install the Trap Handlers. */\r
-extern void vTrapInstallHandlers( void );\r
        vTrapInstallHandlers();\r
 \r
        /* Install the Syscall Handler. */\r
-       if ( 0 == _install_trap_handler( portSYSCALL_TRAP, vPortYield ) )\r
+       if( 0 == _install_trap_handler( portSYSCALL_TRAP, prvPortYield ) )\r
        {\r
-               /* Failed to install the Yield handler. */\r
-               _debug();\r
+               /* Failed to install the yield handler, force an assert. */\r
+               configASSERT( ( ( volatile void * ) NULL ) );\r
        }\r
 \r
        /* Load the initial SYSCON. */\r
@@ -220,23 +216,23 @@ extern void vTrapInstallHandlers( void );
 \r
        /* ENDINIT has already been applied in the 'cstart.c' code. */\r
 \r
-       /* Set-up the Task switching ISR. */\r
-       CPU_SRC0.reg = 0x00001001UL;\r
-\r
-       /* Clear the PSW.CDC to enable RFE */\r
-       uxMFCR = _mfcr( $PSW );\r
-       uxMFCR &= portRESTORE_PSW_MASK;\r
-       _mtcr( $PSW, uxMFCR );\r
+       /* Clear the PSW.CDC to enable the use of an RFE without it generating an\r
+       exception because this code is not genuinely in an exception. */\r
+       ulMFCR = _mfcr( $PSW );\r
+       ulMFCR &= portRESTORE_PSW_MASK;\r
+       _mtcr( $PSW, ulMFCR );\r
 \r
        /* Finally, perform the equivalent of a portRESTORE_CONTEXT() */\r
-       pxLowerCSA = portCSA_TO_ADDRESS( *(unsigned portBASE_TYPE *)pxCurrentTCB );\r
-       pxUpperCSA = portCSA_TO_ADDRESS( pxLowerCSA[0] );\r
+       pulLowerCSA = portCSA_TO_ADDRESS( ( *pxCurrentTCB ) );\r
+       pulUpperCSA = portCSA_TO_ADDRESS( pulLowerCSA[0] );\r
        _mtcr( $PCXI, *pxCurrentTCB );\r
 \r
        _dsync();\r
        _nop();\r
        _rslcx();\r
        _nop();\r
+\r
+       /* Return to the first task selected to execute. */\r
        __asm volatile( "rfe" );\r
 \r
        /* Will not get here. */\r
@@ -248,20 +244,25 @@ static void prvSetupTimerInterrupt( void )
 {\r
        /* Set-up the clock divider. */\r
        unlock_wdtcon();\r
-               while ( 0 != ( WDT_CON0.reg & 0x1UL ) );\r
+       {\r
+               /* Wait until access to Endint protected register is enabled. */\r
+               while( 0 != ( WDT_CON0.reg & 0x1UL ) );\r
+\r
                /* RMC == 1 so STM Clock == FPI */\r
                STM_CLC.reg = ( 1UL << 8 );\r
+       }\r
        lock_wdtcon();\r
 \r
-    /* Set-up the Compare value. */\r
-       STM_CMCON.reg = ( 31UL - __CLZ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) );\r
+    /* Set-up the Compare value.  Determine how many bits are used. */\r
+       STM_CMCON.reg = ( 0x1fUL - __CLZ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) );\r
+\r
        /* Take into account the current time so a tick doesn't happen immediately. */\r
        STM_CMP0.reg = ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ ) + STM_TIM0.reg;\r
 \r
-       if ( 0 != _install_int_handler( portKERNEL_INTERRUPT_PRIORITY_LEVEL, vPortSystemTickHandler, 0 ) )\r
+       if( 0 != _install_int_handler( configKERNEL_INTERRUPT_PRIORITY, vPortSystemTickHandler, 0 ) )\r
        {\r
                /* Set-up the interrupt. */\r
-               STM_SRC0.reg = ( portKERNEL_INTERRUPT_PRIORITY_LEVEL | 0x00005000UL );\r
+               STM_SRC0.reg = ( configKERNEL_INTERRUPT_PRIORITY | 0x00005000UL );\r
 \r
                /* Enable the Interrupt. */\r
                STM_ISRR.reg = 0x1UL;\r
@@ -270,31 +271,37 @@ static void prvSetupTimerInterrupt( void )
        else\r
        {\r
                /* Failed to install the Tick Interrupt. */\r
-               _debug();\r
+               configASSERT( ( ( volatile void * ) NULL ) );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vPortSystemTickHandler( int iArg )\r
 {\r
+unsigned long ulSavedInterruptMask;\r
+\r
+       /* Just to avoid compiler warnings about unused parameters. */\r
+       ( void ) iArg;\r
+\r
        /* Clear the interrupt source. */\r
        STM_ISRR.reg = 1UL;\r
+\r
        /* Reload the Compare Match register for X ticks into the future. */\r
        STM_CMP0.reg += ( configPERIPHERAL_CLOCK_HZ / configTICK_RATE_HZ );\r
 \r
        /* Kernel API calls require Critical Sections. */\r
-       portINTERRUPT_ENTER_CRITICAL();\r
+       ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
        {\r
                /* Increment the Tick. */\r
                vTaskIncrementTick();\r
        }\r
-       portINTERRUPT_EXIT_CRITICAL();\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask );\r
 \r
-#if configUSE_PREEMPTION == 1\r
-       portYIELD_FROM_ISR( pdTRUE );\r
-#endif\r
-\r
-       (void)iArg;\r
+       #if configUSE_PREEMPTION == 1\r
+       {\r
+               portYIELD_FROM_ISR( pdTRUE );\r
+       }\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -379,18 +386,37 @@ void vPortEndScheduler( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vPortYield( int iTrapIdentification )\r
+static void prvPortYield( int iTrapIdentification )\r
 {\r
-       switch ( iTrapIdentification )\r
+       switch( iTrapIdentification )\r
        {\r
-       case portSYSCALL_TASK_YIELD:\r
-               /* Select another task to run. */\r
-               portYIELD_FROM_ISR( pdTRUE );\r
-               break;\r
-\r
-       default:\r
-               _debug();\r
-               break;\r
+               case portSYSCALL_TASK_YIELD:\r
+                       /* Select another task to run. */\r
+                       portYIELD_FROM_ISR( pdTRUE );\r
+                       break;\r
+\r
+               default:\r
+                       /* Unimplemented trap called. */\r
+                       configASSERT( ( ( volatile void * ) NULL ) );\r
+                       break;\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
+\r
+unsigned portBASE_TYPE uxPortSetInterruptMaskFromISR( void )\r
+{\r
+unsigned portBASE_TYPE uxReturn = 0UL;\r
+\r
+       uxReturn = _mfcr( $ICR );\r
+       _mtcr( $ICR, ( ( uxReturn & ~portCCPN_MASK ) | configMAX_SYSCALL_INTERRUPT_PRIORITY ) );\r
+\r
+       return ( uxReturn & portCCPN_MASK );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortClearInterruptMaskFromISR( unsigned portBASE_TYPE uxSavedStatusValue )\r
+{\r
+       _mtcr( $ICR, ( uxSavedStatusValue & portCCPN_MASK ) );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
index 65cb1926c16f9072330169096a69088a85248e9e..0f3a71e6a83ac713fffbd5342d460a3e7666281a 100644 (file)
@@ -97,8 +97,8 @@ extern "C" {
 #define portNOP()                                                                      __asm volatile( " nop " )\r
 #define portCRITICAL_NESTING_IN_TCB                                    1\r
 #define portRESTORE_FIRST_TASK_PRIORITY_LEVEL          1\r
-#define portKERNEL_INTERRUPT_PRIORITY_LEVEL                    4\r
-#define portSYSTEM_INTERRUPT_PRIORITY_LEVEL                    64\r
+\r
+\r
 /*---------------------------------------------------------------------------*/\r
 \r
 typedef struct MPU_SETTINGS { unsigned long ulNotUsed; } xMPU_SETTINGS;\r
@@ -106,6 +106,8 @@ typedef struct MPU_SETTINGS { unsigned long ulNotUsed; } xMPU_SETTINGS;
 /* Define away the instruction from the Restore Context Macro. */\r
 #define portPRIVILEGE_BIT                                                      0x0UL\r
 \r
+#define portCCPN_MASK                                          ( 0x000000FFUL )\r
+\r
 extern void vTaskEnterCritical( void );\r
 extern void vTaskExitCritical( void );\r
 #define portENTER_CRITICAL()                   vTaskEnterCritical()\r
@@ -129,13 +131,20 @@ extern void vPortReclaimCSA( unsigned portBASE_TYPE *pxTCB );
 \r
 /* Critical section management. */\r
 \r
-/* Clear the ICR.IE bit. */            /* Or set ICR.CCPN to portSYSTEM_INTERRUPT_PRIORITY_LEVEL */\r
-#define portDISABLE_INTERRUPTS()                       _disable()\r
-/* Set the ICR.IE bit. */              /* Or set ICR.CCPN to 0 */\r
-#define portENABLE_INTERRUPTS()                                _enable()\r
+/* Clear the ICR.IE bit. */\r
+#define portDISABLE_INTERRUPTS()                       _mtcr( $ICR, ( ( _mfcr( $ICR ) & ~portCCPN_MASK ) | configMAX_SYSCALL_INTERRUPT_PRIORITY ) )\r
+\r
+/* Set the ICR.IE bit. */\r
+#define portENABLE_INTERRUPTS()                                { unsigned long ulCurrentICR = _mfcr( $ICR ); _mtcr( $ICR, ( ulCurrentICR & ~portCCPN_MASK ) ) }\r
+\r
+extern unsigned portBASE_TYPE uxPortSetInterruptMaskFromISR( void );\r
+extern void vPortClearInterruptMaskFromISR( unsigned portBASE_TYPE uxSavedStatusValue );\r
+\r
+/* Set ICR.CCPN to configMAX_SYSCALL_INTERRUPT_PRIORITY */\r
+#define portSET_INTERRUPT_MASK_FROM_ISR()      uxPortSetInterruptMaskFromISR()\r
 \r
-#define portINTERRUPT_ENTER_CRITICAL()         _disable()\r
-#define portINTERRUPT_EXIT_CRITICAL()          _enable()\r
+/* Set ICR.CCPN to uxSavedInterruptStatus */\r
+#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusValue ) vPortClearInterruptMaskFromISR( uxSavedStatusValue )\r
 \r
 /*---------------------------------------------------------------------------*/\r
 \r
@@ -166,8 +175,7 @@ unsigned portBASE_TYPE *pxUpperCSA = NULL;                                          \
 unsigned portBASE_TYPE xUpperCSA = 0UL;                                                        \\r
        if ( pdTRUE == xHigherPriorityTaskWoken )                                       \\r
        {                                                                                                                       \\r
-               /*_disable();*/                                                                                 \\r
-               portINTERRUPT_ENTER_CRITICAL();                                                 \\r
+               _disable();                                                                                             \\r
                _isync();                                                                                               \\r
                xUpperCSA = _mfcr( $PCXI );                                                             \\r
                pxUpperCSA = portCSA_TO_ADDRESS( xUpperCSA );                   \\r
index b1b8c7f3be89d81165c1936bb181907ff82aa241..47df295aaefc2fde00a85ee78399b25b19bc24e5 100644 (file)
@@ -63,7 +63,7 @@
 /*\r
  * This reference is required by the Save/Restore Context Macros.\r
  */\r
-extern volatile unsigned portBASE_TYPE * pxCurrentTCB;\r
+extern volatile unsigned long *pxCurrentTCB;\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
@@ -129,13 +129,13 @@ extern volatile unsigned portBASE_TYPE * pxCurrentTCB;
 #define portTIN_NMI_NON_MASKABLE_INTERRUPT                                     0\r
 /*---------------------------------------------------------------------------*/\r
 \r
-void vMMUTrap( int iTrapIdentification );\r
-void vInternalProtectionTrap( int iTrapIdentification );\r
-void vInstructionErrorTrap( int iTrapIdentification );\r
-void vContextManagementTrap( int iTrapIdentification );\r
-void vSystemBusAndPeripheralsTrap( int iTrapIdentification );\r
-void vAssertionTrap( int iTrapIdentification );\r
-void vNonMaskableInterruptTrap( int iTrapIdentification );\r
+void vMMUTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
+void vInternalProtectionTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
+void vInstructionErrorTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
+void vContextManagementTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
+void vSystemBusAndPeripheralsTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
+void vAssertionTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
+void vNonMaskableInterruptTrap( int iTrapIdentification ) __attribute__( ( longcall, weak ) );\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vTrapInstallHandlers( void )\r
@@ -193,102 +193,116 @@ void vMMUTrap( int iTrapIdentification )
 \r
 void vInternalProtectionTrap( int iTrapIdentification )\r
 {\r
+       /* Deliberate fall through to default. */\r
        switch ( iTrapIdentification )\r
        {\r
-       case portTIN_IPT_PRIVILIGED_INSTRUCTION:\r
-               /* Instruction is not allowed at current execution level, eg DISABLE at User-0. */\r
-       case portTIN_IPT_MEMORY_PROTECTION_READ:\r
-               /* Load word using invalid address. */\r
-       case portTIN_IPT_MEMORY_PROTECTION_WRITE:\r
-               /* Store Word using invalid address. */\r
-       case portTIN_IPT_MEMORY_PROTECTION_EXECUTION:\r
-               /* PC jumped to an address outside of the valid range. */\r
-       case portTIN_IPT_MEMORY_PROTECTION_PERIPHERAL_ACCESS:\r
-               /* Access to a peripheral denied at current execution level. */\r
-       case portTIN_IPT_MEMORY_PROTECTION_NULL_ADDRESS:\r
-               /* NULL Pointer. */\r
-       case portTIN_IPT_MEMORY_PROTECTION_GLOBAL_REGISTER_WRITE_PROTECTION:\r
-               /* Tried to modify a global address pointer register. */\r
-       default:\r
-               pxCurrentTCB[ 0 ] = _mfcr( $PCXI );\r
-               _debug();\r
-               break;\r
+               case portTIN_IPT_PRIVILIGED_INSTRUCTION:\r
+                       /* Instruction is not allowed at current execution level, eg DISABLE at User-0. */\r
+\r
+               case portTIN_IPT_MEMORY_PROTECTION_READ:\r
+                       /* Load word using invalid address. */\r
+                       \r
+               case portTIN_IPT_MEMORY_PROTECTION_WRITE:\r
+                       /* Store Word using invalid address. */\r
+                       \r
+               case portTIN_IPT_MEMORY_PROTECTION_EXECUTION:\r
+                       /* PC jumped to an address outside of the valid range. */\r
+                       \r
+               case portTIN_IPT_MEMORY_PROTECTION_PERIPHERAL_ACCESS:\r
+                       /* Access to a peripheral denied at current execution level. */\r
+                       \r
+               case portTIN_IPT_MEMORY_PROTECTION_NULL_ADDRESS:\r
+                       /* NULL Pointer. */\r
+                       \r
+               case portTIN_IPT_MEMORY_PROTECTION_GLOBAL_REGISTER_WRITE_PROTECTION:\r
+                       /* Tried to modify a global address pointer register. */\r
+                       \r
+               default:\r
+               \r
+                       pxCurrentTCB[ 0 ] = _mfcr( $PCXI );\r
+                       _debug();\r
+                       break;\r
        }\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vInstructionErrorTrap( int iTrapIdentification )\r
 {\r
+       /* Deliberate fall through to default. */\r
        switch ( iTrapIdentification )\r
        {\r
-       case portTIN_IE_ILLEGAL_OPCODE:\r
-       case portTIN_IE_UNIMPLEMENTED_OPCODE:\r
-       case portTIN_IE_INVALID_OPERAND:\r
-       case portTIN_IE_DATA_ADDRESS_ALIGNMENT:\r
-       case portTIN_IE_INVALID_LOCAL_MEMORY_ADDRESS:\r
-       default:\r
-               _debug();\r
-               break;\r
+               case portTIN_IE_ILLEGAL_OPCODE:\r
+               case portTIN_IE_UNIMPLEMENTED_OPCODE:\r
+               case portTIN_IE_INVALID_OPERAND:\r
+               case portTIN_IE_DATA_ADDRESS_ALIGNMENT:\r
+               case portTIN_IE_INVALID_LOCAL_MEMORY_ADDRESS:\r
+               default:\r
+                       _debug();\r
+                       break;\r
        }\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vContextManagementTrap( int iTrapIdentification )\r
 {\r
+       /* Deliberate fall through to default. */\r
        switch ( iTrapIdentification )\r
        {\r
-       case portTIN_CM_FREE_CONTEXT_LIST_DEPLETION:\r
-       case portTIN_CM_CALL_DEPTH_OVERFLOW:\r
-       case portTIN_CM_CALL_DEPTH_UNDEFLOW:\r
-       case portTIN_CM_FREE_CONTEXT_LIST_UNDERFLOW:\r
-       case portTIN_CM_CALL_STACK_UNDERFLOW:\r
-       case portTIN_CM_CONTEXT_TYPE:\r
-       case portTIN_CM_NESTING_ERROR:\r
-       default:\r
-               _debug();\r
-               break;\r
+               case portTIN_CM_FREE_CONTEXT_LIST_DEPLETION:\r
+               case portTIN_CM_CALL_DEPTH_OVERFLOW:\r
+               case portTIN_CM_CALL_DEPTH_UNDEFLOW:\r
+               case portTIN_CM_FREE_CONTEXT_LIST_UNDERFLOW:\r
+               case portTIN_CM_CALL_STACK_UNDERFLOW:\r
+               case portTIN_CM_CONTEXT_TYPE:\r
+               case portTIN_CM_NESTING_ERROR:\r
+               default:\r
+                       _debug();\r
+                       break;\r
        }\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vSystemBusAndPeripheralsTrap( int iTrapIdentification )\r
 {\r
+       /* Deliberate fall through to default. */\r
        switch ( iTrapIdentification )\r
        {\r
-       case portTIN_SBP_PROGRAM_FETCH_SYNCHRONOUS_ERROR:\r
-       case portTIN_SBP_DATA_ACCESS_SYNCHRONOUS_ERROR:\r
-       case portTIN_SBP_DATA_ACCESS_ASYNCHRONOUS_ERROR:\r
-       case portTIN_SBP_COPROCESSOR_TRAP_ASYNCHRONOUS_ERROR:\r
-       case portTIN_SBP_PROGRAM_MEMORY_INTEGRITY_ERROR:\r
-       case portTIN_SBP_DATA_MEMORY_INTEGRITY_ERROR:\r
-       default:\r
-               _debug();\r
-               break;\r
+               case portTIN_SBP_PROGRAM_FETCH_SYNCHRONOUS_ERROR:\r
+               case portTIN_SBP_DATA_ACCESS_SYNCHRONOUS_ERROR:\r
+               case portTIN_SBP_DATA_ACCESS_ASYNCHRONOUS_ERROR:\r
+               case portTIN_SBP_COPROCESSOR_TRAP_ASYNCHRONOUS_ERROR:\r
+               case portTIN_SBP_PROGRAM_MEMORY_INTEGRITY_ERROR:\r
+               case portTIN_SBP_DATA_MEMORY_INTEGRITY_ERROR:\r
+               default:\r
+                       _debug();\r
+                       break;\r
        }\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vAssertionTrap( int iTrapIdentification )\r
 {\r
+       /* Deliberate fall through to default. */\r
        switch ( iTrapIdentification )\r
        {\r
-       case portTIN_ASSERT_ARITHMETIC_OVERFLOW:\r
-       case portTIN_ASSERT_STICKY_ARITHMETIC_OVERFLOW:\r
-       default:\r
-               _debug();\r
-               break;\r
+               case portTIN_ASSERT_ARITHMETIC_OVERFLOW:\r
+               case portTIN_ASSERT_STICKY_ARITHMETIC_OVERFLOW:\r
+               default:\r
+                       _debug();\r
+                       break;\r
        }\r
 }\r
 /*---------------------------------------------------------------------------*/\r
 \r
 void vNonMaskableInterruptTrap( int iTrapIdentification )\r
 {\r
+       /* Deliberate fall through to default. */\r
        switch ( iTrapIdentification )\r
        {\r
-       case portTIN_NMI_NON_MASKABLE_INTERRUPT:\r
-       default:\r
-               _debug();\r
-               break;\r
+               case portTIN_NMI_NON_MASKABLE_INTERRUPT:\r
+               default:\r
+                       _debug();\r
+                       break;\r
        }\r
 }\r
 /*---------------------------------------------------------------------------*/\r