1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ART_RUNTIME_ARCH_ARM64_INSTRUCTION_SET_FEATURES_ARM64_H_ 18 #define ART_RUNTIME_ARCH_ARM64_INSTRUCTION_SET_FEATURES_ARM64_H_ 19 20 #include "arch/instruction_set_features.h" 21 22 namespace art { 23 24 // Instruction set features relevant to the ARM64 architecture. 25 class Arm64InstructionSetFeatures FINAL : public InstructionSetFeatures { 26 public: 27 // Process a CPU variant string like "krait" or "cortex-a15" and create InstructionSetFeatures. 28 static const Arm64InstructionSetFeatures* FromVariant(const std::string& variant, 29 std::string* error_msg); 30 31 // Parse a bitmap and create an InstructionSetFeatures. 32 static const Arm64InstructionSetFeatures* FromBitmap(uint32_t bitmap); 33 34 // Turn C pre-processor #defines into the equivalent instruction set features. 35 static const Arm64InstructionSetFeatures* FromCppDefines(); 36 37 // Process /proc/cpuinfo and use kRuntimeISA to produce InstructionSetFeatures. 38 static const Arm64InstructionSetFeatures* FromCpuInfo(); 39 40 // Process the auxiliary vector AT_HWCAP entry and use kRuntimeISA to produce 41 // InstructionSetFeatures. 42 static const Arm64InstructionSetFeatures* FromHwcap(); 43 44 // Use assembly tests of the current runtime (ie kRuntimeISA) to determine the 45 // InstructionSetFeatures. This works around kernel bugs in AT_HWCAP and /proc/cpuinfo. 46 static const Arm64InstructionSetFeatures* FromAssembly(); 47 48 bool Equals(const InstructionSetFeatures* other) const OVERRIDE; 49 GetInstructionSet()50 InstructionSet GetInstructionSet() const OVERRIDE { 51 return kArm64; 52 } 53 54 uint32_t AsBitmap() const OVERRIDE; 55 56 // Return a string of the form "a53" or "none". 57 std::string GetFeatureString() const OVERRIDE; 58 59 // Generate code addressing Cortex-A53 erratum 835769? NeedFixCortexA53_835769()60 bool NeedFixCortexA53_835769() const { 61 return fix_cortex_a53_835769_; 62 } 63 64 // Generate code addressing Cortex-A53 erratum 843419? NeedFixCortexA53_843419()65 bool NeedFixCortexA53_843419() const { 66 return fix_cortex_a53_843419_; 67 } 68 ~Arm64InstructionSetFeatures()69 virtual ~Arm64InstructionSetFeatures() {} 70 71 protected: 72 // Parse a vector of the form "a53" adding these to a new ArmInstructionSetFeatures. 73 const InstructionSetFeatures* 74 AddFeaturesFromSplitString(const bool smp, const std::vector<std::string>& features, 75 std::string* error_msg) const OVERRIDE; 76 77 private: Arm64InstructionSetFeatures(bool smp,bool needs_a53_835769_fix,bool needs_a53_843419_fix)78 Arm64InstructionSetFeatures(bool smp, bool needs_a53_835769_fix, bool needs_a53_843419_fix) 79 : InstructionSetFeatures(smp), 80 fix_cortex_a53_835769_(needs_a53_835769_fix), 81 fix_cortex_a53_843419_(needs_a53_843419_fix) { 82 } 83 84 // Bitmap positions for encoding features as a bitmap. 85 enum { 86 kSmpBitfield = 1, 87 kA53Bitfield = 2, 88 }; 89 90 const bool fix_cortex_a53_835769_; 91 const bool fix_cortex_a53_843419_; 92 93 DISALLOW_COPY_AND_ASSIGN(Arm64InstructionSetFeatures); 94 }; 95 96 } // namespace art 97 98 #endif // ART_RUNTIME_ARCH_ARM64_INSTRUCTION_SET_FEATURES_ARM64_H_ 99