Exemplo n.º 1
0
HRESULT MV_CC_DSS_Reg(pMV_CC_DSS_ServiceInfo_t pSrvInfo)
{
	HRESULT res;
	pMV_CC_ICCNet_t pICCNet;
	pMV_CC_DSS_ServiceInfo_t pSrvInfo_copy;
	
	if (pSrvInfo == NULL)
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_Reg", NULL);
		
	if (pMV_APP_DSS == NULL)
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_Reg", NULL);
		
	pICCNet = pMV_APP_DSS->m_pICCNet;
	
	// check service id need dynamic generator?
	if (pSrvInfo->m_ServiceID == MV_CC_ServiceID_DynamicApply)
	{
		//get a new dynamic service id
		pSrvInfo->m_ServiceID = MV_CC_DSS_GetDynamicSID(pMV_APP_DSS);
		if (pSrvInfo->m_ServiceID == MV_CC_ServiceID_None)
			MV_CC_DBG_Error(E_FAIL, "MV_CC_DSS_Reg", NULL);
	}

	pSrvInfo_copy = MV_CC_DSS_GlobalServiceList_SrvInfo_Ctor();
	if (pSrvInfo_copy == NULL)
		MV_CC_DBG_Error(E_OUTOFMEMORY, "MV_CC_DSS_Reg", NULL);	
	GaloisMemcpy(pSrvInfo_copy, pSrvInfo, sizeof(MV_CC_DSS_ServiceInfo_t));
	
	MV_OSAL_Mutex_Lock(pMV_APP_DSS->m_hGSListMutex);
	
	res = MV_CC_DSS_GlobalServiceList_Add(pSrvInfo->m_ServiceID, pSrvInfo_copy);
	if (res != S_OK)
	{
	    MV_CC_DBG_Warning(res, "MV_CC_DSS_Reg MV_CC_DSS_GlobalServiceList_Add", NULL);	
	    goto MV_CC_DSS_Reg_Failure;
	}
	
	// Only for test
	//res = MV_CC_DSS_GlobalServiceList_Traversal(GSList_VisitFunc_Demo, NULL);
	
	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);
	
	// Synchronize with Remote CPU
	res = MV_CC_DSS_DSPSendTo(	pMV_APP_DSS,
					 			pMV_APP_DSS->m_RemoteCPU,
					 			DSPPacket_HeadGEN(CMD_DSS_Add, 1, 0, 0),
					 			(UCHAR *)pSrvInfo,
					 			sizeof(MV_CC_DSS_ServiceInfo_t));	
	
	if (res == E_FULL)
		res = S_OK;
		
	return res;
	
MV_CC_DSS_Reg_Failure:

	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);
		
	return res;
}
Exemplo n.º 2
0
HRESULT MV_CC_DSS_Inquiry(pMV_CC_DSS_ServiceInfo_t pSrvInfo)
{
	HRESULT res;
	pMV_CC_DSS_ServiceInfo_t pSrvInfo_Search;
	
	if (pSrvInfo == NULL)
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_Inquiry", NULL);

	if (pMV_APP_DSS == NULL)
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_Inquiry", NULL);
		
	MV_OSAL_Mutex_Lock(pMV_APP_DSS->m_hGSListMutex);	
	
	res = MV_CC_DSS_GlobalServiceList_Get(pSrvInfo->m_ServiceID, &pSrvInfo_Search);
	if (res != S_OK)
	{
	    //MV_CC_DBG_Warning(res, "MV_CC_DSS_Inquiry MV_CC_DSS_GlobalServiceList_Get", NULL);	
	    goto MV_CC_DSS_Inquiry_Failure;
	}

	// Only for test
	//res = MV_CC_DSS_GlobalServiceList_Traversal(GSList_VisitFunc_Demo, NULL);
		
	if (pSrvInfo_Search != NULL)
		GaloisMemcpy(pSrvInfo, pSrvInfo_Search, sizeof(MV_CC_DSS_ServiceInfo_t));

MV_CC_DSS_Inquiry_Failure:
		
	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);

	return res;
}
HRESULT MV_CC_DSS_Reg(pMV_CC_DSS_ServiceInfo_t pSrvInfo,
					MV_CC_Task *cc_task )
{
	HRESULT res;
	pMV_CC_DSS_ServiceInfo_t pSrvInfo_copy;

	if (pSrvInfo == NULL)
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_Reg", NULL);

	if (pMV_APP_DSS == NULL)
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_Reg", NULL);

	MV_OSAL_Mutex_Lock(pMV_APP_DSS->m_hGSListMutex);

	// check service id need dynamic generator?
	if (pSrvInfo->m_ServiceID == MV_CC_ServiceID_DynamicApply) {
		//get a new dynamic service id
		pSrvInfo->m_ServiceID = MV_CC_DSS_GetDynamicSID(pMV_APP_DSS);
		if (pSrvInfo->m_ServiceID == MV_CC_ServiceID_None) {
			pMV_APP_DSS->m_Status.m_RegErrCount++;
		 	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);
			MV_CC_DBG_Error(E_FAIL, "MV_CC_DSS_Reg", NULL);
		}
	}

	pSrvInfo_copy = MV_CC_DSS_GlobalServiceList_SrvInfo_Ctor();
	if (pSrvInfo_copy == NULL) {
		MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);
		MV_CC_DBG_Error(E_OUTOFMEMORY, "MV_CC_DSS_Reg", NULL);
	}
	GaloisMemcpy(pSrvInfo_copy, pSrvInfo, sizeof(MV_CC_DSS_ServiceInfo_t));

	res = MV_CC_DSS_GlobalServiceList_Add(pSrvInfo->m_ServiceID,
						pSrvInfo_copy);
	if (res != S_OK) {
		pMV_APP_DSS->m_Status.m_RegErrCount++;
		MV_CC_DBG_Warning(res, "MV_CC_DSS_Reg"
			" MV_CC_DSS_GlobalServiceList_Add", NULL);
		goto MV_CC_DSS_Reg_Failure;
	}

	singlenode_add(cc_task->serverid_head, pSrvInfo->m_ServiceID);

	pMV_APP_DSS->m_Status.m_RegCount++;
	pMV_APP_DSS->m_Status.m_ServiceCount++;
	pMV_APP_DSS->m_Status.m_LastServiceID = pSrvInfo->m_ServiceID;

MV_CC_DSS_Reg_Failure:

	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);

	return res;
}
HRESULT MV_CC_DSS_GetStatus(pMV_CC_DSS_Status_t pStatus)
{
	if (pStatus == NULL)
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_GetStatus", NULL);

	if (pMV_APP_DSS == NULL)
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_GetStatus", NULL);

	GaloisMemcpy(pStatus, &(pMV_APP_DSS->m_Status),
				sizeof(MV_CC_DSS_Status_t));

	return S_OK;
}
Exemplo n.º 5
0
VOID GSList_VisitFunc_GetList(PVOID arg, MV_CC_ServiceID_U32_t uiSID, pMV_CC_DSS_ServiceInfo_t pData)
{
	pMV_CC_DSS_ServiceInfo_DataList_t 	pSrvInfoList;
	
	if (((pSrvInfoList = (pMV_CC_DSS_ServiceInfo_DataList_t)arg ) == NULL) || (pData == NULL))
	{
		MV_CC_DBG_Warning(E_INVALIDARG, "GSList_VisitFunc_GetList", NULL);
		return;
	}
	
	if (pSrvInfoList->m_DataNum < pSrvInfoList->m_ListNum)
	{
		GaloisMemcpy(&(pSrvInfoList->m_SrvInfo[pSrvInfoList->m_DataNum]), pData, sizeof(MV_CC_DSS_ServiceInfo_t));
		pSrvInfoList->m_DataNum++;
	}
	
	pSrvInfoList->m_MaxNum++;

	return;
}
Exemplo n.º 6
0
static HRESULT MV_SHM_GetBaseInfo_Base(shm_dev_t *shm_dev,
					pMV_SHM_BaseInfo_t pInfo)
{
	if (pInfo == NULL) {
		MV_SHM_Print("MV_SHM_GetBaseInfo_Base parameter"
			" pInfo[%p] error\n", pInfo);
		return E_INVALIDARG;
	}

	if (SHM_DEVICE_LOAD_COUNT <= 0) {
		MV_SHM_Print("MV_SHM_GetBaseInfo_Base shm device"
			" not be open\n");
		return E_NOTREADY;
	}

	GaloisMemcpy(pInfo, &shm_dev->base,
			sizeof(shm_dev->base));

	return S_OK;
}
HRESULT MV_CC_DSS_Update(pMV_CC_DSS_ServiceInfo_t pSrvInfo)
{
	HRESULT res;
	pMV_CC_DSS_ServiceInfo_t pSrvInfo_Search;

	if (pSrvInfo == NULL)
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_Update", NULL);

	if (pMV_APP_DSS == NULL)
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_Update", NULL);

	// check service id
	if (pSrvInfo->m_ServiceID == MV_CC_ServiceID_DynamicApply)
		MV_CC_DBG_Error(E_BADVALUE, "MV_CC_DSS_Update", NULL);

	MV_OSAL_Mutex_Lock(pMV_APP_DSS->m_hGSListMutex);

	res = MV_CC_DSS_GlobalServiceList_Get(pSrvInfo->m_ServiceID, \
					&pSrvInfo_Search);
	if (res != S_OK) {
		pMV_APP_DSS->m_Status.m_UpdateErrCount++;
		goto MV_CC_DSS_Update_Failure;
	}

	if (pSrvInfo_Search != NULL) {
		GaloisMemcpy(pSrvInfo_Search, pSrvInfo, \
		sizeof(MV_CC_DSS_ServiceInfo_t));
	} else {
		pMV_APP_DSS->m_Status.m_UpdateErrCount++;
		goto MV_CC_DSS_Update_Failure;
	}

	pMV_APP_DSS->m_Status.m_UpdateCount++;
	pMV_APP_DSS->m_Status.m_LastServiceID = pSrvInfo->m_ServiceID;

MV_CC_DSS_Update_Failure:

	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);

	return res;
}
HRESULT MV_CC_DSS_Inquiry(pMV_CC_DSS_ServiceInfo_t pSrvInfo)
{
	HRESULT res;
	pMV_CC_DSS_ServiceInfo_t pSrvInfo_Search;

	if (pSrvInfo == NULL)
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_Inquiry", NULL);

	if (pMV_APP_DSS == NULL)
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_Inquiry", NULL);

	MV_OSAL_Mutex_Lock(pMV_APP_DSS->m_hGSListMutex);

	res = MV_CC_DSS_GlobalServiceList_Get(pSrvInfo->m_ServiceID, \
						&pSrvInfo_Search);
	if (res != S_OK) {
		pMV_APP_DSS->m_Status.m_InquiryErrCount++;
		goto MV_CC_DSS_Inquiry_Failure;
	}

	if (pSrvInfo_Search != NULL)
		GaloisMemcpy(pSrvInfo, pSrvInfo_Search, \
			sizeof(MV_CC_DSS_ServiceInfo_t));
	else {
		pMV_APP_DSS->m_Status.m_InquiryErrCount++;
		goto MV_CC_DSS_Inquiry_Failure;
	}

	pMV_APP_DSS->m_Status.m_InquiryCount++;
	pMV_APP_DSS->m_Status.m_LastServiceID = pSrvInfo->m_ServiceID;

MV_CC_DSS_Inquiry_Failure:

	MV_OSAL_Mutex_Unlock(pMV_APP_DSS->m_hGSListMutex);

	return res;
}
Exemplo n.º 9
0
HRESULT MV_CC_DSS_DSPSendTo(pMV_CC_DSP_t 		self,
                          	MV_OSAL_CPUID_U8_t  DstCPU,
						  	UINT32				Head,
				   	      	UCHAR 				*pData,
				   	      	UINT32 				DataLen)
{
	HRESULT res;
	UCHAR MsgBuf[MV_CC_ICCFIFO_FRAME_SIZE];
	UCHAR *pMsgBuf = MsgBuf;
	
	/* Parameter Check */
	if ((self == NULL) || (self->m_pICCNet == NULL) ||
		(DstCPU >= MV_OSAL_CPU_NUM) ||		
		(DataLen > MV_CC_CCDSP_DATA_BYTESIZE) ||
		((DataLen > 0) && (pData == NULL)))
		MV_CC_DBG_Error(E_INVALIDARG, "MV_CC_DSS_DSPSendTo", NULL);
	
	/* assemble ICCP Datagram */
	ICCP_SrcCPU(pMsgBuf) = self->m_pICCNet->m_LocalCPU;
	ICCP_SrcProcess(pMsgBuf) = MV_CC_PROCESS_ID_BROADCAST;
	ICCP_DstCPU(pMsgBuf) = DstCPU;
	ICCP_DstProcess(pMsgBuf) = MV_CC_PROCESS_ID_BROADCAST;
	
	ICCP_DatagramID(pMsgBuf) = 0;
	ICCP_Protocol(pMsgBuf) = MV_CC_Protocol_CCDSP;
	ICCP_Padding(pMsgBuf) = 0xFF;
	ICCP_TimeStamp(pMsgBuf) = 0x12345678;

	/* assemble DSP Packet */
	GaloisMemcpy(DSPPacket_HeadStart(pMsgBuf), (UCHAR *)(&Head), sizeof(Head));
	if (DataLen > 0)
		GaloisMemcpy(DSPPacket_DataStart(pMsgBuf), pData, DataLen);
	
	//MV_CC_DBG_Info("(CPU-%d) sent DSP Parket CMD[%d] to (CPU-%d)\n", 
	//			ICCP_SrcCPU(pMsgBuf),	
	//			CCDSP_Command(pMsgBuf),
	//			ICCP_DstCPU(pMsgBuf));

	/* Send a CC-DSP Packet*/
	res = MV_CC_ICCNetWrite(self->m_pICCNet, pMsgBuf);	

	switch (res)
	{	
		case S_OK:
			
			self->m_WrCount++;
						
			break;
				
		case E_FULL:
			
			self->m_WrErrCount++;
						
			break;
		
		default:
			
			self->m_WrErrCount++;
						
			MV_CC_DBG_Error(res, "MV_CC_DSS_DSPSendTo", NULL);
			break;
	}	
	
	return res;
}
Exemplo n.º 10
0
HRESULT MV_CC_DSS_DSPOnRecvDemux(void *self, UCHAR *pFrameBuf)
{
	HRESULT res = S_OK, i;
	MV_OSAL_CPUID_U8_t  DstCPU;
	UINT8	Cmd, Param1;
	pMV_CC_DSP_t pHandle;
	pMV_CC_DSS_ServiceInfo_t pSrvInfo, pSrvInfo_copy;

	/* Parameter Check */
	if (((pHandle = (pMV_CC_DSP_t)self ) == NULL) || 
		(pFrameBuf == NULL))
		MV_CC_DBG_Error(E_NOTREADY, "MV_CC_DSS_DSPOnRecvDemux", NULL);

	DstCPU = ICCP_SrcCPU(pFrameBuf);
	Cmd = CCDSP_Command(pFrameBuf);
			

	switch (Cmd)
	{
		case CMD_DSS_AskUpdate:
			
			
			//if (DstCPU != MV_OSAL_CPU_LOCAL)
			if (DstCPU == pHandle->m_RemoteCPU)
			{
				// Ask DSS_Update_Task to update with Remote CPU
				//MV_OSAL_Sem_Post(pHandle->m_UpdateTaskSem);
				res = DSS_Update(pHandle);
			}
			else
			{
				MV_CC_DBG_Warning(res, "MV_CC_DSS_DSPOnRecvDemux CMD_DSS_AskUpdate error", NULL);
				res = E_FAIL;
			}

			break;

		case CMD_DSS_UpdateOK:

			MV_CC_DBG_Info("(CPU-%d)MV_CC_DSS_DSPOnRecvDemux CMD_DSS_UpdateOK from (CPU-%d)\n", MV_OSAL_CPU_LOCAL, DstCPU);
						
			pHandle->m_bStatusUpdate = true;
			res = S_OK;
			
			// Only for test
			//res = MV_CC_DSS_GlobalServiceList_Traversal(GSList_VisitFunc_Demo, NULL);
			
			break;

		case CMD_DSS_UpdateError:

			MV_CC_DBG_Info("(CPU-%d)MV_CC_DSS_DSPOnRecvDemux CMD_DSS_UpdateError from (CPU-%d)\n", MV_OSAL_CPU_LOCAL, DstCPU);
						
			//pHandle->m_bStatusUpdate = false;
			res = S_OK;
			
			break;
			
		case CMD_DSS_Add:

						
			Param1 = CCDSP_Param1(pFrameBuf);

			i = 0;
			while (i < Param1)
			{
				if ( (sizeof(MV_CC_DSS_ServiceInfo_t) * ( i + 1 )) > MV_CC_CCDSP_DATA_BYTESIZE)
				{
					res = E_OUTOFRANGE;
					MV_CC_DBG_Warning(res, "MV_CC_DSS_DSPOnRecvDemux CMD_DSS_Add->Parameter 1", NULl);
					break;
				}
				
				pSrvInfo = (pMV_CC_DSS_ServiceInfo_t)(DSPPacket_DataStart(pFrameBuf) + sizeof(MV_CC_DSS_ServiceInfo_t) * i);
				
				pSrvInfo_copy = MV_CC_DSS_GlobalServiceList_SrvInfo_Ctor();
				if (pSrvInfo_copy == NULL)
					MV_CC_DBG_Error(E_OUTOFMEMORY, "MV_CC_DSS_DSPOnRecvDemux", NULL);	
				GaloisMemcpy(pSrvInfo_copy, pSrvInfo, sizeof(MV_CC_DSS_ServiceInfo_t));
				
				MV_OSAL_Mutex_Lock(pHandle->m_hGSListMutex);
				
				res = MV_CC_DSS_GlobalServiceList_Add(pSrvInfo->m_ServiceID, pSrvInfo_copy);
				if (res != S_OK)
				    MV_CC_DBG_Warning(res, "MV_CC_DSS_DSPOnRecvDemux MV_CC_DSS_GlobalServiceList_Add", NULL);	

				// Only for test
				//res = MV_CC_DSS_GlobalServiceList_Traversal(GSList_VisitFunc_Demo, NULL);
					
				MV_OSAL_Mutex_Unlock(pHandle->m_hGSListMutex);
				
				i++;
			}
			
			break;

		case CMD_DSS_Delete:


			Param1 = CCDSP_Param1(pFrameBuf);
			i = 0;
			while (i < Param1)
			{
				if ( (sizeof(MV_CC_DSS_ServiceInfo_t) * ( i + 1 )) > MV_CC_CCDSP_DATA_BYTESIZE)
				{
					res = E_OUTOFRANGE;
					MV_CC_DBG_Warning(res, "MV_CC_DSS_DSPOnRecvDemux CMD_DSS_Delete->Parameter 1", NULL);
					break;
				}
				
				pSrvInfo = (pMV_CC_DSS_ServiceInfo_t)(DSPPacket_DataStart(pFrameBuf) + sizeof(MV_CC_DSS_ServiceInfo_t) * i);

				MV_OSAL_Mutex_Lock(pHandle->m_hGSListMutex);
				
				res = MV_CC_DSS_GlobalServiceList_Delete(pSrvInfo->m_ServiceID);
				if (res != S_OK)
				    MV_CC_DBG_Warning(res, "MV_CC_DSS_DSPOnRecvDemux MV_CC_DSS_GlobalServiceList_Delete", NULL);	

				// Only for test
				//res = MV_CC_DSS_GlobalServiceList_Traversal(GSList_VisitFunc_Demo, NULL);
								
				MV_OSAL_Mutex_Unlock(pHandle->m_hGSListMutex);

				i++;
			}

			break;
		
		default:
			
			res = E_BADVALUE;
			MV_CC_DBG_Warning(res, "MV_CC_DSS_DSPOnRecvDemux Error Command", NULL);
			
			break;									
	}
	
	if (res == S_OK)
		pHandle->m_RdCount++;
	else
		pHandle->m_RdErrCount++;
		
	return res;
}