int main(int argc, char* argv[])
{
unsigned long s1,s2,s3,s4;
char sel;
printf("Select the function:/n1-------Read CPU id./n2-------Disable CPU id./n");
sel=getchar();
switch(sel)
{
case '1':
asm volatile
( "movl $0x01 , %%eax ; /n/t"
"xorl %%edx , %%edx ;/n/t"
"cpuid ;/n/t"
"movl %%edx ,%0 ;/n/t"
"movl %%eax ,%1 ; /n/t"
:"=m"(s1),"=m"(s2)
);
printf("%08X-%08X-",s1,s2);
asm volatile
("movl $0x03,%%eax ;/n/t"
"xorl %%ecx,%%ecx ;/n/t"
"xorl %%edx,%%edx ;/n/t"
"cpuid ;/n/t"
"movl %%edx,%0 ;/n/t"
"movl %%ecx,%1 ;/n/t"
:"=m"(s3),"=m"(s4)
);
printf("%08X-%08X /n",s3,s4);
break;
case '2':
asm volatile
("mov $0x119,%ecx /n/t"
"rdmsr /n/t"
"or $0x00200000,%eax /n/t"
"wrmsr /n/t"
);
printf("CPU id is disabled./n");
break;
}
return 0;
}
获取CPU序列号
最新推荐文章于 2025-03-28 16:33:29 发布