Exemplo n.º 1
0
HRESULT cliCBCallArea(PB * incomingPacket, PB_PACKETTYPE packetType, RCODE_1394 *errorResponse)
// Called when a CLI remote call arrives at the CLI_CALL_AREA for the new CLI interface
// Only block writes are allowed to this register
{
	HRESULT			hResult = NO_ERROR;
	uint32			payloadSize = 0;
	uint32*			pPayload = NULL;
	char			cliCommandStr[kTempBufferSize] = {0};

	*errorResponse = RSP_TYPE_ERROR;

	hResult = pbGetPayloadSize(incomingPacket,&payloadSize);
	if (hResult != NO_ERROR) return hResult;
	hResult = pbGetPayload(incomingPacket, (void **) &pPayload);
	if (hResult != NO_ERROR) return hResult;

	SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "CLI command call: ");
	SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "packetType: %i, ", packetType);
	SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "payloadSize: %i", payloadSize);
	SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "\n\r");

	if ((packetType == PB_TYPE_WRITE_REQUEST) && payloadSize > 4)
	{
		// Get the command and execute it
		if (payloadSize <= kTempBufferSize)
		{
			memcpy(cliCommandStr, pPayload, payloadSize);
			formatSwapStrBytes(cliCommandStr, payloadSize);

			SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "CLI command call: ");
			SYS_DEBUG(SYSDEBUG_TRACE_CLICB, cliCommandStr);
			SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "\n\r");

#ifdef _CLICB_DEFERRED_TASK	
			if (cliCBDeferred == TRUE)
			{
				CLICB_CMD*	cmd = NULL;

				hResult = lalReplyWriteResponse(incomingPacket, RSP_COMPLETE, TRUE);
				*errorResponse = RSP_COMPLETE;

				SYS_DEBUG(SYSDEBUG_TRACE_CLICB, "CLI command call: deferring to cli CB task \n\r");
				
				hResult = cliCBAllocateDeferredCmd(&cmd, cliCommandStr);
				if (hResult != NO_ERROR) return hResult;

				// thread cli CB deferred task message queue
				hResult = TCMsgQueueSend(cliCBDeferredQueueID, (void *) &cmd, TC_NO_WAIT);
				if (hResult != NO_ERROR)
				{
					sysLogError(hResult, __LINE__, moduleName);
				}
			}
			else
#endif //_CLICB_DEFERRED_TASK
			{
				cliCBResult = cliCBHandleCommand(cliCommandStr);
				if (cliCBResult == NO_ERROR)
				{
					hResult = lalReplyWriteResponse(incomingPacket, RSP_COMPLETE, TRUE);
					*errorResponse = RSP_COMPLETE;
				}
				else
				{
					*errorResponse = RSP_DATA_ERROR;
				}
			}
		}
		else
		{
			*errorResponse = RSP_DATA_ERROR;
		}
	}
	else 
	{
		if (payloadSize < 4) {
			// <4 = DATA ERROR, =4 = TYPE ERROR, >4 <max = ok, >max = DATA ERROR
			*errorResponse = RSP_DATA_ERROR;
		}
	}

	return hResult;
}
Exemplo n.º 2
0
static HRESULT context1PostPacket(PB * pPacket,uint32 semID)
{
	HRESULT hResult = NO_ERROR;

	//check if context is available, should be as we only have one thread using the context
	volatile POSTED_TX_CONTEXT * pContext = &postedTxState.contexts[1];
	if (pContext->bPosted)
	{
			hResult = E_LAL_RESPONSE_UNEXPECTED;
			sysLogError(hResult, __LINE__, moduleName);
			return hResult;
	}
	PB_HEADER*	pHeader = 0;
	uint32		speedCode = 0;
#ifdef _LOOSE_ISO
	uint8		asyncStream = FALSE;
#endif //_LOOSE_ISO


 	// ML 140610: Busreset storm fix. Let's skip if we ar ein bus reset
 	if (postedTxState.inBr)
	{
	  hResult = E_LAL_BUS_RESET_IN_PROGRESS;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	pbGetPacketHeader(pPacket, &pHeader);
	pbGetPacketSpeed(pPacket, &speedCode);

	PB_PACKETTYPE packetType;
	pbGetPacketType(pPacket, &packetType);

	pContext->header.quadlets[0] = (pHeader->quadlets[0] & 0x0000ffff);		// 0:spd,tag,ch,tcode,sy
	pContext->header.quadlets[0]|= speedCode;

#ifdef _LOOSE_ISO
	pbIsAsyncStreamPacket (pPacket, &asyncStream);
	if (asyncStream == TRUE)
	{
		pContext->header.quadlets[1] = (pHeader->quadlets[1] & 0xffff0000);		// 1:data_length,reserved
	}
	else
#endif //_LOOSE_ISO
	if (packetType == TCODE_PHY_PACKET)
	{
		pContext->header.quadlets[0] = ((uint32)TCODE_LLC_SPECIFIC) << SHIFT_TCODE;
		pContext->header.quadlets[1] = pHeader->quadlets[0];
		pContext->header.quadlets[2] = ~pHeader->quadlets[0];
	}
	else
	{
		pContext->header.quadlets[0] |= LLC_SOURCEID_NODEID;
		pContext->header.quadlets[1] = (pHeader->quadlets[0] & 0xffff0000);		// 1:dstId,destination_offsetHigh
		pContext->header.quadlets[1] |= (pHeader->quadlets[1] & 0x0000ffff);
		pContext->header.quadlets[2] = pHeader->quadlets[2];						// 2:destination_offsetLow
		pContext->header.quadlets[3] = pHeader->quadlets[3];						// 3:data_length,extended_tcode
	}
	hResult = lhlGetHeaderQuadSizeFromTCode(LHL_TX, packetType, (uint16 *)&pContext->headerLen);
	if (hResult != NO_ERROR) return hResult;

	uint32 payloadNumBytes=0;
	
	pbGetPayload(pPacket, (void **)&pContext->pPayload);
	pbGetPayloadSize(pPacket, &payloadNumBytes);
	
	//Ugly, the payload is not always refering to the outgoing packet.
	if ((packetType==PB_TYPE_READ_REQUEST) || (packetType==PB_TYPE_READ_REQUEST_QUADLET) ||(packetType==PB_TYPE_WRITE_RESPONSE) || (packetType==TCODE_PHY_PACKET)) 
		payloadNumBytes=0;
	//Another hack as the read resp payload should always be one quadlet even in case of error
	if (packetType==PB_TYPE_READ_RESPONSE_QUADLET)
		payloadNumBytes=4;

	pContext->payloadLen = (payloadNumBytes+3)>>2;
	
	// ML 140610: Busreset storm fix. There is potentially a race condition here if
	//            Isr or Dsr comes here. Fixed with interrupt disable.
	TCInterruptGlobalDisable();
	if (postedTxState.inBr)
	{
	  TCInterruptGlobalEnable();
	  hResult = E_LAL_BUS_RESET_IN_PROGRESS;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}
  pContext->semID = semID;
	pContext->bPosted = TRUE;
  fSYS_TRACE1(SYSDEBUG_TRACE_TESTS,0);
  llcLinkRegWrite(INTERRUPT_REG_SET_DP, LLC_INT_BIT(LLCID_ASY_TX_CMPL));	
	TCInterruptGlobalEnable();
	return hResult;
}