2015-03-08 07:20:20 -06:00
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2017-11-07 19:17:51 -07:00
|
|
|
// +build arm64
|
|
|
|
|
2015-03-08 07:20:20 -06:00
|
|
|
package runtime
|
|
|
|
|
2017-11-07 19:17:51 -07:00
|
|
|
// For go:linkname
|
|
|
|
import _ "unsafe"
|
2017-03-16 21:31:09 -06:00
|
|
|
|
2015-03-08 07:20:20 -06:00
|
|
|
var randomNumber uint32
|
2017-11-07 19:17:51 -07:00
|
|
|
|
|
|
|
// arm64 doesn't have a 'cpuid' instruction equivalent and relies on
|
|
|
|
// HWCAP/HWCAP2 bits for hardware capabilities.
|
|
|
|
|
2018-02-04 12:57:56 -07:00
|
|
|
//go:linkname cpu_hwcap internal/cpu.hwcap
|
2017-11-07 19:17:51 -07:00
|
|
|
var cpu_hwcap uint
|
2018-04-03 23:15:22 -06:00
|
|
|
|
2018-02-04 12:57:56 -07:00
|
|
|
//go:linkname cpu_hwcap2 internal/cpu.hwcap2
|
2017-11-07 19:17:51 -07:00
|
|
|
var cpu_hwcap2 uint
|
2015-03-08 07:20:20 -06:00
|
|
|
|
2016-04-14 10:12:45 -06:00
|
|
|
func archauxv(tag, val uintptr) {
|
|
|
|
switch tag {
|
2016-04-14 10:32:28 -06:00
|
|
|
case _AT_RANDOM:
|
|
|
|
// sysargs filled in startupRandomData, but that
|
|
|
|
// pointer may not be word aligned, so we must treat
|
|
|
|
// it as a byte array.
|
2016-04-14 10:12:45 -06:00
|
|
|
randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 |
|
|
|
|
uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24
|
2017-04-24 03:37:17 -06:00
|
|
|
case _AT_HWCAP:
|
2017-11-07 19:17:51 -07:00
|
|
|
cpu_hwcap = uint(val)
|
|
|
|
case _AT_HWCAP2:
|
|
|
|
cpu_hwcap2 = uint(val)
|
2016-04-05 21:09:39 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-15 03:11:47 -06:00
|
|
|
//go:nosplit
|
2015-03-08 07:20:20 -06:00
|
|
|
func cputicks() int64 {
|
2016-06-28 10:22:46 -06:00
|
|
|
// Currently cputicks() is used in blocking profiler and to seed fastrand().
|
2015-03-08 07:20:20 -06:00
|
|
|
// nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
|
2016-06-28 10:22:46 -06:00
|
|
|
// randomNumber provides better seeding of fastrand.
|
2015-03-08 07:20:20 -06:00
|
|
|
return nanotime() + int64(randomNumber)
|
|
|
|
}
|