diff --git a/CMakeLists.txt b/CMakeLists.txt index 84dc3a40..06d4e348 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ add_executable(shadps4 src/Core/Memory.h src/Core/PS4/Linker.cpp src/Core/PS4/Linker.h - "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Util/StringUtil.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/Debug.h" "src/Core/PS4/HLE/Kernel/MemoryManagement.cpp" "src/Core/PS4/HLE/Kernel/MemoryManagement.h" "src/Core/PS4/HLE/Kernel/MemMngCodes.h") + "src/Util/Singleton.h" "src/Util/Disassembler.cpp" "src/Util/Disassembler.h" "src/Util/StringUtil.h" "src/Core/PS4/Util/aerolib.h" "src/Core/PS4/Loader/SymbolsResolver.h" "src/Core/PS4/Loader/SymbolsResolver.cpp" "src/Core/PS4/HLE/Libs.cpp" "src/Core/PS4/HLE/Libs.h" "src/Core/PS4/HLE/LibC.cpp" "src/Core/PS4/HLE/LibC.h" "src/Lib/Timer.cpp" "src/Lib/Timer.h" "src/Core/PS4/HLE/LibKernel.cpp" "src/Core/PS4/HLE/LibKernel.h" "src/Core/PS4/HLE/LibSceVideoOut.cpp" "src/Core/PS4/HLE/LibSceVideoOut.h" "src/Core/PS4/HLE/LibSceGnmDriver.cpp" "src/Core/PS4/HLE/LibSceGnmDriver.h" "src/Core/PS4/HLE/Kernel/ThreadManagement.cpp" "src/Core/PS4/HLE/Kernel/ThreadManagement.h" "src/Core/PS4/HLE/ErrorCodes.h" "src/Debug.h" "src/Core/PS4/HLE/Kernel/MemoryManagement.cpp" "src/Core/PS4/HLE/Kernel/MemoryManagement.h" "src/Core/PS4/HLE/Kernel/MemMngCodes.h" "src/Core/PS4/HLE/Kernel/PhysicalMemory.cpp" "src/Util/StringUtil.cpp") find_package(OpenGL REQUIRED) target_link_libraries(shadps4 PUBLIC fmt spdlog IMGUI SDL3-shared ${OPENGL_LIBRARY}) diff --git a/src/Core/PS4/HLE/Kernel/PhysicalMemory.cpp b/src/Core/PS4/HLE/Kernel/PhysicalMemory.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Core/PS4/HLE/Kernel/PhysicalMemory.h b/src/Core/PS4/HLE/Kernel/PhysicalMemory.h new file mode 100644 index 00000000..07a990d8 --- /dev/null +++ b/src/Core/PS4/HLE/Kernel/PhysicalMemory.h @@ -0,0 +1,15 @@ +#pragma once + +namespace HLE::Libs::LibKernel::MemoryManagement { + +class PysicalMemory { + struct AllocatedBlock { + u64 start_addr; + u64 size; + }; + + private: + std::vector m_allocatedBlocks; +}; + +} // namespace HLE::Libs::LibKernel::MemoryManagement \ No newline at end of file diff --git a/src/Core/PS4/Linker.cpp b/src/Core/PS4/Linker.cpp index 8ed91844..b170af8a 100644 --- a/src/Core/PS4/Linker.cpp +++ b/src/Core/PS4/Linker.cpp @@ -427,7 +427,7 @@ void Linker::LoadSymbols(Module* m) sym++) { std::string id = std::string(m->dynamic_info->str_table + sym->st_name); - auto ids = StringUtil::split(id, '#'); + auto ids = StringUtil::split_string(id, '#'); if (ids.size() == 3)//symbols are 3 parts name , library , module { const auto* library = FindLibrary(*m, ids.at(1)); @@ -590,7 +590,7 @@ void Linker::Relocate(Module* m) void Linker::Resolve(const std::string& name, int Symtype, Module* m, SymbolRecord* return_info) { - auto ids = StringUtil::split(name, '#'); + auto ids = StringUtil::split_string(name, '#'); if (ids.size() == 3) // symbols are 3 parts name , library , module { diff --git a/src/Util/StringUtil.cpp b/src/Util/StringUtil.cpp new file mode 100644 index 00000000..e3ebb756 --- /dev/null +++ b/src/Util/StringUtil.cpp @@ -0,0 +1,23 @@ +#include "StringUtil.h" +#include +#include +#include + +namespace StringUtil { + +std::vector split_string(const std::string &str, char delimiter) { + std::stringstream str_stream(str); + std::string segment; + std::vector seglist; + + const size_t num_segments = std::count_if(str.begin(), str.end(), [&](char c) { return c == delimiter; }) + (str.empty() ? 1 : 0); + + seglist.reserve(num_segments); + + while (std::getline(str_stream, segment, delimiter)) { + seglist.push_back(segment); + } + return seglist; +} + +} // namespace StringUtil \ No newline at end of file diff --git a/src/Util/StringUtil.h b/src/Util/StringUtil.h index 3ebc6ae7..97d8eb85 100644 --- a/src/Util/StringUtil.h +++ b/src/Util/StringUtil.h @@ -4,23 +4,6 @@ namespace StringUtil { - static std::vector split(const std::string& s, char seperator) - { - std::vector output; + std::vector split_string(const std::string& str, char delimiter); - std::string::size_type prev_pos = 0, pos = 0; - - while ((pos = s.find(seperator, pos)) != std::string::npos) - { - std::string substring(s.substr(prev_pos, pos - prev_pos)); - - output.push_back(substring); - - prev_pos = ++pos; - } - - output.push_back(s.substr(prev_pos, pos - prev_pos)); // Last word - - return output; - } } \ No newline at end of file