void __UmdReplace(std::string filepath) { // Only get system from disc0 seems have been enough. IFileSystem* currentUMD = pspFileSystem.GetSystem("disc0:"); if (!currentUMD) return; IFileSystem* umd2; FileInfo info; if (!getFileInfo(filepath.c_str(), &info)) // This shouldn't happen, but for safety. return; if (info.isDirectory) { umd2 = new VirtualDiscFileSystem(&pspFileSystem, filepath); } else { auto bd = constructBlockDevice(filepath.c_str()); if (!bd) return; umd2 = new ISOFileSystem(&pspFileSystem, bd); pspFileSystem.Remount(currentUMD, umd2); } delete currentUMD; // TODO Is this always correct if UMD was not activated? u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE | PSP_UMD_CHANGED; if (driveCBId != -1) __KernelNotifyCallback(driveCBId, notifyArg); }
void sceKernelNotifyCallback() { SceUID cbid = PARAM(0); u32 arg = PARAM(1); DEBUG_LOG(HLE,"sceKernelNotifyCallback(%i, %i)", cbid, arg); __KernelNotifyCallback(__KernelGetCurThread(), cbid, arg); RETURN(0); }
void __KernelUmdDeactivate() { u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READY; if (driveCBId != -1) __KernelNotifyCallback(driveCBId, notifyArg); CoreTiming::RemoveAllEvents(umdStatChangeEvent); __UmdStatChange(0, 0); }
void __IoCompleteAsyncIO(SceUID id) { u32 error; FileNode *f = kernelObjects.Get < FileNode > (id, error); if (f) { if (f->callbackID) { __KernelNotifyCallback(THREAD_CALLBACK_IO, f->callbackID, f->callbackArg); } } }
void __KernelUmdActivate() { u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE; if (driveCBId != -1) __KernelNotifyCallback(driveCBId, notifyArg); // Don't activate immediately, take time to "spin up." CoreTiming::RemoveAllEvents(umdStatChangeEvent); CoreTiming::ScheduleEvent(usToCycles(MICRO_DELAY_ACTIVATE), umdStatChangeEvent, 1); }
static void __KernelUmdActivate() { u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE; // PSP_UMD_READY will be returned when sceKernelGetCompiledSdkVersion() != 0 if (sceKernelGetCompiledSdkVersion() != 0) { notifyArg |= PSP_UMD_READY; } if (driveCBId != 0) __KernelNotifyCallback(driveCBId, notifyArg); // Don't activate immediately, take time to "spin up." CoreTiming::RemoveAllEvents(umdStatChangeEvent); CoreTiming::ScheduleEvent(usToCycles(MICRO_DELAY_ACTIVATE), umdStatChangeEvent, 1); }
void __UmdReplace(std::string filepath) { // TODO: This should really go through Loaders, no? What if it's an invalid file? // Only get system from disc0 seems have been enough. IFileSystem* currentUMD = pspFileSystem.GetSystem("disc0:"); IFileSystem* currentISOBlock = pspFileSystem.GetSystem("umd0:"); if (!currentUMD) return; FileLoader *loadedFile = ConstructFileLoader(filepath); IFileSystem* umd2; if (!loadedFile->Exists()) { delete loadedFile; return; } UpdateLoadedFile(loadedFile); if (loadedFile->IsDirectory()) { umd2 = new VirtualDiscFileSystem(&pspFileSystem, filepath); } else { auto bd = constructBlockDevice(loadedFile); if (!bd) return; umd2 = new ISOFileSystem(&pspFileSystem, bd); pspFileSystem.Remount(currentUMD, umd2); if (currentUMD != currentISOBlock) { // We mounted an ISO block system separately. IFileSystem *iso = new ISOBlockSystem(static_cast<ISOFileSystem *>(umd2)); pspFileSystem.Remount(currentISOBlock, iso); delete currentISOBlock; } } delete currentUMD; // TODO Is this always correct if UMD was not activated? u32 notifyArg = PSP_UMD_PRESENT | PSP_UMD_READABLE | PSP_UMD_CHANGED; if (driveCBId != -1) __KernelNotifyCallback(driveCBId, notifyArg); }
int scePowerRegisterCallback(int slot, int cbId) { DEBUG_LOG(HLE, "0=scePowerRegisterCallback(%i, %i)", slot, cbId); if (slot < -1 || slot >= numberOfCBPowerSlotsPrivate) { return PSP_POWER_ERROR_INVALID_SLOT; } if (slot >= numberOfCBPowerSlots) { return PSP_POWER_ERROR_PRIVATE_SLOT; } // TODO: If cbId is invalid return PSP_POWER_ERROR_INVALID_CB. if (cbId == 0) { return PSP_POWER_ERROR_INVALID_CB; } int retval = -1; if (slot == POWER_CB_AUTO) { // -1 signifies auto select of bank for (int i=0; i < numberOfCBPowerSlots; i++) { if (powerCbSlots[i] == 0 && retval == -1) { // found an empty slot powerCbSlots[i] = cbId; retval = i; } } if (retval == -1) { return PSP_POWER_ERROR_SLOTS_FULL; } } else { if (powerCbSlots[slot] == 0) { powerCbSlots[slot] = cbId; retval = 0; } else { return PSP_POWER_ERROR_TAKEN_SLOT; } } if (retval >= 0) { int arg = PSP_POWER_CB_AC_POWER | PSP_POWER_CB_BATTERY_EXIST | PSP_POWER_CB_BATTERY_FULL; __KernelNotifyCallback(cbId, arg); } return retval; }