 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
phobox
Joined: 24 Mar 2008 Posts: 140
|
Posted: Mon Aug 25, 2008 1:59 am Post subject: modular application |
|
|
i want to build a modular application base on various modules, like vsh.
Graphic library will be vlf.
i thought to load modules (in this example Plugin.prx) and call functions stored inside those.
this is the situation:
main module that loads all other submodules + vlf lib.
calling vlf functions from inside the main module is (ofcourse) everything ok.
BUT if i try to call a vlf function from a submodule it doesn't work.
here the main module (main.c)
| Code: |
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspsdk.h>
#include <string.h>
#include <vlf.h>
PSP_MODULE_INFO("VLF_demo", 0x800, 2, 0);
PSP_MAIN_THREAD_ATTR(0);
int addText();
int OnCrossPress(void *param)
{
sceKernelExitGame();
return VLF_EV_RET_REMOVE_HANDLERS;
}
int OnSquarePress(void *param)
{
addText();
return VLF_EV_RET_NOTHING;
}
int app_main()
{
void *bi;
//vlfGuiSetBackgroundPlane(0xFF000000);
vlfGuiSetBackgroundSystem(0);
vlfGuiCacheResource("system_plugin");
vlfGuiCacheResource("system_plugin_fg");
vlfGuiSetModelSystem();
vlfGuiAddBatteryIconSystem(&bi, 10*1000*1000);
vlfGuiAddClock();
vlfGuiAddEventHandler(PSP_CTRL_CROSS, -1, OnCrossPress, NULL);
vlfGuiAddEventHandler(PSP_CTRL_SQUARE, -1, OnSquarePress, NULL);
while (1)
{
vlfGuiDrawFrame();
}
return 0;
}
|
here the makefile of main module
| Code: |
release: all
psppacker 400I VLF_Sample.prx
TARGET = VLF_Sample
OBJS = crt0.o main.o Plugin.o
INCDIR = ./include
CFLAGS = -O2 -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS) -c
LIBDIR = ./lib
LDFLAGS = -mno-crt0 -nostdlib -nodefaultlibs
LIBS = -lvlfgui -lvlfgu -lvlfutils -lvlflibc
BUILD_PRX = 1
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Vlf Sample
PSPSDK=$(shell psp-config --pspsdk-path)
include ./build.mak
|
here crt0.c (main module)
| Code: |
#include <pspsdk.h>
#include <pspkernel.h>
#include <kubridge.h>
#include <stdio.h>
#include <vlf.h>
extern int app_main(int argc, char *argv[]);
int start_thread(SceSize args, void *argp)
{
SceUID mod;
char *path = (char*) argp;
int last_trail = -1;
int i;
if(path)
{
for(i=0; path[i]; i++)
{
if(path[i] == '/')
last_trail = i;
}
}
if (last_trail >= 0)
path[last_trail] = 0;
sceIoChdir(path);
path[last_trail] = '/';
mod = sceKernelLoadModule("iop.prx", 0, NULL);
mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
mod = sceKernelLoadModule("intraFont.prx", 0, NULL);
mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
mod = sceKernelLoadModule("vlf.prx", 0, NULL);
mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
mod = sceKernelLoadModule("Plugin.prx", 0, NULL);
mod = sceKernelStartModule(mod, args, argp, NULL, NULL);
vlfGuiInit(-1, app_main);
return sceKernelExitDeleteThread(0);
}
int module_start(SceSize args, void *argp)
{
SceUID thid = sceKernelCreateThread("start_thread", start_thread, 0x10, 0x4000, 0, NULL);
if (thid < 0)
return thid;
sceKernelStartThread(thid, args, argp);
return 0;
}
|
now the submodules,
in this case a module called Plugin.prx that SHOULD display a text on the screen but it doesn't work (lol)
main.c
| Code: |
#include <pspsdk.h>
#include <pspkernel.h>
#include <vlf.h>
PSP_MODULE_INFO("Plugin", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
u32 k1;
int addText(){
k1 = pspSdkSetK1(0);
vlfGuiAddText(200, 10, "Please display this!");
pspSdkSetK1(k1);
return 0;
}
int module_start(SceSize args, void *argp)
{
return 0;
}
int module_stop()
{
return 0;
}
|
the makefile
| Code: |
TARGET = Plugin
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = exports.exp
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lvlfgui -lvlfgu -lvlfutils -lvlflibc
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
the exports
| Code: |
# 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
# Export our function
PSP_EXPORT_START(Plugin, 0, 0x4001)
PSP_EXPORT_FUNC(addText)
PSP_EXPORT_END
PSP_END_EXPORTS
|
please try to help me solve this problem. _________________ Ciao! from Italy |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Aug 25, 2008 2:01 am Post subject: |
|
|
| You are calling an user function (vlfGuiAddText), from a kernel module. And that doesn't work, the kernel won't ever resolve the library. |
|
| Back to top |
|
 |
phobox
Joined: 24 Mar 2008 Posts: 140
|
Posted: Mon Aug 25, 2008 3:38 am Post subject: |
|
|
| moonlight wrote: | | You are calling an user function (vlfGuiAddText), from a kernel module. And that doesn't work, the kernel won't ever resolve the library. |
so if i convert the kernel module to an user one it will work? i'll try it now
thanks.
EDIT: still don't work.
I changed:
PSP_MODULE_INFO("Plugin", 0, 1, 1);
removed k1 stuff
removed
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
PSP_EXPORT_START(Plugin, 0, 0)
what else should i do? _________________ Ciao! from Italy |
|
| Back to top |
|
 |
phobox
Joined: 24 Mar 2008 Posts: 140
|
Posted: Mon Aug 25, 2008 6:32 am Post subject: |
|
|
sorry for double post.
don't know why i changed PSP_EXPORT_START(Plugin, 0, 0) ...
it should be PSP_EXPORT_START(Plugin, 0, 0x0001) cause a user module is loading an user module.
now i'll try
edit: it is working! i think i was drunk when i changed the params of PSP_EXPORT_START... _________________ Ciao! from Italy |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Aug 25, 2008 7:31 am Post subject: |
|
|
0x0001 -> export to modules with same privileges (resolved with jumps)
0x4001 -> export from kernel to user (resolved with syscalls) |
|
| Back to top |
|
 |
phobox
Joined: 24 Mar 2008 Posts: 140
|
Posted: Mon Aug 25, 2008 7:36 am Post subject: |
|
|
| moonlight wrote: | 0x0001 -> export to modules with same privileges (resolved with jumps)
0x4001 -> export from kernel to user (resolved with syscalls) |
yeah yeah i know.. i read it from the module tuto from this site. thanks anyway...
now a bug for you...
look at the shadow of the battery...
the title bar is called by the plugin module... _________________ Ciao! from Italy |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Aug 25, 2008 8:02 am Post subject: |
|
|
| What is the code? Have you tried to add the battery icon yourself without using vlfGuiAddBatteryIcon? |
|
| Back to top |
|
 |
phobox
Joined: 24 Mar 2008 Posts: 140
|
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Mon Aug 25, 2008 6:19 pm Post subject: |
|
|
The problem is this: vlfGuiSetTitleBar(u, 0, 1, 0);
when it should be vlfGuiSetTitleBar(u, -1, 1, 0);
0 is a valid handler for a picture, and was assigned to the battery shadow internally when calling vlfGuiAddBatteryIconSystem. |
|
| Back to top |
|
 |
phobox
Joined: 24 Mar 2008 Posts: 140
|
Posted: Mon Aug 25, 2008 6:28 pm Post subject: |
|
|
thanks
now i have another problem, it seems that module_start function is not called when the module is started. in that function i load texts and pictures but they result not loaded.
is the problem when loading/starting module? _________________ Ciao! from Italy |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|