1 /* 2 * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "esp_memprot_err.h" 8 #include "hal/memprot_types.h" 9 #include "esp_memprot_types.h" 10 esp_mprot_ll_err_to_esp_err(const memprot_ll_err_t err)11esp_err_t esp_mprot_ll_err_to_esp_err(const memprot_ll_err_t err) 12 { 13 switch (err) { 14 case MEMP_LL_OK: return ESP_OK; 15 case MEMP_LL_ERR_SPLIT_ADDR_OUT_OF_RANGE: return ESP_ERR_MEMPROT_SPLIT_ADDR_OUT_OF_RANGE; 16 case MEMP_LL_ERR_SPLIT_ADDR_UNALIGNED: return ESP_ERR_MEMPROT_SPLIT_ADDR_UNALIGNED; 17 case MEMP_LL_ERR_UNI_BLOCK_INVALID: return ESP_ERR_MEMPROT_UNIMGMT_BLOCK_INVALID; 18 case MEMP_LL_ERR_WORLD_INVALID: return ESP_ERR_MEMPROT_WORLD_INVALID; 19 case MEMP_LL_ERR_AREA_INVALID: return ESP_ERR_MEMPROT_AREA_INVALID; 20 default: 21 return ESP_FAIL; 22 } 23 } 24 esp_mprot_ll_world_to_hl_world(const memprot_ll_world_t world)25esp_mprot_pms_world_t esp_mprot_ll_world_to_hl_world(const memprot_ll_world_t world) 26 { 27 switch (world) { 28 case MEMP_LL_WORLD_NONE: return MEMPROT_PMS_WORLD_NONE; 29 case MEMP_LL_WORLD_0: return MEMPROT_PMS_WORLD_0; 30 case MEMP_LL_WORLD_1: return MEMPROT_PMS_WORLD_1; 31 default: 32 return MEMPROT_PMS_WORLD_INVALID; 33 } 34 } 35 esp_mprot_oper_type_to_str(const uint32_t oper_type)36const char *esp_mprot_oper_type_to_str(const uint32_t oper_type) 37 { 38 switch (oper_type) { 39 case MEMPROT_OP_NONE: return "NONE"; 40 case MEMPROT_OP_READ: return "READ"; 41 case MEMPROT_OP_WRITE: return "WRITE"; 42 case MEMPROT_OP_EXEC: return "EXEC"; 43 default: return "INVALID"; 44 } 45 } 46 esp_mprot_pms_world_to_str(const esp_mprot_pms_world_t world_type)47const char *esp_mprot_pms_world_to_str(const esp_mprot_pms_world_t world_type) 48 { 49 switch (world_type) { 50 case MEMPROT_PMS_WORLD_NONE: 51 return "PMS_WORLD_NONE"; 52 case MEMPROT_PMS_WORLD_0: 53 return "PMS_WORLD_0"; 54 case MEMPROT_PMS_WORLD_1: 55 return "PMS_WORLD_1"; 56 case MEMPROT_PMS_WORLD_2: 57 return "PMS_WORLD_2"; 58 case MEMPROT_PMS_WORLD_ALL: 59 return "PMS_WORLD_ALL"; 60 default: 61 return "PMS_WORLD_INVALID"; 62 } 63 } 64