1 // Copyright (C) 2022 Beken Corporation 2 // 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 #pragma once 16 17 #include "hal_config.h" 18 #include "mpc_hw.h" 19 #include "mpc_ll.h" 20 #include <driver/hal/hal_mpc_types.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 typedef struct { 27 mpc_hw_t *hw; 28 mpc_dev_t dev; 29 } mpc_hal_t; 30 31 #define MPC_BLOCK_LUT_MAX_BIT_NUM (32) 32 33 #define mpc_hal_get_block_size(hal) mpc_ll_get_block_size((hal)->hw) 34 #define mpc_hal_enable_sec_lock(hal) mpc_ll_enable_sec_lock((hal)->hw) 35 #define mpc_hal_get_max_block_index(hal) mpc_ll_get_max_block_index((hal)->hw) 36 #define mpc_hal_set_block_index(hal, index) mpc_ll_set_block_index((hal)->hw, index) 37 #define mpc_hal_enable_auto_increase(hal) mpc_ll_enable_auto_increase((hal)->hw) 38 #define mpc_hal_disable_auto_increase(hal) mpc_ll_disable_auto_increase((hal)->hw) 39 40 bk_err_t mpc_hal_init(mpc_hal_t *hal); 41 bk_err_t mpc_hal_config_block_lut(mpc_hal_t *hal, uint32_t block_offset, uint32_t block_num, mpc_block_secure_type_t secure_type); 42 43 #if CFG_HAL_DEBUG_MPC 44 void mpc_struct_dump(mpc_dev_t mpc_dev); 45 #else 46 #define mpc_struct_dump(mpc_dev) 47 #endif 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 54