Black Lives Matter. Support the Equal Justice Initiative.

Source file src/internal/cpu/cpu_arm64_freebsd.go

Documentation: internal/cpu

     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  // +build arm64
     7  
     8  package cpu
     9  
    10  func osInit() {
    11  	// Retrieve info from system register ID_AA64ISAR0_EL1.
    12  	isar0 := getisar0()
    13  
    14  	// ID_AA64ISAR0_EL1
    15  	switch extractBits(isar0, 4, 7) {
    16  	case 1:
    17  		ARM64.HasAES = true
    18  	case 2:
    19  		ARM64.HasAES = true
    20  		ARM64.HasPMULL = true
    21  	}
    22  
    23  	switch extractBits(isar0, 8, 11) {
    24  	case 1:
    25  		ARM64.HasSHA1 = true
    26  	}
    27  
    28  	switch extractBits(isar0, 12, 15) {
    29  	case 1, 2:
    30  		ARM64.HasSHA2 = true
    31  	}
    32  
    33  	switch extractBits(isar0, 16, 19) {
    34  	case 1:
    35  		ARM64.HasCRC32 = true
    36  	}
    37  
    38  	switch extractBits(isar0, 20, 23) {
    39  	case 2:
    40  		ARM64.HasATOMICS = true
    41  	}
    42  }
    43  
    44  func extractBits(data uint64, start, end uint) uint {
    45  	return (uint)(data>>start) & ((1 << (end - start + 1)) - 1)
    46  }
    47  

View as plain text