rsc.io/go@v0.0.0-20150416155037-e040fd465409/src/runtime/os_linux_arm.go (about) 1 // Copyright 2009 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 package runtime 6 7 import "unsafe" 8 9 const ( 10 _AT_NULL = 0 11 _AT_PLATFORM = 15 // introduced in at least 2.6.11 12 _AT_HWCAP = 16 // introduced in at least 2.6.11 13 _AT_RANDOM = 25 // introduced in 2.6.29 14 15 _HWCAP_VFP = 1 << 6 // introduced in at least 2.6.11 16 _HWCAP_VFPv3 = 1 << 13 // introduced in 2.6.30 17 ) 18 19 var randomNumber uint32 20 var armArch uint8 = 6 // we default to ARMv6 21 var hwcap uint32 // set by setup_auxv 22 var goarm uint8 // set by 5l 23 24 func checkgoarm() { 25 if goarm > 5 && hwcap&_HWCAP_VFP == 0 { 26 print("runtime: this CPU has no floating point hardware, so it cannot run\n") 27 print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n") 28 exit(1) 29 } 30 if goarm > 6 && hwcap&_HWCAP_VFPv3 == 0 { 31 print("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n") 32 print("this GOARM=", goarm, " binary. Recompile using GOARM=5.\n") 33 exit(1) 34 } 35 } 36 37 func sysargs(argc int32, argv **byte) { 38 // skip over argv, envv to get to auxv 39 n := argc + 1 40 for argv_index(argv, n) != nil { 41 n++ 42 } 43 n++ 44 auxv := (*[1 << 28]uint32)(add(unsafe.Pointer(argv), uintptr(n)*ptrSize)) 45 46 for i := 0; auxv[i] != _AT_NULL; i += 2 { 47 switch auxv[i] { 48 case _AT_RANDOM: // kernel provides a pointer to 16-bytes worth of random data 49 startupRandomData = (*[16]byte)(unsafe.Pointer(uintptr(auxv[i+1])))[:] 50 // the pointer provided may not be word alined, so we must to treat it 51 // as a byte array. 52 randomNumber = uint32(startupRandomData[4]) | uint32(startupRandomData[5])<<8 | 53 uint32(startupRandomData[6])<<16 | uint32(startupRandomData[7])<<24 54 55 case _AT_PLATFORM: // v5l, v6l, v7l 56 t := *(*uint8)(unsafe.Pointer(uintptr(auxv[i+1] + 1))) 57 if '5' <= t && t <= '7' { 58 armArch = t - '0' 59 } 60 61 case _AT_HWCAP: // CPU capability bit flags 62 hwcap = auxv[i+1] 63 } 64 } 65 } 66 67 //go:nosplit 68 func cputicks() int64 { 69 // Currently cputicks() is used in blocking profiler and to seed fastrand1(). 70 // nanotime() is a poor approximation of CPU ticks that is enough for the profiler. 71 // randomNumber provides better seeding of fastrand1. 72 return nanotime() + int64(randomNumber) 73 }