github.com/elijahmorg/goternal@v1.18.0/cpu/cpu_arm64_freebsd.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build arm64 6 7 package cpu 8 9 func osInit() { 10 // Retrieve info from system register ID_AA64ISAR0_EL1. 11 isar0 := getisar0() 12 13 // ID_AA64ISAR0_EL1 14 switch extractBits(isar0, 4, 7) { 15 case 1: 16 ARM64.HasAES = true 17 case 2: 18 ARM64.HasAES = true 19 ARM64.HasPMULL = true 20 } 21 22 switch extractBits(isar0, 8, 11) { 23 case 1: 24 ARM64.HasSHA1 = true 25 } 26 27 switch extractBits(isar0, 12, 15) { 28 case 1, 2: 29 ARM64.HasSHA2 = true 30 } 31 32 switch extractBits(isar0, 16, 19) { 33 case 1: 34 ARM64.HasCRC32 = true 35 } 36 37 switch extractBits(isar0, 20, 23) { 38 case 2: 39 ARM64.HasATOMICS = true 40 } 41 } 42 43 func extractBits(data uint64, start, end uint) uint { 44 return (uint)(data>>start) & ((1 << (end - start + 1)) - 1) 45 }