Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
platform_alt.c
00001 /* 00002 * platform_alt.c 00003 * 00004 * Copyright (C) 2018, Arm Limited, All Rights Reserved 00005 * SPDX-License-Identifier: Apache-2.0 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00008 * not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00015 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 * 00019 */ 00020 00021 #include "mbedtls/platform.h" 00022 #if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT) 00023 #include "mbed_critical.h" 00024 00025 mbedtls_platform_context ctx = { { 0 } }; 00026 00027 int mbedtls_platform_setup( mbedtls_platform_context *unused_ctx ) 00028 { 00029 int ret = 0; 00030 00031 core_util_atomic_incr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 ); 00032 00033 if( ctx.reference_count == 1 ) 00034 { 00035 /* call platform specific code to setup crypto driver */ 00036 ret = crypto_platform_setup( &ctx.platform_impl_ctx ); 00037 } 00038 return ( ret ); 00039 } 00040 00041 void mbedtls_platform_teardown( mbedtls_platform_context *unused_ctx ) 00042 { 00043 core_util_atomic_decr_u32( ( volatile uint32_t * )&ctx.reference_count, 1 ); 00044 if( ctx.reference_count < 1 ) 00045 { 00046 /* call platform specific code to terminate crypto driver */ 00047 crypto_platform_terminate( &ctx.platform_impl_ctx ); 00048 ctx.reference_count = 0; 00049 } 00050 } 00051 00052 #endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT*/
Generated on Tue Aug 9 2022 00:37:17 by
1.7.2