forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PSP) add support for kernel-mode functions through a loadable module.
- Loading branch information
1 parent
9a2ee92
commit b185fc3
Showing
8 changed files
with
162 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
TARGET = kernelFunctions | ||
OBJS = main.o | ||
PSP_FW_VERSION = 150 | ||
|
||
INCDIR = | ||
CFLAGS = -O2 -G0 -Wall | ||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti | ||
ASFLAGS = $(CFLAGS) | ||
|
||
BUILD_PRX = 1 | ||
PRX_EXPORTS = $(TARGET).exp | ||
|
||
USE_KERNEL_LIBC=1 | ||
USE_KERNEL_LIBS=1 | ||
|
||
LIBDIR = | ||
LDFLAGS = -mno-crt0 -nostartfiles | ||
LIBS = -lpspdebug -lpspge -lpspsdk -lc -lpspuser | ||
PSPSDK=$(shell psp-config --pspsdk-path) | ||
include $(PSPSDK)/lib/build.mak | ||
|
||
all: | ||
psp-build-exports -s $(PRX_EXPORTS) | ||
cp $(TARGET).prx ../../$(TARGET).prx | ||
cp $(TARGET).S ../$(TARGET).S | ||
cp $(TARGET).h ../$(TARGET).h | ||
rm -f $(TARGET).prx | ||
rm -f $(TARGET).S | ||
rm -f *.o | ||
rm -f *.elf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Define the exports for the prx | ||
PSP_BEGIN_EXPORTS | ||
|
||
# These four lines are mandatory (although you can add other functions like module_stop) | ||
# syslib is a psynonym for the single mandatory export. | ||
PSP_EXPORT_START(syslib, 0, 0x8000) | ||
PSP_EXPORT_FUNC_HASH(module_start) | ||
PSP_EXPORT_VAR_HASH(module_info) | ||
PSP_EXPORT_END | ||
|
||
PSP_EXPORT_START(kernelFunctions, 0, 0x4001) | ||
PSP_EXPORT_FUNC(readSystemButtons) | ||
PSP_EXPORT_FUNC(loadGame) | ||
PSP_EXPORT_END | ||
|
||
PSP_END_EXPORTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef SYSTEMBUTTONS_PRX_H | ||
#define SYSTEMBUTTONS_PRX_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
unsigned int readSystemButtons(void); | ||
void loadGame( const char* fileName, void * argp); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* SYSTEMBUTTONS_PRX_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include <stdio.h> | ||
|
||
#include <pspdebug.h> | ||
#include <pspsdk.h> | ||
#include <pspctrl.h> | ||
#include <psploadexec_kernel.h> | ||
#include <pspthreadman_kernel.h> | ||
#include <string.h> | ||
|
||
PSP_MODULE_INFO("kernelFunctions", PSP_MODULE_KERNEL, 0, 0); | ||
PSP_MAIN_THREAD_ATTR(0); | ||
|
||
|
||
static volatile int thread_active; | ||
static unsigned int buttons; | ||
static SceUID main_thread; | ||
|
||
static int mainThread(SceSize args, void *argp) | ||
{ | ||
SceCtrlData paddata; | ||
|
||
thread_active = 1; | ||
|
||
while (thread_active) | ||
{ | ||
sceCtrlPeekBufferPositive(&paddata, 1); | ||
buttons = paddata.Buttons; | ||
sceKernelDelayThread(1000000/60); | ||
} | ||
|
||
sceKernelExitThread(0); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
unsigned int readSystemButtons(void) | ||
{ | ||
return buttons; | ||
} | ||
|
||
void loadGame(const char* fileName, void * argp){ | ||
thread_active = 0; | ||
struct SceKernelLoadExecVSHParam game_param; | ||
pspDebugScreenClear(); | ||
|
||
memset(&game_param,0,sizeof(game_param)); | ||
|
||
game_param.size = sizeof(game_param); | ||
game_param.args = strlen(argp)+1; | ||
game_param.argp = argp; | ||
game_param.key = "game"; | ||
game_param.vshmain_args_size = 0; | ||
game_param.vshmain_args = NULL; | ||
game_param.configfile = 0; | ||
game_param.unk4 = 0; | ||
game_param.unk5 = 0x10000; | ||
|
||
pspSdkSetK1(0); | ||
sceKernelSuspendAllUserThreads(); | ||
sceKernelLoadExecVSHMs2(fileName, &game_param); | ||
} | ||
|
||
int module_start(SceSize args, void *argp) | ||
{ | ||
(void)args; | ||
(void)argp; | ||
|
||
buttons = 0; | ||
thread_active = 0; | ||
main_thread = sceKernelCreateThread("main Thread", mainThread, 0x11, 0x200, 0, NULL); | ||
|
||
if (main_thread >= 0) | ||
sceKernelStartThread(main_thread, 0, 0); | ||
|
||
return 0; | ||
} | ||
|
||
|
||
int module_stop(void) | ||
{ | ||
if (main_thread >= 0) | ||
{ | ||
thread_active = 0; | ||
sceKernelWaitThreadEnd(main_thread, NULL); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters