HalpTimerSelectRoles
__int64 HalpTimerSelectRoles(){
unsigned int v0;
ULONG_PTR *v1;
ULONG_PTR *v2;
void *v3;
ULONG_PTR *Timer;
void *v5;
void *v6;
void *v7;
void *v8;
void *v9;
ULONG_PTR *IdealClockSource;
void *v11;
void *v12;
void *v13;
ULONG_PTR v14;
ULONG_PTR *IdealPerformanceCounterSource;
void *v16;
void *v17;
void *v18;
INT64 v19;
KDPC *v20;
ULONG_PTR *v21;
void *v22;
void *v23;
void *v24;
ULONG_PTR *v25;
ULONG_PTR *BestAlwaysOnTimer;
void *v27;
void *v28;
void *v29;
ULONG_PTR v30;
ULONG_PTR v31;
ULONG_PTR *v32;
void *v33;
void *v34;
void *v35;
ULONG_PTR v36;
ULONG_PTR *v37;
void *v38;
void *v39;
void *v40;
__int64 v41;
ULONG_PTR *IdealWatchdog;
void *v43;
void *v44;
void *v45;
ULONG_PTR *v46;
ULONG_PTR *v48;
void *v49;
void *v50;
void *v51;
ULONG_PTR *v52;
ULONG_PTR v53;
ULONG_PTR *v54;
void *v55;
INT64 v56;
ULONG_PTR *v57;
void *v58;
void *v59;
v0 = 0;
if( HalpTimerFrequenciesMeasured )
goto LABEL_6;
do
{
v1 = 0i64;
v2 = 0i64;
Timer = HalpFindTimer(1, 2, 24576, 0, 0);
if( Timer )
goto LABEL_3;
Timer = HalpFindTimer(3, 2, 24576, 0, 0);
if( Timer )
goto LABEL_3;
Timer = HalpFindTimer(6, 2, 24576, 0, 0);
if( Timer )
goto LABEL_3;
Timer = HalpFindTimer(2, 0, 0, 0, 0);
if( Timer )
goto LABEL_3;
v48 = (ULONG_PTR *)HalpRegisteredTimers;
if( (ULONG_PTR *)HalpRegisteredTimers == &HalpRegisteredTimers )
goto LABEL_57;
do
{
Timer = v48;
v48 = (ULONG_PTR *)*v48;
v3 = (void *)*((unsigned int *)Timer + 46);
if( ((unsigned __int8)v3 & 1) == 0 )
{
if( Timer[22] )
v1 = Timer;
if( (Timer[28] & 2) != 0 && Timer[24] )
{
if( ((unsigned __int8)v3 & 8) == 0 )
goto LABEL_58;
if( !v2 )
v2 = Timer;
}
}
}
while( v48 != &HalpRegisteredTimers );
if( v1 )
{
Timer = v1;
goto LABEL_58;
}
if( !v2 )
{
LABEL_57:
Timer = 0i64;
}
else
{
*((_DWORD *)v2 + 46) &= ~8u;
Timer = v2;
}
LABEL_58:
if( !Timer )
{
HalpTimerLastProblem = 19;
return(unsigned int)-1073741823;
}
LABEL_3:
if( (int)HalpTimerInitialize((__int64)Timer, v3, v5, v6) >= 0 )
{
HalpTimerMeasureFrequencies((__int64)Timer, v7, v8, v9);
HalpTimerFrequenciesMeasured = 1;
}
}
while( !HalpTimerFrequenciesMeasured );
LABEL_6:
while( !HalpClockTimer )
{
IdealClockSource = HalpTimerFindIdealClockSource();
v14 = (ULONG_PTR)IdealClockSource;
if( !IdealClockSource )
goto LABEL_60;
if( (int)HalpTimerInitialize((__int64)IdealClockSource, v11, v12, v13) >= 0 )
{
*(_DWORD *)(v14 + 184) |= 4u;
HalpClockTimer = v14;
break;
}
}
while( !HalpPerformanceCounter
|| (*(_DWORD *)(HalpPerformanceCounter + 184) & 4) == 0
|| HalpPerformanceCounter == HalpClockTimer )
{
IdealPerformanceCounterSource = HalpTimerFindIdealPerformanceCounterSource();
v19 = (INT64)IdealPerformanceCounterSource;
if( !IdealPerformanceCounterSource )
{
HalpTimerLastProblem = 21;
return(unsigned int)-1073741823;
}
if( (int)HalpTimerInitialize((__int64)IdealPerformanceCounterSource, v16, v17, v18) >= 0 )
{
HalpPerformanceCounter = v19;
HalpTimerPropagateQpcBiasUpdate(v19);
*(_DWORD *)(v19 + 184) |= 4u;
break;
}
}
v20 = HalpStallCounter;
if( ((__int64)HalpStallCounter[3].DeferredContext & 0x2000) != 0 || HalpStallCounter == (KDPC *)HalpClockTimer )
{
v20 = (KDPC *)HalpPerformanceCounter;
HalpStallCounter = (KDPC *)HalpPerformanceCounter;
}
else
{
LODWORD(HalpStallCounter[2].DpcData) |= 4u;
}
if( v20 != (KDPC *)HalpOriginalStallTimer )
*(_DWORD *)(HalpOriginalStallTimer + 184) |= 4u;
if( !HalpAuxiliaryCounter )
{
v21 = HalpFindTimer(15, 1048578, 24576, 0, 0);
v25 = v21;
if( v21 )
{
if( v21[24] <= 0x3B9ACA00 && (int)HalpTimerInitialize((__int64)v21, v22, v23, v24) >= 0 )
{
*((_DWORD *)v25 + 46) |= 4u;
HalpAuxiliaryCounter = v25;
}
}
}
while( !HalpAlwaysOnTimer )
{
if( (*(_DWORD *)(HalpClockTimer + 224) & 0x8000) != 0 )
break;
BestAlwaysOnTimer = HalpTimerFindBestAlwaysOnTimer(0);
v30 = (ULONG_PTR)BestAlwaysOnTimer;
if( !BestAlwaysOnTimer )
break;
if( (int)HalpTimerInitialize((__int64)BestAlwaysOnTimer, v27, v28, v29) >= 0 )
{
*(_DWORD *)(v30 + 184) |= 4u;
HalpAlwaysOnTimer = v30;
break;
}
}
v31 = HalpClockTimer;
if( (*(_DWORD *)(HalpClockTimer + 224) & 1) != 0 )
goto LABEL_26;
if( HalpVpptTimerRegister(HalpClockTimer, 0) < 0 )
v52 = 0i64;
else
v52 = HalpFindTimer(12, 32, 0, 3840, 0);
HalpClockTimer = (ULONG_PTR)v52;
if( !v52 )
{
LABEL_60:
HalpTimerLastProblem = 20;
return(unsigned int)-1073741823;
}
if( (int)HalpTimerInitialize((__int64)v52, v49, v50, v51) < 0 )
{
v53 = HalpClockTimer;
HalpTimerLastProblem = 20;
if( HalpClockTimer )
{
*(_DWORD *)(HalpClockTimer + 252) = 20;
*(_QWORD *)(v53 + 264) = "minkernel\\hals\\lib\\timers\\common\\timer.c";
*(_DWORD *)(v53 + 256) = 2;
*(_DWORD *)(v53 + 272) = 3280;
}
return(unsigned int)-1073741823;
}
v31 = HalpClockTimer;
*(_DWORD *)(HalpClockTimer + 184) |= 4u;
LABEL_26:
if( HalpAlwaysOnTimer && (*(_DWORD *)(HalpAlwaysOnTimer + 224) & 1) == 0 && (*(_DWORD *)(v31 + 224) & 1) != 0 )
{
if( HalpVpptTimerRegister(HalpAlwaysOnTimer, 1) < 0 )
v54 = 0i64;
else
v54 = HalpFindTimer(12, 32, 0, 3840, 0);
HalpAlwaysOnTimer = (ULONG_PTR)v54;
if( !v54 )
{
HalpTimerLastProblem = 33;
return(unsigned int)-1073741823;
}
*((_DWORD *)v54 + 46) |= 4u;
}
while( !HalpAlwaysOnCounter
&& ((*(_DWORD *)(HalpPerformanceCounter + 224) & 0x8000) == 0
|| ((__int64)HalpStallCounter[3].DeferredContext & 0x8000) == 0) )
{
v32 = HalpTimerFindBestAlwaysOnTimer(1);
v36 = (ULONG_PTR)v32;
if( !v32 )
break;
if( (int)HalpTimerInitialize((__int64)v32, v33, v34, v35) >= 0 )
{
*(_DWORD *)(v36 + 184) |= 4u;
HalpAlwaysOnCounter = v36;
break;
}
}
while( !HalpProfileTimer && (__int64(__fastcall **)())HalpProfileInterface[0] == DefaultProfileInterface )
{
v57 = HalpFindTimer(0, 65, 0, 3840, 0);
if( !v57
&& (HalpQueryMaximumRegisteredProcessorCount(v56) != 1 || (v57 = HalpFindTimer(0, 64, 0, 3840, 0)) == 0i64) )
{
HalpTimerLastProblem = 23;
break;
}
if( (int)HalpTimerInitialize((__int64)v57, v55, v58, v59) >= 0 )
{
*((_DWORD *)v57 + 46) |= 4u;
HalpProfileTimer = v57;
HalpTimerStopProfileInterrupt();
break;
}
}
if( (*(_DWORD *)(HalpPerformanceCounter + 224) & 1) != 0 )
{
while( !HalpFallbackPerformanceCounter )
{
v37 = HalpTimerFindIdealPerformanceCounterSource();
v41 = (__int64)v37;
if( !v37 )
{
HalpTimerLastProblem = 22;
break;
}
if( (int)HalpTimerInitialize((__int64)v37, v38, v39, v40) >= 0 )
{
*(_DWORD *)(v41 + 184) |= 4u;
HalpFallbackPerformanceCounter = v41;
break;
}
}
}
if( !HalpTimerWatchdogDisable )
{
IdealWatchdog = HalpTimerFindIdealWatchdog();
v46 = IdealWatchdog;
if( IdealWatchdog )
{
if( (int)HalpTimerInitialize((__int64)IdealWatchdog, v43, v44, v45) >= 0 )
{
*((_DWORD *)v46 + 46) |= 4u;
HalpWatchdogTimer = v46;
}
}
}
return v0;
}Referenced by:
HalpInitializeTimers