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 |
|||
.global armGetSystemTick |
|||
.type armGetSystemTick, %function |
|||
// Macro for writing less code |
|||
.macro FUNC name |
|||
.section .text.\name, "ax", %progbits |
|||
.global \name |
|||
.type \name, %function |
|||
.align 2 |
|||
armGetSystemTick: |
|||
mrs x0, cntpct_el0 |
|||
ret |
|||
|
|||
.section .text.nxOutputString, "ax", %progbits |
|||
.global nxOutputString |
|||
.type nxOutputString, %function |
|||
.align 2 |
|||
.cfi_startproc |
|||
nxOutputString: |
|||
svc 0x27 |
|||
ret |
|||
.cfi_endproc |
|||
\name: |
|||
.endm |
|||
|
|||
.section .text.exit, "ax", %progbits |
|||
.global exit |
|||
.type exit, %function |
|||
.align 2 |
|||
exit: |
|||
svc 0x7 |
|||
FUNC armGetSystemTick |
|||
mrs x0, cntpct_el0 |
|||
ret |
|||
|
|||
.section .text.setHeapSize, "ax", %progbits |
|||
.global setHeapSize |
|||
.type setHeapSize, %function |
|||
.align 2 |
|||
setHeapSize: |
|||
// Horizon System Calls |
|||
// https://switchbrew.org/wiki/SVC |
|||
FUNC svcSetHeapSize |
|||
str x0, [sp, #-16]! |
|||
svc 0x1 |
|||
ldr x2, [sp], #16 |
|||
str x1, [x2] |
|||
ret |
|||
|
|||
FUNC svcExitProcess |
|||
svc 0x7 |
|||
ret |
|||
|
|||
.section .text.sleepThread, "ax", %progbits |
|||
.global sleepThread |
|||
.type sleepThread, %function |
|||
.align 2 |
|||
sleepThread: |
|||
FUNC svcSleepThread |
|||
svc 0xB |
|||
ret |
|||
|
|||
FUNC svcOutputDebugString |
|||
svc 0x27 |
|||
ret |
|||
|
|||
FUNC svcGetInfo |
|||
str x0, [sp, #-16]! |
|||
svc 0x29 |
|||
ldr x2, [sp], #16 |
|||
str x1, [x2] |
|||
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