app: Load kernel plugins from memory

This commit is contained in:
Joel16 2022-05-31 10:57:03 -04:00
parent 98cc6d93b7
commit 4f10474794
6 changed files with 53 additions and 28 deletions

View File

@ -20,18 +20,6 @@ jobs:
- name: Compile project - name: Compile project
run: make run: make
- uses: actions/upload-artifact@v2
with:
path: audio_driver/audio_driver.prx
- uses: actions/upload-artifact@v2
with:
path: display_driver/display_driver.prx
- uses: actions/upload-artifact@v2
with:
path: fs_driver/fs_driver.prx
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
path: app/EBOOT.PBP path: app/EBOOT.PBP

View File

@ -1,14 +1,15 @@
TARGET = CMFileManager TARGET = CMFileManager
SOURCES := data drivers source source/audio source/gui ../libs/libnsbmp ../libs/libnsgif SOURCES := data drivers source source/audio source/gui ../libs/libnsbmp ../libs/libnsgif
CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c)) CFILES := $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
SFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.S)) SFILES := $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.S))
CPPFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.cpp)) CPPFILES := $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))
GFXFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.png)) FONTFILES := $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.pgf))
FONTFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.pgf)) GFXFILES := $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.png))
PRXFILES := $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.prx))
OBJS := $(addsuffix .o,$(BINFILES)) \ OBJS := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(SFILES:.S=.o) $(CPPFILES:.cpp=.o) \
$(CFILES:.c=.o) $(SFILES:.S=.o) $(CPPFILES:.cpp=.o) $(GFXFILES:.png=.o) $(FONTFILES:.pgf=.o) $(FONTFILES:.pgf=.o) $(GFXFILES:.png=.o) $(PRXFILES:.prx=.o)
VERSION_MAJOR := 4 VERSION_MAJOR := 4
VERSION_MINOR := 1 VERSION_MINOR := 1
@ -30,15 +31,18 @@ LIBS = -lintrafont -lglib2d -lxmp -lmpg123 -lvorbisfile -lvorbis -lopusfile -
-lpspkubridge -lpspsystemctrl_user -lpspusbdevice \ -lpspkubridge -lpspsystemctrl_user -lpspusbdevice \
-lpspgu -lpspvram -lpspaudio -lpsppower -lpspreg -lpspusb -lpspusbstor -lpspumd -lpspgu -lpspvram -lpspaudio -lpsppower -lpspreg -lpspusb -lpspusbstor -lpspumd
EXTRA_TARGETS = EBOOT.PBP EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = CM File Manager PSP v$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_MICRO) PSP_EBOOT_TITLE = CM File Manager PSP v$(VERSION_MAJOR).$(VERSION_MINOR)$(VERSION_MICRO)
PSP_EBOOT_ICON = ../ICON0.PNG PSP_EBOOT_ICON = ../ICON0.PNG
PSPSDK=$(shell psp-config --pspsdk-path) PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak include $(PSPSDK)/lib/build.mak
%.o: %.pgf
bin2o -i $< $@ $(addsuffix _pgf, $(basename $(notdir $<) ))
%.o: %.png %.o: %.png
bin2o -i $< $@ $(addsuffix _png, $(basename $(notdir $<) )) bin2o -i $< $@ $(addsuffix _png, $(basename $(notdir $<) ))
%.o: %.pgf %.o: %.prx
bin2o -i $< $@ $(addsuffix _pgf, $(basename $(notdir $<) )) bin2o -i $< $@ $(addsuffix _prx, $(basename $(notdir $<) ))

View File

@ -21,6 +21,9 @@ enum PspCtrlButtons PSP_CTRL_ENTER, PSP_CTRL_CANCEL;
BROWSE_STATE device = BROWSE_STATE_EXTERNAL; BROWSE_STATE device = BROWSE_STATE_EXTERNAL;
int g_psp_language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH; int g_psp_language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
extern unsigned char audio_driver_prx_start[], display_driver_prx_start[], fs_driver_prx_start[];
extern unsigned int audio_driver_prx_size, display_driver_prx_size, fs_driver_prx_size;
namespace Utils { namespace Utils {
constexpr unsigned int CTRL_DEADZONE_DELAY = 500000; constexpr unsigned int CTRL_DEADZONE_DELAY = 500000;
constexpr unsigned int CTRL_DELAY = 100000; constexpr unsigned int CTRL_DELAY = 100000;
@ -34,12 +37,14 @@ namespace Utils {
typedef struct { typedef struct {
const char *path = nullptr; const char *path = nullptr;
int id = 0; int id = 0;
unsigned char *data = nullptr;
unsigned int size = 0;
} Module; } Module;
static std::vector<Module> kernel_modules { static std::vector<Module> kernel_modules {
{ "audio_driver.prx", -1, }, { "audio_driver.prx", -1, audio_driver_prx_start, audio_driver_prx_size },
{ "display_driver.prx", -1, }, { "display_driver.prx", -1, display_driver_prx_start, display_driver_prx_size },
{ "fs_driver.prx", -1, } { "fs_driver.prx", -1, fs_driver_prx_start, fs_driver_prx_size }
}; };
static std::vector<Module> usb_modules { static std::vector<Module> usb_modules {
@ -110,6 +115,31 @@ namespace Utils {
return ret; return ret;
} }
// Basically removes and re-creates prx from memory -> then remove it after inital load
static int LoadStartModuleMem(const char *path, const void *buf, SceSize size) {
int ret = 0;
SceUID modID = 0;
// Don't care if this passes or fails
sceIoRemove(path);
SceUID file = sceIoOpen(path, PSP_O_WRONLY | PSP_O_CREAT, 0777);
sceIoWrite(file, buf, size);
sceIoClose(file);
if (R_FAILED(ret = modID = kuKernelLoadModule(path, 0, nullptr))) {
Log::Error("kuKernelLoadModule(%s) failed: 0x%08x\n", path, ret);
return ret;
}
if (R_FAILED(ret = sceKernelStartModule(modID, 0, nullptr, nullptr, nullptr))) {
Log::Error("sceKernelStartModule(%s) failed: 0x%08x\n", path, ret);
return ret;
}
sceIoRemove(path);
return 0;
}
static void StopUnloadModules(SceUID modID) { static void StopUnloadModules(SceUID modID) {
sceKernelStopModule(modID, 0, nullptr, nullptr, nullptr); sceKernelStopModule(modID, 0, nullptr, nullptr, nullptr);
sceKernelUnloadModule(modID); sceKernelUnloadModule(modID);
@ -216,7 +246,7 @@ namespace Utils {
void InitKernelDrivers(void) { void InitKernelDrivers(void) {
for (unsigned int i = 0; i < kernel_modules.size(); ++i) for (unsigned int i = 0; i < kernel_modules.size(); ++i)
kernel_modules[i].id = Utils::LoadStartModule(kernel_modules[i].path); kernel_modules[i].id = Utils::LoadStartModuleMem(kernel_modules[i].path, kernel_modules[i].data, kernel_modules[i].size);
Utils::InitUSB(); Utils::InitUSB();
} }

View File

@ -24,3 +24,4 @@ include $(PSPSDK)/lib/build_prx.mak
all: all:
psp-build-exports -s $(PRX_EXPORTS) psp-build-exports -s $(PRX_EXPORTS)
mv audio_driver.S "../app/drivers/" mv audio_driver.S "../app/drivers/"
mv audio_driver.prx "../app/data/"

View File

@ -24,3 +24,4 @@ include $(PSPSDK)/lib/build_prx.mak
all: all:
psp-build-exports -s $(PRX_EXPORTS) psp-build-exports -s $(PRX_EXPORTS)
mv display_driver.S "../app/drivers/" mv display_driver.S "../app/drivers/"
mv display_driver.prx "../app/data/"

View File

@ -24,3 +24,4 @@ include $(PSPSDK)/lib/build_prx.mak
all: all:
psp-build-exports -s $(PRX_EXPORTS) psp-build-exports -s $(PRX_EXPORTS)
mv fs_driver.S "../app/drivers/" mv fs_driver.S "../app/drivers/"
mv fs_driver.prx "../app/data/"