diff --git a/app/main.c b/app/main.c index 9d14a51..5553dfc 100644 --- a/app/main.c +++ b/app/main.c @@ -83,9 +83,11 @@ int getFileSize(const char *file) { void main() { psvDebugScreenInit(); - if(vshSblAimgrIsDEX() == 0) + + + if(vshSblAimgrIsCEX()) { - printf("This is not a testing kit . . . \n"); + printf("This is not a test/dev kit . . . \n"); get_key(); sceKernelExitProcess(0); } @@ -229,46 +231,58 @@ void main() { printf("Done, backup at pd0:/data and ux0:/data\n"); - printf("Calculating PSTime: "); - unsigned long long int timestamp; - memset(×tamp,0,sizeof(unsigned long long int)); - timestamp = *((unsigned int*)&startDate); - timestamp = ((timestamp * 1000) + 62135596800000) * 1000; - - - printf("%llx\n",timestamp); - - printf("Creating splits..\n"); - char hexint[15]; - memset(hexint,0,15); - - sprintf(hexint,"%llx",timestamp); - - char ts1[7] = {hexint[0],hexint[1],hexint[2],hexint[3],hexint[4],hexint[5],0x00}; - unsigned long long int split1 = (unsigned int)strtoul(ts1, NULL, 16); - printf("Split1: %llx\n",split1); - - - char ts2[10] = {hexint[6],hexint[7],hexint[8],hexint[9],hexint[10],hexint[11],hexint[12],hexint[13],hexint[14],0x00}; - unsigned long long int split2 = (unsigned int)strtoul(ts2, NULL, 16); - printf("Split2: %llx\n",split2); - - printf("Updating SecureTick.. "); - - ret = silRtcSetCurrentSecureTick(split2,split1); - sceRegMgrSetKeyInt("/CONFIG/DATE", "set_automatically", 0); - - printf("has ret 0x%x\n",ret); + if(vshSblAimgrIsTool()) + { + unsigned int timestamp = *((unsigned int*)&startDate); + printf("Updating CPRTC to %x\n",timestamp); + ret = silSblPostSsMgrSetCpRtc(timestamp); + sceRegMgrSetKeyInt("/CONFIG/DATE", "set_automatically", 0); + printf("has ret 0x%x\n",ret); + } + else if(vshSblAimgrIsDEX()) + { + printf("Calculating PSTime: "); + unsigned long long int timestamp; + memset(×tamp,0,sizeof(unsigned long long int)); + timestamp = *((unsigned int*)&startDate); + timestamp = ((timestamp * 1000) + 62135596800000) * 1000; + + + printf("%llx\n",timestamp); + + printf("Creating splits..\n"); + char hexint[15]; + memset(hexint,0,15); + + sprintf(hexint,"%llx",timestamp); + + char ts1[7] = {hexint[0],hexint[1],hexint[2],hexint[3],hexint[4],hexint[5],0x00}; + unsigned long long int split1 = (unsigned int)strtoul(ts1, NULL, 16); + printf("Split1: %llx\n",split1); + + + char ts2[10] = {hexint[6],hexint[7],hexint[8],hexint[9],hexint[10],hexint[11],hexint[12],hexint[13],hexint[14],0x00}; + unsigned long long int split2 = (unsigned int)strtoul(ts2, NULL, 16); + printf("Split2: %llx\n",split2); + + printf("Updating SecureTick.. "); + + ret = silRtcSetCurrentSecureTick(split2,split1); + sceRegMgrSetKeyInt("/CONFIG/DATE", "set_automatically", 0); + + printf("has ret 0x%x\n",ret); + } + if(ret == 0) { - printf("\n\nYour PSVITA Testing Kit has been activated!\n"); + printf("\n\nYour PSVITA Test/Dev Kit has been activated!\n"); printf("\n"); printf("Deactivate by holding START + SELECT + PS + POWER\n\n"); - printf("Press any key to reboot console"); + printf("Press any key to turn off console"); get_key(); - scePowerRequestColdReset(); + scePowerRequestSuspend(); } else { diff --git a/app/rtcUserBridge.h b/app/rtcUserBridge.h index b89f4ec..60bc83d 100644 --- a/app/rtcUserBridge.h +++ b/app/rtcUserBridge.h @@ -1,3 +1,4 @@ int silRtcSetCurrentTick(unsigned int timestamp1, unsigned int timestamp2); int silRtcSetCurrentNetworkTick(unsigned int timestamp1, unsigned int timestamp2); -int silRtcSetCurrentSecureTick(unsigned int timestamp1, unsigned int timestamp2); \ No newline at end of file +int silRtcSetCurrentSecureTick(unsigned int timestamp1, unsigned int timestamp2); +int silSblPostSsMgrSetCpRtc(unsigned int timestamp); \ No newline at end of file diff --git a/kern/CMakeLists.txt b/kern/CMakeLists.txt index 696b39d..11f27ae 100644 --- a/kern/CMakeLists.txt +++ b/kern/CMakeLists.txt @@ -31,6 +31,7 @@ target_link_libraries(${PROJECT_NAME} SceDebugForDriver_stub SceSysmem_stub SceRtcForDriver_stub + SceSblPostSsMgrForDriver_stub SceCpuForDriver_stub taihenForKernel_stub gcc @@ -47,5 +48,6 @@ vita_create_stubs(${PROJECT_NAME}-stubs ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/expo install(DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-stubs/ DESTINATION lib FILES_MATCHING PATTERN "*.a" + ) diff --git a/kern/exports.yml b/kern/exports.yml index 9f8961b..2cdaf11 100644 --- a/kern/exports.yml +++ b/kern/exports.yml @@ -12,4 +12,5 @@ kern_clockset: functions: - ksilRtcSetCurrentSecureTick - ksilRtcSetCurrentNetworkTick - - ksilRtcSetCurrentTick \ No newline at end of file + - ksilRtcSetCurrentTick + - ksilSblPostSsMgrSetCpRtc \ No newline at end of file diff --git a/kern/kern_clockset.c b/kern/kern_clockset.c index 28aaa9c..02ced24 100644 --- a/kern/kern_clockset.c +++ b/kern/kern_clockset.c @@ -6,15 +6,14 @@ * */ - - #include #include #include #include #include +#include "rtc.h" -int ksilRtcSetCurrentTick(timestamp1,timestamp2) +int ksilRtcSetCurrentTick(unsigned int timestamp1,unsigned int timestamp2) { unsigned int timestamp[2]; @@ -24,7 +23,7 @@ int ksilRtcSetCurrentTick(timestamp1,timestamp2) return ksceRtcSetCurrentTick(timestamp); } -int ksilRtcSetCurrentNetworkTick(timestamp1,timestamp2) +int ksilRtcSetCurrentNetworkTick(unsigned int timestamp1,unsigned int timestamp2) { unsigned int timestamp[2]; @@ -34,7 +33,7 @@ int ksilRtcSetCurrentNetworkTick(timestamp1,timestamp2) return ksceRtcSetCurrentNetworkTick(timestamp); } -int ksilRtcSetCurrentSecureTick(timestamp1,timestamp2) +int ksilRtcSetCurrentSecureTick(unsigned int timestamp1,unsigned int timestamp2) { unsigned int timestamp[2]; @@ -44,6 +43,11 @@ int ksilRtcSetCurrentSecureTick(timestamp1,timestamp2) return ksceRtcSetCurrentSecureTick(timestamp); } +int ksilSblPostSsMgrSetCpRtc(unsigned int timestamp) +{ + return ksceSblPostSsMgrSetCpRtc(timestamp); +} + void _start() __attribute__ ((weak, alias ("module_start"))); diff --git a/kern/rtc.h b/kern/rtc.h new file mode 100644 index 0000000..2f22a45 --- /dev/null +++ b/kern/rtc.h @@ -0,0 +1,5 @@ +int ksceRtcSetCurrentTick(unsigned int* timestamp); +int ksceRtcSetCurrentNetworkTick(unsigned int* timestamp); +int ksceRtcSetCurrentSecureTick(unsigned int* timestamp); + +int ksceSblPostSsMgrSetCpRtc(unsigned int timestamp); \ No newline at end of file diff --git a/kern/rtcKernelBridge.h b/kern/rtcKernelBridge.h new file mode 100644 index 0000000..24949a8 --- /dev/null +++ b/kern/rtcKernelBridge.h @@ -0,0 +1,4 @@ +int ksilRtcSetCurrentTick(unsigned int timestamp1, unsigned int timestamp2); +int ksilRtcSetCurrentNetworkTick(unsigned int timestamp1, unsigned int timestamp2); +int ksilRtcSetCurrentSecureTick(unsigned int timestamp1, unsigned int timestamp2); +int ksilSblPostSsMgrSetCpRtc(unsigned int timestamp); \ No newline at end of file diff --git a/user/exports.yml b/user/exports.yml index ee0598a..9e2f3a0 100644 --- a/user/exports.yml +++ b/user/exports.yml @@ -13,3 +13,4 @@ user_clockset: - silRtcSetCurrentNetworkTick - silRtcSetCurrentTick - silRtcSetCurrentSecureTick + - silSblPostSsMgrSetCpRtc diff --git a/user/rtcKernelBridge.h b/user/rtcKernelBridge.h new file mode 100644 index 0000000..24949a8 --- /dev/null +++ b/user/rtcKernelBridge.h @@ -0,0 +1,4 @@ +int ksilRtcSetCurrentTick(unsigned int timestamp1, unsigned int timestamp2); +int ksilRtcSetCurrentNetworkTick(unsigned int timestamp1, unsigned int timestamp2); +int ksilRtcSetCurrentSecureTick(unsigned int timestamp1, unsigned int timestamp2); +int ksilSblPostSsMgrSetCpRtc(unsigned int timestamp); \ No newline at end of file diff --git a/user/user_clockset.c b/user/user_clockset.c index 5232590..3d42146 100644 --- a/user/user_clockset.c +++ b/user/user_clockset.c @@ -5,23 +5,28 @@ #include #include #include -#include "rtcUserBridge.h" +#include "rtcKernelBridge.h" -int silRtcSetCurrentTick(timestamp1,timestamp2) +int silRtcSetCurrentTick(unsigned int timestamp1, unsigned int timestamp2) { return ksilRtcSetCurrentTick(timestamp1,timestamp2); } -int silRtcSetCurrentNetworkTick(timestamp1,timestamp2) +int silRtcSetCurrentNetworkTick(unsigned int timestamp1, unsigned int timestamp2) { return ksilRtcSetCurrentNetworkTick(timestamp1,timestamp2); } -int silRtcSetCurrentSecureTick(timestamp1,timestamp2) +int silRtcSetCurrentSecureTick(unsigned int timestamp1, unsigned int timestamp2) { return ksilRtcSetCurrentSecureTick(timestamp1,timestamp2); } +int silSblPostSsMgrSetCpRtc(unsigned int timestamp) +{ + return ksilSblPostSsMgrSetCpRtc(timestamp); +} + int module_start(SceSize argc, const void *args) { return SCE_KERNEL_START_SUCCESS;