improvements in definations
This commit is contained in:
parent
4d5e9d1da4
commit
d30703b4eb
|
@ -18,36 +18,44 @@ int PS4_SYSV_ABI sceKernelCreateEventFlag(OrbisKernelEventFlag* ef, const char*
|
||||||
}
|
}
|
||||||
if (pOptParam || !pName ||
|
if (pOptParam || !pName ||
|
||||||
attr > (ORBIS_KERNEL_EVF_ATTR_MULTI | ORBIS_KERNEL_EVF_ATTR_TH_PRIO)) {
|
attr > (ORBIS_KERNEL_EVF_ATTR_MULTI | ORBIS_KERNEL_EVF_ATTR_TH_PRIO)) {
|
||||||
return SCE_KERNEL_ERROR_EINVAL;
|
return ORBIS_KERNEL_ERROR_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(pName) >= 32) {
|
if (strlen(pName) >= 32) {
|
||||||
return ORBIS_KERNEL_ERROR_ENAMETOOLONG;
|
return ORBIS_KERNEL_ERROR_ENAMETOOLONG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool single = true;
|
EventFlagInternal::ThreadMode thread_mode = EventFlagInternal::ThreadMode::Single;
|
||||||
bool fifo = true;
|
EventFlagInternal::QueueMode queue_mode = EventFlagInternal::QueueMode::Fifo;
|
||||||
|
|
||||||
switch (attr) {
|
switch (attr & 0xfu) {
|
||||||
case 0x10:
|
case 0x01:
|
||||||
case 0x11:
|
queue_mode = EventFlagInternal::QueueMode::Fifo;
|
||||||
single = true;
|
|
||||||
fifo = true;
|
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x02:
|
||||||
case 0x21:
|
queue_mode = EventFlagInternal::QueueMode::ThreadPrio;
|
||||||
single = false;
|
|
||||||
fifo = true;
|
|
||||||
break;
|
break;
|
||||||
case 0x22:
|
case 0x00:
|
||||||
single = false;
|
|
||||||
fifo = false;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
*ef = new EventFlagInternal(std::string(pName), single, fifo, initPattern);
|
switch (attr & 0xf0) {
|
||||||
|
case 0x10:
|
||||||
|
thread_mode = EventFlagInternal::ThreadMode::Single;
|
||||||
|
break;
|
||||||
|
case 0x20:
|
||||||
|
thread_mode = EventFlagInternal::ThreadMode::Multi;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT_MSG(queue_mode == EventFlagInternal::QueueMode::Fifo,
|
||||||
|
"ThreadPriority attr is not supported!");
|
||||||
|
|
||||||
|
*ef = new EventFlagInternal(std::string(pName), thread_mode, queue_mode, initPattern);
|
||||||
return ORBIS_OK;
|
return ORBIS_OK;
|
||||||
}
|
}
|
||||||
int PS4_SYSV_ABI sceKernelDeleteEventFlag(OrbisKernelEventFlag ef) {
|
int PS4_SYSV_ABI sceKernelDeleteEventFlag(OrbisKernelEventFlag ef) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ int EventFlagInternal::Wait(u64 bits, WaitMode wait_mode, ClearMode clear_mode,
|
||||||
infinitely = false;
|
infinitely = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_single_thread && m_waiting_threads > 0) {
|
if (m_thread_mode == ThreadMode::Single && m_waiting_threads > 0) {
|
||||||
return ORBIS_KERNEL_ERROR_EPERM;
|
return ORBIS_KERNEL_ERROR_EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,13 @@ public:
|
||||||
|
|
||||||
enum class WaitMode { And, Or };
|
enum class WaitMode { And, Or };
|
||||||
|
|
||||||
EventFlagInternal(const std::string& name, bool single, bool fifo, uint64_t bits)
|
enum class ThreadMode { Single, Multi };
|
||||||
: m_name(name), m_single_thread(single), m_fifo(fifo), m_bits(bits){};
|
|
||||||
|
enum class QueueMode { Fifo, ThreadPrio };
|
||||||
|
|
||||||
|
EventFlagInternal(const std::string& name, ThreadMode thread_mode, QueueMode queue_mode,
|
||||||
|
uint64_t bits)
|
||||||
|
: m_name(name), m_thread_mode(thread_mode), m_queue_mode(queue_mode), m_bits(bits){};
|
||||||
|
|
||||||
int Wait(u64 bits, WaitMode wait_mode, ClearMode clear_mode, u64* result, u32* ptr_micros);
|
int Wait(u64 bits, WaitMode wait_mode, ClearMode clear_mode, u64* result, u32* ptr_micros);
|
||||||
int Poll(u64 bits, WaitMode wait_mode, ClearMode clear_mode, u64* result);
|
int Poll(u64 bits, WaitMode wait_mode, ClearMode clear_mode, u64* result);
|
||||||
|
@ -29,8 +34,8 @@ private:
|
||||||
Status m_status = Status::Set;
|
Status m_status = Status::Set;
|
||||||
int m_waiting_threads = 0;
|
int m_waiting_threads = 0;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
bool m_single_thread = false;
|
ThreadMode m_thread_mode = ThreadMode::Single;
|
||||||
bool m_fifo = false;
|
QueueMode m_queue_mode = QueueMode::Fifo;
|
||||||
u64 m_bits = 0;
|
u64 m_bits = 0;
|
||||||
};
|
};
|
||||||
} // namespace Libraries::Kernel
|
} // namespace Libraries::Kernel
|
Loading…
Reference in New Issue