/* * Copyright (c) Hisilicon Technologies Co., Ltd. 2019-2021. All rights reserved. * Description: akl test. * Author: Hisilicon * Create: 2019-11-25 */ #include #include #include #include "uapi_cert.h" #define SOC_ID_KLAD SOC_ID_USR #define ext_dbg_klad(fmt...) soc_log_dbg(fmt) #define ext_fatal_klad(fmt...) soc_log_fatal(fmt) #define ext_err_klad(fmt...) soc_log_err(fmt) #define ext_warn_klad(fmt...) soc_log_warn(fmt) #define ext_info_klad(fmt...) soc_log_info(fmt) #define print_err(val) ext_err_klad("%s\n", val) #define print_dbg_hex(val) ext_info_klad("%s = 0x%08x\n", #val, val) #define print_dbg_hex2(x, y) ext_info_klad("%s = 0x%08x %s = 0x%08x\n", #x, x, #y, y) #define print_dbg_hex3(x, y, z) ext_info_klad("%s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #x, x, #y, y, #z, z) #define print_err_hex(val) ext_err_klad("%s = 0x%08x\n", #val, val) #define print_err_hex2(x, y) ext_err_klad("%s = 0x%08x %s = 0x%08x\n", #x, x, #y, y) #define print_err_hex3(x, y, z) ext_err_klad("%s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #x, x, #y, y, #z, z) #define print_err_hex4(w, x, y, z) ext_err_klad("%s = 0x%08x %s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #w, \ w, #x, x, #y, y, #z, z) #define print_dbg_func_hex(func, val) ext_info_klad("call [%s]%s = 0x%08x\n", #func, #val, val) #define print_dbg_func_hex2(func, x, y) ext_info_klad("call [%s]%s = 0x%08x %s = 0x%08x\n", #func, #x, x, #y, y) #define print_dbg_func_hex3(func, x, y, z) \ ext_info_klad("call [%s]%s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #func, #x, x, #y, y, #z, z) #define print_dbg_func_hex4(func, w, x, y, z) \ ext_info_klad("call [%s]%s = 0x%08x %s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #func, #w, w, #x, x, #y, y, #z, z) #define print_err_func_hex(func, val) ext_err_klad("call [%s]%s = 0x%08x\n", #func, #val, val) #define print_err_func_hex2(func, x, y) ext_err_klad("call [%s]%s = 0x%08x %s = 0x%08x\n", #func, #x, x, #y, y) #define print_err_func_hex3(func, x, y, z) \ ext_err_klad("call [%s]%s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #func, #x, x, #y, y, #z, z) #define print_err_func_hex4(func, w, x, y, z) \ ext_err_klad("call [%s]%s = 0x%08x %s = 0x%08x %s = 0x%08x %s = 0x%08x\n", #func, #w, w, #x, x, #y, y, #z, z) #define dbg_print_dbg_hex(val) ext_dbg_klad("%s = 0x%08x\n", #val, val) #define print_err_val(val) ext_err_klad("%s = %d\n", #val, val) #define print_err_point(val) ext_err_klad("%s = %p\n", #val, val) #define print_err_code(err_code) ext_err_klad("return [0x%08x]\n", err_code) #define print_warn_code(err_code) ext_warn_klad("return [0x%08x]\n", err_code) #define print_err_func(func, err_code) ext_err_klad("call [%s] return [0x%08x]\n", #func, err_code) #define CMD_NUM 2 int main(int argc, char *argv[]) { int ret; uapi_cert_res_handle *handle = TD_NULL; td_size_t num_of_proccessed = 0; uapi_cert_command command[CMD_NUM] = { { {0}, {0}, {0}, { 0x04, 0x01, 0x00, 0x01 }, UAPI_CERT_TIMEOUT_DEFAULT }, { {0}, {0}, {0}, { 0x04, 0x04, 0x00, 0x01 }, UAPI_CERT_TIMEOUT_DEFAULT } }; if (argv == TD_NULL) { printf("argv is NULL \n"); return 0; } ret = uapi_cert_init(); if (ret != TD_SUCCESS) { print_err_func(uapi_cert_init, ret); return ret; } ret = uapi_cert_reset(); if (ret != TD_SUCCESS) { print_err_func(uapi_cert_reset, ret); goto out; } ret = uapi_cert_lock(&handle); if (ret != TD_SUCCESS) { print_err_func(uapi_cert_lock, ret); goto out; } ret = uapi_cert_exchange(handle, CMD_NUM, command, &num_of_proccessed); if (ret != TD_SUCCESS) { print_err_func(uapi_cert_unlock, ret); goto unlock; } unlock: ret = uapi_cert_unlock(handle); if (ret != TD_SUCCESS) { print_err_func(uapi_cert_unlock, ret); goto out; } out: uapi_cert_deinit(); return ret; }