scePower Question

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

Moderators: cheriff, TyRaNiD

Post Reply
pegasus21
Posts: 8
Joined: Sun Jun 18, 2006 4:24 am

scePower Question

Post by pegasus21 »

Is there a way to set the cpu clock frequency on 1.5 and when you exit that program, the clock still remains at the frequency set.

Thanks
pegasus21
Posts: 8
Joined: Sun Jun 18, 2006 4:24 am

Post by pegasus21 »

Ok, I've read that only via a loadmodule will the cpu be able to stick at the rate I've set so I came up with the following code but I'm unable to load the module. I get a 80020001 error code.

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <stdio.h>
#include <pspmoduleinfo.h>

/* Define the module info section */
//PSP_MODULE_INFO&#40;"CPU Test", 0, 0, 71&#41;;
PSP_MODULE_INFO&#40;"CPU TEST", 0x1000, 1, 1&#41;; 
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

/* Define printf, just to make typing easier */
#define printf  pspDebugScreenPrintf

/** 
 * Function that is called from _init in kernelmode before the 
 * main thread is started in usermode. 
 */ 
__attribute__ &#40;&#40;constructor&#41;&#41; 
void loaderInit&#40;&#41; 
&#123; 
    pspKernelSetKernelPC&#40;&#41;;
    pspSdkInstallNoDeviceCheckPatch&#40;&#41;;
    pspSdkInstallNoPlainModuleCheckPatch&#40;&#41;;
    pspDebugInstallKprintfHandler&#40;NULL&#41;;
&#125;

int LoadThread&#40;&#41; &#123;
	SceUID moduid; 
	int start;
	char *eboot = "flash0&#58;/vsh/module/vshmain.prx";

	if &#40;&#40;moduid = sceKernelLoadModule&#40;eboot, 0, NULL&#41;&#41; & 0x80000000&#41; 
	&#123; 
   		printf&#40;"Error %08X loading module.\n", moduid&#41;;      
	&#125; 

	if &#40;&#40;start = sceKernelStartModule&#40;moduid, 0, NULL, NULL, NULL&#41;&#41; & 0x80000000&#41; 
	&#123; 
		printf&#40;"Error %08X starting module.\n", start&#41;; 
	&#125;

	return 0;
&#125;

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
          sceKernelExitGame&#40;&#41;;
          return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
          int cbid;

          cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
          sceKernelRegisterExitCallback&#40;cbid&#41;;

          sceKernelSleepThreadCB&#40;&#41;;

          return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
          int thid = 0;

          thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
          if&#40;thid >= 0&#41; &#123;
                    sceKernelStartThread&#40;thid, 0, 0&#41;;
          &#125;

          return thid;
&#125;

/* main routine */
int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
    int thid = 0;

    //init screen and callbacks
    pspDebugScreenInit&#40;&#41;;
    pspDebugScreenClear&#40;&#41;;
    SetupCallbacks&#40;&#41;;

    thid = sceKernelCreateThread&#40;"load_thread", LoadThread, 0x10, 0xFA0, 0, 0&#41;;
    if&#40;thid >= 0&#41; &#123;
    	sceKernelStartThread&#40;thid, 0, 0&#41;;
    &#125;

    sceKernelSleepThread&#40;&#41;;
    sceKernelExitGame&#40;&#41;;

    return 0;
&#125;

Any help? Thanks.
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

Loading just vshmain wont get you very far as loading the vsh up requires a few more modules. And yes by default unless you use loadmodule the clock frequency wont stick, in fact even with hacks it wont stick (but you can reset it again once the psp has rebooted).
pegasus21
Posts: 8
Joined: Sun Jun 18, 2006 4:24 am

Post by pegasus21 »

I see. Thx for the reply.

Looks like loadexec of the vshmain.prx does load other prx along with it. Since it restarts the menu.
Post Reply