1 /* 2 * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef CPU_ARM_VM_VERSION_ARM_HPP 26 #define CPU_ARM_VM_VERSION_ARM_HPP 27 28 #include "runtime/abstract_vm_version.hpp" 29 #include "runtime/globals_extension.hpp" 30 31 class VM_Version: public Abstract_VM_Version { 32 friend class JVMCIVMStructs; 33 34 static bool _has_simd; 35 static bool _has_mp_ext; 36 37 protected: 38 // Are we done with vm version initialization 39 static bool _is_initialized; 40 41 public: 42 static void initialize(); is_initialized()43 static bool is_initialized() { return _is_initialized; } 44 45 46 protected: 47 enum Feature_Flag { 48 vfp = 0, 49 vfp3_32 = 1, 50 simd = 2, 51 mp_ext = 3 52 }; 53 54 enum Feature_Flag_Set { 55 unknown_m = 0, 56 all_features_m = -1, 57 58 vfp_m = 1 << vfp, 59 vfp3_32_m = 1 << vfp3_32, 60 simd_m = 1 << simd, 61 mp_ext_m = 1 << mp_ext 62 }; 63 64 // The value stored by "STR PC, [addr]" instruction can be either 65 // (address of this instruction + 8) or (address of this instruction + 12) 66 // depending on hardware implementation. 67 // This adjustment is calculated in runtime. 68 static int _stored_pc_adjustment; 69 70 // ARM architecture version: 5 = ARMv5, 6 = ARMv6, 7 = ARMv7 etc. 71 static int _arm_arch; 72 73 // linux kernel atomic helper function version info 74 // __kuser_cmpxchg() if version >= 2 75 // __kuser_cmpxchg64() if version >= 5 76 static int _kuser_helper_version; 77 78 #define KUSER_HELPER_VERSION_ADDR 0xffff0ffc 79 #define KUSER_VERSION_CMPXCHG32 2 80 #define KUSER_VERSION_CMPXCHG64 5 81 82 // Read additional info using OS-specific interfaces 83 static void get_os_cpu_info(); 84 85 public: 86 static void early_initialize(); 87 arm_arch()88 static int arm_arch() { return _arm_arch; } stored_pc_adjustment()89 static int stored_pc_adjustment() { return _stored_pc_adjustment; } supports_rev()90 static bool supports_rev() { return _arm_arch >= 6; } supports_ldrex()91 static bool supports_ldrex() { return _arm_arch >= 6; } supports_movw()92 static bool supports_movw() { return _arm_arch >= 7; } supports_ldrexd()93 static bool supports_ldrexd() { return _arm_arch >= 7; } supports_compare_and_exchange()94 static bool supports_compare_and_exchange() { return true; } supports_kuser_cmpxchg32()95 static bool supports_kuser_cmpxchg32() { return _kuser_helper_version >= KUSER_VERSION_CMPXCHG32; } supports_kuser_cmpxchg64()96 static bool supports_kuser_cmpxchg64() { return _kuser_helper_version >= KUSER_VERSION_CMPXCHG64; } 97 // Override Abstract_VM_Version implementation 98 static bool use_biased_locking(); 99 has_vfp()100 static bool has_vfp() { return (_features & vfp_m) != 0; } has_vfp3_32()101 static bool has_vfp3_32() { return (_features & vfp3_32_m) != 0; } has_simd()102 static bool has_simd() { return (_features & simd_m) != 0; } has_multiprocessing_extensions()103 static bool has_multiprocessing_extensions() { return (_features & mp_ext_m) != 0; } 104 simd_math_is_compliant()105 static bool simd_math_is_compliant() { return false; } 106 prefer_moves_over_load_literal()107 static bool prefer_moves_over_load_literal() { return supports_movw(); } 108 109 friend class VM_Version_StubGenerator; 110 111 }; 112 113 #endif // CPU_ARM_VM_VERSION_ARM_HPP 114