| View previous topic :: View next topic |
| Author |
Message |
nikocronaldo
Joined: 24 Feb 2008 Posts: 31
|
Posted: Mon Nov 24, 2008 11:08 pm Post subject: My USB plugin doesn't work properly |
|
|
Why my psp show the Sony error screen when I try this code :
| Code: |
#include <pspkernel.h>
#include <pspiofilemgr.h>
#include <pspsdk.h>
#include <stdio.h>
#include <string.h>
#include <psploadexec_kernel.h>
#include <psploadcore.h>
#include <pspsysmem.h>
#include <pspsysmem_kernel.h>
#include <systemctrl.h>
#include <psppower.h>
#include <pspctrl.h>
#include <pspusb.h>
#include <pspusbstor.h>
#include <pspusbbus.h>
#include <pspdisplay_kernel.h>
#include <pspmodulemgr_kernel.h>
#include <kubridge.h>
#include <pspdisplay.h>
PSP_MODULE_INFO("Brightnes USB 1.0", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);
static int curBrightness = 0;
int USB_GetState(void)
{
int k1 = pspSdkSetK1(0);
sceDisplayGetBrightness(&curBrightness, 0);
sceDisplaySetBrightness(0, 0);
pspSdkSetK1(k1);
return 0;
}
int USB_Stop(void)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
pspSdkSetK1(k1);
return 0;
}
int module_start(SceSize args, void *argp)
{
u32 x = sctrlHENFindFunction("sceThreadManager" ,"ThreadManForUser", 0xAA73C935);
x = sctrlHENFindFunction("sceUSB_Driver", "sceUsb", 0xC21645A4);
sctrlHENPatchSyscall(x, USB_GetState);
x = sctrlHENFindFunction("sceUSB_Driver", "sceUsb", 0xC2464FA0);
sctrlHENPatchSyscall(x, USB_Stop);
return 0;
}
|
|
|
| Back to top |
|
 |
blu_eye4
Joined: 26 Oct 2008 Posts: 37
|
Posted: Tue Nov 25, 2008 12:15 am Post subject: |
|
|
| what type of error does PSP show? |
|
| Back to top |
|
 |
nikocronaldo
Joined: 24 Feb 2008 Posts: 31
|
Posted: Tue Nov 25, 2008 12:29 am Post subject: |
|
|
| blu_eye4 wrote: | | what type of error does PSP show? |
PSP shows the following error when I connect again to the USB Mode:
| Code: | | An internal error has ocurred (80243101) |
|
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Tue Nov 25, 2008 2:49 am Post subject: |
|
|
You are not calling original functions, wo aht you would expect?
Your GetState and Stop functions should call original functions for this to work. |
|
| Back to top |
|
 |
Mashphealh
Joined: 28 Nov 2007 Posts: 18
|
Posted: Tue Nov 25, 2008 4:40 am Post subject: |
|
|
Yes, you don't call original function. Try using this code :
int USB_GetState(void)
{
int k1 = pspSdkSetK1(0);
sceDisplayGetBrightness(&curBrightness, 0);
sceDisplaySetBrightness(0, 0);
pspSdkSetK1(k1);
return sceUsbGetState();
}
int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
pspSdkSetK1(k1);
return sceUsbStop(driverName, size, args);
}
M33's vshctrl patches sceUsbStop also, so I don't know if now usbdevice works for you. |
|
| Back to top |
|
 |
nikocronaldo
Joined: 24 Feb 2008 Posts: 31
|
Posted: Tue Nov 25, 2008 4:51 am Post subject: |
|
|
| moonlight wrote: | You are not calling original functions, wo aht you would expect?
Your GetState and Stop functions should call original functions for this to work. |
The PSP crashes with the original functions, with the same Mashphealt's code, why moonlight? |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Tue Nov 25, 2008 5:01 am Post subject: |
|
|
The usb stop function should be like this. The original function must be executed between the k1 stuff. This doesn't matter in the GetState one.
| Quote: |
int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
int ret = sceUsbStop(driverName, size, args)
pspSdkSetK1(k1);
return ret;
} |
|
|
| Back to top |
|
 |
nikocronaldo
Joined: 24 Feb 2008 Posts: 31
|
Posted: Tue Nov 25, 2008 5:15 am Post subject: |
|
|
| moonlight wrote: | The psp stop function should be like this. The original function must be executed between the k1 stuff. This doesn't matter in the GetState one.
| Quote: |
int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
int ret = sceUsbStop(driverName, size, args)
pspSdkSetK1(k1);
return ret;
} |
|
It crashes again, why?
| Quote: | int USB_GetState(void)
{
int k1 = pspSdkSetK1(0);
sceDisplayGetBrightness(&curBrightness, 0);
sceDisplaySetBrightness(0, 0);
pspSdkSetK1(k1);
return 0;
}
int USB_Stop(const char* driverName, int size, void *args)
{
int k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(curBrightness, 0);
int ret = sceUsbStop(driverName, size, args);
pspSdkSetK1(k1);
return ret;
} |
|
|
| Back to top |
|
 |
blu_eye4
Joined: 26 Oct 2008 Posts: 37
|
Posted: Tue Nov 25, 2008 6:34 am Post subject: |
|
|
| maybe, if you want make a prx you haven't to give 0x1000 at PSP_MODULE_INFO, maybe... |
|
| Back to top |
|
 |
moonlight
Joined: 26 Oct 2005 Posts: 567
|
Posted: Tue Nov 25, 2008 7:07 am Post subject: |
|
|
| Do a test commenting the calls to the display functions, to see if it crashes too or not. |
|
| Back to top |
|
 |
nikocronaldo
Joined: 24 Feb 2008 Posts: 31
|
Posted: Wed Nov 26, 2008 1:10 am Post subject: |
|
|
| moonlight wrote: | | Do a test commenting the calls to the display functions, to see if it crashes too or not. |
Prx still crashes, any idea? |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Wed Nov 26, 2008 3:57 am Post subject: |
|
|
A suggestion, When you ask for something post the entire code, the makefile and give more infos, I can't see your actual code...
Anyway if I'm right you want to hook the usb load?
To do this use the m33 module handler, is better then hook some functions I think...
Sorry for my english... |
|
| Back to top |
|
 |
|