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