1 /** @file 2 * Copyright (c) 2018-2022, Arm Limited or its affiliates. All rights reserved. 3 * SPDX-License-Identifier : Apache-2.0 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 **/ 17 18 #ifndef _VAL_INTERFACES_H_ 19 #define _VAL_INTERFACES_H_ 20 21 #include "val.h" 22 #include "val_client_defs.h" 23 #include "pal_interfaces_ns.h" 24 25 /* typedef's */ 26 typedef struct { 27 val_status_t (*print) (print_verbosity_t verbosity, 28 const char *string, int32_t data); 29 val_status_t (*set_status) (uint32_t status); 30 uint32_t (*get_status) (void); 31 void (*test_init) (uint32_t test_num, char8_t *desc, 32 uint32_t test_bitfield); 33 void (*test_exit) (void); 34 val_status_t (*err_check_set) (uint32_t checkpoint, val_status_t status); 35 val_status_t (*target_get_config) (cfg_id_t cfg_id, uint8_t **data, uint32_t *size); 36 val_status_t (*execute_non_secure_tests) (uint32_t test_num, 37 const client_test_t *tests_list, 38 bool_t server_hs); 39 val_status_t (*switch_to_secure_client) (uint32_t test_num); 40 val_status_t (*execute_secure_test_func) (psa_handle_t *handle, test_info_t test_info, 41 uint32_t sid); 42 val_status_t (*ipc_connect) (uint32_t sid, uint32_t version, 43 psa_handle_t *handle ); 44 val_status_t (*ipc_call) (psa_handle_t handle, 45 int32_t type, 46 const psa_invec *in_vec, 47 size_t in_len, 48 psa_outvec *out_vec, 49 size_t out_len); 50 void (*ipc_close) (psa_handle_t handle); 51 val_status_t (*get_secure_test_result) (psa_handle_t *handle); 52 val_status_t (*nvmem_read) (uint32_t offset, void *buffer, int size); 53 val_status_t (*nvmem_write) (uint32_t offset, void *buffer, int size); 54 val_status_t (*wd_timer_init) (wd_timeout_type_t timeout_type); 55 val_status_t (*wd_timer_enable) (void); 56 val_status_t (*wd_timer_disable) (void); 57 val_status_t (*wd_reprogram_timer) (wd_timeout_type_t timeout_type); 58 val_status_t (*set_boot_flag) (boot_state_t state); 59 val_status_t (*get_boot_flag) (boot_state_t *state); 60 val_status_t (*get_test_data) (int32_t nvm_index, int32_t *test_data); 61 val_status_t (*set_test_data) (int32_t nvm_index, int32_t test_data); 62 int32_t (*crypto_function) (int type, ...); 63 int32_t (*storage_function) (int type, ...); 64 int32_t (*attestation_function) (int type, ...); 65 } val_api_t; 66 67 typedef struct { 68 uint32_t (*framework_version) (void); 69 uint32_t (*version) (uint32_t sid); 70 psa_handle_t (*connect) (uint32_t sid, uint32_t version); 71 psa_status_t (*call) (psa_handle_t handle, 72 int32_t type, 73 const psa_invec *in_vec, 74 size_t in_len, 75 psa_outvec *out_vec, 76 size_t out_len); 77 void (*close) (psa_handle_t handle); 78 } psa_api_t; 79 80 typedef void (*test_fptr_t)(val_api_t *val, psa_api_t *psa); 81 82 typedef struct { 83 test_id_t test_id; 84 test_fptr_t entry_addr; 85 } val_test_info_t; 86 87 typedef enum { 88 VAL_TEST_IDX0 = 0x0, 89 VAL_TEST_IDX1 = 0x1, 90 VAL_TEST_IDX2 = 0x2, 91 VAL_TEST_IDX3 = 0x3, 92 VAL_TEST_IDX4 = 0x4, 93 VAL_TEST_IDX5 = 0x5, 94 VAL_TEST_IDX6 = 0x6, 95 VAL_TEST_IDX7 = 0x7, 96 VAL_TEST_IDX8 = 0x8, 97 VAL_TEST_IDX9 = 0x9, 98 VAL_TEST_IDX10 = 0xA, 99 VAL_TEST_IDX11 = 0xB, 100 VAL_TEST_IDX12 = 0xC, 101 VAL_TEST_IDX13 = 0xD, 102 VAL_TEST_IDX14 = 0xE, 103 VAL_TEST_IDX15 = 0xF, 104 VAL_TEST_IDX16 = 0x10, 105 VAL_TEST_IDX17 = 0x11, 106 VAL_TEST_IDX18 = 0x12, 107 VAL_TEST_IDX19 = 0x13, 108 VAL_TEST_IDX20 = 0x14, 109 VAL_TEST_IDX21 = 0x15, 110 VAL_TEST_IDX22 = 0x16, 111 VAL_TEST_IDX23 = 0x17, 112 VAL_TEST_IDX24 = 0x18, 113 VAL_TEST_IDX25 = 0x19, 114 VAL_TEST_IDX26 = 0x1A, 115 VAL_TEST_IDX27 = 0x1B, 116 VAL_TEST_IDX28 = 0x1C, 117 VAL_TEST_IDX29 = 0x1D, 118 VAL_TEST_IDX30 = 0x1E, 119 } val_test_index_t; 120 121 #include "test_entry_fn_declare_list.inc" 122 123 void test_entry(val_api_t *val, psa_api_t *psa); 124 #endif 125