threads svcs

This commit is contained in:
Lectem 2015-05-25 21:11:16 +02:00
parent 33eb72e071
commit f3bb5339f7
2 changed files with 83 additions and 0 deletions

View File

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

View File

@ -59,11 +59,47 @@ svcSleepThread:
svc 0x0A svc 0x0A
bx lr 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 .global svcSetThreadPriority
.type svcSetThreadPriority, %function .type svcSetThreadPriority, %function
svcSetThreadPriority: svcSetThreadPriority:
svc 0x0C svc 0x0C
bx lr 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 .global svcGetProcessorID
.type svcGetProcessorID, %function .type svcGetProcessorID, %function
@ -259,6 +295,17 @@ svcGetProcessInfo:
ldr r4, [sp], #4 ldr r4, [sp], #4
bx lr bx lr
.global svcGetThreadInfo
.type svcGetThreadInfo, %function
svcGetThreadInfo:
push {r0,r4}
svc 0x2C
ldr r4, [sp], #4
str r1, [r4]
str r2, [r4, #4]
ldr r4, [sp], #4
bx lr
.global svcConnectToPort .global svcConnectToPort
.type svcConnectToPort, %function .type svcConnectToPort, %function
svcConnectToPort: svcConnectToPort:
@ -283,6 +330,17 @@ svcOpenProcess:
str r1, [r2] str r1, [r2]
bx lr bx lr
.global svcOpenThread
.type svcOpenThread, %function
svcOpenThread:
push {r0}
svc 0x34
pop {r2}
str r1, [r2]
bx lr
.global svcGetProcessId .global svcGetProcessId
.type svcGetProcessId, %function .type svcGetProcessId, %function
svcGetProcessId: svcGetProcessId:
@ -292,6 +350,16 @@ svcGetProcessId:
str r1, [r3] str r1, [r3]
bx lr 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 .global svcGetThreadId
.type svcGetThreadId, %function .type svcGetThreadId, %function
svcGetThreadId: svcGetThreadId: