lib/sw_services/xilplmi/src/xplmi_err.c
void XPlmi_EmInit(XPlmi_ShutdownHandler_t SystemShutdown,
		  XPlmi_RestartHandler_t SubsystemRestart)
{
	u32 Index;
	u32 PmcErr1Status;
	u32 PmcErr2Status;
	u32 FwErr;
	u32 RegMask;
	u32 SiliconVal = XPlmi_In32(PMC_TAP_VERSION) &
			PMC_TAP_VERSION_PMC_VERSION_MASK;

	/* Register Error module commands */
	XPlmi_ErrModuleInit();

	/* Save FW_ERR register value to RTCA and clear it */
	FwErr = XPlmi_In32(PMC_GLOBAL_PMC_FW_ERR);
	XPlmi_Out32(XPLMI_RTCFG_PMC_FW_ERR_VAL_ADDR, FwErr);
	XPlmi_Out32(PMC_GLOBAL_PMC_FW_ERR, 0x0U);

	/* Disable all the Error Actions */
	XPlmi_Out32(PMC_GLOBAL_PMC_POR1_DIS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_ERR_OUT1_DIS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_IRQ1_DIS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_SRST1_DIS, MASK32_ALL_HIGH);

	PmcErr1Status = XPlmi_In32(PMC_GLOBAL_PMC_ERR1_STATUS);
	PmcErr2Status = XPlmi_In32(PMC_GLOBAL_PMC_ERR2_STATUS);

	/* Ignore SSIT Errors on ES1 */
	if (SiliconVal == XPLMI_SILICON_ES1_VAL) {
		PmcErr1Status &= ~(XPLMI_PMC_ERR1_SSIT_MASK);
		PmcErr2Status &= ~(XPLMI_PMC_ERR2_SSIT_MASK);
	}

	XPlmi_Out32(XPLMI_RTCFG_PMC_ERR1_STATUS_ADDR, PmcErr1Status);
	XPlmi_Out32(XPLMI_RTCFG_PMC_ERR2_STATUS_ADDR, PmcErr2Status);
	if (PmcErr1Status != 0U) {
		XPlmi_Printf(DEBUG_INFO, "PMC_GLOBAL_PMC_ERR1_STATUS: "
			"0x%08x\n\r", PmcErr1Status);
	}
	if (PmcErr2Status != 0U) {
		XPlmi_Printf(DEBUG_INFO, "PMC_GLOBAL_PMC_ERR2_STATUS: "
			"0x%08x\n\r", PmcErr2Status);
	}

	/* Clear the error status registers */
	XPlmi_Out32(PMC_GLOBAL_PMC_ERR1_STATUS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_ERR2_STATUS, MASK32_ALL_HIGH);

	/* Detect if we are in over-temperature condition */
	XPlmi_SysMonOTDetect();

	PmSystemShutdown = SystemShutdown;
	PmSubsysRestart = SubsystemRestart;

	/* Set the default actions as defined in the Error table */
	for (Index = XPLMI_ERROR_BOOT_CR;
		Index < XPLMI_ERROR_PMCERR1_MAX; Index++) {
		if (ErrorTable[Index].Action != XPLMI_EM_ACTION_INVALID) {
			RegMask = XPlmi_ErrRegMask(Index);
			if (XPlmi_EmSetAction(XPLMI_NODETYPE_EVENT_ERROR_PMC_ERR1, RegMask,
						ErrorTable[Index].Action,
						ErrorTable[Index].Handler) != XST_SUCCESS) {
				XPlmi_Printf(DEBUG_GENERAL,
						"Warning: XPlmi_EmInit: Failed to "
						"set action for PMC ERR1: %u\r\n", Index);
			}
		}
	}

	for (Index = XPLMI_ERROR_PMCAPB;
		Index < XPLMI_ERROR_PMCERR2_MAX; Index++) {
		if (ErrorTable[Index].Action != XPLMI_EM_ACTION_INVALID) {
			RegMask = XPlmi_ErrRegMask(Index);
			if (XPlmi_EmSetAction(XPLMI_NODETYPE_EVENT_ERROR_PMC_ERR2, RegMask,
						ErrorTable[Index].Action,
						ErrorTable[Index].Handler) != XST_SUCCESS) {
				XPlmi_Printf(DEBUG_GENERAL,
						"Warning: XPlmi_EmInit: Failed to "
						"set action for PMC ERR2: %u\r\n", Index);
			}
		}
	}
}
/*****************************************************************************/
/**
 * @brief	This function initializes the error module. Disables all the error
 * actions and registers default action.
 *
 * @param	SystemShutdown is the pointer to the PM system shutdown
 *		callback handler for action subtype system shutdown
 * @param	SubsystemRestart is pointer to the PM subsystem restart
 *		with CPU idle support handler for action subtype restart
 *
 * @return	None
 *
 *****************************************************************************/
@brief       This function initializes the error module. Disables all the error
actions and registers default action.

@param       SystemShutdown is the pointer to the PM system shutdown
callback handler for action subtype system shutdown
@param       SubsystemRestart is pointer to the PM subsystem restart
with CPU idle support handler for action subtype restart

@return      None
@brief This function initializes the error module . Disables all the error actions and registers default action . @param SystemShutdown is the pointer to the PM system shutdown callback handler for action subtype system shutdown @param SubsystemRestart is pointer to the PM subsystem restart with CPU idle support handler for action subtype restart @return None
void XPlmi_EmInit(XPlmi_ShutdownHandler_t SystemShutdown,
		  XPlmi_RestartHandler_t SubsystemRestart)
{
	u32 Index;
	u32 PmcErr1Status;
	u32 PmcErr2Status;
	u32 FwErr;
	u32 RegMask;
	u32 SiliconVal = XPlmi_In32(PMC_TAP_VERSION) &
			PMC_TAP_VERSION_PMC_VERSION_MASK;
	XPlmi_ErrModuleInit();
	FwErr = XPlmi_In32(PMC_GLOBAL_PMC_FW_ERR);
	XPlmi_Out32(XPLMI_RTCFG_PMC_FW_ERR_VAL_ADDR, FwErr);
	XPlmi_Out32(PMC_GLOBAL_PMC_FW_ERR, 0x0U);
	XPlmi_Out32(PMC_GLOBAL_PMC_POR1_DIS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_ERR_OUT1_DIS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_IRQ1_DIS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_SRST1_DIS, MASK32_ALL_HIGH);
	PmcErr1Status = XPlmi_In32(PMC_GLOBAL_PMC_ERR1_STATUS);
	PmcErr2Status = XPlmi_In32(PMC_GLOBAL_PMC_ERR2_STATUS);
	if (SiliconVal == XPLMI_SILICON_ES1_VAL) {
		PmcErr1Status &= ~(XPLMI_PMC_ERR1_SSIT_MASK);
		PmcErr2Status &= ~(XPLMI_PMC_ERR2_SSIT_MASK);
	}
	XPlmi_Out32(XPLMI_RTCFG_PMC_ERR1_STATUS_ADDR, PmcErr1Status);
	XPlmi_Out32(XPLMI_RTCFG_PMC_ERR2_STATUS_ADDR, PmcErr2Status);
	if (PmcErr1Status != 0U) {
		XPlmi_Printf(DEBUG_INFO, "PMC_GLOBAL_PMC_ERR1_STATUS: "
			"0x%08x\n\r", PmcErr1Status);
	}
	if (PmcErr2Status != 0U) {
		XPlmi_Printf(DEBUG_INFO, "PMC_GLOBAL_PMC_ERR2_STATUS: "
			"0x%08x\n\r", PmcErr2Status);
	}
	XPlmi_Out32(PMC_GLOBAL_PMC_ERR1_STATUS, MASK32_ALL_HIGH);
	XPlmi_Out32(PMC_GLOBAL_PMC_ERR2_STATUS, MASK32_ALL_HIGH);
	XPlmi_SysMonOTDetect();
	PmSystemShutdown = SystemShutdown;
	PmSubsysRestart = SubsystemRestart;
	for (Index = XPLMI_ERROR_BOOT_CR;
		Index < XPLMI_ERROR_PMCERR1_MAX; Index++) {
		if (ErrorTable[Index].Action != XPLMI_EM_ACTION_INVALID) {
			RegMask = XPlmi_ErrRegMask(Index);
			if (XPlmi_EmSetAction(XPLMI_NODETYPE_EVENT_ERROR_PMC_ERR1, RegMask,
						ErrorTable[Index].Action,
						ErrorTable[Index].Handler) != XST_SUCCESS) {
				XPlmi_Printf(DEBUG_GENERAL,
						"Warning: XPlmi_EmInit: Failed to "
						"set action for PMC ERR1: %u\r\n", Index);
			}
		}
	}
	for (Index = XPLMI_ERROR_PMCAPB;
		Index < XPLMI_ERROR_PMCERR2_MAX; Index++) {
		if (ErrorTable[Index].Action != XPLMI_EM_ACTION_INVALID) {
			RegMask = XPlmi_ErrRegMask(Index);
			if (XPlmi_EmSetAction(XPLMI_NODETYPE_EVENT_ERROR_PMC_ERR2, RegMask,
						ErrorTable[Index].Action,
						ErrorTable[Index].Handler) != XST_SUCCESS) {
				XPlmi_Printf(DEBUG_GENERAL,
						"Warning: XPlmi_EmInit: Failed to "
						"set action for PMC ERR2: %u\r\n", Index);
			}
		}
	}
}
void XPlmi_EmInit ( XPlmi_ShutdownHandler_t SystemShutdown , XPlmi_RestartHandler_t SubsystemRestart ) { u32 Index ; u32 PmcErr1Status ; u32 PmcErr2Status ; u32 FwErr ; u32 RegMask ; u32 SiliconVal = XPlmi_In32 ( PMC_TAP_VERSION ) & PMC_TAP_VERSION_PMC_VERSION_MASK ; XPlmi_ErrModuleInit ( ) ; FwErr = XPlmi_In32 ( PMC_GLOBAL_PMC_FW_ERR ) ; XPlmi_Out32 ( XPLMI_RTCFG_PMC_FW_ERR_VAL_ADDR , FwErr ) ; XPlmi_Out32 ( PMC_GLOBAL_PMC_FW_ERR , 0x0U ) ; XPlmi_Out32 ( PMC_GLOBAL_PMC_POR1_DIS , MASK32_ALL_HIGH ) ; XPlmi_Out32 ( PMC_GLOBAL_PMC_ERR_OUT1_DIS , MASK32_ALL_HIGH ) ; XPlmi_Out32 ( PMC_GLOBAL_PMC_IRQ1_DIS , MASK32_ALL_HIGH ) ; XPlmi_Out32 ( PMC_GLOBAL_PMC_SRST1_DIS , MASK32_ALL_HIGH ) ; PmcErr1Status = XPlmi_In32 ( PMC_GLOBAL_PMC_ERR1_STATUS ) ; PmcErr2Status = XPlmi_In32 ( PMC_GLOBAL_PMC_ERR2_STATUS ) ; if ( SiliconVal == XPLMI_SILICON_ES1_VAL ) { PmcErr1Status &= ~ ( XPLMI_PMC_ERR1_SSIT_MASK ) ; PmcErr2Status &= ~ ( XPLMI_PMC_ERR2_SSIT_MASK ) ; } XPlmi_Out32 ( XPLMI_RTCFG_PMC_ERR1_STATUS_ADDR , PmcErr1Status ) ; XPlmi_Out32 ( XPLMI_RTCFG_PMC_ERR2_STATUS_ADDR , PmcErr2Status ) ; if ( PmcErr1Status != 0U ) { XPlmi_Printf ( DEBUG_INFO , " " " \n \r " , PmcErr1Status ) ; } if ( PmcErr2Status != 0U ) { XPlmi_Printf ( DEBUG_INFO , " " " \n \r " , PmcErr2Status ) ; } XPlmi_Out32 ( PMC_GLOBAL_PMC_ERR1_STATUS , MASK32_ALL_HIGH ) ; XPlmi_Out32 ( PMC_GLOBAL_PMC_ERR2_STATUS , MASK32_ALL_HIGH ) ; XPlmi_SysMonOTDetect ( ) ; PmSystemShutdown = SystemShutdown ; PmSubsysRestart = SubsystemRestart ; for ( Index = XPLMI_ERROR_BOOT_CR ; Index < XPLMI_ERROR_PMCERR1_MAX ; Index ++ ) { if ( ErrorTable [ Index ] . Action != XPLMI_EM_ACTION_INVALID ) { RegMask = XPlmi_ErrRegMask ( Index ) ; if ( XPlmi_EmSetAction ( XPLMI_NODETYPE_EVENT_ERROR_PMC_ERR1 , RegMask , ErrorTable [ Index ] . Action , ErrorTable [ Index ] . Handler ) != XST_SUCCESS ) { XPlmi_Printf ( DEBUG_GENERAL , " " " \r \n " , Index ) ; } } } for ( Index = XPLMI_ERROR_PMCAPB ; Index < XPLMI_ERROR_PMCERR2_MAX ; Index ++ ) { if ( ErrorTable [ Index ] . Action != XPLMI_EM_ACTION_INVALID ) { RegMask = XPlmi_ErrRegMask ( Index ) ; if ( XPlmi_EmSetAction ( XPLMI_NODETYPE_EVENT_ERROR_PMC_ERR2 , RegMask , ErrorTable [ Index ] . Action , ErrorTable [ Index ] . Handler ) != XST_SUCCESS ) { XPlmi_Printf ( DEBUG_GENERAL , " " " \r \n " , Index ) ; } } } }
@brief       This function initializes the error module.
@brief This function initializes the error module .
/* Register Error module commands */ /* Save FW_ERR register value to RTCA and clear it */ /* Disable all the Error Actions */ /* Ignore SSIT Errors on ES1 */ /* Clear the error status registers */ /* Detect if we are in over-temperature condition */ /* Set the default actions as defined in the Error table */