1 /** 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef TEST_SUITE_IPC_H 17 #define TEST_SUITE_IPC_H 18 19 #ifdef CONFIG_TESTSUITE_SUPPORT_MULTI_CORE 20 #include "ipc.h" 21 #endif 22 #include "test_suite_channel.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif /* __cplusplus */ 28 #endif /* __cplusplus */ 29 30 #define TEST_SUITE_PRIVATE_COMMAND_BUFFER_SIZE 60 31 32 #define TEST_SUITE_CORE_IMPLEMENTING_THE_CONSOLE APPS 33 34 #define CORES_CORE_IMPLEMENTING_THE_CONSOLE CORES_APPS_CORE 35 36 #define CMD_TEST_RUNNING 0 37 #define CMD_TEST_PASS 1 38 #define CMD_TEST_FAIL 2 39 #define CMD_TEST_ERROR 3 40 #define CMD_TEST_RETURN_CONTROL 4 41 42 #define TEST_SUITE_TIMER_S_TO_US 1000000 43 /** 44 * @defgroup test_common_testsuite_ipc IPC 45 * @ingroup test_common_testsuite 46 * @{ 47 */ 48 49 /** 50 * @if Eng 51 * @brief Gets test suite ipc functions. 52 * @return test suite ipc functions address. 53 * @else 54 * @brief 获取测试套件ipc功能函数。 55 * @return 测试套件ipc功能函数接口地址。 56 * @endif 57 */ 58 test_suite_channel_funcs_t *test_suite_ipc_funcs_get(void); 59 60 #ifdef CONFIG_TESTSUITE_SUPPORT_MULTI_CORE 61 62 /** 63 * @if Eng 64 * @brief Clear the receive flag of echo core. 65 * @param [in] core core. 66 * @else 67 * @brief 清除各个核的接收标志 68 * @param [in] core 核。 69 * @endif 70 */ 71 void test_suite_commands_echo_clear(cores_t core); 72 73 /** 74 * @if Eng 75 * @brief Clear the receive flag of all core. 76 * @else 77 * @brief 清除所有核的接收标志 78 * @endif 79 */ 80 void test_suite_ipc_clear_core_flag(void); 81 82 /** 83 * @if Eng 84 * @brief The command is executed on another core, blocking the execution. 85 * @param [in] core core. 86 * @param [in] commmand command string. 87 * @param [in] timeout timeout interval, unit ms. 88 * @else 89 * @brief 命令在别的核执行,阻塞执行 90 * @param [in] core 核. 91 * @param [in] commmand 命令字符. 92 * @param [in] timeout 超时时间,单位ms. 93 * @endif 94 */ 95 void test_suite_commands_execute_in_external_core(cores_t core, char *command, uint32_t timeout); 96 97 /** 98 * @if Eng 99 * @brief Callback function for receiving command responses. 100 * @param [in] message The ipc_action_t of the received message. 101 * @param [in] payload_p Data payload of the received mssage. 102 * @param [in] src Sending core. 103 * @param [in] id Internal message id. Can be used to detect duplicate delivery and for debug. 104 * @return True if the incoming mailslot shluld be released or false if the message was 105 * not (fully) processed and should be redelivered 106 * @else 107 * @brief 命令的响应接收回调函数. 108 * @param [in] message 接收消息的ipc_action_t。 109 * @param [in] payload_p 接收到的消息缓存buffer。 110 * @param [in] src 发送核. 111 * @param [in] id 内部消息流水号ID。可用于检测重复交付和调试. 112 * @return 如果消息处理完成,应释放本条消息所在内存,则为True 113 * 如果消息未完全处理完成,且应重新处理该条消息,则为False 114 * @endif 115 */ 116 bool test_suite_commands_ipc_message_handler(ipc_action_t message, 117 const volatile ipc_payload *payload_p, cores_t src, uint32_t id); 118 119 #endif 120 121 /** 122 * @} 123 */ 124 125 #ifdef __cplusplus 126 #if __cplusplus 127 } 128 #endif /* __cplusplus */ 129 #endif /* __cplusplus */ 130 131 #endif 132