IPC_SmPtr IPC_SmPoolAlloc(IPC_U32 PoolOverhead,
			IPC_U32 HeaderSize,
			IPC_U32 DataSize,
			IPC_U32 BufferCount)
{
	IPC_SmPtr Pool;

	if (SmLocalControl.SmControl->
	    CurrentBuffers[IPC_CPU_ID_INDEX(IPC_SM_CURRENT_CPU)] +
	    BufferCount >= IPC_SM_MAX_BUFFERS) {
		IPC_TRACE(IPC_Channel_Error, "IPC_SmPoolAlloc",
			  "Too Many Buffers", 0, 0, 0, 0);
		return 0;
	}

	Pool = IPC_SmAlloc(PoolOverhead
			   + (IPC_BufferOverhead() + HeaderSize +
			      DataSize) * BufferCount);

	if (Pool == 0) {
		IPC_TRACE(IPC_Channel_Error, "IPC_SmPoolAlloc",
			  "Failed to Allocate Sm", 0, 0, 0, 0);
		return 0;
	}

	SmLocalControl.SmControl->
	    CurrentBuffers[IPC_CPU_ID_INDEX(IPC_SM_CURRENT_CPU)] += BufferCount;

	IPC_SmAddPool(Pool);

	return Pool;
}
Ejemplo n.º 2
0
void IPC_PoolDump(IPC_BufferPool Pool)
{
	IPC_BufferPool_T *PoolPtr = IPC_PoolToPtr(Pool);
	IPC_U32 Id;
	IPC_SmPtr Buffer;
	IPC_U32 BufferSize;
	IPC_Buffer_T *BufferPtr;

	IPC_TRACE(IPC_Channel_General, "----- IPC_PoolDump -----", "", 0, 0, 0,
		  0);

	if (!PoolPtr) {
		IPC_TRACE(IPC_Channel_General, "IPC_PoolDump",
			  "Pool %08X Invalid", Pool, 0, 0, 0);
		return;
	};

	IPC_TRACE(IPC_Channel_General, "IPC_PoolDump",
		  "Pool %08X, CPU %s, SrcEp %02X, DestEp %02X", Pool,
		  (IPC_U32)IPC_GetCpuName(PoolPtr->Cpu),
		  PoolPtr->SourceEndpointId, PoolPtr->DestinationEndpointId);
	IPC_TRACE(IPC_Channel_General, "            ",
		  "SrcEp Id=%02X Name=%s, DestEp Id=%02X Name=%s",
		  PoolPtr->SourceEndpointId,
		  (IPC_U32)IPC_GetEndPointName(PoolPtr->SourceEndpointId),
		  PoolPtr->DestinationEndpointId,
		  (IPC_U32)IPC_GetEndPointName(PoolPtr->DestinationEndpointId));

	IPC_TRACE(IPC_Channel_General, "            ",
		  "BufCount %d, Free  %d, FlowState %01d, Param %08X",
		  PoolPtr->MaxBuffers, PoolPtr->FreeBuffers,
		  PoolPtr->FlowControlState, PoolPtr->UserParameter);

	IPC_PoolDumpStats(Pool);

	/* Dump IPC buffer not consumed by receiver to debug
	   IPC memory depletion issue */
	if (PoolPtr->MaxBuffers == PoolPtr->FreeBuffers)
		return;

	Buffer = Pool + sizeof(IPC_BufferPool_T);
	BufferSize =
	    IPC_BufferOverhead() + PoolPtr->MaxHeaderSize +
	    PoolPtr->MaxDataSize;
	IPC_TRACE(IPC_Channel_General, "IPC_PoolDump", "Allocated Buffers:", 0,
		  0, 0, 0);
	for (Id = 0; Id < PoolPtr->MaxBuffers; Id++) {
		BufferPtr = IPC_BufferToPtr(Buffer);
		if (BufferPtr->StatusCode != IPC_BUFFER_STATUS_FREE)
			IPC_BufferDump(Buffer);
		Buffer += BufferSize;
	}
}