In an attempt to add new feature to the cpu detection algo, am trying to put some portion of code to the cpu.c file. Even though it compiles without warning, my system keeps rebooting in an endless loop. I feel am doing something wrong, but cannot find out where.
The snippet in question is this:bool maxCPUID(void)
{
unsigned int max_cpuid = 0;
asm ( "movl $0, %%eax;"
"cpuid;"
"movl %%eax, %0;"
: "=a" (max_cpuid)
);
if (max_cpuid == 0)
{
return FALSE;
}
else
{
return TRUE;
printf("Max CPUID: 0x%x", max_cpuid);
}
}
It's intended to give the largest standard function number to the max_cpuid variable. And I need this to be able to detect if the cpu has a digital thermal sensor capability. That would come later into play, and it has been removed for the time being, just to be sure where the problem is. So, to capitulate, if I add that code to the begging of cpu.c (straight before static uint64_t measure_tsc_frequency(void) and also before void scan_cpu(PlatformInfo_t *p)), system keeps rebooting. But when omitted, everything is ok.
What do u think?