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,72 +1,69 @@
|
|||||||
.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
|
||||||
ldr r2, [sp], #4
|
ldr r2, [sp], #4
|
||||||
str r1, [r2]
|
str r1, [r2]
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.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]
|
||||||
str r3, [r6,#8]
|
str r3, [r6, #8]
|
||||||
str r4, [r6,#0xc]
|
str r4, [r6, #0xc]
|
||||||
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
|
||||||
.type svcExitProcess, %function
|
.type svcExitProcess, %function
|
||||||
svcExitProcess:
|
svcExitProcess:
|
||||||
svc 0x03
|
svc 0x03
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.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
|
||||||
ldr r2, [sp], #4
|
ldr r2, [sp], #4
|
||||||
str r1, [r2]
|
str r1, [r2]
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcExitThread
|
.global svcExitThread
|
||||||
.type svcExitThread, %function
|
.type svcExitThread, %function
|
||||||
svcExitThread:
|
svcExitThread:
|
||||||
svc 0x09
|
svc 0x09
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcSleepThread
|
.global svcSleepThread
|
||||||
.type svcSleepThread, %function
|
.type svcSleepThread, %function
|
||||||
svcSleepThread:
|
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
|
||||||
@ -75,61 +72,61 @@ svcCreateMutex:
|
|||||||
svc 0x13
|
svc 0x13
|
||||||
ldr r3, [sp], #4
|
ldr r3, [sp], #4
|
||||||
str r1, [r3]
|
str r1, [r3]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcReleaseMutex
|
.global svcReleaseMutex
|
||||||
.type svcReleaseMutex, %function
|
.type svcReleaseMutex, %function
|
||||||
svcReleaseMutex:
|
svcReleaseMutex:
|
||||||
svc 0x14
|
svc 0x14
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcCreateEvent
|
.global svcCreateEvent
|
||||||
.type svcCreateEvent, %function
|
.type svcCreateEvent, %function
|
||||||
svcCreateEvent:
|
svcCreateEvent:
|
||||||
str r0, [sp,#-4]!
|
str r0, [sp, #-4]!
|
||||||
svc 0x17
|
svc 0x17
|
||||||
ldr r2, [sp], #4
|
ldr r2, [sp], #4
|
||||||
str r1, [r2]
|
str r1, [r2]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcSignalEvent
|
.global svcSignalEvent
|
||||||
.type svcSignalEvent, %function
|
.type svcSignalEvent, %function
|
||||||
svcSignalEvent:
|
svcSignalEvent:
|
||||||
svc 0x18
|
svc 0x18
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcClearEvent
|
.global svcClearEvent
|
||||||
.type svcClearEvent, %function
|
.type svcClearEvent, %function
|
||||||
svcClearEvent:
|
svcClearEvent:
|
||||||
svc 0x19
|
svc 0x19
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcCreateTimer
|
.global svcCreateTimer
|
||||||
.type svcCreateTimer, %function
|
.type svcCreateTimer, %function
|
||||||
svcCreateTimer:
|
svcCreateTimer:
|
||||||
str r0, [sp,#-4]!
|
str r0, [sp, #-4]!
|
||||||
svc 0x1A
|
svc 0x1A
|
||||||
ldr r2, [sp], #4
|
ldr r2, [sp], #4
|
||||||
str r1, [r2]
|
str r1, [r2]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcSetTimer
|
.global svcSetTimer
|
||||||
.type svcSetTimer, %function
|
.type svcSetTimer, %function
|
||||||
svcSetTimer:
|
svcSetTimer:
|
||||||
svc 0x1B
|
svc 0x1B
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcCancelTimer
|
.global svcCancelTimer
|
||||||
.type svcCancelTimer, %function
|
.type svcCancelTimer, %function
|
||||||
svcCancelTimer:
|
svcCancelTimer:
|
||||||
svc 0x1C
|
svc 0x1C
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcClearTimer
|
.global svcClearTimer
|
||||||
.type svcClearTimer, %function
|
.type svcClearTimer, %function
|
||||||
svcClearTimer:
|
svcClearTimer:
|
||||||
svc 0x1D
|
svc 0x1D
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcCreateMemoryBlock
|
.global svcCreateMemoryBlock
|
||||||
.type svcCreateMemoryBlock, %function
|
.type svcCreateMemoryBlock, %function
|
||||||
@ -139,49 +136,49 @@ svcCreateMemoryBlock:
|
|||||||
svc 0x1E
|
svc 0x1E
|
||||||
ldr r2, [sp], #4
|
ldr r2, [sp], #4
|
||||||
str r1, [r2]
|
str r1, [r2]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcMapMemoryBlock
|
.global svcMapMemoryBlock
|
||||||
.type svcMapMemoryBlock, %function
|
.type svcMapMemoryBlock, %function
|
||||||
svcMapMemoryBlock:
|
svcMapMemoryBlock:
|
||||||
svc 0x1F
|
svc 0x1F
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcUnmapMemoryBlock
|
.global svcUnmapMemoryBlock
|
||||||
.type svcUnmapMemoryBlock, %function
|
.type svcUnmapMemoryBlock, %function
|
||||||
svcUnmapMemoryBlock:
|
svcUnmapMemoryBlock:
|
||||||
svc 0x20
|
svc 0x20
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcCreateAddressArbiter
|
.global svcCreateAddressArbiter
|
||||||
.type svcCreateAddressArbiter, %function
|
.type svcCreateAddressArbiter, %function
|
||||||
svcCreateAddressArbiter:
|
svcCreateAddressArbiter:
|
||||||
svc 0x21
|
svc 0x21
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcArbitrateAddress
|
.global svcArbitrateAddress
|
||||||
.type svcArbitrateAddress, %function
|
.type svcArbitrateAddress, %function
|
||||||
svcArbitrateAddress:
|
svcArbitrateAddress:
|
||||||
push {r4,r5}
|
push {r4, r5}
|
||||||
add sp, #8
|
add sp, #8
|
||||||
ldr r5, [sp]
|
ldr r5, [sp]
|
||||||
ldr r4, [sp, #4]
|
ldr r4, [sp, #4]
|
||||||
sub sp, #8
|
sub sp, #8
|
||||||
svc 0x22
|
svc 0x22
|
||||||
pop {r4,r5}
|
pop {r4, r5}
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcCloseHandle
|
.global svcCloseHandle
|
||||||
.type svcCloseHandle, %function
|
.type svcCloseHandle, %function
|
||||||
svcCloseHandle:
|
svcCloseHandle:
|
||||||
svc 0x23
|
svc 0x23
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcWaitSynchronization
|
.global svcWaitSynchronization
|
||||||
.type svcWaitSynchronization, %function
|
.type svcWaitSynchronization, %function
|
||||||
svcWaitSynchronization:
|
svcWaitSynchronization:
|
||||||
svc 0x24
|
svc 0x24
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcWaitSynchronizationN
|
.global svcWaitSynchronizationN
|
||||||
.type svcWaitSynchronizationN, %function
|
.type svcWaitSynchronizationN, %function
|
||||||
@ -195,16 +192,16 @@ svcWaitSynchronizationN:
|
|||||||
str r1, [r5]
|
str r1, [r5]
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
ldr r5, [sp], #4
|
ldr r5, [sp], #4
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcDuplicateHandle
|
.global svcDuplicateHandle
|
||||||
.type svcDuplicateHandle, %function
|
.type svcDuplicateHandle, %function
|
||||||
svcDuplicateHandle:
|
svcDuplicateHandle:
|
||||||
str r0, [sp,#-0x4]!
|
str r0, [sp, #-0x4]!
|
||||||
svc 0x27
|
svc 0x27
|
||||||
ldr r3, [sp], #4
|
ldr r3, [sp], #4
|
||||||
str r1, [r3]
|
str r1, [r3]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcGetSystemTick
|
.global svcGetSystemTick
|
||||||
.type svcGetSystemTick, %function
|
.type svcGetSystemTick, %function
|
||||||
@ -215,34 +212,34 @@ 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]
|
||||||
str r2, [r4, #4]
|
str r2, [r4, #4]
|
||||||
str r3, [r4, #8]
|
str r3, [r4, #8]
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.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]
|
||||||
str r2, [r4, #4]
|
str r2, [r4, #4]
|
||||||
ldr r4, [sp], #4
|
ldr r4, [sp], #4
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcConnectToPort
|
.global svcConnectToPort
|
||||||
.type svcConnectToPort, %function
|
.type svcConnectToPort, %function
|
||||||
svcConnectToPort:
|
svcConnectToPort:
|
||||||
str r0, [sp,#-0x4]!
|
str r0, [sp, #-0x4]!
|
||||||
svc 0x2D
|
svc 0x2D
|
||||||
ldr r3, [sp], #4
|
ldr r3, [sp], #4
|
||||||
str r1, [r3]
|
str r1, [r3]
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
.global svcSendSyncRequest
|
.global svcSendSyncRequest
|
||||||
.type svcSendSyncRequest, %function
|
.type svcSendSyncRequest, %function
|
||||||
@ -253,23 +250,17 @@ svcSendSyncRequest:
|
|||||||
.global svcGetProcessId
|
.global svcGetProcessId
|
||||||
.type svcGetProcessId, %function
|
.type svcGetProcessId, %function
|
||||||
svcGetProcessId:
|
svcGetProcessId:
|
||||||
str r0, [sp,#-0x4]!
|
str r0, [sp, #-0x4]!
|
||||||
svc 0x35
|
svc 0x35
|
||||||
ldr r3, [sp], #4
|
ldr r3, [sp], #4
|
||||||
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:
|
||||||
str r0, [sp,#-0x4]!
|
str r0, [sp, #-0x4]!
|
||||||
svc 0x3D
|
svc 0x3D
|
||||||
ldr r2, [sp], #4
|
ldr r2, [sp], #4
|
||||||
str r1, [r2]
|
str r1, [r2]
|
||||||
bx lr
|
bx lr
|
||||||
|
Loading…
Reference in New Issue
Block a user