cpu_linux_ppc64x.go

 1// Copyright 2018 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 linux && (ppc64 || ppc64le)
 6
 7package cpu
 8
 9// HWCAP/HWCAP2 bits. These are exposed by the kernel.
10const (
11	// ISA Level
12	_PPC_FEATURE2_ARCH_2_07 = 0x80000000
13	_PPC_FEATURE2_ARCH_3_00 = 0x00800000
14
15	// CPU features
16	_PPC_FEATURE2_DARN = 0x00200000
17	_PPC_FEATURE2_SCV  = 0x00100000
18)
19
20func doinit() {
21	// HWCAP2 feature bits
22	PPC64.IsPOWER8 = isSet(hwCap2, _PPC_FEATURE2_ARCH_2_07)
23	PPC64.IsPOWER9 = isSet(hwCap2, _PPC_FEATURE2_ARCH_3_00)
24	PPC64.HasDARN = isSet(hwCap2, _PPC_FEATURE2_DARN)
25	PPC64.HasSCV = isSet(hwCap2, _PPC_FEATURE2_SCV)
26}
27
28func isSet(hwc uint, value uint) bool {
29	return hwc&value != 0
30}