]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(xilinx): fix misra defects
authorJay Buddhabhatti <jay.buddhabhatti@amd.com>
Fri, 10 Feb 2023 06:56:53 +0000 (22:56 -0800)
committerJay Buddhabhatti <jay.buddhabhatti@amd.com>
Tue, 28 Mar 2023 06:09:00 +0000 (23:09 -0700)
This patch fixes defects 5.5, 10.1, 10.3, 10.4, 10.7 reported
by MISRA-2012 scan.

Signed-off-by: Jay Buddhabhatti <jay.buddhabhatti@amd.com>
Change-Id: Ie6f6e9bf2ce1335bbb61aa2e69a3a196865fd504

plat/xilinx/common/include/pm_defs.h
plat/xilinx/common/include/pm_node.h
plat/xilinx/common/pm_service/pm_api_sys.c
plat/xilinx/common/pm_service/pm_svc_main.c

index eae1f842dbf75cce4106aa57e579f6e6deda169f..09507dda5f271d05baf0253a4f7198041a544551 100644 (file)
@@ -30,9 +30,9 @@
 #define XPM_DEVID_ACPU_0       APU_DEVID(XPM_NODEIDX_DEV_ACPU_0)
 #define XPM_DEVID_ACPU_1       APU_DEVID(XPM_NODEIDX_DEV_ACPU_1)
 
-#define PERIPH_DEVID(IDX)      NODEID(XPM_NODECLASS_DEVICE, \
-                                      XPM_NODESUBCL_DEV_PERIPH, \
-                                      XPM_NODETYPE_DEV_PERIPH, (IDX))
+#define PERIPH_DEVID(IDX)      NODEID((uint32_t)XPM_NODECLASS_DEVICE, \
+                                      (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \
+                                      (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX))
 
 #define PM_GET_CALLBACK_DATA           0xa01U
 #define PM_GET_TRUSTZONE_VERSION       0xa03U
index 0d5616c739aec4a8b7e4d64aa6a749da77318299..b6c2d81429041215586318b7b8707da3fc897399 100644 (file)
 #define NODE_SUBCLASS_SHIFT    20U
 #define NODE_TYPE_SHIFT                14U
 #define NODE_INDEX_SHIFT       0U
-#define NODE_CLASS_MASK_BITS    0x3F
-#define NODE_SUBCLASS_MASK_BITS 0x3F
-#define NODE_TYPE_MASK_BITS     0x3F
-#define NODE_INDEX_MASK_BITS    0x3FFF
+#define NODE_CLASS_MASK_BITS    GENMASK_32(5, 0)
+#define NODE_SUBCLASS_MASK_BITS GENMASK_32(5, 0)
+#define NODE_TYPE_MASK_BITS     GENMASK_32(5, 0)
+#define NODE_INDEX_MASK_BITS    GENMASK_32(13, 0)
 #define NODE_CLASS_MASK         (NODE_CLASS_MASK_BITS << NODE_CLASS_SHIFT)
 #define NODE_SUBCLASS_MASK      (NODE_SUBCLASS_MASK_BITS << NODE_SUBCLASS_SHIFT)
 #define NODE_TYPE_MASK          (NODE_TYPE_MASK_BITS << NODE_TYPE_SHIFT)
index 582b724f85ca5d67f1817074411cfa7386fa8b61..c36a0ec8f0eb3ec05ad879e70d238abdbc95f07f 100644 (file)
@@ -48,7 +48,7 @@ void pm_client_set_wakeup_sources(uint32_t node_id)
 {
        uint32_t reg_num, device_id;
        uint8_t pm_wakeup_nodes_set[XPM_NODEIDX_DEV_MAX] = {0U};
-       uintptr_t isenabler1 = PLAT_GICD_BASE_VALUE + GICD_ISENABLER + 4U;
+       uint32_t isenabler1 = PLAT_GICD_BASE_VALUE + GICD_ISENABLER + 4U;
 
        zeromem(&pm_wakeup_nodes_set, (u_register_t)sizeof(pm_wakeup_nodes_set));
 
@@ -65,7 +65,7 @@ void pm_client_set_wakeup_sources(uint32_t node_id)
                        uint32_t idx, irq, lowest_set = reg & (-reg);
                        enum pm_ret_status ret;
 
-                       idx = __builtin_ctz(lowest_set);
+                       idx = (uint32_t)__builtin_ctz(lowest_set);
                        irq = base_irq + idx;
 
                        if (irq > IRQ_MAX) {
@@ -78,7 +78,7 @@ void pm_client_set_wakeup_sources(uint32_t node_id)
                        if (node_idx > XPM_NODEIDX_DEV_MIN) {
                                if (pm_wakeup_nodes_set[node_idx] == 0U) {
                                        /* Get device ID from node index */
-                                       device_id = PERIPH_DEVID(node_idx);
+                                       device_id = PERIPH_DEVID((uint32_t)node_idx);
                                        ret = pm_set_wakeup_source(node_id,
                                                                   device_id, 1U,
                                                                   SECURE_FLAG);
@@ -461,7 +461,7 @@ enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
        PM_PACK_PAYLOAD5(payload, LIBPM_MODULE_ID, flag, PM_QUERY_DATA, qid,
                         arg1, arg2, arg3);
 
-       ret = pm_feature_check(PM_QUERY_DATA, &version[0], flag);
+       ret = pm_feature_check((uint32_t)PM_QUERY_DATA, &version[0], flag);
        if (ret == PM_RET_SUCCESS) {
                fw_api_version = version[0] & 0xFFFFU;
                if ((fw_api_version == 2U) &&
@@ -515,10 +515,10 @@ enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id,
                ret =  pm_pll_get_mode(arg1, value, flag);
                break;
        case IOCTL_SET_PLL_FRAC_DATA:
-               ret =  pm_pll_set_param(arg1, PM_PLL_PARAM_DATA, arg2, flag);
+               ret =  pm_pll_set_param(arg1, (uint32_t)PM_PLL_PARAM_DATA, arg2, flag);
                break;
        case IOCTL_GET_PLL_FRAC_DATA:
-               ret =  pm_pll_get_param(arg1, PM_PLL_PARAM_DATA, value, flag);
+               ret =  pm_pll_get_param(arg1, (uint32_t)PM_PLL_PARAM_DATA, value, flag);
                break;
        case IOCTL_SET_SGI:
                /* Get the sgi number */
index 6fd7f0d52c48beeb39e7750797925a073dea3697..1bd2192a61c716f51d4ef5fafef56845f1e8e357 100644 (file)
@@ -168,7 +168,7 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg,
 
        switch (api_id) {
 
-       case PM_IOCTL:
+       case (uint32_t)PM_IOCTL:
        {
                uint32_t value = 0U;
 
@@ -181,7 +181,7 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg,
                SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U);
        }
 
-       case PM_QUERY_DATA:
+       case (uint32_t)PM_QUERY_DATA:
        {
                uint32_t data[PAYLOAD_ARG_CNT] = { 0 };
 
@@ -192,7 +192,7 @@ static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg,
                         (uint64_t)data[1] | ((uint64_t)data[2] << 32U));
        }
 
-       case PM_FEATURE_CHECK:
+       case (uint32_t)PM_FEATURE_CHECK:
        {
                uint32_t result[PAYLOAD_ARG_CNT] = {0U};
 
@@ -230,25 +230,25 @@ static uintptr_t eemi_psci_debugfs_handler(uint32_t api_id, uint32_t *pm_arg,
 
        switch (api_id) {
 
-       case PM_SELF_SUSPEND:
+       case (uint32_t)PM_SELF_SUSPEND:
                ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
                                      pm_arg[3], security_flag);
                SMC_RET1(handle, (u_register_t)ret);
 
-       case PM_FORCE_POWERDOWN:
+       case (uint32_t)PM_FORCE_POWERDOWN:
                ret = pm_force_powerdown(pm_arg[0], pm_arg[1], security_flag);
                SMC_RET1(handle, (u_register_t)ret);
 
-       case PM_REQ_SUSPEND:
+       case (uint32_t)PM_REQ_SUSPEND:
                ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
                                     pm_arg[3], security_flag);
                SMC_RET1(handle, (u_register_t)ret);
 
-       case PM_ABORT_SUSPEND:
+       case (uint32_t)PM_ABORT_SUSPEND:
                ret = pm_abort_suspend(pm_arg[0], security_flag);
                SMC_RET1(handle, (u_register_t)ret);
 
-       case PM_SYSTEM_SHUTDOWN:
+       case (uint32_t)PM_SYSTEM_SHUTDOWN:
                ret = pm_system_shutdown(pm_arg[0], pm_arg[1], security_flag);
                SMC_RET1(handle, (u_register_t)ret);
 
@@ -330,7 +330,7 @@ static uintptr_t eemi_handler(uint32_t api_id, uint32_t *pm_arg,
         * receive only 4 words from TF-A. So, this needs to be handled separately
         * than other eemi calls.
         */
-       if (api_id == PM_QUERY_DATA) {
+       if (api_id == (uint32_t)PM_QUERY_DATA) {
                if ((pm_arg[0] == XPM_QID_CLOCK_GET_NAME ||
                    pm_arg[0] == XPM_QID_PINCTRL_GET_FUNCTION_NAME) &&
                    ret == PM_RET_SUCCESS) {