diff --git a/Utilities/Log.h b/Utilities/Log.h index 32c0f18e81..8dbeb71e07 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -123,7 +123,7 @@ static struct { inline operator Log::LogType() { return Log::LogType::PPU; } } P static struct { inline operator Log::LogType() { return Log::LogType::SPU; } } SPU; static struct { inline operator Log::LogType() { return Log::LogType::TTY; } } TTY; -inline void log_message(Log::LogType type, Log::LogSeverity sev, std::string text) +inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text) { //another msvc bug makes this not work, uncomment this and delete everything else in this function when it's fixed //Log::LogManager::getInstance().log({logType, severity, text}) @@ -133,8 +133,8 @@ inline void log_message(Log::LogType type, Log::LogSeverity sev, std::string tex } template -inline void log_message(Log::LogType type, Log::LogSeverity sev, std::string text, T arg, Ts... args) +inline void log_message(Log::LogType type, Log::LogSeverity sev, const char* text, T arg, Ts... args) { - Log::LogMessage msg{type, sev, fmt::Format(text,arg,args...)}; + Log::LogMessage msg{type, sev, fmt::Format(text, arg, args...)}; Log::LogManager::getInstance().log(msg); } \ No newline at end of file diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 6e79d92d07..9f1709c0bf 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -4,38 +4,6 @@ extern const std::string fmt::placeholder = "???"; - -//wrapper to deal with advance sprintf formating options with automatic length finding -//can't take strings by reference because of "va_start", so overload it with char * -std::string fmt::FormatV(const char *fmt, va_list args) -{ - size_t length = 256; - std::string str; - - for (;;) - { - std::vector buffptr(length); -#if !defined(_MSC_VER) - size_t printlen = vsnprintf(buffptr.data(), length, fmt, args); -#else - size_t printlen = vsnprintf_s(buffptr.data(), length, length - 1, fmt, args); -#endif - if (printlen < length) - { - str = std::string(buffptr.data(), printlen); - break; - } - length *= 2; - } - return str; -} - -std::string fmt::FormatV(std::string fmt, va_list args) -{ - std::string str = FormatV(fmt.c_str(), args); - return str; -} - std::string replace_first(const std::string& src, const std::string& from, const std::string& to) { auto pos = src.find(from); diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index de78cb74a8..1914cb26e0 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -96,15 +96,9 @@ namespace fmt{ template T by_value(T x) { return x; } - //wrapper to deal with advance sprintf formating options with automatic length finding - //can't take strings by reference because of "va_start", so overload it with char * - string FormatV(const char *fmt, va_list args); - - string FormatV(string fmt, va_list args); - //wrapper to deal with advance sprintf formating options with automatic length finding template - string Format(const string &fmt, Args ... parameters) + string Format(const char* fmt, Args ... parameters) { size_t length = 256; string str; @@ -115,10 +109,10 @@ namespace fmt{ #if !defined(_MSC_VER) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-security" - size_t printlen = snprintf(buffptr.data(), length, fmt.c_str(), std::forward(parameters)...); + size_t printlen = snprintf(buffptr.data(), length, fmt, std::forward(parameters)...); #pragma clang diagnostic pop #else - size_t printlen = _snprintf_s(buffptr.data(), length, length - 1, fmt.c_str(), std::forward(parameters)...); + size_t printlen = _snprintf_s(buffptr.data(), length, length - 1, fmt, std::forward(parameters)...); #endif if (printlen < length) { diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index c512d083ea..26352c1c4d 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -3983,7 +3983,7 @@ private: void UNK(const std::string& err, bool pause = true) { - LOG_ERROR(PPU, err + fmt::Format(" #pc: 0x%x", CPU.PC)); + LOG_ERROR(PPU, "%s #pc: 0x%x", err.c_str(), CPU.PC); if(!pause) return; @@ -3992,17 +3992,17 @@ private: for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "r%d = 0x%llx", i, CPU.GPR[i]); for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "f%d = %llf", i, CPU.FPR[i]); for(uint i=0; i<32; ++i) LOG_NOTICE(PPU, "v%d = 0x%s [%s]", i, CPU.VPR[i].to_hex().c_str(), CPU.VPR[i].to_xyzw().c_str()); - LOG_NOTICE(PPU, "CR = 0x%08x", CPU.CR); + LOG_NOTICE(PPU, "CR = 0x%08x", CPU.CR.CR); LOG_NOTICE(PPU, "LR = 0x%llx", CPU.LR); LOG_NOTICE(PPU, "CTR = 0x%llx", CPU.CTR); - LOG_NOTICE(PPU, "XER = 0x%llx [CA=%lld | OV=%lld | SO=%lld]", CPU.XER, fmt::by_value(CPU.XER.CA), fmt::by_value(CPU.XER.OV), fmt::by_value(CPU.XER.SO)); + LOG_NOTICE(PPU, "XER = 0x%llx [CA=%lld | OV=%lld | SO=%lld]", CPU.XER.XER, fmt::by_value(CPU.XER.CA), fmt::by_value(CPU.XER.OV), fmt::by_value(CPU.XER.SO)); LOG_NOTICE(PPU, "FPSCR = 0x%x " "[RN=%d | NI=%d | XE=%d | ZE=%d | UE=%d | OE=%d | VE=%d | " "VXCVI=%d | VXSQRT=%d | VXSOFT=%d | FPRF=%d | " "FI=%d | FR=%d | VXVC=%d | VXIMZ=%d | " "VXZDZ=%d | VXIDI=%d | VXISI=%d | VXSNAN=%d | " "XX=%d | ZX=%d | UX=%d | OX=%d | VX=%d | FEX=%d | FX=%d]", - CPU.FPSCR, + CPU.FPSCR.FPSCR, fmt::by_value(CPU.FPSCR.RN), fmt::by_value(CPU.FPSCR.NI), fmt::by_value(CPU.FPSCR.XE), fmt::by_value(CPU.FPSCR.ZE), fmt::by_value(CPU.FPSCR.UE), fmt::by_value(CPU.FPSCR.OE), fmt::by_value(CPU.FPSCR.VE), fmt::by_value(CPU.FPSCR.VXCVI), fmt::by_value(CPU.FPSCR.VXSQRT), fmt::by_value(CPU.FPSCR.VXSOFT), fmt::by_value(CPU.FPSCR.FPRF), diff --git a/rpcs3/Emu/Cell/SPUInterpreter.h b/rpcs3/Emu/Cell/SPUInterpreter.h index 152db4a7c6..ac6e5df820 100644 --- a/rpcs3/Emu/Cell/SPUInterpreter.h +++ b/rpcs3/Emu/Cell/SPUInterpreter.h @@ -1497,7 +1497,7 @@ private: void UNK(const std::string& err) { - LOG_ERROR(Log::SPU, err + fmt::Format(" #pc: 0x%x", CPU.PC)); + LOG_ERROR(Log::SPU, "%s #pc: 0x%x", err.c_str(), CPU.PC); Emu.Pause(); for(uint i=0; i<128; ++i) LOG_NOTICE(Log::SPU, "r%d = 0x%s", i, CPU.GPR[i].to_hex().c_str()); } diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index 787e5e2047..390db51594 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -3779,7 +3779,7 @@ private: void UNK(const std::string& err) { - LOG_ERROR(Log::SPU, err + fmt::Format(" #pc: 0x%x", CPU.PC)); + LOG_ERROR(Log::SPU, "%s #pc: 0x%x", err.c_str(), CPU.PC); c.mov(cpu_dword(PC), CPU.PC); do_finalize = true; Emu.Pause(); diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 6593244d40..2a460fb235 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -593,8 +593,8 @@ void GLTexture::Save(RSXTexture& tex) if (!rExists(dir_path)) rMkdir(dir_path); u32 count = 0; - while (rExists(fmt::Format(file_fmt, count))) count++; - Save(tex, fmt::Format(file_fmt, count)); + while (rExists(fmt::Format(file_fmt.c_str(), count))) count++; + Save(tex, fmt::Format(file_fmt.c_str(), count)); } void GLTexture::Bind() diff --git a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp index e460b06f35..b67cccd255 100644 --- a/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/RSX/GL/GLVertexProgram.cpp @@ -436,7 +436,7 @@ std::string GLVertexDecompilerThread::BuildCode() "%s\n" "%s"; - return fmt::Format(prot, p.c_str(), fp.c_str(), f.c_str()); + return fmt::Format(prot.c_str(), p.c_str(), fp.c_str(), f.c_str()); } void GLVertexDecompilerThread::Task() @@ -648,7 +648,7 @@ void GLVertexProgram::Compile() delete[] buf; } - LOG_NOTICE(RSX, shader); + LOG_NOTICE(RSX, "%s", shader.c_str()); Emu.Pause(); } //else LOG_WARNING(RSX, "Vertex shader compiled successfully!"); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 3f42777a40..952a963f1b 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -149,7 +149,7 @@ u32 RSXThread::OutOfArgsCount(const uint x, const u32 cmd, const u32 count, cons debug += "("; for(u32 i=0; i void Notice(const u32 id, const char* fmt, Targs... args) const + template __noinline void Notice(const u32 id, const char* fmt, Targs... args) const { LogOutput(LogNotice, id, ": ", fmt::Format(fmt, args...)); } - template void Notice(const char* fmt, Targs... args) const + template __noinline void Notice(const char* fmt, Targs... args) const { LogOutput(LogNotice, ": ", fmt::Format(fmt, args...)); } @@ -55,42 +55,42 @@ public: } } - template void Success(const u32 id, const char* fmt, Targs... args) const + template __noinline void Success(const u32 id, const char* fmt, Targs... args) const { LogOutput(LogSuccess, id, ": ", fmt::Format(fmt, args...)); } - template void Success(const char* fmt, Targs... args) const + template __noinline void Success(const char* fmt, Targs... args) const { LogOutput(LogSuccess, ": ", fmt::Format(fmt, args...)); } - template void Warning(const u32 id, const char* fmt, Targs... args) const + template __noinline void Warning(const u32 id, const char* fmt, Targs... args) const { LogOutput(LogWarning, id, " warning: ", fmt::Format(fmt, args...)); } - template void Warning(const char* fmt, Targs... args) const + template __noinline void Warning(const char* fmt, Targs... args) const { LogOutput(LogWarning, " warning: ", fmt::Format(fmt, args...)); } - template void Error(const u32 id, const char* fmt, Targs... args) const + template __noinline void Error(const u32 id, const char* fmt, Targs... args) const { LogOutput(LogError, id, " error: ", fmt::Format(fmt, args...)); } - template void Error(const char* fmt, Targs... args) const + template __noinline void Error(const char* fmt, Targs... args) const { LogOutput(LogError, " error: ", fmt::Format(fmt, args...)); } - template void Todo(const u32 id, const char* fmt, Targs... args) const + template __noinline void Todo(const u32 id, const char* fmt, Targs... args) const { LogOutput(LogError, id, " TODO: ", fmt::Format(fmt, args...)); } - template void Todo(const char* fmt, Targs... args) const + template __noinline void Todo(const char* fmt, Targs... args) const { LogOutput(LogError, " TODO: ", fmt::Format(fmt, args...)); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index b137cbe5d2..5d12d644fe 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -187,7 +187,6 @@ int cellGameContentPermit(vm::ptr contentInfoPath, vm: return CELL_GAME_ERROR_FAILURE; } - // TODO: make it better strcpy_trunc(*contentInfoPath, contentInfo); strcpy_trunc(*usrdirPath, usrdir); diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index e26f3597ff..377ab0970e 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -60,7 +60,7 @@ static func_caller* sc_table[kSyscallTableLength] = bind_func(sys_process_get_number_of_object), //12 (0x00C) bind_func(sys_process_get_id), //13 (0x00D) - null_func,//bind_func(sys_process_is_spu_lock_line_reservation_address), //14 (0x00E) + bind_func(sys_process_is_spu_lock_line_reservation_address), //14 (0x00E) null_func, null_func, null_func, //15-17 UNS diff --git a/rpcs3/Emu/SysCalls/lv2/sys_memory.h b/rpcs3/Emu/SysCalls/lv2/sys_memory.h index 3941590e02..fd4c9102b9 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_memory.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_memory.h @@ -1,13 +1,22 @@ #pragma once -#define SYS_MEMORY_CONTAINER_ID_INVALID 0xFFFFFFFF -#define SYS_MEMORY_ACCESS_RIGHT_NONE 0x00000000000000F0ULL -#define SYS_MEMORY_ACCESS_RIGHT_PPU_THREAD 0x0000000000000008ULL -#define SYS_MEMORY_ACCESS_RIGHT_HANDLER 0x0000000000000004ULL -#define SYS_MEMORY_ACCESS_RIGHT_SPU_THREAD 0x0000000000000002ULL -#define SYS_MEMORY_ACCESS_RIGHT_SPU_RAW 0x0000000000000001ULL -#define SYS_MEMORY_ATTR_READ_ONLY 0x0000000000080000ULL -#define SYS_MEMORY_ATTR_READ_WRITE 0x0000000000040000ULL +enum : u32 +{ + SYS_MEMORY_CONTAINER_ID_INVALID = 0xFFFFFFFF, +}; + +enum : u64 +{ + SYS_MEMORY_ACCESS_RIGHT_NONE = 0x00000000000000F0ULL, + SYS_MEMORY_ACCESS_RIGHT_ANY = 0x000000000000000FULL, + SYS_MEMORY_ACCESS_RIGHT_PPU_THR = 0x0000000000000008ULL, + SYS_MEMORY_ACCESS_RIGHT_HANDLER = 0x0000000000000004ULL, + SYS_MEMORY_ACCESS_RIGHT_SPU_THR = 0x0000000000000002ULL, + SYS_MEMORY_ACCESS_RIGHT_RAW_SPU = 0x0000000000000001ULL, + + SYS_MEMORY_ATTR_READ_ONLY = 0x0000000000080000ULL, + SYS_MEMORY_ATTR_READ_WRITE = 0x0000000000040000ULL, +}; enum { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp index 54ed003377..039bbe66b2 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp @@ -3,6 +3,7 @@ #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" +#include "sys_memory.h" #include "sys_process.h" SysCallBase sys_process("sys_process"); @@ -212,6 +213,24 @@ s32 sys_process_get_id(u32 object, vm::ptr> buffer, u32 size, vm::ptr< return CELL_OK; } +s32 process_is_spu_lock_line_reservation_address(u32 addr, u64 flags) +{ + if (!flags || flags & ~(SYS_MEMORY_ACCESS_RIGHT_SPU_THR | SYS_MEMORY_ACCESS_RIGHT_RAW_SPU)) + { + return CELL_EINVAL; + } + + // TODO + return CELL_OK; +} + +s32 sys_process_is_spu_lock_line_reservation_address(u32 addr, u64 flags) +{ + sys_process.Warning("sys_process_is_spu_lock_line_reservation_address(addr=0x%x, flags=0x%llx)", addr, flags); + + return process_is_spu_lock_line_reservation_address(addr, flags); +} + s32 sys_process_get_paramsfo(vm::ptr buffer) { sys_process.Todo("sys_process_get_paramsfo(buffer_addr=0x%x) -> CELL_ENOENT", buffer.addr()); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.h b/rpcs3/Emu/SysCalls/lv2/sys_process.h index 2d6c642d34..faa8194bbe 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.h @@ -26,6 +26,7 @@ enum // Auxiliary functions s32 process_getpid(); s32 process_get_sdk_version(u32 pid, s32& ver); +s32 process_is_spu_lock_line_reservation_address(u32 addr, u64 flags); // SysCalls s32 sys_process_getpid(); @@ -35,6 +36,7 @@ s32 sys_process_get_id(u32 object, vm::ptr> buffer, u32 size, vm::ptr< s32 sys_process_get_paramsfo(vm::ptr buffer); s32 sys_process_get_sdk_version(u32 pid, vm::ptr> version); s32 sys_process_get_status(u64 unk); +s32 sys_process_is_spu_lock_line_reservation_address(u32 addr, u64 flags); s32 sys_process_exit(s32 errorcode); s32 sys_process_kill(u32 pid); s32 sys_process_wait_for_child(u32 pid, vm::ptr> status, u64 unk); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 80ceb65097..e92724f006 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -269,7 +269,7 @@ void Emulator::Load() } catch(const std::string& e) { - LOG_ERROR(LOADER, e); + LOG_ERROR(LOADER, "%s", e.c_str()); is_error = true; } catch(...) diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp index 4033c2986e..398c893827 100644 --- a/rpcs3/Gui/VHDDManager.cpp +++ b/rpcs3/Gui/VHDDManager.cpp @@ -251,9 +251,9 @@ void VHDDExplorer::OnCreateDir(wxCommandEvent& event) { int i = 1; static const std::string& fmt = "New Dir (%d)"; - while(m_hdd->HasEntry(fmt::Format(fmt, i))) i++; + while(m_hdd->HasEntry(fmt::Format(fmt.c_str(), i))) i++; - m_hdd->Create(vfsHDD_Entry_Dir, fmt::Format(fmt, i)); + m_hdd->Create(vfsHDD_Entry_Dir, fmt::Format(fmt.c_str(), i)); UpdateList(); } @@ -261,9 +261,9 @@ void VHDDExplorer::OnCreateFile(wxCommandEvent& event) { int i = 1; static const std::string& fmt = "New File (%d)"; - while (m_hdd->HasEntry(fmt::Format(fmt, i))) i++; + while (m_hdd->HasEntry(fmt::Format(fmt.c_str(), i))) i++; - m_hdd->Create(vfsHDD_Entry_File, fmt::Format(fmt, i)); + m_hdd->Create(vfsHDD_Entry_File, fmt::Format(fmt.c_str(), i)); UpdateList(); }