getmemsize.c
679 Bytes
#include "osint.h"
u32 osGetMemSize(void)
{
#ifdef BBPLAYER
return osMemSize;
#else
volatile u32 *memory;
u32 memsize = 0x00400000;
u32 org_data, org_data2;
while(memsize < 0x00800000){
memory = (u32 *)(0xA0000000L + memsize);
org_data = memory[0x00000];
org_data2 = memory[0x3ffff];
memory[0x00000] = memory[0x00000] ^ 0xffffffff;
memory[0x3ffff] = memory[0x3ffff] ^ 0xffffffff;
if ((memory[0x00000] != (org_data ^ 0xffffffff)) ||
(memory[0x3ffff] != (org_data2 ^ 0xffffffff))){
return memsize;
}
memory[0x00000] = org_data;
memory[0x3ffff] = org_data2;
memsize += 0x00100000;
}
return memsize;
#endif
}