diff --git a/librecomp/include/librecomp/addresses.hpp b/librecomp/include/librecomp/addresses.hpp index 38102bc..0918f4c 100644 --- a/librecomp/include/librecomp/addresses.hpp +++ b/librecomp/include/librecomp/addresses.hpp @@ -7,9 +7,9 @@ namespace recomp { // 512GB (kseg0 size) - constexpr size_t mem_size = 512U * 1024U * 1024U; - // 2GB (Addressable upper half of the address space) - constexpr size_t allocation_size = 2048U * 1024U * 1024U; + constexpr size_t mem_size = 512ULL * 1024ULL * 1024ULL; + // 4GB (the full address space) + constexpr size_t allocation_size = 4096ULL * 1024ULL * 1024ULL; // We need a place in rdram to hold the PI handles, so pick an address in extended rdram constexpr int32_t cart_handle = 0x80800000; constexpr int32_t drive_handle = (int32_t)(cart_handle + sizeof(OSPiHandle)); diff --git a/librecomp/include/librecomp/mods.hpp b/librecomp/include/librecomp/mods.hpp index 00ec367..8a9e04f 100644 --- a/librecomp/include/librecomp/mods.hpp +++ b/librecomp/include/librecomp/mods.hpp @@ -232,6 +232,7 @@ namespace recomp { CodeModLoadError load_mod_code(uint8_t* rdram, const std::unordered_map& section_vrom_map, recomp::mods::ModHandle& mod, int32_t load_address, uint32_t& ram_used, std::string& error_param); CodeModLoadError resolve_code_dependencies(recomp::mods::ModHandle& mod, std::string& error_param); void add_opened_mod(ModManifest&& manifest, std::vector&& game_indices, std::vector&& detected_content_types); + void close_mods(); static void on_code_mod_enabled(ModContext& context, const ModHandle& mod); diff --git a/librecomp/src/mods.cpp b/librecomp/src/mods.cpp index fa9e0dc..9b48e71 100644 --- a/librecomp/src/mods.cpp +++ b/librecomp/src/mods.cpp @@ -460,9 +460,18 @@ void recomp::mods::ModContext::register_game(const std::string& mod_game_id) { mod_game_ids.emplace(mod_game_id, mod_game_ids.size()); } +void recomp::mods::ModContext::close_mods() { + opened_mods_by_id.clear(); + opened_mods.clear(); + mod_ids.clear(); + enabled_mods.clear(); +} + std::vector recomp::mods::ModContext::scan_mod_folder(const std::filesystem::path& mod_folder) { std::vector ret{}; std::error_code ec; + close_mods(); + for (const auto& mod_path : std::filesystem::directory_iterator{mod_folder, std::filesystem::directory_options::skip_permission_denied, ec}) { bool is_mod = false; bool requires_manifest = true; diff --git a/librecomp/src/recomp.cpp b/librecomp/src/recomp.cpp index ad1cf00..499749a 100644 --- a/librecomp/src/recomp.cpp +++ b/librecomp/src/recomp.cpp @@ -648,7 +648,7 @@ void recomp::start( } } #else - rdram = (uint8_t*)mmap(NULL, allocation_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); + rdram = (uint8_t*)mmap(NULL, allocation_size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0); alloc_failed = rdram == reinterpret_cast(MAP_FAILED); if (!alloc_failed) { // mprotect returns -1 on failure.