GPU unai update
[pcsx_rearmed.git] / frontend / 3ds / 3ds_utils.h
CommitLineData
fc99395c 1#ifndef _3DS_UTILS_H
2#define _3DS_UTILS_H
3
f72db18e 4#include <stdio.h>
fc99395c 5
f72db18e 6#define MEMOP_PROT 6
7#define MEMOP_MAP 4
8#define MEMOP_UNMAP 5
fc99395c 9
f72db18e 10void* linearMemAlign(size_t size, size_t alignment);
11void linearFree(void* mem);
12
13int32_t svcDuplicateHandle(uint32_t* out, uint32_t original);
14int32_t svcCloseHandle(uint32_t handle);
15int32_t svcControlMemory(void* addr_out, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
16int32_t svcControlProcessMemory(uint32_t process, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm);
17
18int32_t svcCreateThread(int32_t* thread, void *(*entrypoint)(void*), void* arg, void* stack_top, int32_t thread_priority, int32_t processor_id);
19int32_t svcWaitSynchronization(int32_t handle, int64_t nanoseconds);
20void svcExitThread(void) __attribute__((noreturn));
21
22int32_t svcBackdoor(int32_t (*callback)(void));
e4d84733 23
e4d84733 24#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
25
26void wait_for_input(void);
fc99395c 27
f72db18e 28extern __attribute__((weak)) int __ctr_svchax;
29
30typedef int32_t (*ctr_callback_type)(void);
31
32static inline void ctr_invalidate_ICache_kernel(void)
33{
34 __asm__ volatile(
35 "cpsid aif\n\t"
36 "mov r0, #0\n\t"
37 "mcr p15, 0, r0, c7, c5, 0\n\t");
38}
39
40static inline void ctr_flush_DCache_kernel(void)
41{
42 __asm__ volatile(
43 "cpsid aif\n\t"
44 "mov r0, #0\n\t"
45 "mcr p15, 0, r0, c7, c10, 0\n\t");
46}
47
48static inline void ctr_invalidate_ICache(void)
49{
50 svcBackdoor((ctr_callback_type)ctr_invalidate_ICache_kernel);
51}
52
53static inline void ctr_flush_DCache(void)
54{
55 svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel);
56}
57
58
59static inline void ctr_flush_invalidate_cache(void)
60{
61 ctr_flush_DCache();
62 ctr_invalidate_ICache();
63}
64
65
fc99395c 66#endif // _3DS_UTILS_H