From bfff7ff5f9db8e064b9830b90405f223f9da06ae Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 29 Nov 2014 19:01:04 +0200 Subject: [PATCH] Fix CellVideoOut values, formatting fixes --- rpcs3/Emu/RSX/sysutil_video.h | 4 +- rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp | 96 +++++++++++++---------- rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp | 10 +-- rpcs3/Emu/SysCalls/lv2/sys_memory.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/sys_process.cpp | 30 ++++++- rpcs3/Gui/KernelExplorer.cpp | 2 +- 6 files changed, 87 insertions(+), 57 deletions(-) diff --git a/rpcs3/Emu/RSX/sysutil_video.h b/rpcs3/Emu/RSX/sysutil_video.h index c5bf9426cd..e501f73b03 100644 --- a/rpcs3/Emu/RSX/sysutil_video.h +++ b/rpcs3/Emu/RSX/sysutil_video.h @@ -16,8 +16,8 @@ enum VideoErrorCode enum CellVideoOut { - CELL_VIDEO_OUT_PRIMARY, - CELL_VIDEO_OUT_SECONDARY, + CELL_VIDEO_OUT_PRIMARY = 0, + CELL_VIDEO_OUT_SECONDARY = 1, }; enum CellVideoOutResolutionId diff --git a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp index 9c5feb2a0c..f2fc7b8fd9 100644 --- a/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp +++ b/rpcs3/Emu/SysCalls/lv2/lv2Fs.cpp @@ -40,7 +40,7 @@ s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::p LV2_LOCK(0); s32 _oflags = flags; - if(flags & CELL_O_CREAT) + if (flags & CELL_O_CREAT) { _oflags &= ~CELL_O_CREAT; Emu.GetVFS().CreateFile(_path); @@ -48,7 +48,7 @@ s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::p vfsOpenMode o_mode; - switch(flags & CELL_O_ACCMODE) + switch (flags & CELL_O_ACCMODE) { case CELL_O_RDONLY: _oflags &= ~CELL_O_RDONLY; @@ -88,7 +88,7 @@ s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::p break; } - if(_oflags != 0) + if (_oflags != 0) { sys_fs->Error("\"%s\" has unknown flags! flags: 0x%08x", path.get_ptr(), flags); return CELL_EINVAL; @@ -102,7 +102,7 @@ s32 cellFsOpen(vm::ptr path, s32 flags, vm::ptr> fd, vm::p vfsFileBase* stream = Emu.GetVFS().OpenFile(_path, o_mode); - if(!stream || !stream->IsOpened()) + if (!stream || !stream->IsOpened()) { delete stream; sys_fs->Error("\"%s\" not found! flags: 0x%08x", path.get_ptr(), flags); @@ -124,9 +124,11 @@ s32 cellFsRead(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr> nread) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; - if (nbytes != (u32)nbytes) return CELL_ENOMEM; + if (nbytes != (u32)nbytes) + return CELL_ENOMEM; // TODO: checks @@ -145,7 +147,7 @@ s32 cellFsWrite(u32 fd, vm::ptr buf, u64 nbytes, vm::ptr nwrite LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) return CELL_ESRCH; if (nbytes != (u32)nbytes) return CELL_ENOMEM; @@ -164,7 +166,7 @@ s32 cellFsClose(u32 fd) LV2_LOCK(0); - if(!Emu.GetIdManager().RemoveID(fd)) + if (!Emu.GetIdManager().RemoveID(fd)) return CELL_ESRCH; return CELL_OK; @@ -177,7 +179,7 @@ s32 cellFsOpendir(vm::ptr path, vm::ptr fd) LV2_LOCK(0); vfsDirBase* dir = Emu.GetVFS().OpenDir(path.get_ptr()); - if(!dir || !dir->IsOpened()) + if (!dir || !dir->IsOpened()) { delete dir; return CELL_ENOENT; @@ -194,11 +196,11 @@ s32 cellFsReaddir(u32 fd, vm::ptr dir, vm::ptr nread) LV2_LOCK(0); vfsDirBase* directory; - if(!sys_fs->CheckId(fd, directory)) + if (!sys_fs->CheckId(fd, directory)) return CELL_ESRCH; const DirEntryInfo* info = directory->Read(); - if(info) + if (info) { dir->d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY; dir->d_namlen = u8(std::min((u32)info->name.length(), (u32)CELL_MAX_FS_FILE_NAME_LENGTH)); @@ -219,7 +221,7 @@ s32 cellFsClosedir(u32 fd) LV2_LOCK(0); - if(!Emu.GetIdManager().RemoveID(fd)) + if (!Emu.GetIdManager().RemoveID(fd)) return CELL_ESRCH; return CELL_OK; @@ -276,9 +278,8 @@ s32 cellFsFstat(u32 fd, vm::ptr sb) IDType type; vfsStream* file; - if(!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) { + if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) return CELL_ESRCH; - } sb->st_mode = CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR | @@ -305,9 +306,9 @@ s32 cellFsMkdir(vm::ptr path, u32 mode) const std::string _path = path.get_ptr(); - if(Emu.GetVFS().ExistsDir(_path)) + if (Emu.GetVFS().ExistsDir(_path)) return CELL_EEXIST; - if(!Emu.GetVFS().CreateDir(_path)) + if (!Emu.GetVFS().CreateDir(_path)) return CELL_EBUSY; return CELL_OK; @@ -378,10 +379,10 @@ s32 cellFsRmdir(vm::ptr path) std::string _path = path.get_ptr(); vfsDir d; - if(!d.IsExists(_path)) + if (!d.IsExists(_path)) return CELL_ENOENT; - if(!d.Remove(_path)) + if (!d.Remove(_path)) return CELL_EBUSY; return CELL_OK; @@ -426,9 +427,9 @@ s32 cellFsLseek(u32 fd, s64 offset, u32 whence, vm::ptr> pos) IDType type; vfsStream* file; - if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) { + if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) return CELL_ESRCH; - } + *pos = file->Seek(offset, seek_mode); return CELL_OK; } @@ -441,9 +442,9 @@ s32 cellFsFtruncate(u32 fd, u64 size) IDType type; vfsStream* file; - if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) { + if (!sys_fs->CheckId(fd, file, type) || type != TYPE_FS_FILE) return CELL_ESRCH; - } + u64 initialSize = file->GetSize(); if (initialSize < size) @@ -471,7 +472,7 @@ s32 cellFsTruncate(vm::ptr path, u64 size) LV2_LOCK(0); vfsFile f(path.get_ptr(), vfsReadWrite); - if(!f.IsOpened()) + if (!f.IsOpened()) { sys_fs->Warning("cellFsTruncate: \"%s\" not found.", path.get_ptr()); return CELL_ENOENT; @@ -504,7 +505,8 @@ s32 cellFsFGetBlockSize(u32 fd, vm::ptr sector_size, vm::ptr block_siz LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; *sector_size = 4096; // ? *block_size = 4096; // ? @@ -547,11 +549,11 @@ s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr entries, u32 LV2_LOCK(0); vfsDirBase* directory; - if(!sys_fs->CheckId(fd, directory)) + if (!sys_fs->CheckId(fd, directory)) return CELL_ESRCH; const DirEntryInfo* info = directory->Read(); - if(info) + if (info) { entries->attribute.st_mode = CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR | @@ -585,17 +587,16 @@ s32 cellFsStReadInit(u32 fd, vm::ptr ringbuf) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; fs_config.m_ring_buffer = *ringbuf; // If the size is less than 1MB - if(ringbuf->ringbuf_size < 0x40000000) { + if (ringbuf->ringbuf_size < 0x40000000) fs_config.m_alloc_mem_size = (((u32)ringbuf->ringbuf_size + 64 * 1024 - 1) / (64 * 1024)) * (64 * 1024); - } - else { + else fs_config.m_alloc_mem_size = (((u32)ringbuf->ringbuf_size + 1024 * 1024 - 1) / (1024 * 1024)) * (1024 * 1024); - } // alloc memory fs_config.m_buffer = (u32)Memory.Alloc(fs_config.m_alloc_mem_size, 1024); @@ -613,7 +614,8 @@ s32 cellFsStReadFinish(u32 fd) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; Memory.Free(fs_config.m_buffer); fs_config.m_fs_status = CELL_FS_ST_NOT_INITIALIZED; @@ -628,7 +630,8 @@ s32 cellFsStReadGetRingBuf(u32 fd, vm::ptr ringbuf) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; *ringbuf = fs_config.m_ring_buffer; @@ -644,7 +647,8 @@ s32 cellFsStReadGetStatus(u32 fd, vm::ptr status) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; *status = fs_config.m_fs_status; @@ -658,7 +662,8 @@ s32 cellFsStReadGetRegid(u32 fd, vm::ptr regid) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; *regid = fs_config.m_regid; @@ -672,7 +677,8 @@ s32 cellFsStReadStart(u32 fd, u64 offset, u64 size) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; fs_config.m_current_addr = fs_config.m_buffer + (u32)offset; fs_config.m_fs_status = CELL_FS_ST_PROGRESS; @@ -687,7 +693,8 @@ s32 cellFsStReadStop(u32 fd) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; fs_config.m_fs_status = CELL_FS_ST_STOP; @@ -701,7 +708,8 @@ s32 cellFsStRead(u32 fd, u32 buf_addr, u64 size, vm::ptr rsize) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; // TODO: use ringbuffer (fs_config) fs_config.m_regid += size; @@ -721,7 +729,8 @@ s32 cellFsStReadGetCurrentAddr(u32 fd, vm::ptr addr, vm::ptr size) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; return CELL_OK; } @@ -733,7 +742,8 @@ s32 cellFsStReadPutCurrentAddr(u32 fd, u32 addr_addr, u64 size) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; return CELL_OK; } @@ -745,7 +755,8 @@ s32 cellFsStReadWait(u32 fd, u64 size) LV2_LOCK(0); vfsStream* file; - if(!sys_fs->CheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; return CELL_OK; } @@ -757,7 +768,8 @@ s32 cellFsStReadWaitCallback(u32 fd, u64 size, vm::ptrCheckId(fd, file)) return CELL_ESRCH; + if (!sys_fs->CheckId(fd, file)) + return CELL_ESRCH; return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp index 336c88c4bb..9a0da23fe6 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event_flag.cpp @@ -30,9 +30,7 @@ u32 EventFlag::check() } if (m_protocol == SYS_SYNC_PRIORITY) - { target = sq.pop_prio(); - } return target; } @@ -42,13 +40,13 @@ s32 sys_event_flag_create(vm::ptr eflag_id, vm::ptr at sys_event_flag.Warning("sys_event_flag_create(eflag_id_addr=0x%x, attr_addr=0x%x, init=0x%llx)", eflag_id.addr(), attr.addr(), init); - if (eflag_id.addr() == NULL) + if (!eflag_id) { sys_event_flag.Error("sys_event_flag_create(): invalid memory access (eflag_id_addr=0x%x)", eflag_id.addr()); return CELL_EFAULT; } - if (attr.addr() == NULL) + if (!attr) { sys_event_flag.Error("sys_event_flag_create(): invalid memory access (attr_addr=0x%x)", attr.addr()); return CELL_EFAULT; @@ -64,9 +62,7 @@ s32 sys_event_flag_create(vm::ptr eflag_id, vm::ptr at } if (attr->pshared.ToBE() != se32(0x200)) - { return CELL_EINVAL; - } switch (attr->type.ToBE()) { @@ -370,7 +366,7 @@ s32 sys_event_flag_get(u32 eflag_id, vm::ptr flags) { sys_event_flag.Log("sys_event_flag_get(eflag_id=%d, flags_addr=0x%x)", eflag_id, flags.addr()); - if (flags.addr() == NULL) + if (!flags) { sys_event_flag.Error("sys_event_flag_create(): invalid memory access (flags_addr=0x%x)", flags.addr()); return CELL_EFAULT; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp b/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp index 45526a143b..ed68723e9d 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_memory.cpp @@ -28,7 +28,7 @@ s32 sys_memory_allocate(u32 size, u32 flags, u32 alloc_addr_addr) default: return CELL_EINVAL; } - if(!addr) + if (!addr) return CELL_ENOMEM; // Write back the start address of the allocated area. diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp index 964bafcc4b..ea419694d4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp @@ -73,16 +73,27 @@ void sys_game_process_exitspawn( envp++; } - for (auto &arg : argv){ + for (auto &arg : argv) { sys_process.Log("argument: %s", arg.c_str()); } - for (auto &en : env){ + + for (auto &en : env) { sys_process.Log("env_argument: %s", en.c_str()); } + //TODO: execute the file in with the args in argv //and the environment parameters in envp and copy the data //from data_addr into the adress space of the new process //then kill the current process + + Emu.Pause(); + sys_process.Success("Process finished"); + + CallAfter([]() + { + Emu.Stop(); + }); + return; } @@ -121,16 +132,27 @@ void sys_game_process_exitspawn2( envp++; } - for (auto &arg : argv){ + for (auto &arg : argv) { sys_process.Log("argument: %s", arg.c_str()); } - for (auto &en : env){ + + for (auto &en : env) { sys_process.Log("env_argument: %s", en.c_str()); } + //TODO: execute the file in with the args in argv //and the environment parameters in envp and copy the data //from data_addr into the adress space of the new process //then kill the current process + + Emu.Pause(); + sys_process.Success("Process finished"); + + CallAfter([]() + { + Emu.Stop(); + }); + return; } diff --git a/rpcs3/Gui/KernelExplorer.cpp b/rpcs3/Gui/KernelExplorer.cpp index 64e84e36df..9e551f27de 100644 --- a/rpcs3/Gui/KernelExplorer.cpp +++ b/rpcs3/Gui/KernelExplorer.cpp @@ -147,7 +147,7 @@ void KernelExplorer::Update() sprintf(name, "Modules (%d)", count); const auto& node = m_tree->AppendItem(root, name); const auto& objects = Emu.GetIdManager().GetTypeIDs(TYPE_PRX); - sprintf(name, "Segment List (%d)", 2 * objects.size()); // TODO: Assuming 2 segments per PRX file is not good + sprintf(name, "Segment List (%l)", 2 * objects.size()); // TODO: Assuming 2 segments per PRX file is not good m_tree->AppendItem(node, name); for (const auto& id : objects) {