Add getThreadLocalStorage(), major cleanup in svc.h/svc.s
This commit is contained in:
parent
0f93112ecb
commit
377e753b7d
@ -2,8 +2,7 @@
|
|||||||
svc.h _ Syscall wrappers.
|
svc.h _ Syscall wrappers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SVC_H
|
#pragma once
|
||||||
#define SVC_H
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MEMOP_FREE =1, // Free heap
|
MEMOP_FREE =1, // Free heap
|
||||||
@ -42,8 +41,17 @@ typedef enum {
|
|||||||
ARBITER_KERNEL4 =4,
|
ARBITER_KERNEL4 =4,
|
||||||
} ArbitrationType;
|
} ArbitrationType;
|
||||||
|
|
||||||
|
static inline void* getThreadLocalStorage(void)
|
||||||
|
{
|
||||||
|
void* ret;
|
||||||
|
asm volatile("mrc p15, 0, %[data], c13, c0, 3" : [data] "=r" (ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
u32* getThreadCommandBuffer(void);
|
static inline u32* getThreadCommandBuffer(void)
|
||||||
|
{
|
||||||
|
return (u32*)((u8*)getThreadLocalStorage() + 0x80);
|
||||||
|
}
|
||||||
|
|
||||||
s32 svcControlMemory(u32* addr_out, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
|
s32 svcControlMemory(u32* addr_out, u32 addr0, u32 addr1, u32 size, MemOp op, MemPerm perm);
|
||||||
s32 svcQueryMemory(MemInfo* info, PageInfo* out, u32 addr);
|
s32 svcQueryMemory(MemInfo* info, PageInfo* out, u32 addr);
|
||||||
@ -51,6 +59,7 @@ 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 svcSetThreadPriority(Handle thread, s32 prio);
|
||||||
s32 svcCreateMutex(Handle* mutex, bool initially_locked);
|
s32 svcCreateMutex(Handle* mutex, bool initially_locked);
|
||||||
s32 svcReleaseMutex(Handle handle);
|
s32 svcReleaseMutex(Handle handle);
|
||||||
s32 svcCreateEvent(Handle* event, u8 reset_type);
|
s32 svcCreateEvent(Handle* event, u8 reset_type);
|
||||||
@ -76,6 +85,3 @@ s32 svcConnectToPort(volatile Handle* out, const char* portName);
|
|||||||
s32 svcSendSyncRequest(Handle session);
|
s32 svcSendSyncRequest(Handle session);
|
||||||
s32 svcGetProcessId(u32 *out, Handle handle);
|
s32 svcGetProcessId(u32 *out, Handle handle);
|
||||||
s32 svcOutputDebugString(const char* str, int length);
|
s32 svcOutputDebugString(const char* str, int length);
|
||||||
s32 svcSetThreadPriority(Handle thread, s32 prio);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
.arm
|
.arm
|
||||||
.align 4
|
.align 4
|
||||||
|
|
||||||
/* THIS DOES NOT BELONG HERE */
|
|
||||||
.global getThreadCommandBuffer
|
|
||||||
.type getThreadCommandBuffer, %function
|
|
||||||
getThreadCommandBuffer:
|
|
||||||
mrc p15, 0, r0, c13, c0, 3
|
|
||||||
add r0, #0x80
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
|
|
||||||
.global svcControlMemory
|
.global svcControlMemory
|
||||||
.type svcControlMemory, %function
|
.type svcControlMemory, %function
|
||||||
svcControlMemory:
|
svcControlMemory:
|
||||||
stmfd sp!, {r0, r4}
|
push {r0, r4}
|
||||||
ldr r0, [sp, #0x8]
|
ldr r0, [sp, #0x8]
|
||||||
ldr r4, [sp, #0x8+0x4]
|
ldr r4, [sp, #0x8+0x4]
|
||||||
svc 0x01
|
svc 0x01
|
||||||
@ -25,8 +16,8 @@ svcControlMemory:
|
|||||||
.global svcQueryMemory
|
.global svcQueryMemory
|
||||||
.type svcQueryMemory, %function
|
.type svcQueryMemory, %function
|
||||||
svcQueryMemory:
|
svcQueryMemory:
|
||||||
stmfd sp!, {r0,r1,r4-r6}
|
push {r0, r1, r4-r6}
|
||||||
svc 2
|
svc 0x02
|
||||||
ldr r6, [sp]
|
ldr r6, [sp]
|
||||||
str r1, [r6]
|
str r1, [r6]
|
||||||
str r2, [r6, #4]
|
str r2, [r6, #4]
|
||||||
@ -35,7 +26,7 @@ svcQueryMemory:
|
|||||||
ldr r6, [sp, #4]
|
ldr r6, [sp, #4]
|
||||||
str r5, [r6]
|
str r5, [r6]
|
||||||
add sp, sp, #8
|
add sp, sp, #8
|
||||||
ldmfd sp!, {r4-r6}
|
pop {r4-r6}
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcExitProcess
|
.global svcExitProcess
|
||||||
@ -47,7 +38,7 @@ svcExitProcess:
|
|||||||
.global svcCreateThread
|
.global svcCreateThread
|
||||||
.type svcCreateThread, %function
|
.type svcCreateThread, %function
|
||||||
svcCreateThread:
|
svcCreateThread:
|
||||||
stmfd sp!, {r0, r4}
|
push {r0, r4}
|
||||||
ldr r0, [sp, #0x8]
|
ldr r0, [sp, #0x8]
|
||||||
ldr r4, [sp, #0x8+0x4]
|
ldr r4, [sp, #0x8+0x4]
|
||||||
svc 0x08
|
svc 0x08
|
||||||
@ -68,6 +59,12 @@ svcSleepThread:
|
|||||||
svc 0x0A
|
svc 0x0A
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
|
.global svcSetThreadPriority
|
||||||
|
.type svcSetThreadPriority, %function
|
||||||
|
svcSetThreadPriority:
|
||||||
|
svc 0x0C
|
||||||
|
bx lr
|
||||||
|
|
||||||
.global svcCreateMutex
|
.global svcCreateMutex
|
||||||
.type svcCreateMutex, %function
|
.type svcCreateMutex, %function
|
||||||
svcCreateMutex:
|
svcCreateMutex:
|
||||||
@ -215,7 +212,7 @@ svcGetSystemTick:
|
|||||||
.global svcGetSystemInfo
|
.global svcGetSystemInfo
|
||||||
.type svcGetSystemInfo, %function
|
.type svcGetSystemInfo, %function
|
||||||
svcGetSystemInfo:
|
svcGetSystemInfo:
|
||||||
stmfd sp!, {r0, r4}
|
push {r0, r4}
|
||||||
svc 0x2A
|
svc 0x2A
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
str r1, [r4]
|
str r1, [r4]
|
||||||
@ -227,7 +224,7 @@ svcGetSystemInfo:
|
|||||||
.global svcGetProcessInfo
|
.global svcGetProcessInfo
|
||||||
.type svcGetProcessInfo, %function
|
.type svcGetProcessInfo, %function
|
||||||
svcGetProcessInfo:
|
svcGetProcessInfo:
|
||||||
stmfd sp!, {r0, r4}
|
push {r0,r4}
|
||||||
svc 0x2B
|
svc 0x2B
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
str r1, [r4]
|
str r1, [r4]
|
||||||
@ -259,12 +256,6 @@ svcGetProcessId:
|
|||||||
str r1, [r3]
|
str r1, [r3]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcSetThreadPriority
|
|
||||||
.type svcSetThreadPriority, %function
|
|
||||||
svcSetThreadPriority:
|
|
||||||
svc 0x0C
|
|
||||||
bx lr
|
|
||||||
|
|
||||||
.global svcOutputDebugString
|
.global svcOutputDebugString
|
||||||
.type svcOutputDebugString, %function
|
.type svcOutputDebugString, %function
|
||||||
svcOutputDebugString:
|
svcOutputDebugString:
|
||||||
|
Loading…
Reference in New Issue
Block a user