Example #1
0
void testTryAllocThread(const char *title, u32 attr, u32 requestBytes, u32 initialBytes) {
	schedf("%s: ", title);

	SceUID vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, attr, 0x100, NULL);

	// This way we have some allocated + free.
	void *data;
	sceKernelAllocateVpl(vpl, initialBytes, &data, NULL);

	SceUID allocThread = sceKernelCreateThread("allocThread", &allocFunc, 0x12, 0x1000, 0, NULL);
	sceKernelStartThread(allocThread, sizeof(SceUID), &vpl);
	sceKernelDelayThread(400);

	int result = sceKernelTryAllocateVpl(vpl, requestBytes, &data);
	schedf("L2 ");
	sceKernelDelayThread(600);

	sceKernelDeleteVpl(vpl);
	sceKernelWaitThreadEnd(allocThread, NULL);
	sceKernelTerminateDeleteThread(allocThread);

	if (result == 0) {
		schedf("OK (thread=%08X)\n", schedulingResult);
	} else {
		schedf("Failed (thread=%08X, main=%08X)\n", schedulingResult, result);
	}
}
Example #2
0
void testDiff() {
	SceUID vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	char *data1, *data2, *data3;
	sceKernelTryAllocateVpl(vpl, 0x08, (void **) &data1);
	sceKernelTryAllocateVpl(vpl, 0x10, (void **) &data2);
	sceKernelTryAllocateVpl(vpl, 0x01, (void **) &data3);

	schedf("Three 0x08s: diff=%x, %x\n", data1 - data2, data2 - data3);
	flushschedf();

	sceKernelDeleteVpl(vpl);
}
Example #3
0
extern "C" int main(int argc, char **argv) {
	SceUID th1 = sceKernelCreateThread("thread1", &thread1, 0x21, 0x1000, 0, NULL);
	SceUID th2 = sceKernelCreateThread("thread2", &thread2, 0x21, 0x1000, 0, NULL);
	vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x1000 + 0x20, NULL);
	void *data;
	sceKernelAllocateVpl(vpl, 0x800, &data, NULL);
	checkpoint("starting");
	sceKernelStartThread(th1, 0, NULL);
	sceKernelStartThread(th2, 0, NULL);
	checkpoint("waiting");
	sceKernelDelayThread(10000);
	checkpoint("deleting");
	sceKernelDeleteVpl(vpl);
	checkpoint("done, waiting");
	sceKernelDelayThread(10000);

	return 0;
}
Example #4
0
int main(int argc, char **argv) {
	SceUID vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	void *data;

	testTryAlloc("More than free", vpl, 0xFFE1, 1);
	testTryAlloc("0 bytes", vpl, 0, 1);
	testTryAlloc("1 byte", vpl, 1, 1);
	testTryAlloc("-1 bytes", vpl, -1, 1);
	testTryAlloc("16 bytes", vpl, 16, 1);
	testTryAlloc("8 bytes", vpl, 8, 1);

	// Crashes.
	//testTryAlloc("Into NULL", vpl, 8, 0);

	testTryAlloc("Most remaining", vpl, 0xFF00, 1);
	testTryAlloc("More than remaining", vpl, 0xA1, 1);
	testTryAlloc("All remaining", vpl, 0xA0, 1);
	testTryAlloc("All remaining - 7", vpl, 0xA0 - 7, 1);
	testTryAlloc("All remaining - 8", vpl, 0xA0 - 8, 1);
	testTryAlloc("1 byte (none left)", vpl, 1, 1);

	sceKernelDeleteVpl(vpl);

	testTryAlloc("NULL", 0, 0x100, 1);
	testTryAlloc("NULL with invalid", 0, 0, 0);
	testTryAlloc("Invalid", 0xDEADBEEF, 0x100, 1);
	testTryAlloc("Deleted", vpl, 0x100, 1);
	flushschedf();

	testDiff();

	u32 attrs[] = {PSP_VPL_ATTR_FIFO, PSP_VPL_ATTR_PRIORITY, PSP_VPL_ATTR_SMALLEST, PSP_VPL_ATTR_HIGHMEM};
	int i;
	for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); ++i) {
		schedf("Attr %x:\n", attrs[i]);
		testTryAllocThread("  Alloc 0x20 of 0x00/0xE0", attrs[i], 0x20, 0xE0 - 0x08);
		testTryAllocThread("  Alloc 0x20 of 0x20/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08));
		testTryAllocThread("  Alloc 0x20 of 0x40/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08) * 2);
		schedf("\n");
	}

	BASIC_SCHED_TEST("Zero",
		result = sceKernelTryAllocateVpl(vpl1, 0, &data);
	);
Example #5
0
File: main.c Project: CDragu/pspsdk
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;
}
Example #6
0
void vpl_finish(void)
{
	sceKernelDeleteVpl(g_vpl_uid);
}
int main(int argc, char **argv) {
	SceUID vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	void *data;

	schedf("No timeout:\n");
	testAlloc("  More than free", vpl, 0xFFE1, 1);
	testAlloc("  0 bytes", vpl, 0, 1);
	testAlloc("  1 byte", vpl, 1, 1);
	testAlloc("  -1 bytes", vpl, -1, 1);
	testAlloc("  16 bytes", vpl, 16, 1);
	testAlloc("  8 bytes", vpl, 8, 1);

	schedf("\nWith timeout:\n");
	testAllocTimeout("  More than free", vpl, 0xFFE1, 500, 1);
	testAllocTimeout("  0 bytes", vpl, 0, 500, 1);
	testAllocTimeout("  1 byte", vpl, 1, 500, 1);
	testAllocTimeout("  -1 bytes", vpl, -1, 500, 1);
	testAllocTimeout("  16 bytes", vpl, 16, 500, 1);
	testAllocTimeout("  8 bytes", vpl, 8, 500, 1);
	
	schedf("\nErrors:\n");
	// Crashes.
	//testAllocTimeout("Into NULL", vpl, 8, 500, 0);
	testAllocTimeout("  Into NULL", vpl, 0xFFE0, 500, 0);

	testAllocTimeout("  Most remaining", vpl, 0xFF00, 500, 1);
	testAllocTimeout("  More than remaining", vpl, 0xA1, 500, 1);
	testAllocTimeout("  All remaining", vpl, 0x68, 500, 1);
	testAllocTimeout("  All remaining - 7", vpl, 0x68 - 7, 500, 1);
	testAllocTimeout("  All remaining - 8", vpl, 0x68 - 8, 500, 1);
	testAllocTimeout("  1 byte (none left)", vpl, 1, 500, 1);
	testAllocTimeout("  1 byte (none left, 0 timeout)", vpl, 1, 0, 1);

	sceKernelDeleteVpl(vpl);

	testAllocTimeout("  NULL", 0, 0x100, 500, 1);
	testAllocTimeout("  NULL with invalid", 0, 0, 500, 0);
	testAllocTimeout("  Invalid", 0xDEADBEEF, 0x100, 500, 1);
	testAllocTimeout("  Deleted", vpl, 0x100, 500, 1);
	schedf("\n");

	testDiff();

	u32 attrs[] = {PSP_VPL_ATTR_FIFO, PSP_VPL_ATTR_PRIORITY, PSP_VPL_ATTR_SMALLEST, PSP_VPL_ATTR_HIGHMEM};
	int i;
	for (i = 0; i < sizeof(attrs) / sizeof(attrs[0]); ++i) {
		schedf("Attr %x:\n", attrs[i]);
		testAllocThread("  Alloc 0x10 of 0x00/0xE0", attrs[i], 0x20, 0xE0 - 0x08);
		testAllocThread("  Alloc 0x10 of 0x20/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08));
		testAllocThread("  Alloc 0x10 of 0x40/0xE0", attrs[i], 0x20, 0xE0 - 0x08 - (0x20 + 0x08) * 2);
		schedf("\n");
	}
	flushschedf();

	SceUID deleteThread = CREATE_SIMPLE_THREAD(deleteMeFunc);
	vpl = sceKernelCreateVpl("vpl", PSP_MEMORY_PARTITION_USER, 0, 0x10000, NULL);
	sceKernelAllocateVpl(vpl, 0x10000 - 0x20 - 0x08, &data, NULL);
	sceKernelStartThread(deleteThread, sizeof(SceUID), &vpl);
	sceKernelDeleteVpl(vpl);
	flushschedf();

	unsigned int timeout;
	BASIC_SCHED_TEST("Zero",
		timeout = 500;
		result = sceKernelAllocateVpl(vpl1, 0, &data, &timeout);
	);