SceMemDisk: Difference between revisions

From Vita Development Wiki
Jump to navigation Jump to search
(Created page with "= Module = {| class="wikitable" ! Version !! World !! Privilege |- | 0.931-0.996 || Non-secure || Kernel |} Example code <source lang="C"> void md_access_test(void){ int...")
 
(Add some comments, link to reimplementation for modern firmwares.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
SceMemDisk is a VFS driver for virtual memdisk block devices backed by user space memblocks.
Re-implemented [https://github.com/bythos14/SceMemDisk here]
= Module =
= Module =


Line 56: Line 60:
}
}
</source>
</source>
[[Category:ARM]]
[[Category:Kernel]]
[[Category:Modules]]

Latest revision as of 04:29, 2 January 2025

SceMemDisk is a VFS driver for virtual memdisk block devices backed by user space memblocks.

Re-implemented here

Module

Version World Privilege
0.931-0.996 Non-secure Kernel

Example code

void md_access_test(void){

	int md_res;
	SceUID memid, fd;

	memid = sceKernelAllocMemBlock("md_buffer", 0x0C20D060, 0x10000, NULL);

	md_res = 0xDEADBEEF;
	res = sceIoDevctl("md0:", 1, &memid, sizeof(memid), &md_res, sizeof(md_res));
	sceClibPrintf("sceIoDevctl: 0x%X md_res: 0x%X\n", res, md_res);

	res = sceIoRemove("md0:0");
	sceClibPrintf("sceIoRemove: 0x%X\n", res);

	fd = sceIoOpen("md0:0", SCE_O_WRONLY, 0);
	sceClibPrintf("sceIoOpen: 0x%X\n", fd);
	if(fd >= 0){
		char buf[0x200];

		sceClibStrncpy(buf, "Hello", 0x200);

		res = sceIoWrite(fd, buf, sizeof(buf));
		sceIoClose(fd);
		sceClibPrintf("sceIoWrite: 0x%X\n", res);
	}

	fd = sceIoOpen("md0:0", SCE_O_RDONLY, 0);
	sceClibPrintf("sceIoOpen: 0x%X\n", fd);
	if(fd >= 0){
		char buf[0x200];
		sceClibMemset(buf, 0, sizeof(buf));

		res = sceIoRead(fd, buf, 0x200);
		sceIoClose(fd);
		sceClibPrintf("sceIoRead: 0x%X\n", res);
		sceClibPrintf("Msg: %s\n", buf);
	}

	res = sceIoRemove("md0:0");
	sceClibPrintf("sceIoRemove: 0x%X\n", res);
	res = sceIoRemove("md0:");
	sceClibPrintf("sceIoRemove: 0x%X\n", res);

	sceKernelFreeMemBlock(memid);
}