mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
all: pretend to be linux/arm in baremetal targets
So far, we've pretended to be js/wasm in baremetal targets to make the
stdlib happy. Unfortunately, this has various problems because
syscall/js (a dependency of many stdlib packages) thinks it can do JS
calls, and emulating them gets quite hard with all changes to the
syscall/js packages in Go 1.12.
This commit does a few things:
* It lets baremetal targets pretend to be linux/arm instead of
js/wasm.
* It lets the loader only select particular packages from the src
overlay, instead of inserting them just before GOROOT. This makes it
possible to pick which packages to overlay for a given target.
* It adds a baremetal-only syscall package that stubs out almost all
syscalls.
This commit is contained in:
committed by
Ron Evans
parent
792274e86f
commit
a2d0f79be3
@@ -0,0 +1,46 @@
|
||||
// +build cortexm
|
||||
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"device/arm"
|
||||
)
|
||||
|
||||
const GOARCH = "arm"
|
||||
|
||||
// The bitness of the CPU (e.g. 8, 32, 64).
|
||||
const TargetBits = 32
|
||||
|
||||
//go:extern _heap_start
|
||||
var heapStartSymbol unsafe.Pointer
|
||||
|
||||
//go:extern _heap_end
|
||||
var heapEndSymbol unsafe.Pointer
|
||||
|
||||
//go:extern _globals_start
|
||||
var globalsStartSymbol unsafe.Pointer
|
||||
|
||||
//go:extern _globals_end
|
||||
var globalsEndSymbol unsafe.Pointer
|
||||
|
||||
//go:extern _stack_top
|
||||
var stackTopSymbol unsafe.Pointer
|
||||
|
||||
var (
|
||||
heapStart = uintptr(unsafe.Pointer(&heapStartSymbol))
|
||||
heapEnd = uintptr(unsafe.Pointer(&heapEndSymbol))
|
||||
globalsStart = uintptr(unsafe.Pointer(&globalsStartSymbol))
|
||||
globalsEnd = uintptr(unsafe.Pointer(&globalsEndSymbol))
|
||||
stackTop = uintptr(unsafe.Pointer(&stackTopSymbol))
|
||||
)
|
||||
|
||||
// Align on word boundary.
|
||||
func align(ptr uintptr) uintptr {
|
||||
return (ptr + 3) &^ 3
|
||||
}
|
||||
|
||||
func getCurrentStackPointer() uintptr {
|
||||
return arm.ReadRegister("sp")
|
||||
}
|
||||
Reference in New Issue
Block a user