mirror of https://github.com/tinygo-org/tinygo.git
Browse Source
* Heap allocation based on available ram * Added homebrew launcher parser (for overriden heap) * Removed unused stuff (moved to gonx) * Kept require code at minimum to work in a real device * Moved everything to a single filepull/1480/head
Lucas Teske
4 years ago
committed by
Ayke
9 changed files with 300 additions and 122 deletions
@ -1,45 +1,40 @@ |
|||||
.section .text.armGetSystemTick, "ax", %progbits |
// Macro for writing less code |
||||
.global armGetSystemTick |
.macro FUNC name |
||||
.type armGetSystemTick, %function |
.section .text.\name, "ax", %progbits |
||||
.align 2 |
.global \name |
||||
armGetSystemTick: |
.type \name, %function |
||||
|
.align 2 |
||||
|
\name: |
||||
|
.endm |
||||
|
|
||||
|
FUNC armGetSystemTick |
||||
mrs x0, cntpct_el0 |
mrs x0, cntpct_el0 |
||||
ret |
ret |
||||
|
|
||||
.section .text.nxOutputString, "ax", %progbits |
// Horizon System Calls |
||||
.global nxOutputString |
// https://switchbrew.org/wiki/SVC |
||||
.type nxOutputString, %function |
FUNC svcSetHeapSize |
||||
.align 2 |
str x0, [sp, #-16]! |
||||
.cfi_startproc |
svc 0x1 |
||||
nxOutputString: |
ldr x2, [sp], #16 |
||||
svc 0x27 |
str x1, [x2] |
||||
ret |
ret |
||||
.cfi_endproc |
|
||||
|
|
||||
.section .text.exit, "ax", %progbits |
FUNC svcExitProcess |
||||
.global exit |
svc 0x7 |
||||
.type exit, %function |
ret |
||||
.align 2 |
|
||||
exit: |
|
||||
svc 0x7 |
|
||||
ret |
|
||||
|
|
||||
.section .text.setHeapSize, "ax", %progbits |
FUNC svcSleepThread |
||||
.global setHeapSize |
svc 0xB |
||||
.type setHeapSize, %function |
ret |
||||
.align 2 |
|
||||
setHeapSize: |
|
||||
str x0, [sp, #-16]! |
|
||||
svc 0x1 |
|
||||
ldr x2, [sp], #16 |
|
||||
str x1, [x2] |
|
||||
ret |
|
||||
|
|
||||
|
FUNC svcOutputDebugString |
||||
|
svc 0x27 |
||||
|
ret |
||||
|
|
||||
.section .text.sleepThread, "ax", %progbits |
FUNC svcGetInfo |
||||
.global sleepThread |
str x0, [sp, #-16]! |
||||
.type sleepThread, %function |
svc 0x29 |
||||
.align 2 |
ldr x2, [sp], #16 |
||||
sleepThread: |
str x1, [x2] |
||||
svc 0xB |
ret |
||||
ret |
|
||||
|
@ -1,25 +0,0 @@ |
|||||
// +build nintendoswitch
|
|
||||
|
|
||||
// +build gc.conservative gc.leaking
|
|
||||
|
|
||||
package runtime |
|
||||
|
|
||||
const heapSize = 0x2000000 * 16 // Default by libnx
|
|
||||
|
|
||||
var ( |
|
||||
heapStart = uintptr(0) |
|
||||
heapEnd = uintptr(0) |
|
||||
) |
|
||||
|
|
||||
//export setHeapSize
|
|
||||
func setHeapSize(addr *uintptr, length uint64) uint64 |
|
||||
|
|
||||
func preinit() { |
|
||||
setHeapSize(&heapStart, heapSize) |
|
||||
|
|
||||
if heapStart == 0 { |
|
||||
runtimePanic("failed to allocate heap") |
|
||||
} |
|
||||
|
|
||||
heapEnd = heapStart + heapSize |
|
||||
} |
|
@ -1,7 +0,0 @@ |
|||||
// +build nintendoswitch
|
|
||||
|
|
||||
// +build gc.none gc.extalloc
|
|
||||
|
|
||||
package runtime |
|
||||
|
|
||||
func preinit() {} |
|
@ -1,22 +0,0 @@ |
|||||
// +build nintendoswitch
|
|
||||
|
|
||||
package runtime |
|
||||
|
|
||||
import ( |
|
||||
"unsafe" |
|
||||
) |
|
||||
|
|
||||
// Result nxOutputString(const char *str, u64 size)
|
|
||||
//export nxOutputString
|
|
||||
func nxOutputString(str *uint8, size uint64) uint64 |
|
||||
|
|
||||
func NxOutputString(str string) uint64 { |
|
||||
strData := (*_string)(unsafe.Pointer(&str)) |
|
||||
return nxOutputString((*uint8)(unsafe.Pointer(strData.ptr)), uint64(strData.length)) |
|
||||
} |
|
||||
|
|
||||
//export malloc
|
|
||||
func extalloc(size uintptr) unsafe.Pointer |
|
||||
|
|
||||
//export free
|
|
||||
func extfree(ptr unsafe.Pointer) |
|
Loading…
Reference in new issue