-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtesting_tamago.go
55 lines (42 loc) · 1.16 KB
/
testing_tamago.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build tamago && (amd64 || arm || riscv64)
package testing
import (
"runtime"
_ "unsafe"
)
//go:linkname ramStart runtime.ramStart
var ramStart uint64 = 0x80000000
//go:linkname ramSize runtime.ramSize
var ramSize uint64 = 0x20000000 // 512MB
//go:linkname ramStackOffset runtime.ramStackOffset
var ramStackOffset uint64 = 0x100
// defined in testing_tamago_*.s
func sys_exit(code int32)
func sys_write(c *byte)
func sys_clock_gettime() (ns int64)
func sys_getrandom(b []byte, n int)
//go:linkname nanotime1 runtime.nanotime1
func nanotime1() int64 {
return sys_clock_gettime()
}
//go:linkname initRNG runtime.initRNG
func initRNG() {}
//go:linkname getRandomData runtime.getRandomData
func getRandomData(b []byte) {
sys_getrandom(b, len(b))
}
// preallocated memory to avoid malloc during panic
var a [1]byte
//go:linkname printk runtime.printk
func printk(c byte) {
a[0] = c
sys_write(&a[0])
}
//go:linkname hwinit runtime.hwinit
func hwinit() {
runtime.Bloc = uintptr(ramStart)
runtime.Exit = sys_exit
}