11 void* linearMemAlign(size_t size, size_t alignment);
12 void linearFree(void* mem);
14 int32_t svcDuplicateHandle(uint32_t* out, uint32_t original);
15 int32_t svcCloseHandle(uint32_t handle);
16 int32_t svcControlMemory(void* addr_out, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
17 int32_t svcControlProcessMemory(uint32_t process, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
19 int32_t threadCreate(void *(*entrypoint)(void*), void* arg, size_t stack_size, int32_t prio, int32_t affinity, bool detached);
20 int32_t threadJoin(int32_t thread, int64_t timeout_ns);
21 void threadFree(int32_t thread);
22 void threadExit(int32_t rc) __attribute__((noreturn));
24 int32_t svcBackdoor(int32_t (*callback)(void));
26 #define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
28 void wait_for_input(void);
30 extern __attribute__((weak)) int __ctr_svchax;
32 typedef int32_t (*ctr_callback_type)(void);
34 static inline void ctr_invalidate_ICache_kernel(void)
39 "mcr p15, 0, r0, c7, c5, 0\n\t");
42 static inline void ctr_flush_DCache_kernel(void)
47 "mcr p15, 0, r0, c7, c10, 0\n\t");
50 static inline void ctr_invalidate_ICache(void)
52 svcBackdoor((ctr_callback_type)ctr_invalidate_ICache_kernel);
55 static inline void ctr_flush_DCache(void)
57 svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel);
61 static inline void ctr_flush_invalidate_cache(void)
64 ctr_invalidate_ICache();
68 #endif // _3DS_UTILS_H