From 5f2b1391747dfc7eea7e2a5c1f2400334e501797 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 9 Sep 2017 00:42:10 -0400 Subject: [PATCH 1/2] Fixed crt0 issues which triggered crashes. --- crt0/switch_crt0.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crt0/switch_crt0.s b/crt0/switch_crt0.s index b8f04ac3..55b790d3 100644 --- a/crt0/switch_crt0.s +++ b/crt0/switch_crt0.s @@ -34,10 +34,9 @@ bss_loop: add x0, x0, x30 // relocate ptr got_loop: - ldr x2, [x0] - ldr x3, [x2] + ldr x3, [x0] add x3, x3, x30 - str x3, [x2] + str x3, [x0], #8 subs x1, x1, #8 bne got_loop @@ -45,6 +44,7 @@ got_loop: mov x1, #0 // argv ldr x3, =main + add x3, x3, x30 blr x3 _sysexit: From 346324cc5b045ae9c96fbc8e8003c09858260776 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sat, 9 Sep 2017 01:29:50 -0400 Subject: [PATCH 2/2] Added svcCloseHandle, svcWaitSynchronization, and svcAcceptSession. --- nx/include/switch/svc.h | 3 +++ nx/source/svc.s | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/nx/include/switch/svc.h b/nx/include/switch/svc.h index 40883af7..5c110975 100644 --- a/nx/include/switch/svc.h +++ b/nx/include/switch/svc.h @@ -18,8 +18,11 @@ static inline void* armGetTls(void) { return ret; } +Result svcCloseHandle(Handle handle); +Result svcWaitSynchronization(s32* index, const Handle* handles, s32 handleCount, u64 timeout); Result svcConnectToNamedPort(Handle* session, const char* name); Result svcBreak(u32 BreakReason, u64 inval1, u64 inval2); +Result svcAcceptSession(Handle *session_handle, Handle port_handle); Result svcReplyAndReceive(s32* index, const Handle* handles, s32 handleCount, Handle replyTarget, u64 timeout); Result svcManageNamedPort(Handle* portServer, const char* name, s32 maxSessions); diff --git a/nx/source/svc.s b/nx/source/svc.s index 510e277e..784953bf 100644 --- a/nx/source/svc.s +++ b/nx/source/svc.s @@ -11,6 +11,19 @@ .cfi_endproc .endm +SVC_BEGIN svcCloseHandle + svc 0x16 + ret +SVC_END + +SVC_BEGIN svcWaitSynchronization + str x0, [sp, #-16]! + svc 0x18 + ldr x2, [sp], #16 + str w1, [x2] + ret +SVC_END + SVC_BEGIN svcConnectToNamedPort str x0, [sp, #-16]! svc 0x1f @@ -24,6 +37,14 @@ SVC_BEGIN svcBreak ret SVC_END +SVC_BEGIN svcAcceptSession + str x0, [sp, #-16]! + svc 0x41 + ldr x2, [sp], #16 + str w1, [x2] + ret +SVC_END + SVC_BEGIN svcReplyAndReceive str x0, [sp, #-16]! svc 0x43