static int allocFunc(SceSize argSize, void* argPointer) { SceUInt timeout = 1000; void *data; schedulingResult = sceKernelAllocateVpl(*(SceUID *) argPointer, 0x20, &data, &timeout); schedf("L1 "); sceKernelDelayThread(1000); sceKernelFreeVpl(*(SceUID *) argPointer, data); return 0; }
void vpl_free(void *p) { int ret; ret = sceKernelFreeVpl(g_vpl_uid, p); #ifdef DEBUG if(ret != 0) { asm("break 0x8492"); } #endif }
int main(int argc, char *argv[]) { char url[] = "http://www.ps2dev.org/"; setupGu(); netInit(); htmlViewerInit(url); while(updateHtmlViewer()) { sceDisplayWaitVblankStart(); sceGuSwapBuffers(); } netTerm(); sceKernelFreeVpl(vpl, params.memaddr); sceKernelDeleteVpl(vpl); sceKernelExitGame(); return 0; }
extern "C" int main(int argc, char *argv[]) { int result; void *addr; void *addr1; void *addr3; void *addrs[50]; SceUID uid1 = sceKernelCreateVpl("bottom", 2, 0x4300, 0x100, NULL); SceUID uid2 = sceKernelCreateVpl("middle", 2, 0x4300, 0x100, NULL); SceUID uid3 = sceKernelCreateVpl("top", 2, 0x4300, 0x100, NULL); result = sceKernelAllocateVpl(uid1, 0x10, &addr1, NULL); result = sceKernelAllocateVpl(uid3, 0x10, &addr3, NULL); VplAccounting *acct = (VplAccounting *)((char *)addr3 + 0x18); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); checkpoint("alloc 0"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[1], NULL); checkpoint("alloc 1"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[2], NULL); checkpoint("alloc 2"); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 1: %08x", sceKernelFreeVpl(uid2, addrs[1])); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 0: %08x", sceKernelFreeVpl(uid2, addrs[0])); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 2: %08x", sceKernelFreeVpl(uid2, addrs[2])); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); checkpoint("alloc 0"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[1], NULL); checkpoint("alloc 1"); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 1: %08x", sceKernelFreeVpl(uid2, addrs[1])); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 0: %08x", sceKernelFreeVpl(uid2, addrs[0])); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[1], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[2], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[3], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[4], NULL); void *addr2 = addrs[4]; result = sceKernelAllocateVpl(uid2, 0x10, &addrs[5], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[6], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[7], NULL); result = sceKernelAllocateVpl(uid2, 0x18, &addrs[8], NULL); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 4: %08x", sceKernelFreeVpl(uid2, addr2)); schedfAcct(acct); schedfVpl(uid2); for (int i = 0; i <= 8; i += 2) { sceKernelFreeVpl(uid2, addrs[i]); checkpoint("free %d", i); schedfAcct(acct); schedfVpl(uid2); } checkpoint("free every other"); schedfAcct(acct); schedfVpl(uid2); for (int i = 8; i >= 0; --i) { sceKernelFreeVpl(uid2, addrs[i]); } checkpoint("free all"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); checkpoint("alloc 1"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelFreeVpl(uid2, addrs[0]); checkpoint("free 1"); schedfAcct(acct); schedfVpl(uid2); return 0; }