all: move generic ARM bits into separate files
Этот коммит содержится в:
		
							родитель
							
								
									895d109fc4
								
							
						
					
					
						коммит
						12298d23a7
					
				
					 5 изменённых файлов: 67 добавлений и 58 удалений
				
			
		
							
								
								
									
										55
									
								
								src/runtime/runtime_arm.go
									
										
									
									
									
										Обычный файл
									
								
							
							
						
						
									
										55
									
								
								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
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,6 @@ package runtime
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"device/arm"
 | 
						"device/arm"
 | 
				
			||||||
	"device/nrf"
 | 
						"device/nrf"
 | 
				
			||||||
	"unsafe"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type timeUnit int64
 | 
					type timeUnit int64
 | 
				
			||||||
| 
						 | 
					@ -21,42 +20,6 @@ func handleReset() {
 | 
				
			||||||
	main()
 | 
						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() {
 | 
					func init() {
 | 
				
			||||||
	initUART()
 | 
						initUART()
 | 
				
			||||||
	initLFCLK()
 | 
						initLFCLK()
 | 
				
			||||||
| 
						 | 
					@ -118,17 +81,6 @@ func ticks() timeUnit {
 | 
				
			||||||
	return timestamp
 | 
						return timestamp
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func abort() {
 | 
					 | 
				
			||||||
	for {
 | 
					 | 
				
			||||||
		arm.Asm("wfi")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Align on word boundary.
 | 
					 | 
				
			||||||
func align(ptr uintptr) uintptr {
 | 
					 | 
				
			||||||
	return (ptr + 3) &^ 3
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
type __volatile bool
 | 
					type __volatile bool
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var rtc_wakeup __volatile
 | 
					var rtc_wakeup __volatile
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 */
 | 
					/* define output sections */
 | 
				
			||||||
SECTIONS
 | 
					SECTIONS
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										10
									
								
								targets/nrf52.ld
									
										
									
									
									
										Обычный файл
									
								
							
							
						
						
									
										10
									
								
								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"
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	"llvm-target": "armv7em-none-eabi",
 | 
						"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",
 | 
						"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",
 | 
						"objcopy": "arm-none-eabi-objcopy",
 | 
				
			||||||
	"flash": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset"
 | 
						"flash": "nrfjprog -f nrf52 --sectorerase --program {hex} --reset"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче