sys_memory: add cpu_flag::wait

This commit is contained in:
Nekotekina 2020-10-30 18:09:30 +03:00
parent 95aeebe4b5
commit 13c564f2af
4 changed files with 36 additions and 34 deletions

View file

@ -505,7 +505,7 @@ error_code cellGemEnableMagnetometer2()
return CELL_OK; return CELL_OK;
} }
error_code cellGemEnd() error_code cellGemEnd(ppu_thread& ppu)
{ {
cellGem.warning("cellGemEnd()"); cellGem.warning("cellGemEnd()");
@ -517,7 +517,7 @@ error_code cellGemEnd()
{ {
if (u32 addr = gem->memory_ptr) if (u32 addr = gem->memory_ptr)
{ {
sys_memory_free(addr); sys_memory_free(ppu, addr);
} }
return CELL_OK; return CELL_OK;
@ -950,7 +950,7 @@ error_code cellGemHSVtoRGB(f32 h, f32 s, f32 v, vm::ptr<f32> r, vm::ptr<f32> g,
return CELL_OK; return CELL_OK;
} }
error_code cellGemInit(vm::cptr<CellGemAttribute> attribute) error_code cellGemInit(ppu_thread& ppu, vm::cptr<CellGemAttribute> attribute)
{ {
cellGem.warning("cellGemInit(attribute=*0x%x)", attribute); cellGem.warning("cellGemInit(attribute=*0x%x)", attribute);
@ -973,7 +973,7 @@ error_code cellGemInit(vm::cptr<CellGemAttribute> attribute)
vm::var<u32> addr(0); vm::var<u32> addr(0);
// Decrease memory stats // Decrease memory stats
if (sys_memory_allocate(GemGetMemorySize(attribute->max_connect), SYS_MEMORY_PAGE_SIZE_64K, +addr) != CELL_OK) if (sys_memory_allocate(ppu, GemGetMemorySize(attribute->max_connect), SYS_MEMORY_PAGE_SIZE_64K, +addr) != CELL_OK)
{ {
return CELL_GEM_ERROR_RESOURCE_ALLOCATION_FAILED; return CELL_GEM_ERROR_RESOURCE_ALLOCATION_FAILED;
} }

View file

@ -19,9 +19,9 @@ struct sys_memory_address_table
// Todo: fix order of error checks // Todo: fix order of error checks
error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr) error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32> alloc_addr)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_allocate(size=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, flags, alloc_addr); sys_memory.warning("sys_memory_allocate(size=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, flags, alloc_addr);
@ -68,7 +68,7 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
} }
// Dealloc using the syscall // Dealloc using the syscall
sys_memory_free(addr); sys_memory_free(cpu, addr);
return CELL_EFAULT; return CELL_EFAULT;
} }
} }
@ -77,9 +77,9 @@ error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr)
return CELL_ENOMEM; return CELL_ENOMEM;
} }
error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr<u32> alloc_addr) error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid, u64 flags, vm::ptr<u32> alloc_addr)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, cid, flags, alloc_addr); sys_memory.warning("sys_memory_allocate_from_container(size=0x%x, cid=0x%x, flags=0x%llx, alloc_addr=*0x%x)", size, cid, flags, alloc_addr);
@ -138,7 +138,7 @@ error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::
} }
// Dealloc using the syscall // Dealloc using the syscall
sys_memory_free(addr); sys_memory_free(cpu, addr);
return CELL_EFAULT; return CELL_EFAULT;
} }
} }
@ -147,9 +147,9 @@ error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::
return CELL_ENOMEM; return CELL_ENOMEM;
} }
error_code sys_memory_free(u32 addr) error_code sys_memory_free(cpu_thread& cpu, u32 addr)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_free(addr=0x%x)", addr); sys_memory.warning("sys_memory_free(addr=0x%x)", addr);
@ -165,9 +165,9 @@ error_code sys_memory_free(u32 addr)
return CELL_OK; return CELL_OK;
} }
error_code sys_memory_get_page_attribute(u32 addr, vm::ptr<sys_page_attr_t> attr) error_code sys_memory_get_page_attribute(cpu_thread& cpu, u32 addr, vm::ptr<sys_page_attr_t> attr)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.trace("sys_memory_get_page_attribute(addr=0x%x, attr=*0x%x)", addr, attr); sys_memory.trace("sys_memory_get_page_attribute(addr=0x%x, attr=*0x%x)", addr, attr);
@ -203,9 +203,9 @@ error_code sys_memory_get_page_attribute(u32 addr, vm::ptr<sys_page_attr_t> attr
return CELL_OK; return CELL_OK;
} }
error_code sys_memory_get_user_memory_size(vm::ptr<sys_memory_info_t> mem_info) error_code sys_memory_get_user_memory_size(cpu_thread& cpu, vm::ptr<sys_memory_info_t> mem_info)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info); sys_memory.warning("sys_memory_get_user_memory_size(mem_info=*0x%x)", mem_info);
@ -226,18 +226,18 @@ error_code sys_memory_get_user_memory_size(vm::ptr<sys_memory_info_t> mem_info)
return CELL_OK; return CELL_OK;
} }
error_code sys_memory_get_user_memory_stat(vm::ptr<sys_memory_user_memory_stat_t> mem_stat) error_code sys_memory_get_user_memory_stat(cpu_thread& cpu, vm::ptr<sys_memory_user_memory_stat_t> mem_stat)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.todo("sys_memory_get_user_memory_stat(mem_stat=*0x%x)", mem_stat); sys_memory.todo("sys_memory_get_user_memory_stat(mem_stat=*0x%x)", mem_stat);
return CELL_OK; return CELL_OK;
} }
error_code sys_memory_container_create(vm::ptr<u32> cid, u32 size) error_code sys_memory_container_create(cpu_thread& cpu, vm::ptr<u32> cid, u32 size)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_container_create(cid=*0x%x, size=0x%x)", cid, size); sys_memory.warning("sys_memory_container_create(cid=*0x%x, size=0x%x)", cid, size);
@ -270,9 +270,9 @@ error_code sys_memory_container_create(vm::ptr<u32> cid, u32 size)
return CELL_EAGAIN; return CELL_EAGAIN;
} }
error_code sys_memory_container_destroy(u32 cid) error_code sys_memory_container_destroy(cpu_thread& cpu, u32 cid)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_container_destroy(cid=0x%x)", cid); sys_memory.warning("sys_memory_container_destroy(cid=0x%x)", cid);
@ -305,9 +305,9 @@ error_code sys_memory_container_destroy(u32 cid)
return CELL_OK; return CELL_OK;
} }
error_code sys_memory_container_get_size(vm::ptr<sys_memory_info_t> mem_info, u32 cid) error_code sys_memory_container_get_size(cpu_thread& cpu, vm::ptr<sys_memory_info_t> mem_info, u32 cid)
{ {
vm::temporary_unlock(); cpu.state += cpu_flag::wait;
sys_memory.warning("sys_memory_container_get_size(mem_info=*0x%x, cid=0x%x)", mem_info, cid); sys_memory.warning("sys_memory_container_get_size(mem_info=*0x%x, cid=0x%x)", mem_info, cid);

View file

@ -4,6 +4,8 @@
#include "Emu/Memory/vm_ptr.h" #include "Emu/Memory/vm_ptr.h"
#include "Emu/IdManager.h" #include "Emu/IdManager.h"
class cpu_thread;
enum : u32 enum : u32
{ {
SYS_MEMORY_CONTAINER_ID_INVALID = 0xFFFFFFFF, SYS_MEMORY_CONTAINER_ID_INVALID = 0xFFFFFFFF,
@ -89,12 +91,12 @@ struct sys_memory_user_memory_stat_t
}; };
// SysCalls // SysCalls
error_code sys_memory_allocate(u32 size, u64 flags, vm::ptr<u32> alloc_addr); error_code sys_memory_allocate(cpu_thread& cpu, u32 size, u64 flags, vm::ptr<u32> alloc_addr);
error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags, vm::ptr<u32> alloc_addr); error_code sys_memory_allocate_from_container(cpu_thread& cpu, u32 size, u32 cid, u64 flags, vm::ptr<u32> alloc_addr);
error_code sys_memory_free(u32 start_addr); error_code sys_memory_free(cpu_thread& cpu, u32 start_addr);
error_code sys_memory_get_page_attribute(u32 addr, vm::ptr<sys_page_attr_t> attr); error_code sys_memory_get_page_attribute(cpu_thread& cpu, u32 addr, vm::ptr<sys_page_attr_t> attr);
error_code sys_memory_get_user_memory_size(vm::ptr<sys_memory_info_t> mem_info); error_code sys_memory_get_user_memory_size(cpu_thread& cpu, vm::ptr<sys_memory_info_t> mem_info);
error_code sys_memory_get_user_memory_stat(vm::ptr<sys_memory_user_memory_stat_t> mem_stat); error_code sys_memory_get_user_memory_stat(cpu_thread& cpu, vm::ptr<sys_memory_user_memory_stat_t> mem_stat);
error_code sys_memory_container_create(vm::ptr<u32> cid, u32 size); error_code sys_memory_container_create(cpu_thread& cpu, vm::ptr<u32> cid, u32 size);
error_code sys_memory_container_destroy(u32 cid); error_code sys_memory_container_destroy(cpu_thread& cpu, u32 cid);
error_code sys_memory_container_get_size(vm::ptr<sys_memory_info_t> mem_info, u32 cid); error_code sys_memory_container_get_size(cpu_thread& cpu, vm::ptr<sys_memory_info_t> mem_info, u32 cid);

View file

@ -33,7 +33,7 @@ namespace rsx
const auto contextInfo = vm::ptr<rsx_context>::make(contextAddr); const auto contextInfo = vm::ptr<rsx_context>::make(contextAddr);
// 'fake' initialize usermemory // 'fake' initialize usermemory
sys_memory_allocate(buffer_size, SYS_MEMORY_PAGE_SIZE_1M, contextInfo.ptr(&rsx_context::user_addr)); sys_memory_allocate(*this, buffer_size, SYS_MEMORY_PAGE_SIZE_1M, contextInfo.ptr(&rsx_context::user_addr));
verify(HERE), (user_mem_addr = contextInfo->user_addr) != 0; verify(HERE), (user_mem_addr = contextInfo->user_addr) != 0;
if (sys_rsx_device_map(*this, contextInfo.ptr(&rsx_context::dev_addr), vm::null, 0x8) != CELL_OK) if (sys_rsx_device_map(*this, contextInfo.ptr(&rsx_context::dev_addr), vm::null, 0x8) != CELL_OK)