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