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.
6
#include "defs_GOOS_GOARCH.h"
10
#define AT_PLATFORM 15 // introduced in at least 2.6.11
11
#define AT_HWCAP 16 // introduced in at least 2.6.11
12
#define AT_RANDOM 25 // introduced in 2.6.29
13
#define HWCAP_VFP (1 << 6) // introduced in at least 2.6.11
14
#define HWCAP_VFPv3 (1 << 13) // introduced in 2.6.30
15
static uint32 runtime·randomNumber;
16
uint8 runtime·armArch = 6; // we default to ARMv6
17
uint32 runtime·hwcap; // set by setup_auxv
18
uint8 runtime·goarm; // set by 5l
21
runtime·checkgoarm(void)
23
if(runtime·goarm > 5 && !(runtime·hwcap & HWCAP_VFP)) {
24
runtime·printf("runtime: this CPU has no floating point hardware, so it cannot run\n");
25
runtime·printf("this GOARM=%d binary. Recompile using GOARM=5.\n", runtime·goarm);
28
if(runtime·goarm > 6 && !(runtime·hwcap & HWCAP_VFPv3)) {
29
runtime·printf("runtime: this CPU has no VFPv3 floating point hardware, so it cannot run\n");
30
runtime·printf("this GOARM=%d binary. Recompile using GOARM=6.\n", runtime·goarm);
37
runtime·setup_auxv(int32 argc, void *argv_list)
47
// skip envp to get to ELF auxiliary vector.
48
for(envp = &argv[argc+1]; *envp != nil; envp++)
52
for(auxv=(uint32*)envp; auxv[0] != AT_NULL; auxv += 2) {
54
case AT_RANDOM: // kernel provided 16-byte worth of random data
57
runtime·randomNumber = rnd[4] | rnd[5]<<8 | rnd[6]<<16 | rnd[7]<<24;
60
case AT_PLATFORM: // v5l, v6l, v7l
62
t = *(uint8*)(auxv[1]+1);
63
if(t >= '5' && t <= '7')
64
runtime·armArch = t - '0';
67
case AT_HWCAP: // CPU capability bit flags
68
runtime·hwcap = auxv[1];
76
runtime·cputicks(void)
78
// Currently cputicks() is used in blocking profiler and to seed runtime·fastrand1().
79
// runtime·nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
80
// runtime·randomNumber provides better seeding of fastrand1.
81
return runtime·nanotime() + runtime·randomNumber;