|
From: Paul M. <pa...@sa...> - 2008-12-22 22:43:37
|
Bart Van Assche writes: > A source code comment in m_machine.c says the following: > > /* ppc32 doesn't seem to have a sane way to find out what insn > sets the CPU supports. So we have to arse around with > SIGILLs. Yuck. */ > > I don't know everything about the PowerPC architecture, but by looking > around in the Linux kernel sources I found out that the Linux kernel > determines the PowerPC CPU type from the value in the PowerPC PVR > register. And although reading the PVR is privileged on PowerPC, under Linux the kernel will emulate the move-from-PVR instruction and supply the actual PVR value. So userspace can do a mfpvr to find out what sort of processor it's running on. The only problem with doing that is that you need some way to handle the case where you don't recognize the PVR value you get, because the processor is a new implementation that didn't exist when your program was compiled. Another way to find out what the hardware can do is to look at the AT_HWCAP and AT_PLATFORM entries in the ELF auxiliary table. The AT_PLATFORM is a string such as "ppc970" or "power6" or "ppc750". The bits in AT_HWCAP are defined in <asm/cputable.h> and are: #define PPC_FEATURE_32 0x80000000 #define PPC_FEATURE_64 0x40000000 #define PPC_FEATURE_601_INSTR 0x20000000 #define PPC_FEATURE_HAS_ALTIVEC 0x10000000 #define PPC_FEATURE_HAS_FPU 0x08000000 #define PPC_FEATURE_HAS_MMU 0x04000000 #define PPC_FEATURE_HAS_4xxMAC 0x02000000 #define PPC_FEATURE_UNIFIED_CACHE 0x01000000 #define PPC_FEATURE_HAS_SPE 0x00800000 #define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 #define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 #define PPC_FEATURE_NO_TB 0x00100000 #define PPC_FEATURE_POWER4 0x00080000 #define PPC_FEATURE_POWER5 0x00040000 #define PPC_FEATURE_POWER5_PLUS 0x00020000 #define PPC_FEATURE_CELL 0x00010000 #define PPC_FEATURE_BOOKE 0x00008000 #define PPC_FEATURE_SMT 0x00004000 #define PPC_FEATURE_ICACHE_SNOOP 0x00002000 #define PPC_FEATURE_ARCH_2_05 0x00001000 #define PPC_FEATURE_PA6T 0x00000800 #define PPC_FEATURE_HAS_DFP 0x00000400 #define PPC_FEATURE_POWER6_EXT 0x00000200 #define PPC_FEATURE_ARCH_2_06 0x00000100 #define PPC_FEATURE_HAS_VSX 0x00000080 #define PPC_FEATURE_PSERIES_PERFMON_COMPAT \ 0x00000040 #define PPC_FEATURE_TRUE_LE 0x00000002 #define PPC_FEATURE_PPC_LE 0x00000001 Is there anything you need to know about that isn't on that list? Paul. |