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