diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 5e274ea22f..dbac50e797 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -131,9 +131,12 @@ namespace vm location_info g_locations[memory_location_count] = { { 0x00010000, 0x2FFF0000, ps3::main_alloc, ps3::main_fixed_alloc, ps3::main_dealloc }, - { 0x00010000, 0x2FFF0000, ps3::stack_alloc, ps3::stack_fixed_alloc, ps3::stack_dealloc }, + { 0xD0000000, 0x10000000, ps3::stack_alloc, ps3::stack_fixed_alloc, ps3::stack_dealloc }, + + //remove me { 0x00010000, 0x2FFF0000, ps3::sprx_alloc, ps3::sprx_fixed_alloc, ps3::sprx_dealloc }, - { 0x00010000, 0x2FFF0000, ps3::user_space_alloc, ps3::user_space_fixed_alloc, ps3::user_space_dealloc }, + + { 0x30000000, 0x10000000, ps3::user_space_alloc, ps3::user_space_fixed_alloc, ps3::user_space_dealloc }, }; void close() diff --git a/rpcs3/Emu/Memory/vm.h b/rpcs3/Emu/Memory/vm.h index ac8c1dd12e..0d5859a8ee 100644 --- a/rpcs3/Emu/Memory/vm.h +++ b/rpcs3/Emu/Memory/vm.h @@ -3,30 +3,19 @@ namespace vm { - enum memory_location + enum memory_location : uint { main, stack, + + //remove me sprx, + user_space, memory_location_count }; - struct location_info - { - u32 addr_offset; - u32 size; - - u32(*allocator)(u32 size); - u32(*fixed_allocator)(u32 addr, u32 size); - void(*deallocator)(u32 addr); - - u32 alloc_offset; - }; - - extern location_info g_locations[memory_location_count]; - static void set_stack_size(u32 size) {} static void initialize_stack() {} @@ -200,4 +189,34 @@ namespace vm #include "vm_ref.h" #include "vm_ptr.h" -#include "vm_var.h" \ No newline at end of file +#include "vm_var.h" + +namespace vm +{ + struct location_info + { + u32 addr_offset; + u32 size; + + u32(*allocator)(u32 size); + u32(*fixed_allocator)(u32 addr, u32 size); + void(*deallocator)(u32 addr); + + u32 alloc_offset; + + template + ptr alloc(u32 count) const + { + return ptr::make(allocator(count * sizeof(T))); + } + }; + + extern location_info g_locations[memory_location_count]; + + template + location_info& get() + { + assert(location < memory_location_count); + return g_locations[location]; + } +} diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 223bda5243..9bef4bedee 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -165,12 +165,12 @@ namespace vm __forceinline T& operator [](typename remove_be_t::type index) const { - return vm::get_ref(m_addr + sizeof(AT)* index); + return vm::get_ref(m_addr + sizeof(T)* index); } __forceinline T& operator [](typename to_be_t::forced_type index) const { - return vm::get_ref(m_addr + sizeof(AT)* index); + return vm::get_ref(m_addr + sizeof(T)* index); } __forceinline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; } diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index a21acdb18d..b42fd4be6f 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -34,7 +34,8 @@ enum IDs { id_boot_elf = 0x555, id_boot_game, - id_install_pkg, + id_boot_install_pkg, + id_boot_exit, id_sys_pause, id_sys_stop, id_sys_send_open_menu, @@ -76,43 +77,45 @@ MainFrame::MainFrame() wxMenuBar* menubar = new wxMenuBar(); wxMenu* menu_boot = new wxMenu(); - menubar->Append(menu_boot, "Boot"); - menu_boot->Append(id_boot_elf, "Boot ELF / SELF file"); - menu_boot->Append(id_boot_game, "Boot game"); + menubar->Append(menu_boot, "&Boot"); + menu_boot->Append(id_boot_elf, "Boot &ELF / SELF file"); + menu_boot->Append(id_boot_game, "Boot &game"); menu_boot->AppendSeparator(); - menu_boot->Append(id_install_pkg, "Install PKG"); + menu_boot->Append(id_boot_install_pkg, "&Install PKG"); + menu_boot->AppendSeparator(); + menu_boot->Append(id_boot_exit, "&Exit"); wxMenu* menu_sys = new wxMenu(); - menubar->Append(menu_sys, "System"); - menu_sys->Append(id_sys_pause, "Pause")->Enable(false); - menu_sys->Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false); + menubar->Append(menu_sys, "&System"); + menu_sys->Append(id_sys_pause, "&Pause")->Enable(false); + menu_sys->Append(id_sys_stop, "&Stop\tCtrl + S")->Enable(false); menu_sys->AppendSeparator(); - menu_sys->Append(id_sys_send_open_menu, "Send open system menu cmd")->Enable(false); - menu_sys->Append(id_sys_send_exit, "Send exit cmd")->Enable(false); + menu_sys->Append(id_sys_send_open_menu, "Send &open system menu cmd")->Enable(false); + menu_sys->Append(id_sys_send_exit, "Send &exit cmd")->Enable(false); wxMenu* menu_conf = new wxMenu(); - menubar->Append(menu_conf, "Config"); - menu_conf->Append(id_config_emu, "Settings"); - menu_conf->Append(id_config_pad, "PAD Settings"); + menubar->Append(menu_conf, "&Config"); + menu_conf->Append(id_config_emu, "&Settings"); + menu_conf->Append(id_config_pad, "&PAD Settings"); menu_conf->AppendSeparator(); - menu_conf->Append(id_config_autopause_manager, "Auto Pause Settings"); + menu_conf->Append(id_config_autopause_manager, "&Auto Pause Settings"); menu_conf->AppendSeparator(); - menu_conf->Append(id_config_vfs_manager, "Virtual File System Manager"); - menu_conf->Append(id_config_vhdd_manager, "Virtual HDD Manager"); - menu_conf->Append(id_config_savedata_manager, "Save Data Utility"); - menu_conf->Append(id_config_lle_modules_manager, "LLE Modules Manager"); + menu_conf->Append(id_config_vfs_manager, "Virtual &File System Manager"); + menu_conf->Append(id_config_vhdd_manager, "Virtual &HDD Manager"); + menu_conf->Append(id_config_savedata_manager, "Save &Data Utility"); + menu_conf->Append(id_config_lle_modules_manager, "&LLE Modules Manager"); wxMenu* menu_tools = new wxMenu(); - menubar->Append(menu_tools, "Tools"); - menu_tools->Append(id_tools_compiler, "ELF Compiler"); - menu_tools->Append(id_tools_kernel_explorer, "Kernel Explorer")->Enable(false); - menu_tools->Append(id_tools_memory_viewer, "Memory Viewer")->Enable(false); - menu_tools->Append(id_tools_rsx_debugger, "RSX Debugger")->Enable(false); + menubar->Append(menu_tools, "&Tools"); + menu_tools->Append(id_tools_compiler, "&ELF Compiler"); + menu_tools->Append(id_tools_kernel_explorer, "&Kernel Explorer")->Enable(false); + menu_tools->Append(id_tools_memory_viewer, "&Memory Viewer")->Enable(false); + menu_tools->Append(id_tools_rsx_debugger, "&RSX Debugger")->Enable(false); wxMenu* menu_help = new wxMenu(); - menubar->Append(menu_help, "Help"); - menu_help->Append(id_help_about, "About..."); + menubar->Append(menu_help, "&Help"); + menu_help->Append(id_help_about, "&About..."); SetMenuBar(menubar); @@ -128,7 +131,8 @@ MainFrame::MainFrame() // Events Bind(wxEVT_MENU, &MainFrame::BootElf, this, id_boot_elf); Bind(wxEVT_MENU, &MainFrame::BootGame, this, id_boot_game); - Bind(wxEVT_MENU, &MainFrame::InstallPkg, this, id_install_pkg); + Bind(wxEVT_MENU, &MainFrame::InstallPkg, this, id_boot_install_pkg); + Bind(wxEVT_MENU, [](wxCommandEvent&){ wxGetApp().Exit(); }, id_boot_exit); Bind(wxEVT_MENU, &MainFrame::Pause, this, id_sys_pause); Bind(wxEVT_MENU, &MainFrame::Stop, this, id_sys_stop); @@ -785,7 +789,7 @@ void MainFrame::UpdateUI(wxCommandEvent& event) // Emulation wxMenuItem& pause = *menubar.FindItem( id_sys_pause ); wxMenuItem& stop = *menubar.FindItem( id_sys_stop ); - pause.SetItemLabel(is_running ? "Pause\tCtrl + P" : is_ready ? "Start\tCtrl + E" : "Resume\tCtrl + E"); + pause.SetItemLabel(is_running ? "&Pause\tCtrl + P" : is_ready ? "&Start\tCtrl + E" : "&Resume\tCtrl + E"); pause.Enable(!is_stopped); stop.Enable(!is_stopped); @@ -793,7 +797,7 @@ void MainFrame::UpdateUI(wxCommandEvent& event) wxMenuItem& send_exit = *menubar.FindItem( id_sys_send_exit ); wxMenuItem& send_open_menu = *menubar.FindItem( id_sys_send_open_menu ); bool enable_commands = !is_stopped; - send_open_menu.SetItemLabel(wxString::Format("Send %s system menu cmd", (m_sys_menu_opened ? "close" : "open"))); + send_open_menu.SetItemLabel(wxString::Format("Send &%s system menu cmd", (m_sys_menu_opened ? "close" : "open"))); send_open_menu.Enable(enable_commands); send_exit.Enable(enable_commands); diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 3eb33b8bc2..01036e8bf5 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -446,25 +446,38 @@ namespace loader LOG_WARNING(LOADER, "Unknown module '%s'", module_name.c_str()); } - static const u32 tbl_section_size = 2 * 4; - static const u32 dst_section_size = 3 * 4; - auto tbl = ptr::make(alloc(stub->s_imports * tbl_section_size)); - auto dst = ptr::make(alloc(stub->s_imports * dst_section_size)); + struct tbl_item + { + be_t stub; + be_t rtoc; + }; + + struct stub_data_t + { + be_t data[3]; + } + static const stub_data = + { + be_t::make(MR(11, 2)), + be_t::make(SC(2)), + be_t::make(BLR()) + }; + + auto& tbl = vm::get().alloc(stub->s_imports); + auto& dst = vm::get().alloc(stub->s_imports); for (u32 i = 0; i < stub->s_imports; ++i) { - const u32 nid = *stub->s_nid++; + const u32 nid = stub->s_nid[i]; if (!Emu.GetModuleManager().get_function_stub(nid, stub->s_text[i])) { - stub->s_text[i] = tbl.addr(); + dst[i] = stub_data; - *tbl++ = dst.addr(); - *tbl++ = Emu.GetModuleManager().GetFuncNumById(nid); + tbl[i].stub = (dst + i).addr(); + tbl[i].rtoc = stub->s_nid[i]; - *dst++ = MR(11, 2); - *dst++ = SC(2); - *dst++ = BLR(); + stub->s_text[i] = (tbl + i).addr(); if (module && !module->Load(nid)) {