aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-09-22 01:44:47 +0200
committerAyke van Laethem <[email protected]>2018-09-22 01:44:47 +0200
commit12298d23a776e2e8051e5b8f63591e7e5c9864c3 (patch)
tree7c7cb393d86f7953d9788da8d6b2de5c7d99d24b
parent895d109fc476360be1231d813c233ba01e5a6837 (diff)
downloadtinygo-12298d23a776e2e8051e5b8f63591e7e5c9864c3.tar.gz
tinygo-12298d23a776e2e8051e5b8f63591e7e5c9864c3.zip
all: move generic ARM bits into separate files
-rw-r--r--src/runtime/runtime_arm.go55
-rw-r--r--src/runtime/runtime_nrf.go48
-rw-r--r--targets/arm.ld8
-rw-r--r--targets/nrf52.ld10
-rw-r--r--targets/pca10040.json4
5 files changed, 67 insertions, 58 deletions
diff --git a/src/runtime/runtime_arm.go b/src/runtime/runtime_arm.go
new file mode 100644
index 000000000..1bc1a0563
--- /dev/null
+++ b/src/runtime/runtime_arm.go
@@ -0,0 +1,55 @@
+/// +build arm
+
+package runtime
+
+import (
+ "device/arm"
+ "unsafe"
+)
+
+//go:extern _sbss
+var _sbss unsafe.Pointer
+
+//go:extern _ebss
+var _ebss unsafe.Pointer
+
+//go:extern _sdata
+var _sdata unsafe.Pointer
+
+//go:extern _sidata
+var _sidata unsafe.Pointer
+
+//go:extern _edata
+var _edata unsafe.Pointer
+
+func preinit() {
+ // Initialize .bss: zero-initialized global variables.
+ ptr := uintptr(unsafe.Pointer(&_sbss))
+ for ptr != uintptr(unsafe.Pointer(&_ebss)) {
+ *(*uint32)(unsafe.Pointer(ptr)) = 0
+ ptr += 4
+ }
+
+ // Initialize .data: global variables initialized from flash.
+ src := uintptr(unsafe.Pointer(&_sidata))
+ dst := uintptr(unsafe.Pointer(&_sdata))
+ for dst != uintptr(unsafe.Pointer(&_edata)) {
+ *(*uint32)(unsafe.Pointer(dst)) = *(*uint32)(unsafe.Pointer(src))
+ dst += 4
+ src += 4
+ }
+}
+
+func postinit() {
+}
+
+func abort() {
+ for {
+ arm.Asm("wfi")
+ }
+}
+
+// Align on word boundary.
+func align(ptr uintptr) uintptr {
+ return (ptr + 3) &^ 3
+}
diff --git a/src/runtime/runtime_nrf.go b/src/runtime/runtime_nrf.go
index bca187e8f..eb1e5e49d 100644
--- a/src/runtime/runtime_nrf.go
+++ b/src/runtime/runtime_nrf.go
@@ -5,7 +5,6 @@ package runtime
import (
"device/arm"
"device/nrf"
- "unsafe"
)
type timeUnit int64
@@ -21,42 +20,6 @@ func handleReset() {
main()
}
-//go:extern _sbss
-var _sbss unsafe.Pointer
-
-//go:extern _ebss
-var _ebss unsafe.Pointer
-
-//go:extern _sdata
-var _sdata unsafe.Pointer
-
-//go:extern _sidata
-var _sidata unsafe.Pointer
-
-//go:extern _edata
-var _edata unsafe.Pointer
-
-func preinit() {
- // Initialize .bss: zero-initialized global variables.
- ptr := uintptr(unsafe.Pointer(&_sbss))
- for ptr != uintptr(unsafe.Pointer(&_ebss)) {
- *(*uint32)(unsafe.Pointer(ptr)) = 0
- ptr += 4
- }
-
- // Initialize .data: global variables initialized from flash.
- src := uintptr(unsafe.Pointer(&_sidata))
- dst := uintptr(unsafe.Pointer(&_sdata))
- for dst != uintptr(unsafe.Pointer(&_edata)) {
- *(*uint32)(unsafe.Pointer(dst)) = *(*uint32)(unsafe.Pointer(src))
- dst += 4
- src += 4
- }
-}
-
-func postinit() {
-}
-
func init() {
initUART()
initLFCLK()
@@ -118,17 +81,6 @@ func ticks() timeUnit {
return timestamp
}
-func abort() {
- for {
- arm.Asm("wfi")
- }
-}
-
-// Align on word boundary.
-func align(ptr uintptr) uintptr {
- return (ptr + 3) &^ 3
-}
-
type __volatile bool
var rtc_wakeup __volatile
diff --git a/targets/arm.ld b/targets/arm.ld
index e5df36013..1cf417831 100644
--- a/targets/arm.ld
+++ b/targets/arm.ld
@@ -1,12 +1,4 @@
-MEMORY
-{
- FLASH_TEXT (rw) : ORIGIN = 0x00000000, LENGTH = 256K /* .text */
- RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
-}
-
-_stack_size = 2K;
-
/* define output sections */
SECTIONS
{
diff --git a/targets/nrf52.ld b/targets/nrf52.ld
new file mode 100644
index 000000000..a388cf7e4
--- /dev/null
+++ b/targets/nrf52.ld
@@ -0,0 +1,10 @@
+
+MEMORY
+{
+ FLASH_TEXT (rw) : ORIGIN = 0x00000000, LENGTH = 256K /* .text */
+ RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
+}
+
+_stack_size = 2K;
+
+INCLUDE "targets/arm.ld"
diff --git a/targets/pca10040.json b/targets/pca10040.json
index 17d03769e..48f800bd3 100644
--- a/targets/pca10040.json
+++ b/targets/pca10040.json
@@ -1,8 +1,8 @@
{
"llvm-target": "armv7em-none-eabi",
- "build-tags": ["nrf", "nrf52", "nrf52832", "js", "wasm"],
+ "build-tags": ["nrf", "nrf52", "nrf52832", "arm", "js", "wasm"],
"linker": "arm-none-eabi-gcc",
- "pre-link-args": ["-nostdlib", "-nostartfiles", "-mcpu=cortex-m4", "-mthumb", "-T", "targets/arm.ld", "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", "-Os", "-DNRF52832_XXAA", "-Ilib/CMSIS/CMSIS/Include", "lib/nrfx/mdk/system_nrf52.c", "src/device/nrf/nrf52.s"],
+ "pre-link-args": ["-nostdlib", "-nostartfiles", "-mcpu=cortex-m4", "-mthumb", "-T", "targets/nrf52.ld", "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", "-Os", "-DNRF52832_XXAA", "-Ilib/CMSIS/CMSIS/Include", "lib/nrfx/mdk/system_nrf52.c", "src/device/nrf/nrf52.s"],
"objcopy": "arm-none-eabi-objcopy",
"flash": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset"
}