Skip to content

Commit

Permalink
Update to be buildable with latest vitasdk. Replaces TheOfficialFloW#456
Browse files Browse the repository at this point in the history
  • Loading branch information
isage committed Nov 14, 2024
1 parent 7d382b7 commit 39396d0
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 13 deletions.
Binary file modified bubble/pkg/sce_module/adrenaline_kernel.skprx
Binary file not shown.
Binary file modified bubble/pkg/sce_module/adrenaline_user.suprx
Binary file not shown.
Binary file modified bubble/pkg/sce_module/adrenaline_vsh.suprx
Binary file not shown.
1 change: 1 addition & 0 deletions kernel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ target_link_libraries(adrenaline_kernel
SceSysrootForKernel_stub
SceSysrootForDriver_stub
SceThreadmgrForDriver_stub
SceDebugForDriver_stub
)

vita_create_self(adrenaline_kernel.skprx adrenaline_kernel CONFIG exports.yml UNSAFE)
Expand Down
2 changes: 1 addition & 1 deletion kernel/exports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ AdrenalineKernel:
main:
start: module_start
stop: module_stop
modules:
libraries:
AdrenalineKubridge:
syscall: true
functions:
Expand Down
15 changes: 8 additions & 7 deletions kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <psp2kern/kernel/modulemgr.h>
#include <psp2kern/kernel/threadmgr.h>
#include <psp2kern/kernel/sysmem.h>
#include <psp2kern/kernel/sysroot.h>
#include <psp2kern/kernel/cpu.h>

#include <stdio.h>
Expand Down Expand Up @@ -94,21 +95,21 @@ static int sceCompatSecSetSSRAMAclPatched() {
uint32_t a;

a = 0;
ksceKernelMemcpyUserToKernel(&a, 0x70FC0000, sizeof(uint32_t));
ksceKernelMemcpyUserToKernel(&a, (void*)0x70FC0000, sizeof(uint32_t));

if (a != 0) {
// jal 0x88FC0000
a = 0x0E3F0000;
if (module_nid == 0x8F2D0378) { // 3.60 retail
ksceKernelMemcpyKernelToUser(0x70602D58, &a, sizeof(uint32_t));
ksceKernelCpuDcacheWritebackRange((void *)0x70602D58, sizeof(uint32_t));
ksceKernelMemcpyKernelToUser((void*)0x70602D58, &a, sizeof(uint32_t));
ksceKernelDcacheCleanRangeForL1WBWA((void *)0x70602D58, sizeof(uint32_t));
} else if (module_nid == 0x07937779 ||
module_nid == 0x71BF9CC5 ||
module_nid == 0x7C185186 ||
module_nid == 0x52DFE3A7 ||
module_nid == 0xE0E3AA51) { // 3.65-3.70 retail
ksceKernelMemcpyKernelToUser(0x70602D70, &a, sizeof(uint32_t));
ksceKernelCpuDcacheWritebackRange((void *)0x70602D70, sizeof(uint32_t));
ksceKernelMemcpyKernelToUser((void*)0x70602D70, &a, sizeof(uint32_t));
ksceKernelDcacheCleanRangeForL1WBWA((void *)0x70602D70, sizeof(uint32_t));
}
}

Expand All @@ -124,7 +125,7 @@ static int ksceKernelStartPreloadedModulesPatched(SceUID pid) {
int res = TAI_CONTINUE(int, ksceKernelStartPreloadedModulesRef, pid);

char titleid[32];
ksceKernelGetProcessTitleId(pid, titleid, sizeof(titleid));
ksceKernelSysrootGetProcessTitleId(pid, titleid, sizeof(titleid));

if (strcmp(titleid, "main") == 0) {
ksceKernelLoadStartModuleForPid(pid, "ux0:app/" ADRENALINE_TITLEID "/sce_module/adrenaline_vsh.suprx", 0, NULL, 0, NULL, NULL);
Expand All @@ -151,7 +152,7 @@ int kuCtrlPeekBufferPositive(int port, SceCtrlData *pad_data, int count) {
// restore cpu offset
asm volatile ("mcr p15, 0, %0, c13, c0, 4" :: "r" (off));

ksceKernelMemcpyKernelToUser((uintptr_t)pad_data, &pad, sizeof(SceCtrlData));
ksceKernelMemcpyKernelToUser((void*)pad_data, &pad, sizeof(SceCtrlData));

EXIT_SYSCALL(state);
return res;
Expand Down
1 change: 1 addition & 0 deletions user/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ target_link_libraries(adrenaline_user
SceKernelThreadMgr_stub
SceLibKernel_stub
SceMtpIfDriver_stub
SceNet_stub_weak
ScePgf_stub_weak
ScePower_stub
SceProcessmgr_stub
Expand Down
2 changes: 1 addition & 1 deletion user/msfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ static int ScePspemuMsfsExtraDread(ScePspemuMsfsDescriptor *descriptor, SceIoDir

ScePspemuMsfsGetstat(descriptor->path, &dir->d_stat);

dir->d_stat.st_mode = (SCE_S_IFDIR | SCE_S_IRWXO | SCE_S_IRWXG | SCE_S_IRWXU);
dir->d_stat.st_mode = (SCE_S_IFDIR | SCE_S_IRWXS | SCE_S_IRWXG | SCE_S_IRWXU);
dir->d_stat.st_attr = SCE_SO_IFDIR;

return 1;
Expand Down
13 changes: 13 additions & 0 deletions user/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,26 @@ void _init_vita_reent(void);
void _init_vita_malloc(void);
void _init_vita_io(void);

void _free_vita_heap(void);
void _free_vita_reent(void);
void _free_vita_malloc(void);
void _free_vita_io(void);

void _init_vita_newlib(void) {
_init_vita_heap();
_init_vita_reent();
_init_vita_malloc();
_init_vita_io();
}

void _free_vita_newlib(void)
{
_free_vita_io();
_free_vita_malloc();
_free_vita_reent();
_free_vita_heap();
}

int debugPrintf(char *text, ...) {
va_list list;
char string[512];
Expand Down
1 change: 1 addition & 0 deletions user/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern Pad old_pad, current_pad, pressed_pad, released_pad, hold_pad, hold2_pad;
extern Pad hold_count, hold2_count;

void _init_vita_newlib(void);
void _free_vita_newlib(void);

int debugPrintf(char *text, ...);
int ReadFile(char *file, void *buf, int size);
Expand Down
4 changes: 3 additions & 1 deletion vsh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
project(adrenaline_vsh)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostartfiles")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")

add_executable(adrenaline_vsh
Expand All @@ -21,8 +21,10 @@ add_executable(adrenaline_vsh

target_link_libraries(adrenaline_vsh
taihen_stub
SceLibKernel_stub
SceAppMgr_stub
SceLsdb_stub_weak
SceIofilemgr_stub
)

vita_create_self(adrenaline_vsh.suprx adrenaline_vsh CONFIG exports.yml UNSAFE)
Expand Down
2 changes: 1 addition & 1 deletion vsh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static int sceLsdbGetTypePatched(void *a1) {

if (val == 1) { // type normal
char *name = sceLsdbGetName(a1);
if (name && strcmp(name, ADRENALINE_TITLEID) == 0) {
if (name && sceClibStrcmp(name, ADRENALINE_TITLEID) == 0) {
return 2; // type pspemu
}
}
Expand Down
5 changes: 3 additions & 2 deletions vsh/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <psp2/kernel/clib.h>
#include <psp2/kernel/modulemgr.h>
#include <psp2/kernel/sysmem.h>
#include <psp2/io/fcntl.h>
Expand All @@ -29,12 +30,12 @@ int debugPrintf(char *text, ...) {
char string[512];

va_start(list, text);
vsprintf(string, text, list);
sceClibVsnprintf(string, 512, text, list);
va_end(list);

SceUID fd = sceIoOpen("ux0:data/adrenaline_vsh_log.txt", SCE_O_WRONLY | SCE_O_CREAT | SCE_O_APPEND, 0777);
if (fd >= 0) {
sceIoWrite(fd, string, strlen(string));
sceIoWrite(fd, string, sceClibStrnlen(string, 512));
sceIoClose(fd);
}

Expand Down

0 comments on commit 39396d0

Please sign in to comment.