int sys_lwmutex_unlock(mem_ptr_t<sys_lwmutex_t> lwmutex) { sc_lwmutex.Log("sys_lwmutex_unlock(lwmutex_addr=0x%x)", lwmutex.GetAddr()); if (!lwmutex.IsGood()) return CELL_EFAULT; //ConLog.Write("*** unlocking mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); return lwmutex->unlock(GetCurrentPPUThread().GetId()); }
int cellPamfReaderGetNumberOfEp(mem_ptr_t<CellPamfReader> pSelf) { cellPamf->Warning("cellPamfReaderGetNumberOfEp(pSelf=0x%x (stream=%d))", pSelf.GetAddr(), pSelf->stream); if (!pSelf.IsGood() || !Memory.IsGoodAddr(pSelf->pAddr)) return CELL_PAMF_ERROR_INVALID_ARG; const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr); return pAddr->stream_headers[pSelf->stream].ep_num; }
int sys_net_initialize_network_ex(mem_ptr_t<sys_net_initialize_parameter> param) { sys_net.Warning("sys_net_initialize_network_ex(param_addr=0x%x)", param.GetAddr()); g_lastError.SetAddr(Memory.Alloc(4, 1)); #ifdef _WIN32 WSADATA wsaData; WORD wVersionRequested = MAKEWORD(1,1); WSAStartup(wVersionRequested, &wsaData); #endif return CELL_OK; }
int sys_lwmutex_lock(mem_ptr_t<sys_lwmutex_t> lwmutex, u64 timeout) { sc_lwmutex.Log("sys_lwmutex_lock(lwmutex_addr=0x%x, timeout=%lld)", lwmutex.GetAddr(), timeout); if (!lwmutex.IsGood()) return CELL_EFAULT; //ConLog.Write("*** lock mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); return lwmutex->lock(GetCurrentPPUThread().GetId(), timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0); }
int cellFontRenderCharGlyphImage(mem_ptr_t<CellFont> font, u32 code, mem_ptr_t<CellFontRenderSurface> surface, float x, float y, mem_ptr_t<CellFontGlyphMetrics> metrics, mem_ptr_t<CellFontImageTransInfo> transInfo) { x = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments y = GetCurrentPPUThread().FPR[2]; // TODO: Something is wrong with the float arguments cellFont->Log("cellFontRenderCharGlyphImage(font_addr=0x%x, code=0x%x, surface_addr=0x%x, x=%f, y=%f, metrics_addr=0x%x, trans_addr=0x%x)", font.GetAddr(), code, surface.GetAddr(), x, y, metrics.GetAddr(), transInfo.GetAddr()); if (!font.IsGood() || !surface.IsGood() || !metrics.IsGood() || !transInfo.IsGood()) return CELL_FONT_ERROR_INVALID_PARAMETER; if (!font->renderer_addr) return CELL_FONT_ERROR_RENDERER_UNBIND; // Render the character int width, height, xoff, yoff; float scale = stbtt_ScaleForPixelHeight(&(font->stbfont), font->scale_y); unsigned char* box = stbtt_GetCodepointBitmap(&(font->stbfont), scale, scale, code, &width, &height, &xoff, &yoff); if (!box) return CELL_OK; // Get the baseLineY value int baseLineY; int ascent, descent, lineGap; stbtt_GetFontVMetrics(&(font->stbfont), &ascent, &descent, &lineGap); baseLineY = ascent * scale; // Move the rendered character to the surface unsigned char* buffer = (unsigned char*)Memory.VirtualToRealAddr(surface->buffer_addr); for (u32 ypos = 0; ypos < (u32)height; ypos++){ if ((u32)y + ypos + yoff + baseLineY >= surface->height) break; for (u32 xpos = 0; xpos < (u32)width; xpos++){ if ((u32)x + xpos >= surface->width) break; // TODO: There are some oddities in the position of the character in the final buffer buffer[((int)y + ypos + yoff + baseLineY)*surface->width + (int)x+xpos] = box[ypos*width + xpos]; } } stbtt_FreeBitmap(box, 0); return CELL_FONT_OK; }
int cellSpursCreateTaskset(mem_ptr_t<CellSpurs> spurs, mem_ptr_t<CellSpursTaskset> taskset, u64 args, mem8_t priority, u32 maxContention) { cellSpurs->Todo("cellSpursCreateTaskset(spurs_addr=0x%x, taskset_addr=0x%x, args=0x%x, priority_addr=0x%x, maxContention=%u)", spurs.GetAddr(), taskset.GetAddr(), args, priority.GetAddr(), maxContention); if ((spurs.GetAddr() % 128 != 0) || (taskset.GetAddr() % 128 != 0)) { cellSpurs->Error("cellSpursCreateTaskset : CELL_SPURS_TASK_ERROR_ALIGN"); return CELL_SPURS_TASK_ERROR_ALIGN; } if (!spurs.IsGood() || !taskset.IsGood()) { cellSpurs->Error("cellSpursCreateTaskset : CELL_SPURS_TASK_ERROR_NULL_POINTER"); return CELL_SPURS_TASK_ERROR_NULL_POINTER; } SPURSManagerTasksetAttribute *tattr = new SPURSManagerTasksetAttribute(args, priority, maxContention); taskset->taskset = new SPURSManagerTaskset(taskset.GetAddr(), tattr); return CELL_OK; }
int cellFontSetScalePixel(mem_ptr_t<CellFont> font, float w, float h) { h = GetCurrentPPUThread().FPR[1]; // TODO: Something is wrong with the float arguments cellFont.Warning("cellFontSetScalePixel(font_addr=0x%x, w=%f, h=%f)", font.GetAddr(), w, h); if (!font.IsGood()) return CELL_FONT_ERROR_INVALID_PARAMETER; font->scale_x = w; font->scale_y = h; return CELL_FONT_OK; }
int cellFontUnbindRenderer(mem_ptr_t<CellFont> font) { cellFont.Warning("cellFontBindRenderer(font_addr=0x%x)", font.GetAddr()); if (!font.IsGood()) return CELL_FONT_ERROR_INVALID_PARAMETER; if (!font->renderer_addr) return CELL_FONT_ERROR_RENDERER_UNBIND; font->renderer_addr = NULL; return CELL_FONT_OK; }
int sys_lwcond_destroy(mem_ptr_t<sys_lwcond_t> lwcond) { sys_lwcond.Warning("sys_lwcond_destroy(lwcond_addr=0x%x)", lwcond.GetAddr()); if (!lwcond.IsGood()) return CELL_EFAULT; LWCond* lwc; u32 id = (u32)lwcond->lwcond_queue; if (!sys_lwcond.CheckId(id, lwc)) return CELL_ESRCH; Emu.GetIdManager().RemoveID(id); return CELL_OK; }
int cellPamfReaderGetStreamTypeAndChannel(mem_ptr_t<CellPamfReader> pSelf, mem8_t pType, mem8_t pCh) { cellPamf.Warning("cellPamfReaderGetStreamTypeAndChannel(pSelf=0x%x (stream=%d), pType_addr=0x%x, pCh_addr=0x%x", pSelf.GetAddr(), pSelf->stream, pType.GetAddr(), pCh.GetAddr()); if (!pSelf.IsGood() || !pCh.IsGood()) return CELL_PAMF_ERROR_INVALID_ARG; pType = pamfGetStreamType(pSelf, pSelf->stream); pCh = pamfGetStreamChannel(pSelf, pSelf->stream); return CELL_OK; }
int sceNpTrophyGetTrophyInfo(u32 context, u32 handle, s32 trophyId, mem_ptr_t<SceNpTrophyDetails> details, mem_ptr_t<SceNpTrophyData> data) { sceNpTrophy.Warning("sceNpTrophyGetTrophyInfo(context=%u, handle=%u, trophyId=%d, details_addr=0x%x, data_addr=0x%x)", context, handle, trophyId, details.GetAddr(), data.GetAddr()); if (!s_npTrophyInstance.m_bInitialized) return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED; if (!details.IsGood() || !data.IsGood()) return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT; // TODO: There are other possible errors // sceNpTrophyInternalContext& ctxt = s_npTrophyInstance.contexts[context]; // TODO: This data is faked, implement a XML reader and get it from TROP.SFM memcpy(details->name, "Some Trophy", SCE_NP_TROPHY_NAME_MAX_SIZE); memcpy(details->description, "Hey! Implement a XML reader, and load the description from TROP.SFM", SCE_NP_TROPHY_DESCR_MAX_SIZE); details->hidden = false; details->trophyId = trophyId; details->trophyGrade = SCE_NP_TROPHY_GRADE_GOLD; return CELL_OK; }
int cellFsStat(const u32 path_addr, mem_ptr_t<CellFsStat> sb) { const wxString& path = Memory.ReadString(path_addr); sys_fs.Log("cellFsStat(path: %s, sb_addr: 0x%x)", path.mb_str(), sb.GetAddr()); sb->st_mode = CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR | CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP | CELL_FS_S_IROTH | CELL_FS_S_IWOTH | CELL_FS_S_IXOTH; sb->st_uid = 0; sb->st_gid = 0; sb->st_atime_ = 0; //TODO sb->st_mtime_ = 0; //TODO sb->st_ctime_ = 0; //TODO sb->st_blksize = 4096; // Check if path is a mount point. (TODO: Add information in sb_addr) for(u32 i=0; i<Emu.GetVFS().m_devices.GetCount(); ++i) { if(path.CmpNoCase(Emu.GetVFS().m_devices[i].GetPs3Path().RemoveLast(1)) == 0) { sys_fs.Log("cellFsStat: '%s' is a mount point.", path.mb_str()); sb->st_mode |= CELL_FS_S_IFDIR; return CELL_OK; } } // TODO: Temporary solution until vfsDir is implemented wxString real_path; Emu.GetVFS().GetDevice(path, real_path); struct stat s; if(stat(real_path.c_str(), &s) == 0) { if(s.st_mode & S_IFDIR) { sb->st_mode |= CELL_FS_S_IFDIR; } else if(s.st_mode & S_IFREG) { vfsFile f(path); sb->st_mode |= CELL_FS_S_IFREG; sb->st_size = f.GetSize(); } } else { sys_fs.Warning("cellFsStat: '%s' not found.", path.mb_str()); return CELL_ENOENT; } return CELL_OK; }
int cellSysutilGetBgmPlaybackStatus(mem_ptr_t<CellBgmPlaybackStatus> status) { cellSysutil.Warning("cellSysutilGetBgmPlaybackStatus(status=0x%x)", status.GetAddr()); // non-essential, so always assume background music is stopped/disabled status->playbackState = CELL_BGMPLAYBACK_STATUS_STOP; status->enabled = CELL_BGMPLAYBACK_STATUS_DISABLE; status->fadeRatio = 0; // volume ratio memset(status->contentId, 0, sizeof(status->contentId)); return CELL_OK; }
int cellSpursCreateTask(mem_ptr_t<CellSpursTaskset> taskset, mem32_t taskID, mem_ptr_t<void> elf_addr, mem_ptr_t<void> context_addr, u32 context_size, mem_ptr_t<CellSpursTaskLsPattern> lsPattern, mem_ptr_t<CellSpursTaskArgument> argument) { cellSpurs->Todo("cellSpursCreateTask(taskset_addr=0x%x, taskID_addr=0x%x, elf_addr_addr=0x%x, context_addr_addr=0x%x, context_size=%u, lsPattern_addr=0x%x, argument_addr=0x%x)", taskset.GetAddr(), taskID.GetAddr(), elf_addr.GetAddr(), context_addr.GetAddr(), context_size, lsPattern.GetAddr(), argument.GetAddr()); if (taskset.GetAddr() % 128 != 0) { cellSpurs->Error("cellSpursCreateTask : CELL_SPURS_TASK_ERROR_ALIGN"); return CELL_SPURS_TASK_ERROR_ALIGN; } if (!taskset.IsGood()) { cellSpurs->Error("cellSpursCreateTask : CELL_SPURS_TASK_ERROR_NULL_POINTER"); return CELL_SPURS_TASK_ERROR_NULL_POINTER; } return CELL_OK; }
int sys_lwcond_create(mem_ptr_t<sys_lwcond_t> lwcond, mem_ptr_t<sys_lwmutex_t> lwmutex, mem_ptr_t<sys_lwcond_attribute_t> attr) { sys_lwcond.Log("sys_lwcond_create(lwcond_addr=0x%x, lwmutex_addr=0x%x, attr_addr=0x%x)", lwcond.GetAddr(), lwmutex.GetAddr(), attr.GetAddr()); if (!lwcond.IsGood() /*|| !lwmutex.IsGood()*/ || !attr.IsGood()) { return CELL_EFAULT; } lwcond->lwmutex = lwmutex.GetAddr(); lwcond->lwcond_queue = sys_lwcond.GetNewId(new SleepQueue(attr->name_u64)); if (lwmutex.IsGood()) { if (lwmutex->attribute.ToBE() & se32(SYS_SYNC_RETRY)) { sys_lwcond.Warning("Unsupported SYS_SYNC_RETRY lwmutex protocol"); } if (lwmutex->attribute.ToBE() & se32(SYS_SYNC_RECURSIVE)) { sys_lwcond.Warning("Recursive lwmutex(sq=%d)", (u32)lwmutex->sleep_queue); } } else { sys_lwcond.Warning("Invalid lwmutex address(0x%x)", lwmutex.GetAddr()); } sys_lwcond.Warning("*** lwcond created [%s] (lwmutex_addr=0x%x): id = %d", wxString(attr->name, 8).wx_str(), lwmutex.GetAddr(), (u32)lwcond->lwcond_queue); return CELL_OK; }
int cellSaveDataAutoSave2(u32 version, u32 dirName_addr, u32 errDialog, mem_ptr_t<CellSaveDataSetBuf> setBuf, mem_func_ptr_t<CellSaveDataStatCallback> funcStat, mem_func_ptr_t<CellSaveDataFileCallback> funcFile, u32 container, u32 userdata_addr) { cellSysutil->Warning("cellSaveDataAutoSave2(version=%d, dirName_addr=0x%x, errDialog=%d, setBuf=0x%x, funcList=0x%x, funcStat=0x%x, funcFile=0x%x, container=%d, userdata_addr=0x%x)", version, dirName_addr, errDialog, setBuf.GetAddr(), funcStat.GetAddr(), funcFile.GetAddr(), container, userdata_addr); MemoryAllocator<CellSaveDataCBResult> result; MemoryAllocator<CellSaveDataStatGet> statGet; MemoryAllocator<CellSaveDataStatSet> statSet; std::string saveBaseDir = "/dev_hdd0/home/00000001/savedata/"; // TODO: Get the path of the current user vfsDir dir(saveBaseDir); if (!dir.IsOpened()) return CELL_SAVEDATA_ERROR_INTERNAL; std::string dirName = Memory.ReadString(dirName_addr); std::vector<SaveDataEntry> saveEntries; for (const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { if (entry->flags & DirEntry_TypeDir && entry->name == dirName) { addSaveDataEntry(saveEntries, saveBaseDir+dirName); } } // The target entry does not exist if (saveEntries.size() == 0) { SaveDataEntry entry; entry.dirName = dirName; entry.sizeKB = 0; entry.isNew = true; saveEntries.push_back(entry); } getSaveDataStat(saveEntries[0], statGet.GetAddr()); // There should be only one element in this list result->userdata_addr = userdata_addr; funcStat(result.GetAddr(), statGet.GetAddr(), statSet.GetAddr()); Memory.Free(statGet->fileList.GetAddr()); if (result->result < 0) { LOG_ERROR(HLE, "cellSaveDataAutoSave2: CellSaveDataStatCallback failed."); // TODO: Once we verify that the entire SysCall is working, delete this debug error message. return CELL_SAVEDATA_ERROR_CBRESULT; } /*if (statSet->setParam.GetAddr()) // TODO: Write PARAM.SFO file */ // Enter the loop where the save files are read/created/deleted. s32 ret = modifySaveDataFiles(funcFile, result.GetAddr(), saveBaseDir + (char*)statGet->dir.dirName); return CELL_SAVEDATA_RET_OK; }
int sys_raw_spu_image_load(int id, mem_ptr_t<sys_spu_image> img) { sysPrxForUser->Warning("sys_raw_spu_image_load(id=0x%x, img_addr=0x%x)", id, img.GetAddr()); if (!Memory.Copy(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id, (u32)img->segs_addr, 256 * 1024)) { sysPrxForUser->Error("sys_raw_spu_image_load() failed"); return CELL_EFAULT; } Memory.Write32(RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * id + RAW_SPU_PROB_OFFSET + SPU_NPC_offs, (u32)img->entry_point); return CELL_OK; }
int cellSysutilGetBgmPlaybackStatus(mem_ptr_t<CellSysutilBgmPlaybackStatus> status) { cellSysutil->Log("cellSysutilGetBgmPlaybackStatus(status_addr=0x%x)", status.GetAddr()); // TODO status->playerState = CELL_SYSUTIL_BGMPLAYBACK_STATUS_STOP; status->enableState = bgm_playback_enabled ? CELL_SYSUTIL_BGMPLAYBACK_STATUS_ENABLE : CELL_SYSUTIL_BGMPLAYBACK_STATUS_DISABLE; status->currentFadeRatio = 0; // current volume ratio (0%) memset(status->contentId, 0, sizeof(status->contentId)); memset(status->reserved, 0, sizeof(status->reserved)); return CELL_OK; }
int sceNpTrophyCreateContext(mem32_t context, mem_ptr_t<SceNpCommunicationId> commID, mem_ptr_t<SceNpCommunicationSignature> commSign, u64 options) { sceNpTrophy.Warning("sceNpTrophyCreateContext(context_addr=0x%x, commID_addr=0x%x, commSign_addr=0x%x, options=0x%llx)", context.GetAddr(), commID.GetAddr(), commSign.GetAddr(), options); if (!s_npTrophyInstance.m_bInitialized) return SCE_NP_TROPHY_ERROR_NOT_INITIALIZED; if (!context.IsGood()) return SCE_NP_TROPHY_ERROR_INVALID_ARGUMENT; if (options & (~(u64)1)) SCE_NP_TROPHY_ERROR_NOT_SUPPORTED; // TODO: There are other possible errors // TODO: Is the TROPHY.TRP file necessarily located in this path? vfsDir dir("/app_home/TROPDIR/"); if(!dir.IsOpened()) return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST; // TODO: Following method will retrieve the TROPHY.TRP of the first folder that contains such file for(const DirEntryInfo* entry = dir.Read(); entry; entry = dir.Read()) { if (entry->flags & DirEntry_TypeDir) { std::shared_ptr<vfsFileBase> f(Emu.GetVFS().OpenFile("/app_home/TROPDIR/" + entry->name + "/TROPHY.TRP", vfsRead)); if (f && f->IsOpened()) { sceNpTrophyInternalContext ctxt; ctxt.trp_stream = f.get(); ctxt.trp_name = entry->name; s_npTrophyInstance.contexts.push_back(ctxt); f = nullptr; return CELL_OK; } } } return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST; }
int sys_lwmutex_create(mem_ptr_t<sys_lwmutex_t> lwmutex, mem_ptr_t<sys_lwmutex_attribute_t> attr) { sc_lwmutex.Log("sys_lwmutex_create(lwmutex_addr=0x%x, lwmutex_attr_addr=0x%x)", lwmutex.GetAddr(), attr.GetAddr()); if (!lwmutex.IsGood() || !attr.IsGood()) return CELL_EFAULT; switch (attr->attr_recursive.ToBE()) { case se32(SYS_SYNC_RECURSIVE): break; case se32(SYS_SYNC_NOT_RECURSIVE): break; default: sc_lwmutex.Error("Unknown recursive attribute(0x%x)", (u32)attr->attr_recursive); return CELL_EINVAL; } switch (attr->attr_protocol.ToBE()) { case se32(SYS_SYNC_PRIORITY): break; case se32(SYS_SYNC_RETRY): break; case se32(SYS_SYNC_PRIORITY_INHERIT): sc_lwmutex.Error("Invalid SYS_SYNC_PRIORITY_INHERIT protocol attr"); return CELL_EINVAL; case se32(SYS_SYNC_FIFO): break; default: sc_lwmutex.Error("Unknown protocol attribute(0x%x)", (u32)attr->attr_protocol); return CELL_EINVAL; } lwmutex->attribute = attr->attr_protocol | attr->attr_recursive; lwmutex->waiter = 0; lwmutex->mutex.initialize(); //lwmutex->waiter = lwmutex->owner.GetOwner(); lwmutex->pad = 0; lwmutex->recursive_count = 0; u32 sq_id = sc_lwmutex.GetNewId(new SleepQueue(attr->name_u64)); lwmutex->sleep_queue = sq_id; procObjects.lwmutex_objects.insert(sq_id); sc_lwmutex.Warning("*** lwmutex created [%s] (attribute=0x%x): sq_id = %d", std::string(attr->name, 8).c_str(), (u32) lwmutex->attribute, sq_id); return CELL_OK; }
int cellSysCacheMount(mem_ptr_t<CellSysCacheParam> param) { cellSysutil->Warning("cellSysCacheMount(param_addr=0x%x)", param.GetAddr()); //TODO: implement char id[CELL_SYSCACHE_ID_SIZE]; strncpy(id, param->cacheId, CELL_SYSCACHE_ID_SIZE); strncpy(param->getCachePath, ("/dev_hdd1/cache/" + std::string(id) + "/").c_str(), CELL_SYSCACHE_PATH_MAX); param->getCachePath[CELL_SYSCACHE_PATH_MAX - 1] = '\0'; Emu.GetVFS().CreateDir(std::string(param->getCachePath)); return CELL_SYSCACHE_RET_OK_RELAYED; }
s32 cellFsStReadGetRingBuf(u32 fd, mem_ptr_t<CellFsRingBuffer> ringbuf) { sys_fs->Warning("cellFsStReadGetRingBuf(fd=%d, ringbuf_addr=0x%x)", fd, ringbuf.GetAddr()); vfsStream* file; if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; *ringbuf = fs_config.m_ring_buffer; sys_fs->Warning("*** fs stream config: block_size=0x%llx, copy=%d, ringbuf_size = 0x%llx, transfer_rate = 0x%llx", ringbuf->block_size, ringbuf->copy,ringbuf->ringbuf_size, ringbuf->transfer_rate); return CELL_OK; }
int _cellSpursAttributeInitialize(mem_ptr_t<CellSpursAttribute> attr, int nSpus, int spuPriority, int ppuPriority, bool exitIfNoWork) { cellSpurs.Warning("_cellSpursAttributeInitialize(attr_addr=0x%x, nSpus=%u, spuPriority=%u, ppuPriority=%u, exitIfNoWork=%u)", attr.GetAddr(), nSpus, spuPriority, ppuPriority, exitIfNoWork); if(!attr.IsGood()) return CELL_SPURS_CORE_ERROR_NULL_POINTER; attr->attr = new SPURSManagerAttribute(nSpus, spuPriority, ppuPriority, exitIfNoWork); return CELL_OK; }
int sys_lwcond_signal_all(mem_ptr_t<sys_lwcond_t> lwcond) { sys_lwcond.Log("sys_lwcond_signal_all(lwcond_addr=0x%x)", lwcond.GetAddr()); if (!lwcond.IsGood()) return CELL_EFAULT; LWCond* lwc; u32 id = (u32)lwcond->lwcond_queue; if (!sys_lwcond.CheckId(id, lwc)) return CELL_ESRCH; lwc->signal_all(); return CELL_OK; }
int sys_lwcond_signal_to(mem_ptr_t<sys_lwcond_t> lwcond, u32 ppu_thread_id) { sys_lwcond.Log("sys_lwcond_signal_to(lwcond_addr=0x%x, ppu_thread_id=%d)", lwcond.GetAddr(), ppu_thread_id); if (!lwcond.IsGood()) return CELL_EFAULT; LWCond* lwc; u32 id = (u32)lwcond->lwcond_queue; if (!sys_lwcond.CheckId(id, lwc)) return CELL_ESRCH; if (!lwc->signal_to(ppu_thread_id)) return CELL_EPERM; return CELL_OK; }
int cellVideoOutGetResolution(u32 resolutionId, mem_ptr_t<CellVideoOutResolution> resolution) { cellSysutil->Log("cellVideoOutGetResolution(resolutionId=%d, resolution_addr=0x%x)", resolutionId, resolution.GetAddr()); u32 num = ResolutionIdToNum(resolutionId); if(!num) return CELL_EINVAL; resolution->width = ResolutionTable[num].width; resolution->height = ResolutionTable[num].height; return CELL_VIDEO_OUT_SUCCEEDED; }
int cellFontCloseFont(mem_ptr_t<CellFont> font) { cellFont->Warning("cellFontCloseFont(font_addr=0x%x)", font.GetAddr()); if (!font.IsGood()) return CELL_FONT_ERROR_INVALID_PARAMETER; if (font->origin == CELL_FONT_OPEN_FONTSET || font->origin == CELL_FONT_OPEN_FONT_FILE || font->origin == CELL_FONT_OPEN_MEMORY) Memory.Free(font->fontdata_addr); return CELL_FONT_OK; }
int cellPamfReaderSetStreamWithTypeAndIndex(mem_ptr_t<CellPamfReader> pSelf, u8 streamType, u8 streamIndex) { cellPamf.Warning("cellPamfReaderSetStreamWithTypeAndIndex(pSelf=0x%x, streamType=%d, streamIndex=%d)", pSelf.GetAddr(), streamType, streamIndex); if (!pSelf.IsGood() || !Memory.IsGoodAddr(pSelf->pAddr)) return CELL_PAMF_ERROR_INVALID_ARG; const mem_ptr_t<PamfHeader> pAddr(pSelf->pAddr); u32 found = 0; for (u8 i = 0; i < pAddr->stream_count; i++) { const u8 type = pamfGetStreamType(pSelf, i); if (type == streamType) { found++; } else switch(streamType) { case CELL_PAMF_STREAM_TYPE_VIDEO: if (type == CELL_PAMF_STREAM_TYPE_AVC || type == CELL_PAMF_STREAM_TYPE_M2V) { found++; } break; case CELL_PAMF_STREAM_TYPE_AUDIO: if (type == CELL_PAMF_STREAM_TYPE_ATRAC3PLUS || type == CELL_PAMF_STREAM_TYPE_AC3 || type == CELL_PAMF_STREAM_TYPE_PAMF_LPCM) { found++; } break; default: if (streamType > 5) { return CELL_PAMF_ERROR_INVALID_ARG; } } if (found > streamIndex) { pSelf->stream = i; return i; } } return CELL_PAMF_ERROR_STREAM_NOT_FOUND; }
int cellSpursInitialize(mem_ptr_t<CellSpurs> spurs, int nSpus, int spuPriority, int ppuPriority, bool exitIfNoWork) { cellSpurs.Warning("cellSpursInitialize(spurs_addr=0x%x, nSpus=%u, spuPriority=%u, ppuPriority=%u, exitIfNoWork=%u)", spurs.GetAddr(), nSpus, spuPriority, ppuPriority, exitIfNoWork); if(!spurs.IsGood()) return CELL_SPURS_CORE_ERROR_NULL_POINTER; SPURSManagerAttribute *attr = new SPURSManagerAttribute(nSpus, spuPriority, ppuPriority, exitIfNoWork); spurs->spurs = new SPURSManager(attr); return CELL_OK; }
//128 int sys_event_queue_create(mem32_t equeue_id, mem_ptr_t<sys_event_queue_attr> attr, u64 event_queue_key, int size) { sys_event.Warning("sys_event_queue_create(equeue_id_addr=0x%x, attr_addr=0x%x, event_queue_key=0x%llx, size=%d)", equeue_id.GetAddr(), attr.GetAddr(), event_queue_key, size); if(size <= 0 || size > 127) { return CELL_EINVAL; } if(!equeue_id.IsGood() || !attr.IsGood()) { return CELL_EFAULT; } switch (attr->protocol.ToBE()) { case se32(SYS_SYNC_PRIORITY): break; case se32(SYS_SYNC_RETRY): sys_event.Error("Invalid SYS_SYNC_RETRY protocol attr"); return CELL_EINVAL; case se32(SYS_SYNC_PRIORITY_INHERIT): sys_event.Error("Invalid SYS_SYNC_PRIORITY_INHERIT protocol attr"); return CELL_EINVAL; case se32(SYS_SYNC_FIFO): break; default: sys_event.Error("Unknown 0x%x protocol attr", (u32)attr->protocol); return CELL_EINVAL; } switch (attr->type.ToBE()) { case se32(SYS_PPU_QUEUE): break; case se32(SYS_SPU_QUEUE): break; default: sys_event.Error("Unknown 0x%x type attr", (u32)attr->type); return CELL_EINVAL; } if (event_queue_key && Emu.GetEventManager().CheckKey(event_queue_key)) { return CELL_EEXIST; } EventQueue* eq = new EventQueue((u32)attr->protocol, (int)attr->type, attr->name_u64, event_queue_key, size); if (event_queue_key && !Emu.GetEventManager().RegisterKey(eq, event_queue_key)) { delete eq; return CELL_EAGAIN; } equeue_id = sys_event.GetNewId(eq); sys_event.Warning("*** event_queue created [%s] (protocol=0x%x, type=0x%x): id = %d", wxString(attr->name, 8).wx_str(), (u32)attr->protocol, (int)attr->type, equeue_id.GetValue()); return CELL_OK; }