...
Source file
src/internal/cpu/cpu_arm64_hwcap.go
1
2
3
4
5
6
7 package cpu
8
9
10
11 var HWCap uint
12
13
14 const (
15 hwcap_AES = 1 << 3
16 hwcap_PMULL = 1 << 4
17 hwcap_SHA1 = 1 << 5
18 hwcap_SHA2 = 1 << 6
19 hwcap_CRC32 = 1 << 7
20 hwcap_ATOMICS = 1 << 8
21 hwcap_CPUID = 1 << 11
22 hwcap_SHA512 = 1 << 21
23 )
24
25 func hwcapInit(os string) {
26
27
28
29 ARM64.HasAES = isSet(HWCap, hwcap_AES)
30 ARM64.HasPMULL = isSet(HWCap, hwcap_PMULL)
31 ARM64.HasSHA1 = isSet(HWCap, hwcap_SHA1)
32 ARM64.HasSHA2 = isSet(HWCap, hwcap_SHA2)
33 ARM64.HasCRC32 = isSet(HWCap, hwcap_CRC32)
34 ARM64.HasCPUID = isSet(HWCap, hwcap_CPUID)
35 ARM64.HasSHA512 = isSet(HWCap, hwcap_SHA512)
36
37
38
39
40 ARM64.HasATOMICS = isSet(HWCap, hwcap_ATOMICS) && os != "android"
41
42
43
44
45
46
47
48 if ARM64.HasCPUID {
49 midr := getMIDR()
50 part_num := uint16((midr >> 4) & 0xfff)
51 implementor := byte((midr >> 24) & 0xff)
52
53
54
55
56
57 if implementor == 'A' && (part_num == 0xd0c || part_num == 0xd40 ||
58 part_num == 0xd49 || part_num == 0xd4f) {
59 ARM64.IsNeoverse = true
60 }
61 }
62 }
63
64 func isSet(hwc uint, value uint) bool {
65 return hwc&value != 0
66 }
67
View as plain text