mirror of
https://github.com/FunKey-Project/gpsp_libretro.git
synced 2026-03-26 22:02:42 +01:00
(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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user