]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add svcSetProcessAffinityMask, svcSetProcessIdealProcessor and svcRun
authorfincs <fincs.alt1@gmail.com>
Mon, 16 May 2016 22:14:32 +0000 (00:14 +0200)
committerfincs <fincs.alt1@gmail.com>
Mon, 16 May 2016 22:14:32 +0000 (00:14 +0200)
libctru/include/3ds/svc.h
libctru/source/svc.s

index 25dcc9b5808e83e457bde115584612d7fdcdfda2..96679636aa136d8ddb1921e0c5727b783b8b3e6f 100644 (file)
@@ -263,6 +263,16 @@ typedef struct {
        u64 program_id;       ///< Program ID
 } CodeSetInfo;
 
+/// Information for the main thread of a process.
+typedef struct
+{
+       int priority;   ///< Priority of the main thread.
+       u32 stack_size; ///< Size of the stack of the main thread.
+       int argc;       ///< Unused on retail kernel.
+       u16* argv;      ///< Unused on retail kernel.
+       u16* envp;      ///< Unused on retail kernel.
+} StartupInfo;
+
 ///@}
 
 /**
@@ -529,7 +539,30 @@ Result svcCreateCodeSet(Handle* out, const CodeSetInfo *info, void* code_ptr, vo
  * @param arm11kernelcaps ARM11 Kernel Capabilities from exheader
  * @param arm11kernelcaps_num Number of kernel capabilities
  */
-Result svcCreateProcess(Handle* out, Handle codeset, u32 *arm11kernelcaps, u32 arm11kernelcaps_num);
+Result svcCreateProcess(Handle* out, Handle codeset, const u32 *arm11kernelcaps, u32 arm11kernelcaps_num);
+
+/**
+ * @brief Sets a process's affinity mask.
+ * @param process Handle of the process.
+ * @param affinitymask Pointer to retrieve the affinity masks from.
+ * @param processorcount Number of processors.
+ */
+Result svcSetProcessAffinityMask(Handle process, const u8* affinitymask, s32 processorcount);
+
+/**
+ * Sets a process's ideal processor.
+ * @param process Handle of the process.
+ * @param processorid ID of the thread's ideal processor.
+ */
+Result svcSetProcessIdealProcessor(Handle process, s32 processorid);
+
+/**
+ * Launches the main thread of the process.
+ * @param process Handle of the process.
+ * @param info Pointer to a StartupInfo structure describing information for the main thread.
+ */
+Result svcRun(Handle process, const StartupInfo* info);
+
 ///@}
 
 ///@name Multithreading
@@ -602,7 +635,7 @@ Result svcGetThreadAffinityMask(u8* affinitymask, Handle thread, s32 processorco
  * @param affinitymask Pointer to retrieve the affinity masks from.
  * @param processorcount Number of processors.
  */
-Result svcSetThreadAffinityMask(Handle thread, u8* affinitymask, s32 processorcount);
+Result svcSetThreadAffinityMask(Handle thread, const u8* affinitymask, s32 processorcount);
 
 /**
  * @brief Gets a thread's ideal processor.
index 59560e5412c60d291e45413f3af8712aede99c10..309487baf146b5117af4282bcafbdbf156459288 100644 (file)
@@ -37,6 +37,14 @@ SVC_BEGIN svcExitProcess
        svc 0x03
        bx  lr
 
+SVC_BEGIN svcSetProcessAffinityMask
+       svc 0x05
+       bx lr
+
+SVC_BEGIN svcSetProcessIdealProcessor
+       svc 0x07
+       bx lr
+
 SVC_BEGIN svcCreateThread
        push {r0, r4}
        ldr  r0, [sp, #0x8]
@@ -89,6 +97,17 @@ SVC_BEGIN svcGetProcessorID
        svc 0x11
        bx  lr
 
+SVC_BEGIN svcRun
+       push {r4,r5}
+       ldr r2, [r1, #0x04]
+       ldr r3, [r1, #0x08]
+       ldr r4, [r1, #0x0C]
+       ldr r5, [r1, #0x10]
+       ldr r1, [r1, #0x00]
+       svc 0x12
+       pop {r4,r5}
+       bx  lr
+
 SVC_BEGIN svcCreateMutex
        str r0, [sp, #-4]!
        svc 0x13