X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2F3ds%2F3ds_utils.h;h=75ab63b912957b3004c2383d06792ab71d19e947;hb=1fec8a9574a8128c9b64f79a5c1f72bbd86ac2bf;hp=3d50a6681f053aca0b648be7a4b34381b3a103c2;hpb=f72db18e0c39a5bf115f493767decc409e10f94a;p=pcsx_rearmed.git diff --git a/frontend/3ds/3ds_utils.h b/frontend/3ds/3ds_utils.h index 3d50a668..75ab63b9 100644 --- a/frontend/3ds/3ds_utils.h +++ b/frontend/3ds/3ds_utils.h @@ -2,30 +2,40 @@ #define _3DS_UTILS_H #include +#include +#include <3ds.h> + +#ifdef OS_HEAP_AREA_BEGIN // defined in libctru 2.0+ +#define USE_CTRULIB_2 1 +#endif #define MEMOP_PROT 6 #define MEMOP_MAP 4 #define MEMOP_UNMAP 5 -void* linearMemAlign(size_t size, size_t alignment); -void linearFree(void* mem); +#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) -int32_t svcDuplicateHandle(uint32_t* out, uint32_t original); -int32_t svcCloseHandle(uint32_t handle); -int32_t svcControlMemory(void* addr_out, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm); -int32_t svcControlProcessMemory(uint32_t process, void* addr0, void* addr1, uint32_t size, uint32_t op, uint32_t perm); +void wait_for_input(void); -int32_t svcCreateThread(int32_t* thread, void *(*entrypoint)(void*), void* arg, void* stack_top, int32_t thread_priority, int32_t processor_id); -int32_t svcWaitSynchronization(int32_t handle, int64_t nanoseconds); -void svcExitThread(void) __attribute__((noreturn)); +extern __attribute__((weak)) int __ctr_svchax; -int32_t svcBackdoor(int32_t (*callback)(void)); +static bool has_rosalina; -#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) +static inline void check_rosalina() { + int64_t version; + uint32_t major; -void wait_for_input(void); + has_rosalina = false; -extern __attribute__((weak)) int __ctr_svchax; + if (!svcGetSystemInfo(&version, 0x10000, 0)) { + major = GET_VERSION_MAJOR(version); + + if (major >= 8) + has_rosalina = true; + } +} + +void ctr_clear_cache(void); typedef int32_t (*ctr_callback_type)(void); @@ -55,12 +65,14 @@ static inline void ctr_flush_DCache(void) svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel); } - static inline void ctr_flush_invalidate_cache(void) { - ctr_flush_DCache(); - ctr_invalidate_ICache(); + if (has_rosalina) { + ctr_clear_cache(); + } else { + ctr_flush_DCache(); + ctr_invalidate_ICache(); + } } - #endif // _3DS_UTILS_H