VOS_UINT32 PIH_RegISIMCardIndMsg(VOS_UINT32 ulRegPID)
{
    VOS_UINT32                          ulResult;

    if (VOS_TRUE != VOS_CheckPSPidValidity(ulRegPID))
    {
        PIH_WARNING_LOG("PIH_RegISIMCardIndMsg: PID is Error");

        return VOS_ERR;
    }

    if (VOS_OK != VOS_TaskLock())
    {
        PIH_WARNING_LOG("PIH_RegISIMCardIndMsg: SmP Error");

        return VOS_ERR;
    }

    ulResult = SI_PIH_RegisterPID(ulRegPID, SI_PIH_BCPID_REG_MAX, g_aulPIHISIMBCPid);

    if (VOS_OK != ulResult)
    {
        PIH_WARNING_LOG("PIH_RegISIMCardIndMsg: Space is Full");
    }

    VOS_TaskUnlock();

    return ulResult;
}
VOS_UINT32 PIH_DeregCardRefreshIndMsg(VOS_UINT32 ulRegPID)
{
    VOS_UINT32                          i;

    if (VOS_OK != VOS_TaskLock())
    {
        PIH_WARNING_LOG("PIH_RegUsimCardStatusIndMsg: SmP Error");

        return VOS_ERR;
    }

    for (i = 0; i<SI_PIH_BCPID_REG_MAX; i++)
    {
        if (ulRegPID == g_aulPIHRefreshBCPid[i])
        {
            g_aulPIHRefreshBCPid[i] = VOS_NULL;

            VOS_TaskUnlock();

            return VOS_OK;
        }
    }

    VOS_TaskUnlock();

    return VOS_ERR;
}
/*****************************************************************************
函 数 名  : PIH_GetVsimAPN
功能描述  : VSIM卡APN接口
输入参数  : APN的存储空间
输出参数  : 无
修订记录  :
1. 日    期   : 2014年10月9日
   作    者   : 祝锂
   修改内容   : Creat
*****************************************************************************/
VOS_VOID PIH_GetVsimAPN(VOS_UINT32 ulApnMax, VOS_UINT8 *pucApnData, VOS_UINT8 *pucApnLen)
{
#if (FEATURE_ON == FEATURE_VSIM)
    VOS_UINT32          ulDataLen;

    if ((VOS_NULL_PTR == pucApnData)||(VOS_NULL_PTR == pucApnLen))
    {
        PIH_WARNING_LOG("PIH_GetVsimAPN: Input Para is NULL");

        return;
    }

    if (VOS_FALSE == USIMM_VsimIsActive())   /*VSIM is Disable*/
    {
        PIH_WARNING_LOG("PIH_GetVsimAPN: USIMM_VsimIsActive return False");

        return;
    }

    if (VOS_OK != VOS_TaskLock())
    {
        PIH_WARNING_LOG("PIH_GetVsimAPN: VOS_TaskLock Error");

        return;
    }

    ulDataLen = VOS_StrLen((VOS_CHAR*)g_aucVsimAPNData);

    if ((VOS_NULL != ulDataLen)&&(ulApnMax >= ulDataLen))
    {
        VOS_MemCpy(pucApnData, g_aucVsimAPNData, ulDataLen);  /*拷贝不包含字符串结尾*/

        *pucApnLen = (VOS_UINT8)ulDataLen;
    }
    else
    {
        PIH_WARNING1_LOG("PIH_GetVsimAPN: VSIM Apn Data Len is %d", (VOS_INT32)ulDataLen);
    }

    VOS_TaskUnlock();
#endif

    return;
}
/*****************************************************************************
 Function   : TF_NVAutoResume
 Description: resume NV
 Input      : void
 Return     : void
 Other      :
 *****************************************************************************/
VOS_VOID TF_NVAutoResume(VOS_VOID)
{
    VOS_INT                             lNVResumeFlag;
    VOS_UINT16                          usNVResumeFlag = VOS_FALSE;
    OAM_MNTN_NV_ERRLOG_EVENT_STRU       stErrLog;

    /* get the flag from DRV */
    lNVResumeFlag = DRV_GET_CDROM_FLAG();

    if ( DRV_ISO_NOT_LOAD == lNVResumeFlag )/* need to do */
    {
        /* clear DRV's flag */
        DRV_SET_CDROM_FLAG(DRV_ISO_LOAD);
    }

    /* Get Flag */
    if ( VOS_OK != NV_Read(en_NV_Resume_Flag,
                    (VOS_VOID *)(&usNVResumeFlag), sizeof(VOS_UINT16)) )
    {
        Print("TF can't read NV resume flag.\r\n");
    }

    if ( VOS_TRUE != usNVResumeFlag )
    {
        return;
    }

    /* light LED updating */
    PS_TURN_ON_UPDATE_VERSION_LED();

    /*lint -e534*/
    VOS_TaskLock();
    /*lint +e534*/

    if ( VOS_FALSE == DRV_BOOT_FORCELOAD_MODE_CHECK() )/* noraml update */
    {
        if ( VOS_OK != NV_RestoreAll() )
        {
            /* light LED.fail. */
            PS_TURN_ON_UPDATE_VERSION_NVFAIL_LED();

            Print("TF can't resume All NV.\r\n");

            DRV_SDMMC_CLEAR_WHOLE_SCREEN();
            DRV_SDMMC_UPDATE_DISPLAY(VOS_FALSE);

            /*lint -e534*/
            VOS_TaskUnlock();
            /*lint +e534*/

            return;
        }
        else
        {
            /* clear flag */
            usNVResumeFlag = VOS_FALSE;

            if ( VOS_OK != NV_Write(en_NV_Resume_Flag,
                            (VOS_VOID *)(&usNVResumeFlag), sizeof(VOS_UINT16)))
            {
                Print("TF can't write NV resume flag.\r\n");
            }

            /* light LED sucess. */
            PS_TURN_ON_UPDATE_VERSION_SUCCESS_LED();

            DRV_SDMMC_CLEAR_WHOLE_SCREEN();
            DRV_SDMMC_UPDATE_DISPLAY(VOS_TRUE);
        }
    }
    else    /* force update */
    {
        if ( VOS_OK != NV_RestoreManufacture() )
        {
            /* light LED.fail. */
            PS_TURN_ON_UPDATE_VERSION_NVFAIL_LED();

            Print("TF can't resume Manufacture NV.\r\n");

            DRV_SDMMC_CLEAR_WHOLE_SCREEN();
            DRV_SDMMC_UPDATE_DISPLAY(VOS_FALSE);

            /*lint -e534*/
            VOS_TaskUnlock();
            /*lint +e534*/

            return;
        }
        else
        {
            /* clear flag */
            usNVResumeFlag = VOS_FALSE;

            if ( VOS_OK != NV_Write(en_NV_Resume_Flag,
                            (VOS_VOID *)(&usNVResumeFlag), sizeof(VOS_UINT16)))
            {
                Print("TF can't write NV resume flag.\r\n");
            }

            /* light LED sucess. */
            PS_TURN_ON_UPDATE_VERSION_SUCCESS_LED();

            DRV_SDMMC_CLEAR_WHOLE_SCREEN();
            DRV_SDMMC_UPDATE_DISPLAY(VOS_TRUE);
        }
    }

    /* NV Backup*/
    if ( VOS_OK != NV_Backup() )
    {
        MNTN_RecordErrorLog(MNTN_OAM_MNTN_NV_ERRLOG_EVENT, (void *)&stErrLog,
                    sizeof(OAM_MNTN_NV_ERRLOG_EVENT_STRU));
    }

    /*lint -e534*/
    VOS_TaskUnlock();
    /*lint +e534*/

    return;
}
VOS_UINT32 VOS_Startup( enum VOS_STARTUP_PHASE ph )
{
    VOS_UINT32      ulReturnValue;
    VOS_UINT32      ulStartUpFailStage = 0;

    switch(ph)
    {
    case VOS_STARTUP_INIT_DOPRA_SOFEWARE_RESOURCE :
        vos_StartUpStage = 0x00010000;

        if ( VOS_OK != VOS_MemInit() )
        {
            ulStartUpFailStage |= 0x0001;

            break;
        }

        VOS_SemCtrlBlkInit();

        VOS_QueueCtrlBlkInit();

        VOS_TaskCtrlBlkInit();

        VOS_TimerCtrlBlkInit();

        OM_RecordMemInit();

        if ( VOS_OK != RTC_TimerCtrlBlkInit() )
        {
            ulStartUpFailStage |= 0x0100;
        }

#if (OSA_CPU_CCPU == VOS_OSA_CPU)
        if ( VOS_OK != VOS_DrxTimerCtrlBlkInit())
        {
            ulStartUpFailStage |= 0x0200;
        }
#endif

        if ( VOS_OK != VOS_PidCtrlBlkInit() )
        {
            ulStartUpFailStage |= 0x0400;
        }

        if ( VOS_OK != VOS_FidCtrlBlkInit() )
        {
            ulStartUpFailStage |= 0x0800;
        }

        if ( VOS_OK != CreateFidsQueque() )
        {
            ulStartUpFailStage |= 0x1000;
        }
        break;

    case VOS_STARTUP_SET_TIME_INTERRUPT:
        vos_StartUpStage = 0x00020000;
        break;

    case VOS_STARTUP_CREATE_TICK_TASK:
        vos_StartUpStage = 0x00040000;
        /* create soft timer task */
        if ( VOS_OK != VOS_TimerTaskCreat() )
        {
            ulStartUpFailStage |= 0x0001;
        }

        if ( VOS_OK != RTC_TimerTaskCreat() )
        {
            ulStartUpFailStage |= 0x0002;
        }

#if (OSA_CPU_CCPU == VOS_OSA_CPU)
        if ( VOS_OK != VOS_DrxTimerTaskCreat() )
        {
            ulStartUpFailStage |= 0x0004;
        }
#endif

        break;

    case VOS_STARTUP_CREATE_ROOT_TASK:
        vos_StartUpStage = 0x00080000;

        if ( VOS_OK !=
                VOS_StartCallBackRelTimer(&g_VosProtectInitTimer,
                                          DOPRA_PID_TIMER, 20000, 0, 0,
                                          VOS_RELTIMER_NOLOOP, VOS_ProtectInit, VOS_TIMER_NO_PRECISION) )
        {
            ulStartUpFailStage |= 0x0001;
        }

        g_ulVosStartStep = 0x0000;

        ulReturnValue = VOS_OutsideInit();

        if(VOS_OK != ulReturnValue)
        {
            ulStartUpFailStage |= ulReturnValue;
        }

        g_ulVosStartStep = 0x0004;

        if ( VOS_OK != WD_TaskCreat() )
        {
            ulStartUpFailStage |= 0x0004;
        }

        g_ulVosStartStep = 0x0008;

        if ( VOS_OK != VOS_FidsInit() )
        {
            ulStartUpFailStage |= 0x0008;
        }

        g_ulVosStartStep = 0x0010;

#if 0
        /* 创建VOS各FID任务之前,锁任务 */
        if ( VOS_OK != VOS_TaskLock() )
        {
            ulStartUpFailStage |= 0x0010;
        }
#endif
        g_ulVosStartStep = 0x0020;

        /* create FID task & selftask task */
        if ( VOS_OK != CreateFidsTask() )
        {
            ulStartUpFailStage |= 0x0020;
        }

#if (VOS_WIN32 != VOS_OS_VER)
        g_ulVosStartStep = 0x0040;

        /* suspend FID task & selftask task */
        if ( VOS_OK != VOS_SuspendFidsTask() )
        {
            ulStartUpFailStage |= 0x0040;
        }
#endif

        g_ulVosStartStep = 0x0080;
#if 0
        /* 创建VOS各FID任务完成后解锁 */
        if ( VOS_OK != VOS_TaskUnlock() )
        {
            ulStartUpFailStage |= 0x0080;
        }
#endif
        g_ulVosStartStep = 0x0100;

        if ( VOS_OK != VOS_PidsInit() )
        {
            ulStartUpFailStage |= 0x0100;
        }
        break;

    case VOS_STARTUP_SUSPEND_MAIN_TASK:
        vos_StartUpStage = 0x00100000;

        g_ulVosStartStep = 0x0001;

        /* Resume任务之前,锁任务 */
        if ( VOS_OK != VOS_TaskLock() )
        {
            ulStartUpFailStage |= 0x0001;
        }

#if (VOS_WIN32 != VOS_OS_VER)

        g_ulVosStartStep = 0x0002;

        /* Resume FID task & selftask task */
        if ( VOS_OK != VOS_ResumeFidsTask() )
        {
            ulStartUpFailStage |= 0x0002;
        }
#endif

        g_ulVosStartStep = 0x0004;

        /* Resume任务之后解锁 */
        if ( VOS_OK != VOS_TaskUnlock() )
        {
            ulStartUpFailStage |= 0x0004;
        }

        g_ulVosStartStep = 0x0008;

        /* stop protect timer */
        VOS_StopRelTimer(&g_VosProtectInitTimer);

#if (OSA_CPU_CCPU == VOS_OSA_CPU)
        /* OSA初始化完成,需要调用DRV函数通知DRV OSA启动完成 */
        if ( VOS_OK != DRV_CCPU_RESET_OVER() )
        {
            ulStartUpFailStage |= 0x0008;
        }
#endif

#if (VOS_LINUX == VOS_OS_VER)
        VOS_RunTask();
#endif


        break;

    default:
        break;
    }

    /* calculate return value */
    if( 0 != ulStartUpFailStage )
    {
        ulReturnValue = vos_StartUpStage;
        ulReturnValue |= ulStartUpFailStage;
        Print1("startup retuen value is %x.\r\n",ulReturnValue);

        /* reboot */
        VOS_ProtectionReboot(OSA_INIT_ERROR, (VOS_INT)ulReturnValue,
                             (VOS_INT)g_ulOmPidInit, (VOS_CHAR *)&g_ulOmFidInit, sizeof(VOS_UINT32));

        return(ulReturnValue);
    }
    else
    {
        return(VOS_OK);
    }
}