summaryrefslogtreecommitdiff
path: root/3ds
diff options
context:
space:
mode:
authoraliaspider2015-11-04 15:46:27 +0100
committeraliaspider2015-11-04 15:46:27 +0100
commitf1d14fbe7ce749b613ee2f7071cdfff1de013152 (patch)
tree9b7e838c4c0c879d7a65e4dd65ae0647dc31f068 /3ds
parent6b8417143a395674d7ab0b771060ac36f1e72df5 (diff)
downloadpicogpsp-f1d14fbe7ce749b613ee2f7071cdfff1de013152.tar.gz
picogpsp-f1d14fbe7ce749b613ee2f7071cdfff1de013152.tar.bz2
picogpsp-f1d14fbe7ce749b613ee2f7071cdfff1de013152.zip
(3ds) dynarec: map the translation caches to specific addresses at
runtime, increases compatibility with loaders that can reloacate each program section seperately. move the svc enabling functions to the frontend.
Diffstat (limited to '3ds')
-rw-r--r--3ds/3ds_utils.c59
-rw-r--r--3ds/3ds_utils.h9
2 files changed, 11 insertions, 57 deletions
diff --git a/3ds/3ds_utils.c b/3ds/3ds_utils.c
index aaa9a8a..4f8f9be 100644
--- a/3ds/3ds_utils.c
+++ b/3ds/3ds_utils.c
@@ -1,24 +1,12 @@
-#include "3ds.h"
-#include "libkhax/khax.h"
-
-static int ninjhax_version = 0;
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <3ds.h>
+#include "3ds_utils.h"
typedef s32 (*ctr_callback_type)(void);
-static void ctr_enable_all_svc_kernel(void)
-{
- __asm__ volatile("cpsid aif");
-
- u32* svc_access_control = *(*(u32***)0xFFFF9000 + 0x22) - 0x6;
-
- svc_access_control[0]=0xFFFFFFFE;
- svc_access_control[1]=0xFFFFFFFF;
- svc_access_control[2]=0xFFFFFFFF;
- svc_access_control[3]=0x3FFFFFFF;
-}
-
-
static void ctr_invalidate_ICache_kernel(void)
{
__asm__ volatile(
@@ -36,22 +24,14 @@ static void ctr_flush_DCache_kernel(void)
}
-
-static void ctr_enable_all_svc(void)
-{
- svcBackdoor((ctr_callback_type)ctr_enable_all_svc_kernel);
-}
-
void ctr_invalidate_ICache(void)
{
-// __asm__ volatile("svc 0x2E\n\t");
svcBackdoor((ctr_callback_type)ctr_invalidate_ICache_kernel);
}
void ctr_flush_DCache(void)
{
-// __asm__ volatile("svc 0x4B\n\t");
svcBackdoor((ctr_callback_type)ctr_flush_DCache_kernel);
}
@@ -61,32 +41,3 @@ void ctr_flush_invalidate_cache(void)
ctr_flush_DCache();
ctr_invalidate_ICache();
}
-
-int ctr_svchack_init(void)
-{
- extern unsigned int __service_ptr;
- if(__service_ptr)
- {
- if(hbInit() == 0)
- {
- /* ninjhax 1.0 */
- ninjhax_version = 1;
- hbExit();
- khaxInit();
- return 1;
- }
- ninjhax_version = 2;
- return 0;
- }
- /* CFW */
- ninjhax_version = 0;
- ctr_enable_all_svc();
- return 1;
-}
-
-
-void ctr_svchack_exit(void)
-{
- if (ninjhax_version == 1)
- khaxExit();
-}
diff --git a/3ds/3ds_utils.h b/3ds/3ds_utils.h
index 150c56e..b16f2dc 100644
--- a/3ds/3ds_utils.h
+++ b/3ds/3ds_utils.h
@@ -3,10 +3,13 @@
void ctr_invalidate_ICache(void);
void ctr_flush_DCache(void);
-
void ctr_flush_invalidate_cache(void);
-int ctr_svchack_init(void);
-void ctr_svchack_exit(void);
+extern __attribute((weak)) unsigned int __ctr_svchax;
+
+void wait_for_input();
+#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
+#define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X))
+#define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016llX\n", (u64)(X))
#endif // _3DS_UTILS_H