Advertising (This ad goes away for registered users. You can Login or Register)

Know status of PSP Go's internal memory?

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
suloku
Posts: 117
Joined: Wed Jul 09, 2014 2:58 pm

Know status of PSP Go's internal memory?

Post by suloku » Sat Jul 26, 2014 10:02 am

The following macro can be used to retrieve the status of the memory stick and for example wait for it to be ready. This is used to prevent hangs in several plugins when suspending the games thread (quickboot, pspstates menu pict...)

IO_MEM_STICK_STATUS *((volatile int*)(0xBD200038))

I've been researching but I can't find any information regarding the psp go's internal 16 GB memory, if it is handled as a second memory stick or anything. Is there somewhere were I can read some information regarding this? I'm mainly interested in getting to know if the internal memory is getting accessed at a certain time.

By the way out of curiosity, Is the memory stick status obtainable trough a sceiodevctl() command?
Advertising

User avatar
Omega2058
Developer
Posts: 246
Joined: Tue Sep 28, 2010 4:27 am
Contact:

Re: Know status of PSP Go's internal memory?

Post by Omega2058 » Sun Jul 27, 2014 2:50 am

suloku wrote:The following macro can be used to retrieve the status of the memory stick and for example wait for it to be ready. This is used to prevent hangs in several plugins when suspending the games thread (quickboot, pspstates menu pict...)

IO_MEM_STICK_STATUS *((volatile int*)(0xBD200038))

I've been researching but I can't find any information regarding the psp go's internal 16 GB memory, if it is handled as a second memory stick or anything. Is there somewhere were I can read some information regarding this? I'm mainly interested in getting to know if the internal memory is getting accessed at a certain time.

By the way out of curiosity, Is the memory stick status obtainable trough a sceiodevctl() command?
If you want to know more then you'll have to dive deep into PRO's source code and try to understand it. Also yes, the status is obtainable via sceIoDevctl() and below is a simple snippet that you can use to do so which works with the GO.

Code: Select all

#define SCE_INIT_BOOT_EF 	0x50
#define PSP_GO				        4
#define READY 				        4

/*
 * Waits until the memory stick is ready
 */
static void waitMsready(void) {
	int ret, status;
	const char *drvname;

	status = 0;
	drvname = "mscmhc0:";

	if (sceKernelGetModel() == PSP_GO) {
		if (sceKernelBootFrom() == SCE_INIT_BOOT_EF) {
			drvname = "mscmhcemu0:";
		} else {
			return;
		}
	}

	while (1) {
		ret = sceIoDevctl(drvname, 0x02025801, 0, 0, &status, sizeof(status));

		if (ret < 0) {
			sceKernelDelayThread(2 * 100 * 100);
			continue;
		}

		if (status == READY)
			break;

		sceKernelDelayThread(2 * 100 * 100);
	}
}
Edit: Spelling.
Advertising

suloku
Posts: 117
Joined: Wed Jul 09, 2014 2:58 pm

Re: Know status of PSP Go's internal memory?

Post by suloku » Tue Jul 29, 2014 10:10 pm

Thank you very much, I had looked at pro's cfw source, but I should have looked deeper.

Today I was finally able to try it both my Go and Slim and the modifications seem to work fine so far. Thanks again!

User avatar
Omega2058
Developer
Posts: 246
Joined: Tue Sep 28, 2010 4:27 am
Contact:

Re: Know status of PSP Go's internal memory?

Post by Omega2058 » Wed Jul 30, 2014 12:01 am

That's great news and you're welcome. Don't hesitate to ask if you need more help. :)

suloku
Posts: 117
Joined: Wed Jul 09, 2014 2:58 pm

Re: Know status of PSP Go's internal memory?

Post by suloku » Sat Aug 09, 2014 1:21 pm

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...

User avatar
Omega2058
Developer
Posts: 246
Joined: Tue Sep 28, 2010 4:27 am
Contact:

Re: Know status of PSP Go's internal memory?

Post by Omega2058 » Sat Aug 09, 2014 8:57 pm

uOFW does not have a any information regarding the internal storage status of the PSP Go. Unfortunately, that was the only way I could find for now and I don't know have any ideas nor do I know of any alternative methods.

I'm pretty sure there's something that could be used, but it might have been overlooked at some point. It's not impossible, that's for sure though. I'll look into it and try to come up with more information about this, but it'll be a bit of time though since I'm pretty busy with work. :/

suloku
Posts: 117
Joined: Wed Jul 09, 2014 2:58 pm

Re: Know status of PSP Go's internal memory?

Post by suloku » Sat Aug 09, 2014 9:54 pm

Thank you vey much, anyway it's not like it isn't working, just that under certain stress situations it seems to not perform as well.

Best regards

Post Reply

Return to “Programming and Security”