mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-22 14:31:59 -04:00
* Extend support to Arm Cortex-M85 Signed-off-by: Gabor Toth <gabor.toth@arm.com> Change-Id: I679ba8e193638126b683b651513f08df445f9fe6 * Add generated Cortex-M85 support files Signed-off-by: Gabor Toth <gabor.toth@arm.com> Change-Id: Ib329d88623c2936ffe3e9a24f5d6e07655e4e5c8 * Extend Trusted Firmware M port Extend Trusted Firmware M port to Cortex-M23, Cortex-M55 and Cortex-M85. Signed-off-by: Gabor Toth <gabor.toth@arm.com> Change-Id: If8f1081acfd04e547b3227579e70e355a6adffe3 * Re-run copy_files.py script Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Signed-off-by: Gabor Toth <gabor.toth@arm.com> Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
99 lines
2.9 KiB
C
99 lines
2.9 KiB
C
/*
|
|
* Copyright (c) 2019-2020, Arm Limited. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
* the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
* subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* This file contains the implementation of APIs which are defined in
|
|
* os_wrapper/mutex.h by TF-M(tag: TF-Mv1.1). The implementation is based
|
|
* on FreeRTOS mutex type semaphore.
|
|
*/
|
|
|
|
#include "os_wrapper/mutex.h"
|
|
|
|
#include "FreeRTOS.h"
|
|
#include "semphr.h"
|
|
#include "mpu_wrappers.h"
|
|
|
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
|
/*
|
|
* In the static allocation, the RAM is required to hold the semaphore's
|
|
* state.
|
|
*/
|
|
StaticSemaphore_t xSecureMutexBuffer;
|
|
#endif
|
|
|
|
void * os_wrapper_mutex_create( void )
|
|
{
|
|
SemaphoreHandle_t xMutexHandle = NULL;
|
|
|
|
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
|
|
xMutexHandle = xSemaphoreCreateMutex();
|
|
#elif( configSUPPORT_STATIC_ALLOCATION == 1 )
|
|
xMutexHandle = xSemaphoreCreateMutexStatic( &xSecureMutexBuffer );
|
|
#endif
|
|
return ( void * ) xMutexHandle;
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
|
|
uint32_t os_wrapper_mutex_acquire( void * handle, uint32_t timeout )
|
|
{
|
|
BaseType_t xRet;
|
|
|
|
if( ! handle )
|
|
return OS_WRAPPER_ERROR;
|
|
|
|
xRet = xSemaphoreTake( ( SemaphoreHandle_t ) handle,
|
|
( timeout == OS_WRAPPER_WAIT_FOREVER ) ?
|
|
portMAX_DELAY : ( TickType_t ) timeout );
|
|
|
|
if( xRet != pdPASS )
|
|
return OS_WRAPPER_ERROR;
|
|
else
|
|
return OS_WRAPPER_SUCCESS;
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
|
|
uint32_t os_wrapper_mutex_release( void * handle )
|
|
{
|
|
BaseType_t xRet;
|
|
|
|
if( !handle )
|
|
return OS_WRAPPER_ERROR;
|
|
|
|
xRet = xSemaphoreGive( ( SemaphoreHandle_t ) handle );
|
|
|
|
if( xRet != pdPASS )
|
|
return OS_WRAPPER_ERROR;
|
|
else
|
|
return OS_WRAPPER_SUCCESS;
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
|
|
uint32_t os_wrapper_mutex_delete( void * handle )
|
|
{
|
|
vSemaphoreDelete( ( SemaphoreHandle_t ) handle );
|
|
|
|
return OS_WRAPPER_SUCCESS;
|
|
}
|
|
/*-----------------------------------------------------------*/
|