4 #define GET_VERSION_MAJOR(version) ((version) >>24)
6 typedef int (*ctr_callback_type)(void);
8 int srvGetServiceHandle(unsigned int* out, const char* name);
9 int svcCloseHandle(unsigned int handle);
10 int svcBackdoor(ctr_callback_type);
11 int32_t svcGetSystemInfo(int64_t* out, uint32_t type, int32_t param);
12 void ctr_clear_cache(void);
14 static int has_rosalina;
16 void check_rosalina(void) {
22 if (!svcGetSystemInfo(&version, 0x10000, 0)) {
23 major = GET_VERSION_MAJOR(version);
30 static void ctr_enable_all_svc_kernel(void)
32 __asm__ volatile("cpsid aif");
34 unsigned int* svc_access_control = *(*(unsigned int***)0xFFFF9000 + 0x22) - 0x6;
36 svc_access_control[0]=0xFFFFFFFE;
37 svc_access_control[1]=0xFFFFFFFF;
38 svc_access_control[2]=0xFFFFFFFF;
39 svc_access_control[3]=0x3FFFFFFF;
42 static void ctr_enable_all_svc(void)
44 svcBackdoor((ctr_callback_type)ctr_enable_all_svc_kernel);
47 static void ctr_clean_invalidate_kernel(void)
51 "cpsid aif\n" // disable interrupts
53 "mcr p15, 0, r0, c7, c10, 0\n" // clean dcache
54 "mcr p15, 0, r0, c7, c10, 4\n" // DSB
55 "mcr p15, 0, r0, c7, c5, 0\n" // invalidate icache+BTAC
56 "msr cpsr_cx, r1\n" // restore interrupts
60 void ctr_flush_invalidate_cache(void)
65 // __asm__ volatile("svc 0x2E\n\t");
66 // __asm__ volatile("svc 0x4B\n\t");
67 svcBackdoor((ctr_callback_type)ctr_clean_invalidate_kernel);
71 int ctr_svchack_init(void)
73 extern unsigned int __ctr_svchax;
74 extern unsigned int __service_ptr;
77 return 1; /* All services have already been enabled */