private void installIoFunctions(pspIoDrvFuncs controllerFuncs, pspIoDrvFuncs storageFuncs, pspIoDrvFuncs partitionFuncs) { const int sizeIoFunctionStub = 12; const int numberIoFunctions = 15; SysMemInfo memInfo = Modules.SysMemUserForUserModule.malloc(SysMemUserForUser.KERNEL_PARTITION_ID, "sceMSstor-IoFunctions", SysMemUserForUser.PSP_SMEM_Low, sizeIoFunctionStub * numberIoFunctions, 0); int addr = memInfo.addr; controllerFuncs.ioInit = addr; addr += sizeIoFunctionStub; controllerFuncs.ioDevctl = addr; addr += sizeIoFunctionStub; installHLESyscall(controllerFuncs.ioInit, this, "hleMSstorControllerIoInit"); installHLESyscall(controllerFuncs.ioDevctl, this, "hleMSstorControllerIoDevctl"); storageFuncs.ioInit = addr; addr += sizeIoFunctionStub; storageFuncs.ioDevctl = addr; addr += sizeIoFunctionStub; storageFuncs.ioOpen = addr; addr += sizeIoFunctionStub; storageFuncs.ioIoctl = addr; addr += sizeIoFunctionStub; storageFuncs.ioClose = addr; addr += sizeIoFunctionStub; installHLESyscall(storageFuncs.ioInit, this, "hleMSstorStorageIoInit"); installHLESyscall(storageFuncs.ioDevctl, this, "hleMSstorStorageIoDevctl"); installHLESyscall(storageFuncs.ioOpen, this, "hleMSstorStorageIoOpen"); installHLESyscall(storageFuncs.ioIoctl, this, "hleMSstorStorageIoIoctl"); installHLESyscall(storageFuncs.ioClose, this, "hleMSstorStorageIoClose"); partitionFuncs.ioInit = addr; addr += sizeIoFunctionStub; partitionFuncs.ioDevctl = addr; addr += sizeIoFunctionStub; partitionFuncs.ioOpen = addr; addr += sizeIoFunctionStub; partitionFuncs.ioClose = addr; addr += sizeIoFunctionStub; partitionFuncs.ioIoctl = addr; addr += sizeIoFunctionStub; partitionFuncs.ioLseek = addr; addr += sizeIoFunctionStub; partitionFuncs.ioRead = addr; addr += sizeIoFunctionStub; partitionFuncs.ioWrite = addr; addr += sizeIoFunctionStub; installHLESyscall(partitionFuncs.ioInit, this, "hleMSstorPartitionIoInit"); installHLESyscall(partitionFuncs.ioDevctl, this, "hleMSstorPartitionIoDevctl"); installHLESyscall(partitionFuncs.ioOpen, this, "hleMSstorPartitionIoOpen"); installHLESyscall(partitionFuncs.ioClose, this, "hleMSstorPartitionIoClose"); installHLESyscall(partitionFuncs.ioIoctl, this, "hleMSstorPartitionIoIoctl"); installHLESyscall(partitionFuncs.ioLseek, this, "hleMSstorPartitionIoLseek"); installHLESyscall(partitionFuncs.ioRead, this, "hleMSstorPartitionIoRead"); installHLESyscall(partitionFuncs.ioWrite, this, "hleMSstorPartitionIoWrite"); }
protected internal override void read() { nameAddr = read32(); devType = read32(); unknown = read32(); descriptionAddr = read32(); funcsAddr = read32(); name = readStringZ(nameAddr); description = readStringZ(descriptionAddr); if (funcsAddr == 0) { ioDrvFuncs = null; } else { ioDrvFuncs = new pspIoDrvFuncs(); ioDrvFuncs.read(mem, funcsAddr); } }
public virtual void installDrivers() { Memory mem = Memory.Instance; dumpIoIoctl_0x02125803 = readBytes("ms.ioctl.0x02125803"); hleInit(); pspIoDrv controllerDrv = new pspIoDrv(); pspIoDrvFuncs controllerFuncs = new pspIoDrvFuncs(); string controllerName = "mscmhc"; string controllerDescription = "MS host controller"; pspIoDrv storageDrv = new pspIoDrv(); pspIoDrvFuncs storageFuncs = new pspIoDrvFuncs(); string storageName = "msstor"; string storageDescription = "MSstor whole dev"; pspIoDrv partitionDrv = new pspIoDrv(); pspIoDrvFuncs partitionFuncs = new pspIoDrvFuncs(); string partitionName = "msstor0p"; string partitionDescription = "MSstor partition #1"; int Length = 0; Length += controllerDrv.@sizeof() + controllerFuncs.@sizeof() + controllerName.Length + 1 + controllerDescription.Length + 1; Length += storageDrv.@sizeof() + storageFuncs.@sizeof() + storageName.Length + 1 + storageDescription.Length + 1; Length += partitionDrv.@sizeof() + partitionFuncs.@sizeof() + partitionName.Length + 1 + partitionDescription.Length + 1; SysMemInfo memInfo = Modules.SysMemUserForUserModule.malloc(SysMemUserForUser.KERNEL_PARTITION_ID, "sceMSstor-mscmhc", SysMemUserForUser.PSP_SMEM_Low, Length, 0); int controllerDrvAddr = memInfo.addr; int controllerFuncsAddr = controllerDrvAddr + controllerDrv.@sizeof(); int storageDrvAddr = controllerFuncsAddr + controllerFuncs.@sizeof(); int storageFuncsAddr = storageDrvAddr + storageDrv.@sizeof(); int partitionDrvAddr = storageFuncsAddr + controllerFuncs.@sizeof(); int partitionFuncsAddr = partitionDrvAddr + partitionDrv.@sizeof(); int controllerNameAddr = partitionFuncsAddr + partitionFuncs.@sizeof(); int controllerDescriptionAddr = controllerNameAddr + controllerName.Length + 1; int storageNameAddr = controllerDescriptionAddr + controllerDescription.Length + 1; int storageDescriptionAddr = storageNameAddr + storageName.Length + 1; int partitionNameAddr = storageDescriptionAddr + storageDescription.Length + 1; int partitionDescriptionAddr = partitionNameAddr + partitionName.Length + 1; installIoFunctions(controllerFuncs, storageFuncs, partitionFuncs); Utilities.writeStringZ(mem, controllerNameAddr, controllerName); Utilities.writeStringZ(mem, controllerDescriptionAddr, controllerDescription); controllerDrv.nameAddr = controllerNameAddr; controllerDrv.name = controllerName; controllerDrv.devType = 1; controllerDrv.unknown = 0; controllerDrv.descriptionAddr = controllerDescriptionAddr; controllerDrv.description = controllerDescription; controllerDrv.funcsAddr = controllerFuncsAddr; controllerDrv.ioDrvFuncs = controllerFuncs; controllerDrv.write(mem, controllerDrvAddr); Utilities.writeStringZ(mem, storageNameAddr, storageName); Utilities.writeStringZ(mem, storageDescriptionAddr, storageDescription); storageDrv.nameAddr = storageNameAddr; storageDrv.name = storageName; storageDrv.devType = 1; storageDrv.unknown = 0; storageDrv.descriptionAddr = storageDescriptionAddr; storageDrv.description = storageDescription; storageDrv.funcsAddr = storageFuncsAddr; storageDrv.ioDrvFuncs = storageFuncs; storageDrv.write(mem, storageDrvAddr); Utilities.writeStringZ(mem, partitionNameAddr, partitionName); Utilities.writeStringZ(mem, partitionDescriptionAddr, partitionDescription); partitionDrv.nameAddr = partitionNameAddr; partitionDrv.name = partitionName; partitionDrv.devType = 1; partitionDrv.unknown = 0; partitionDrv.descriptionAddr = partitionDescriptionAddr; partitionDrv.description = partitionDescription; partitionDrv.funcsAddr = partitionFuncsAddr; partitionDrv.ioDrvFuncs = partitionFuncs; partitionDrv.write(mem, partitionDrvAddr); int sceIoAddDrv = NIDMapper.Instance.getAddressByName("sceIoAddDrv"); if (sceIoAddDrv != 0) { SceKernelThreadInfo thread = Modules.ThreadManForUserModule.CurrentThread; Modules.ThreadManForUserModule.executeCallback(thread, sceIoAddDrv, new AfterAddDrvController(thread, sceIoAddDrv, storageDrvAddr, partitionDrvAddr), false, controllerDrvAddr); } }