diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 903d47dd13..05e98d77da 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -242,6 +242,17 @@ namespace fmt } }; + template + struct unveil, false> + { + using result_type = typename unveil::result_type; + + force_inline static result_type get_value(const le_t& arg) + { + return unveil::get_value(arg.value()); + } + }; + template force_inline typename unveil::result_type do_unveil(const T& arg) { diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 9f7eb958bf..a39dbe9c2a 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -109,6 +109,7 @@ enum x64_op_t : u32 X64OP_NONE, X64OP_LOAD, // obtain and put the value into x64 register X64OP_STORE, // take the value from x64 register or an immediate and use it + // example: add eax,[rax] -> X64OP_LOAD_ADD (add the value to x64 register) // example: add [rax],eax -> X64OP_LOAD_ADD_STORE (this will probably never happen for MMIO registers) @@ -116,7 +117,7 @@ enum x64_op_t : u32 X64OP_STOS, X64OP_XCHG, X64OP_CMPXCHG, - X64OP_LOAD_AND_STORE, + X64OP_LOAD_AND_STORE, // lock and [mem],reg }; void decode_x64_reg_op(const u8* code, x64_op_t& out_op, x64_reg_t& out_reg, size_t& out_size, size_t& out_length) diff --git a/rpcs3/Emu/ARMv7/Modules/sceVoice.h b/rpcs3/Emu/ARMv7/Modules/sceVoice.h index 227cef8615..267ca6e335 100644 --- a/rpcs3/Emu/ARMv7/Modules/sceVoice.h +++ b/rpcs3/Emu/ARMv7/Modules/sceVoice.h @@ -79,6 +79,28 @@ struct SceVoiceBasePortInfo struct SceVoicePortParam { + // aux structs + + struct _voice_t + { + le_t bitrate; // SceVoiceBitRate + }; + + struct _pcmaudio_t + { + using _format_t = SceVoicePCMFormat; + + le_t bufSize; + _format_t format; + }; + + struct _device_t + { + le_t playerId; + }; + + // struct members + le_t portType; // SceVoicePortType le_t threshold; le_t bMute; @@ -86,29 +108,9 @@ struct SceVoicePortParam union { - struct _voice_t - { - le_t bitrate; // SceVoiceBitRate - }; - - _voice_t voice; - - struct _pcmaudio_t - { - using _format_t = SceVoicePCMFormat; - - le_t bufSize; - _format_t format; - }; - _pcmaudio_t pcmaudio; - - struct _device_t - { - le_t playerId; - }; - _device_t device; + _voice_t voice; }; }; diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 080a692beb..cdcf209efb 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -764,9 +764,9 @@ cpu_thread& ppu_thread::args(std::initializer_list values) assert(argc == 0); - envp.set(vm::alloc(align(sizeof32(u64), stack_align), vm::main)); + envp.set(vm::alloc(align(sizeof32(*envp), stack_align), vm::main)); *envp = 0; - argv.set(vm::alloc(sizeof32(u64) * (u32)values.size(), vm::main)); + argv.set(vm::alloc(sizeof32(*argv) * (u32)values.size(), vm::main)); for (auto &arg : values) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp index b72ebbebc6..581d2cde88 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.cpp @@ -106,7 +106,7 @@ s32 sys_cond_signal_all(u32 cond_id) return CELL_ESRCH; } - if (const u32 count = cond->waiters.size()) + if (const u64 count = cond->waiters.size()) { cond->signaled += count; cond->waiters.clear(); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_cond.h b/rpcs3/Emu/SysCalls/lv2/sys_cond.h index c12c5485bb..0bd5e7923e 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_cond.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_cond.h @@ -22,7 +22,7 @@ struct lv2_cond_t const u64 name; const std::shared_ptr mutex; // associated mutex - std::atomic signaled; + std::atomic signaled; // TODO: use sleep queue, possibly remove condition variable std::condition_variable cv; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp index 7a6ab22d41..107e080a86 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.cpp @@ -118,8 +118,13 @@ s32 sys_event_queue_tryreceive(u32 equeue_id, vm::ptr event_array, while (!queue->waiters && count < size && queue->events.size()) { + auto& dest = event_array[count++]; + auto& event = queue->events.front(); - event_array[count++] = { be_t::make(event.source), be_t::make(event.data1), be_t::make(event.data2), be_t::make(event.data3) }; + dest.source = event.source; + dest.data1 = event.data1; + dest.data2 = event.data2; + dest.data3 = event.data3; queue->events.pop_front(); } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp index d86f786cda..9a9d9ba87a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_lwcond.cpp @@ -131,7 +131,7 @@ s32 _sys_lwcond_signal_all(u32 lwcond_id, u32 lwmutex_id, u32 mode) sys_lwcond.Error("_sys_lwcond_signal_all(%d): invalid mode (%d)", lwcond_id, mode); } - const u32 count = cond->waiters.size(); + const u32 count = (u32)cond->waiters.size(); if (count) { diff --git a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp index a693d7239a..26528daa6b 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_semaphore.cpp @@ -43,7 +43,7 @@ s32 sys_semaphore_create(vm::ptr sem, vm::ptr at return CELL_EINVAL; } - *sem = Emu.GetIdManager().make(initial_val, max_val, protocol, attr->name_u64); + *sem = Emu.GetIdManager().make(protocol, max_val, attr->name_u64, initial_val); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp index 6b214719a8..c9dd634062 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.cpp @@ -72,6 +72,8 @@ s32 sys_timer_destroy(u32 timer_id) { sys_timer.Warning("sys_timer_destroy(timer_id=0x%x)", timer_id); + LV2_LOCK; + const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -79,8 +81,6 @@ s32 sys_timer_destroy(u32 timer_id) return CELL_ESRCH; } - LV2_LOCK; - if (!timer->port.expired()) { return CELL_EISCONN; @@ -88,6 +88,8 @@ s32 sys_timer_destroy(u32 timer_id) Emu.GetIdManager().remove(timer_id); + lv2_lock.unlock(); + return CELL_OK; } @@ -95,6 +97,8 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr inf { sys_timer.Warning("sys_timer_get_information(timer_id=0x%x, info=*0x%x)", timer_id, info); + LV2_LOCK; + const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -102,8 +106,6 @@ s32 sys_timer_get_information(u32 timer_id, vm::ptr inf return CELL_ESRCH; } - LV2_LOCK; - info->next_expiration_time = timer->start; info->period = timer->period; @@ -118,6 +120,8 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period) const u64 start_time = get_system_time(); + LV2_LOCK; + const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -125,8 +129,6 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period) return CELL_ESRCH; } - LV2_LOCK; - if (timer->state != SYS_TIMER_STATE_STOP) { return CELL_EBUSY; @@ -170,6 +172,8 @@ s32 sys_timer_stop(u32 timer_id) { sys_timer.Warning("sys_timer_stop()"); + LV2_LOCK; + const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -177,8 +181,6 @@ s32 sys_timer_stop(u32 timer_id) return CELL_ESRCH; } - LV2_LOCK; - timer->state = SYS_TIMER_STATE_STOP; // stop timer return CELL_OK; @@ -188,6 +190,8 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data { sys_timer.Warning("sys_timer_connect_event_queue(timer_id=0x%x, queue_id=0x%x, name=0x%llx, data1=0x%llx, data2=0x%llx)", timer_id, queue_id, name, data1, data2); + LV2_LOCK; + const auto timer = Emu.GetIdManager().get(timer_id); const auto queue = Emu.GetIdManager().get(queue_id); @@ -196,8 +200,6 @@ s32 sys_timer_connect_event_queue(u32 timer_id, u32 queue_id, u64 name, u64 data return CELL_ESRCH; } - LV2_LOCK; - if (!timer->port.expired()) { return CELL_EISCONN; @@ -215,6 +217,8 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id) { sys_timer.Warning("sys_timer_disconnect_event_queue(timer_id=0x%x)", timer_id); + LV2_LOCK; + const auto timer = Emu.GetIdManager().get(timer_id); if (!timer) @@ -222,8 +226,6 @@ s32 sys_timer_disconnect_event_queue(u32 timer_id) return CELL_ESRCH; } - LV2_LOCK; - if (timer->port.expired()) { return CELL_ENOTCONN; diff --git a/rpcs3/Emu/SysCalls/lv2/sys_timer.h b/rpcs3/Emu/SysCalls/lv2/sys_timer.h index 5e69d20c88..52d9a9b5f4 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_timer.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_timer.h @@ -19,7 +19,6 @@ struct sys_timer_information_t be_t pad; }; -// "timer_t" conflicts with some definition struct lv2_timer_t { std::weak_ptr port; // event queue