VOS_UINT32 Aging_TestInit(VOS_VOID)
{
    NAS_MMA_NVIM_RF_AUTO_TEST_FLAG_STRU stRfAutoTestFlg;
    MODEM_ID_ENUM_UINT16                enModemID;
    VOS_UINT32                          aulReceiverPid[] = {I0_DSP_PID_GPHY, I1_DSP_PID_GPHY};

    VOS_MemSet(g_apstGAgingTestMsg, VOS_NULL_PTR, sizeof(g_apstGAgingTestMsg));

    g_pstOmAgingTestNV = (OM_AGING_TEST_NV_STRU*)VOS_MemAlloc(
                  WUEPS_PID_AGING, STATIC_MEM_PT, sizeof(OM_AGING_TEST_NV_STRU));

    if (VOS_NULL_PTR == g_pstOmAgingTestNV)
    {
        PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_WARNING, "Aging_TestInit: VOS_MemAlloc fail.\n");
        return VOS_ERR;
    }

    /*读取老化测试需要的NV项*/
    if(NV_OK != NV_Read(en_NV_Item_AGING_TEST_TABLE,
                        g_pstOmAgingTestNV,
                        sizeof(OM_AGING_TEST_NV_STRU)))
    {
        PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_WARNING, "Aging_TestInit: NV_Read fail.\n");
        return VOS_ERR;
    }
    /*判断老化测试是否开启*/
    if (VOS_NO == g_pstOmAgingTestNV->ulIsEnable)
    {
        return VOS_ERR;
    }

    /*读取自动开机使能位*/
    if(NV_OK != NV_Read(en_NV_Item_RF_Auto_Test_Flag,
                        &stRfAutoTestFlg,
                        sizeof(NAS_MMA_NVIM_RF_AUTO_TEST_FLAG_STRU)))
    {
        PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_WARNING, "Aging_TestInit: RF NV_Read fail.\n");
        return VOS_ERR;
    }

    if(VOS_YES == stRfAutoTestFlg.usRfAutoTestFlg)
    {
        PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_WARNING, "Aging_TestInit: Auto test enabled!\n");
        return VOS_ERR;
    }

    /*参数检测*/
    if ((0 == g_pstOmAgingTestNV->ulNumber)
        || (OM_AGING_TEST_NUM < g_pstOmAgingTestNV->ulNumber)
        || (0 == g_pstOmAgingTestNV->ulTimerLen))
    {
        return VOS_ERR;
    }

    PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_INFO, "Aging_TestInit: Aging test is launched.\n");

    DRV_PWRCTRL_SLEEPVOTE_LOCK(PWRCTRL_SLEEP_FTM);

    for (enModemID = MODEM_ID_0; enModemID < MODEM_ID_BUTT; enModemID++)
    {
        /*初始化发送给G物理层的配置数据包*/
        g_apstGAgingTestMsg[enModemID] = (GPHY_OAM_RF_AGING_TEST_REQ_STRU*)VOS_AllocMsg(
                        WUEPS_PID_AGING, sizeof(GPHY_OAM_RF_AGING_TEST_REQ_STRU) - VOS_MSG_HEAD_LENGTH);

        if (VOS_NULL_PTR == g_apstGAgingTestMsg[enModemID])
        {
            PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_WARNING, "Aging_TestInit: VOS_AllocMsg fail.\n");
            return VOS_ERR;
        }

        VOS_ReserveMsg(WUEPS_PID_AGING, (MsgBlock *)g_apstGAgingTestMsg[enModemID]);

        g_apstGAgingTestMsg[enModemID]->ulReceiverPid = aulReceiverPid[enModemID];
        g_apstGAgingTestMsg[enModemID]->enMsgId = ID_OAM_GPHY_RF_AGING_TEST_REQ;
    }

    /*初始化发送给W物理层的配置数据包*/
    g_pstWAgingTestMsg = (WPHY_OAM_RF_AGING_TEST_REQ_STRU*)VOS_AllocMsg(
                    WUEPS_PID_AGING, sizeof(WPHY_OAM_RF_AGING_TEST_REQ_STRU) - VOS_MSG_HEAD_LENGTH);

    if (VOS_NULL_PTR == g_pstWAgingTestMsg)
    {
        PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_WARNING, "Aging_TestInit: VOS_AllocMsg fail.\n");
        return VOS_ERR;
    }

    VOS_ReserveMsg(WUEPS_PID_AGING, (MsgBlock *)g_pstWAgingTestMsg);

    g_pstWAgingTestMsg->ulReceiverPid = DSP_PID_WPHY;
    g_pstWAgingTestMsg->enMsgID = ID_OAM_WPHY_RF_AGING_TEST_REQ;

    /*启动老化测试定时器*/
    if (VOS_OK != VOS_StartRelTimer(&g_hAgingTestTimer,
                      WUEPS_PID_AGING, 10000, OM_AGING_START_TIMER, 0,
                      VOS_RELTIMER_NOLOOP, VOS_TIMER_NO_PRECISION))
    {
        PS_LOG(WUEPS_PID_AGING, 0, PS_PRINT_ERROR, "Aging_TestInit:VOS_StartRelTimer fail!");
        return VOS_ERR;
    }

    return VOS_OK;
}
VOS_VOID OM_AcpuAgentMsgProc(MsgBlock* pMsg)
{
    VOS_UINT16                  usPrimId;
    VOS_UINT32                  ulRet = VOS_OK;
    OM_AUTOCONFIG_CNF_STRU     *pstSendCnf;

    /* 从消息前两个字节中取出原语ID */
    usPrimId = *(VOS_UINT16*)(pMsg->aucValue);

    OM_RecordInfoStart(VOS_EXC_DUMP_MEM_NUM_1, pMsg->ulSenderPid, ACPU_PID_OMAGENT, *((VOS_UINT32*)pMsg->aucValue));

    /* 判断是否为CCCPU AGENT发来的回复消息 */
    if (IS_CAGENT_CNF_MSG(usPrimId))
    {
        /* 判断消息是否被释放 */
        if (VOS_NULL_PTR == g_pstOmAcpuCnfMsg)
        {
            /* 标记该消息不用释放 */
            VOS_ReserveMsg(ACPU_PID_OMAGENT, pMsg);

            g_pstOmAcpuCnfMsg = pMsg;

            /* 释放信号量,使得调用API任务继续运行 */
            VOS_SmV(g_ulOmAcpuCnfSem);
        }

        /* CCPU 已经OK,可以进行SD卡配置信息 */
        if(OM_AUTOCONFIG_CNF == usPrimId)
        {
            OM_AutoConfigProc();
        }

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    /* 否则为CCPU发来不需要回复的请求消息 */
    if (OM_OLED_CLEAR_REQ == usPrimId)
    {
        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if (OM_OLED_DISPLAY_REQ == usPrimId)
    {
        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if (OM_HSIC_CONNECT_REQ == usPrimId)
    {
        Om_HsicConnectProc();

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if(OM_RECORD_DBU_INFO_REQ == usPrimId)
    {
        pstSendCnf = (OM_AUTOCONFIG_CNF_STRU *)pMsg;

        OM_AcpuLogShowToFile(VOS_FALSE);

        /* 将写文件的结果发送给PC侧 */
        OM_AcpuSendResult(pstSendCnf->aucData[0], ulRet, OM_APP_WRITE_NV_LOG_FILE_CNF);
    }

    if(OM_SET_FTM_MODE_REQ == usPrimId)
    {
        g_ulAcpuFTMFlag = VOS_TRUE;
    }

    OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

    return;
}
/*****************************************************************************
 Prototype       : OM_CAgentMsgProc
 Description     : 处理来自CCPU AGENT的消息.
 Input           : pMsg -- The pointer of the msg.
 Output          : None
 Return Value    : VOS_VOID

 History         : ---
    Date         : 2011-07-01
    Author       : g47350
    Modification : Created function
 *****************************************************************************/
VOS_VOID OM_AcpuAgentMsgProc(MsgBlock* pMsg)
{
    VOS_UINT16                  usPrimId;

    /* 从消息前两个字节中取出原语ID */
    usPrimId = *(VOS_UINT16*)(pMsg->aucValue);

    OM_RecordInfoStart(VOS_EXC_DUMP_MEM_NUM_1, pMsg->ulSenderPid, ACPU_PID_OMAGENT, *((VOS_UINT32*)pMsg->aucValue));

    /* 判断是否为CCCPU AGENT发来的回复消息 */
    if (IS_CAGENT_CNF_MSG(usPrimId))
    {
        /* 判断消息是否被释放 */
        if (VOS_NULL_PTR == g_pstOmAcpuCnfMsg)
        {
            /* 标记该消息不用释放 */
            VOS_ReserveMsg(ACPU_PID_OMAGENT, pMsg);

            g_pstOmAcpuCnfMsg = pMsg;

            /* 释放信号量,使得调用API任务继续运行 */
            VOS_SmV(g_ulOmAcpuCnfSem);
        }

        /* CCPU 已经OK,可以进行SD卡配置信息 */
        if(OM_AUTOCONFIG_CNF == usPrimId)
        {
            OM_AutoConfigProc();
        }

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    /* 否则为CCPU发来不需要回复的请求消息 */
    if (OM_OLED_CLEAR_REQ == usPrimId)
    {
        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if (OM_OLED_DISPLAY_REQ == usPrimId)
    {
        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    /* Modified by h59254 for AP-Modem Personalisation Project, 2012/04/12, begin */
    if (OM_HSIC_CONNECT_REQ == usPrimId)
    {
        PPM_HsicConnectProc();

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }
    /* Modified by h59254 for AP-Modem Personalisation Project, 2012/04/12, end */

    if(OM_RECORD_DBU_INFO_REQ == usPrimId)
    {
        OM_AcpuLogShowToFile(VOS_FALSE);
    }

    if (OM_CONNECT_INFO_CNF == usPrimId)
    {
        OMRL_AcpuConnectInfoReportEvent((OM_CONNECT_INFO_CNF_STRU *)pMsg);
    }

    OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

    return;
}
VOS_VOID OM_AcpuAgentMsgProc(MsgBlock* pMsg)
{
    VOS_UINT16                  usPrimId;
    OM_CBT_MSG_STRU             *pstCbtMsg;

    /* 从消息前两个字节中取出原语ID */
    usPrimId = *(VOS_UINT16*)(pMsg->aucValue);

    OM_RecordInfoStart(VOS_EXC_DUMP_MEM_NUM_1, pMsg->ulSenderPid, ACPU_PID_OMAGENT, *((VOS_UINT32*)pMsg->aucValue));

    /* 判断是否为CCCPU AGENT发来的回复消息 */
    if (IS_CAGENT_CNF_MSG(usPrimId))
    {
        /* 判断消息是否被释放 */
        if (VOS_NULL_PTR == g_pstOmAcpuCnfMsg)
        {
            /* 标记该消息不用释放 */
            VOS_ReserveMsg(ACPU_PID_OMAGENT, pMsg);

            g_pstOmAcpuCnfMsg = pMsg;

            /* 释放信号量,使得调用API任务继续运行 */
            VOS_SmV(g_ulOmAcpuCnfSem);
        }

        /* CCPU 已经OK,可以进行SD卡配置信息 */
        if(OM_AUTOCONFIG_CNF == usPrimId)
        {
            OM_AutoConfigProc();
        }

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    /* 否则为CCPU发来不需要回复的请求消息 */
    if (OM_OLED_CLEAR_REQ == usPrimId)
    {
        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if (OM_OLED_DISPLAY_REQ == usPrimId)
    {
        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if (OM_HSIC_CONNECT_REQ == usPrimId)
    {
        PPM_HsicConnectProc();

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if (OM_CBT_SEND_DATA_REQ == usPrimId)
    {
        pstCbtMsg = (OM_CBT_MSG_STRU *)pMsg;

        /* C核发过来的校准数据 */
        OM_AcpuSendDataChannel((OM_LOGIC_CHANNEL_ENUM_UINT32)OM_LOGIC_CHANNEL_CBT, (OM_RSP_PACKET_STRU *)(pstCbtMsg->aucData), pstCbtMsg->usLen);

        OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

        return;
    }

    if(OM_RECORD_DBU_INFO_REQ == usPrimId)
    {
        OM_AcpuLogShowToFile(VOS_FALSE);
    }

    if (OM_VERSION_DEBUG_INFO_CNF == usPrimId)
    {
        vos_printf("\r\nVersion Qry Rcv times = %d",((OM_VERSION_QRY_DEBUG_INFO_CNF_STRU *)pMsg)->stVerDebugInfo.ulVerQryRcvCnt);
        vos_printf("\r\nAlloc Mem Fail times = %d",((OM_VERSION_QRY_DEBUG_INFO_CNF_STRU *)pMsg)->stVerDebugInfo.ulAllocMemFail);
        vos_printf("\r\nDrv Err times = %d",((OM_VERSION_QRY_DEBUG_INFO_CNF_STRU *)pMsg)->stVerDebugInfo.ulDrvErr);
        vos_printf("\r\nLen Err times = %d",((OM_VERSION_QRY_DEBUG_INFO_CNF_STRU *)pMsg)->stVerDebugInfo.ulLenErr);
        vos_printf("\r\nSucc times = %d",((OM_VERSION_QRY_DEBUG_INFO_CNF_STRU *)pMsg)->stVerDebugInfo.ulSucc);
    }

    OM_RecordInfoEnd(VOS_EXC_DUMP_MEM_NUM_1);

    return;
}