kernel/eka/nkernsmp/x86/ncutils.cpp
changeset 90 947f0dc9f7a8
parent 0 a41df078684a
child 177 a232af6b0b1f
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
    30 TUint32 NKern::IdleGenerationCount()
    30 TUint32 NKern::IdleGenerationCount()
    31 	{
    31 	{
    32 	return TheScheduler.iIdleGenerationCount;
    32 	return TheScheduler.iIdleGenerationCount;
    33 	}
    33 	}
    34 
    34 
    35 void NKern::Idle()
    35 void NKern::DoIdle()
    36 	{
    36 	{
    37 	TScheduler& s = TheScheduler;
    37 	TScheduler& s = TheScheduler;
    38 	TSubScheduler& ss = SubScheduler();	// OK since idle thread is locked to CPU
    38 	TSubScheduler& ss = SubScheduler();	// OK since idle thread is locked to CPU
    39 	TUint32 m = ss.iCpuMask;
    39 	TUint32 m = ss.iCpuMask;
    40 
    40 
    55 			NKern::Lock();
    55 			NKern::Lock();
    56 			NKern::Unlock();	// process idle DFCs here
    56 			NKern::Unlock();	// process idle DFCs here
    57 			return;
    57 			return;
    58 			}
    58 			}
    59 		}
    59 		}
       
    60 	if (ss.iCurrentThread->iSavedSP)
       
    61 		{
       
    62 		// rescheduled between entry to NKern::Idle() and here
       
    63 		// go round again to see if any more threads to pull from other CPUs
       
    64 		__e32_atomic_ior_ord32(&s.iCpusNotIdle, m);	// we aren't idle after all
       
    65 		s.iIdleSpinLock.UnlockIrq();
       
    66 		return;
       
    67 		}
       
    68 
    60 	s.iIdleSpinLock.UnlockOnly();	// leave interrupts disabled
    69 	s.iIdleSpinLock.UnlockOnly();	// leave interrupts disabled
       
    70 
    61 	NKIdle(0);
    71 	NKIdle(0);
       
    72 	
    62 	}
    73 	}
    63 
    74 
    64 TUint32 ContextId()
    75 TUint32 ContextId()
    65 	{
    76 	{
    66 	switch(NKern::CurrentContext())
    77 	switch(NKern::CurrentContext())
   322 	__KTRACE_OPT(KBOOT,DEBUGPRINT("iMaxTimerClock=%u", VIB->iMaxTimerClock));
   333 	__KTRACE_OPT(KBOOT,DEBUGPRINT("iMaxTimerClock=%u", VIB->iMaxTimerClock));
   323 	TInt i;
   334 	TInt i;
   324 	for (i=0; i<KMaxCpus; ++i)
   335 	for (i=0; i<KMaxCpus; ++i)
   325 		{
   336 		{
   326 		TSubScheduler& ss = TheSubSchedulers[i];
   337 		TSubScheduler& ss = TheSubSchedulers[i];
   327 		ss.i_TimerMultF = (TAny*)KMaxTUint32;
   338 		ss.iSSX.iCpuFreqM = KMaxTUint32;
   328 		ss.i_TimerMultI = (TAny*)0x01000000u;
   339 		ss.iSSX.iCpuFreqS = 0;
   329 		ss.i_CpuMult = (TAny*)KMaxTUint32;
   340 		ss.iSSX.iCpuPeriodM = 0x80000000u;
   330 		VIB->iTimerMult[i] = (volatile STimerMult*)&ss.i_TimerMultF;
   341 		ss.iSSX.iCpuPeriodS = 31;
   331 		VIB->iCpuMult[i] = (volatile TUint32*)&ss.i_CpuMult;
   342 		ss.iSSX.iNTimerFreqM = KMaxTUint32;
   332 		}
   343 		ss.iSSX.iNTimerFreqS = 0;
   333 	TheScheduler.i_TimerMax = (TAny*)(VIB->iMaxTimerClock / 128);
   344 		ss.iSSX.iNTimerPeriodM = 0x80000000u;
       
   345 		ss.iSSX.iNTimerPeriodS = 31;
       
   346 		ss.iSSX.iTimerFreqM = KMaxTUint32;
       
   347 		ss.iSSX.iTimerFreqS = 0;
       
   348 		ss.iSSX.iTimerPeriodM = 0x80000000u;
       
   349 		ss.iSSX.iTimerPeriodS = 31;
       
   350 		ss.iSSX.iTimestampOffset.i64 = 0;
       
   351 		VIB->iTimerMult[i] = 0;
       
   352 		VIB->iCpuMult[i] = 0;
       
   353 		}
       
   354 	TheScheduler.iSX.iTimerMax = (VIB->iMaxTimerClock / 128);
   334 	InitFpu();
   355 	InitFpu();
   335 	InterruptInit0();
   356 	InterruptInit0();
   336 	}
   357 	}
   337 
   358 
   338 EXPORT_C TUint32 NKern::CpuTimeMeasFreq()
   359 EXPORT_C TUint32 NKern::CpuTimeMeasFreq()
   349  	@pre aMicroseconds should be nonnegative
   370  	@pre aMicroseconds should be nonnegative
   350 	@pre any context
   371 	@pre any context
   351  */
   372  */
   352 EXPORT_C TInt NKern::TimesliceTicks(TUint32 aMicroseconds)
   373 EXPORT_C TInt NKern::TimesliceTicks(TUint32 aMicroseconds)
   353 	{
   374 	{
   354 	TUint32 mf32 = (TUint32)TheScheduler.i_TimerMax;
   375 	TUint32 mf32 = (TUint32)TheScheduler.iSX.iTimerMax;
   355 	TUint64 mf(mf32);
   376 	TUint64 mf(mf32);
   356 	TUint64 ticks = mf*TUint64(aMicroseconds) + UI64LIT(999999);
   377 	TUint64 ticks = mf*TUint64(aMicroseconds) + UI64LIT(999999);
   357 	ticks /= UI64LIT(1000000);
   378 	ticks /= UI64LIT(1000000);
   358 	if (ticks > TUint64(TInt(KMaxTInt)))
   379 	if (ticks > TUint64(TInt(KMaxTInt)))
   359 		return KMaxTInt;
   380 		return KMaxTInt;
   360 	else
   381 	else
   361 		return (TInt)ticks;
   382 		return (TInt)ticks;
   362 	}
   383 	}
   363 
   384 
       
   385 TBool TSubScheduler::Detached()
       
   386 	{
       
   387 	return FALSE;
       
   388 	}
       
   389 
       
   390 TBool TScheduler::CoreControlSupported()
       
   391 	{
       
   392 	return FALSE;
       
   393 	}
       
   394 
       
   395 void TScheduler::CCInitiatePowerUp(TUint32 /*aCores*/)
       
   396 	{
       
   397 	}
       
   398 
       
   399 void TScheduler::CCIndirectPowerDown(TAny*)
       
   400 	{
       
   401 	}
       
   402