PSP Slim RAM partitions

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

Moderators: cheriff, TyRaNiD

Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Yep its really cool :)

The main problem now is to rewrite all the code of most of my homebrews :/ I still can't understand some strange things while coding for the 3.71, sometime a function work, i remove a printf then nothing work anymore. I have a lot of strange things like this.
mypspdev
Posts: 178
Joined: Wed Jul 11, 2007 10:30 pm

Post by mypspdev »

Is anybody updating this page
http://wiki.ps2dev.org/psp:memory_map
on RAM partion for S&L too?

Thanks, by best to all
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

mypspdev wrote:Is anybody updating this page
http://wiki.ps2dev.org/psp:memory_map
on RAM partion for S&L too?

Thanks, by best to all
And they shouldn't call "kernel partition" to the volatile one too :p
User modules can be loaded there while kernel ones can't, so it is not definitely an appropiate name.
mypspdev
Posts: 178
Joined: Wed Jul 11, 2007 10:30 pm

Post by mypspdev »

I'm trying to investigate on, just as an exercise:

Code: Select all

void check_RAM()
{
	int i;
	PspSysmemPartitionInfo pinfo;
	for&#40;i = 0; i < 6; i++&#41;
	&#123;
		memset&#40;&pinfo, 0, sizeof&#40;pinfo&#41;&#41;;
		pinfo.size = sizeof&#40;pinfo&#41;;
		sceKernelQueryMemoryPartitionInfo&#40;i + 1, &pinfo&#41;;
		printf&#40; "%u  0x%08x  0x%08x  0x%08x 0x%08x 0x%x", i + 1, pinfo.memsize, pinfo.startaddr, sceKernelPartitionTotalFreeMemSize &#40;i + 1&#41;, sceKernelPartitionMaxFreeMemSize &#40;i + 1&#41;, pinfo.attr&#41;;
	&#125;
&#125;
But it doesn't work properly.

Could please anyone check whet's wrong? thanks in advance
mypspdev
Posts: 178
Joined: Wed Jul 11, 2007 10:30 pm

Post by mypspdev »

Solved:

#step 1 Create a prx under 1.50 kernel

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <string.h>
#include <pspsysmem_kernel.h>


PSP_MODULE_INFO&#40;"MyRAMPRX", 0x1006, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;0&#41;;


int PTotFreeMemSize&#40;int i&#41;
&#123;
	u32 k1; 
    	k1 = pspSdkSetK1&#40;0&#41;;
	int pttfms=sceKernelPartitionTotalFreeMemSize&#40;i&#41;;
	pspSdkSetK1&#40;k1&#41;;
	return pttfms; 
&#125;

int PMaxFreeMemSize&#40;int i&#41;
&#123;
	u32 k1; 
    	k1 = pspSdkSetK1&#40;0&#41;;
	int ptmfms=sceKernelPartitionMaxFreeMemSize&#40;i&#41;;
	pspSdkSetK1&#40;k1&#41;;
	return ptmfms; 
&#125;

PspSysmemPartitionInfo RAMpinfo&#40;int i&#41;
&#123;
	u32 k1; 
    	k1 = pspSdkSetK1&#40;0&#41;;
	PspSysmemPartitionInfo pinfo;

	memset&#40;&pinfo, 0, sizeof&#40;pinfo&#41;&#41;;
	pinfo.size = sizeof&#40;pinfo&#41;;
	sceKernelQueryMemoryPartitionInfo&#40;i, &pinfo&#41;;

	pspSdkSetK1&#40;k1&#41;;
	return pinfo;
&#125;


int module_start&#40;SceSize args, void *argp&#41; 
&#123;
	return 0;
&#125;

int module_stop&#40;&#41;
&#123;
	return 0;
&#125;
#step 2: create a main program 3.xx calling RAMprx:

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <string.h>
#include <pspsysmem_kernel.h>

PSP_MODULE_INFO&#40;"MyRAMPRXLoader", 0, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;
PSP_HEAP_SIZE_KB&#40;2500&#41;;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions imported from prx&#58;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int PMaxFreeMemSize&#40;int i&#41;;
int PTotFreeMemSize&#40;int i&#41;;
PspSysmemPartitionInfo RAMpinfo&#40;int i&#41;;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Globals&#58;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main&#58;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main&#40;&#41;&#123;
	SceUID modid;

	pspDebugScreenInit&#40;&#41;; 

		
	pspDebugScreenPrintf&#40;"Eboot test\n"&#41;;

	modid = pspSdkLoadStartModule&#40;"MyRAMPRX.prx", PSP_MEMORY_PARTITION_KERNEL&#41;;
	if &#40;modid < 0&#41;&#123;
		pspDebugScreenPrintf&#40;"Error 0x%08X loading/starting MyRAMPRX.prx.\n", modid&#41;;
        sceKernelDelayThread&#40;5*1000*1000&#41;;
        return -1;
	&#125;

	pspDebugScreenPrintf&#40;"Module ID %08X\n", modid&#41;;
	int i=0;
	for &#40;i=1;i<7;i++&#41;
	&#123;
		int k=PTotFreeMemSize&#40;i&#41;;
		pspDebugScreenPrintf&#40;"Total Free Mem Size - Partition %u 0x%08x  ", i, k&#41;;
		pspDebugScreenPrintf&#40;" \n"&#41;;
		int pmfms=PMaxFreeMemSize&#40;i&#41;;
		pspDebugScreenPrintf&#40;"Max Free Mem Size - Partition %u 0x%08x  ",i , pmfms&#41;;
		pspDebugScreenPrintf&#40;" \n"&#41;;
		PspSysmemPartitionInfo pinfo;
		pinfo=RAMpinfo&#40;i&#41;;
		pspDebugScreenPrintf&#40; "Partition %u - memsize&#58; 0x%08x start addr&#58; 0x%08x attr&#58; 0x%x",  i, pinfo.memsize, pinfo.startaddr, pinfo.attr&#41;;
		pspDebugScreenPrintf&#40;" \n"&#41;;
	&#125;

      pspDebugScreenPrintf&#40;"Press X to quit\n"&#41;;


      SceCtrlData pad;
      while&#40;1&#41;&#123;
      sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
      if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;&#123;
          break;
      &#125;
      &#125;
	sceKernelExitGame&#40;&#41;;
      return 0;
&#125;
cloudhunter
Posts: 86
Joined: Thu Aug 17, 2006 3:27 am

Post by cloudhunter »

#step 1 Create a prx under 1.50 kernel
I'm no expert, but that is incorrect. I believe you actually make a kernel mode prx.

Cloudy
:)
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

cloudhunter wrote:
#step 1 Create a prx under 1.50 kernel
I'm no expert, but that is incorrect. I believe you actually make a kernel mode prx.

Cloudy
Yes. Running in kernel mode does not necessarily mean 1.50 firmware. :)
mypspdev
Posts: 178
Joined: Wed Jul 11, 2007 10:30 pm

Post by mypspdev »

I apologize for used terminology, but finally it works fine: I have RAM Partition info from Fat and S&L.
It was impossible to do it within 3.xx I needed the prx to be called.
If anybody wants zip file, it's available.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, it stands to reason that those functions would need to be called from kernel mode seeing as how they return info about kernel mode partitions. They aren't about to give you that info in user mode. :)
Post Reply