bool APartyBeaconHost::InitHostBeacon(int32 InTeamCount, int32 InTeamSize, int32 InMaxReservations, FName InSessionName)
{
	UE_LOG(LogBeacon, Verbose, TEXT("InitPartyHost TeamCount:%d TeamSize:%d MaxSize:%d"), InTeamCount, InTeamSize, InMaxReservations);
	if (InMaxReservations > 0)
	{
		SessionName = InSessionName;

		NumTeams = InTeamCount;
		NumPlayersPerTeam = InTeamSize;
		MaxReservations = InMaxReservations;
		Reservations.Empty(MaxReservations);
		return InitHost();
	}

	return false;
}
Beispiel #2
0
boolean CDWHCIDevice::Initialize (void)
{
	DataMemBarrier ();

	assert (m_pInterruptSystem != 0);
	assert (m_pTimer != 0);

	CDWHCIRegister VendorId (DWHCI_CORE_VENDOR_ID);
	if (VendorId.Read () != 0x4F54280A)
	{
		CLogger::Get ()->Write (FromDWHCI, LogError, "Unknown vendor 0x%0X", VendorId.Get ());
		return FALSE;
	}

	if (!PowerOn ())
	{
		CLogger::Get ()->Write (FromDWHCI, LogError, "Cannot power on");
		return FALSE;
	}
	
	// Disable all interrupts
	CDWHCIRegister AHBConfig (DWHCI_CORE_AHB_CFG);
	AHBConfig.Read ();
	AHBConfig.And (~DWHCI_CORE_AHB_CFG_GLOBALINT_MASK);
	AHBConfig.Write ();
	
	assert (m_pInterruptSystem != 0);
	m_pInterruptSystem->ConnectIRQ (ARM_IRQ_USB, InterruptStub, this);

	if (!InitCore ())
	{
		CLogger::Get ()->Write (FromDWHCI, LogError, "Cannot initialize core");
		return FALSE;
	}
	
	EnableGlobalInterrupts ();
	
	if (!InitHost ())
	{
		CLogger::Get ()->Write (FromDWHCI, LogError, "Cannot initialize host");
		return FALSE;
	}

	// The following calls will fail if there is no device or no supported device connected
	// to root port. This is not an error because the system may run without an USB device.

	if (!EnableRootPort ())
	{
		CLogger::Get ()->Write (FromDWHCI, LogWarning, "No device connected to root port");
		return TRUE;
	}

	if (!m_RootPort.Initialize ())
	{
		CLogger::Get ()->Write (FromDWHCI, LogWarning, "Cannot initialize root port");
		return TRUE;
	}
	
	DataMemBarrier ();

	return TRUE;
}
Beispiel #3
0
JLThreadFuncDecl
TaskThreadProc( void *threadArg ) {

	TaskPrivate *pv = NULL;
	jl::ChunkedBuffer<char> errBuffer;

	JSContext *cx = CreateHost((uint32_t)-1, (uint32_t)-1, 0);
	if ( cx == NULL ) // out of memory
		JLThreadExit(0);

	jl::Host& hpv;
	hpv = jl::Host::getJLHost(cx);

// allocator must be threadsafe !
	hpv->alloc.malloc = jl_malloc;
	hpv->alloc.calloc = jl_calloc;
	hpv->alloc.memalign = jl_memalign;
	hpv->alloc.realloc = jl_realloc;
	hpv->alloc.msize = jl_msize;
	hpv->alloc.free = jl_free;

	JL_CHK( InitHost(cx, _unsafeMode != 0, NULL, NULL, TaskStdErrHostOutput, &errBuffer) );

	JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_DONT_REPORT_UNCAUGHT);

	pv = (TaskPrivate*)threadArg;
	ASSERT( pv );

	bool ok;
	
	ok = TheTask(cx, pv);
	
	if ( !ok ) { // handle fatal error

		jsval ex;
		if ( JL_IsExceptionPending(cx) ) {

			ok = JS_GetPendingException(cx, &ex);
			JS_ClearPendingException(cx);
			JL_CHK( ok );
		} else {

			JL_CHK( JL_NativeToJsval(cx, errBuffer.GetData(), errBuffer.Length(), &ex) );
		}

		SerializedData * serializedException;
		SerializerCreate(&serializedException);

		if ( !SerializeJsval(cx, serializedException, &ex) ) {

ASSERT( false );

			JLSemaphoreRelease(pv->responseSem); // +1
			JL_ERR( E_JSLIBS, E_STR("serializer"), E_INTERNAL );
		}

		JLMutexAcquire(pv->mutex); // --
		pv->end = true;
		QueuePush(&pv->exceptionList, serializedException);
		JLMutexRelease(pv->mutex); // ++
		
		JLSemaphoreRelease(pv->responseSem); // +1
	}

good:

bad:

	// These queues must be destroyed before cx because SerializedData * *ser hold a reference to the context that created the value.
	JLMutexAcquire(pv->mutex); // --
	while ( !QueueIsEmpty(&pv->exceptionList) ) {

		SerializedData * ser = (SerializedData *)QueueShift(&pv->exceptionList);
		SerializerFree(&ser);
	}
	while ( !QueueIsEmpty(&pv->responseList) ) {

		SerializedData * ser = (SerializedData *)QueueShift(&pv->responseList);
		SerializerFree(&ser);
	}
	JLMutexRelease(pv->mutex); // ++

	if ( cx )
		DestroyHost(cx, false); // no skip cleanup, else memory leaks.
	JLThreadExit(0);
	return 0;
}