11 #define GET_VERSION_MAJOR(version) ((version) >>24)
13 void* linearMemAlign(size_t size, size_t alignment);
14 void linearFree(void* mem);
16 int32_t svcDuplicateHandle(uint32_t* out, uint32_t original);
17 int32_t svcCloseHandle(uint32_t handle);
18 int32_t svcControlMemory(void* addr_out, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
19 int32_t svcControlProcessMemory(uint32_t process, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
21 int32_t threadCreate(void *(*entrypoint)(void*), void* arg, size_t stack_size, int32_t prio, int32_t affinity, bool detached);
22 int32_t threadJoin(int32_t thread, int64_t timeout_ns);
23 void threadFree(int32_t thread);
24 void threadExit(int32_t rc) __attribute__((noreturn));
26 int32_t svcGetSystemInfo(int64_t* out, uint32_t type, int32_t param);
28 int32_t svcCreateSemaphore(uint32_t *sem, int32_t initial_count, uint32_t max_count);
29 int32_t svcReleaseSemaphore(int32_t *count, uint32_t sem, int32_t release_count);
30 int32_t svcWaitSynchronization(uint32_t handle, int64_t nanoseconds);
32 typedef int32_t LightLock;
34 void LightLock_Init(LightLock* lock);
35 void LightLock_Lock(LightLock* lock);
36 int LightLock_TryLock(LightLock* lock);
37 void LightLock_Unlock(LightLock* lock);
39 int32_t APT_CheckNew3DS(bool *out);
41 int32_t svcBackdoor(int32_t (*callback)(void));
43 #define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
45 void wait_for_input(void);
47 extern __attribute__((weak)) int __ctr_svchax;
51 static void check_rosalina() {
57 if (!svcGetSystemInfo(&version, 0x10000, 0)) {
58 major = GET_VERSION_MAJOR(version);
65 void ctr_clear_cache(void);
67 typedef int32_t (*ctr_callback_type)(void);
69 static inline void ctr_invalidate_ICache_kernel(void)
74 "mcr p15, 0, r0, c7, c5, 0\n\t");
77 static inline void ctr_flush_DCache_kernel(void)
82 "mcr p15, 0, r0, c7, c10, 0\n\t");
85 static inline void ctr_invalidate_ICache(void)
87 svcBackdoor((ctr_callback_type)ctr_invalidate_ICache_kernel);
90 static inline void ctr_flush_DCache(void)
92 svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel);
95 static inline void ctr_flush_invalidate_cache(void)
101 ctr_invalidate_ICache();
105 #endif // _3DS_UTILS_H