// those as well. The minimum processor requirement is POWER8 (ISA 2.07).
// The struct is padded to avoid false sharing.
var PPC64 struct {
- _ CacheLinePad
- HasDARN bool // Hardware random number generator (requires kernel enablement)
- HasSCV bool // Syscall vectored (requires kernel enablement)
- IsPOWER8 bool // ISA v2.07 (POWER8)
- IsPOWER9 bool // ISA v3.00 (POWER9)
- _ CacheLinePad
+ _ CacheLinePad
+ HasDARN bool // Hardware random number generator (requires kernel enablement)
+ HasSCV bool // Syscall vectored (requires kernel enablement)
+ IsPOWER8 bool // ISA v2.07 (POWER8)
+ IsPOWER9 bool // ISA v3.00 (POWER9)
+ IsPOWER10 bool // ISA v3.1 (POWER10)
+ _ CacheLinePad
}
var S390X struct {
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build !386 && !amd64
+//go:build !386 && !amd64 && !ppc64 && !ppc64le
package cpu
func isSet(hwc uint, value uint) bool {
return hwc&value != 0
}
+
+func Name() string {
+ switch {
+ case PPC64.IsPOWER10:
+ return "POWER10"
+ case PPC64.IsPOWER9:
+ return "POWER9"
+ case PPC64.IsPOWER8:
+ return "POWER8"
+ }
+ return ""
+}
const (
// getsystemcfg constants
- _SC_IMPL = 2
- _IMPL_POWER9 = 0x20000
+ _SC_IMPL = 2
+ _IMPL_POWER8 = 0x10000
+ _IMPL_POWER9 = 0x20000
+ _IMPL_POWER10 = 0x40000
)
func osinit() {
impl := getsystemcfg(_SC_IMPL)
+ PPC64.IsPOWER8 = isSet(impl, _IMPL_POWER8)
PPC64.IsPOWER9 = isSet(impl, _IMPL_POWER9)
+ PPC64.IsPOWER10 = isSet(impl, _IMPL_POWER10)
}
// getsystemcfg is defined in runtime/os2_aix.go
// ISA Level
hwcap2_ARCH_2_07 = 0x80000000
hwcap2_ARCH_3_00 = 0x00800000
+ hwcap2_ARCH_3_1 = 0x00040000
// CPU features
hwcap2_DARN = 0x00200000
func osinit() {
PPC64.IsPOWER8 = isSet(HWCap2, hwcap2_ARCH_2_07)
PPC64.IsPOWER9 = isSet(HWCap2, hwcap2_ARCH_3_00)
+ PPC64.IsPOWER10 = isSet(HWCap2, hwcap2_ARCH_3_1)
PPC64.HasDARN = isSet(HWCap2, hwcap2_DARN)
PPC64.HasSCV = isSet(HWCap2, hwcap2_SCV)
}