Nicolas Borla / Mbed OS BBR_1Ebene
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers linker_exports.h Source File

linker_exports.h

00001 /*
00002  * Copyright (c) 2017, ARM Limited, All Rights Reserved
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00006  * not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  * http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00013  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef __UVISOR_API_LINKER_EXPORTS_H__
00018 #define __UVISOR_API_LINKER_EXPORTS_H__
00019 
00020 /* FIXME Consider supporting other aliasing schemes. This is dependent on the
00021  * IDAU implementation. Not all aliasing is guaranteed to work the same way. We
00022  * currently only support a 1-bit MSB IDAU. */
00023 #if defined (ARCH_CORE_ARMv8M) || defined (TARGET_M33)
00024 #  define SECURE_ALIAS_OFFSET 0x10000000
00025 #else
00026 #  define SECURE_ALIAS_OFFSET 0
00027 #endif
00028 
00029 /** @returns the non-secure alias of the input address. */
00030 #define UVISOR_GET_NS_ALIAS(addr) ((typeof(addr)) ((uint32_t) (addr) & ~SECURE_ALIAS_OFFSET))
00031 /** @returns the secure alias of the input address. */
00032 #define UVISOR_GET_S_ALIAS(addr) ((typeof(addr)) ((uint32_t) (addr) | SECURE_ALIAS_OFFSET))
00033 /** @returns `true` if address is a secure alias. */
00034 #define UVISOR_IS_S_ALIAS(addr) ((uint32_t) (addr) & SECURE_ALIAS_OFFSET)
00035 /** @returns an address targeting the non-secure state. */
00036 #define UVISOR_GET_NS_ADDRESS(addr) ((addr) & ~1UL)
00037 
00038 /** @returns the secure alias of the input address for uVisor core builds, and
00039  * the non-secure alias for non-uVisor core builds.
00040  * This is useful for code shared across secure and non-secure aliases. */
00041 #if UVISOR_CORE_BUILD
00042 #define UVISOR_AUTO_ALIAS(addr) UVISOR_GET_S_ALIAS(addr)
00043 #else
00044 #define UVISOR_AUTO_ALIAS(addr) UVISOR_GET_NS_ALIAS(addr)
00045 #endif
00046 
00047 /** @returns the secure alias of the input address for uVisor core builds, and
00048  * assumes the addr supplied is already a non-secure alias for non-uVisor core builds.
00049  * This is useful for code shared across secure and non-secure aliases. */
00050 #if UVISOR_CORE_BUILD
00051 #define UVISOR_AUTO_NS_ALIAS(addr) UVISOR_GET_S_ALIAS(addr)
00052 #else
00053 #define UVISOR_AUTO_NS_ALIAS(addr) addr
00054 #endif
00055 
00056 #endif