forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

My prx plugin will not print to screen!

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sun Mar 16, 2008 2:07 am    Post subject: My prx plugin will not print to screen! Reply with quote

All the functions of this plugin will run perfectly, but the plugin never print to
screen! Why?
Or how to printf in kernel mode? I will print "Hello World"

#include <psptypes.h>
#include <pspkernel.h>
#include <string.h>
#include <stdio.h>
#include <pspusb.h>
#include <psppower.h>
#include <pspdisplay.h>
#include <pspdisplay_kernel.h>
#include <pspusbstor.h>

#include "include/systemctrl_se.h"
#include "include/pspmodulemgr_kernel.h"
#include "include/systemctrl.h"
#include <pspsysmem_kernel.h>
#include "include/kubridge.h"

#include "main.h"
#include "translateButtons.h"
#include "blit.h"

PSP_MODULE_INFO("prx plugin", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
PSP_MAIN_THREAD_STACK_SIZE_KB(0);

#define PSP_USBBUS_DRIVERNAME "USBBusDriver"
#define PSP_USBSTOR_DRIVERNAME "USBStor_Driver"
#define PSP_USB_ACTIVATED 0x200

char strMsg[128];

int showMsg = 0;
int showHelp = 1;

int menuDone = 0;

int usePspSlim = 0;

char fullpath[30][128];
int num = 0;

int usbIsInit = 0;
int usbIsActivate = 0;

SceCtrlData pad;
SceCtrlData padIso;
unsigned int pad_old;

SceUID main_thid;
SceUID display_thid;

int build_args(char *args, const char *execfile, int argc, char **argv)
{
int loc = 0;
int i;

strcpy(args, execfile);
loc += strlen(execfile) + 1;
for(i = 0; i < argc; i++)
{
strcpy(&args[loc], argv[i]);
loc += strlen(argv[i]) + 1;
}

return loc;
}

int doBlit(char *msg)
{
strcpy(strMsg, msg);
showMsg=1;
return 0;
}

int loadStartModule(const char *name, int argc, char **argv)
{
SceUID modid;
int status;
char args[128];
int len;

modid = sceKernelLoadModule(name, 0, NULL);
if(modid >= 0)
{
len = build_args(args, name, argc, argv);
modid = sceKernelStartModule(modid, len, (void *) args, &status, NULL);
char tmp[32];
strcpy(tmp, "module loaded : ");
strcat(tmp, name);
doBlit(tmp);
}
else
{
char tmp[32];
strcpy(tmp, "lsm: Error loading module ");
strcat(tmp, name);
doBlit(tmp);
printf("lsm: Error loading module %s\n", name);
}

return modid;
}

int unloadStopModule(char *modname)
{
SceModule *mod;
while ((mod = sceKernelFindModuleByName(modname)))
{
sceKernelStopModule(mod->modid, 0, NULL, NULL, NULL);
sceKernelUnloadModule(mod->modid);
}

return 0;

}

int display_thread(SceSize args, void *argp)
{
while(1)
{
if(showMsg)
{
blit_string(1,33,strMsg,0xffffff,0x000000);
showMsg++;
if(showMsg==600) showMsg=0;
}

if(showHelp)
{
blit_string(1, 9, "PRX Plugin v0.1",0xffffff,0x000000);
blit_string(1, 10, "==========================================",0xffffff,0x000000);
blit_string(1, 12, "NOTE + HOME = Shutdown PSP",0xffffff,0x000000);
blit_string(1, 20, "NOTE + DOWN = Set Max Brightness",0xffffff,0x000000);
blit_string(1, 22, "NOTE + L = Start/Stop Usb Mass",0xffffff,0x000000);
blit_string(1, 28, "NOTE + VOL_DOWN = Show this help",0xffffff,0x000000);
blit_string(1, 30, "Circle = Hide This Help",0xffffff,0x000000);
}

sceKernelDelayThread(2000);
}
return 0;
}

int helpMenu()
{
menuDone=0;

while(!menuDone)
{
showHelp=1;

sceDisplayWaitVblankStart();

sceCtrlPeekBufferPositive(&pad, 1);
if (pad.Buttons != pad_old)
{
if(pad.Buttons & PSP_CTRL_CIRCLE)
{
showHelp=0;
menuDone=1;
}
}
}
pad_old = pad.Buttons;
sceKernelDelayThread(1000);
return 0;
}

void setBrightness(int x)
{
sceDisplaySetBrightness(x,0);
blit_string(1, 30, "Circle = Hide This Help",0xffffff,0x000000);
}

int usbInit(){

u32 retVal;

//start necessary drivers
loadStartModule("flash0:/kd/chkreg.prx", 0, NULL);
loadStartModule("flash0:/kd/npdrm.prx", 0, NULL);
loadStartModule("flash0:/kd/semawm.prx", 0, NULL);
loadStartModule("flash0:/kd/usbstor.prx", 0, NULL);
loadStartModule("flash0:/kd/usbstormgr.prx", 0, NULL);
loadStartModule("flash0:/kd/usbstorms.prx", 0, NULL);
loadStartModule("flash0:/kd/usbstorboot.prx", 0, NULL);

//setup USB drivers
retVal = sceUsbStart(PSP_USBBUS_DRIVERNAME, 0, 0);
if (retVal != 0) {
return -6;
}

retVal = sceUsbStart(PSP_USBSTOR_DRIVERNAME, 0, 0);
if (retVal != 0) {
return -7;
}

retVal = sceUsbstorBootSetCapacity(0x800000);
if (retVal != 0) {
return -8;
}

return 0;
}

int usbActivate()
{
sceUsbActivate(0x1c8);
return 0;
}

int usbDeactivate()
{
sceUsbDeactivate(0x1c8);
sceIoDevctl("fatms0:", 0x0240D81E, NULL, 0, NULL, 0 ); //Avoid corrupted files
return 0;
}

int loadUsb(){
if(!usbIsInit)
{
usbInit();
sceKernelDelayThread(10000);
usbActivate();
usbIsInit=1;
usbIsActivate=1;
}
else
{
if(usbIsActivate)
{
usbDeactivate();
usbIsActivate=0;
}
else
{
usbActivate();
usbIsActivate=1;
}
}
}

int threadMain(SceSize args, void *argp)
{
sceKernelDelayThread(10000);

while(!translateButtons()) {
printf("waiting\n");
}

while(1) {

//cleanBeforeExit();

sceCtrlPeekBufferPositive(&pad, 1);

if (pad.Buttons != pad_old)
{
if((pad.Buttons & (PSP_CTRL_HOME | PSP_CTRL_NOTE)) == (PSP_CTRL_HOME | PSP_CTRL_NOTE))
{
doBlit("Standby requested");
scePowerRequestStandby();
}

if((pad.Buttons & (PSP_CTRL_DOWN | PSP_CTRL_NOTE)) == (PSP_CTRL_DOWN | PSP_CTRL_NOTE))
{
setBrightness(99);
doBlit("Brightness set to maximum value");
}

if((pad.Buttons & (PSP_CTRL_VOLDOWN | PSP_CTRL_NOTE)) == (PSP_CTRL_VOLDOWN | PSP_CTRL_NOTE))
{
helpMenu();
}

if((pad.Buttons & (PSP_CTRL_LTRIGGER | PSP_CTRL_NOTE)) == (PSP_CTRL_LTRIGGER | PSP_CTRL_NOTE))
{
loadUsb();
}

}
pad_old = pad.Buttons;
sceKernelDelayThread(1000);
}
return 0;
}

int module_start(SceSize args, void *argp)
{

display_thid = sceKernelCreateThread("prx_plugin_display", display_thread, 8, 0x200, 0, NULL);
if(display_thid >= 0) sceKernelStartThread(display_thid, args, argp);

main_thid = sceKernelCreateThread("prx_plugin_main", threadMain, 6, 0x800, 0, NULL);
if(main_thid >= 0) sceKernelStartThread(main_thid, args, argp);

return 0;

sceKernelExitDeleteThread(0);
}

int module_stop(SceSize args, void *argp)
{
return 0;
}

I use blit library to print text, can i use other library to printf in a plugin?

Makefile:

TARGET = prx_plugin
OBJS = main.o translateButtons.o blit.o scr_printf.o

BUILD_PRX=1
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1

INCDIR = include
CFLAGS = -Os -G0 -Wall -fno-strict-aliasing -fno-builtin-printf -D_PSPSLIM
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR = lib
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspsystemctrl_kernel -lpspusb -lpsppower -lpspusbstor -lpspdebug

include $(PSPSDK)/lib/build_prx.mak



Please, help me...
Back to top
View user's profile Send private message
Question_dev



Joined: 24 Aug 2007
Posts: 88

PostPosted: Sat May 17, 2008 2:14 am    Post subject: Reply with quote

You have to call fisrt (before printing)

Code:
blit_setup();



Cu
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sat May 17, 2008 10:51 pm    Post subject: Reply with quote

o, thanks but i've already resolved, it's a old post...
_________________
Get Xplora!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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