Author Topic: Adding feature to cpu.c  (Read 2365 times)

0 Members and 1 Guest are viewing this topic.

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
Adding feature to cpu.c
« on: October 03, 2010, 06:15:04 PM »
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:
Code: [Select]
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?

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
Re: Adding feature to cpu.c
« Reply #1 on: October 04, 2010, 02:27:07 PM »
one typo got fixed:    asm (   "movl $0x0, %%eax;"
The value is also shown at boot time. But I could not stop endless reboots...not yet :P

Kabyl

  • VoodooLabs
  • Posts: 158
Re: Adding feature to cpu.c
« Reply #2 on: October 04, 2010, 04:47:22 PM »
Why not use the available do_cpuid(), or just Platform.CPU.CPUID[0] ?
« Last Edit: October 04, 2010, 04:52:04 PM by Kabyl »

valv

  • VoodooLabs
  • Posts: 72
    • The AnVAL Forum (fr)
Re: Adding feature to cpu.c
« Reply #3 on: October 05, 2010, 12:49:24 AM »
well, I've tested it that way and even CPUID[0], but I wasn't looking into the right place.
btw, why did u omitted the last possibility, is it not impossible?
The problem got fixed (with respect to meklort) once I got rid of modularity.

Up to next step.