github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/pkg/runtime/os_linux_arm.c (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 #include "runtime.h" 6 #include "defs_GOOS_GOARCH.h" 7 #include "os_GOOS.h" 8 #include "../../cmd/ld/textflag.h" 9 10 #define AT_NULL 0 11 #define AT_PLATFORM 15 // introduced in at least 2.6.11 12 #define AT_HWCAP 16 // introduced in at least 2.6.11 13 #define AT_RANDOM 25 // introduced in 2.6.29 14 #define HWCAP_VFP (1 << 6) // introduced in at least 2.6.11 15 #define HWCAP_VFPv3 (1 << 13) // introduced in 2.6.30 16 static uint32 runtime·randomNumber; 17 uint8 runtime·armArch = 6; // we default to ARMv6 18 uint32 runtime·hwcap; // set by setup_auxv 19 uint8 runtime·goarm; // set by 5l 20 21 void 22 runtime·checkgoarm(void) 23 { 24 if(runtime·goarm > 5 && !(runtime·hwcap & HWCAP_VFP)) { 25 runtime·printf("runtime: this CPU has no floating point hardware, so it cannot run\n"); 26 runtime·printf("this GOARM=%d binary. Recompile using GOARM=5.\n", runtime·goarm); 27 runtime·exit(1); 28 } 29 if(runtime·goarm > 6 && !(runtime·hwcap & HWCAP_VFPv3)) { 30 runtime·printf("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n"); 31 runtime·printf("this GOARM=%d binary. Recompile using GOARM=6.\n", runtime·goarm); 32 runtime·exit(1); 33 } 34 } 35 36 #pragma textflag NOSPLIT 37 void 38 runtime·setup_auxv(int32 argc, byte **argv) 39 { 40 byte **envp; 41 byte *rnd; 42 uint32 *auxv; 43 uint32 t; 44 45 // skip envp to get to ELF auxiliary vector. 46 for(envp = &argv[argc+1]; *envp != nil; envp++) 47 ; 48 envp++; 49 50 for(auxv=(uint32*)envp; auxv[0] != AT_NULL; auxv += 2) { 51 switch(auxv[0]) { 52 case AT_RANDOM: // kernel provided 16-byte worth of random data 53 if(auxv[1]) { 54 rnd = (byte*)auxv[1]; 55 runtime·randomNumber = rnd[4] | rnd[5]<<8 | rnd[6]<<16 | rnd[7]<<24; 56 } 57 break; 58 case AT_PLATFORM: // v5l, v6l, v7l 59 if(auxv[1]) { 60 t = *(uint8*)(auxv[1]+1); 61 if(t >= '5' && t <= '7') 62 runtime·armArch = t - '0'; 63 } 64 break; 65 case AT_HWCAP: // CPU capability bit flags 66 runtime·hwcap = auxv[1]; 67 break; 68 } 69 } 70 } 71 72 #pragma textflag NOSPLIT 73 int64 74 runtime·cputicks(void) 75 { 76 // Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1(). 77 // runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler. 78 // runtime·randomNumber provides better seeding of fastrand1. 79 return runtime·nanotime() + runtime·randomNumber; 80 }