/***************************************************************************** Prototype : BSP_MailBox_SpMsgRead Description : 专有邮箱(Special Mailbox)的读接口 (由调用者保证调用接口时DSP处于非睡眠状态) Input : ulAddr : 专有邮箱的偏移地址(从消息头开始的地址) ulSize : 初始值的大小(以字节为单位) pData : 数据信息(不包含消息头信息) Return Value : BSP_OK: 读取成功 ERR_MAILBOX_READ_NULL: 无数据 ERR_MAILBOX_NOT_INIT: 邮箱未初始化 ERR_MAILBOX_PARAM_INCORRECT: 参数错误 *****************************************************************************/ u32 BSP_MailBox_SpMsgRead(u32 ulAddr, u32 ulSize, void* pData) { unsigned long key = 0; u32 ret = 0; if(!(g_stMbxCtrl.bMbxInit)) { g_stMbxMntn.stAbnormal.ulNInitSlic = BSP_GetSliceValue(); return ERR_MAILBOX_NOT_INIT; } if((BSP_NULL == pData) || (0 == ulSize)) { return ERR_MAILBOX_PARAM_INCORRECT; } local_irq_save(key); ret = MailBox_SpMsgRead(ulAddr, ulSize, pData); local_irq_restore(key); return ret; }
/***************************************************************************** Prototype : BSP_MailBox_SpMsgRead Description : 专有邮箱(Special Mailbox)的读接口 (由调用者保证调用接口时DSP处于非睡眠状态) Input : ulAddr : 专有邮箱的偏移地址(从消息头开始的地址) ulSize : 初始值的大小(以字节为单位) pData : 数据信息(不包含消息头信息) Return Value : BSP_OK: 读取成功 ERR_MAILBOX_READ_NULL: 无数据 ERR_MAILBOX_NOT_INIT: 邮箱未初始化 ERR_MAILBOX_PARAM_INCORRECT: 参数错误 *****************************************************************************/ u32 BSP_MailBox_SpMsgRead(u32 ulAddr, u32 ulSize, void* pData) { s32 key = 0; u32 ret = 0; if(!(g_stMbxCtrl.bMbxInit)) { g_stMbxMntn.stAbnormal.ulNInitSlic = BSP_GetSliceValue(); return ERR_MAILBOX_NOT_INIT; } if((BSP_NULL == pData) || (0 == ulSize)) { return ERR_MAILBOX_PARAM_INCORRECT; } key = intLock(); ret = MailBox_SpMsgRead(ulAddr, ulSize, pData); intUnlock(key); return ret; }
MAILBOX_EXTERN long mailbox_get_timestamp(void) { #ifndef _DRV_LLT_ return BSP_GetSliceValue(); #else return 0; #endif }
void Mbx_MntnWritStart(MAILBOX_SERVICE_TYPE_E enMbxType) { g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulSliceStart = BSP_GetSliceValue(); switch(enMbxType) { case EN_MAILBOX_SERVICE_LTE_PS: case EN_MAILBOX_SERVICE_TDS_PS: #if (FEATURE_UE_MODE_CDMA == FEATURE_ON) case EN_MAILBOX_SERVICE_XSYS_RL: #endif g_stMbxMntn.stNumber.ulPsComPsReqNum++; return; case EN_MAILBOX_SERVICE_LTE_CT: case EN_MAILBOX_SERVICE_LTE_BT: case EN_MAILBOX_SERVICE_TDS_CT: case EN_MAILBOX_SERVICE_TDS_BT: case EN_MAILBOX_SERVICE_LTE_COEX: case EN_MAILBOX_SERVICE_RTT_SYS_CTRL: #if (FEATURE_UE_MODE_CDMA == FEATURE_ON) case EN_MAILBOX_SERVICE_XSYS_CT: case EN_MAILBOX_SERVICE_XSYS_BT: #endif g_stMbxMntn.stNumber.ulPsComMspReqNum++; return; case EN_MAILBOX_SERVICE_LTE_RCM: case EN_MAILBOX_SERVICE_TDS_RCM: g_stMbxMntn.stNumber.ulPsComRcmReqNum++; return; case EN_MAILBOX_SERVICE_LTE_OM: case EN_MAILBOX_SERVICE_TDS_OM: case EN_MAILBOX_SERVICE_LTE_HS_DIAG: case EN_MAILBOX_SERVICE_TDS_HS_DIAG: #if (FEATURE_UE_MODE_CDMA == FEATURE_ON) case EN_MAILBOX_SERVICE_XSYS_OM: #endif g_stMbxMntn.stNumber.ulOmComReqNum++; return; case EN_MAILBOX_SERVICE_RTT_AGENT: g_stMbxMntn.stNumber.ulPsComRttAgentReqNum++; return; default : return ; } }
void Mbx_MntnWriteEnd(MAILBOX_RINGBUFF_STRU* pHead, MAILBOX_MSG_HAED_STRU* pstMsg, u32 ulTempPPTR) { u32 ulInterval = 0; g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulSliceEnd = BSP_GetSliceValue(); g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulModId = pstMsg->usDstMod; g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulMsgId = *(u32*)(pstMsg->pPayload); g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulRWPtr = (pHead->ulRbufRdPtr << 16) | ulTempPPTR; ulInterval = (g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulSliceEnd - g_stMbxMntn.stReqInfo.astReq[g_stMbxMntn.stReqInfo.ulPtr].ulSliceStart); if(ulInterval > g_stMbxMntn.stAbnormal.ulLongestReq) { g_stMbxMntn.stAbnormal.ulLongestReq = ulInterval; } g_stMbxMntn.stReqInfo.ulPtr = (g_stMbxMntn.stReqInfo.ulPtr+1)%MAILBOX_MNTN_NUMBER; }
/***************************************************************************** Prototype : BSP_MailBox_ComMsgWrite Description : 邮箱写接口(每次只支持写一条原语) Input : enMbxType 邮箱的业务类型 pData 数据指针 ulLen 数据长度(以字节为单位) enProcType DSP睡眠时的处理类型 Output : None. Return Value : BSP_OK: 成功 其他: 失败 *****************************************************************************/ u32 BSP_MailBox_ComMsgWrite(MAILBOX_SERVICE_TYPE_E enMbxType, void* pData, u32 ulLen, MAILBOX_SLEEP_PROC_E enProcType) { u32 ret = 0; MAILBOX_RINGBUFF_STRU* pstAddr; u8 ucModule = 0; g_stMbxMntn.stNumber.ulPsComReqNum++; if((BSP_NULL == pData) || (0 == ulLen) || (enMbxType >= EN_MAILBOX_SERVICE_BUTT)) { Mbx_Printf("pData %p, ulLen %d, enMbxType %d.\n", pData, ulLen, enMbxType); return ERR_MAILBOX_PARAM_INCORRECT; } if((EN_MAILBOX_SERVICE_LTE_CT == enMbxType) || (EN_MAILBOX_SERVICE_LTE_BT == enMbxType) || (EN_MAILBOX_SERVICE_TDS_CT == enMbxType) || (EN_MAILBOX_SERVICE_TDS_BT == enMbxType) #if (FEATURE_UE_MODE_CDMA == FEATURE_ON) ||(EN_MAILBOX_SERVICE_XSYS_CT == enMbxType) ||(EN_MAILBOX_SERVICE_XSYS_BT == enMbxType) #endif ) { Mbx_Printf("Write CBT 0x%x request.\n", *((u32*)pData)); } if(!(g_stMbxCtrl.bMbxInit)) { g_stMbxMntn.stAbnormal.ulNInitSlic = BSP_GetSliceValue(); return ERR_MAILBOX_NOT_INIT; } /*lint -save -e628 -e718 -e746*/ Mbx_Trace(pData, ulLen);/*lint --e{628,718,746}*/ /*lint -restore*/ pstAddr = (MAILBOX_RINGBUFF_STRU*)g_astMbxChnTbl[enMbxType].ulDlAddr; ucModule = (u8)g_astMbxChnTbl[enMbxType].ulModule; Mbx_MntnWritStart(enMbxType); ret = BSP_Mailbox_ForbidDspSleep(enProcType); if(BSP_OK != ret) { return ret; } ret = Mailbox_ComMsgWrite(ucModule, pstAddr, pData, ulLen); if(BSP_OK != ret) { Mbx_Printf("Mailbox_ComMsgWrite failed %d.\n", ret); } if(BSP_OK == ret) { if(BSP_OK != BSP_IPC_IntSend(MBX_IPC_CORE_DSP,g_astMbxChnTbl[enMbxType].ulIntNum)) { Mbx_Printf("BSP_IPC_IntSend PS failed. Int Num %d\n",g_astMbxChnTbl[enMbxType].ulIntNum); } } BSP_Mailbox_AllowDspSleep(); return ret; }
/***************************************************************************** Prototype : BSP_Mailbox_ForbidDspSleep Description : 禁止DSP睡眠接口(与BSP_Mailbox_AllowDspSleep配对使用) Input : enProcType DSP睡眠时的处理类型 EN_MAILBOX_SLEEP_WAKEUP : 强制唤醒时会有等待处理, 不能在中断回调中输入此参数 只能在任务中输入此参数 EN_MAILBOX_SLEEP_LOST : 中断回调和任务中都可输入此参数 pkey : intLock key Return Value : BSP_OK: 成功,DSP当前没睡眠,且已设置禁止DSP进入睡眠 ERR_MAILBOX_DSP_POWERDOWN : 当输入为EN_MAILBOX_SLEEP_LOST, DSP当前处于低功耗状态,设置失败 ERR_MAILBOX_TIMEOUT : 当输入为EN_MAILBOX_SLEEP_WAKEUP, 唤醒DSP超时(10s) *****************************************************************************/ u32 BSP_Mailbox_ForbidDspSleep(MAILBOX_SLEEP_PROC_E enProcType) { #if (FEATURE_UE_MODE_CDMA == FEATURE_ON) return BSP_OK; #else s32 ret; Mbx_ForbidDspSleep(); if(EN_MAILBOX_SLEEP_DIRECT == enProcType)/*直接返回OK*/ { g_stMbxMntn.stDirectInfo.ulSlice[g_stMbxMntn.stDirectInfo.ulPtr%MAILBOX_MNTN_NUMBER] = BSP_GetSliceValue(); g_stMbxMntn.stDirectInfo.ulPtr++; return BSP_OK; } if((NULL != g_stMbxCtrl.pfnGetDspStatusProc) && (BSP_TRUE == g_stMbxCtrl.pfnGetDspStatusProc())) { if(EN_MAILBOX_SLEEP_WAKEUP == enProcType) { ret = osl_sem_downtimeout(&g_stMbxCtrl.semDspMutex, MAILBOX_WAKEUP_TIMEOUT); if(BSP_OK != ret) { Mbx_Printf("semTake semDspMutex failed.\n"); ret = ERR_MAILBOX_TIMEOUT; goto mbx_forbiddspsleep_fail;/*lint !e801*/ } /* 调用低功耗接口唤醒DSP */ if(NULL == g_stMbxCtrl.pfnDspForceAwakeProc) { ret = ERR_MAILBOX_TIMEOUT; osl_sem_up(&g_stMbxCtrl.semDspMutex); goto mbx_forbiddspsleep_fail;/*lint !e801*/ } /* 记录标志,表示是邮箱模块发起的唤醒DSP */ g_stMbxCtrl.bDspWakeFlag = BSP_TRUE; g_stMbxMntn.stSleepInfo.astwakeup[g_stMbxMntn.stSleepInfo.ulPtr].ulSlice1 = BSP_GetSliceValue(); g_stMbxCtrl.pfnDspForceAwakeProc(); /* 等待DSP被唤醒 */ /* coverity[lock] */ ret = osl_sem_downtimeout(&g_stMbxCtrl.semDspWakeup, MAILBOX_WAKEUP_TIMEOUT); g_stMbxMntn.stSleepInfo.astwakeup[g_stMbxMntn.stSleepInfo.ulPtr].ulSlice3 = BSP_GetSliceValue(); g_stMbxMntn.stSleepInfo.ulPtr = (g_stMbxMntn.stSleepInfo.ulPtr+1)%MAILBOX_MNTN_NUMBER; if(BSP_OK != ret) { Mbx_Printf("semTake semDspWakeup failed.\n"); ret = ERR_MAILBOX_TIMEOUT; osl_sem_up(&g_stMbxCtrl.semDspMutex); goto mbx_forbiddspsleep_fail;/*lint !e801*/ } osl_sem_up(&g_stMbxCtrl.semDspMutex); } else if(EN_MAILBOX_SLEEP_LOST == enProcType) { ret = ERR_MAILBOX_DSP_POWERDOWN; goto mbx_forbiddspsleep_fail;/*lint !e801*/ } else { Mbx_Printf("enProcType %d.\n",enProcType); ret = ERR_MAILBOX_PARAM_INCORRECT; goto mbx_forbiddspsleep_fail;/*lint !e801*/ } } return BSP_OK; mbx_forbiddspsleep_fail: Mbx_AllowDspSleep(); return (u32)ret; #endif }
u32_t pwrctrl_get_slice_time( void_t ) { return BSP_GetSliceValue(); }