예제 #1
0
static HRESULT cliBuiltInToolSetValue(char* addressarg, uint32 address, uint32 size, CLIVariableChangedCallback varcallback, uint32 oldvalue, uint32 newvalue)
{
	HRESULT		hResult = NO_ERROR;

	if (varcallback)
	{
		// if there is a callback associated with the variable, call it
		hResult = (varcallback) (kCLI_VariableCallbackOperation_SET, addressarg, oldvalue, &newvalue);
		if (hResult != NO_ERROR) return hResult; // Returning here, means that the variable's value will not be changed.
	}
	else if (address)
	{
		// Otherwise just set the value directly
		// Assign the pointer to the correctly sized variable pointer type.
		// This way we don't have to worry about handling byte ordering, when changing the data.
		switch (size)
		{
			case 32:	*((uint32 *) address) = newvalue;			break;
			case 16:	*((uint16 *) address) = (uint16) newvalue;	break;
			case 8:		*((uint8 *) address) = (uint8) newvalue;	break;
			default:
				hResult = E_NOT_IMPLEMENTED;
				sysLogError(hResult, __LINE__, moduleName);
				return hResult;
		}
	}
	else
	{
		hResult = E_FAIL;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	return hResult;
}
예제 #2
0
/*
	kvCreate
*/
HRESULT	kvCreate (KEYVALUE* list, uint32 size)
{
	HRESULT		hResult = NO_ERROR;
	uint32		counter=0;
	
	if (list == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	if (size == 0)
	{
		hResult = E_BAD_INPUT_PARAMETERS;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}
	
	for (counter=0; counter < size - 1; counter++)
	{
		(list[counter]).key = KV_KEYSPACE;
		(list[counter]).value = 0;
	} 
	
	(list[counter]).key = KV_TERMINATEKEY;
	(list[counter]).value = KV_TERMINATEVALUE;
	
	return hResult;
}
예제 #3
0
HRESULT grayEventAddCallback(uint32 enc, GRAYEVENT_CALLBACK callback)
{
	HRESULT hResult = NO_ERROR;

	if (enc > GRAY_ENC_ITEMS - 1)
	{
		hResult = E_GRAY_EVENT_CB_RANGE_ERR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	if (grayEventSetup.callback[enc] == NULL)
	{
		grayEventSetup.callback[enc] = callback;

		grayEventHandlerDirectPolling(); // clear status and counters before installing enc callback (handle possible installed ones)

		grayEventSetup.mask |= 0xff << (enc * 8);
		*((volatile uint32 *) GRAY_INT_SETUP) |= 1 << enc;
	}
	else
	{
		hResult = E_GRAY_EVENT_CB_ERR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	return hResult;
}
예제 #4
0
HRESULT grayEventRemoveCallback(uint32 enc)
{
	HRESULT hResult = NO_ERROR;

	if (enc > GRAY_ENC_ITEMS - 1)
	{
		hResult = E_GRAY_EVENT_CB_RANGE_ERR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	if (grayEventSetup.callback[enc] != NULL)
	{
		grayEventSetup.callback[enc] = NULL;
		grayEventSetup.mask &= ~(0xff << (enc * 8));
		*((volatile uint32 *) GRAY_INT_SETUP) &= ~(1 << enc);
	}
	else
	{
		hResult = E_GRAY_EVENT_CB_ERR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	return hResult;
}
예제 #5
0
HRESULT grayEventSetMode(uint32 enc, uint32 mode)
{
	HRESULT hResult = NO_ERROR;

	if (enc > GRAY_ENC_ITEMS - 1)
	{
		hResult = E_GRAY_EVENT_CB_RANGE_ERR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	switch (mode)
	{
		case GRAY_ENC_MODE_DIRECT:
#ifdef _GRAYINT_DEFERRED
		case GRAY_ENC_MODE_DEFERRED:
#endif //_GRAYINT_DEFERRED
			break;
		default:
			hResult = E_BAD_INPUT_PARAMETERS;
			sysLogError(hResult, __LINE__, moduleName);
			return hResult;
	}

	grayEventSetup.mode[enc] = mode;

	return hResult;
}
예제 #6
0
HRESULT grayEventSetAccMode(uint32 enc, uint32 accMode, GRAYACC_CALLBACK accCustomCallback)
{
	HRESULT hResult = NO_ERROR;

	if (enc > GRAY_ENC_ITEMS - 1)
	{
		hResult = E_GRAY_EVENT_CB_RANGE_ERR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	switch (accMode)
	{
		case GRAY_ENC_ACC_MODE_NONE:
		case GRAY_ENC_ACC_MODE_TYPE1:
		case GRAY_ENC_ACC_MODE_TYPE2:
			break;
		case GRAY_ENC_ACC_MODE_CUSTOM:
			grayEventSetup.accCustomCallback[enc] = accCustomCallback;
			break;
		default:
			hResult = E_BAD_INPUT_PARAMETERS;
			sysLogError(hResult, __LINE__, moduleName);
			return hResult;
	}

	grayEventSetup.accMode[enc] = accMode;

	return hResult;
}
예제 #7
0
//This is the interrupt version of SPI, if user wants an blocking version of op, an 
//user defined semaphore needs to be signalled in the complete_cb. 
HRESULT spiOpNonBlock(uint32 slaveId, uint32 outData, uint32 *inData)
{
	HRESULT hResult = NO_ERROR;

	if (!TCTaskStarted ())
	{
		hResult = E_GEN_WRONG_CONTEXT;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;		
	}

	if((slaveId >= SPI_MAX_SLAVE_COUNT) || !ssTable[slaveId].bValid )
	{
		hResult = E_SPI_INVALID_SLAVEID;
		sysLogError(hResult, __LINE__, moduleName);
	}
	else 
	{
		if (!_spiBufAdd(slaveId, outData, inData))
		{
			sysLogError(E_SPI_BUF_FULL, __LINE__, moduleName);
			return E_SPI_BUF_FULL;
		}
	}
	return hResult;
}
예제 #8
0
HRESULT lmCreateList(LM_CONTEXT* newlist,
					uint32 list_sizeinbytes,
					uint32 elem_sizeinbyte,
					uint32* elementcount)
{
	HRESULT		hResult = NO_ERROR;
	uint32		internalelementsize = 0;
	uint32		myelemcount = 0;
	uint32		counter = 0;
	LM_ELEMENT	*curelem = NULL;

	if (!newlist || list_sizeinbytes < sizeof(LM_CONTEXT))
	{
		hResult = E_BAD_INPUT_PARAMETERS;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}
	
	memset(newlist, 0, list_sizeinbytes);
	
	internalelementsize = elem_sizeinbyte + sizeof(LM_ELEMENT);
	
	myelemcount = (list_sizeinbytes - sizeof(LM_CONTEXT)) / internalelementsize;
	if (elementcount)
	{
		*elementcount = myelemcount;
	}

	curelem = (LM_ELEMENT*) &(newlist->elements);
	
	while (counter++ < myelemcount)
	{
		if (curelem == NULL)
		{
			hResult = E_NULL_PTR;
			sysLogError(hResult, __LINE__, moduleName);
			return hResult;
		}
		curelem->flags += ELEMFLAG_AVAILABLE;
		lmMoveAheadElementSize(elem_sizeinbyte, &curelem);
	}
	
	newlist->listsize = list_sizeinbytes;
	newlist->nextfree = 0;
	newlist->elemsize = elem_sizeinbyte;
	newlist->elemcount = myelemcount; // Number of allocated elements
	newlist->mode = LM_LISTMODE_EXCLUSIVEACCESS;
	
	// setup semaphores for the list (mutex)
	hResult = TCMutexOpen(&(newlist->lmMutexSemID));
		
	return hResult;
}
예제 #9
0
static HRESULT cliBuiltInToolGetAddress(char* addressarg, uint32 *pAddress, uint32 *pSize, CLIVariableChangedCallback *pVarcallback, uint32 *pDisplaytype)
{
	HRESULT			hResult = NO_ERROR;
	CLIDescriptor*	variable = 0;
	
	// get address and size of the variable.

	if (cliBuiltInToolGetAddressHexValue(addressarg, pAddress, pSize) == NO_ERROR)
	{
		// the address argument is a hex value.
		*pVarcallback = NULL;
		if (pDisplaytype)
		{
			*pDisplaytype = kCLI_DISPLAYTYPE_HEX;
		}
	}
	else	
	{
		// didn't find a direct address, assume that the passed in argument is the name of a variable
		uint32	temp = 0;
		
		variable = cliLookupDescriptorByName("",addressarg);
		
		if (!variable)
		{
			hResult = E_CLI_BADDESCRIPTORNAME;
			sysLogError(hResult, __LINE__, moduleName);
			return hResult;
		}
		
		//	Check to make sure that this is variable and not a tool.
		kvGetValue(variable, kCLI_Type, (uint32*)&temp);
		if (temp == kCLI_TYPE_TOOL)
		{
			hResult = E_CLI_BADDESCRIPTORTYPE;
			sysLogError(hResult, __LINE__, moduleName);
			return hResult;
		}
		
		//	Get information about the variable.
		kvGetValue(variable, kCLI_VariableSize, pSize);
		kvGetValue(variable, kCLI_Function, (uint32*) pVarcallback);
		kvGetValue(variable, kCLI_Variable, pAddress);
		if (pDisplaytype)
		{
			kvGetValue(variable, kCLI_VariableDisplayType, (uint32*) pDisplaytype);
		}
	}

	return hResult;
}
예제 #10
0
HRESULT lmGetElementCB(LM_CONTEXT* list, uint32 index, LM_ELEMENT* elem, void **data, uint32 *arg1, uint32 *arg2)
{
	HRESULT		hResult = NO_ERROR;

	UNUSED_ARG(index);
	UNUSED_ARG(arg1);
	UNUSED_ARG(arg2);

	if (data == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	hResult = lmCheckElementAllocated(elem);
	if (hResult != NO_ERROR) return hResult;

	hResult = lmCheckElementLocked(list, elem);
	if (hResult != NO_ERROR) return hResult;

	elem->flags += ELEMFLAG_LOCKED;	
	*data = &(elem->data);

	return hResult;
}
예제 #11
0
HRESULT lmGetNthElementCB(LM_CONTEXT* list, uint32 index, LM_ELEMENT* elem, void **data, uint32 *pPos, uint32 *pIndex)
{
	HRESULT		hResult = NO_ERROR;

	if (data == NULL ||
		pPos == NULL)	
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	hResult = lmCheckElementAllocated(elem);
	if (hResult != NO_ERROR) return E_LM_ELEMENT_NOT_FOUND;

	if (elem->position != *pPos) return E_LM_ELEMENT_NOT_FOUND;

	hResult = lmCheckElementLocked(list, elem);
	if (hResult != NO_ERROR) return hResult;

	elem->flags += ELEMFLAG_LOCKED;	
	*data = &(elem->data);

	if (pIndex)
	{
		*pIndex = index;
	}

	return hResult;
}
예제 #12
0
HRESULT	crRemoveCallback(CALLBACK_DESCRIPTOR* callback)
{
	HRESULT					hResult = NO_ERROR;
	CALLBACK_DESCRIPTOR*	prev = NULL;
	CALLBACK_DESCRIPTOR*	next = NULL;

	if (crFindCallback(CR_FIND_CALLBACK_PREV, 0, 0, callback, &prev) == FALSE)
	{
		hResult = E_AVC_CR_CALLBACK_NOT_FOUND;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}
	
	// exclusive access for the cr list (mutex)
	hResult = TCMutexLock(crListMutexSemID);
	if (hResult != NO_ERROR) return hResult;
	
	kvGetValue(callback, CALLBACK_DESCRIPTOR_NEXT, (uint32 *) &next);
	kvSetValue(callback, CALLBACK_DESCRIPTOR_NEXT, 0);
	kvSetValue(prev, CALLBACK_DESCRIPTOR_NEXT, (uint32) next);
	if (crDescHead == callback)
	{
		crDescHead = next;
	}

	// exclusive access for the cr list (mutex)
	TCMutexUnlock(crListMutexSemID);
	
	return hResult;	
}
예제 #13
0
static HRESULT cmpP2PInConnectionSetOwned(uint32 iPCRNumber, uint32 oPCRNumber, uint16 oNodeAddr, CONNECTION_STATUS status)
{
	HRESULT		hResult = NO_ERROR;

	// check range of iPCRNumber;
	if (iPCRNumber > plugsGetNumIsochInPlugs())
	{
		hResult = E_CMP_PCR_INVALID;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	cmpP2PInConnectionsOwned[iPCRNumber].oPCRNumber = oPCRNumber;
	cmpP2PInConnectionsOwned[iPCRNumber].status = status;

#ifdef _CMP_P2P_USE_NODE_HANDLE
	{
		LAL_NODE_HANDLE		oNodeHandle = 0;

		hResult = lalGetHandleFromNodeAddr(oNodeAddr, &oNodeHandle);
		if (hResult != NO_ERROR) return hResult;

		cmpP2PInConnectionsOwned[iPCRNumber].oNodeHandle = oNodeHandle;
	}
#else //_CMP_P2P_USE_NODE_HANDLE
	cmpP2PInConnectionsOwned[iPCRNumber].oNodeAddr = oNodeAddr;
#endif //_CMP_P2P_USE_NODE_HANDLE
	
	return hResult;
}
예제 #14
0
HRESULT avsIntEventHandleEvent(uint32 eventReg, uint32 index)
{
	HRESULT	hResult = NO_ERROR;
	uint32	bit;

	if (eventReg != 0)
	{
		hResult = E_BAD_INPUT_PARAMETERS;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	bit = avsIntEventState[eventReg].avsIntEvents[index];
	
	//AVS INT 0 bits
	switch (bit)
	{
#ifdef _DTCP																			
		case IRQ_ADO1_STREAM_START:	avsDTCPHandleRxCheckDecryptionNeeded(AVS_PLUG_ID1);				break;
		case IRQ_ARX1_CFG_FAIL:		avsDTCPHandleRxCheckDecryptionChanged(AVS_PLUG_ID1);			break;	// Source Id has changed or EMI bits have changed for plug ID 1

		case IRQ_CIPHER0_KEY_REQ:	avsDTCPHandleRxCipherNewContentKeyRequest(0);					break;	// New Content Key Request for cipher 0
		case IRQ_CIPHER1_KEY_REQ:	avsDTCPHandleRxCipherNewContentKeyRequest(1);					break;	// New Content Key Request for cipher 1
		case IRQ_CIPHER2_KEY_REQ:	avsDTCPHandleRxCipherNewContentKeyRequest(2);					break;	// New Content Key Request for cipher 2
																									
#endif //_DTCP

		case IRQ_ADO1_SYT_AGEOUT:   avsHandleRxSytAgeOut (AVS_PLUG_ID1);							break;
		case IRQ_ARX1_DBC_FAIL:     avsHandleRxDbcFail   (AVS_PLUG_ID1);							break;
		case IRQ_ARX1_PKT_ABORT:    avsHandleRxPktAbort  (AVS_PLUG_ID1);							break;
	}

	return hResult;
}
예제 #15
0
/*********************************************************
	Signal to waiting threads bus reset completion
*/
HRESULT	briSignalOnResetPreCompletion (void)
{
	HRESULT		hResult = NO_ERROR;
	uint32		waitingTasks = 0;

	if (!briInitialized)
	{
		hResult = E_BRI_NOT_INITIALIZED_FATAL;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	// Exclusive exclusive access for briPreCompletionWaitingTasks (mutex)
	hResult = TCMutexLock(briPreCompletionMutexSemID);
	if (hResult != NO_ERROR) return hResult;

	waitingTasks = briPreCompletionWaitingTasks;
	briPreCompletionWaitingTasks = 0;
	
	// Release exclusive access for briPreCompletionWaitingTasks (mutex)
	TCMutexUnlock(briPreCompletionMutexSemID);

	if (waitingTasks > 0)
	{
		while (waitingTasks--)
		{
			TCSemaphoreSignal(briPreCompletionSemID);
		}
	}

	return hResult;
}
예제 #16
0
int32 lmGetHighestElementPosition(LM_CONTEXT* list)
{
	HRESULT		hResult = NO_ERROR;
	LM_ELEMENT*	elem = 0;
	uint32		count = 0;
	int32		highest = -1;
	
	if (list == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return highest;
	}
	
	// walk through the list elements
	elem = (LM_ELEMENT*) &(list->elements);

	for (count = 0; count < list->elemcount; count++)
	{
		if (lmCheckElementAllocated(elem) == NO_ERROR)
		{
			if (elem->position > highest)
			{
				highest = elem->position;
			}
		}
		lmMoveAheadElementSize(list->elemsize, &elem);
	}
	
	return highest;
}
예제 #17
0
static int fis_flash_erase_progress(void *base, int len, void **err_address, FIS_PROGRESS_STRUCT * pProgress)
{
	HRESULT		hResult = NO_ERROR;
  int				stat = FLASH_ERR_OK;

	
	//we will erase one sector at a time to be able to provide progress info
	while (len>=flash_block_size)
	{
		// Non-blocking erase flash operation
		// note: the flash may not be accessed during this flash erase function
		stat = flash_erase_with_cb(base, flash_block_size, err_address, fis_flash_erase_cb);
		if (stat != FLASH_ERR_OK)
		{
			hResult = E_FIS_FLASH_OP_FAILED;
			sysLogError(hResult, __LINE__, moduleName);
			break;
		}
		if (pProgress && pProgress->func)
		{
			pProgress->procur+=10;
			pProgress->func(pProgress->promax, pProgress->procur);
		}
		base=  (void *)(((int)base)+flash_block_size);
		len-=flash_block_size;
	}
	return stat;
}
예제 #18
0
HRESULT targetPlugExists(AVC_CONNECTION *connection, BOOL source)
{
	HRESULT		hResult = NO_ERROR;
	BOOL		bFound = FALSE;
	uint8		numSrcPlugs = 0;
	uint8		numDstPlugs = 0;

	// Simply check that a plug exists in a subunit.
	// Uses "source" to determine whether to check the source or the destination part of the connection.

	if (source)
	{
		targetGetSubunitPlugs(&connection->plugs.src.addrSubunit, &numSrcPlugs, &numDstPlugs);
		if (connection->plugs.src.plugID < numSrcPlugs) bFound = TRUE;
	}
	else
	{
		targetGetSubunitPlugs(&connection->plugs.dst.addrSubunit, &numSrcPlugs, &numDstPlugs);
		if (connection->plugs.dst.plugID < numDstPlugs) bFound = TRUE;
	}

	if (bFound == FALSE)
	{
		hResult = E_FAIL;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	return hResult;
}
예제 #19
0
HRESULT lmMoveElementPositions(LM_CONTEXT* list, uint32 pos, int16 delta)
{
	HRESULT		hResult = NO_ERROR;
	LM_ELEMENT*	elem = 0;
	uint32		count = 0;
	
	if (list == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}
	
	// walk through the list elements
	elem = (LM_ELEMENT*) &(list->elements);

	for (count = 0; count < list->elemcount; count++)
	{
		if (lmCheckElementAllocated(elem) == NO_ERROR)
		{
			if (elem->position >= pos)
			{
				elem->position = (uint16) (elem->position + delta);
			}
		}
		lmMoveAheadElementSize(list->elemsize, &elem);
	}

	return hResult;
}
예제 #20
0
static HRESULT cliBuiltInToolGetValue(char* addressarg, uint32 address, uint32 size, CLIVariableChangedCallback varcallback, uint32 *pValue)
{
	HRESULT		hResult = NO_ERROR;

	if (varcallback)
	{
		// if there is a callback associated with the variable, call it
		hResult = (varcallback) (kCLI_VariableCallbackOperation_GET, addressarg, 0L, pValue);
		if (hResult != NO_ERROR) return hResult;
	}
	else
	{
		// Otherwise just get the value directly
		// Assign the pointer to the correctly sized variable pointer type.
		// This way we don't have to worry about handling byte ordering, when changing the data.
		switch (size)
		{
			case 32:	*pValue = *((uint32 *) address);	break;
			case 16:	*pValue = *((uint16 *) address);	break;
			case 8:		*pValue = *((uint8 *) address);		break;
			default:
				hResult = E_NOT_IMPLEMENTED;
				sysLogError(hResult, __LINE__, moduleName);
				return hResult;
		}
	}

	return hResult;
}
예제 #21
0
/*********************************************************
	Wait for a bus reset pre completion
*/
HRESULT	briWaitOnResetPreCompletion (BOOL *bResetDetected)
{
	HRESULT		hResult = NO_ERROR;

	*bResetDetected = FALSE;

	if (!briInitialized)
	{
		hResult = E_BRI_NOT_INITIALIZED_FATAL;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	// exclusive access for briPreCompletionWaitingTasks (mutex)
	hResult = TCMutexLock(briPreCompletionMutexSemID);
	if (hResult != NO_ERROR) return hResult;

	if (briInBusResetProgress == TRUE &&
		briPreCompletionDone == FALSE)
	{
		*bResetDetected = TRUE;
		briPreCompletionWaitingTasks++;		
	}

	// Release exclusive access for briPreCompletionWaitingTasks (mutex)
	TCMutexUnlock(briPreCompletionMutexSemID);
	
	if (*bResetDetected == TRUE)
	{
		hResult = TCSemaphoreWait(briPreCompletionSemID);
		if (hResult != NO_ERROR) return hResult;
	}

	return hResult;
}
예제 #22
0
void kvFreeKey(KEYVALUE* list, uint32 key)
{
	HRESULT		hResult = NO_ERROR;
	uint32		curkey, curvalue;
	
	if (list == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return;
	}

	hResult = kvIsKey(list, key);
	if (hResult != NO_ERROR) return;

	DO_FOREVER
	{
		curkey = list->key;
		curvalue = list->value;
		
		if (curkey == KV_TERMINATEKEY || curvalue == KV_TERMINATEVALUE) break;

		if (curkey == key)
		{
			list->key = KV_KEYSPACE;
			break;
		}

		list++;
	}
}	
예제 #23
0
HRESULT briGetNodeAddrRoot(uint32 *pNodeAddr)
{
	HRESULT		hResult = NO_ERROR;
	uint16		busId = 0;
	uint32		rootId = ROOT_ID_UNDEF;
	uint32		numNodes = 0;

	// find out Root node address
	numNodes = briGetNumNodes();

	if (numNodes == 0)
	{
		hResult = E_NCI_NODE_ID_OUT_OF_RANGE;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}
	
	rootId = numNodes - 1; 

	hResult = briGetBusID(&busId);
	if (hResult != NO_ERROR) return hResult;

	*pNodeAddr = rootId | busId;

	return hResult;
}
예제 #24
0
// Get receiver channel status: user data, word length, emphasis on/off
HRESULT tdifRxGetChStatus(uint8 channel, uint8 *userData, uint8 *wdLen, BOOL *emphasis)
{
	HRESULT hResult = NO_ERROR;

	if (channel < NUM_TDIF_CHANNELS)
	{
		uint8 offset;
		uint8 even;
		offset = channel / 2;
		even = channel % 2;
		if (even)
		{
			*userData = pDiceTDIFRx->chSetup[offset].bit.user_data2;
			*wdLen = pDiceTDIFRx->chSetup[offset].bit.word_len2;
			*emphasis = pDiceTDIFRx->chSetup[offset].bit.emphasis2;
		}
		else
		{
			*userData = pDiceTDIFRx->chSetup[offset].bit.user_data1;
			*wdLen = pDiceTDIFRx->chSetup[offset].bit.word_len1;
			*emphasis = pDiceTDIFRx->chSetup[offset].bit.emphasis1;
		}
		return hResult;
	}

	hResult = E_DICE_BAD_INPUT_PARAM;
	sysLogError(hResult, __LINE__, moduleName);
	return hResult;
}
예제 #25
0
/*	
	CountKeys
	
	Count the number of used keys in the keyvalue map.
*/
uint32 kvCountKeys(KEYVALUE* list)
{
	HRESULT		hResult = NO_ERROR;
	uint32		curkey, curvalue;
	uint32		counter = 0;
		
	if (list == NULL)
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return 0;
	}

	DO_FOREVER
	{
		curkey = list->key;
		curvalue = list->value;
		
		if (curkey == KV_TERMINATEKEY || curvalue == KV_TERMINATEVALUE) break;

		if (curkey != KV_KEYSPACE)
		{
			counter++;
		}

		list++;
	}

	return counter;
}
예제 #26
0
static HRESULT cmpP2PInConnectionGetOwned(uint32 iPCRNumber, uint32 *oPCRNumber, uint16 *oNodeAddr, CONNECTION_STATUS *status)
{
	HRESULT		hResult = NO_ERROR;

	// check range of iPCRNumber;
	if (iPCRNumber > plugsGetNumIsochInPlugs())
	{
		hResult = E_CMP_PCR_INVALID;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

#ifdef _CMP_P2P_USE_NODE_HANDLE
	{
		uint32	nodeAddr = 0;

		hResult = lalGetNodeAddrFromHandle(cmpP2PInConnectionsOwned[iPCRNumber].oNodeHandle, &nodeAddr);
		if (hResult != NO_ERROR) return hResult;

		*oNodeAddr = (uint16) nodeAddr;
	}
#else //_CMP_P2P_USE_NODE_HANDLE
	*oNodeAddr = cmpP2PInConnectionsOwned[iPCRNumber].oNodeAddr;
#endif //_CMP_P2P_USE_NODE_HANDLE
	
	*oPCRNumber = cmpP2PInConnectionsOwned[iPCRNumber].oPCRNumber;
	*status = cmpP2PInConnectionsOwned[iPCRNumber].status;

	return hResult;
}
예제 #27
0
HRESULT lmInsertElementCB(LM_CONTEXT* list, uint32 index, LM_ELEMENT* elem, void **data, uint32 *pPos, uint32 *pIndex)
{
	HRESULT		hResult = NO_ERROR;

	if (data == NULL ||
		pPos == NULL ||
		*data == NULL)	
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	hResult = lmCheckElementAvailable(elem);
	if (hResult != NO_ERROR) return E_LM_ELEMENT_NOT_FOUND;

	// found the first available element

	lmMoveElementPositions(list, *pPos, +1);
	
	memcpy(&(elem->data), *data, list->elemsize);
	elem->position = (uint16) *pPos;
	elem->flags -= ELEMFLAG_AVAILABLE;
	list->allocated++;

	if (pIndex)
	{
		*pIndex = index;
	}

	return hResult;
}
예제 #28
0
HRESULT lmFindElementCB(LM_CONTEXT* list, uint32 index, LM_ELEMENT* elem, void **data, uint32 *arg1, uint32 *pIndex)
{
	HRESULT		hResult = NO_ERROR;

	UNUSED_ARG(arg1);

	if (data == NULL ||
		*data == NULL)	
	{
		hResult = E_NULL_PTR;
		sysLogError(hResult, __LINE__, moduleName);
		return hResult;
	}

	hResult = lmCheckElementAllocated(elem);
	if (hResult != NO_ERROR) return E_LM_ELEMENT_NOT_FOUND;

	if (memcmp(*data, &(elem->data), list->elemsize)) return E_LM_ELEMENT_NOT_FOUND;

	if (pIndex)
	{
		*pIndex = index;
	}

	return hResult;
}
예제 #29
0
HRESULT dalEventsUninstallCallback(DAL_EVENT_INTERFACE * pEventInterface, DAL_CALLBACK_FUNC func)
{
	HRESULT hResult = NO_ERROR;
	uint8 icb = 0, found = 0;

	if (func) 
	{
		// Reset masterMask - it will be re-built as we run thru callbacks[]
		pEventInterface->masterMask = 0;
		while (icb < DAL_CB_MAX_NUM) 
		{
			if (func == pEventInterface->callbacks[icb].func) 
			{
				memset (&pEventInterface->callbacks[icb], 0, sizeof(DAL_EVENT_CALLBACK));
				pEventInterface->callbacks[icb].func = NULL;
				found++;
			}
			// re-create masterMask
			pEventInterface->masterMask |= _dalGetMasterEvents (&pEventInterface->callbacks[icb].events);
			icb++;
		}
	}
	if (!found) 
	{
		hResult = E_DAL_INVALID_CALLBACK;
		sysLogError(hResult, __LINE__, moduleName);
	} 

	return hResult;
}
예제 #30
0
파일: TunIntf.cpp 프로젝트: Gardenya/fboss
bool TunIntf::sendPacketToHost(std::unique_ptr<RxPacket> pkt) {
  CHECK(fd_ != -1);
  const int l2Len = EthHdr::SIZE;
  auto buf = pkt->buf();
  if (buf->length() <= l2Len) {
    LOG(ERROR) << "Received a too small packet with length " << buf->length();
    return false;
  }
  // skip L2 header
  buf->trimStart(l2Len);
  int ret = 0;
  do {
    ret = write(fd_, buf->data(), buf->length());
  } while (ret == -1 && errno == EINTR);
  if (ret < 0) {
    sysLogError(ret, "Failed to send packet to the host from router ", rid_);
    return false;
  } else if (ret < buf->length()) {
    LOG(ERROR) << "Failed to send full packet to host from router " << rid_
               << ret << " bytes sent instead of " << buf->length();
  } else {
    VLOG(4) << "Send packet (" << ret << " bytes) to host from router "
            << rid_;
  }
  return true;
}