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