Easy way to get cpu features

I was wondering if there is an easy way to get certain cpu features like SSE2 or MMX without coding cpuid in assembler?

thx
Freddie
 
Forgot to add

I've noticed the in the kernel initcpu.c file that there are cpu_feature flags, but is this exposed to userland in one way or another?
 
Freddie, do you mean how to use those features, or how to get an overview of the features? They will always be printed in dmesg (so [cmd=]dmesg -a[/cmd] or /var/run/dmesg.boot), e.g.

Code:
# grep Features /var/run/dmesg.boot
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0xe3bd<SSE3,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x1<LAHF>
 
Looks like it, unless someone knows which call harvests these data and prints them to dmesg and how to use it as a separate cli utility ;)
 
There is some limited information available via sysctl. On FreeBSD however it is even more limited, there is only "hw.instruction_sse" flag that will then in return state that MMX is also available. I have seen several libraries and utilities that had to check CPU features at some step and most either parsed dmesg.boot or had an internal CPU feature database, since all other methods are not portable.
 
Perhaps I can add a feature request to the FreeBSD team to expose more cpu features via sysctl? Does anybody know where this can be done?

Freddie
 
There's also devel/cpuflags

Code:
$ cpuflags                                                                                                               
Unknown machine - please send cpuflags details to [edit]
OS		: 'FreeBSD'
hw.model	: 'Intel Core2 Duo CPU     T7500  @ 2.20GHz'
hw.machine	: 'amd64'
hw.machine_arch : 'amd64'
cpu details	:
CPU: Intel(R) Core(TM)2 Duo CPU     T7500  @ 2.20GHz (2194.52-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0x6fb  Family = 6  Model = f  Stepping = 11
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0xe3bd<SSE3,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM>
  AMD Features=0x20100800<SYSCALL,NX,LM>
  AMD Features2=0x1<LAHF>
  TSC: P-state invariant
-msse3 -mfpmath=sse

Most of this is already in dmesg.
 
hey... nevermind... I just tought you guys would appreciate such program, I know there must be like 20+ out there. besides anyone could actually go ahead read the product # on the box in which your PC's CPU came and then look it up on the proper mfg's page...

the author of the app I posted above (of whom there is like no more info of whatsoever he's doing right know, perhaps vacations?) is also the author of stuf such like NSPluginWrapper, SheepShaver, Basilisk II JIT... just to mention a few.

I'm not taking any credits on that... is quite hard to find it anyways... kindda rare piece of soft.. .I can be wrong thogh... so as by the freebsd style... nevermind.
 
sorry... I just got kindda touchy on the subject, I expected someone would find it interesting like I did... don't get me wrong, I don't want to get banned, sorry... just realized I was shouting...
 
Back
Top