how to let psp reboot ?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

etenia
Posts: 6
Joined: Thu Sep 07, 2006 11:40 pm

Post by etenia »

moonlight wrote:
etenia wrote:Is it possible to reboot the PSP in Usermode?

thanks
scePower_0442D852 can be called in user mode. But since pspsdk doesn't support it yet, you'll have to create the stub yourself.
Ok thanks.
I tried it after I read this topic, and PSPSDK indeed gives an error.
Maybe it's the wrong topic, but how do I create the stub myself?
(I'm new to PSP programming, and to C overall)

If I create a header file

Code: Select all

void scePower_0442D852(int);
I get the following error:
undefined reference to `scePower_0442D852(int)'

I do include the header file.

Code: Select all

#include "scePower.h"
scePower_0442D852(0);
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

you must do a stub in a asm file like the sdk does.
download the pspsdk source and check for example sceAudio.S
or you could use the prx utils to make stub file for other prxs
etenia
Posts: 6
Joined: Thu Sep 07, 2006 11:40 pm

Post by etenia »

Ok, thank you very much.

I need to look more into this, because it doesn't say much to me :)
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

example of stub to firmware:

pspUtility.S(assembly):

Code: Select all

.set noreorder

#include "pspstub.s" //included in pspsdk

STUB_START "sceUtility",0x40010000,0x00240005 
  STUB_FUNC 0xc492f751,sceUtilityGameSharingInitStart 
  STUB_FUNC 0xefc6f80f,sceUtilityGameSharingShutdownStart 
  STUB_FUNC 0x7853182d,sceUtilityGameSharingUpdate 
  STUB_FUNC 0x946963f3,sceUtilityGameSharingGetStatus 
  STUB_FUNC 0x3ad50ae7,sceNetplayDialogInitStart 
  STUB_FUNC 0xbc6b6296,sceNetplayDialogShutdownStart 
  STUB_FUNC 0x417bed54,sceKernelAutomagicallyPlaybackDevice 

... //rest of stubbed functions

STUB_END
pspUtility.h (C code):

Code: Select all

#ifndef PSP_UTILITY_H
#define PSP_UTILITY_H

//preprocessor macros, defines, includes etc..;

//some structures for osk use
typedef struct SceUtilityOskInputFieldInfo_s {
    unsigned int input_method_type;
    unsigned int input_method_attributes;
    unsigned int writing_language_type;
    int hide_mode;
    int input_character_type;
    int num_lines;
    int kinsoku;
    SceWChar16 *message;
    SceWChar16 *init_text;
    int result_text_buffer_size;
    SceWChar16 *result_text_buffer;
    int result;
    int limit_length;
} SceUtilityOskInputFieldInfo;

typedef struct SceUtilityOskParam_s {
    SceUtilityParamBase	base;
    unsigned int num_input_fields;
    SceUtilityOskInputFieldInfo *input_field_info;
    int local_status;
    int error;
} SceUtilityOskParam;

//prototypes for stub functions from pspUtility.S
int sceUtilityOskInitStart(SceUtilityOskParam* param);
int sceUtilityOskShutdownStart(void);
int sceUtilityOskUpdate(int animation_speed);
int sceUtilityOskGetStatus(void);
Makefile:

Code: Select all

... //lets skip to important lines

OBJS = \
	main.o \
	draw.o \
	pspUtility.o \ //the above pspUtility.S will be created into a object
                           //so we can use those stub functions

... //etc...
and thats all you need to use your stubs
Note: HOW to create your stubs you will have to
figure that on your own ...its too simple and clues
are plentiful on this thread for example
to get the prototypes you will have to learn Mips Asm :P
of course if you learn that first then you would not
need help from examples like this post ...so go learn!

Example of Use:

Code: Select all

#include "pspUtility.h"
//lets use an above function ....say sceUtilityOskInitStart();
//so we can use the sony osk...all this is done in the osk sample if 
//youd like to see complete source of use
...
...

//function to handle users input 
int getOskInput(const char* name, const char* input, char* output, unsigned int len){
...

//variable for osk data
SceUtilityOskParam osk;
	memset(&osk, 0, sizeof(osk));
	osk.base.size = sizeof(osk);
	osk.base.message_lang = 2;
	osk.base.ctrl_assign = GetEnterButton();
	osk.base.main_thread_priority  = 17;
	osk.base.sub_thread_priority   = 19;
	osk.base.font_thread_priority  = 18;
	osk.base.sound_thread_priority = 16;

//also setup input field info
SceUtilityOskInputFieldInfo inparam;
	memset(&inparam, 0, sizeof(inparam));
	inparam.input_method_type = 0x000D;
	inparam.input_method_attributes = 0;
	inparam.writing_language_type = 0x0005;
	inparam.hide_mode = 0;
	inparam.input_character_type = 0;
	inparam.num_lines = 4;
	inparam.kinsoku = 1;
	inparam.message = name16;
	inparam.init_text = input16;
	inparam.result_text_buffer = output16;
	inparam.result_text_buffer_size = 512;
	inparam.result = 0;
	inparam.limit_length = len;

   //everything is setup lets init osk
	int rc = sceUtilityOskInitStart(&osk);
	if(rc) {
		return 1;	
	}
        
        //main loop ...infinite
        for(;;){
            drawFrame();

            //use another stub
            int status = sceUtilityOskGetStatus();
            switch(state) {
                //... do what you will
            }
            drawFlip();
         }
         return 1;
} //end of getOskInput()

...//continue source
10011011 00101010 11010111 10001001 10111010
User avatar
TUniqueW
Posts: 12
Joined: Sat Dec 09, 2006 12:51 pm

Post by TUniqueW »

thanks to dot_blank i have made the scepower sub here we go:
scepower.S

Code: Select all

.set noreorder

#include "pspstub.s"

STUB_START "scePower", 0x40010000, 0x20005
STUB_FUNC 0x0442D852, scePower_0442D852
STUB_END
scepower.h

Code: Select all


#ifndef PSP_POWER_H
#define PSP_POWER_H 


#ifdef __cplusplus
extern "C" {
#endif
/*
Simply reboots the PSP
@code
@unknown - unknown just pass 50000 or any more then 0 only tested that

*/


int scePower_0442D852(int unknown);

#ifdef __cplusplus
}
#endif

#endif
correct me please .....
because I used the fucntion like this:

Code: Select all

scePower_0442D852(0); //This won't work
//this should work tested 100% success 
scePower_0442D852(50000);
and made it with no warnings. but didn't get a reboot
NOTE: PSP I'm using is on 2.71 SE-C + This function is called from a PRX loaded successfully from the PRX (as other things work perfectly).

I'm lost,
Thanks in Advance,
TUW

SOLVED!
Last edited by TUniqueW on Sun Dec 10, 2006 6:20 pm, edited 1 time in total.
Developer: C/C++ knows nothing about assembly!
User avatar
TUniqueW
Posts: 12
Joined: Sat Dec 09, 2006 12:51 pm

Post by TUniqueW »

ok I fixed it my self.....
if you pass 50000 to the function it will reboot your PSP like a charm (even in user mode ) I'll edit the source

Cheers,
TUW
Developer: C/C++ knows nothing about assembly!
User avatar
TUniqueW
Posts: 12
Joined: Sat Dec 09, 2006 12:51 pm

sceSysconResetDevice

Post by TUniqueW »

as you said there is a simple way of rebootig:

Code: Select all

sceSysconResetDevice(1, 1);
and that gives you a disk error
and even if you use 2 as the second argument it still gives you the error:

Code: Select all

sceSysconResetDevice(1, 2);
but the reboot time is faster.
I have tried this two:

Code: Select all

sceSysconResetDevice(2, 1); //That I thought it would reset UMD_DRIVE(?)
sceSysconResetDevice(1, 1);
in that PSP reboots after 3-5 mins but still Disk Error and with bright less level one. ??

Anu suggestions how to make it work without the Disk Error ?

Cheers,
TUW
Developer: C/C++ knows nothing about assembly!
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

What is the use of the 0x200 length parameters that M33 Recovery passes to VSH on exit recovery.
Post Reply