Now that I've received an M2 card I've been testing this more I've concluded that even though the scedevioctl way works most of the time, sometimes the psp hangs when pausing the threads (I'm using the function to know when it is safe to suspend the game's thread). Of course it happens in situations whith heavy memory stick access and those can manually be prevented, but accessing the memory stick hardware register directly doesn't have this problem (tested the same situation multiple times with both methods), here's the function (from quickboot's 3.2 source):
Code: Select all
#define IO_MEM_STICK_STATUS *((volatile int*)(0xBD200038))
void waitMsready(){
int i;
// wait MS (Thanks to hiroi, taba)
for(i = 0; i < 100; i++){
if((IO_MEM_STICK_STATUS & 0x2000) == 0){
i = 0;
}
sceKernelDelayThread(1);
}
return;
}
I think 0x2000 is the read bit flag, but I'm not sure about that. By the way the above's function will hang the psp if there's no memory stick inserted (only really relevant for the psp go).
I've looked at uOFW documentation for hardware registers, but unfortunately it still doesn't hold information about the psp go's internal storage status registry, for the moment I've made a mixed function:
Code: Select all
#define IO_MEM_STICK_STATUS *((volatile int*)(0xBD200038))
#define SCE_INIT_BOOT_EF 0x50
#define PSP_GO 4
#define READY 4
void waitMsready(){
int ret, status, i;
const char *drvname;
status = 0;
drvname = "mscmhc0:";
if (kuKernelGetModel() == PSP_GO && kuKernelBootFrom() == SCE_INIT_BOOT_EF)
{
drvname = "mscmhcemu0:";
while (1)
{
ret = sceIoDevctl(drvname, 0x02025801, 0, 0, &status, sizeof(status));
if (ret < 0)
{
sceKernelDelayThread(1);
continue;
}
if (status == READY)
{
break;
}
sceKernelDelayThread(1);
}
//For memory stick access the registry directly
}else{
if (MScmIsMediumInserted()){
// wait MS (Thanks to hiroi, taba)
for(i = 0; i < 100; i++){
if((IO_MEM_STICK_STATUS & 0x2000) == 0){
i = 0;
}
sceKernelDelayThread(1);
}
}
}
return;
}
I've tried looking for more information about the status output by sceIoDevctl in order to wait not until the device is ready, but until there's no data being read (I think the registry funcion does that) but I didn't find anything. Any ideas?
EDIT: I've found out that sceKernelBootFrom and kuKernelBootFrom seem to rely on the apitype of the aplication. Loading an app from internal storage but with 0x141 apitype reports 0x40, but I guess one should not play with this kind of things...