1
2
3
4
5 package cpu
6
7
8
9
10 const CacheLinePadSize = 128
11
12 func doinit() {
13 options = []option{
14 {Name: "aes", Feature: &ARM64.HasAES},
15 {Name: "pmull", Feature: &ARM64.HasPMULL},
16 {Name: "sha1", Feature: &ARM64.HasSHA1},
17 {Name: "sha2", Feature: &ARM64.HasSHA2},
18 {Name: "sha512", Feature: &ARM64.HasSHA512},
19 {Name: "crc32", Feature: &ARM64.HasCRC32},
20 {Name: "atomics", Feature: &ARM64.HasATOMICS},
21 {Name: "cpuid", Feature: &ARM64.HasCPUID},
22 {Name: "isNeoverse", Feature: &ARM64.IsNeoverse},
23 }
24
25
26 osInit()
27 }
28
29 func getisar0() uint64
30
31 func getpfr0() uint64
32
33 func getMIDR() uint64
34
35 func extractBits(data uint64, start, end uint) uint {
36 return (uint)(data>>start) & ((1 << (end - start + 1)) - 1)
37 }
38
39 func parseARM64SystemRegisters(isar0, pfr0 uint64) {
40
41 switch extractBits(isar0, 4, 7) {
42 case 1:
43 ARM64.HasAES = true
44 case 2:
45 ARM64.HasAES = true
46 ARM64.HasPMULL = true
47 }
48
49 switch extractBits(isar0, 8, 11) {
50 case 1:
51 ARM64.HasSHA1 = true
52 }
53
54 switch extractBits(isar0, 12, 15) {
55 case 1:
56 ARM64.HasSHA2 = true
57 case 2:
58 ARM64.HasSHA2 = true
59 ARM64.HasSHA512 = true
60 }
61
62 switch extractBits(isar0, 16, 19) {
63 case 1:
64 ARM64.HasCRC32 = true
65 }
66
67 switch extractBits(isar0, 20, 23) {
68 case 2:
69 ARM64.HasATOMICS = true
70 }
71
72 switch extractBits(pfr0, 48, 51) {
73 case 1:
74 ARM64.HasDIT = true
75 }
76 }
77
View as plain text