Skip to content

Commit

Permalink
Merge branch 'master' into osk
Browse files Browse the repository at this point in the history
  • Loading branch information
kd-11 authored Jan 31, 2019
2 parents cd5df9c + 987b607 commit f4a6bdc
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
49 changes: 33 additions & 16 deletions rpcs3/Emu/Cell/lv2/sys_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,24 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
return CELL_ENOMEM;
}

if (!alloc_addr)
if (const auto area = vm::get(align == 0x10000 ? vm::user64k : vm::user1m, 0, ::align(size, 0x10000000)))
{
dct->used -= size;
return CELL_EFAULT;
if (u32 addr = area->alloc(size, align))
{
if (alloc_addr)
{
*alloc_addr = addr;
return CELL_OK;
}

// Dealloc using the syscall
sys_memory_free(addr);
return CELL_EFAULT;
}
}

// Allocate memory, write back the start address of the allocated area
*alloc_addr = verify(HERE, vm::alloc(size, align == 0x10000 ? vm::user64k : vm::user1m, align));

return CELL_OK;
dct->used -= size;
return CELL_ENOMEM;
}

error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr<u32> alloc_addr)
Expand Down Expand Up @@ -98,19 +106,28 @@ error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::
return ct.ret;
}

if (!alloc_addr)
{
ct->used -= size;
return CELL_EFAULT;
}

// Create phantom memory object
const auto mem = idm::make_ptr<lv2_memory_alloca>(size, align, flags, ct.ptr);

// Allocate memory
*alloc_addr = verify(HERE, vm::get(align == 0x10000 ? vm::user64k : vm::user1m)->alloc(size, mem->align, &mem->shm));
if (const auto area = vm::get(align == 0x10000 ? vm::user64k : vm::user1m, 0, ::align(size, 0x10000000)))
{
if (u32 addr = area->alloc(size, mem->align, &mem->shm))
{
if (alloc_addr)
{
*alloc_addr = addr;
return CELL_OK;
}

// Dealloc using the syscall
sys_memory_free(addr);
return CELL_EFAULT;
}
}

return CELL_OK;
idm::remove<lv2_memory_alloca>(idm::last_id());
ct->used -= size;
return CELL_ENOMEM;
}

error_code sys_memory_free(u32 addr)
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Memory/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ namespace vm
return nullptr;
}

std::shared_ptr<block_t> get(memory_location_t location, u32 addr)
std::shared_ptr<block_t> get(memory_location_t location, u32 addr, u32 area_size)
{
vm::reader_lock lock;

Expand All @@ -989,7 +989,7 @@ namespace vm
{
auto& loc = g_locations[location];

if (!loc)
if (!loc && area_size)
{
if (location == vm::user64k || location == vm::user1m)
{
Expand All @@ -998,7 +998,7 @@ namespace vm
if (!loc)
{
// Deferred allocation
loc = _find_map(0x10000000, 0x10000000, location == vm::user64k ? 0x201 : 0x401);
loc = _find_map(area_size, 0x10000000, location == vm::user64k ? 0x201 : 0x401);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Memory/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace vm
std::shared_ptr<block_t> unmap(u32 addr, bool must_be_empty = false);

// Get memory block associated with optionally specified memory location or optionally specified address
std::shared_ptr<block_t> get(memory_location_t location, u32 addr = 0);
std::shared_ptr<block_t> get(memory_location_t location, u32 addr = 0, u32 area_size = 0);

// Get PS3/PSV virtual memory address from the provided pointer (nullptr always converted to 0)
inline vm::addr_t get_addr(const void* real_ptr)
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Json/tooltips.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"accurateGETLLAR": "Never use this.",
"accuratePUTLLUC": "Never use this.",
"hookStFunc": "Allows to hook some functions like 'memcpy' replacing them with high-level implementations. May do nothing or break things. Experimental.",
"debugConsoleMode": "Increases the amount of usable system memory to match a DECR console and more.\nCauses some software to behave differently than on retail hardware.",
"readColor": "Never use this.",
"dumpDepth": "Never use this.",
"readDepth": "Never use this.",
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/rpcs3qt/emu_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class emu_settings : public QObject
SPUBlockSize,
SPUCache,
SPUVerification,
DebugConsoleMode,

// Graphics
Renderer,
Expand Down Expand Up @@ -254,6 +255,7 @@ public Q_SLOTS:
{ SPUBlockSize, { "Core", "SPU Block Size"}},
{ SPUCache, { "Core", "SPU Cache"}},
{ SPUVerification, { "Core", "SPU Verification"}},
{ DebugConsoleMode, { "Core", "Debug Console Mode"}},

// Graphics Tab
{ Renderer, { "Video", "Renderer"}},
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/rpcs3qt/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,9 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
xemu_settings->EnhanceCheckBox(ui->hookStFunc, emu_settings::HookStaticFuncs);
SubscribeTooltip(ui->hookStFunc, json_debug["hookStFunc"].toString());

xemu_settings->EnhanceCheckBox(ui->debugConsoleMode, emu_settings::DebugConsoleMode);
SubscribeTooltip(ui->debugConsoleMode, json_debug["debugConsoleMode"].toString());

// Layout fix for High Dpi
layout()->setSizeConstraint(QLayout::SetFixedSize);
}
Expand Down
7 changes: 7 additions & 0 deletions rpcs3/rpcs3qt/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="debugConsoleMode">
<property name="text">
<string>Debug Console Mode</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down

0 comments on commit f4a6bdc

Please sign in to comment.