mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 10:42:36 +01:00
Fixed vm_ptr
Improved elf64 loader. Minor improvements to vm. Added hotkeys to MainFrame.
This commit is contained in:
parent
c846e33a10
commit
795729a0b7
@ -131,9 +131,12 @@ namespace vm
|
|||||||
location_info g_locations[memory_location_count] =
|
location_info g_locations[memory_location_count] =
|
||||||
{
|
{
|
||||||
{ 0x00010000, 0x2FFF0000, ps3::main_alloc, ps3::main_fixed_alloc, ps3::main_dealloc },
|
{ 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::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()
|
void close()
|
||||||
|
@ -3,30 +3,19 @@
|
|||||||
|
|
||||||
namespace vm
|
namespace vm
|
||||||
{
|
{
|
||||||
enum memory_location
|
enum memory_location : uint
|
||||||
{
|
{
|
||||||
main,
|
main,
|
||||||
stack,
|
stack,
|
||||||
|
|
||||||
|
//remove me
|
||||||
sprx,
|
sprx,
|
||||||
|
|
||||||
user_space,
|
user_space,
|
||||||
|
|
||||||
memory_location_count
|
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 set_stack_size(u32 size) {}
|
||||||
static void initialize_stack() {}
|
static void initialize_stack() {}
|
||||||
|
|
||||||
@ -200,4 +189,34 @@ namespace vm
|
|||||||
|
|
||||||
#include "vm_ref.h"
|
#include "vm_ref.h"
|
||||||
#include "vm_ptr.h"
|
#include "vm_ptr.h"
|
||||||
#include "vm_var.h"
|
#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<typename T = char>
|
||||||
|
ptr<T> alloc(u32 count) const
|
||||||
|
{
|
||||||
|
return ptr<T>::make(allocator(count * sizeof(T)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
extern location_info g_locations[memory_location_count];
|
||||||
|
|
||||||
|
template<memory_location location = main>
|
||||||
|
location_info& get()
|
||||||
|
{
|
||||||
|
assert(location < memory_location_count);
|
||||||
|
return g_locations[location];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -165,12 +165,12 @@ namespace vm
|
|||||||
|
|
||||||
__forceinline T& operator [](typename remove_be_t<AT>::type index) const
|
__forceinline T& operator [](typename remove_be_t<AT>::type index) const
|
||||||
{
|
{
|
||||||
return vm::get_ref<T>(m_addr + sizeof(AT)* index);
|
return vm::get_ref<T>(m_addr + sizeof(T)* index);
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline T& operator [](typename to_be_t<AT>::forced_type index) const
|
__forceinline T& operator [](typename to_be_t<AT>::forced_type index) const
|
||||||
{
|
{
|
||||||
return vm::get_ref<T>(m_addr + sizeof(AT)* index);
|
return vm::get_ref<T>(m_addr + sizeof(T)* index);
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
|
__forceinline bool operator <(const _ptr_base& right) const { return m_addr < right.m_addr; }
|
||||||
|
@ -34,7 +34,8 @@ enum IDs
|
|||||||
{
|
{
|
||||||
id_boot_elf = 0x555,
|
id_boot_elf = 0x555,
|
||||||
id_boot_game,
|
id_boot_game,
|
||||||
id_install_pkg,
|
id_boot_install_pkg,
|
||||||
|
id_boot_exit,
|
||||||
id_sys_pause,
|
id_sys_pause,
|
||||||
id_sys_stop,
|
id_sys_stop,
|
||||||
id_sys_send_open_menu,
|
id_sys_send_open_menu,
|
||||||
@ -76,43 +77,45 @@ MainFrame::MainFrame()
|
|||||||
wxMenuBar* menubar = new wxMenuBar();
|
wxMenuBar* menubar = new wxMenuBar();
|
||||||
|
|
||||||
wxMenu* menu_boot = new wxMenu();
|
wxMenu* menu_boot = new wxMenu();
|
||||||
menubar->Append(menu_boot, "Boot");
|
menubar->Append(menu_boot, "&Boot");
|
||||||
menu_boot->Append(id_boot_elf, "Boot ELF / SELF file");
|
menu_boot->Append(id_boot_elf, "Boot &ELF / SELF file");
|
||||||
menu_boot->Append(id_boot_game, "Boot game");
|
menu_boot->Append(id_boot_game, "Boot &game");
|
||||||
menu_boot->AppendSeparator();
|
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();
|
wxMenu* menu_sys = new wxMenu();
|
||||||
menubar->Append(menu_sys, "System");
|
menubar->Append(menu_sys, "&System");
|
||||||
menu_sys->Append(id_sys_pause, "Pause")->Enable(false);
|
menu_sys->Append(id_sys_pause, "&Pause")->Enable(false);
|
||||||
menu_sys->Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false);
|
menu_sys->Append(id_sys_stop, "&Stop\tCtrl + S")->Enable(false);
|
||||||
menu_sys->AppendSeparator();
|
menu_sys->AppendSeparator();
|
||||||
menu_sys->Append(id_sys_send_open_menu, "Send open system menu 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);
|
menu_sys->Append(id_sys_send_exit, "Send &exit cmd")->Enable(false);
|
||||||
|
|
||||||
wxMenu* menu_conf = new wxMenu();
|
wxMenu* menu_conf = new wxMenu();
|
||||||
menubar->Append(menu_conf, "Config");
|
menubar->Append(menu_conf, "&Config");
|
||||||
menu_conf->Append(id_config_emu, "Settings");
|
menu_conf->Append(id_config_emu, "&Settings");
|
||||||
menu_conf->Append(id_config_pad, "PAD Settings");
|
menu_conf->Append(id_config_pad, "&PAD Settings");
|
||||||
menu_conf->AppendSeparator();
|
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->AppendSeparator();
|
||||||
menu_conf->Append(id_config_vfs_manager, "Virtual File System 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_vhdd_manager, "Virtual &HDD Manager");
|
||||||
menu_conf->Append(id_config_savedata_manager, "Save Data Utility");
|
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_lle_modules_manager, "&LLE Modules Manager");
|
||||||
|
|
||||||
|
|
||||||
wxMenu* menu_tools = new wxMenu();
|
wxMenu* menu_tools = new wxMenu();
|
||||||
menubar->Append(menu_tools, "Tools");
|
menubar->Append(menu_tools, "&Tools");
|
||||||
menu_tools->Append(id_tools_compiler, "ELF Compiler");
|
menu_tools->Append(id_tools_compiler, "&ELF Compiler");
|
||||||
menu_tools->Append(id_tools_kernel_explorer, "Kernel Explorer")->Enable(false);
|
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_memory_viewer, "&Memory Viewer")->Enable(false);
|
||||||
menu_tools->Append(id_tools_rsx_debugger, "RSX Debugger")->Enable(false);
|
menu_tools->Append(id_tools_rsx_debugger, "&RSX Debugger")->Enable(false);
|
||||||
|
|
||||||
wxMenu* menu_help = new wxMenu();
|
wxMenu* menu_help = new wxMenu();
|
||||||
menubar->Append(menu_help, "Help");
|
menubar->Append(menu_help, "&Help");
|
||||||
menu_help->Append(id_help_about, "About...");
|
menu_help->Append(id_help_about, "&About...");
|
||||||
|
|
||||||
SetMenuBar(menubar);
|
SetMenuBar(menubar);
|
||||||
|
|
||||||
@ -128,7 +131,8 @@ MainFrame::MainFrame()
|
|||||||
// Events
|
// Events
|
||||||
Bind(wxEVT_MENU, &MainFrame::BootElf, this, id_boot_elf);
|
Bind(wxEVT_MENU, &MainFrame::BootElf, this, id_boot_elf);
|
||||||
Bind(wxEVT_MENU, &MainFrame::BootGame, this, id_boot_game);
|
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::Pause, this, id_sys_pause);
|
||||||
Bind(wxEVT_MENU, &MainFrame::Stop, this, id_sys_stop);
|
Bind(wxEVT_MENU, &MainFrame::Stop, this, id_sys_stop);
|
||||||
@ -785,7 +789,7 @@ void MainFrame::UpdateUI(wxCommandEvent& event)
|
|||||||
// Emulation
|
// Emulation
|
||||||
wxMenuItem& pause = *menubar.FindItem( id_sys_pause );
|
wxMenuItem& pause = *menubar.FindItem( id_sys_pause );
|
||||||
wxMenuItem& stop = *menubar.FindItem( id_sys_stop );
|
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);
|
pause.Enable(!is_stopped);
|
||||||
stop.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_exit = *menubar.FindItem( id_sys_send_exit );
|
||||||
wxMenuItem& send_open_menu = *menubar.FindItem( id_sys_send_open_menu );
|
wxMenuItem& send_open_menu = *menubar.FindItem( id_sys_send_open_menu );
|
||||||
bool enable_commands = !is_stopped;
|
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_open_menu.Enable(enable_commands);
|
||||||
send_exit.Enable(enable_commands);
|
send_exit.Enable(enable_commands);
|
||||||
|
|
||||||
|
@ -446,25 +446,38 @@ namespace loader
|
|||||||
LOG_WARNING(LOADER, "Unknown module '%s'", module_name.c_str());
|
LOG_WARNING(LOADER, "Unknown module '%s'", module_name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const u32 tbl_section_size = 2 * 4;
|
struct tbl_item
|
||||||
static const u32 dst_section_size = 3 * 4;
|
{
|
||||||
auto tbl = ptr<u32>::make(alloc(stub->s_imports * tbl_section_size));
|
be_t<u32> stub;
|
||||||
auto dst = ptr<u32>::make(alloc(stub->s_imports * dst_section_size));
|
be_t<u32> rtoc;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct stub_data_t
|
||||||
|
{
|
||||||
|
be_t<u32> data[3];
|
||||||
|
}
|
||||||
|
static const stub_data =
|
||||||
|
{
|
||||||
|
be_t<u32>::make(MR(11, 2)),
|
||||||
|
be_t<u32>::make(SC(2)),
|
||||||
|
be_t<u32>::make(BLR())
|
||||||
|
};
|
||||||
|
|
||||||
|
auto& tbl = vm::get().alloc<tbl_item>(stub->s_imports);
|
||||||
|
auto& dst = vm::get().alloc<stub_data_t>(stub->s_imports);
|
||||||
|
|
||||||
for (u32 i = 0; i < stub->s_imports; ++i)
|
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]))
|
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[i].stub = (dst + i).addr();
|
||||||
*tbl++ = Emu.GetModuleManager().GetFuncNumById(nid);
|
tbl[i].rtoc = stub->s_nid[i];
|
||||||
|
|
||||||
*dst++ = MR(11, 2);
|
stub->s_text[i] = (tbl + i).addr();
|
||||||
*dst++ = SC(2);
|
|
||||||
*dst++ = BLR();
|
|
||||||
|
|
||||||
if (module && !module->Load(nid))
|
if (module && !module->Load(nid))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user