Merge pull request #156 from Dazzozo/yay-svcs

svc: add a few more SVC bindings
This commit is contained in:
fincs 2015-09-05 17:45:37 +02:00
commit 2a0e9655a6
2 changed files with 112 additions and 22 deletions

View File

@ -270,6 +270,10 @@ Result svcMapMemoryBlock(Handle memblock, u32 addr, MemPerm my_perm, MemPerm oth
Result svcMapProcessMemory(Handle process, u32 startAddr, u32 endAddr); Result svcMapProcessMemory(Handle process, u32 startAddr, u32 endAddr);
Result svcUnmapProcessMemory(Handle process, u32 startAddr, u32 endAddr); Result svcUnmapProcessMemory(Handle process, u32 startAddr, u32 endAddr);
Result svcUnmapMemoryBlock(Handle memblock, u32 addr); Result svcUnmapMemoryBlock(Handle memblock, u32 addr);
Result svcStartInterProcessDma(Handle* dma, Handle dstProcess, void* dst, Handle srcProcess, const void* src, u32 size, void* dmaConfig);
Result svcStopDma(Handle dma);
Result svcGetDmaState(void* dmaState, Handle dma);
/** /**
* @brief Memory information query * @brief Memory information query
* @param addr Virtual memory address * @param addr Virtual memory address
@ -280,6 +284,9 @@ Result svcQueryProcessMemory(MemInfo* info, PageInfo* out, Handle process, u32 a
Result svcCreateAddressArbiter(Handle *arbiter); Result svcCreateAddressArbiter(Handle *arbiter);
Result svcArbitrateAddress(Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 nanoseconds); Result svcArbitrateAddress(Handle arbiter, u32 addr, ArbitrationType type, s32 value, s64 nanoseconds);
Result svcInvalidateProcessDataCache(Handle process, void* addr, u32 size);
Result svcFlushProcessDataCache(Handle process, void const* addr, u32 size);
Result svcReadProcessMemory(void* buffer, Handle debug, u32 addr, u32 size); Result svcReadProcessMemory(void* buffer, Handle debug, u32 addr, u32 size);
Result svcWriteProcessMemory(Handle debug, const void* buffer, u32 addr, u32 size); Result svcWriteProcessMemory(Handle debug, const void* buffer, u32 addr, u32 size);
///@} ///@}
@ -295,6 +302,7 @@ Result svcWriteProcessMemory(Handle debug, const void* buffer, u32 addr, u32 siz
*/ */
Result svcOpenProcess(Handle* process, u32 processId); Result svcOpenProcess(Handle* process, u32 processId);
void svcExitProcess() __attribute__((noreturn)); void svcExitProcess() __attribute__((noreturn));
Result svcTerminateProcess(Handle process);
Result svcGetProcessInfo(s64* out, Handle process, u32 type); Result svcGetProcessInfo(s64* out, Handle process, u32 type);
Result svcGetProcessId(u32 *out, Handle handle); Result svcGetProcessId(u32 *out, Handle handle);
@ -312,7 +320,7 @@ Result svcConnectToPort(volatile Handle* out, const char* portName);
* @param arg The argument passed to @p entrypoint * @param arg The argument passed to @p entrypoint
* @param stack_top The top of the thread's stack. Must be 0x8 bytes mem-aligned. * @param stack_top The top of the thread's stack. Must be 0x8 bytes mem-aligned.
* @param thread_priority Low values gives the thread higher priority. * @param thread_priority Low values gives the thread higher priority.
* For userland app, this has to be withing the range [0x18;0x3F] * For userland apps, this has to be within the range [0x18;0x3F]
* @param processor_id The id of the processor the thread should be ran on. Those are labelled starting from 0. * @param processor_id The id of the processor the thread should be ran on. Those are labelled starting from 0.
* For old 3ds it has to be <2, and for new 3DS <4. * For old 3ds it has to be <2, and for new 3DS <4.
* Value -1 means all CPUs and -2 read from the Exheader. * Value -1 means all CPUs and -2 read from the Exheader.
@ -355,7 +363,7 @@ Result svcGetThreadPriority(s32 *out, Handle handle);
/** /**
* @brief Changes the priority of a thread * @brief Changes the priority of a thread
* @param prio For userland apps, this has to be withing the range [0x18;0x3F] * @param prio For userland apps, this has to be within the range [0x18;0x3F]
* *
* Low values gives the thread higher priority. * Low values gives the thread higher priority.
*/ */
@ -396,14 +404,20 @@ Result svcGetThreadInfo(s64* out, Handle thread, ThreadInfoType type);
///@{ ///@{
Result svcCreateMutex(Handle* mutex, bool initially_locked); Result svcCreateMutex(Handle* mutex, bool initially_locked);
Result svcReleaseMutex(Handle handle); Result svcReleaseMutex(Handle handle);
Result svcCreateSemaphore(Handle* semaphore, s32 initial_count, s32 max_count); Result svcCreateSemaphore(Handle* semaphore, s32 initial_count, s32 max_count);
Result svcReleaseSemaphore(s32* count, Handle semaphore, s32 release_count); Result svcReleaseSemaphore(s32* count, Handle semaphore, s32 release_count);
Result svcCreateEvent(Handle* event, u8 reset_type); Result svcCreateEvent(Handle* event, u8 reset_type);
Result svcSignalEvent(Handle handle); Result svcSignalEvent(Handle handle);
Result svcClearEvent(Handle handle); Result svcClearEvent(Handle handle);
Result svcWaitSynchronization(Handle handle, s64 nanoseconds); Result svcWaitSynchronization(Handle handle, s64 nanoseconds);
Result svcWaitSynchronizationN(s32* out, Handle* handles, s32 handles_num, bool wait_all, s64 nanoseconds); Result svcWaitSynchronizationN(s32* out, Handle* handles, s32 handles_num, bool wait_all, s64 nanoseconds);
Result svcSendSyncRequest(Handle session); Result svcSendSyncRequest(Handle session);
Result svcAcceptSession(Handle* session, Handle port);
Result svcReplyAndReceive(s32* index, Handle* handles, s32 handleCount, Handle replyTarget);
///@} ///@}
///@name Time ///@name Time
@ -420,11 +434,13 @@ u64 svcGetSystemTick();
Result svcCloseHandle(Handle handle); Result svcCloseHandle(Handle handle);
Result svcDuplicateHandle(Handle* out, Handle original); Result svcDuplicateHandle(Handle* out, Handle original);
Result svcGetSystemInfo(s64* out, u32 type, s32 param); Result svcGetSystemInfo(s64* out, u32 type, s32 param);
Result svcKernelSetState(u32 type, u32 param0, u32 param1, u32 param2);
///@} ///@}
///@name Debugging ///@name Debugging
///@{ ///@{
void svcBreak(UserBreakType breakReason);
Result svcOutputDebugString(const char* str, int length); Result svcOutputDebugString(const char* str, int length);
Result svcDebugActiveProcess(Handle* debug, u32 processId); Result svcDebugActiveProcess(Handle* debug, u32 processId);
Result svcBreakDebugProcess(Handle debug); Result svcBreakDebugProcess(Handle debug);

View File

@ -270,7 +270,7 @@ svcDuplicateHandle:
.type svcGetSystemTick, %function .type svcGetSystemTick, %function
svcGetSystemTick: svcGetSystemTick:
svc 0x28 svc 0x28
bx lr bx lr
.global svcGetSystemInfo .global svcGetSystemInfo
.type svcGetSystemInfo, %function .type svcGetSystemInfo, %function
@ -315,7 +315,7 @@ svcConnectToPort:
.type svcSendSyncRequest, %function .type svcSendSyncRequest, %function
svcSendSyncRequest: svcSendSyncRequest:
svc 0x32 svc 0x32
bx lr bx lr
.global svcOpenProcess .global svcOpenProcess
.type svcOpenProcess, %function .type svcOpenProcess, %function
@ -324,8 +324,7 @@ svcOpenProcess:
svc 0x33 svc 0x33
pop {r2} pop {r2}
str r1, [r2] str r1, [r2]
bx lr bx lr
.global svcOpenThread .global svcOpenThread
.type svcOpenThread, %function .type svcOpenThread, %function
@ -334,8 +333,7 @@ svcOpenThread:
svc 0x34 svc 0x34
pop {r2} pop {r2}
str r1, [r2] str r1, [r2]
bx lr bx lr
.global svcGetProcessId .global svcGetProcessId
.type svcGetProcessId, %function .type svcGetProcessId, %function
@ -346,7 +344,6 @@ svcGetProcessId:
str r1, [r3] str r1, [r3]
bx lr bx lr
.global svcGetProcessIdOfThread .global svcGetProcessIdOfThread
.type svcGetProcessIdOfThread, %function .type svcGetProcessIdOfThread, %function
svcGetProcessIdOfThread: svcGetProcessIdOfThread:
@ -365,6 +362,12 @@ svcGetThreadId:
str r1, [r3] str r1, [r3]
bx lr bx lr
.global svcBreak
.type svcBreak, %function
svcBreak:
svc 0x3C
bx lr
.global svcOutputDebugString .global svcOutputDebugString
.type svcOutputDebugString, %function .type svcOutputDebugString, %function
svcOutputDebugString: svcOutputDebugString:
@ -381,7 +384,66 @@ svcCreatePort:
ldr r3, [sp, #4] ldr r3, [sp, #4]
str r2, [r3] str r2, [r3]
add sp, sp, #8 add sp, sp, #8
bx lr bx lr
.global svcAcceptSession
.type svcAcceptSession, %function
svcAcceptSession:
str r0, [sp, #-4]!
svc 0x4A
ldr r2, [sp]
str r1, [r2]
add sp, sp, #4
bx lr
.global svcReplyAndReceive
.type svcReplyAndReceive, %function
svcReplyAndReceive:
str r0, [sp, #-4]!
svc 0x4F
ldr r2, [sp]
str r1, [r2]
add sp, sp, #4
bx lr
.global svcInvalidateProcessDataCache
.type svcInvalidateProcessDataCache, %function
svcInvalidateProcessDataCache:
svc 0x52
bx lr
.global svcFlushProcessDataCache
.type svcFlushProcessDataCache, %function
svcFlushProcessDataCache:
svc 0x54
bx lr
.global svcStartInterProcessDma
.type svcStartInterProcessDma, %function
svcStartInterProcessDma:
stmfd sp!, {r0, r4, r5}
ldr r0, [sp, #0xC]
ldr r4, [sp, #0x10]
ldr r5, [sp, #0x14]
svc 0x55
ldmfd sp!, {r2, r4, r5}
str r1, [r2]
bx lr
.global svcStopDma
.type svcStopDma, %function
svcStopDma:
svc 0x56
bx lr
.global svcGetDmaState
.type svcGetDmaState, %function
svcGetDmaState:
str r0, [sp, #-4]!
svc 0x57
ldr r3, [sp], #4
str r1, [r3]
bx lr
.global svcDebugActiveProcess .global svcDebugActiveProcess
.type svcDebugActiveProcess, %function .type svcDebugActiveProcess, %function
@ -390,31 +452,31 @@ svcDebugActiveProcess:
svc 0x60 svc 0x60
pop {r2} pop {r2}
str r1, [r2] str r1, [r2]
bx lr bx lr
.global svcBreakDebugProcess .global svcBreakDebugProcess
.type svcBreakDebugProcess, %function .type svcBreakDebugProcess, %function
svcBreakDebugProcess: svcBreakDebugProcess:
svc 0x61 svc 0x61
bx lr bx lr
.global svcTerminateDebugProcess .global svcTerminateDebugProcess
.type svcTerminateDebugProcess, %function .type svcTerminateDebugProcess, %function
svcTerminateDebugProcess: svcTerminateDebugProcess:
svc 0x62 svc 0x62
bx lr bx lr
.global svcGetProcessDebugEvent .global svcGetProcessDebugEvent
.type svcGetProcessDebugEvent, %function .type svcGetProcessDebugEvent, %function
svcGetProcessDebugEvent: svcGetProcessDebugEvent:
svc 0x63 svc 0x63
bx lr bx lr
.global svcContinueDebugEvent .global svcContinueDebugEvent
.type svcContinueDebugEvent, %function .type svcContinueDebugEvent, %function
svcContinueDebugEvent: svcContinueDebugEvent:
svc 0x64 svc 0x64
bx lr bx lr
.global svcGetProcessList .global svcGetProcessList
.type svcGetProcessList, %function .type svcGetProcessList, %function
@ -426,13 +488,13 @@ svcGetProcessList:
ldr r3, [sp, #4] ldr r3, [sp, #4]
str r2, [r3] str r2, [r3]
add sp, sp, #8 add sp, sp, #8
bx lr bx lr
.global svcReadProcessMemory .global svcReadProcessMemory
.type svcReadProcessMemory, %function .type svcReadProcessMemory, %function
svcReadProcessMemory: svcReadProcessMemory:
svc 0x6A svc 0x6A
bx lr bx lr
.global svcWriteProcessMemory .global svcWriteProcessMemory
.type svcWriteProcessMemory, %function .type svcWriteProcessMemory, %function
@ -448,25 +510,37 @@ svcControlProcessMemory:
ldr r5, [sp, #0xC] ldr r5, [sp, #0xC]
svc 0x70 svc 0x70
pop {r4-r5} pop {r4-r5}
bx lr bx lr
.global svcMapProcessMemory .global svcMapProcessMemory
.type svcMapProcessMemory, %function .type svcMapProcessMemory, %function
svcMapProcessMemory: svcMapProcessMemory:
svc 0x71 svc 0x71
bx lr bx lr
.global svcUnmapProcessMemory .global svcUnmapProcessMemory
.type svcUnmapProcessMemory, %function .type svcUnmapProcessMemory, %function
svcUnmapProcessMemory: svcUnmapProcessMemory:
svc 0x72 svc 0x72
bx lr bx lr
.global svcTerminateProcess
.type svcTerminateProcess, %function
svcTerminateProcess:
svc 0x76
bx lr
.global svcBackdoor .global svcBackdoor
.type svcBackdoor, %function .type svcBackdoor, %function
svcBackdoor: svcBackdoor:
svc 0x7B svc 0x7B
bx lr bx lr
.global svcKernelSetState
.type svcKernelSetState, %function
svcKernelSetState:
svc 0x7C
bx lr
.global svcQueryProcessMemory .global svcQueryProcessMemory
.type svcQueryProcessMemory, %function .type svcQueryProcessMemory, %function
@ -479,4 +553,4 @@ svcQueryProcessMemory:
str r5, [r6] str r5, [r6]
add sp, sp, #8 add sp, sp, #8
pop {r4-r6} pop {r4-r6}
bx lr bx lr