Source file src/internal/cpu/cpu_arm64_openbsd.go

     1  // Copyright 2022 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  const (
    10  	// From OpenBSD's sys/sysctl.h.
    11  	_CTL_MACHDEP = 7
    12  
    13  	// From OpenBSD's machine/cpu.h.
    14  	_CPU_ID_AA64ISAR0 = 2
    15  	_CPU_ID_AA64ISAR1 = 3
    16  	_CPU_ID_AA64PFR0  = 8
    17  )
    18  
    19  //go:noescape
    20  func sysctlUint64(mib []uint32) (uint64, bool)
    21  
    22  func osInit() {
    23  	// Get ID_AA64ISAR0 from sysctl.
    24  	isar0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64ISAR0})
    25  	if !ok {
    26  		return
    27  	}
    28  	// Get ID_AA64PFR0 from sysctl.
    29  	pfr0, ok := sysctlUint64([]uint32{_CTL_MACHDEP, _CPU_ID_AA64PFR0})
    30  	if !ok {
    31  		return
    32  	}
    33  
    34  	parseARM64SystemRegisters(isar0, pfr0)
    35  }
    36  

View as plain text