From 1b1368305f839ab88628f0d306dde92a0854385d Mon Sep 17 00:00:00 2001 From: Sarat Chand Savitala Date: Sat, 8 Aug 2015 15:44:24 +0530 Subject: [PATCH] sw_apps:zynqmp_fsbl: Fix to handle invalid cluster id Added check to detect invalid cluster id and throw error accordingly. Signed-off-by: Sarat Chand Savitala Acked-by: Krishna Chaitanya Patakamuri --- lib/sw_apps/zynqmp_fsbl/src/xfsbl_error.h | 1 + .../zynqmp_fsbl/src/xfsbl_initialization.c | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_error.h b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_error.h index 232899c2..391b7c7d 100644 --- a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_error.h +++ b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_error.h @@ -168,6 +168,7 @@ extern "C" { #define XFSBL_ERROR_R5_0_TCM_POWER_UP (0x46U) #define XFSBL_ERROR_R5_1_TCM_POWER_UP (0x47U) #define XFSBL_ERROR_R5_L_TCM_POWER_UP (0x48U) +#define XFSBL_ERROR_UNSUPPORTED_CLUSTER_ID (0x49U) #define XFSBL_FAILURE (0x3FFU) diff --git a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_initialization.c b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_initialization.c index d5b6ee27..379fd72f 100644 --- a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_initialization.c +++ b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_initialization.c @@ -257,13 +257,18 @@ static u32 XFsbl_ProcessorInit(XFsblPs * FsblInstancePtr) */ if (ClusterId == 0x80000004U) { ClusterId = 0xC0000100U; + } else if (ClusterId == 0x80000005U) { + /* this corresponds to R5-1 */ + Status = XFSBL_ERROR_UNSUPPORTED_CLUSTER_ID; + XFsbl_Printf(DEBUG_GENERAL, + "XFSBL_ERROR_UNSUPPORTED_CLUSTER_ID\n\r"); + goto END; + } else { + /* For MISRA C compliance */ } } - /** - * store the processor ID based on the cluster ID - * Need a check for unsupported Cluster ID - */ + /* store the processor ID based on the cluster ID */ if ((ClusterId & XFSBL_CLUSTER_ID_MASK) == XFSBL_A53_PROCESSOR) { XFsbl_Printf(DEBUG_GENERAL,"Running on A53-0 "); FsblInstancePtr->ProcessorID = @@ -278,7 +283,7 @@ static u32 XFsbl_ProcessorInit(XFsblPs * FsblInstancePtr) FsblInstancePtr->A53ExecState = XIH_PH_ATTRB_A53_EXEC_ST_AA32; #endif - } else { + } else if ((ClusterId & XFSBL_CLUSTER_ID_MASK) == XFSBL_R5_PROCESSOR) { /* A53ExecState is not valid for R5 */ FsblInstancePtr->A53ExecState = XIH_INVALID_EXEC_ST; @@ -304,12 +309,19 @@ static u32 XFsbl_ProcessorInit(XFsblPs * FsblInstancePtr) Index += 4; } + } else { + Status = XFSBL_ERROR_UNSUPPORTED_CLUSTER_ID; + XFsbl_Printf(DEBUG_GENERAL, + "XFSBL_ERROR_UNSUPPORTED_CLUSTER_ID\n\r"); + goto END; } /** * Register the exception handlers */ XFsbl_RegisterHandlers(); + +END: return Status; }