1 // Copyright 2018 IBM 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ 16 #define CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ 17 18 #include "cpu_features_cache_info.h" 19 #include "cpu_features_macros.h" 20 21 CPU_FEATURES_START_CPP_NAMESPACE 22 23 typedef struct { 24 int ppc32 : 1; 25 int ppc64 : 1; 26 int ppc601 : 1; 27 int altivec : 1; 28 int fpu : 1; 29 int mmu : 1; 30 int mac_4xx : 1; 31 int unifiedcache : 1; 32 int spe : 1; 33 int efpsingle : 1; 34 int efpdouble : 1; 35 int no_tb : 1; 36 int power4 : 1; 37 int power5 : 1; 38 int power5plus : 1; 39 int cell : 1; 40 int booke : 1; 41 int smt : 1; 42 int icachesnoop : 1; 43 int arch205 : 1; 44 int pa6t : 1; 45 int dfp : 1; 46 int power6ext : 1; 47 int arch206 : 1; 48 int vsx : 1; 49 int pseries_perfmon_compat : 1; 50 int truele : 1; 51 int ppcle : 1; 52 int arch207 : 1; 53 int htm : 1; 54 int dscr : 1; 55 int ebb : 1; 56 int isel : 1; 57 int tar : 1; 58 int vcrypto : 1; 59 int htm_nosc : 1; 60 int arch300 : 1; 61 int ieee128 : 1; 62 int darn : 1; 63 int scv : 1; 64 int htm_no_suspend : 1; 65 66 // Make sure to update PPCFeaturesEnum below if you add a field here. 67 } PPCFeatures; 68 69 typedef struct { 70 PPCFeatures features; 71 } PPCInfo; 72 73 PPCInfo GetPPCInfo(void); 74 75 typedef struct { 76 char platform[64]; // 0 terminated string 77 char base_platform[64]; // 0 terminated string 78 } PPCPlatformTypeStrings; 79 80 typedef struct { 81 char platform[64]; // 0 terminated string 82 char model[64]; // 0 terminated string 83 char machine[64]; // 0 terminated string 84 char cpu[64]; // 0 terminated string 85 PPCPlatformTypeStrings type; 86 } PPCPlatformStrings; 87 88 PPCPlatformStrings GetPPCPlatformStrings(void); 89 90 //////////////////////////////////////////////////////////////////////////////// 91 // Introspection functions 92 93 typedef enum { 94 PPC_32, /* 32 bit mode execution */ 95 PPC_64, /* 64 bit mode execution */ 96 PPC_601_INSTR, /* Old POWER ISA */ 97 PPC_HAS_ALTIVEC, /* SIMD Unit*/ 98 PPC_HAS_FPU, /* Floating Point Unit */ 99 PPC_HAS_MMU, /* Memory management unit */ 100 PPC_HAS_4xxMAC, 101 PPC_UNIFIED_CACHE, /* Unified instruction and data cache */ 102 PPC_HAS_SPE, /* Signal processing extention unit */ 103 PPC_HAS_EFP_SINGLE, /* SPE single precision fpu */ 104 PPC_HAS_EFP_DOUBLE, /* SPE double precision fpu */ 105 PPC_NO_TB, /* No timebase */ 106 PPC_POWER4, 107 PPC_POWER5, 108 PPC_POWER5_PLUS, 109 PPC_CELL, /* Cell broadband engine */ 110 PPC_BOOKE, /* Embedded ISA */ 111 PPC_SMT, /* Simultaneous multi-threading */ 112 PPC_ICACHE_SNOOP, 113 PPC_ARCH_2_05, /* ISA 2.05 - POWER6 */ 114 PPC_PA6T, /* PA Semi 6T core ISA */ 115 PPC_HAS_DFP, /* Decimal floating point unit */ 116 PPC_POWER6_EXT, 117 PPC_ARCH_2_06, /* ISA 2.06 - POWER7 */ 118 PPC_HAS_VSX, /* Vector-scalar extension */ 119 PPC_PSERIES_PERFMON_COMPAT, /* Set of backwards compatibile performance 120 monitoring events */ 121 PPC_TRUE_LE, 122 PPC_PPC_LE, 123 PPC_ARCH_2_07, /* ISA 2.07 - POWER8 */ 124 PPC_HTM, /* Hardware Transactional Memory */ 125 PPC_DSCR, /* Data stream control register */ 126 PPC_EBB, /* Event base branching */ 127 PPC_ISEL, /* Integer select instructions */ 128 PPC_TAR, /* Target address register */ 129 PPC_VEC_CRYPTO, /* Vector cryptography instructions */ 130 PPC_HTM_NOSC, /* Transactions aborted when syscall made*/ 131 PPC_ARCH_3_00, /* ISA 3.00 - POWER9 */ 132 PPC_HAS_IEEE128, /* VSX IEEE Binary Float 128-bit */ 133 PPC_DARN, /* Deliver a random number instruction */ 134 PPC_SCV, /* scv syscall */ 135 PPC_HTM_NO_SUSPEND, /* TM w/out suspended state */ 136 PPC_LAST_, 137 } PPCFeaturesEnum; 138 139 int GetPPCFeaturesEnumValue(const PPCFeatures* features, PPCFeaturesEnum value); 140 141 const char* GetPPCFeaturesEnumName(PPCFeaturesEnum); 142 143 CPU_FEATURES_END_CPP_NAMESPACE 144 145 #if !defined(CPU_FEATURES_ARCH_PPC) 146 #error "Including cpuinfo_ppc.h from a non-ppc target." 147 #endif 148 149 #endif // CPU_FEATURES_INCLUDE_CPUINFO_PPC_H_ 150