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.
Fork of mbed-os by
rpc_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_EXPORTS_H__ 00018 #define __UVISOR_API_RPC_EXPORTS_H__ 00019 00020 #include "api/inc/pool_queue_exports.h" 00021 #include "api/inc/uvisor_semaphore_exports.h" 00022 #include "api/inc/rpc_gateway_exports.h" 00023 00024 typedef uint32_t (*TFN_Ptr)(uint32_t, uint32_t, uint32_t, uint32_t); 00025 00026 #define UVISOR_RESULT_SLOT_BITS 10 00027 #define UVISOR_RESULT_SLOT_MASK ((1 << UVISOR_RESULT_SLOT_BITS) - 1) 00028 00029 #define UVISOR_RESULT_COUNTER_MASK (0xFFFFFFFFUL << UVISOR_RESULT_SLOT_BITS) 00030 00031 /* Increment by 2 because we never want to overflow into the invalid value. */ 00032 #define UVISOR_RESULT_COUNTER_INCREMENT (2 << UVISOR_RESULT_SLOT_BITS) 00033 00034 #define UVISOR_RESULT_INVALID_COUNTER (UVISOR_RESULT_COUNTER_MASK) 00035 00036 /* This is the token to wait on for the result of an asynchronous RPC. */ 00037 typedef uint32_t uvisor_rpc_result_t; 00038 00039 static inline uvisor_pool_slot_t uvisor_result_slot(uvisor_rpc_result_t result) 00040 { 00041 return result & UVISOR_RESULT_SLOT_MASK; 00042 } 00043 00044 static inline uint32_t uvisor_result_counter(uvisor_rpc_result_t result) 00045 { 00046 return result & UVISOR_RESULT_COUNTER_MASK; 00047 } 00048 00049 static inline uvisor_rpc_result_t uvisor_result_build(uint32_t counter, uvisor_pool_slot_t slot) 00050 { 00051 return (counter & UVISOR_RESULT_COUNTER_MASK) | (slot & UVISOR_RESULT_SLOT_MASK); 00052 } 00053 00054 typedef enum { 00055 /* Who sets this value for caller (outgoing queue), Who sets this value for (incoming queue) callee. */ 00056 UVISOR_RPC_MESSAGE_STATE_INVALID, /* nobody, nobody */ 00057 UVISOR_RPC_MESSAGE_STATE_IDLE, /* caller receive function before freeing, uvisor when delivers back */ 00058 UVISOR_RPC_MESSAGE_STATE_READY_TO_SEND, /* send function, nobody */ 00059 UVISOR_RPC_MESSAGE_STATE_SENT, /* uvisor, uvisor */ 00060 UVISOR_RPC_MESSAGE_STATE_DONE, /* waitfor_fngroup function, uvisor when delivers back */ 00061 } uvisor_rpc_message_state_t; 00062 00063 typedef struct uvisor_rpc_message { 00064 /* NOTE: These are set by the caller, and read by the callee. */ 00065 uint32_t p0; 00066 uint32_t p1; 00067 uint32_t p2; 00068 uint32_t p3; 00069 00070 const TRPCGateway * gateway; 00071 00072 /* The box ID of the other box. For callers, this is the destination box 00073 * ID. For callees, this is the source box ID. */ 00074 int other_box_id; 00075 00076 /* The semaphore to post to when a result is ready */ 00077 UvisorSemaphore semaphore; 00078 00079 /* This cookie keeps track of which result to wait for. It changes 00080 * atomically to an invalid cookie when being waited on, to prevent 00081 * multiple waits for the same result. */ 00082 uvisor_rpc_result_t wait_cookie; 00083 00084 /* This is an extra copy of the above cookie, used by uVisor to verify that 00085 * a certain result matches a certain caller. This identifies to uVisor 00086 * which RPC it should complete. uVisor must verify this information of 00087 * course, to see if this box is currently being called into and is allowed 00088 * to complete the RPC. */ 00089 uvisor_rpc_result_t match_cookie; 00090 00091 uvisor_rpc_message_state_t state; 00092 00093 uint32_t result; 00094 } uvisor_rpc_message_t; 00095 00096 typedef struct uvisor_rpc_fn_group { 00097 /* A pointer to the function group */ 00098 TFN_Ptr const * fn_ptr_array; 00099 size_t fn_count; 00100 00101 /* The semaphore to wait on for this function group */ 00102 UvisorSemaphore semaphore; 00103 } uvisor_rpc_fn_group_t; 00104 00105 #define UVISOR_RPC_OUTGOING_MESSAGE_SLOTS (8) 00106 00107 #define UVISOR_RPC_INCOMING_MESSAGE_SLOTS (8) 00108 00109 #define UVISOR_RPC_FN_GROUP_SLOTS (8) 00110 00111 #define UVISOR_RPC_OUTGOING_MESSAGE_TYPE(slots) \ 00112 struct { \ 00113 uvisor_pool_queue_t queue; \ 00114 uvisor_pool_t pool; \ 00115 uvisor_pool_queue_entry_t entries[slots]; \ 00116 uvisor_rpc_message_t messages[slots]; \ 00117 } 00118 00119 #define UVISOR_RPC_INCOMING_MESSAGE_TYPE(slots) \ 00120 struct { \ 00121 uvisor_pool_queue_t todo_queue; \ 00122 uvisor_pool_queue_t done_queue; \ 00123 uvisor_pool_t pool; \ 00124 uvisor_pool_queue_entry_t entries[slots]; \ 00125 uvisor_rpc_message_t messages[slots]; \ 00126 } 00127 00128 #define UVISOR_RPC_FN_GROUP_TYPE(slots) \ 00129 struct { \ 00130 uvisor_pool_queue_t queue; \ 00131 uvisor_pool_t pool; \ 00132 uvisor_pool_queue_entry_t entries[slots]; \ 00133 uvisor_rpc_fn_group_t fn_groups[slots]; \ 00134 } 00135 00136 typedef UVISOR_RPC_OUTGOING_MESSAGE_TYPE(UVISOR_RPC_OUTGOING_MESSAGE_SLOTS) uvisor_rpc_outgoing_message_queue_t; 00137 typedef UVISOR_RPC_INCOMING_MESSAGE_TYPE(UVISOR_RPC_INCOMING_MESSAGE_SLOTS) uvisor_rpc_incoming_message_queue_t; 00138 typedef UVISOR_RPC_FN_GROUP_TYPE(UVISOR_RPC_FN_GROUP_SLOTS) uvisor_rpc_fn_group_queue_t; 00139 00140 #endif
Generated on Tue Jul 12 2022 13:16:04 by
1.7.2
