Merge pull request #122 from Lectem/thread_svcs

threads svcs
This commit is contained in:
smea 2015-05-30 09:07:41 -07:00
commit 31e0f2ee07
2 changed files with 94 additions and 15 deletions

View File

@ -135,6 +135,13 @@ typedef enum {
USERBREAK_USER = 2
} UserBreakType;
/**
* Type of the query for svcGetThreadInfo
*/
typedef enum {
THREADINFO_TYPE_UNKNOWN
} ThreadInfoType;
typedef struct {
u64 clock_tick;
} SchedulerInOutEvent;
@ -193,7 +200,12 @@ void __attribute__((noreturn)) svcExitProcess();
s32 svcCreateThread(Handle* thread, ThreadFunc entrypoint, u32 arg, u32* stack_top, s32 thread_priority, s32 processor_id);
void __attribute__((noreturn)) svcExitThread();
void svcSleepThread(s64 ns);
s32 svcGetThreadPriority(s32 *out, Handle handle);
s32 svcSetThreadPriority(Handle thread, s32 prio);
s32 svcGetThreadAffinityMask(u8* affinitymask, Handle thread, s32 processorcount);
s32 svcSetThreadAffinityMask(Handle thread, u8* affinitymask, s32 processorcount);
s32 svcGetThreadIdealProcessor(s32* processorid, Handle thread);
s32 svcSetThreadIdealProcessor(Handle thread, s32 processorid);
s32 svcGetProcessorID();
s32 svcCreateMutex(Handle* mutex, bool initially_locked);
s32 svcReleaseMutex(Handle handle);
@ -218,10 +230,13 @@ s32 svcDuplicateHandle(Handle* out, Handle original);
u64 svcGetSystemTick();
s32 svcGetSystemInfo(s64* out, u32 type, s32 param);
s32 svcGetProcessInfo(s64* out, Handle process, u32 type);
s32 svcGetThreadInfo(s64* out, Handle thread, ThreadInfoType type);
s32 svcConnectToPort(volatile Handle* out, const char* portName);
s32 svcSendSyncRequest(Handle session);
Result svcOpenProcess(Handle* process, u32 processId);
Result svcOpenThread(Handle* thread,Handle process, u32 threadId);
s32 svcGetProcessId(u32 *out, Handle handle);
s32 svcGetProcessIdOfThread(u32 *out, Handle handle);
s32 svcGetThreadId(u32 *out, Handle handle);
s32 svcOutputDebugString(const char* str, int length);
Result svcCreatePort(Handle* portServer, Handle* portClient, const char* name, s32 maxSessions);

View File

@ -59,12 +59,48 @@ svcSleepThread:
svc 0x0A
bx lr
.global svcGetThreadPriority
.type svcGetThreadPriority, %function
svcGetThreadPriority:
str r0, [sp, #-0x4]!
svc 0x0B
ldr r3, [sp], #4
str r1, [r3]
bx lr
.global svcSetThreadPriority
.type svcSetThreadPriority, %function
svcSetThreadPriority:
svc 0x0C
bx lr
.global svcGetThreadAffinityMask
.type svcGetThreadAffinityMask, %function
svcGetThreadAffinityMask:
svc 0x0D
bx lr
.global svcSetThreadAffinityMask
.type svcSetThreadAffinityMask, %function
svcSetThreadAffinityMask:
svc 0x0E
bx lr
.global svcGetThreadIdealProcessor
.type svcGetThreadIdealProcessor, %function
svcGetThreadIdealProcessor:
str r0, [sp, #-0x4]!
svc 0x0F
ldr r3, [sp], #4
str r1, [r3]
bx lr
.global svcSetThreadIdealProcessor
.type svcSetThreadIdealProcessor, %function
svcSetThreadIdealProcessor:
svc 0x10
bx lr
.global svcGetProcessorID
.type svcGetProcessorID, %function
svcGetProcessorID:
@ -239,25 +275,32 @@ svcGetSystemTick:
.global svcGetSystemInfo
.type svcGetSystemInfo, %function
svcGetSystemInfo:
push {r0, r4}
svc 0x2A
ldr r4, [sp], #4
str r1, [r4]
str r2, [r4, #4]
str r3, [r4, #8]
ldr r4, [sp], #4
bx lr
str r0, [sp, #-0x4]!
svc 0x2A
ldr r3, [sp], #4
str r1, [r3]
str r2, [r3,#4]
bx lr
.global svcGetProcessInfo
.type svcGetProcessInfo, %function
svcGetProcessInfo:
push {r0,r4}
svc 0x2B
ldr r4, [sp], #4
str r1, [r4]
str r2, [r4, #4]
ldr r4, [sp], #4
bx lr
str r0, [sp, #-0x4]!
svc 0x2B
ldr r3, [sp], #4
str r1, [r3]
str r2, [r3,#4]
bx lr
.global svcGetThreadInfo
.type svcGetThreadInfo, %function
svcGetThreadInfo:
str r0, [sp, #-0x4]!
svc 0x2C
ldr r3, [sp], #4
str r1, [r3]
str r2, [r3,#4]
bx lr
.global svcConnectToPort
.type svcConnectToPort, %function
@ -283,6 +326,17 @@ svcOpenProcess:
str r1, [r2]
bx lr
.global svcOpenThread
.type svcOpenThread, %function
svcOpenThread:
push {r0}
svc 0x34
pop {r2}
str r1, [r2]
bx lr
.global svcGetProcessId
.type svcGetProcessId, %function
svcGetProcessId:
@ -292,6 +346,16 @@ svcGetProcessId:
str r1, [r3]
bx lr
.global svcGetProcessIdOfThread
.type svcGetProcessIdOfThread, %function
svcGetProcessIdOfThread:
str r0, [sp, #-0x4]!
svc 0x36
ldr r3, [sp], #4
str r1, [r3]
bx lr
.global svcGetThreadId
.type svcGetThreadId, %function
svcGetThreadId: