More sys_ fixes
This commit is contained in:
@@ -170,8 +170,7 @@ CellError lv2_event_queue::send(lv2_event event, bool* notified_thread, lv2_even
|
|||||||
{
|
{
|
||||||
if (auto cpu = get_current_cpu_thread())
|
if (auto cpu = get_current_cpu_thread())
|
||||||
{
|
{
|
||||||
cpu->state += cpu_flag::again;
|
cpu->state += cpu_flag::again + cpu_flag::exit;
|
||||||
cpu->state += cpu_flag::exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sys_event.warning("Ignored event!");
|
sys_event.warning("Ignored event!");
|
||||||
|
|||||||
@@ -19,6 +19,22 @@ lv2_event_flag::lv2_event_flag(utils::serial& ar)
|
|||||||
ar(pattern);
|
ar(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always set result
|
||||||
|
struct sys_event_store_result
|
||||||
|
{
|
||||||
|
vm::ptr<u64> ptr;
|
||||||
|
u64 val = 0;
|
||||||
|
|
||||||
|
~sys_event_store_result() noexcept
|
||||||
|
{
|
||||||
|
if (ptr)
|
||||||
|
{
|
||||||
|
cpu_thread::get_current()->check_state();
|
||||||
|
*ptr = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::function<void(void*)> lv2_event_flag::load(utils::serial& ar)
|
std::function<void(void*)> lv2_event_flag::load(utils::serial& ar)
|
||||||
{
|
{
|
||||||
return load_func(make_shared<lv2_event_flag>(stx::exact_t<utils::serial&>(ar)));
|
return load_func(make_shared<lv2_event_flag>(stx::exact_t<utils::serial&>(ar)));
|
||||||
@@ -120,21 +136,7 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm
|
|||||||
ppu.gpr[5] = mode;
|
ppu.gpr[5] = mode;
|
||||||
ppu.gpr[6] = 0;
|
ppu.gpr[6] = 0;
|
||||||
|
|
||||||
// Always set result
|
sys_event_store_result store{result};
|
||||||
struct store_result
|
|
||||||
{
|
|
||||||
vm::ptr<u64> ptr;
|
|
||||||
u64 val = 0;
|
|
||||||
|
|
||||||
~store_result() noexcept
|
|
||||||
{
|
|
||||||
if (ptr)
|
|
||||||
{
|
|
||||||
cpu_thread::get_current()->check_state();
|
|
||||||
*ptr = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} store{result};
|
|
||||||
|
|
||||||
if (!lv2_event_flag::check_mode(mode))
|
if (!lv2_event_flag::check_mode(mode))
|
||||||
{
|
{
|
||||||
@@ -273,21 +275,7 @@ error_code sys_event_flag_trywait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode,
|
|||||||
|
|
||||||
sys_event_flag.trace("sys_event_flag_trywait(id=0x%x, bitptn=0x%llx, mode=0x%x, result=*0x%x)", id, bitptn, mode, result);
|
sys_event_flag.trace("sys_event_flag_trywait(id=0x%x, bitptn=0x%llx, mode=0x%x, result=*0x%x)", id, bitptn, mode, result);
|
||||||
|
|
||||||
// Always set result
|
sys_event_store_result store{result};
|
||||||
struct store_result
|
|
||||||
{
|
|
||||||
vm::ptr<u64> ptr;
|
|
||||||
u64 val = 0;
|
|
||||||
|
|
||||||
~store_result() noexcept
|
|
||||||
{
|
|
||||||
if (ptr)
|
|
||||||
{
|
|
||||||
cpu_thread::get_current()->check_state();
|
|
||||||
*ptr = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} store{result};
|
|
||||||
|
|
||||||
if (!lv2_event_flag::check_mode(mode))
|
if (!lv2_event_flag::check_mode(mode))
|
||||||
{
|
{
|
||||||
@@ -556,8 +544,6 @@ error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr<u64> flags)
|
|||||||
return +flag.pattern;
|
return +flag.pattern;
|
||||||
});
|
});
|
||||||
|
|
||||||
ppu.check_state();
|
|
||||||
|
|
||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
if (flags) *flags = 0;
|
if (flags) *flags = 0;
|
||||||
@@ -569,6 +555,8 @@ error_code sys_event_flag_get(ppu_thread& ppu, u32 id, vm::ptr<u64> flags)
|
|||||||
return CELL_EFAULT;
|
return CELL_EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppu.check_state();
|
||||||
|
|
||||||
*flags = flag.ret;
|
*flags = flag.ret;
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,11 @@ struct lv2_mutex final : lv2_obj
|
|||||||
|
|
||||||
if (sq == data.sq)
|
if (sq == data.sq)
|
||||||
{
|
{
|
||||||
atomic_storage<u32>::release(control.raw().owner, res->id);
|
if (cpu_flag::again - res->state)
|
||||||
|
{
|
||||||
|
atomic_storage<u32>::release(control.raw().owner, res->id);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -441,6 +441,8 @@ error_code sys_rwlock_wlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ppu.state += cpu_flag::wait;
|
||||||
|
|
||||||
std::lock_guard lock(rwlock->mutex);
|
std::lock_guard lock(rwlock->mutex);
|
||||||
|
|
||||||
if (!rwlock->unqueue(rwlock->wq, &ppu))
|
if (!rwlock->unqueue(rwlock->wq, &ppu))
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ error_code sys_semaphore_create(ppu_thread& ppu, vm::ptr<u32> sem_id, vm::ptr<sy
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<void>(ppu.test_stopped());
|
ppu.check_state();
|
||||||
|
|
||||||
*sem_id = idm::last_id();
|
*sem_id = idm::last_id();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
@@ -358,7 +358,7 @@ error_code sys_semaphore_get_value(ppu_thread& ppu, u32 sem_id, vm::ptr<s32> cou
|
|||||||
return CELL_EFAULT;
|
return CELL_EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static_cast<void>(ppu.test_stopped());
|
ppu.check_state();
|
||||||
|
|
||||||
*count = sema.ret;
|
*count = sema.ret;
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user