mirror of
https://github.com/RPCSX/rpcsx.git
synced 2025-12-06 07:12:14 +01:00
Compare commits
10 commits
a7152c7ad7
...
69158b9f74
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69158b9f74 | ||
|
|
ac853e0817 | ||
|
|
7b03b695f5 | ||
|
|
e73a0b962d | ||
|
|
30469f7fb9 | ||
|
|
2965aaf3e3 | ||
|
|
3f14b99f24 | ||
|
|
3230bfefd8 | ||
|
|
77dd5d7d10 | ||
|
|
47e164d2ad |
|
|
@ -124,7 +124,7 @@ enum class lv2_mp_flag {
|
|||
strict_get_block_size,
|
||||
cache,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = cache,
|
||||
};
|
||||
|
||||
enum class lv2_file_type {
|
||||
|
|
@ -140,7 +140,7 @@ struct lv2_fs_mount_point {
|
|||
const u32 sector_size = 512;
|
||||
const u64 sector_count = 256;
|
||||
const u32 block_size = 4096;
|
||||
const bs_t<lv2_mp_flag> flags{};
|
||||
const rx::EnumBitSet<lv2_mp_flag> flags{};
|
||||
lv2_fs_mount_point *const next = nullptr;
|
||||
|
||||
mutable shared_mutex mutex;
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "util/bit_set.h"
|
||||
#include "util/mutex.h"
|
||||
|
||||
#include "Emu/Cell/ErrorCodes.h"
|
||||
#include "Emu/Memory/vm_ptr.h"
|
||||
|
||||
#include <functional>
|
||||
#include <queue>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// Error codes
|
||||
enum sys_net_error : s32 {
|
||||
SYS_NET_ENOENT = 2,
|
||||
|
|
@ -54,7 +46,7 @@ enum sys_net_error : s32 {
|
|||
};
|
||||
|
||||
static constexpr sys_net_error operator-(sys_net_error v) {
|
||||
return sys_net_error{-+v};
|
||||
return sys_net_error{-static_cast<s32>(v)};
|
||||
}
|
||||
|
||||
// Socket types (prefixed with SYS_NET_)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include "Emu/IdManager.h"
|
||||
#include "Emu/NP/ip_address.h"
|
||||
#include "cellos/sys_net.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "util/atomic_bit_set.h"
|
||||
#include "util/mutex.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
@ -32,7 +34,7 @@ public:
|
|||
write,
|
||||
error,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = error,
|
||||
};
|
||||
|
||||
union sockopt_data {
|
||||
|
|
@ -62,10 +64,10 @@ public:
|
|||
std::unique_lock<shared_mutex> lock();
|
||||
|
||||
void set_lv2_id(u32 id);
|
||||
bs_t<poll_t> get_events() const;
|
||||
void set_poll_event(bs_t<poll_t> event);
|
||||
void poll_queue(shared_ptr<ppu_thread> ppu, bs_t<poll_t> event,
|
||||
std::function<bool(bs_t<poll_t>)> poll_cb);
|
||||
rx::EnumBitSet<poll_t> get_events() const;
|
||||
void set_poll_event(rx::EnumBitSet<poll_t> event);
|
||||
void poll_queue(shared_ptr<ppu_thread> ppu, rx::EnumBitSet<poll_t> event,
|
||||
std::function<bool(rx::EnumBitSet<poll_t>)> poll_cb);
|
||||
u32 clear_queue(ppu_thread *);
|
||||
void handle_events(const pollfd &native_fd, bool unset_connecting = false);
|
||||
void queue_wake(ppu_thread *ppu);
|
||||
|
|
@ -110,7 +112,7 @@ public:
|
|||
virtual s32 shutdown(s32 how) = 0;
|
||||
|
||||
virtual s32 poll(sys_net_pollfd &sn_pfd, pollfd &native_pfd) = 0;
|
||||
virtual std::tuple<bool, bool, bool> select(bs_t<poll_t> selected,
|
||||
virtual std::tuple<bool, bool, bool> select(rx::EnumBitSet<poll_t> selected,
|
||||
pollfd &native_pfd) = 0;
|
||||
|
||||
error_code abort_socket(s32 flags);
|
||||
|
|
@ -137,8 +139,8 @@ protected:
|
|||
atomic_bs_t<poll_t> events{};
|
||||
|
||||
// Event processing workload (pair of thread id and the processing function)
|
||||
std::vector<
|
||||
std::pair<shared_ptr<ppu_thread>, std::function<bool(bs_t<poll_t>)>>>
|
||||
std::vector<std::pair<shared_ptr<ppu_thread>,
|
||||
std::function<bool(rx::EnumBitSet<poll_t>)>>>
|
||||
queue;
|
||||
|
||||
// Socket options value keepers
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public:
|
|||
bool is_lock = true) override;
|
||||
|
||||
s32 poll(sys_net_pollfd &sn_pfd, pollfd &native_pfd) override;
|
||||
std::tuple<bool, bool, bool> select(bs_t<poll_t> selected,
|
||||
std::tuple<bool, bool, bool> select(rx::EnumBitSet<poll_t> selected,
|
||||
pollfd &native_pfd) override;
|
||||
|
||||
bool is_socket_connected();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "lv2_socket.h"
|
||||
#include <queue>
|
||||
|
||||
class lv2_socket_p2p : public lv2_socket {
|
||||
public:
|
||||
|
|
@ -38,7 +39,7 @@ public:
|
|||
s32 shutdown(s32 how) override;
|
||||
|
||||
s32 poll(sys_net_pollfd &sn_pfd, pollfd &native_pfd) override;
|
||||
std::tuple<bool, bool, bool> select(bs_t<poll_t> selected,
|
||||
std::tuple<bool, bool, bool> select(rx::EnumBitSet<poll_t> selected,
|
||||
pollfd &native_pfd) override;
|
||||
|
||||
void handle_new_data(sys_net_sockaddr_in_p2p p2p_addr,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
#ifdef _WIN32
|
||||
#include <WS2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
|
|
@ -101,7 +102,7 @@ public:
|
|||
s32 shutdown(s32 how) override;
|
||||
|
||||
s32 poll(sys_net_pollfd &sn_pfd, pollfd &native_pfd) override;
|
||||
std::tuple<bool, bool, bool> select(bs_t<poll_t> selected,
|
||||
std::tuple<bool, bool, bool> select(rx::EnumBitSet<poll_t> selected,
|
||||
pollfd &native_pfd) override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -40,6 +40,6 @@ public:
|
|||
s32 shutdown(s32 how) override;
|
||||
|
||||
s32 poll(sys_net_pollfd &sn_pfd, pollfd &native_pfd) override;
|
||||
std::tuple<bool, bool, bool> select(bs_t<poll_t> selected,
|
||||
std::tuple<bool, bool, bool> select(rx::EnumBitSet<poll_t> selected,
|
||||
pollfd &native_pfd) override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
#include "sys_usbd.h"
|
||||
#include "sys_vm.h"
|
||||
|
||||
#include "util/atomic_bit_set.h"
|
||||
#include "util/init_mutex.hpp"
|
||||
#include "util/sysinfo.hpp"
|
||||
#include "util/tsc.hpp"
|
||||
|
|
@ -1762,17 +1763,18 @@ bool lv2_obj::sleep_unlocked(cpu_thread &thread, u64 timeout,
|
|||
return_val = false;
|
||||
}
|
||||
|
||||
const auto [_, ok] = ppu->state.fetch_op([&](bs_t<cpu_flag> &val) {
|
||||
if (!(val & cpu_flag::signal)) {
|
||||
val += cpu_flag::suspend;
|
||||
const auto [_, ok] =
|
||||
ppu->state.fetch_op([&](rx::EnumBitSet<cpu_flag> &val) {
|
||||
if (!(val & cpu_flag::signal)) {
|
||||
val += cpu_flag::suspend;
|
||||
|
||||
// Flag used for forced timeout notification
|
||||
ensure(!timeout || !(val & cpu_flag::notify));
|
||||
return true;
|
||||
}
|
||||
// Flag used for forced timeout notification
|
||||
ensure(!timeout || !(val & cpu_flag::notify));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
if (!ok) {
|
||||
ppu_log.fatal("sleep() failed (signaled) (%s)", ppu->current_function);
|
||||
|
|
@ -2075,7 +2077,7 @@ void lv2_obj::schedule_all(u64 current_time) {
|
|||
ppu_log.trace("schedule(): %s", target->id);
|
||||
|
||||
// Remove yield if it was sleeping until now
|
||||
const bs_t<cpu_flag> remove_yield =
|
||||
const rx::EnumBitSet<cpu_flag> remove_yield =
|
||||
target->start_time == 0 ? +cpu_flag::suspend
|
||||
: (cpu_flag::yield + cpu_flag::preempt);
|
||||
|
||||
|
|
|
|||
|
|
@ -740,7 +740,7 @@ lv2_file::open_raw_result_t lv2_file::open_raw(const std::string &local_path,
|
|||
return {CELL_EISDIR};
|
||||
}
|
||||
|
||||
bs_t<fs::open_mode> open_mode{};
|
||||
rx::EnumBitSet<fs::open_mode> open_mode{};
|
||||
|
||||
switch (flags & CELL_FS_O_ACCMODE) {
|
||||
case CELL_FS_O_RDONLY:
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ error_code sys_net_bnet_accept(ppu_thread &ppu, s32 s,
|
|||
|
||||
sock.poll_queue(idm::get_unlocked<named_thread<ppu_thread>>(ppu.id),
|
||||
lv2_socket::poll_t::read,
|
||||
[&](bs_t<lv2_socket::poll_t> events) -> bool {
|
||||
[&](rx::EnumBitSet<lv2_socket::poll_t> events) -> bool {
|
||||
if (events & lv2_socket::poll_t::read) {
|
||||
auto [success, res, res_socket, res_addr] =
|
||||
sock.accept(false);
|
||||
|
|
@ -554,7 +554,7 @@ error_code sys_net_bnet_connect(ppu_thread &ppu, s32 s,
|
|||
|
||||
sock.poll_queue(idm::get_unlocked<named_thread<ppu_thread>>(ppu.id),
|
||||
lv2_socket::poll_t::write,
|
||||
[&](bs_t<lv2_socket::poll_t> events) -> bool {
|
||||
[&](rx::EnumBitSet<lv2_socket::poll_t> events) -> bool {
|
||||
if (events & lv2_socket::poll_t::write) {
|
||||
result = sock.connect_followup();
|
||||
|
||||
|
|
@ -819,7 +819,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread &ppu, s32 s, vm::ptr<void> buf,
|
|||
sock.poll_queue(
|
||||
idm::get_unlocked<named_thread<ppu_thread>>(ppu.id),
|
||||
lv2_socket::poll_t::read,
|
||||
[&](bs_t<lv2_socket::poll_t> events) -> bool {
|
||||
[&](rx::EnumBitSet<lv2_socket::poll_t> events) -> bool {
|
||||
if (events & lv2_socket::poll_t::read) {
|
||||
const auto success = sock.recvfrom(flags, len, false);
|
||||
|
||||
|
|
@ -929,7 +929,7 @@ error_code sys_net_bnet_sendmsg(ppu_thread &ppu, s32 s,
|
|||
|
||||
sock.poll_queue(idm::get_unlocked<named_thread<ppu_thread>>(ppu.id),
|
||||
lv2_socket::poll_t::write,
|
||||
[&](bs_t<lv2_socket::poll_t> events) -> bool {
|
||||
[&](rx::EnumBitSet<lv2_socket::poll_t> events) -> bool {
|
||||
if (events & lv2_socket::poll_t::write) {
|
||||
const auto success =
|
||||
sock.sendmsg(flags, *netmsg, false);
|
||||
|
|
@ -1023,7 +1023,7 @@ error_code sys_net_bnet_sendto(ppu_thread &ppu, s32 s, vm::cptr<void> buf,
|
|||
// Enable write event
|
||||
sock.poll_queue(idm::get_unlocked<named_thread<ppu_thread>>(ppu.id),
|
||||
lv2_socket::poll_t::write,
|
||||
[&](bs_t<lv2_socket::poll_t> events) -> bool {
|
||||
[&](rx::EnumBitSet<lv2_socket::poll_t> events) -> bool {
|
||||
if (events & lv2_socket::poll_t::write) {
|
||||
auto success =
|
||||
sock.sendto(flags, buf_copy, sn_addr, false);
|
||||
|
|
@ -1336,7 +1336,7 @@ error_code sys_net_bnet_poll(ppu_thread &ppu, vm::ptr<sys_net_pollfd> fds,
|
|||
sock->set_connecting(connecting[i]);
|
||||
#endif
|
||||
|
||||
bs_t<lv2_socket::poll_t> selected = +lv2_socket::poll_t::error;
|
||||
rx::EnumBitSet<lv2_socket::poll_t> selected = lv2_socket::poll_t::error;
|
||||
|
||||
if (fds_buf[i].events & SYS_NET_POLLIN)
|
||||
selected += lv2_socket::poll_t::read;
|
||||
|
|
@ -1348,7 +1348,7 @@ error_code sys_net_bnet_poll(ppu_thread &ppu, vm::ptr<sys_net_pollfd> fds,
|
|||
sock->poll_queue(idm::get_unlocked<named_thread<ppu_thread>>(ppu.id),
|
||||
selected,
|
||||
[sock, selected, &fds_buf, i, &signaled,
|
||||
&ppu](bs_t<lv2_socket::poll_t> events) {
|
||||
&ppu](rx::EnumBitSet<lv2_socket::poll_t> events) {
|
||||
if (events & selected) {
|
||||
if (events & selected & lv2_socket::poll_t::read)
|
||||
fds_buf[i].revents |= SYS_NET_POLLIN;
|
||||
|
|
@ -1457,7 +1457,7 @@ error_code sys_net_bnet_select(ppu_thread &ppu, s32 nfds,
|
|||
|
||||
for (s32 i = 0; i < nfds; i++) {
|
||||
_fds[i].fd = -1;
|
||||
bs_t<lv2_socket::poll_t> selected{};
|
||||
rx::EnumBitSet<lv2_socket::poll_t> selected{};
|
||||
|
||||
if (readfds && _readfds.bit(i))
|
||||
selected += lv2_socket::poll_t::read;
|
||||
|
|
@ -1529,7 +1529,7 @@ error_code sys_net_bnet_select(ppu_thread &ppu, s32 nfds,
|
|||
}
|
||||
|
||||
for (s32 i = 0; i < nfds; i++) {
|
||||
bs_t<lv2_socket::poll_t> selected{};
|
||||
rx::EnumBitSet<lv2_socket::poll_t> selected{};
|
||||
|
||||
if (readfds && _readfds.bit(i))
|
||||
selected += lv2_socket::poll_t::read;
|
||||
|
|
@ -1554,7 +1554,7 @@ error_code sys_net_bnet_select(ppu_thread &ppu, s32 nfds,
|
|||
sock->poll_queue(
|
||||
idm::get_unlocked<named_thread<ppu_thread>>(ppu.id), selected,
|
||||
[sock, selected, i, &rread, &rwrite, &rexcept, &signaled,
|
||||
&ppu](bs_t<lv2_socket::poll_t> events) {
|
||||
&ppu](rx::EnumBitSet<lv2_socket::poll_t> events) {
|
||||
if (events & selected) {
|
||||
if (selected & lv2_socket::poll_t::read &&
|
||||
events &
|
||||
|
|
|
|||
|
|
@ -32,17 +32,17 @@ void lv2_socket::set_connecting(bool connecting) {
|
|||
|
||||
void lv2_socket::set_lv2_id(u32 id) { lv2_id = id; }
|
||||
|
||||
bs_t<lv2_socket::poll_t> lv2_socket::get_events() const {
|
||||
rx::EnumBitSet<lv2_socket::poll_t> lv2_socket::get_events() const {
|
||||
return events.load();
|
||||
}
|
||||
|
||||
void lv2_socket::set_poll_event(bs_t<lv2_socket::poll_t> event) {
|
||||
void lv2_socket::set_poll_event(rx::EnumBitSet<lv2_socket::poll_t> event) {
|
||||
events += event;
|
||||
}
|
||||
|
||||
void lv2_socket::poll_queue(
|
||||
shared_ptr<ppu_thread> ppu, bs_t<lv2_socket::poll_t> event,
|
||||
std::function<bool(bs_t<lv2_socket::poll_t>)> poll_cb) {
|
||||
shared_ptr<ppu_thread> ppu, rx::EnumBitSet<lv2_socket::poll_t> event,
|
||||
std::function<bool(rx::EnumBitSet<lv2_socket::poll_t>)> poll_cb) {
|
||||
set_poll_event(event);
|
||||
queue.emplace_back(std::move(ppu), poll_cb);
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ u32 lv2_socket::clear_queue(ppu_thread *ppu) {
|
|||
|
||||
void lv2_socket::handle_events(const pollfd &native_pfd,
|
||||
[[maybe_unused]] bool unset_connecting) {
|
||||
bs_t<lv2_socket::poll_t> events_happening{};
|
||||
rx::EnumBitSet<lv2_socket::poll_t> events_happening{};
|
||||
|
||||
if (native_pfd.revents & (POLLIN | POLLHUP) &&
|
||||
events.test_and_reset(lv2_socket::poll_t::read))
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ std::optional<s32> lv2_socket_native::connect(const sys_net_sockaddr &addr) {
|
|||
#endif
|
||||
this->poll_queue(
|
||||
null_ptr, lv2_socket::poll_t::write,
|
||||
[this](bs_t<lv2_socket::poll_t> events) -> bool {
|
||||
[this](rx::EnumBitSet<lv2_socket::poll_t> events) -> bool {
|
||||
if (events & lv2_socket::poll_t::write) {
|
||||
int native_error;
|
||||
::socklen_t size = sizeof(native_error);
|
||||
|
|
@ -1101,7 +1101,7 @@ s32 lv2_socket_native::poll(sys_net_pollfd &sn_pfd, pollfd &native_pfd) {
|
|||
}
|
||||
|
||||
std::tuple<bool, bool, bool>
|
||||
lv2_socket_native::select(bs_t<lv2_socket::poll_t> selected,
|
||||
lv2_socket_native::select(rx::EnumBitSet<lv2_socket::poll_t> selected,
|
||||
pollfd &native_pfd) {
|
||||
native_pfd.fd = native_socket;
|
||||
if (selected & lv2_socket::poll_t::read) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "sys_net/lv2_socket_p2p.h"
|
||||
#include "sys_net/network_context.h"
|
||||
#include "sys_net/sys_net_helpers.h"
|
||||
#include <deque>
|
||||
|
||||
LOG_CHANNEL(sys_net);
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ void lv2_socket_p2p::handle_new_data(sys_net_sockaddr_in_p2p p2p_addr,
|
|||
|
||||
// Check if poll is happening
|
||||
if (events.test_and_reset(lv2_socket::poll_t::read)) {
|
||||
bs_t<lv2_socket::poll_t> read_event = lv2_socket::poll_t::read;
|
||||
rx::EnumBitSet<lv2_socket::poll_t> read_event = lv2_socket::poll_t::read;
|
||||
for (auto it = queue.begin(); it != queue.end();) {
|
||||
if (it->second(read_event)) {
|
||||
it = queue.erase(it);
|
||||
|
|
@ -378,7 +379,7 @@ s32 lv2_socket_p2p::poll(sys_net_pollfd &sn_pfd,
|
|||
}
|
||||
|
||||
std::tuple<bool, bool, bool>
|
||||
lv2_socket_p2p::select(bs_t<lv2_socket::poll_t> selected,
|
||||
lv2_socket_p2p::select(rx::EnumBitSet<lv2_socket::poll_t> selected,
|
||||
[[maybe_unused]] pollfd &native_pfd) {
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ bool lv2_socket_p2ps::handle_connected(p2ps_encapsulated_tcp *tcp_header,
|
|||
|
||||
// check if polling is happening
|
||||
if (data_available && events.test_and_reset(lv2_socket::poll_t::read)) {
|
||||
bs_t<lv2_socket::poll_t> read_event = lv2_socket::poll_t::read;
|
||||
rx::EnumBitSet<lv2_socket::poll_t> read_event = lv2_socket::poll_t::read;
|
||||
for (auto it = queue.begin(); it != queue.end();) {
|
||||
if (it->second(read_event)) {
|
||||
it = queue.erase(it);
|
||||
|
|
@ -479,7 +479,7 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp *tcp_header,
|
|||
|
||||
backlog.push_back(new_sock_id);
|
||||
if (events.test_and_reset(lv2_socket::poll_t::read)) {
|
||||
bs_t<lv2_socket::poll_t> read_event = lv2_socket::poll_t::read;
|
||||
rx::EnumBitSet<lv2_socket::poll_t> read_event = lv2_socket::poll_t::read;
|
||||
for (auto it = queue.begin(); it != queue.end();) {
|
||||
if (it->second(read_event)) {
|
||||
it = queue.erase(it);
|
||||
|
|
@ -983,7 +983,7 @@ s32 lv2_socket_p2ps::poll(sys_net_pollfd &sn_pfd,
|
|||
}
|
||||
|
||||
std::tuple<bool, bool, bool>
|
||||
lv2_socket_p2ps::select(bs_t<lv2_socket::poll_t> selected,
|
||||
lv2_socket_p2ps::select(rx::EnumBitSet<lv2_socket::poll_t> selected,
|
||||
[[maybe_unused]] pollfd &native_pfd) {
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,9 +129,9 @@ s32 lv2_socket_raw::poll([[maybe_unused]] sys_net_pollfd &sn_pfd,
|
|||
return {};
|
||||
}
|
||||
|
||||
std::tuple<bool, bool, bool>
|
||||
lv2_socket_raw::select([[maybe_unused]] bs_t<lv2_socket::poll_t> selected,
|
||||
[[maybe_unused]] pollfd &native_pfd) {
|
||||
std::tuple<bool, bool, bool> lv2_socket_raw::select(
|
||||
[[maybe_unused]] rx::EnumBitSet<lv2_socket::poll_t> selected,
|
||||
[[maybe_unused]] pollfd &native_pfd) {
|
||||
LOG_ONCE(raw_select, "lv2_socket_raw::select");
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1295,7 +1295,7 @@ error_code sys_spu_thread_group_terminate(ppu_thread &ppu, u32 id, s32 value) {
|
|||
|
||||
for (auto &thread : group->threads) {
|
||||
if (thread) {
|
||||
thread->state.fetch_op([](bs_t<cpu_flag> &flags) {
|
||||
thread->state.fetch_op([](rx::EnumBitSet<cpu_flag> &flags) {
|
||||
if (flags & cpu_flag::stop) {
|
||||
// In case the thread raised the ret flag itself at some point do not
|
||||
// raise it again
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
set(CMAKE_POSITION_INDEPENDENT_CODE on)
|
||||
|
||||
add_library(obj.orbis-utils-ipc OBJECT
|
||||
src/utils/SharedMutex.cpp
|
||||
src/utils/SharedCV.cpp
|
||||
src/utils/SharedAtomic.cpp
|
||||
)
|
||||
add_library(obj.orbis-kernel OBJECT
|
||||
src/module.cpp
|
||||
src/pipe.cpp
|
||||
|
|
@ -72,7 +67,7 @@ add_library(obj.orbis-kernel OBJECT
|
|||
src/utils/Logs.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(obj.orbis-kernel PUBLIC orbis::kernel::config $<TARGET_OBJECTS:obj.orbis-utils-ipc>)
|
||||
target_link_libraries(obj.orbis-kernel PUBLIC orbis::kernel::config rx)
|
||||
|
||||
target_include_directories(obj.orbis-kernel
|
||||
PUBLIC
|
||||
|
|
@ -82,27 +77,10 @@ target_include_directories(obj.orbis-kernel
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/include/orbis
|
||||
)
|
||||
|
||||
target_include_directories(obj.orbis-utils-ipc
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/orbis
|
||||
)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
target_compile_definitions(obj.orbis-utils-ipc PUBLIC ORBIS_HAS_FUTEX)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
target_compile_definitions(obj.orbis-utils-ipc PUBLIC ORBIS_HAS_ULOCK)
|
||||
endif()
|
||||
|
||||
add_library(orbis-utils-ipc STATIC)
|
||||
add_library(orbis-kernel STATIC)
|
||||
add_library(orbis-kernel-shared SHARED)
|
||||
add_library(orbis::utils::ipc ALIAS orbis-utils-ipc)
|
||||
add_library(orbis::kernel ALIAS orbis-kernel)
|
||||
add_library(orbis::kernel-shared ALIAS orbis-kernel-shared)
|
||||
|
||||
target_link_libraries(orbis-utils-ipc PUBLIC obj.orbis-utils-ipc)
|
||||
target_link_libraries(orbis-kernel PUBLIC obj.orbis-kernel)
|
||||
target_link_libraries(orbis-kernel-shared PUBLIC obj.orbis-kernel)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "orbis-config.hpp"
|
||||
#include "utils/BitSet.hpp"
|
||||
#include "utils/Rc.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include "rx/BitSet.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -43,7 +44,7 @@ static_assert(sizeof(BudgetInfo) == 0x18);
|
|||
using BudgetInfoList =
|
||||
std::array<BudgetInfo, static_cast<int>(BudgetResource::_count)>;
|
||||
|
||||
class Budget : public RcBase {
|
||||
class Budget : public rx::RcBase {
|
||||
using BudgetList =
|
||||
std::array<BudgetItem, static_cast<int>(BudgetResource::_count)>;
|
||||
|
||||
|
|
@ -132,8 +133,8 @@ public:
|
|||
[[nodiscard]] ProcessType processType() const { return mProcessType; }
|
||||
|
||||
private:
|
||||
mutable shared_mutex mMtx;
|
||||
orbis::BitSet<static_cast<int>(BudgetResource::_count)> mUsed;
|
||||
mutable rx::shared_mutex mMtx;
|
||||
rx::BitSet<static_cast<int>(BudgetResource::_count)> mUsed;
|
||||
ProcessType mProcessType{};
|
||||
BudgetList mList;
|
||||
char mName[32]{};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
|
@ -56,22 +56,31 @@ using kunmap =
|
|||
template <typename T, typename... Args>
|
||||
requires(std::is_constructible_v<T, Args...>)
|
||||
T *knew(Args &&...args) {
|
||||
auto loc = static_cast<T *>(utils::kalloc(sizeof(T), alignof(T)));
|
||||
auto res = std::construct_at(loc, std::forward<Args>(args)...);
|
||||
if constexpr (requires(T *t) { t->_total_size = sizeof(T); })
|
||||
res->_total_size = sizeof(T);
|
||||
return res;
|
||||
if constexpr (std::is_base_of_v<rx::RcBase, T>) {
|
||||
static_assert(!std::is_final_v<T>);
|
||||
struct DynamicObject final : T {
|
||||
using T::T;
|
||||
|
||||
void operator delete(void *pointer) { utils::kfree(pointer, sizeof(T)); }
|
||||
};
|
||||
|
||||
auto loc = static_cast<DynamicObject *>(
|
||||
utils::kalloc(sizeof(DynamicObject), alignof(DynamicObject)));
|
||||
return std::construct_at(loc, std::forward<Args>(args)...);
|
||||
} else {
|
||||
static_assert(!std::is_polymorphic_v<T>,
|
||||
"Polymorphic type should be derived from rx::RcBase");
|
||||
|
||||
auto loc = static_cast<T *>(utils::kalloc(sizeof(T), alignof(T)));
|
||||
return std::construct_at(loc, std::forward<Args>(args)...);
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
template <typename T> void kdelete(T *ptr) {
|
||||
auto total_size = sizeof(T);
|
||||
if constexpr (requires(T *t) { t->_total_size = sizeof(T); })
|
||||
total_size = ptr->_total_size;
|
||||
else
|
||||
static_assert(std::is_final_v<T>, "Uncertain type size");
|
||||
static_assert(std::is_final_v<T>, "Uncertain type size");
|
||||
ptr->~T();
|
||||
utils::kfree(ptr, total_size);
|
||||
utils::kfree(ptr, sizeof(T));
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
#include "ipmi.hpp"
|
||||
#include "orbis/note.hpp"
|
||||
#include "osem.hpp"
|
||||
#include "rx/IdMap.hpp"
|
||||
#include "rx/LinkedNode.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include "thread/types.hpp"
|
||||
#include "utils/IdMap.hpp"
|
||||
#include "utils/LinkedNode.hpp"
|
||||
#include "utils/SharedCV.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
|
|
@ -32,13 +32,13 @@ struct UmtxKey {
|
|||
|
||||
struct UmtxCond {
|
||||
Thread *thr;
|
||||
utils::shared_cv cv;
|
||||
rx::shared_cv cv;
|
||||
|
||||
UmtxCond(Thread *thr) : thr(thr) {}
|
||||
};
|
||||
|
||||
struct UmtxChain {
|
||||
utils::shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
using queue_type = utils::kmultimap<UmtxKey, UmtxCond>;
|
||||
queue_type sleep_queue;
|
||||
queue_type spare_queue;
|
||||
|
|
@ -57,7 +57,7 @@ enum class FwType : std::uint8_t {
|
|||
Ps5,
|
||||
};
|
||||
|
||||
struct RcAppInfo : RcBase, AppInfoEx {
|
||||
struct RcAppInfo : rx::RcBase, AppInfoEx {
|
||||
orbis::uint32_t appState = 0;
|
||||
};
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public:
|
|||
Process *findProcessById(pid_t pid) const;
|
||||
Process *findProcessByHostId(std::uint64_t pid) const;
|
||||
|
||||
utils::LinkedNode<Process> *getProcessList() { return m_processes; }
|
||||
rx::LinkedNode<Process> *getProcessList() { return m_processes; }
|
||||
|
||||
long allocatePid() {
|
||||
std::lock_guard lock(m_thread_id_mtx);
|
||||
|
|
@ -98,7 +98,7 @@ public:
|
|||
return {it->second.get(), inserted};
|
||||
}
|
||||
|
||||
Ref<EventFlag> findEventFlag(std::string_view name) {
|
||||
rx::Ref<EventFlag> findEventFlag(std::string_view name) {
|
||||
std::lock_guard lock(m_evf_mtx);
|
||||
|
||||
if (auto it = m_event_flags.find(name); it != m_event_flags.end()) {
|
||||
|
|
@ -121,7 +121,7 @@ public:
|
|||
return {it->second.get(), inserted};
|
||||
}
|
||||
|
||||
Ref<Semaphore> findSemaphore(std::string_view name) {
|
||||
rx::Ref<Semaphore> findSemaphore(std::string_view name) {
|
||||
std::lock_guard lock(m_sem_mtx);
|
||||
if (auto it = m_semaphores.find(name); it != m_semaphores.end()) {
|
||||
return it->second;
|
||||
|
|
@ -130,7 +130,8 @@ public:
|
|||
return {};
|
||||
}
|
||||
|
||||
std::pair<Ref<IpmiServer>, ErrorCode> createIpmiServer(utils::kstring name) {
|
||||
std::pair<rx::Ref<IpmiServer>, ErrorCode>
|
||||
createIpmiServer(utils::kstring name) {
|
||||
std::lock_guard lock(m_sem_mtx);
|
||||
auto [it, inserted] = mIpmiServers.try_emplace(std::move(name), nullptr);
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ public:
|
|||
return {it->second, {}};
|
||||
}
|
||||
|
||||
Ref<IpmiServer> findIpmiServer(std::string_view name) {
|
||||
rx::Ref<IpmiServer> findIpmiServer(std::string_view name) {
|
||||
std::lock_guard lock(m_sem_mtx);
|
||||
if (auto it = mIpmiServers.find(name); it != mIpmiServers.end()) {
|
||||
return it->second;
|
||||
|
|
@ -158,7 +159,7 @@ public:
|
|||
}
|
||||
|
||||
std::tuple<utils::kmap<utils::kstring, char[128]> &,
|
||||
std::unique_lock<shared_mutex>>
|
||||
std::unique_lock<rx::shared_mutex>>
|
||||
getKernelEnv() {
|
||||
std::unique_lock lock(m_kenv_mtx);
|
||||
return {m_kenv, std::move(lock)};
|
||||
|
|
@ -178,7 +179,7 @@ public:
|
|||
};
|
||||
|
||||
// Use getUmtxChain0 or getUmtxChain1
|
||||
std::tuple<UmtxChain &, UmtxKey, std::unique_lock<shared_mutex>>
|
||||
std::tuple<UmtxChain &, UmtxKey, std::unique_lock<rx::shared_mutex>>
|
||||
getUmtxChainIndexed(int i, Thread *t, uint32_t flags, void *ptr);
|
||||
|
||||
// Internal Umtx: Wait/Cv/Sem
|
||||
|
|
@ -191,44 +192,44 @@ public:
|
|||
return getUmtxChainIndexed(1, t, flags, ptr);
|
||||
}
|
||||
|
||||
Ref<EventEmitter> deviceEventEmitter;
|
||||
Ref<RcBase> shmDevice;
|
||||
Ref<RcBase> dmemDevice;
|
||||
Ref<RcBase> blockpoolDevice;
|
||||
Ref<RcBase> gpuDevice;
|
||||
Ref<RcBase> dceDevice;
|
||||
shared_mutex gpuDeviceMtx;
|
||||
rx::Ref<EventEmitter> deviceEventEmitter;
|
||||
rx::Ref<rx::RcBase> shmDevice;
|
||||
rx::Ref<rx::RcBase> dmemDevice;
|
||||
rx::Ref<rx::RcBase> blockpoolDevice;
|
||||
rx::Ref<rx::RcBase> gpuDevice;
|
||||
rx::Ref<rx::RcBase> dceDevice;
|
||||
rx::shared_mutex gpuDeviceMtx;
|
||||
uint sdkVersion{};
|
||||
uint fwSdkVersion{};
|
||||
uint safeMode{};
|
||||
utils::RcIdMap<RcBase, sint, 4097, 1> ipmiMap;
|
||||
RcIdMap<RcAppInfo> appInfos;
|
||||
RcIdMap<Budget, sint, 4097, 1> budgets;
|
||||
Ref<Budget> processTypeBudgets[4];
|
||||
rx::RcIdMap<rx::RcBase, sint, 4097, 1> ipmiMap;
|
||||
rx::RcIdMap<RcAppInfo> appInfos;
|
||||
rx::RcIdMap<Budget, sint, 4097, 1> budgets;
|
||||
rx::Ref<Budget> processTypeBudgets[4];
|
||||
|
||||
shared_mutex regMgrMtx;
|
||||
rx::shared_mutex regMgrMtx;
|
||||
kmap<std::uint32_t, std::uint32_t> regMgrInt;
|
||||
std::vector<std::tuple<std::uint8_t *, size_t>> dialogs{};
|
||||
|
||||
FwType fwType = FwType::Unknown;
|
||||
bool isDevKit = false;
|
||||
|
||||
Ref<Budget> createProcessTypeBudget(Budget::ProcessType processType,
|
||||
std::string_view name,
|
||||
std::span<const BudgetInfo> items) {
|
||||
rx::Ref<Budget> createProcessTypeBudget(Budget::ProcessType processType,
|
||||
std::string_view name,
|
||||
std::span<const BudgetInfo> items) {
|
||||
auto budget = orbis::knew<orbis::Budget>(name, processType, items);
|
||||
processTypeBudgets[static_cast<int>(processType)] =
|
||||
orbis::knew<orbis::Budget>(name, processType, items);
|
||||
return budget;
|
||||
}
|
||||
|
||||
Ref<Budget> getProcessTypeBudget(Budget::ProcessType processType) {
|
||||
rx::Ref<Budget> getProcessTypeBudget(Budget::ProcessType processType) {
|
||||
return processTypeBudgets[static_cast<int>(processType)];
|
||||
}
|
||||
|
||||
private:
|
||||
shared_mutex m_heap_mtx;
|
||||
shared_mutex m_heap_map_mtx;
|
||||
rx::shared_mutex m_heap_mtx;
|
||||
rx::shared_mutex m_heap_map_mtx;
|
||||
void *m_heap_next = this + 1;
|
||||
|
||||
utils::kmultimap<std::size_t, void *> m_free_heap;
|
||||
|
|
@ -238,21 +239,21 @@ private:
|
|||
|
||||
std::atomic<long> m_tsc_freq{0};
|
||||
|
||||
shared_mutex m_thread_id_mtx;
|
||||
OwningIdMap<char, long, 256, 0> m_thread_id_map;
|
||||
mutable shared_mutex m_proc_mtx;
|
||||
utils::LinkedNode<Process> *m_processes = nullptr;
|
||||
rx::shared_mutex m_thread_id_mtx;
|
||||
rx::OwningIdMap<char, long, 256, 0> m_thread_id_map;
|
||||
mutable rx::shared_mutex m_proc_mtx;
|
||||
rx::LinkedNode<Process> *m_processes = nullptr;
|
||||
|
||||
shared_mutex m_evf_mtx;
|
||||
utils::kmap<utils::kstring, Ref<EventFlag>> m_event_flags;
|
||||
rx::shared_mutex m_evf_mtx;
|
||||
utils::kmap<utils::kstring, rx::Ref<EventFlag>> m_event_flags;
|
||||
|
||||
shared_mutex m_sem_mtx;
|
||||
utils::kmap<utils::kstring, Ref<Semaphore>> m_semaphores;
|
||||
rx::shared_mutex m_sem_mtx;
|
||||
utils::kmap<utils::kstring, rx::Ref<Semaphore>> m_semaphores;
|
||||
|
||||
shared_mutex mIpmiServerMtx;
|
||||
utils::kmap<utils::kstring, Ref<IpmiServer>> mIpmiServers;
|
||||
rx::shared_mutex mIpmiServerMtx;
|
||||
utils::kmap<utils::kstring, rx::Ref<IpmiServer>> mIpmiServers;
|
||||
|
||||
shared_mutex m_kenv_mtx;
|
||||
rx::shared_mutex m_kenv_mtx;
|
||||
utils::kmap<utils::kstring, char[128]> m_kenv; // max size: 127 + '\0'
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
#include "file.hpp"
|
||||
#include "note.hpp"
|
||||
#include "utils/SharedCV.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include <list>
|
||||
|
||||
namespace orbis {
|
||||
struct KQueue : orbis::File {
|
||||
shared_cv cv;
|
||||
rx::shared_cv cv;
|
||||
kstring name;
|
||||
kvector<KEvent> triggeredEvents;
|
||||
std::list<KNote, kallocator<KNote>> notes;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include "thread/Thread.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include <atomic>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -56,7 +56,7 @@ struct EventFlag final {
|
|||
}
|
||||
};
|
||||
|
||||
utils::shared_mutex queueMtx;
|
||||
rx::shared_mutex queueMtx;
|
||||
utils::kvector<WaitingThread> waitingThreads;
|
||||
|
||||
enum class NotifyType { Set, Cancel, Destroy };
|
||||
|
|
@ -80,7 +80,7 @@ struct EventFlag final {
|
|||
std::size_t set(std::uint64_t bits) { return notify(NotifyType::Set, bits); }
|
||||
|
||||
void clear(std::uint64_t bits) {
|
||||
writer_lock lock(queueMtx);
|
||||
rx::writer_lock lock(queueMtx);
|
||||
value.fetch_and(bits, std::memory_order::relaxed);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
#include "KernelAllocator.hpp"
|
||||
#include "error/ErrorCode.hpp"
|
||||
#include "note.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include "stat.hpp"
|
||||
#include "utils/Rc.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -73,11 +73,11 @@ struct FileOps {
|
|||
Thread *thread) = nullptr;
|
||||
};
|
||||
|
||||
struct File : RcBase {
|
||||
shared_mutex mtx;
|
||||
Ref<EventEmitter> event;
|
||||
struct File : rx::RcBase {
|
||||
rx::shared_mutex mtx;
|
||||
rx::Ref<EventEmitter> event;
|
||||
const FileOps *ops = nullptr;
|
||||
Ref<RcBase> device;
|
||||
rx::Ref<RcBase> device;
|
||||
std::uint64_t nextOff = 0;
|
||||
int flags = 0;
|
||||
int mode = 0;
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
#include "KernelAllocator.hpp"
|
||||
#include "evf.hpp"
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/utils/SharedCV.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <list>
|
||||
#include <optional>
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ struct IpmiSession;
|
|||
struct IpmiClient;
|
||||
struct Thread;
|
||||
|
||||
struct IpmiServer : RcBase {
|
||||
struct IpmiServer : rx::RcBase {
|
||||
struct IpmiPacketInfo {
|
||||
ulong inputSize;
|
||||
uint type;
|
||||
|
|
@ -27,12 +27,12 @@ struct IpmiServer : RcBase {
|
|||
struct Packet {
|
||||
IpmiPacketInfo info;
|
||||
lwpid_t clientTid;
|
||||
Ref<IpmiSession> session;
|
||||
rx::Ref<IpmiSession> session;
|
||||
kvector<std::byte> message;
|
||||
};
|
||||
|
||||
struct ConnectionRequest {
|
||||
Ref<IpmiClient> client;
|
||||
rx::Ref<IpmiClient> client;
|
||||
slong clientTid{};
|
||||
slong clientPid{};
|
||||
slong serverTid{};
|
||||
|
|
@ -43,8 +43,8 @@ struct IpmiServer : RcBase {
|
|||
ptr<void> serverImpl;
|
||||
ptr<void> eventHandler;
|
||||
ptr<void> userData;
|
||||
shared_mutex mutex;
|
||||
shared_cv receiveCv;
|
||||
rx::shared_mutex mutex;
|
||||
rx::shared_cv receiveCv;
|
||||
sint pid;
|
||||
kdeque<Packet> packets;
|
||||
std::list<ConnectionRequest, kallocator<ConnectionRequest>>
|
||||
|
|
@ -53,9 +53,9 @@ struct IpmiServer : RcBase {
|
|||
explicit IpmiServer(kstring name) : name(std::move(name)) {}
|
||||
};
|
||||
|
||||
struct IpmiClient : RcBase {
|
||||
struct IpmiClient : rx::RcBase {
|
||||
struct MessageQueue {
|
||||
shared_cv messageCv;
|
||||
rx::shared_cv messageCv;
|
||||
kdeque<kvector<std::byte>> messages;
|
||||
};
|
||||
|
||||
|
|
@ -68,11 +68,11 @@ struct IpmiClient : RcBase {
|
|||
kstring name;
|
||||
ptr<void> clientImpl;
|
||||
ptr<void> userData;
|
||||
Ref<IpmiSession> session;
|
||||
shared_mutex mutex;
|
||||
shared_cv sessionCv;
|
||||
shared_cv asyncResponseCv;
|
||||
shared_cv connectCv;
|
||||
rx::Ref<IpmiSession> session;
|
||||
rx::shared_mutex mutex;
|
||||
rx::shared_cv sessionCv;
|
||||
rx::shared_cv asyncResponseCv;
|
||||
rx::shared_cv connectCv;
|
||||
std::optional<sint> connectionStatus{};
|
||||
Process *process;
|
||||
kdeque<MessageQueue> messageQueues;
|
||||
|
|
@ -82,7 +82,7 @@ struct IpmiClient : RcBase {
|
|||
explicit IpmiClient(kstring name) : name(std::move(name)) {}
|
||||
};
|
||||
|
||||
struct IpmiSession : RcBase {
|
||||
struct IpmiSession : rx::RcBase {
|
||||
struct SyncResponse {
|
||||
sint errorCode;
|
||||
std::uint32_t callerTid;
|
||||
|
|
@ -91,10 +91,10 @@ struct IpmiSession : RcBase {
|
|||
|
||||
ptr<void> sessionImpl;
|
||||
ptr<void> userData;
|
||||
Ref<IpmiClient> client;
|
||||
Ref<IpmiServer> server;
|
||||
shared_mutex mutex;
|
||||
shared_cv responseCv;
|
||||
rx::Ref<IpmiClient> client;
|
||||
rx::Ref<IpmiServer> server;
|
||||
rx::shared_mutex mutex;
|
||||
rx::shared_cv responseCv;
|
||||
kdeque<SyncResponse> syncResponses;
|
||||
uint expectedOutput{0};
|
||||
};
|
||||
|
|
@ -185,12 +185,12 @@ static_assert(sizeof(IpmiClientConnectParams) == 0x20);
|
|||
|
||||
ErrorCode ipmiCreateClient(Process *proc, void *clientImpl, const char *name,
|
||||
const IpmiCreateClientConfig &config,
|
||||
Ref<IpmiClient> &result);
|
||||
rx::Ref<IpmiClient> &result);
|
||||
ErrorCode ipmiCreateServer(Process *proc, void *serverImpl, const char *name,
|
||||
const IpmiCreateServerConfig &config,
|
||||
Ref<IpmiServer> &result);
|
||||
rx::Ref<IpmiServer> &result);
|
||||
ErrorCode ipmiCreateSession(Thread *thread, void *sessionImpl,
|
||||
ptr<void> userData, Ref<IpmiSession> &result);
|
||||
ptr<void> userData, rx::Ref<IpmiSession> &result);
|
||||
|
||||
SysResult sysIpmiCreateClient(Thread *thread, ptr<uint> result,
|
||||
ptr<void> params, uint64_t paramsSz);
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@
|
|||
#include "ModuleSegment.hpp"
|
||||
|
||||
#include "../KernelAllocator.hpp"
|
||||
#include "../utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
|
||||
#include "orbis-config.hpp"
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace orbis {
|
||||
struct Thread;
|
||||
|
|
@ -118,16 +116,13 @@ struct Module final {
|
|||
utils::kvector<Relocation> nonPltRelocations;
|
||||
utils::kvector<ModuleNeeded> neededModules;
|
||||
utils::kvector<ModuleNeeded> neededLibraries;
|
||||
utils::kvector<utils::Ref<Module>> importedModules;
|
||||
utils::kvector<utils::Ref<Module>> namespaceModules;
|
||||
utils::kvector<rx::Ref<Module>> importedModules;
|
||||
utils::kvector<rx::Ref<Module>> namespaceModules;
|
||||
utils::kvector<utils::kstring> needed;
|
||||
|
||||
std::atomic<unsigned> references{0};
|
||||
unsigned _total_size = 0;
|
||||
|
||||
void incRef() {
|
||||
if (_total_size != sizeof(Module))
|
||||
std::abort();
|
||||
if (references.fetch_add(1, std::memory_order::relaxed) > 512) {
|
||||
assert(!"too many references");
|
||||
}
|
||||
|
|
@ -142,10 +137,11 @@ struct Module final {
|
|||
|
||||
orbis::SysResult relocate(Process *process);
|
||||
|
||||
void operator delete(void *pointer);
|
||||
|
||||
private:
|
||||
void destroy();
|
||||
};
|
||||
|
||||
utils::Ref<Module> createModule(Thread *p, std::string vfsPath,
|
||||
const char *name);
|
||||
rx::Ref<Module> createModule(Thread *p, std::string vfsPath, const char *name);
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <limits>
|
||||
#include <set>
|
||||
|
||||
|
|
@ -75,20 +75,20 @@ struct KEvent {
|
|||
struct EventEmitter;
|
||||
struct KQueue;
|
||||
struct KNote {
|
||||
shared_mutex mutex;
|
||||
rx::shared_mutex mutex;
|
||||
KQueue *queue;
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
KEvent event{};
|
||||
bool enabled = true;
|
||||
bool triggered = false;
|
||||
void *linked = nullptr; // TODO: use Ref<>
|
||||
kvector<Ref<EventEmitter>> emitters;
|
||||
void *linked = nullptr; // TODO: use rx::Ref<>
|
||||
kvector<rx::Ref<EventEmitter>> emitters;
|
||||
|
||||
~KNote();
|
||||
};
|
||||
|
||||
struct EventEmitter : orbis::RcBase {
|
||||
shared_mutex mutex;
|
||||
struct EventEmitter : rx::RcBase {
|
||||
rx::shared_mutex mutex;
|
||||
std::set<KNote *, std::less<>, kallocator<KNote *>> notes;
|
||||
|
||||
void emit(sshort filter, uint fflags = 0, intptr_t data = 0,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "thread/Thread.hpp"
|
||||
#include "utils/SharedCV.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include "orbis-config.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace orbis {
|
||||
enum {
|
||||
|
|
@ -22,8 +21,8 @@ struct Semaphore final {
|
|||
std::atomic<unsigned> references{0};
|
||||
std::atomic<sint> value;
|
||||
const sint maxValue;
|
||||
utils::shared_mutex mtx;
|
||||
utils::shared_cv cond;
|
||||
rx::shared_mutex mtx;
|
||||
rx::shared_cv cond;
|
||||
|
||||
Semaphore(uint attrs, sint value, sint max)
|
||||
: attrs(attrs), value(value), maxValue(max) {}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "file.hpp"
|
||||
#include "utils/Rc.hpp"
|
||||
#include "utils/SharedCV.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <utility>
|
||||
|
||||
namespace orbis {
|
||||
struct Pipe final : File {
|
||||
shared_cv cv;
|
||||
struct Pipe : File {
|
||||
rx::shared_cv cv;
|
||||
kvector<std::byte> data;
|
||||
Ref<Pipe> other;
|
||||
rx::Ref<Pipe> other;
|
||||
};
|
||||
|
||||
std::pair<Ref<Pipe>, Ref<Pipe>> createPipe();
|
||||
std::pair<rx::Ref<Pipe>, rx::Ref<Pipe>> createPipe();
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
#include "orbis/Budget.hpp"
|
||||
#include "orbis/file.hpp"
|
||||
#include "orbis/module/Module.hpp"
|
||||
#include "orbis/utils/IdMap.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "rx/IdMap.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <optional>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -59,7 +59,7 @@ struct Process final {
|
|||
sysentvec *sysent = nullptr;
|
||||
ProcessState state = ProcessState::NEW;
|
||||
Process *parentProcess = nullptr;
|
||||
shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
int vmId = -1;
|
||||
ProcessType type = ProcessType::FreeBsd;
|
||||
void (*onSysEnter)(Thread *thread, int id, uint64_t *args,
|
||||
|
|
@ -85,21 +85,21 @@ struct Process final {
|
|||
std::uint64_t nextTlsSlot = 1;
|
||||
std::uint64_t lastTlsOffset = 0;
|
||||
|
||||
utils::RcIdMap<EventFlag, sint, 4097, 1> evfMap;
|
||||
utils::RcIdMap<Semaphore, sint, 4097, 1> semMap;
|
||||
utils::RcIdMap<Module, ModuleHandle> modulesMap;
|
||||
utils::OwningIdMap<Thread, lwpid_t> threadsMap;
|
||||
utils::RcIdMap<orbis::File, sint> fileDescriptors;
|
||||
rx::RcIdMap<EventFlag, sint, 4097, 1> evfMap;
|
||||
rx::RcIdMap<Semaphore, sint, 4097, 1> semMap;
|
||||
rx::RcIdMap<Module, ModuleHandle> modulesMap;
|
||||
rx::OwningIdMap<Thread, lwpid_t> threadsMap;
|
||||
rx::RcIdMap<orbis::File, sint> fileDescriptors;
|
||||
|
||||
// Named objects for debugging
|
||||
utils::shared_mutex namedObjMutex;
|
||||
rx::shared_mutex namedObjMutex;
|
||||
utils::kmap<void *, utils::kstring> namedObjNames;
|
||||
utils::OwningIdMap<NamedObjInfo, uint, 65535, 1> namedObjIds;
|
||||
rx::OwningIdMap<NamedObjInfo, uint, 65535, 1> namedObjIds;
|
||||
|
||||
utils::kmap<std::int32_t, SigAction> sigActions;
|
||||
|
||||
// Named memory ranges for debugging
|
||||
utils::shared_mutex namedMemMutex;
|
||||
rx::shared_mutex namedMemMutex;
|
||||
utils::kmap<NamedMemoryRange, utils::kstring> namedMem;
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "../module/ModuleHandle.hpp"
|
||||
#include "../thread/types.hpp"
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
|
||||
namespace orbis {
|
||||
struct Thread;
|
||||
|
|
@ -39,21 +39,21 @@ struct ProcessOps {
|
|||
ptr<MemoryProtection> protection);
|
||||
|
||||
SysResult (*open)(Thread *thread, ptr<const char> path, sint flags, sint mode,
|
||||
Ref<File> *file);
|
||||
rx::Ref<File> *file);
|
||||
SysResult (*shm_open)(Thread *thread, const char *path, sint flags, sint mode,
|
||||
Ref<File> *file);
|
||||
rx::Ref<File> *file);
|
||||
SysResult (*unlink)(Thread *thread, ptr<const char> path);
|
||||
SysResult (*mkdir)(Thread *thread, ptr<const char> path, sint mode);
|
||||
SysResult (*rmdir)(Thread *thread, ptr<const char> path);
|
||||
SysResult (*rename)(Thread *thread, ptr<const char> from, ptr<const char> to);
|
||||
SysResult (*blockpool_open)(Thread *thread, Ref<File> *file);
|
||||
SysResult (*blockpool_open)(Thread *thread, rx::Ref<File> *file);
|
||||
SysResult (*blockpool_map)(Thread *thread, caddr_t addr, size_t len,
|
||||
sint prot, sint flags);
|
||||
SysResult (*blockpool_unmap)(Thread *thread, caddr_t addr, size_t len);
|
||||
SysResult (*socket)(Thread *thread, ptr<const char> name, sint domain,
|
||||
sint type, sint protocol, Ref<File> *file);
|
||||
sint type, sint protocol, rx::Ref<File> *file);
|
||||
SysResult (*socketpair)(Thread *thread, sint domain, sint type, sint protocol,
|
||||
Ref<File> *a, Ref<File> *b);
|
||||
rx::Ref<File> *a, rx::Ref<File> *b);
|
||||
SysResult (*shm_unlink)(Thread *thread, const char *path);
|
||||
SysResult (*dynlib_get_obj_member)(Thread *thread, ModuleHandle handle,
|
||||
uint64_t index, ptr<ptr<void>> addrp);
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "../KernelAllocator.hpp"
|
||||
#include "../ucontext.hpp"
|
||||
#include "../utils/SharedAtomic.hpp"
|
||||
#include "../utils/SharedCV.hpp"
|
||||
#include "../utils/SharedMutex.hpp"
|
||||
#include "rx/SharedAtomic.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <thread>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -17,7 +17,7 @@ struct Process;
|
|||
|
||||
static constexpr std::uint32_t kThreadSuspendFlag = 1 << 31;
|
||||
struct Thread {
|
||||
utils::shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
Process *tproc = nullptr;
|
||||
uint64_t retval[2]{};
|
||||
void *context{};
|
||||
|
|
@ -34,14 +34,14 @@ struct Thread {
|
|||
.type = 2,
|
||||
.prio = 10,
|
||||
};
|
||||
utils::shared_mutex suspend_mtx;
|
||||
utils::shared_cv suspend_cv;
|
||||
rx::shared_mutex suspend_mtx;
|
||||
rx::shared_cv suspend_cv;
|
||||
kvector<UContext> sigReturns;
|
||||
kvector<SigInfo> blockedSignals;
|
||||
kvector<SigInfo> queuedSignals;
|
||||
shared_atomic32 suspendFlags{0};
|
||||
rx::shared_atomic32 suspendFlags{0};
|
||||
|
||||
utils::shared_atomic32 interruptedMtx{0};
|
||||
rx::shared_atomic32 interruptedMtx{0};
|
||||
|
||||
std::int64_t hostTid = -1;
|
||||
lwpid_t tid = -1;
|
||||
|
|
@ -51,7 +51,7 @@ struct Thread {
|
|||
std::thread::native_handle_type nativeHandle;
|
||||
|
||||
// Used to wake up thread in sleep queue
|
||||
utils::shared_cv sync_cv;
|
||||
rx::shared_cv sync_cv;
|
||||
uint64_t evfResultPattern;
|
||||
uint64_t evfIsCancelled;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "orbis/thread/Process.hpp"
|
||||
#include "orbis/thread/ProcessOps.hpp"
|
||||
#include "orbis/utils/Logs.hpp"
|
||||
#include "utils/SharedAtomic.hpp"
|
||||
#include "rx/SharedAtomic.hpp"
|
||||
#include <bit>
|
||||
#include <chrono>
|
||||
#include <csignal>
|
||||
|
|
@ -51,7 +51,7 @@ KernelContext::KernelContext() {
|
|||
KernelContext::~KernelContext() {}
|
||||
|
||||
Process *KernelContext::createProcess(pid_t pid) {
|
||||
auto newProcess = knew<utils::LinkedNode<Process>>();
|
||||
auto newProcess = knew<rx::LinkedNode<Process>>();
|
||||
newProcess->object.context = this;
|
||||
newProcess->object.pid = pid;
|
||||
newProcess->object.state = ProcessState::NEW;
|
||||
|
|
@ -69,7 +69,7 @@ Process *KernelContext::createProcess(pid_t pid) {
|
|||
}
|
||||
|
||||
void KernelContext::deleteProcess(Process *proc) {
|
||||
auto procNode = reinterpret_cast<utils::LinkedNode<Process> *>(proc);
|
||||
auto procNode = reinterpret_cast<rx::LinkedNode<Process> *>(proc);
|
||||
|
||||
{
|
||||
std::lock_guard lock(m_proc_mtx);
|
||||
|
|
@ -283,7 +283,7 @@ void KernelContext::kfree(void *ptr, std::size_t size) {
|
|||
}
|
||||
}
|
||||
|
||||
std::tuple<UmtxChain &, UmtxKey, std::unique_lock<shared_mutex>>
|
||||
std::tuple<UmtxChain &, UmtxKey, std::unique_lock<rx::shared_mutex>>
|
||||
KernelContext::getUmtxChainIndexed(int i, Thread *t, uint32_t flags,
|
||||
void *ptr) {
|
||||
auto pid = t->tproc->pid;
|
||||
|
|
@ -406,7 +406,7 @@ bool Thread::block() {
|
|||
|
||||
scoped_unblock::scoped_unblock() {
|
||||
if (g_currentThread && g_currentThread->context) {
|
||||
g_scopedUnblock = [](bool unblock) {
|
||||
rx::g_scopedUnblock = [](bool unblock) {
|
||||
if (unblock) {
|
||||
return g_currentThread->unblock();
|
||||
}
|
||||
|
|
@ -416,5 +416,5 @@ scoped_unblock::scoped_unblock() {
|
|||
}
|
||||
}
|
||||
|
||||
scoped_unblock::~scoped_unblock() { g_scopedUnblock = nullptr; }
|
||||
scoped_unblock::~scoped_unblock() { rx::g_scopedUnblock = nullptr; }
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "evf.hpp"
|
||||
#include "error/ErrorCode.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
#include "utils/SharedCV.hpp"
|
||||
#include "rx/SharedCV.hpp"
|
||||
#include <atomic>
|
||||
|
||||
orbis::ErrorCode orbis::EventFlag::wait(Thread *thread, std::uint8_t waitMode,
|
||||
|
|
@ -99,7 +98,7 @@ orbis::ErrorCode orbis::EventFlag::wait(Thread *thread, std::uint8_t waitMode,
|
|||
orbis::ErrorCode orbis::EventFlag::tryWait(Thread *thread,
|
||||
std::uint8_t waitMode,
|
||||
std::uint64_t bitPattern) {
|
||||
writer_lock lock(queueMtx);
|
||||
rx::writer_lock lock(queueMtx);
|
||||
|
||||
if (isDeleted) {
|
||||
return ErrorCode::ACCES;
|
||||
|
|
@ -120,7 +119,7 @@ orbis::ErrorCode orbis::EventFlag::tryWait(Thread *thread,
|
|||
}
|
||||
|
||||
std::size_t orbis::EventFlag::notify(NotifyType type, std::uint64_t bits) {
|
||||
writer_lock lock(queueMtx);
|
||||
rx::writer_lock lock(queueMtx);
|
||||
auto patValue = value.load(std::memory_order::relaxed);
|
||||
|
||||
if (type == NotifyType::Destroy) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
orbis::ErrorCode orbis::ipmiCreateClient(Process *proc, void *clientImpl,
|
||||
const char *name,
|
||||
const IpmiCreateClientConfig &config,
|
||||
Ref<IpmiClient> &result) {
|
||||
rx::Ref<IpmiClient> &result) {
|
||||
auto client = knew<IpmiClient>(name);
|
||||
if (client == nullptr) {
|
||||
return ErrorCode::NOMEM;
|
||||
|
|
@ -29,7 +29,7 @@ orbis::ErrorCode orbis::ipmiCreateClient(Process *proc, void *clientImpl,
|
|||
orbis::ErrorCode orbis::ipmiCreateServer(Process *proc, void *serverImpl,
|
||||
const char *name,
|
||||
const IpmiCreateServerConfig &config,
|
||||
Ref<IpmiServer> &result) {
|
||||
rx::Ref<IpmiServer> &result) {
|
||||
auto [server, errorCode] = g_context.createIpmiServer(name);
|
||||
ORBIS_RET_ON_ERROR(errorCode);
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ orbis::ErrorCode orbis::ipmiCreateServer(Process *proc, void *serverImpl,
|
|||
|
||||
orbis::ErrorCode orbis::ipmiCreateSession(Thread *thread, void *sessionImpl,
|
||||
ptr<void> userData,
|
||||
Ref<IpmiSession> &result) {
|
||||
rx::Ref<IpmiSession> &result) {
|
||||
std::unique_lock ipmiMapLock(g_context.ipmiMap.mutex);
|
||||
|
||||
for (auto [kid, obj] : g_context.ipmiMap) {
|
||||
|
|
@ -96,7 +96,7 @@ orbis::SysResult orbis::sysIpmiCreateClient(Thread *thread, ptr<uint> result,
|
|||
IpmiCreateClientParams _params;
|
||||
IpmiCreateClientConfig _config;
|
||||
char _name[25];
|
||||
Ref<IpmiClient> client;
|
||||
rx::Ref<IpmiClient> client;
|
||||
|
||||
ORBIS_RET_ON_ERROR(uread(_params, ptr<IpmiCreateClientParams>(params)));
|
||||
ORBIS_RET_ON_ERROR(uread(_config, _params.config));
|
||||
|
|
@ -132,7 +132,7 @@ orbis::SysResult orbis::sysIpmiCreateServer(Thread *thread, ptr<uint> result,
|
|||
IpmiCreateServerParams _params;
|
||||
IpmiCreateServerConfig _config;
|
||||
char _name[25];
|
||||
Ref<IpmiServer> server;
|
||||
rx::Ref<IpmiServer> server;
|
||||
|
||||
ORBIS_RET_ON_ERROR(uread(_params, ptr<IpmiCreateServerParams>(params)));
|
||||
ORBIS_RET_ON_ERROR(uread(_config, _params.config));
|
||||
|
|
@ -172,7 +172,7 @@ orbis::SysResult orbis::sysIpmiCreateSession(Thread *thread, ptr<uint> result,
|
|||
|
||||
IpmiCreateSessionParams _params;
|
||||
IpmiSessionUserData _userData;
|
||||
Ref<IpmiSession> session;
|
||||
rx::Ref<IpmiSession> session;
|
||||
|
||||
ORBIS_RET_ON_ERROR(uread(_params, ptr<IpmiCreateSessionParams>(params)));
|
||||
ORBIS_RET_ON_ERROR(uread(_userData, _params.userData));
|
||||
|
|
@ -306,7 +306,7 @@ orbis::SysResult orbis::sysIpmiSendConnectResult(Thread *thread,
|
|||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
Ref<IpmiClient> client;
|
||||
rx::Ref<IpmiClient> client;
|
||||
if (auto result = ipmiObject.cast<IpmiSession>()) {
|
||||
client = result->client;
|
||||
} else if (auto result = ipmiObject.cast<IpmiClient>()) {
|
||||
|
|
|
|||
|
|
@ -409,6 +409,10 @@ orbis::SysResult orbis::Module::relocate(Process *process) {
|
|||
return {};
|
||||
}
|
||||
|
||||
void orbis::Module::operator delete(void *pointer) {
|
||||
kfree(pointer, sizeof(orbis::Module));
|
||||
}
|
||||
|
||||
void orbis::Module::destroy() {
|
||||
std::lock_guard lock(proc->mtx);
|
||||
proc->modulesMap.close(id);
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@ static orbis::FileOps pipe_ops = {
|
|||
.write = pipe_write,
|
||||
};
|
||||
|
||||
std::pair<orbis::Ref<orbis::Pipe>, orbis::Ref<orbis::Pipe>>
|
||||
orbis::createPipe() {
|
||||
std::pair<rx::Ref<orbis::Pipe>, rx::Ref<orbis::Pipe>> orbis::createPipe() {
|
||||
auto a = knew<Pipe>();
|
||||
auto b = knew<Pipe>();
|
||||
a->event = knew<EventEmitter>();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ orbis::SysResult orbis::sys_closefrom(Thread *thread, sint lowfd) {
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ static SysResult keventChange(KQueue *kq, KEvent &change, Thread *thread) {
|
|||
nodeIt = kq->notes.end();
|
||||
}
|
||||
|
||||
std::unique_lock<shared_mutex> noteLock;
|
||||
std::unique_lock<rx::shared_mutex> noteLock;
|
||||
if (change.flags & kEvAdd) {
|
||||
if (nodeIt == kq->notes.end()) {
|
||||
auto ¬e = kq->notes.emplace_front();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
orbis::SysResult orbis::sys_read(Thread *thread, sint fd, ptr<void> buf,
|
||||
size_t nbyte) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ orbis::SysResult orbis::sys_read(Thread *thread, sint fd, ptr<void> buf,
|
|||
orbis::SysResult orbis::sys_pread(Thread *thread, sint fd, ptr<void> buf,
|
||||
size_t nbyte, off_t offset) {
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, fd, buf, nbyte, offset);
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ orbis::SysResult orbis::sys_freebsd6_pread(Thread *thread, sint fd,
|
|||
}
|
||||
orbis::SysResult orbis::sys_readv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ orbis::SysResult orbis::sys_readv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
}
|
||||
orbis::SysResult orbis::sys_preadv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt, off_t offset) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ orbis::SysResult orbis::sys_preadv(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
}
|
||||
orbis::SysResult orbis::sys_write(Thread *thread, sint fd, ptr<const void> buf,
|
||||
size_t nbyte) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -185,7 +185,7 @@ orbis::SysResult orbis::sys_write(Thread *thread, sint fd, ptr<const void> buf,
|
|||
}
|
||||
orbis::SysResult orbis::sys_pwrite(Thread *thread, sint fd, ptr<const void> buf,
|
||||
size_t nbyte, off_t offset) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -222,7 +222,7 @@ orbis::SysResult orbis::sys_freebsd6_pwrite(Thread *thread, sint fd,
|
|||
}
|
||||
orbis::SysResult orbis::sys_writev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ orbis::SysResult orbis::sys_writev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
}
|
||||
orbis::SysResult orbis::sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
||||
uint iovcnt, off_t offset) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -285,7 +285,7 @@ orbis::SysResult orbis::sys_pwritev(Thread *thread, sint fd, ptr<IoVec> iovp,
|
|||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_ftruncate(Thread *thread, sint fd, off_t length) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -426,7 +426,7 @@ orbis::SysResult orbis::sys_ioctl(Thread *thread, sint fd, ulong com,
|
|||
caddr_t data) {
|
||||
auto str = ioctlToString(com);
|
||||
// ORBIS_LOG_WARNING(__FUNCTION__, fd, com, str);
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ orbis::SysResult orbis::sys_socketex(Thread *thread, ptr<const char> name,
|
|||
sint domain, sint type, sint protocol) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, name, domain, type, protocol);
|
||||
if (auto socket = thread->tproc->ops->socket) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = socket(thread, name, domain, type, protocol, &file);
|
||||
|
||||
if (result.isError()) {
|
||||
|
|
@ -250,7 +250,7 @@ orbis::SysResult orbis::sys_evf_create(Thread *thread, ptr<const char[32]> name,
|
|||
}
|
||||
orbis::SysResult orbis::sys_evf_delete(Thread *thread, sint id) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, id);
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
rx::Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ orbis::SysResult orbis::sys_evf_wait(Thread *thread, sint id,
|
|||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
rx::Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::SRCH;
|
||||
|
|
@ -336,7 +336,7 @@ orbis::SysResult orbis::sys_evf_trywait(Thread *thread, sint id,
|
|||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
rx::Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::SRCH;
|
||||
|
|
@ -356,7 +356,7 @@ orbis::SysResult orbis::sys_evf_trywait(Thread *thread, sint id,
|
|||
return result;
|
||||
}
|
||||
orbis::SysResult orbis::sys_evf_set(Thread *thread, sint id, uint64_t value) {
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
rx::Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::SRCH;
|
||||
|
|
@ -367,7 +367,7 @@ orbis::SysResult orbis::sys_evf_set(Thread *thread, sint id, uint64_t value) {
|
|||
return {};
|
||||
}
|
||||
orbis::SysResult orbis::sys_evf_clear(Thread *thread, sint id, uint64_t value) {
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
rx::Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::SRCH;
|
||||
|
|
@ -379,7 +379,7 @@ orbis::SysResult orbis::sys_evf_clear(Thread *thread, sint id, uint64_t value) {
|
|||
}
|
||||
orbis::SysResult orbis::sys_evf_cancel(Thread *thread, sint id, uint64_t value,
|
||||
ptr<sint> pNumWaitThreads) {
|
||||
Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
rx::Ref<EventFlag> evf = thread->tproc->evfMap.get(id);
|
||||
|
||||
if (evf == nullptr) {
|
||||
return ErrorCode::SRCH;
|
||||
|
|
@ -522,7 +522,7 @@ orbis::SysResult orbis::sys_osem_create(Thread *thread,
|
|||
}
|
||||
orbis::SysResult orbis::sys_osem_delete(Thread *thread, sint id) {
|
||||
ORBIS_LOG_TRACE(__FUNCTION__, id);
|
||||
Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
rx::Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
if (sem == nullptr) {
|
||||
return ErrorCode::NOENT;
|
||||
}
|
||||
|
|
@ -558,7 +558,7 @@ orbis::SysResult orbis::sys_osem_close(Thread *thread, sint id) {
|
|||
orbis::SysResult orbis::sys_osem_wait(Thread *thread, sint id, sint need,
|
||||
ptr<uint> pTimeout) {
|
||||
ORBIS_LOG_TRACE(__FUNCTION__, thread, id, need, pTimeout);
|
||||
Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
rx::Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
if (sem == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -624,7 +624,7 @@ orbis::SysResult orbis::sys_osem_wait(Thread *thread, sint id, sint need,
|
|||
}
|
||||
orbis::SysResult orbis::sys_osem_trywait(Thread *thread, sint id, sint need) {
|
||||
ORBIS_LOG_TRACE(__FUNCTION__, thread, id, need);
|
||||
Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
rx::Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
if (sem == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -641,7 +641,7 @@ orbis::SysResult orbis::sys_osem_trywait(Thread *thread, sint id, sint need) {
|
|||
}
|
||||
orbis::SysResult orbis::sys_osem_post(Thread *thread, sint id, sint count) {
|
||||
ORBIS_LOG_TRACE(__FUNCTION__, thread, id, count);
|
||||
Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
rx::Ref<Semaphore> sem = thread->tproc->semMap.get(id);
|
||||
if (sem == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -802,7 +802,7 @@ orbis::SysResult orbis::sys_budget_create(Thread *thread, ptr<char> name,
|
|||
return ErrorCode::PERM;
|
||||
}
|
||||
|
||||
orbis::Ref budget =
|
||||
rx::Ref budget =
|
||||
orbis::knew<Budget>(_name, processType, std::span(_resources, count));
|
||||
auto id = g_context.budgets.insert(budget);
|
||||
thread->retval[0] = id;
|
||||
|
|
@ -835,7 +835,7 @@ orbis::SysResult orbis::sys_budget_get(Thread *thread, sint id,
|
|||
return ErrorCode::INVAL;
|
||||
}
|
||||
|
||||
Ref<Budget> budget;
|
||||
rx::Ref<Budget> budget;
|
||||
bool isProcessTypeBudget = id < 0;
|
||||
if (isProcessTypeBudget) {
|
||||
id = -2 - id;
|
||||
|
|
@ -1134,7 +1134,7 @@ orbis::SysResult orbis::sys_mdbg_service(Thread *thread, uint32_t op,
|
|||
|
||||
case 7: {
|
||||
if (auto open = thread->tproc->ops->open) {
|
||||
Ref<File> console;
|
||||
rx::Ref<File> console;
|
||||
auto result = open(thread, "/dev/console", 0, 0, &console);
|
||||
if (!result.value() && console && console->ops->write) {
|
||||
IoVec vec{.base = (char *)arg0, .len = std::strlen((char *)arg0)};
|
||||
|
|
@ -1680,7 +1680,7 @@ orbis::SysResult orbis::sys_budget_get_ptype_of_budget(Thread *thread,
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::Ref<Budget> budget = g_context.budgets.get(budgetId);
|
||||
rx::Ref<Budget> budget = g_context.budgets.get(budgetId);
|
||||
|
||||
if (!budget) {
|
||||
return ErrorCode::SRCH;
|
||||
|
|
@ -1698,7 +1698,7 @@ orbis::SysResult orbis::sys_process_terminate(Thread *thread /* TODO */) {
|
|||
}
|
||||
orbis::SysResult orbis::sys_blockpool_open(Thread *thread) {
|
||||
if (auto blockpool_open = thread->tproc->ops->blockpool_open) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = blockpool_open(thread, &file);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
|
|
@ -1874,7 +1874,7 @@ orbis::SysResult orbis::sys_begin_app_mount(Thread *thread,
|
|||
_info.appInfo.unk7, _info.appInfo.unk8, _info.appInfo.unk9,
|
||||
_info.appInfo.unk10);
|
||||
|
||||
orbis::Ref appInfo = orbis::knew<RcAppInfo>();
|
||||
rx::Ref appInfo = orbis::knew<RcAppInfo>();
|
||||
|
||||
AppInfoEx *appInfoData = appInfo.get();
|
||||
auto handle = g_context.appInfos.insert(appInfo);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ orbis::SysResult orbis::sys_socket(Thread *thread, sint domain, sint type,
|
|||
sint protocol) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, domain, type, protocol);
|
||||
if (auto socket = thread->tproc->ops->socket) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = socket(thread, nullptr, domain, type, protocol, &file);
|
||||
|
||||
if (result.isError()) {
|
||||
|
|
@ -89,8 +89,8 @@ orbis::SysResult orbis::sys_socketpair(Thread *thread, sint domain, sint type,
|
|||
sint protocol, ptr<sint> rsv) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, domain, type, protocol, rsv);
|
||||
if (auto socketpair = thread->tproc->ops->socketpair) {
|
||||
Ref<File> a;
|
||||
Ref<File> b;
|
||||
rx::Ref<File> a;
|
||||
rx::Ref<File> b;
|
||||
auto result = socketpair(thread, domain, type, protocol, &a, &b);
|
||||
|
||||
if (result.isError()) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ orbis::SysResult orbis::sys_shm_open(Thread *thread, ptr<const char> path,
|
|||
}
|
||||
|
||||
if (auto shm_open = thread->tproc->ops->shm_open) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = shm_open(thread, path, flags, mode, &file);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ orbis::SysResult orbis::sys_chroot(Thread *thread, ptr<char> path) {
|
|||
orbis::SysResult orbis::sys_open(Thread *thread, ptr<const char> path,
|
||||
sint flags, sint mode) {
|
||||
if (auto open = thread->tproc->ops->open) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = open(thread, path, flags, mode, &file);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
|
|
@ -114,7 +114,7 @@ orbis::SysResult orbis::sys_openat(Thread *thread, sint fd, ptr<char> path,
|
|||
return sys_open(thread, (cwd + "/" + path).c_str(), flag, mode);
|
||||
}
|
||||
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ orbis::SysResult orbis::sys_unlinkat(Thread *thread, sint fd, ptr<char> path,
|
|||
}
|
||||
orbis::SysResult orbis::sys_lseek(Thread *thread, sint fd, off_t offset,
|
||||
sint whence) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ orbis::SysResult orbis::sys_freebsd6_lseek(Thread *thread, sint fd, sint,
|
|||
}
|
||||
orbis::SysResult orbis::sys_access(Thread *thread, ptr<char> path, sint flags) {
|
||||
if (auto open = thread->tproc->ops->open) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
return open(thread, path, flags, 0, &file);
|
||||
}
|
||||
|
||||
|
|
@ -231,7 +231,7 @@ orbis::SysResult orbis::sys_eaccess(Thread *thread, ptr<char> path,
|
|||
}
|
||||
orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, path);
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = thread->tproc->ops->open(thread, path, 0, 0, &file);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
|
|
@ -289,7 +289,7 @@ orbis::SysResult orbis::sys_readlink(Thread *thread, ptr<char> path,
|
|||
return ErrorCode::NAMETOOLONG;
|
||||
}
|
||||
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
if (auto error = thread->tproc->ops->open(thread, path, 0, 0, &file);
|
||||
error.value()) {
|
||||
return error;
|
||||
|
|
@ -362,7 +362,7 @@ orbis::SysResult orbis::sys_futimes(Thread *thread, sint fd,
|
|||
}
|
||||
orbis::SysResult orbis::sys_truncate(Thread *thread, ptr<char> path,
|
||||
off_t length) {
|
||||
Ref<File> file;
|
||||
rx::Ref<File> file;
|
||||
auto result = thread->tproc->ops->open(thread, path, 2, 0, &file);
|
||||
if (result.isError()) {
|
||||
return result;
|
||||
|
|
@ -400,7 +400,7 @@ orbis::SysResult orbis::sys_mkdir(Thread *thread, ptr<char> path, sint mode) {
|
|||
}
|
||||
orbis::SysResult orbis::sys_mkdirat(Thread *thread, sint fd, ptr<char> path,
|
||||
mode_t mode) {
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
@ -425,7 +425,7 @@ orbis::SysResult orbis::sys_getdirentries(Thread *thread, sint fd,
|
|||
ptr<char> buf, uint count,
|
||||
ptr<slong> basep) {
|
||||
ORBIS_LOG_WARNING(__FUNCTION__, fd, (void *)buf, count, basep);
|
||||
Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
rx::Ref<File> file = thread->tproc->fileDescriptors.get(fd);
|
||||
if (file == nullptr) {
|
||||
return ErrorCode::BADF;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1612,7 +1612,7 @@ enum class strkey_flag : u32
|
|||
// set_other, // writing is allowed for other types of PARAM.SFO (not
|
||||
// possible)
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = get_other,
|
||||
};
|
||||
|
||||
struct string_key_info
|
||||
|
|
@ -1620,7 +1620,7 @@ struct string_key_info
|
|||
public:
|
||||
string_key_info() = default;
|
||||
string_key_info(std::string_view _name, u32 _max_size,
|
||||
bs_t<strkey_flag> _flags)
|
||||
rx::EnumBitSet<strkey_flag> _flags)
|
||||
: name(_name), max_size(_max_size), flags(_flags) {}
|
||||
|
||||
std::string_view name;
|
||||
|
|
@ -1653,7 +1653,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
bs_t<strkey_flag> flags{}; // allowed operations
|
||||
rx::EnumBitSet<strkey_flag> flags{}; // allowed operations
|
||||
};
|
||||
|
||||
static string_key_info get_param_string_key(s32 id)
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ target_link_libraries(rpcs3_core PUBLIC
|
|||
3rdparty::pugixml
|
||||
3rdparty::yaml-cpp
|
||||
3rdparty::zstd
|
||||
3rdparty::llvm
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "Loader/PSF.h"
|
||||
#include "util/StrFmt.h"
|
||||
#include "util/endian.hpp"
|
||||
#include "util/types.hpp"
|
||||
#include "util/File.h"
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
#include "sha256.h"
|
||||
#include "key_vault.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include "util/StrFmt.h"
|
||||
#include "util/StrUtil.h"
|
||||
#include "util/File.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
|
|||
case cpu_flag::dbg_global_pause: return "G-PAUSE";
|
||||
case cpu_flag::dbg_pause: return "PAUSE";
|
||||
case cpu_flag::dbg_step: return "STEP";
|
||||
case cpu_flag::__bitset_enum_max: break;
|
||||
case cpu_flag::bitset_last: break;
|
||||
}
|
||||
|
||||
return unknown;
|
||||
|
|
@ -72,7 +72,7 @@ void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg)
|
|||
}
|
||||
|
||||
template <>
|
||||
void fmt_class_string<bs_t<cpu_flag>>::format(std::string& out, u64 arg)
|
||||
void fmt_class_string<rx::EnumBitSet<cpu_flag>>::format(std::string& out, u64 arg)
|
||||
{
|
||||
format_bitset(out, arg, "[", "|", "]", &fmt_class_string<cpu_flag>::format);
|
||||
}
|
||||
|
|
@ -799,7 +799,7 @@ cpu_thread::cpu_thread(u32 id)
|
|||
}
|
||||
}
|
||||
|
||||
void cpu_thread::cpu_wait(bs_t<cpu_flag> old)
|
||||
void cpu_thread::cpu_wait(rx::EnumBitSet<cpu_flag> old)
|
||||
{
|
||||
state.wait(old);
|
||||
}
|
||||
|
|
@ -816,8 +816,8 @@ bool cpu_thread::check_state() noexcept
|
|||
while (true)
|
||||
{
|
||||
// Process all flags in a single atomic op
|
||||
bs_t<cpu_flag> state1;
|
||||
auto state0 = state.fetch_op([&](bs_t<cpu_flag>& flags)
|
||||
rx::EnumBitSet<cpu_flag> state1;
|
||||
auto state0 = state.fetch_op([&](rx::EnumBitSet<cpu_flag>& flags)
|
||||
{
|
||||
bool store = false;
|
||||
|
||||
|
|
@ -1168,9 +1168,9 @@ cpu_thread& cpu_thread::operator=(thread_state)
|
|||
return *this;
|
||||
}
|
||||
|
||||
void cpu_thread::add_remove_flags(bs_t<cpu_flag> to_add, bs_t<cpu_flag> to_remove)
|
||||
void cpu_thread::add_remove_flags(rx::EnumBitSet<cpu_flag> to_add, rx::EnumBitSet<cpu_flag> to_remove)
|
||||
{
|
||||
bs_t<cpu_flag> result{};
|
||||
rx::EnumBitSet<cpu_flag> result{};
|
||||
|
||||
if (!to_remove)
|
||||
{
|
||||
|
|
@ -1183,7 +1183,7 @@ void cpu_thread::add_remove_flags(bs_t<cpu_flag> to_add, bs_t<cpu_flag> to_remov
|
|||
}
|
||||
else
|
||||
{
|
||||
result = state.atomic_op([&](bs_t<cpu_flag>& v)
|
||||
result = state.atomic_op([&](rx::EnumBitSet<cpu_flag>& v)
|
||||
{
|
||||
v += to_add;
|
||||
v -= to_remove;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "util/Thread.h"
|
||||
#include "util/bit_set.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "util/atomic_bit_set.h"
|
||||
|
||||
#include <vector>
|
||||
#include <any>
|
||||
|
|
@ -33,17 +34,17 @@ enum class cpu_flag : u32
|
|||
dbg_pause, // Thread paused
|
||||
dbg_step, // Thread forced to pause after one step (one instruction, etc)
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = dbg_step,
|
||||
};
|
||||
|
||||
// Test stopped state
|
||||
constexpr bool is_stopped(bs_t<cpu_flag> state)
|
||||
constexpr bool is_stopped(rx::EnumBitSet<cpu_flag> state)
|
||||
{
|
||||
return !!(state & (cpu_flag::stop + cpu_flag::exit + cpu_flag::again));
|
||||
}
|
||||
|
||||
// Test paused state
|
||||
constexpr bool is_paused(bs_t<cpu_flag> state)
|
||||
constexpr bool is_paused(rx::EnumBitSet<cpu_flag> state)
|
||||
{
|
||||
return !!(state & (cpu_flag::suspend + cpu_flag::dbg_global_pause + cpu_flag::dbg_pause)) && !is_stopped(state);
|
||||
}
|
||||
|
|
@ -87,12 +88,12 @@ public:
|
|||
}
|
||||
|
||||
// Wrappers
|
||||
static constexpr bool is_stopped(bs_t<cpu_flag> s)
|
||||
static constexpr bool is_stopped(rx::EnumBitSet<cpu_flag> s)
|
||||
{
|
||||
return ::is_stopped(s);
|
||||
}
|
||||
|
||||
static constexpr bool is_paused(bs_t<cpu_flag> s)
|
||||
static constexpr bool is_paused(rx::EnumBitSet<cpu_flag> s)
|
||||
{
|
||||
return ::is_paused(s);
|
||||
}
|
||||
|
|
@ -155,7 +156,7 @@ public:
|
|||
cpu_thread& operator=(thread_state);
|
||||
|
||||
// Add/remove CPU state flags in an atomic operations, notifying if required
|
||||
void add_remove_flags(bs_t<cpu_flag> to_add, bs_t<cpu_flag> to_remove);
|
||||
void add_remove_flags(rx::EnumBitSet<cpu_flag> to_add, rx::EnumBitSet<cpu_flag> to_remove);
|
||||
|
||||
// Thread stats for external observation
|
||||
static atomic_t<u64> g_threads_created, g_threads_deleted, g_suspend_counter;
|
||||
|
|
@ -194,7 +195,7 @@ public:
|
|||
virtual void cpu_return() {}
|
||||
|
||||
// Callback for thread_ctrl::wait or RSX wait
|
||||
virtual void cpu_wait(bs_t<cpu_flag> old);
|
||||
virtual void cpu_wait(rx::EnumBitSet<cpu_flag> old);
|
||||
|
||||
// Callback for function abortion stats on Emu.Kill()
|
||||
virtual void cpu_on_stop() {}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ void fmt_class_string<ppu_attr>::format(std::string& out, u64 arg)
|
|||
case ppu_attr::no_return: return "no_return";
|
||||
case ppu_attr::no_size: return "no_size";
|
||||
case ppu_attr::has_mfvscr: return "has_mfvscr";
|
||||
case ppu_attr::__bitset_enum_max: break;
|
||||
case ppu_attr::bitset_last: break;
|
||||
}
|
||||
|
||||
return unknown;
|
||||
|
|
@ -33,7 +33,7 @@ void fmt_class_string<ppu_attr>::format(std::string& out, u64 arg)
|
|||
}
|
||||
|
||||
template <>
|
||||
void fmt_class_string<bs_t<ppu_attr>>::format(std::string& out, u64 arg)
|
||||
void fmt_class_string<rx::EnumBitSet<ppu_attr>>::format(std::string& out, u64 arg)
|
||||
{
|
||||
format_bitset(out, arg, "[", ",", "]", &fmt_class_string<ppu_attr>::format);
|
||||
}
|
||||
|
|
@ -857,7 +857,7 @@ bool ppu_module<lv2_obj>::analyse(u32 lib_toc, u32 entry, const u32 sec_end, con
|
|||
// u32 stack_frame = 0;
|
||||
u32 single_target = 0;
|
||||
u32 trampoline = 0;
|
||||
bs_t<ppu_attr> attr{};
|
||||
rx::EnumBitSet<ppu_attr> attr{};
|
||||
|
||||
std::set<u32> callers{};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "util/asm.hpp"
|
||||
#include "util/to_endian.hpp"
|
||||
|
||||
#include "util/bit_set.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "PPUOpcodes.h"
|
||||
|
||||
// PPU Function Attributes
|
||||
|
|
@ -19,7 +19,7 @@ enum class ppu_attr : u8
|
|||
no_size,
|
||||
has_mfvscr,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = has_mfvscr,
|
||||
};
|
||||
|
||||
// PPU Function Information
|
||||
|
|
@ -131,7 +131,7 @@ struct ppu_module : public Type
|
|||
std::string name{}; // Filename
|
||||
std::string path{}; // Filepath
|
||||
s64 offset = 0; // Offset of file
|
||||
mutable bs_t<ppu_attr> attr{}; // Shared module attributes
|
||||
mutable rx::EnumBitSet<ppu_attr> attr{}; // Shared module attributes
|
||||
std::string cache{}; // Cache file path
|
||||
std::vector<ppu_reloc> relocs{}; // Relocations
|
||||
std::vector<ppu_segment> segs{}; // Segments
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ enum class ppu_exec_bit : u64
|
|||
set_call_history,
|
||||
use_feed_data,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = use_feed_data,
|
||||
};
|
||||
|
||||
using enum ppu_exec_bit;
|
||||
|
|
@ -80,7 +80,7 @@ template <ppu_exec_bit... Flags0>
|
|||
struct ppu_exec_select
|
||||
{
|
||||
template <ppu_exec_bit Flag, ppu_exec_bit... Flags, typename F>
|
||||
static ppu_intrp_func_t select(bs_t<ppu_exec_bit> selected, F func)
|
||||
static ppu_intrp_func_t select(rx::EnumBitSet<ppu_exec_bit> selected, F func)
|
||||
{
|
||||
// Make sure there is no flag duplication, otherwise skip flag
|
||||
if constexpr (((Flags0 != Flag) && ...))
|
||||
|
|
@ -97,7 +97,7 @@ struct ppu_exec_select
|
|||
}
|
||||
|
||||
template <typename F>
|
||||
static ppu_intrp_func_t select(bs_t<ppu_exec_bit>, F func)
|
||||
static ppu_intrp_func_t select(rx::EnumBitSet<ppu_exec_bit>, F func)
|
||||
{
|
||||
// Instantiate interpreter function with required set of flags
|
||||
return func.template operator()<Flags0...>();
|
||||
|
|
@ -107,7 +107,7 @@ struct ppu_exec_select
|
|||
static auto select()
|
||||
{
|
||||
#ifndef __INTELLISENSE__
|
||||
return [](bs_t<ppu_exec_bit> selected, auto func)
|
||||
return [](rx::EnumBitSet<ppu_exec_bit> selected, auto func)
|
||||
{
|
||||
return ppu_exec_select::select<Flags1...>(selected, func);
|
||||
};
|
||||
|
|
@ -2350,7 +2350,7 @@ template <u32 Count>
|
|||
struct VSLDOI
|
||||
{
|
||||
template <ppu_exec_bit... Flags>
|
||||
static auto select(bs_t<ppu_exec_bit> selected, auto func)
|
||||
static auto select(rx::EnumBitSet<ppu_exec_bit> selected, auto func)
|
||||
{
|
||||
return ppu_exec_select<>::select<Flags...>(selected, func);
|
||||
}
|
||||
|
|
@ -3891,7 +3891,7 @@ template <u32 N>
|
|||
struct MFOCRF
|
||||
{
|
||||
template <ppu_exec_bit... Flags>
|
||||
static auto select(bs_t<ppu_exec_bit> selected, auto func)
|
||||
static auto select(rx::EnumBitSet<ppu_exec_bit> selected, auto func)
|
||||
{
|
||||
return ppu_exec_select<>::select<Flags...>(selected, func);
|
||||
}
|
||||
|
|
@ -7547,7 +7547,7 @@ struct ppu_interpreter_t
|
|||
ppu_interpreter_rt_base::ppu_interpreter_rt_base() noexcept
|
||||
{
|
||||
// Obtain required set of flags from settings
|
||||
bs_t<ppu_exec_bit> selected{};
|
||||
rx::EnumBitSet<ppu_exec_bit> selected{};
|
||||
if (g_cfg.core.ppu_set_sat_bit)
|
||||
selected += set_sat;
|
||||
if (g_cfg.core.ppu_use_nj_bit)
|
||||
|
|
|
|||
|
|
@ -3254,7 +3254,7 @@ bool ppu_load_rel_exec(const ppu_rel_object& elf)
|
|||
|
||||
std::stable_sort(shdrs.begin(), shdrs.end(), [](auto& a, auto& b) -> bool
|
||||
{
|
||||
const bs_t<sh_flag> flags_a_has = a->sh_flags() - b->sh_flags();
|
||||
const rx::EnumBitSet<sh_flag> flags_a_has = a->sh_flags() - b->sh_flags();
|
||||
return flags_a_has.all_of(sh_flag::shf_execinstr);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1261,7 +1261,7 @@ static void ppu_break(ppu_thread& ppu, ppu_opcode_t, be_t<u32>* this_op, ppu_int
|
|||
ppu.cia = old_cia;
|
||||
|
||||
// Pause
|
||||
ppu.state.atomic_op([&](bs_t<cpu_flag>& state)
|
||||
ppu.state.atomic_op([&](rx::EnumBitSet<cpu_flag>& state)
|
||||
{
|
||||
if (pause_all)
|
||||
state += cpu_flag::dbg_global_pause;
|
||||
|
|
@ -2423,7 +2423,7 @@ void ppu_thread::cpu_on_stop()
|
|||
}
|
||||
}
|
||||
|
||||
void ppu_thread::cpu_wait(bs_t<cpu_flag> old)
|
||||
void ppu_thread::cpu_wait(rx::EnumBitSet<cpu_flag> old)
|
||||
{
|
||||
// Meanwhile while waiting, notify SPU waiters
|
||||
if (u32 addr = res_notify)
|
||||
|
|
@ -2781,7 +2781,7 @@ ppu_thread::ppu_thread(utils::serial& ar)
|
|||
void ppu_thread::save(utils::serial& ar)
|
||||
{
|
||||
// For debugging purposes, load this as soon as this function enters
|
||||
const bs_t<cpu_flag> state_flags = state;
|
||||
const rx::EnumBitSet<cpu_flag> state_flags = state;
|
||||
|
||||
USING_SERIALIZATION_VERSION(ppu);
|
||||
|
||||
|
|
@ -5421,10 +5421,10 @@ bool ppu_initialize(const ppu_module<lv2_obj>& info, bool check_only, u64 file_s
|
|||
accurate_nj_mode,
|
||||
contains_symbol_resolver,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = contains_symbol_resolver,
|
||||
};
|
||||
|
||||
be_t<bs_t<ppu_settings>> settings{};
|
||||
be_t<rx::EnumBitSet<ppu_settings>> settings{};
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
settings += ppu_settings::platform_bit;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public:
|
|||
virtual void cpu_task() override final;
|
||||
virtual void cpu_sleep() override;
|
||||
virtual void cpu_on_stop() override;
|
||||
virtual void cpu_wait(bs_t<cpu_flag> old) override;
|
||||
virtual void cpu_wait(rx::EnumBitSet<cpu_flag> old) override;
|
||||
virtual ~ppu_thread() override;
|
||||
|
||||
SAVESTATE_INIT_POS(3);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class PPUTranslator final : public cpu_translator
|
|||
u64 m_addr = 0;
|
||||
|
||||
// Function attributes
|
||||
bs_t<ppu_attr> m_attr{};
|
||||
rx::EnumBitSet<ppu_attr> m_attr{};
|
||||
|
||||
// Relocation info
|
||||
const ppu_segment* m_reloc = nullptr;
|
||||
|
|
|
|||
|
|
@ -2920,7 +2920,7 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point, s
|
|||
}
|
||||
|
||||
// Weak constant propagation context (for guessing branch targets)
|
||||
std::array<bs_t<vf>, 128> vflags{};
|
||||
std::array<rx::EnumBitSet<vf>, 128> vflags{};
|
||||
|
||||
// Associated constant values for 32-bit preferred slot
|
||||
std::array<u32, 128> values;
|
||||
|
|
@ -5596,7 +5596,7 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point, s
|
|||
pos = ra.origin;
|
||||
}
|
||||
|
||||
const bs_t<vf> flag = (ra.flag & rb.flag) - vf::is_null;
|
||||
const rx::EnumBitSet<vf> flag = (ra.flag & rb.flag) - vf::is_null;
|
||||
|
||||
vregs[reg] = reg_state_t{flag, value, flag & vf::is_const ? u32{umax} : reg_state_t::alloc_tag(), 0, 0, pos};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ enum class spu_exec_bit : u64
|
|||
{
|
||||
use_dfma,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = use_dfma,
|
||||
};
|
||||
|
||||
using enum spu_exec_bit;
|
||||
|
|
@ -43,7 +43,7 @@ template <spu_exec_bit... Flags0>
|
|||
struct spu_exec_select
|
||||
{
|
||||
template <spu_exec_bit Flag, spu_exec_bit... Flags, typename F>
|
||||
static spu_intrp_func_t select(bs_t<spu_exec_bit> selected, F func)
|
||||
static spu_intrp_func_t select(rx::EnumBitSet<spu_exec_bit> selected, F func)
|
||||
{
|
||||
// Make sure there is no flag duplication, otherwise skip flag
|
||||
if constexpr (((Flags0 != Flag) && ...))
|
||||
|
|
@ -60,7 +60,7 @@ struct spu_exec_select
|
|||
}
|
||||
|
||||
template <typename F>
|
||||
static spu_intrp_func_t select(bs_t<spu_exec_bit>, F func)
|
||||
static spu_intrp_func_t select(rx::EnumBitSet<spu_exec_bit>, F func)
|
||||
{
|
||||
// Instantiate interpreter function with required set of flags
|
||||
return func.template operator()<Flags0...>();
|
||||
|
|
@ -3131,7 +3131,7 @@ struct spu_interpreter_t
|
|||
spu_interpreter_rt_base::spu_interpreter_rt_base() noexcept
|
||||
{
|
||||
// Obtain required set of flags from settings
|
||||
bs_t<spu_exec_bit> selected{};
|
||||
rx::EnumBitSet<spu_exec_bit> selected{};
|
||||
if (g_cfg.core.use_accurate_dfma)
|
||||
selected += use_dfma;
|
||||
|
||||
|
|
|
|||
|
|
@ -198,12 +198,12 @@ public:
|
|||
is_rel,
|
||||
is_null,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = is_null,
|
||||
};
|
||||
|
||||
struct reg_state_t
|
||||
{
|
||||
bs_t<vf> flag{+vf::is_null};
|
||||
rx::EnumBitSet<vf> flag{+vf::is_null};
|
||||
u32 value{};
|
||||
u32 tag = umax;
|
||||
u32 known_ones{};
|
||||
|
|
|
|||
|
|
@ -2027,7 +2027,7 @@ void spu_thread::cpu_work()
|
|||
if (!work_left)
|
||||
{
|
||||
// No more pending work
|
||||
state.atomic_op([](bs_t<cpu_flag>& flags)
|
||||
state.atomic_op([](rx::EnumBitSet<cpu_flag>& flags)
|
||||
{
|
||||
if (flags & cpu_flag::pending_recheck)
|
||||
{
|
||||
|
|
@ -7010,7 +7010,7 @@ bool spu_thread::stop_and_signal(u32 code)
|
|||
{
|
||||
if (thread)
|
||||
{
|
||||
thread->state.fetch_op([](bs_t<cpu_flag>& flags)
|
||||
thread->state.fetch_op([](rx::EnumBitSet<cpu_flag>& flags)
|
||||
{
|
||||
if (flags & cpu_flag::stop)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "GDB.h"
|
||||
#include "util/bit_set.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "util/logs.hpp"
|
||||
#include "util/StrUtil.h"
|
||||
#include "Emu/Memory/vm.h"
|
||||
|
|
@ -823,7 +823,7 @@ bool gdb_thread::cmd_vcont(gdb_cmd& cmd)
|
|||
|
||||
if (ppu)
|
||||
{
|
||||
bs_t<cpu_flag> add_flags{};
|
||||
rx::EnumBitSet<cpu_flag> add_flags{};
|
||||
|
||||
if (cmd.data[1] == 's')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -435,7 +435,7 @@ namespace vm
|
|||
|
||||
bool temporary_unlock(cpu_thread& cpu) noexcept
|
||||
{
|
||||
bs_t<cpu_flag> add_state = cpu_flag::wait;
|
||||
rx::EnumBitSet<cpu_flag> add_state = cpu_flag::wait;
|
||||
|
||||
if (g_tls_locked && g_tls_locked->compare_and_swap_test(&cpu, nullptr))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -850,7 +850,7 @@ namespace rsx
|
|||
on_exit();
|
||||
}
|
||||
|
||||
void thread::cpu_wait(bs_t<cpu_flag> old)
|
||||
void thread::cpu_wait(rx::EnumBitSet<cpu_flag> old)
|
||||
{
|
||||
if (external_interrupt_lock)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ namespace rsx
|
|||
u32 get_fifo_cmd() const;
|
||||
|
||||
void dump_regs(std::string&, std::any& custom_data) const override;
|
||||
void cpu_wait(bs_t<cpu_flag> old) override;
|
||||
void cpu_wait(rx::EnumBitSet<cpu_flag> old) override;
|
||||
|
||||
static constexpr u32 id_base = 0x5555'5555; // See get_current_cpu_thread()
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ constexpr VkDriverId VK_DRIVER_ID_MESA_HONEYKRISP = static_cast<VkDriverId>(26);
|
|||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace vk
|
||||
{
|
||||
template <std::size_t N>
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ void init_fxo_for_exec(utils::serial* ar, bool full = false)
|
|||
{
|
||||
ensure(pos == ar->pos);
|
||||
|
||||
(*ar)(Emu.m_savestate_extension_flags1);
|
||||
(*ar)(Emu.m_savestate_extension_flags1.raw());
|
||||
|
||||
const usz advance = (Emu.m_savestate_extension_flags1 & Emulator::SaveStateExtentionFlags1::SupportsMenuOpenResume ? 32 : 31);
|
||||
|
||||
|
|
@ -2654,7 +2654,7 @@ void Emulator::FinalizeRunRequest()
|
|||
{
|
||||
const bool autostart = !m_ar || !!g_cfg.misc.autostart;
|
||||
|
||||
bs_t<cpu_flag> add_flags = cpu_flag::dbg_global_pause;
|
||||
rx::EnumBitSet<cpu_flag> add_flags = cpu_flag::dbg_global_pause;
|
||||
|
||||
if (autostart)
|
||||
{
|
||||
|
|
@ -2663,7 +2663,7 @@ void Emulator::FinalizeRunRequest()
|
|||
|
||||
auto spu_select = [&](u32, spu_thread& spu)
|
||||
{
|
||||
bs_t<cpu_flag> sub_flags = cpu_flag::stop;
|
||||
rx::EnumBitSet<cpu_flag> sub_flags = cpu_flag::stop;
|
||||
|
||||
if (spu.group && spu.index == spu.group->waiter_spu_index)
|
||||
{
|
||||
|
|
@ -3605,14 +3605,14 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
|
|||
|
||||
set_progress_message("Finalizing File");
|
||||
|
||||
bs_t<SaveStateExtentionFlags1> extension_flags{SaveStateExtentionFlags1::SupportsMenuOpenResume};
|
||||
rx::EnumBitSet<SaveStateExtentionFlags1> extension_flags{SaveStateExtentionFlags1::SupportsMenuOpenResume};
|
||||
|
||||
if (g_fxo->get<SysutilMenuOpenStatus>().active)
|
||||
{
|
||||
extension_flags += SaveStateExtentionFlags1::ShouldCloseMenu;
|
||||
}
|
||||
|
||||
ar(extension_flags);
|
||||
ar(extension_flags.raw());
|
||||
|
||||
ar(std::array<u8, 32>{}); // Reserved for future use
|
||||
ar(timestamp);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "util/types.hpp"
|
||||
#include "util/atomic.hpp"
|
||||
#include "util/shared_ptr.hpp"
|
||||
#include "util/bit_set.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "config_mode.h"
|
||||
#include "games_config.h"
|
||||
#include <functional>
|
||||
|
|
@ -188,10 +188,10 @@ class Emulator final
|
|||
SupportsMenuOpenResume,
|
||||
ShouldCloseMenu,
|
||||
|
||||
__bitset_enum_max,
|
||||
bitset_last = ShouldCloseMenu,
|
||||
};
|
||||
|
||||
bs_t<SaveStateExtentionFlags1> m_savestate_extension_flags1{};
|
||||
rx::EnumBitSet<SaveStateExtentionFlags1> m_savestate_extension_flags1{};
|
||||
|
||||
public:
|
||||
static constexpr std::string_view game_id_boot_prefix = "%RPCS3_GAMEID%:";
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "util/types.hpp"
|
||||
#include "util/File.h"
|
||||
#include "util/bit_set.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "util/endian.hpp"
|
||||
|
||||
#include <span>
|
||||
|
|
@ -56,10 +56,10 @@ enum class sh_flag : u32
|
|||
shf_alloc,
|
||||
shf_execinstr,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = shf_execinstr,
|
||||
};
|
||||
|
||||
constexpr bool is_memorizable_section(sec_type type, bs_t<sh_flag> flags)
|
||||
constexpr bool is_memorizable_section(sec_type type, rx::EnumBitSet<sh_flag> flags)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
|
@ -184,9 +184,9 @@ struct elf_shdr
|
|||
en_t<sz_t> sh_addralign;
|
||||
en_t<sz_t> sh_entsize;
|
||||
|
||||
bs_t<sh_flag> sh_flags() const
|
||||
rx::EnumBitSet<sh_flag> sh_flags() const
|
||||
{
|
||||
return std::bit_cast<bs_t<sh_flag>>(static_cast<u32>(+_sh_flags));
|
||||
return std::bit_cast<rx::EnumBitSet<sh_flag>>(static_cast<u32>(+_sh_flags));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ enum class elf_opt : u32
|
|||
no_sections, // Don't load shdrs
|
||||
no_data, // Load phdrs without data
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last = no_data,
|
||||
};
|
||||
|
||||
// ELF loading error
|
||||
|
|
@ -266,12 +266,12 @@ public:
|
|||
public:
|
||||
elf_object() = default;
|
||||
|
||||
elf_object(const fs::file& stream, u64 offset = 0, bs_t<elf_opt> opts = {})
|
||||
elf_object(const fs::file& stream, u64 offset = 0, rx::EnumBitSet<elf_opt> opts = {})
|
||||
{
|
||||
open(stream, offset, opts);
|
||||
}
|
||||
|
||||
elf_error open(const fs::file& stream, u64 offset = 0, bs_t<elf_opt> opts = {})
|
||||
elf_error open(const fs::file& stream, u64 offset = 0, rx::EnumBitSet<elf_opt> opts = {})
|
||||
{
|
||||
highest_offset = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "util/types.hpp"
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ bool iso_dev::statfs(const std::string& path, fs::device_stat& info)
|
|||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<fs::file_base> iso_dev::open(const std::string& path, bs_t<fs::open_mode> mode)
|
||||
std::unique_ptr<fs::file_base> iso_dev::open(const std::string& path, rx::EnumBitSet<fs::open_mode> mode)
|
||||
{
|
||||
if (mode & fs::write)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ public:
|
|||
|
||||
bool stat(const std::string& path, fs::stat_t& info) override;
|
||||
bool statfs(const std::string& path, fs::device_stat& info) override;
|
||||
std::unique_ptr<fs::file_base> open(const std::string& path, bs_t<fs::open_mode> mode) override;
|
||||
std::unique_ptr<fs::file_base> open(const std::string& path, rx::EnumBitSet<fs::open_mode> mode) override;
|
||||
std::unique_ptr<fs::dir_base> open_dir(const std::string& path) override;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1635,7 +1635,7 @@ void fs::sync()
|
|||
fmt::throw_exception("Stream overflow.");
|
||||
}
|
||||
|
||||
fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
||||
fs::file::file(const std::string& path, rx::EnumBitSet<open_mode> mode)
|
||||
{
|
||||
if (path.empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "util/serialization.hpp"
|
||||
#include "util/types.hpp"
|
||||
#include "util/shared_ptr.hpp"
|
||||
#include "bit_set.h"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
|
@ -35,7 +35,7 @@ namespace fs
|
|||
unread,
|
||||
isfile,
|
||||
|
||||
__bitset_enum_max
|
||||
bitset_last
|
||||
};
|
||||
|
||||
constexpr auto read = +open_mode::read; // Enable reading
|
||||
|
|
@ -174,7 +174,7 @@ namespace fs
|
|||
virtual bool trunc(const std::string& path, u64 length);
|
||||
virtual bool utime(const std::string& path, s64 atime, s64 mtime);
|
||||
|
||||
virtual std::unique_ptr<file_base> open(const std::string& path, bs_t<open_mode> mode) = 0;
|
||||
virtual std::unique_ptr<file_base> open(const std::string& path, rx::EnumBitSet<open_mode> mode) = 0;
|
||||
virtual std::unique_ptr<dir_base> open_dir(const std::string& path) = 0;
|
||||
};
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ namespace fs
|
|||
file() = default;
|
||||
|
||||
// Open file with specified mode
|
||||
explicit file(const std::string& path, bs_t<open_mode> mode = ::fs::read);
|
||||
explicit file(const std::string& path, rx::EnumBitSet<open_mode> mode = ::fs::read);
|
||||
|
||||
static file from_native_handle(native_handle handle);
|
||||
|
||||
|
|
@ -903,7 +903,7 @@ namespace fs
|
|||
}
|
||||
|
||||
template <bool Flush = false, typename... Args>
|
||||
bool write_file(const std::string& path, bs_t<fs::open_mode> mode, const Args&... args)
|
||||
bool write_file(const std::string& path, rx::EnumBitSet<fs::open_mode> mode, const Args&... args)
|
||||
{
|
||||
// Always use write flag, remove read flag
|
||||
if (fs::file f{path, mode + fs::write - fs::read})
|
||||
|
|
|
|||
175
rpcs3/util/atomic_bit_set.h
Normal file
175
rpcs3/util/atomic_bit_set.h
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
#pragma once
|
||||
|
||||
/*
|
||||
This header implements bs_t<> class for scoped enum types (enum class).
|
||||
To enable bs_t<>, enum scope must contain `bitset_last` entry.
|
||||
|
||||
enum class flagzz : u32
|
||||
{
|
||||
flag1, // Bit indices start from zero
|
||||
flag2,
|
||||
|
||||
bitset_last // It must be the last value
|
||||
};
|
||||
|
||||
This also enables helper operators for this enum type.
|
||||
|
||||
Examples:
|
||||
`+flagzz::flag1` - unary `+` operator convert flagzz value to bs_t<flagzz>
|
||||
`flagzz::flag1 + flagzz::flag2` - bitset union
|
||||
`flagzz::flag1 - flagzz::flag2` - bitset difference
|
||||
Intersection (&) and symmetric difference (^) is also available.
|
||||
*/
|
||||
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "util/atomic.hpp"
|
||||
#include "util/StrFmt.h"
|
||||
|
||||
template <typename T>
|
||||
concept BitSetEnum = std::is_enum_v<T> && requires(T x) {
|
||||
T::bitset_last;
|
||||
};
|
||||
|
||||
// Atomic bitset specialization with optimized operations
|
||||
template <BitSetEnum T>
|
||||
class atomic_bs_t : public atomic_t<rx::EnumBitSet<T>>
|
||||
{
|
||||
// Corresponding bitset type
|
||||
using bs_t = rx::EnumBitSet<T>;
|
||||
|
||||
// Base class
|
||||
using base = atomic_t<rx::EnumBitSet<T>>;
|
||||
|
||||
// Use underlying m_data
|
||||
using base::m_data;
|
||||
|
||||
public:
|
||||
// Underlying type
|
||||
using underlying_type = typename bs_t::underlying_type;
|
||||
|
||||
atomic_bs_t() = default;
|
||||
|
||||
atomic_bs_t(const atomic_bs_t&) = delete;
|
||||
|
||||
atomic_bs_t& operator=(const atomic_bs_t&) = delete;
|
||||
|
||||
explicit constexpr atomic_bs_t(bs_t value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
explicit constexpr atomic_bs_t(T bit)
|
||||
: base(bit)
|
||||
{
|
||||
}
|
||||
|
||||
using base::operator bs_t;
|
||||
|
||||
explicit operator bool() const
|
||||
{
|
||||
return static_cast<bool>(base::load());
|
||||
}
|
||||
|
||||
explicit operator underlying_type() const
|
||||
{
|
||||
return static_cast<underlying_type>(base::load());
|
||||
}
|
||||
|
||||
bs_t operator+() const
|
||||
{
|
||||
return base::load();
|
||||
}
|
||||
|
||||
bs_t fetch_add(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::fetch_or(m_data.raw(), rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t add_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::or_fetch(m_data.raw(), rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t operator+=(const bs_t& rhs)
|
||||
{
|
||||
return add_fetch(rhs);
|
||||
}
|
||||
|
||||
bs_t fetch_sub(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::fetch_and(m_data.raw(), ~rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t sub_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::and_fetch(m_data.raw(), ~rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t operator-=(const bs_t& rhs)
|
||||
{
|
||||
return sub_fetch(rhs);
|
||||
}
|
||||
|
||||
bs_t fetch_and(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::fetch_and(m_data.raw(), rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t and_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::and_fetch(m_data.raw(), rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t operator&=(const bs_t& rhs)
|
||||
{
|
||||
return and_fetch(rhs);
|
||||
}
|
||||
|
||||
bs_t fetch_xor(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::fetch_xor(m_data.raw(), rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t xor_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t::fromUnderlying(atomic_storage<underlying_type>::xor_fetch(m_data.raw(), rhs.toUnderlying()));
|
||||
}
|
||||
|
||||
bs_t operator^=(const bs_t& rhs)
|
||||
{
|
||||
return xor_fetch(rhs);
|
||||
}
|
||||
|
||||
auto fetch_or(const bs_t&) = delete;
|
||||
auto or_fetch(const bs_t&) = delete;
|
||||
auto operator|=(const bs_t&) = delete;
|
||||
|
||||
bool test_and_set(T rhs)
|
||||
{
|
||||
return atomic_storage<underlying_type>::bts(m_data.raw(), static_cast<uint>(static_cast<underlying_type>(rhs)));
|
||||
}
|
||||
|
||||
bool test_and_reset(T rhs)
|
||||
{
|
||||
return atomic_storage<underlying_type>::btr(m_data.raw(), static_cast<uint>(static_cast<underlying_type>(rhs)));
|
||||
}
|
||||
|
||||
bool test_and_invert(T rhs)
|
||||
{
|
||||
return atomic_storage<underlying_type>::btc(m_data.raw(), static_cast<uint>(static_cast<underlying_type>(rhs)));
|
||||
}
|
||||
|
||||
bool bit_test_set(uint bit) = delete;
|
||||
bool bit_test_reset(uint bit) = delete;
|
||||
bool bit_test_invert(uint bit) = delete;
|
||||
|
||||
bool all_of(bs_t arg) const
|
||||
{
|
||||
return base::load().all_of(arg);
|
||||
}
|
||||
|
||||
bool none_of(bs_t arg) const
|
||||
{
|
||||
return base::load().none_of(arg);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,404 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/*
|
||||
This header implements bs_t<> class for scoped enum types (enum class).
|
||||
To enable bs_t<>, enum scope must contain `__bitset_enum_max` entry.
|
||||
|
||||
enum class flagzz : u32
|
||||
{
|
||||
flag1, // Bit indices start from zero
|
||||
flag2,
|
||||
|
||||
__bitset_enum_max // It must be the last value
|
||||
};
|
||||
|
||||
This also enables helper operators for this enum type.
|
||||
|
||||
Examples:
|
||||
`+flagzz::flag1` - unary `+` operator convert flagzz value to bs_t<flagzz>
|
||||
`flagzz::flag1 + flagzz::flag2` - bitset union
|
||||
`flagzz::flag1 - flagzz::flag2` - bitset difference
|
||||
Intersection (&) and symmetric difference (^) is also available.
|
||||
*/
|
||||
|
||||
#include "util/types.hpp"
|
||||
#include "util/atomic.hpp"
|
||||
#include "util/StrFmt.h"
|
||||
|
||||
template <typename T>
|
||||
concept BitSetEnum = std::is_enum_v<T> && requires(T x) {
|
||||
T::__bitset_enum_max;
|
||||
};
|
||||
|
||||
template <BitSetEnum T>
|
||||
class atomic_bs_t;
|
||||
|
||||
// Bitset type for enum class with available bits [0, T::__bitset_enum_max)
|
||||
template <BitSetEnum T>
|
||||
class bs_t final
|
||||
{
|
||||
public:
|
||||
// Underlying type
|
||||
using under = std::underlying_type_t<T>;
|
||||
|
||||
ENABLE_BITWISE_SERIALIZATION;
|
||||
|
||||
private:
|
||||
// Underlying value
|
||||
under m_data;
|
||||
|
||||
friend class atomic_bs_t<T>;
|
||||
|
||||
// Value constructor
|
||||
constexpr explicit bs_t(int, under data) noexcept
|
||||
: m_data(data)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
static constexpr usz bitmax = sizeof(T) * 8;
|
||||
static constexpr usz bitsize = static_cast<under>(T::__bitset_enum_max);
|
||||
|
||||
static_assert(std::is_enum_v<T>, "bs_t<> error: invalid type (must be enum)");
|
||||
static_assert(bitsize <= bitmax, "bs_t<> error: invalid __bitset_enum_max");
|
||||
static_assert(bitsize != bitmax || std::is_unsigned_v<under>, "bs_t<> error: invalid __bitset_enum_max (sign bit)");
|
||||
|
||||
// Helper function
|
||||
static constexpr under shift(T value)
|
||||
{
|
||||
return static_cast<under>(1) << static_cast<under>(value);
|
||||
}
|
||||
|
||||
bs_t() = default;
|
||||
|
||||
// Construct from a single bit
|
||||
constexpr bs_t(T bit) noexcept
|
||||
: m_data(shift(bit))
|
||||
{
|
||||
}
|
||||
|
||||
// Test for empty bitset
|
||||
constexpr explicit operator bool() const noexcept
|
||||
{
|
||||
return m_data != 0;
|
||||
}
|
||||
|
||||
// Extract underlying data
|
||||
constexpr explicit operator under() const noexcept
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
|
||||
// Copy
|
||||
constexpr bs_t operator+() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bs_t& operator+=(bs_t rhs)
|
||||
{
|
||||
m_data |= static_cast<under>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bs_t& operator-=(bs_t rhs)
|
||||
{
|
||||
m_data &= ~static_cast<under>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bs_t& operator&=(bs_t rhs)
|
||||
{
|
||||
m_data &= static_cast<under>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bs_t& operator^=(bs_t rhs)
|
||||
{
|
||||
m_data ^= static_cast<under>(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend constexpr bs_t operator+(bs_t lhs, bs_t rhs)
|
||||
{
|
||||
return bs_t(0, lhs.m_data | rhs.m_data);
|
||||
}
|
||||
|
||||
friend constexpr bs_t operator-(bs_t lhs, bs_t rhs)
|
||||
{
|
||||
return bs_t(0, lhs.m_data & ~rhs.m_data);
|
||||
}
|
||||
|
||||
friend constexpr bs_t operator&(bs_t lhs, bs_t rhs)
|
||||
{
|
||||
return bs_t(0, lhs.m_data & rhs.m_data);
|
||||
}
|
||||
|
||||
friend constexpr bs_t operator^(bs_t lhs, bs_t rhs)
|
||||
{
|
||||
return bs_t(0, lhs.m_data ^ rhs.m_data);
|
||||
}
|
||||
|
||||
constexpr bool operator==(bs_t rhs) const noexcept
|
||||
{
|
||||
return m_data == rhs.m_data;
|
||||
}
|
||||
|
||||
constexpr bool test_and_set(T bit)
|
||||
{
|
||||
bool r = (m_data & shift(bit)) != 0;
|
||||
m_data |= shift(bit);
|
||||
return r;
|
||||
}
|
||||
|
||||
constexpr bool test_and_reset(T bit)
|
||||
{
|
||||
bool r = (m_data & shift(bit)) != 0;
|
||||
m_data &= ~shift(bit);
|
||||
return r;
|
||||
}
|
||||
|
||||
constexpr bool test_and_complement(T bit)
|
||||
{
|
||||
bool r = (m_data & shift(bit)) != 0;
|
||||
m_data ^= shift(bit);
|
||||
return r;
|
||||
}
|
||||
|
||||
constexpr bool all_of(bs_t arg) const
|
||||
{
|
||||
return (m_data & arg.m_data) == arg.m_data;
|
||||
}
|
||||
|
||||
constexpr bool none_of(bs_t arg) const
|
||||
{
|
||||
return (m_data & arg.m_data) == 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Unary '+' operator: promote plain enum value to bitset value
|
||||
template <BitSetEnum T>
|
||||
constexpr bs_t<T> operator+(T bit)
|
||||
{
|
||||
return bs_t<T>(bit);
|
||||
}
|
||||
|
||||
// Binary '+' operator: bitset union
|
||||
template <BitSetEnum T, typename U>
|
||||
requires(std::is_constructible_v<bs_t<T>, U>)
|
||||
constexpr bs_t<T> operator+(T lhs, const U& rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) + bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '+' operator: bitset union
|
||||
template <typename U, BitSetEnum T>
|
||||
requires(std::is_constructible_v<bs_t<T>, U> && !std::is_enum_v<U>)
|
||||
constexpr bs_t<T> operator+(const U& lhs, T rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) + bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '-' operator: bitset difference
|
||||
template <BitSetEnum T, typename U>
|
||||
requires(std::is_constructible_v<bs_t<T>, U>)
|
||||
constexpr bs_t<T> operator-(T lhs, const U& rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) - bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '-' operator: bitset difference
|
||||
template <typename U, BitSetEnum T>
|
||||
requires(std::is_constructible_v<bs_t<T>, U> && !std::is_enum_v<U>)
|
||||
constexpr bs_t<T> operator-(const U& lhs, T rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) - bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '&' operator: bitset intersection
|
||||
template <BitSetEnum T, typename U>
|
||||
requires(std::is_constructible_v<bs_t<T>, U>)
|
||||
constexpr bs_t<T> operator&(T lhs, const U& rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) & bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '&' operator: bitset intersection
|
||||
template <typename U, BitSetEnum T>
|
||||
requires(std::is_constructible_v<bs_t<T>, U> && !std::is_enum_v<U>)
|
||||
constexpr bs_t<T> operator&(const U& lhs, T rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) & bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '^' operator: bitset symmetric difference
|
||||
template <BitSetEnum T, typename U>
|
||||
requires(std::is_constructible_v<bs_t<T>, U>)
|
||||
constexpr bs_t<T> operator^(T lhs, const U& rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) ^ bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Binary '^' operator: bitset symmetric difference
|
||||
template <typename U, BitSetEnum T>
|
||||
requires(std::is_constructible_v<bs_t<T>, U> && !std::is_enum_v<U>)
|
||||
constexpr bs_t<T> operator^(const U& lhs, T rhs)
|
||||
{
|
||||
return bs_t<T>(lhs) ^ bs_t<T>(rhs);
|
||||
}
|
||||
|
||||
// Atomic bitset specialization with optimized operations
|
||||
template <BitSetEnum T>
|
||||
class atomic_bs_t : public atomic_t<::bs_t<T>>
|
||||
{
|
||||
// Corresponding bitset type
|
||||
using bs_t = ::bs_t<T>;
|
||||
|
||||
// Base class
|
||||
using base = atomic_t<::bs_t<T>>;
|
||||
|
||||
// Use underlying m_data
|
||||
using base::m_data;
|
||||
|
||||
public:
|
||||
// Underlying type
|
||||
using under = typename bs_t::under;
|
||||
|
||||
atomic_bs_t() = default;
|
||||
|
||||
atomic_bs_t(const atomic_bs_t&) = delete;
|
||||
|
||||
atomic_bs_t& operator=(const atomic_bs_t&) = delete;
|
||||
|
||||
explicit constexpr atomic_bs_t(bs_t value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
explicit constexpr atomic_bs_t(T bit)
|
||||
: base(bit)
|
||||
{
|
||||
}
|
||||
|
||||
using base::operator bs_t;
|
||||
|
||||
explicit operator bool() const
|
||||
{
|
||||
return static_cast<bool>(base::load());
|
||||
}
|
||||
|
||||
explicit operator under() const
|
||||
{
|
||||
return static_cast<under>(base::load());
|
||||
}
|
||||
|
||||
bs_t operator+() const
|
||||
{
|
||||
return base::load();
|
||||
}
|
||||
|
||||
bs_t fetch_add(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::fetch_or(m_data.m_data, rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t add_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::or_fetch(m_data.m_data, rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t operator+=(const bs_t& rhs)
|
||||
{
|
||||
return add_fetch(rhs);
|
||||
}
|
||||
|
||||
bs_t fetch_sub(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::fetch_and(m_data.m_data, ~rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t sub_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::and_fetch(m_data.m_data, ~rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t operator-=(const bs_t& rhs)
|
||||
{
|
||||
return sub_fetch(rhs);
|
||||
}
|
||||
|
||||
bs_t fetch_and(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::fetch_and(m_data.m_data, rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t and_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::and_fetch(m_data.m_data, rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t operator&=(const bs_t& rhs)
|
||||
{
|
||||
return and_fetch(rhs);
|
||||
}
|
||||
|
||||
bs_t fetch_xor(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::fetch_xor(m_data.m_data, rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t xor_fetch(const bs_t& rhs)
|
||||
{
|
||||
return bs_t(0, atomic_storage<under>::xor_fetch(m_data.m_data, rhs.m_data));
|
||||
}
|
||||
|
||||
bs_t operator^=(const bs_t& rhs)
|
||||
{
|
||||
return xor_fetch(rhs);
|
||||
}
|
||||
|
||||
auto fetch_or(const bs_t&) = delete;
|
||||
auto or_fetch(const bs_t&) = delete;
|
||||
auto operator|=(const bs_t&) = delete;
|
||||
|
||||
bool test_and_set(T rhs)
|
||||
{
|
||||
return atomic_storage<under>::bts(m_data.m_data, static_cast<uint>(static_cast<under>(rhs)));
|
||||
}
|
||||
|
||||
bool test_and_reset(T rhs)
|
||||
{
|
||||
return atomic_storage<under>::btr(m_data.m_data, static_cast<uint>(static_cast<under>(rhs)));
|
||||
}
|
||||
|
||||
bool test_and_invert(T rhs)
|
||||
{
|
||||
return atomic_storage<under>::btc(m_data.m_data, static_cast<uint>(static_cast<under>(rhs)));
|
||||
}
|
||||
|
||||
bool bit_test_set(uint bit) = delete;
|
||||
bool bit_test_reset(uint bit) = delete;
|
||||
bool bit_test_invert(uint bit) = delete;
|
||||
|
||||
bool all_of(bs_t arg) const
|
||||
{
|
||||
return base::load().all_of(arg);
|
||||
}
|
||||
|
||||
bool none_of(bs_t arg) const
|
||||
{
|
||||
return base::load().none_of(arg);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct fmt_unveil<bs_t<T>>
|
||||
{
|
||||
// Format as is
|
||||
using type = bs_t<T>;
|
||||
|
||||
static inline u64 get(const bs_t<T>& bitset)
|
||||
{
|
||||
return static_cast<std::underlying_type_t<T>>(bitset);
|
||||
}
|
||||
};
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <orbis/evf.hpp>
|
||||
#include <orbis/utils/Rc.hpp>
|
||||
#include <rx/Rc.hpp>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ struct AudioOutChannelInfo {
|
|||
std::int32_t port{};
|
||||
std::int32_t idControl{};
|
||||
std::int32_t channel{};
|
||||
orbis::Ref<orbis::EventFlag> evf;
|
||||
rx::Ref<orbis::EventFlag> evf;
|
||||
};
|
||||
|
||||
struct AudioOutParams {
|
||||
|
|
@ -38,7 +38,7 @@ struct AudioOutParams {
|
|||
std::uint32_t sampleLength{};
|
||||
};
|
||||
|
||||
struct AudioOut : orbis::RcBase {
|
||||
struct AudioOut : rx::RcBase {
|
||||
std::mutex thrMtx;
|
||||
std::mutex soxMtx;
|
||||
std::vector<std::thread> threads;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include <cstdlib>
|
||||
#include <orbis/sys/sysproto.hpp>
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ enum class AudioFormat : std::uint32_t {
|
|||
S32_LE = 0x1000,
|
||||
};
|
||||
|
||||
class AudioDevice : public orbis::RcBase {
|
||||
class AudioDevice : public rx::RcBase {
|
||||
protected:
|
||||
bool mWorking = false;
|
||||
AudioFormat mFormat{};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
#include "shader/spv.hpp"
|
||||
#include "shaders/rdna-semantic-spirv.hpp"
|
||||
#include "vk.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <fcntl.h>
|
||||
|
|
@ -26,6 +25,9 @@
|
|||
#include <sys/mman.h>
|
||||
#include <thread>
|
||||
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
using namespace amdgpu;
|
||||
|
||||
static VKAPI_ATTR VkBool32 VKAPI_CALL debugUtilsMessageCallback(
|
||||
|
|
|
|||
|
|
@ -5,17 +5,18 @@
|
|||
#include "Pipe.hpp"
|
||||
#include "amdgpu/tiler_vulkan.hpp"
|
||||
#include "orbis/KernelAllocator.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "rx/MemoryTable.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include "shader/SemanticInfo.hpp"
|
||||
#include "shader/SpvConverter.hpp"
|
||||
#include "shader/gcn.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <array>
|
||||
#include <thread>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
namespace amdgpu {
|
||||
|
||||
enum : std::uint8_t {
|
||||
|
|
@ -62,7 +63,7 @@ struct RemoteMemory {
|
|||
}
|
||||
};
|
||||
|
||||
struct Device : orbis::RcBase, DeviceContext {
|
||||
struct Device : rx::RcBase, DeviceContext {
|
||||
static constexpr auto kComputePipeCount = 8;
|
||||
static constexpr auto kGfxPipeCount = 2;
|
||||
|
||||
|
|
@ -81,7 +82,7 @@ struct Device : orbis::RcBase, DeviceContext {
|
|||
CommandPipe commandPipe;
|
||||
FlipPipeline flipPipeline;
|
||||
|
||||
orbis::shared_mutex writeCommandMtx;
|
||||
rx::shared_mutex writeCommandMtx;
|
||||
uint32_t imageIndex = 0;
|
||||
bool isImageAcquired = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "orbis/utils/SharedAtomic.hpp"
|
||||
#include "rx/SharedAtomic.hpp"
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
|
|
@ -69,9 +69,9 @@ struct DeviceContext {
|
|||
|
||||
PadState kbPadState{};
|
||||
std::atomic<std::uint64_t> cpuCacheCommands[kMaxProcessCount][4]{};
|
||||
orbis::shared_atomic32 cpuCacheCommandsIdle[kMaxProcessCount]{};
|
||||
orbis::shared_atomic32 gpuCacheCommand[kMaxProcessCount]{};
|
||||
orbis::shared_atomic32 gpuCacheCommandIdle{};
|
||||
rx::shared_atomic32 cpuCacheCommandsIdle[kMaxProcessCount]{};
|
||||
rx::shared_atomic32 gpuCacheCommand[kMaxProcessCount]{};
|
||||
rx::shared_atomic32 gpuCacheCommandIdle{};
|
||||
std::atomic<std::uint8_t> *cachePages[kMaxProcessCount]{};
|
||||
|
||||
volatile std::uint32_t flipBuffer[kMaxProcessCount];
|
||||
|
|
@ -79,4 +79,4 @@ struct DeviceContext {
|
|||
volatile std::uint64_t flipCount[kMaxProcessCount];
|
||||
volatile std::uint64_t bufferInUseAddress[kMaxProcessCount];
|
||||
};
|
||||
} // namespace amdgpu
|
||||
} // namespace amdgpu
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
using namespace amdgpu;
|
||||
|
||||
DeviceCtl::DeviceCtl() noexcept = default;
|
||||
DeviceCtl::DeviceCtl(orbis::Ref<orbis::RcBase> device) noexcept
|
||||
DeviceCtl::DeviceCtl(rx::Ref<rx::RcBase> device) noexcept
|
||||
: mDevice(device.rawStaticCast<Device>()) {}
|
||||
DeviceCtl::DeviceCtl(DeviceCtl &&) noexcept = default;
|
||||
DeviceCtl::DeviceCtl(const DeviceCtl &) = default;
|
||||
|
|
@ -28,7 +28,7 @@ DeviceCtl DeviceCtl::createDevice() {
|
|||
}
|
||||
|
||||
DeviceContext &DeviceCtl::getContext() { return *mDevice.get(); }
|
||||
orbis::Ref<orbis::RcBase> DeviceCtl::getOpaque() { return mDevice; }
|
||||
rx::Ref<rx::RcBase> DeviceCtl::getOpaque() { return mDevice; }
|
||||
|
||||
void DeviceCtl::submitGfxCommand(int gfxPipe, int vmId,
|
||||
std::span<const std::uint32_t> command) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "DeviceContext.hpp"
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ namespace amdgpu {
|
|||
class Device;
|
||||
|
||||
class DeviceCtl {
|
||||
orbis::Ref<Device> mDevice;
|
||||
rx::Ref<Device> mDevice;
|
||||
|
||||
public:
|
||||
DeviceCtl() noexcept;
|
||||
DeviceCtl(orbis::Ref<orbis::RcBase> device) noexcept;
|
||||
DeviceCtl(rx::Ref<rx::RcBase> device) noexcept;
|
||||
DeviceCtl(DeviceCtl &&) noexcept;
|
||||
DeviceCtl(const DeviceCtl &);
|
||||
DeviceCtl &operator=(DeviceCtl &&) noexcept;
|
||||
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
static DeviceCtl createDevice();
|
||||
DeviceContext &getContext();
|
||||
orbis::Ref<orbis::RcBase> getOpaque();
|
||||
rx::Ref<rx::RcBase> getOpaque();
|
||||
|
||||
void submitGfxCommand(int gfxPipe, int vmId,
|
||||
std::span<const std::uint32_t> command);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ void ComputePipe::setIndirectRing(int queueId, int indirectLevel, Ring ring) {
|
|||
}
|
||||
|
||||
void ComputePipe::mapQueue(int queueId, Ring ring,
|
||||
std::unique_lock<orbis::shared_mutex> &lock) {
|
||||
std::unique_lock<rx::shared_mutex> &lock) {
|
||||
if (ring.indirectLevel < 0 || ring.indirectLevel > 1) {
|
||||
rx::die("unexpected compute ring indirect level {}", ring.indirectLevel);
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ void ComputePipe::mapQueue(int queueId, Ring ring,
|
|||
}
|
||||
|
||||
void ComputePipe::waitForIdle(int queueId,
|
||||
std::unique_lock<orbis::shared_mutex> &lock) {
|
||||
std::unique_lock<rx::shared_mutex> &lock) {
|
||||
auto &ring = queues[1][queueId];
|
||||
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "Registers.hpp"
|
||||
#include "Scheduler.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
|
@ -42,7 +42,7 @@ struct ComputePipe {
|
|||
|
||||
using CommandHandler = bool (ComputePipe::*)(Ring &);
|
||||
CommandHandler commandHandlers[255];
|
||||
orbis::shared_mutex queueMtx[kQueueCount];
|
||||
rx::shared_mutex queueMtx[kQueueCount];
|
||||
int index;
|
||||
int currentQueueId;
|
||||
Ring queues[kRingsPerQueue][kQueueCount];
|
||||
|
|
@ -54,12 +54,12 @@ struct ComputePipe {
|
|||
bool processRing(Ring &ring);
|
||||
void setIndirectRing(int queueId, int level, Ring ring);
|
||||
void mapQueue(int queueId, Ring ring,
|
||||
std::unique_lock<orbis::shared_mutex> &lock);
|
||||
void waitForIdle(int queueId, std::unique_lock<orbis::shared_mutex> &lock);
|
||||
std::unique_lock<rx::shared_mutex> &lock);
|
||||
void waitForIdle(int queueId, std::unique_lock<rx::shared_mutex> &lock);
|
||||
void submit(int queueId, std::uint32_t offset);
|
||||
|
||||
std::unique_lock<orbis::shared_mutex> lockQueue(int queueId) {
|
||||
return std::unique_lock<orbis::shared_mutex>(queueMtx[queueId]);
|
||||
std::unique_lock<rx::shared_mutex> lockQueue(int queueId) {
|
||||
return std::unique_lock<rx::shared_mutex>(queueMtx[queueId]);
|
||||
}
|
||||
|
||||
bool setShReg(Ring &ring);
|
||||
|
|
@ -109,7 +109,7 @@ struct GraphicsPipe {
|
|||
Ring deQueues[3];
|
||||
Ring ceQueue;
|
||||
|
||||
orbis::shared_mutex eopFlipMtx;
|
||||
rx::shared_mutex eopFlipMtx;
|
||||
std::uint32_t eopFlipRequestCount{0};
|
||||
EopFlipRequest eopFlipRequests[kEopFlipRequestMax];
|
||||
|
||||
|
|
|
|||
|
|
@ -704,8 +704,8 @@ IoDevice *createHostIoDevice(orbis::kstring hostPath,
|
|||
return orbis::knew<HostFsDevice>(std::move(hostPath), std::move(virtualPath));
|
||||
}
|
||||
|
||||
orbis::Ref<orbis::File> wrapSocket(int hostFd, orbis::kstring name, int dom,
|
||||
int type, int prot) {
|
||||
rx::Ref<orbis::File> wrapSocket(int hostFd, orbis::kstring name, int dom,
|
||||
int type, int prot) {
|
||||
auto s = orbis::knew<SocketFile>();
|
||||
s->name = std::move(name);
|
||||
s->dom = dom;
|
||||
|
|
@ -716,9 +716,8 @@ orbis::Ref<orbis::File> wrapSocket(int hostFd, orbis::kstring name, int dom,
|
|||
return s;
|
||||
}
|
||||
|
||||
orbis::ErrorCode createSocket(orbis::Ref<orbis::File> *file,
|
||||
orbis::kstring name, int dom, int type,
|
||||
int prot) {
|
||||
orbis::ErrorCode createSocket(rx::Ref<orbis::File> *file, orbis::kstring name,
|
||||
int dom, int type, int prot) {
|
||||
// ORBIS_LOG_ERROR(__FUNCTION__, name, dom, type, prot);
|
||||
// *file = orbis::createPipe();
|
||||
// return {};
|
||||
|
|
@ -771,7 +770,7 @@ toRealPath(const std::filesystem::path &inp) {
|
|||
return result;
|
||||
}
|
||||
|
||||
orbis::ErrorCode HostFsDevice::open(orbis::Ref<orbis::File> *file,
|
||||
orbis::ErrorCode HostFsDevice::open(rx::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode, orbis::Thread *thread) {
|
||||
auto realPath = hostPath + "/" + path;
|
||||
|
|
@ -938,7 +937,7 @@ orbis::ErrorCode HostFsDevice::rename(const char *from, const char *to,
|
|||
return convertErrorCode(ec);
|
||||
}
|
||||
|
||||
orbis::File *createHostFile(int hostFd, orbis::Ref<IoDevice> device,
|
||||
orbis::File *createHostFile(int hostFd, rx::Ref<IoDevice> device,
|
||||
bool alignTruncate) {
|
||||
auto newFile = orbis::knew<HostFile>();
|
||||
newFile->hostFd = hostFd;
|
||||
|
|
@ -951,7 +950,7 @@ orbis::File *createHostFile(int hostFd, orbis::Ref<IoDevice> device,
|
|||
struct FdWrapDevice : public IoDevice {
|
||||
int fd;
|
||||
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override {
|
||||
*file = createHostFile(fd, this);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "orbis/KernelAllocator.hpp"
|
||||
#include "orbis/file.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include <cstdint>
|
||||
#include <system_error>
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ enum OpenFlags {
|
|||
kOpenFlagDirectory = 0x20000,
|
||||
};
|
||||
|
||||
struct IoDevice : orbis::RcBase {
|
||||
virtual orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
struct IoDevice : rx::RcBase {
|
||||
virtual orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) = 0;
|
||||
virtual orbis::ErrorCode unlink(const char *path, bool recursive,
|
||||
|
|
@ -56,7 +56,7 @@ struct HostFsDevice : IoDevice {
|
|||
|
||||
HostFsDevice(orbis::kstring path, orbis::kstring virtualPath)
|
||||
: hostPath(std::move(path)), virtualPath(std::move(virtualPath)) {}
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
orbis::ErrorCode unlink(const char *path, bool recursive,
|
||||
|
|
@ -74,10 +74,10 @@ orbis::ErrorCode convertErrorCode(const std::error_code &code);
|
|||
orbis::ErrorCode convertErrno();
|
||||
IoDevice *createHostIoDevice(orbis::kstring hostPath,
|
||||
orbis::kstring virtualPath);
|
||||
orbis::Ref<orbis::File> wrapSocket(int hostFd, orbis::kstring name, int dom,
|
||||
int type, int prot);
|
||||
orbis::ErrorCode createSocket(orbis::Ref<orbis::File> *file,
|
||||
orbis::kstring name, int dom, int type, int prot);
|
||||
orbis::File *createHostFile(int hostFd, orbis::Ref<IoDevice> device,
|
||||
rx::Ref<orbis::File> wrapSocket(int hostFd, orbis::kstring name, int dom,
|
||||
int type, int prot);
|
||||
orbis::ErrorCode createSocket(rx::Ref<orbis::File> *file, orbis::kstring name,
|
||||
int dom, int type, int prot);
|
||||
orbis::File *createHostFile(int hostFd, rx::Ref<IoDevice> device,
|
||||
bool alignTruncate = false);
|
||||
IoDevice *createFdWrapDevice(int fd);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ static const orbis::FileOps fileOps = {
|
|||
};
|
||||
|
||||
struct A53IoDevice : IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override {
|
||||
auto newFile = orbis::knew<A53IoFile>();
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ enum {
|
|||
};
|
||||
|
||||
struct AjmDevice : IoDevice {
|
||||
orbis::shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
orbis::uint32_t batchId = 1; // temp
|
||||
|
||||
orbis::uint32_t instanceIds[AJM_CODEC_COUNT]{};
|
||||
orbis::uint32_t unimplementedInstanceId = 0;
|
||||
orbis::kmap<orbis::int32_t, Instance> instanceMap;
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
};
|
||||
|
|
@ -778,9 +778,9 @@ static const orbis::FileOps fileOps = {
|
|||
.ioctl = ajm_ioctl,
|
||||
};
|
||||
|
||||
orbis::ErrorCode AjmDevice::open(orbis::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode, orbis::Thread *thread) {
|
||||
orbis::ErrorCode AjmDevice::open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) {
|
||||
auto newFile = orbis::knew<AjmFile>();
|
||||
newFile->ops = &fileOps;
|
||||
newFile->device = this;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "libatrac9/libatrac9.h"
|
||||
#include "orbis-config.hpp"
|
||||
#include "orbis/KernelAllocator.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
// #include "orbis/utils/Logs.hpp"
|
||||
#include <cstdint>
|
||||
extern "C" {
|
||||
|
|
@ -326,7 +326,7 @@ struct AJMAACCodecInfoSideband {
|
|||
};
|
||||
|
||||
struct Instance {
|
||||
orbis::shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
AJMCodecs codec;
|
||||
AJMChannels maxChannels;
|
||||
AJMFormat outputFormat;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "orbis/thread/Thread.hpp"
|
||||
#include "orbis/uio.hpp"
|
||||
#include "orbis/utils/Logs.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include <bits/types/struct_iovec.h>
|
||||
// #include <rx/hexdump.hpp>
|
||||
|
||||
|
|
@ -29,12 +29,12 @@ struct AoutFile : orbis::File {};
|
|||
|
||||
struct AoutDevice : public IoDevice {
|
||||
std::int8_t id;
|
||||
orbis::Ref<AudioDevice> audioDevice;
|
||||
rx::Ref<AudioDevice> audioDevice;
|
||||
|
||||
AoutDevice(std::int8_t id, AudioDevice *audioDevice)
|
||||
: id(id), audioDevice(audioDevice) {}
|
||||
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
};
|
||||
|
|
@ -192,9 +192,9 @@ static const orbis::FileOps fileOps = {
|
|||
.write = aout_write,
|
||||
};
|
||||
|
||||
orbis::ErrorCode AoutDevice::open(orbis::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode, orbis::Thread *thread) {
|
||||
orbis::ErrorCode AoutDevice::open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) {
|
||||
ORBIS_LOG_FATAL("aout device open", path, flags, mode);
|
||||
auto newFile = orbis::knew<AoutFile>();
|
||||
newFile->ops = &fileOps;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ static const orbis::FileOps fileOps = {
|
|||
};
|
||||
|
||||
struct AVControlDevice : IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override {
|
||||
auto newFile = orbis::knew<AVControlFile>();
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ static const orbis::FileOps ops = {
|
|||
.mmap = blockpool_mmap,
|
||||
};
|
||||
|
||||
orbis::ErrorCode BlockPoolDevice::open(orbis::Ref<orbis::File> *file,
|
||||
orbis::ErrorCode BlockPoolDevice::open(rx::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode,
|
||||
orbis::Thread *thread) {
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
#include "io-device.hpp"
|
||||
#include "orbis/error/ErrorCode.hpp"
|
||||
#include "orbis/file.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "rx/MemoryTable.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
struct BlockPoolDevice : public IoDevice {
|
||||
orbis::shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
rx::MemoryAreaTable<> pool;
|
||||
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
orbis::ErrorCode map(void **address, std::uint64_t len, std::int32_t prot,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ static const orbis::FileOps fileOps = {
|
|||
};
|
||||
|
||||
struct BtDevice : IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override {
|
||||
auto newFile = orbis::knew<BtFile>();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static const orbis::FileOps fileOps = {
|
|||
};
|
||||
|
||||
struct CameraDevice : IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override {
|
||||
auto newFile = orbis::knew<CameraFile>();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "orbis/utils/Logs.hpp"
|
||||
|
||||
struct CaymanRegDevice : IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
};
|
||||
|
|
@ -22,7 +22,7 @@ static const orbis::FileOps fileOps = {
|
|||
.ioctl = cayman_reg_ioctl,
|
||||
};
|
||||
|
||||
orbis::ErrorCode CaymanRegDevice::open(orbis::Ref<orbis::File> *file,
|
||||
orbis::ErrorCode CaymanRegDevice::open(rx::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode,
|
||||
orbis::Thread *thread) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ static const orbis::FileOps fileOps = {
|
|||
};
|
||||
|
||||
struct CdDevice : IoDevice {
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override {
|
||||
auto newFile = orbis::knew<CdFile>();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ struct ConsoleDevice : IoDevice {
|
|||
ConsoleDevice(int inputFd, int outputFd)
|
||||
: inputFd(inputFd), outputFd(outputFd) {}
|
||||
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
};
|
||||
|
|
@ -64,7 +64,7 @@ static const orbis::FileOps fileOps = {
|
|||
.write = console_write,
|
||||
};
|
||||
|
||||
orbis::ErrorCode ConsoleDevice::open(orbis::Ref<orbis::File> *file,
|
||||
orbis::ErrorCode ConsoleDevice::open(rx::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode,
|
||||
orbis::Thread *thread) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include "rx/mem.hpp"
|
||||
#include "rx/watchdog.hpp"
|
||||
#include "vm.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <mutex>
|
||||
|
|
@ -627,9 +626,9 @@ static void createGpu() {
|
|||
}
|
||||
}
|
||||
|
||||
orbis::ErrorCode DceDevice::open(orbis::Ref<orbis::File> *file,
|
||||
const char *path, std::uint32_t flags,
|
||||
std::uint32_t mode, orbis::Thread *thread) {
|
||||
orbis::ErrorCode DceDevice::open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) {
|
||||
auto newFile = orbis::knew<DceFile>();
|
||||
newFile->device = this;
|
||||
newFile->ops = &ops;
|
||||
|
|
|
|||
|
|
@ -5,18 +5,18 @@
|
|||
#include "orbis/error/ErrorCode.hpp"
|
||||
#include "orbis/file.hpp"
|
||||
#include "orbis/thread/Process.hpp"
|
||||
#include "orbis/utils/Rc.hpp"
|
||||
#include "orbis/utils/SharedMutex.hpp"
|
||||
#include "rx/Rc.hpp"
|
||||
#include "rx/SharedMutex.hpp"
|
||||
|
||||
static constexpr auto kVmIdCount = 6;
|
||||
|
||||
struct DceDevice : IoDevice {
|
||||
orbis::shared_mutex mtx;
|
||||
rx::shared_mutex mtx;
|
||||
std::uint32_t eopCount = 0;
|
||||
std::uint32_t freeVmIds = (1 << (kVmIdCount + 1)) - 1;
|
||||
orbis::uint64_t dmemOffset = ~static_cast<std::uint64_t>(0);
|
||||
|
||||
orbis::ErrorCode open(orbis::Ref<orbis::File> *file, const char *path,
|
||||
orbis::ErrorCode open(rx::Ref<orbis::File> *file, const char *path,
|
||||
std::uint32_t flags, std::uint32_t mode,
|
||||
orbis::Thread *thread) override;
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue