--- ./source/private_module/hdm/stub_v3/stub_hdm_routine.c	2018-03-30 08:15:22.000000000 +0000
+++ ./source/private_module/hdm/stub_v3/stub_hdm_routine.c.hotpatch	2019-04-01 01:27:18.000000000 +0000
@@ -1811,19 +1811,18 @@
     return;
 }
 
+/*Begin Modified by l00472145 DTS2019032206152 2019-03-27*/
+void dp_rt_all_disk_routine(void);
+/*End Modified by l00472145 DTS2019032206152 2019-03-27*/
+
 /**************************************************************************
    : hdmCheckRootDiskStatus
      : ϵͳ״̬IO
- : 
- : 
-   ֵ: 
-     : 
 **************************************************************************/
 void hdmCheckRootDiskStatus(CMD_S *contex)
 {
     uint32_t index = 0;
     HDM_ROOT_DISK_ROUTINE * pstRootDiskRt =NULL;
-
     SMART_TP_CALL(FDSA_RESTRICT_OOPS, HDM_ROOT_DISK_ROUTINE_RESTRICT_TASK);
     BDM_SET_BIT(HDM_ROOT_DISK_ROUTINE_BIT, (void *)(&g_rootDiskRoutineIsOnGoing));
 
@@ -1835,7 +1834,6 @@
     for(index = 0; index < HDM_MAX_ROOT_DISK_NUM_IN_ONE_CTRL; index ++)
     {
         pstRootDiskRt = &g_rootDiskRoutine[index];
-
         if(DISK_TYPE_NVME_SSD == pstRootDiskRt->diskType)
         {
             hdmCheckNvmeRootDiskStatus(index);
@@ -1843,15 +1841,17 @@
         else
         {
             hdmCheckScsiRootDiskStatus(index);
-        }
-        
+        }      
         DBG_LogDebug(LOG_ID_HDM_057D, "RD_RT: root disk[%u] type[%d]", 
             pstRootDiskRt->sdevId, pstRootDiskRt->diskType);
-    }
-    
+    }    
     BDM_CLEAR_BIT(HDM_ROOT_DISK_ROUTINE_BIT, (void *)(&g_rootDiskRoutineIsOnGoing));
     
     DBG_LogDebug(LOG_ID_HDM_057F, "RD_RT: root disk routine finish");
+    
+    /*Begin Modified by l00472145 DTS2019032206152 2019-03-27*/
+    dp_rt_all_disk_routine();
+    /*End Modified by l00472145 DTS2019032206152 2019-03-27*/
 }
 /* NVME Root Disk modified end */
 
@@ -2800,3 +2800,293 @@
 
 HDM_USE_TRACE_POINT /* PC-Lint */
 
+/*Begin Modified by l00472145 DTS2019032206152 2019-03-27*/
+/* RAIDű */
+#define ROOTDISK_RAID_CHECK_SCRIPT    "/OSM/coffer_bin/hotpatch/patch_cur/bdm_root_raid_check_script_DTS2019032206152.sh"
+/* RAID޸ű */
+#define ROOTDISK_RAID_RECOVER_SCRIPT  "/OSM/coffer_bin/hotpatch/patch_cur/bdm_root_raid_recover_script_DTS2019032206152.sh"
+
+/* SEͿɿԽ澯Ҫ⵽RAID쳣ʱŽи澯 */ 
+#define DP_RT_RAID_ALARM_THRESHOLD      (3)
+/* RAID޸ֵ10β޸ */
+#define DP_RT_RAID_RECOVER_THRESHOLD    (10)
+/* RAID쳣ֵ:űֵŷصĸʽ */
+#define RETURN_RAID_ABNORMAL       (1<<8)
+/* RAID״̬ :űֵŷصĸʽ */
+#define RETURN_RAID_NORMAL         (0)
+/*ϵͳڲ*/
+#define ROOT_DISK_INNER_FRAME_NUMBER_HDM  (0)
+
+bool g_dp_rt_raid_alarm = FALSE;     /* RAID澯״̬ */
+/* RAID ޸ʧܼ */
+uint32_t g_dp_rt_raid_abnoraml_count = 0; 
+/* RAID ޸ɹ */
+uint32_t g_dp_rt_raid_recover_count = 0; 
+
+/**************************************************************************
+   : dp_rt_set_raid_alarm_status
+     : ø澯״̬
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_set_raid_alarm_status(bool status)
+{
+    g_dp_rt_raid_alarm = status;
+}
+
+/**************************************************************************
+   : dp_rt_get_raid_alarm_status
+     : ȡ澯״̬
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+bool dp_rt_get_raid_alarm_status(void)
+{
+    return g_dp_rt_raid_alarm;
+}
+
+/**************************************************************************
+   : dp_rt_inc_raid_abnormal_count
+     : ޸ʧܴ1
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_inc_raid_abnormal_count(void)
+{
+    g_dp_rt_raid_abnoraml_count++;     
+}
+
+/**************************************************************************
+   : dp_rt_set_raid_abnormal_count
+     : ޸ʧܴ
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_set_raid_abnormal_count(uint32_t value)
+{
+    g_dp_rt_raid_abnoraml_count = value;     
+}
+
+/**************************************************************************
+   : dp_rt_get_raid_abnormal_count
+     : ȡ޸ʧܴ
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+uint32_t dp_rt_get_raid_abnormal_count(void)
+{
+    return g_dp_rt_raid_abnoraml_count;     
+}
+
+/**************************************************************************
+   : dp_rt_inc_raid_recover_count
+     : ޸ɹ1
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_inc_raid_recover_count(void)
+{
+    g_dp_rt_raid_recover_count++;     
+}
+
+/**************************************************************************
+   : dp_rt_set_raid_recover_count
+     : ޸ɹ
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_set_raid_recover_count(uint32_t value)
+{
+    g_dp_rt_raid_recover_count = value;     
+}
+
+/**************************************************************************
+   : dp_rt_get_raid_recover_count
+     : ȡ޸ɹ
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+uint32_t dp_rt_get_raid_recover_count(void)
+{
+    return g_dp_rt_raid_recover_count;     
+}
+
+/**************************************************************************
+   : dp_rt_check_raid_state
+     : RAID״̬״̬쳣ִ޸ű
+ : 
+ : 
+   ֵ: RETURN_OK ɹ
+           RETURN_ERROR ʧ
+     : 
+**************************************************************************/
+int32_t dp_rt_check_raid_state(void)
+{
+    int32_t ret = RETURN_ERROR;
+
+    DBG_LogDebug(LOG_ID_HDM_02AC, "BDM_RAID_RT:Recover failed times(%d), Recover success times(%d).", dp_rt_get_raid_abnormal_count(), dp_rt_get_raid_recover_count());
+
+    if (dp_rt_get_raid_alarm_status())
+    {
+        DBG_LogDebug(0, "SYS_RAID:It is alarmed, no need repeat check.");
+        return RETURN_ERROR;
+    }
+    
+    /* ýűRAID״̬Զ޸*/
+    ret = LVOS_Execute(ROOTDISK_RAID_CHECK_SCRIPT);
+    if (RETURN_RAID_NORMAL == ret)
+    {
+        /* űִȷ:RAID쳣 */      
+        dp_rt_set_raid_abnormal_count(0);       
+        return RETURN_ERROR;
+    }
+    else if (RETURN_RAID_ABNORMAL == ret)
+    {
+        /*ִ޸ű޸ɹ޸*/
+		ret = LVOS_Execute(ROOTDISK_RAID_RECOVER_SCRIPT);
+		if (RETURN_RAID_NORMAL == ret)
+		{
+		    dp_rt_inc_raid_recover_count();
+			dp_rt_set_raid_abnormal_count(0);
+		}
+		/*޸ʧ޸RAID쳣*/
+		else if (RETURN_RAID_ABNORMAL == ret)
+		{
+		    dp_rt_inc_raid_abnormal_count();
+		}
+		/* űִд󣬿ǲ */
+		else
+		{
+		    dp_rt_inc_raid_abnormal_count();
+		    DBG_LogError(0, "SYS_RAID:Failed to exec cmd(%s).", ROOTDISK_RAID_RECOVER_SCRIPT);          
+		}
+		
+        /* űִȷ:RAID쳣 ,쳣޸ɹ10νи澯*/
+        if (DP_RT_RAID_ALARM_THRESHOLD <= dp_rt_get_raid_abnormal_count()
+			|| DP_RT_RAID_RECOVER_THRESHOLD <= dp_rt_get_raid_recover_count())
+        {
+            /* 澯ƺ󣬼ת */
+            dp_rt_set_raid_abnormal_count(DP_RT_RAID_ALARM_THRESHOLD);   
+			dp_rt_set_raid_recover_count(DP_RT_RAID_RECOVER_THRESHOLD);
+            DBG_LogDebug(LOG_ID_HDM_02AC, "BDM_RAID_RT:The rootdisk raid routine results satisfy alarm conditions, Recover failed times(%d), Recover success times(%d).", dp_rt_get_raid_abnormal_count(), dp_rt_get_raid_recover_count());
+            return RETURN_OK;
+        }
+        else
+        {
+            return RETURN_ERROR;
+        }
+    }
+    else
+    {
+        /* űִд󣬿ǲ */
+        dp_rt_set_raid_abnormal_count(0);
+        DBG_LogError(0, "SYS_RAID:Failed to exec cmd(%s).", ROOTDISK_RAID_CHECK_SCRIPT);
+        return RETURN_ERROR;
+    }    
+}
+
+/**************************************************************************
+   : dp_rt_report_disk_raid_abnormal_event
+     : ϱϵͳRAID쳣; ֱӽ¼֪ͨDMI
+           (RAID澯û̶ûбҪٷLDתһȦ)
+ : 
+ : 
+   ֵ: RETURN_OK:֪ͨDMIɹ RETURN_ERROR ֪ͨDMIʧ
+     : 
+**************************************************************************/
+int32_t dp_rt_report_disk_raid_abnormal_event(void)
+{
+    int32_t ret = RETURN_ERROR;
+    uint32_t dmiRaidStatus = DMI_CTRL_STATUS_BUTT;
+    uint64_t frameWwn = INVALID_VALUE64;
+
+     /* ȡWWN */
+    frameWwn = BDM_EAM_GET_WWN_FROM_INNER_FRAME_ID(ROOT_DISK_INNER_FRAME_NUMBER_HDM);
+    if (INVALID_VALUE64 == frameWwn)
+    {
+        DBG_LogError(0, "SYS_RAID: Fail to get frameWwn by frame id(%u).", ROOT_DISK_INNER_FRAME_NUMBER_HDM);
+        return RETURN_ERROR;
+    }
+
+    dmiRaidStatus = DMI_BOOT_DISK_FAULT;
+    
+    /* ֪ͨDMI RAID쳣*/
+    ret = OperateCtrlBoard(NOTIFY_CTRL_STATUS, frameWwn, INVALID_VALUE32, (void*)&dmiRaidStatus, sizeof(DMI_CTRL_STATUS_E));
+    
+    if (RETURN_OK != ret)
+    {
+        DBG_LogError(0, "SYS_RAID: Fail to report rootdisk raid abnormal, frameWwn(0x%llx), raidStatus(%u).", frameWwn, dmiRaidStatus);
+        return RETURN_ERROR;
+    }
+
+    return RETURN_OK;
+}
+
+/**************************************************************************
+   : dp_rt_report_raid_state
+     : RAID״̬澯
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_report_raid_state(void)
+{
+    int32_t ret = RETURN_ERROR;
+
+    /* Ѿ澯ٸ澯 */
+    if (dp_rt_get_raid_alarm_status())
+    {
+        return;
+    }
+
+    /*ϱϵͳRAID״̬쳣*/
+    ret = dp_rt_report_disk_raid_abnormal_event();
+   
+    /* ø澯״̬ , ظظϱ澯*/
+    if (RETURN_OK == ret)
+    {
+        dp_rt_set_raid_alarm_status(TRUE);
+    }
+
+    return;
+}
+
+/**************************************************************************
+   : dp_rt_all_disk_routine
+     : ϵͳRAID״̬⼰޸ں
+ : 
+ : 
+   ֵ: 
+     : 
+**************************************************************************/
+void dp_rt_all_disk_routine(void)
+{
+    int32_t ret = RETURN_ERROR;
+    
+    /* ϵͳRAID״̬ */
+    ret = dp_rt_check_raid_state();
+    
+    if (RETURN_OK == ret)
+    {
+        dp_rt_report_raid_state();
+    }
+}
+/*End Modified by l00472145 DTS2019032206152 2019-03-27*/
+
