...

Source file src/pkg/internal/cpu/cpu_ppc64x.go

     1	// Copyright 2017 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	// +build ppc64 ppc64le
     6	
     7	package cpu
     8	
     9	const CacheLinePadSize = 128
    10	
    11	// ppc64x doesn't have a 'cpuid' equivalent, so we rely on HWCAP/HWCAP2.
    12	// These are initialized by archauxv in runtime/os_linux_ppc64x.go.
    13	// These should not be changed after they are initialized.
    14	// On aix/ppc64, these values are initialized early in the runtime in runtime/os_aix.go.
    15	var HWCap uint
    16	var HWCap2 uint
    17	
    18	// HWCAP/HWCAP2 bits. These are exposed by the kernel.
    19	const (
    20		// ISA Level
    21		PPC_FEATURE2_ARCH_2_07 = 0x80000000
    22		PPC_FEATURE2_ARCH_3_00 = 0x00800000
    23	
    24		// CPU features
    25		PPC_FEATURE2_DARN = 0x00200000
    26		PPC_FEATURE2_SCV  = 0x00100000
    27	)
    28	
    29	func doinit() {
    30		options = []option{
    31			{Name: "darn", Feature: &PPC64.HasDARN},
    32			{Name: "scv", Feature: &PPC64.HasSCV},
    33			{Name: "power9", Feature: &PPC64.IsPOWER9},
    34	
    35			// These capabilities should always be enabled on ppc64 and ppc64le:
    36			{Name: "power8", Feature: &PPC64.IsPOWER8, Required: true},
    37		}
    38	
    39		// HWCAP2 feature bits
    40		PPC64.IsPOWER8 = isSet(HWCap2, PPC_FEATURE2_ARCH_2_07)
    41		PPC64.IsPOWER9 = isSet(HWCap2, PPC_FEATURE2_ARCH_3_00)
    42		PPC64.HasDARN = isSet(HWCap2, PPC_FEATURE2_DARN)
    43		PPC64.HasSCV = isSet(HWCap2, PPC_FEATURE2_SCV)
    44	}
    45	
    46	func isSet(hwc uint, value uint) bool {
    47		return hwc&value != 0
    48	}
    49	

View as plain text