eventflags enums
This commit is contained in:
parent
8bae44a90b
commit
84467efe51
|
@ -91,31 +91,35 @@ int PS4_SYSV_ABI sceKernelWaitEventFlag(OrbisKernelEventFlag ef, u64 bitPattern,
|
|||
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||
}
|
||||
|
||||
int wait = 0;
|
||||
int clear = 0;
|
||||
EventFlagInternal::WaitMode wait = EventFlagInternal::WaitMode::And;
|
||||
EventFlagInternal::ClearMode clear = EventFlagInternal::ClearMode::None;
|
||||
|
||||
switch (waitMode & 0xf) {
|
||||
case 0x01:
|
||||
wait = ORBIS_KERNEL_EVF_WAITMODE_AND;
|
||||
wait = EventFlagInternal::WaitMode::And;
|
||||
break;
|
||||
case 0x02:
|
||||
wait = ORBIS_KERNEL_EVF_WAITMODE_OR;
|
||||
wait = EventFlagInternal::WaitMode::Or;
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
switch (waitMode & 0xf0) {
|
||||
case 0x00:
|
||||
clear = EventFlagInternal::ClearMode::None;
|
||||
break;
|
||||
case 0x10:
|
||||
clear = ORBIS_KERNEL_EVF_WAITMODE_CLEAR_ALL;
|
||||
clear = EventFlagInternal::ClearMode::All;
|
||||
break;
|
||||
case 0x20:
|
||||
clear = ORBIS_KERNEL_EVF_WAITMODE_CLEAR_PAT;
|
||||
clear = EventFlagInternal::ClearMode::Bits;
|
||||
break;
|
||||
default:
|
||||
clear = 0; // not clear
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
int result = ef->Wait(bitPattern, wait, clear, pResultPat, pTimeout);
|
||||
auto result = ef->Wait(bitPattern, wait, clear, pResultPat, pTimeout);
|
||||
|
||||
if (result != ORBIS_OK) {
|
||||
LOG_ERROR(Kernel_Event, "returned {}", result);
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "event_flag_obj.h"
|
||||
|
||||
namespace Libraries::Kernel {
|
||||
int EventFlagInternal::Wait(u64 bits, int wait_mode, int clear_mode, u64* result, u32* ptr_micros) {
|
||||
int EventFlagInternal::Wait(u64 bits, WaitMode wait_mode, ClearMode clear_mode, u64* result,
|
||||
u32* ptr_micros) {
|
||||
std::unique_lock lock{m_mutex};
|
||||
|
||||
uint32_t micros = 0;
|
||||
|
@ -23,8 +24,8 @@ int EventFlagInternal::Wait(u64 bits, int wait_mode, int clear_mode, u64* result
|
|||
m_waiting_threads++;
|
||||
auto waitFunc = [this, wait_mode, bits] {
|
||||
return (m_status == Status::Canceled || m_status == Status::Deleted ||
|
||||
(wait_mode == ORBIS_KERNEL_EVF_WAITMODE_AND && (m_bits & bits) == bits) ||
|
||||
(wait_mode == ORBIS_KERNEL_EVF_WAITMODE_OR && (m_bits & bits) != 0));
|
||||
(wait_mode == WaitMode::And && (m_bits & bits) == bits) ||
|
||||
(wait_mode == WaitMode::Or && (m_bits & bits) != 0));
|
||||
};
|
||||
|
||||
if (infinitely) {
|
||||
|
@ -61,9 +62,9 @@ int EventFlagInternal::Wait(u64 bits, int wait_mode, int clear_mode, u64* result
|
|||
return ORBIS_KERNEL_ERROR_EACCES;
|
||||
}
|
||||
|
||||
if (clear_mode == ORBIS_KERNEL_EVF_WAITMODE_CLEAR_ALL) {
|
||||
if (clear_mode == ClearMode::All) {
|
||||
m_bits = 0;
|
||||
} else if (clear_mode == ORBIS_KERNEL_EVF_WAITMODE_CLEAR_PAT) {
|
||||
} else if (clear_mode == ClearMode::Bits) {
|
||||
m_bits &= ~bits;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,20 @@
|
|||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include "common/types.h"
|
||||
#include "event_flag_codes.h"
|
||||
|
||||
namespace Libraries::Kernel {
|
||||
|
||||
class EventFlagInternal {
|
||||
public:
|
||||
enum class ClearMode { None, All, Bits };
|
||||
|
||||
enum class WaitMode { And, Or };
|
||||
|
||||
EventFlagInternal(const std::string& name, bool single, bool fifo, uint64_t bits)
|
||||
: m_name(name), m_single_thread(single), m_fifo(fifo), m_bits(bits){};
|
||||
|
||||
int Wait(u64 bits, int wait_mode, int clear_mode, u64* result, u32* ptr_micros);
|
||||
int Wait(u64 bits, WaitMode wait_mode, ClearMode clear_mode, u64* result,
|
||||
u32* ptr_micros);
|
||||
|
||||
private:
|
||||
enum class Status { Set, Canceled, Deleted };
|
||||
|
|
Loading…
Reference in New Issue