mirror of
https://github.com/google/cpu_features.git
synced 2025-07-01 05:11:15 +02:00
powerpc: Added PowerPC implementation
Signed-off-by: Rashmica Gupta <rashmica.gupta@au1.ibm.com>
This commit is contained in:

committed by
Rashmica Gupta

parent
a5093bbe7c
commit
3adafbfe66
BIN
include/.cpuinfo_ppc.h.swp
Normal file
BIN
include/.cpuinfo_ppc.h.swp
Normal file
Binary file not shown.
@ -41,6 +41,10 @@
|
||||
#define CPU_FEATURES_ARCH_MIPS
|
||||
#endif
|
||||
|
||||
#if defined(__powerpc__)
|
||||
#define CPU_FEATURES_ARCH_PPC
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Os
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
139
include/cpuinfo_ppc.h
Normal file
139
include/cpuinfo_ppc.h
Normal file
@ -0,0 +1,139 @@
|
||||
// Copyright 2018 IBM
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
|
||||
#define CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
typedef struct {
|
||||
int ppc32 : 1;
|
||||
int ppc64 : 1;
|
||||
int ppc601 : 1;
|
||||
int altivec : 1;
|
||||
int fpu : 1;
|
||||
int mmu : 1;
|
||||
int mac_4xx : 1;
|
||||
int unifiedcache : 1;
|
||||
int spe : 1;
|
||||
int efpsingle : 1;
|
||||
int efpdouble : 1;
|
||||
int no_tb : 1;
|
||||
int power4 : 1;
|
||||
int power5 : 1;
|
||||
int power5plus : 1;
|
||||
int cell : 1;
|
||||
int booke : 1;
|
||||
int smt : 1;
|
||||
int icachesnoop : 1;
|
||||
int arch205 : 1;
|
||||
int pa6t : 1;
|
||||
int dfp : 1;
|
||||
int power6ext : 1;
|
||||
int arch206 : 1;
|
||||
int vsx : 1;
|
||||
int pseries_perfmon_compat : 1;
|
||||
int truele : 1;
|
||||
int ppcle : 1;
|
||||
int arch207 : 1;
|
||||
int htm : 1;
|
||||
int dscr : 1;
|
||||
int ebb : 1;
|
||||
int isel : 1;
|
||||
int tar : 1;
|
||||
int vcrypto : 1;
|
||||
int htm_nosc : 1;
|
||||
int arch300 : 1;
|
||||
int ieee128 : 1;
|
||||
int darn : 1;
|
||||
int scv : 1;
|
||||
int htm_no_suspend : 1;
|
||||
|
||||
// Make sure to update PPCFeaturesEnum below if you add a field here.
|
||||
} PPCFeatures;
|
||||
|
||||
typedef struct {
|
||||
PPCFeatures features;
|
||||
} PPCInfo;
|
||||
|
||||
// This function is guaranteed to be malloc, memset and memcpy free.
|
||||
PPCInfo GetPPCInfo(void);
|
||||
|
||||
typedef struct {
|
||||
char platform[64]; // 0 terminated string
|
||||
char model[64]; // 0 terminated string
|
||||
char machine[64]; // 0 terminated string
|
||||
char cpu[64]; // 0 terminated string
|
||||
} PPCPlatformStrings;
|
||||
|
||||
PPCPlatformStrings GetPPCPlatformStrings(void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Introspection functions
|
||||
|
||||
typedef enum {
|
||||
PPC_32, /* 32 bit mode execution */
|
||||
PPC_64, /* 64 bit mode execution */
|
||||
PPC_601_INSTR, /* Old POWER ISA */
|
||||
PPC_HAS_ALTIVEC, /* SIMD Unit*/
|
||||
PPC_HAS_FPU, /* Floating Point Unit */
|
||||
PPC_HAS_MMU, /* Memory management unit */
|
||||
PPC_HAS_4xxMAC,
|
||||
PPC_UNIFIED_CACHE, /* Unified instruction and data cache */
|
||||
PPC_HAS_SPE, /* Signal processing extention unit */
|
||||
PPC_HAS_EFP_SINGLE, /* SPE single precision fpu */
|
||||
PPC_HAS_EFP_DOUBLE, /* SPE double precision fpu */
|
||||
PPC_NO_TB, /* No timebase */
|
||||
PPC_POWER4,
|
||||
PPC_POWER5,
|
||||
PPC_POWER5_PLUS,
|
||||
PPC_CELL, /* Cell broadband engine */
|
||||
PPC_BOOKE, /* Embedded ISA */
|
||||
PPC_SMT, /* Simultaneous multi-threading */
|
||||
PPC_ICACHE_SNOOP,
|
||||
PPC_ARCH_2_05, /* ISA 2.05 - POWER6 */
|
||||
PPC_PA6T, /* PA Semi 6T core ISA */
|
||||
PPC_HAS_DFP, /* Decimal floating point unit */
|
||||
PPC_POWER6_EXT,
|
||||
PPC_ARCH_2_06, /* ISA 2.06 - POWER7 */
|
||||
PPC_HAS_VSX, /* Vector-scalar extension */
|
||||
PPC_PSERIES_PERFMON_COMPAT, /* Set of backwards compatibile performance
|
||||
monitoring events */
|
||||
PPC_TRUE_LE,
|
||||
PPC_PPC_LE,
|
||||
PPC_ARCH_2_07, /* ISA 2.07 - POWER8 */
|
||||
PPC_HTM, /* Hardware Transactional Memory */
|
||||
PPC_DSCR, /* Data stream control register */
|
||||
PPC_EBB, /* Event base branching */
|
||||
PPC_ISEL, /* Integer select instructions */
|
||||
PPC_TAR, /* Target address register */
|
||||
PPC_VEC_CRYPTO, /* Vector cryptography instructions */
|
||||
PPC_HTM_NOSC, /* Transactions aborted when syscall made*/
|
||||
PPC_ARCH_3_00, /* ISA 3.00 - POWER9 */
|
||||
PPC_HAS_IEEE128, /* VSX IEEE Binary Float 128-bit */
|
||||
PPC_DARN, /* Deliver a random number instruction */
|
||||
PPC_SCV, /* scv syscall */
|
||||
PPC_HTM_NO_SUSPEND, /* TM w/out suspended state */
|
||||
PPC_LAST_,
|
||||
} PPCFeaturesEnum;
|
||||
|
||||
int GetPPCFeaturesEnumValue(const PPCFeatures* features, PPCFeaturesEnum value);
|
||||
|
||||
const char* GetPPCFeaturesEnumName(PPCFeaturesEnum);
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_
|
@ -61,6 +61,57 @@ CPU_FEATURES_START_CPP_NAMESPACE
|
||||
#define MIPS_HWCAP_DSPR2 (1UL << 8)
|
||||
#define MIPS_HWCAP_MSA (1UL << 9)
|
||||
|
||||
// http://elixir.free-electrons.com/linux/latest/source/arch/powerpc/include/uapi/asm/cputable.h
|
||||
#ifndef _UAPI__ASM_POWERPC_CPUTABLE_H
|
||||
/* in AT_HWCAP */
|
||||
#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
|
||||
|
||||
/* Reserved - do not use 0x00000004 */
|
||||
#define PPC_FEATURE_TRUE_LE 0x00000002
|
||||
#define PPC_FEATURE_PPC_LE 0x00000001
|
||||
|
||||
/* in AT_HWCAP2 */
|
||||
#define PPC_FEATURE2_ARCH_2_07 0x80000000
|
||||
#define PPC_FEATURE2_HTM 0x40000000
|
||||
#define PPC_FEATURE2_DSCR 0x20000000
|
||||
#define PPC_FEATURE2_EBB 0x10000000
|
||||
#define PPC_FEATURE2_ISEL 0x08000000
|
||||
#define PPC_FEATURE2_TAR 0x04000000
|
||||
#define PPC_FEATURE2_VEC_CRYPTO 0x02000000
|
||||
#define PPC_FEATURE2_HTM_NOSC 0x01000000
|
||||
#define PPC_FEATURE2_ARCH_3_00 0x00800000
|
||||
#define PPC_FEATURE2_HAS_IEEE128 0x00400000
|
||||
#define PPC_FEATURE2_DARN 0x00200000
|
||||
#define PPC_FEATURE2_SCV 0x00100000
|
||||
#define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint32_t hwcaps;
|
||||
uint32_t hwcaps2;
|
||||
|
Reference in New Issue
Block a user