joey shelton / LED_Demo

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by Maxim nexpaq

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rpc_gateway_exports.h Source File

rpc_gateway_exports.h

00001 /*
00002  * Copyright (c) 2016, 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_RPC_GATEWAY_EXPORTS_H__
00018 #define __UVISOR_API_RPC_GATEWAY_EXPORTS_H__
00019 
00020 #include "api/inc/uvisor_exports.h"
00021 #include <stdint.h>
00022 
00023 /* udf imm16
00024  * UDF - ARMv7M ARM section A7.7.191
00025  * 111 1;0 111;1111; <imm4>; 1 01 0; <imm12> (Encoding T2)
00026  */
00027 #define UDF_OPCODE(imm16) \
00028     ((uint32_t) (0xA000F7F0UL | (((uint32_t) (imm16) & 0xFFFU) << 16U) | (((uint32_t) (imm16) & 0xF000UL) >> 12)))
00029 
00030 /** RPC gateway magics
00031  *
00032  * The following magics are used to verify an RPC gateway structure. The magics are
00033  * chosen to be one of the explicitly undefined Thumb-2 instructions.
00034  */
00035 /* TODO Unify all sources of magic (for register gateway, rpc gateway, and
00036  * everybody else) */
00037 #if defined(__thumb__) && defined(__thumb2__)
00038 #define UVISOR_RPC_GATEWAY_MAGIC_ASYNC UDF_OPCODE(0x07C2)
00039 #define UVISOR_RPC_GATEWAY_MAGIC_SYNC  UDF_OPCODE(0x07C3)
00040 #else
00041 #error "Unsupported instruction set. The ARM Thumb-2 instruction set must be supported."
00042 #endif   /* __thumb__ && __thumb2__ */
00043 
00044 
00045 /** RPC gateway structure
00046  *
00047  * This struct is packed because we must ensure that the `ldr_pc` field has no
00048  * padding before itself and will be located at a valid instruction location,
00049  * and that the `function` field is at a pre-determined offset from the
00050  * `ldr_pc` field.
00051  */
00052 typedef struct {
00053     uint32_t ldr_pc;
00054     uint32_t magic;
00055     uint32_t box_ptr;
00056     uint32_t function; /* It's like a pretend literal pool. */
00057 } UVISOR_PACKED UVISOR_ALIGN(4) TRPCGateway;
00058 
00059 #endif /* __UVISOR_API_RPC_GATEWAY_EXPORTS_H__ */