1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #include "tc2_scmi.h" 9 10 #include <mod_resource_perms.h> 11 #include <mod_scmi_std.h> 12 13 #include <fwk_element.h> 14 #include <fwk_id.h> 15 #include <fwk_macros.h> 16 #include <fwk_module.h> 17 #include <fwk_module_idx.h> 18 19 /*! 20 * If the agent wants to modify permissions at run-time these tables 21 * must be allocated in writable memory. 22 */ 23 24 #define AGENT_IDX(agent_id) (agent_id - 1) 25 26 static struct mod_res_agent_protocol_permissions agent_protocol_permissions[2] = 27 { 28 [AGENT_IDX(SCP_SCMI_AGENT_ID_OSPM)] = 29 { 30 .protocols = MOD_RES_PERMS_SCMI_ALL_PROTOCOLS_ALLOWED, 31 }, 32 33 /* PSCI agent has no access to clock, perf and sensor protocol */ 34 [AGENT_IDX(SCP_SCMI_AGENT_ID_PSCI)] = 35 { 36 .protocols = MOD_RES_PERMS_SCMI_CLOCK_PROTOCOL_DENIED | 37 MOD_RES_PERMS_SCMI_PERF_PROTOCOL_DENIED | 38 MOD_RES_PERMS_SCMI_SENSOR_PROTOCOL_DENIED, 39 }, 40 }; 41 42 /* 43 * Messages have an index offset from 0x3 as all agents can access 44 * the VERSION/ATTRIBUTES/MSG_ATTRIBUTES messages for all 45 * protocols, hence message 0x3 maps to bit[0], message 0x4 maps 46 * to bit[1], etc. 47 */ 48 static struct mod_res_agent_msg_permissions 49 agent_msg_permissions[2] = 50 { 51 [AGENT_IDX(SCP_SCMI_AGENT_ID_OSPM)] = 52 { 53 .messages = { 54 [MOD_RES_PERMS_SCMI_BASE_MESSAGE_IDX] = 0x0, 55 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_MESSAGE_IDX] = 56 0x0, 57 [MOD_RES_PERMS_SCMI_SYS_POWER_MESSAGE_IDX] = 0x0, 58 [MOD_RES_PERMS_SCMI_PERF_MESSAGE_IDX] = 0x0, 59 [MOD_RES_PERMS_SCMI_CLOCK_MESSAGE_IDX] = 0x0, 60 [MOD_RES_PERMS_SCMI_SENSOR_MESSAGE_IDX] = 0x0, 61 [MOD_RES_PERMS_SCMI_RESET_DOMAIN_MESSAGE_IDX] = 62 0x0, 63 }, 64 }, 65 [AGENT_IDX(SCP_SCMI_AGENT_ID_PSCI)] = 66 { 67 .messages = { 68 [MOD_RES_PERMS_SCMI_BASE_MESSAGE_IDX] = 0x0, 69 [MOD_RES_PERMS_SCMI_POWER_DOMAIN_MESSAGE_IDX] = 70 0x0, 71 [MOD_RES_PERMS_SCMI_SYS_POWER_MESSAGE_IDX] = 0x0, 72 [MOD_RES_PERMS_SCMI_PERF_MESSAGE_IDX] = 73 ((1 74 << (MOD_SCMI_PERF_DOMAIN_ATTRIBUTES - 75 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 76 (0 77 << (MOD_SCMI_PERF_DESCRIBE_LEVELS - 78 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 79 (1 80 << (MOD_SCMI_PERF_LIMITS_SET - 81 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 82 (1 83 << (MOD_SCMI_PERF_LIMITS_GET - 84 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 85 (1 86 << (MOD_SCMI_PERF_LEVEL_SET - 87 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 88 (1 89 << (MOD_SCMI_PERF_LEVEL_GET - 90 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 91 (1 92 << (MOD_SCMI_PERF_NOTIFY_LIMITS - 93 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 94 (1 95 << (MOD_SCMI_PERF_NOTIFY_LEVEL - 96 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES)) | 97 (1 98 << (MOD_SCMI_PERF_DESCRIBE_FAST_CHANNEL - 99 MOD_SCMI_PERF_DOMAIN_ATTRIBUTES))), 100 /* Clocks, no access */ 101 [MOD_RES_PERMS_SCMI_CLOCK_MESSAGE_IDX] = 0xff, 102 [MOD_RES_PERMS_SCMI_SENSOR_MESSAGE_IDX] = 0x0, 103 [MOD_RES_PERMS_SCMI_RESET_DOMAIN_MESSAGE_IDX] = 104 0x0, 105 }, 106 }, 107 }; 108 109 static struct mod_res_agent_permission agent_permissions = { 110 .agent_protocol_permissions = agent_protocol_permissions, 111 .agent_msg_permissions = agent_msg_permissions, 112 }; 113 114 struct fwk_module_config config_resource_perms = { 115 .data = 116 &(struct mod_res_resource_perms_config){ 117 .agent_permissions = (uintptr_t)&agent_permissions, 118 .agent_count = SCP_SCMI_AGENT_ID_COUNT, 119 .protocol_count = 6, 120 }, 121 }; 122