mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-23 00:50:42 +01:00
replace std::abort with rx::die
This commit is contained in:
parent
62465b9001
commit
ea28a6c13e
|
|
@ -321,7 +321,7 @@ orbis::SysResult orbis::sysIpmiSendConnectResult(Thread *thread,
|
|||
|
||||
if (client == nullptr) {
|
||||
ORBIS_LOG_FATAL(__FUNCTION__);
|
||||
std::abort();
|
||||
rx::die("client is null");
|
||||
}
|
||||
|
||||
sint status;
|
||||
|
|
|
|||
|
|
@ -178,10 +178,7 @@ static orbis::SysResult doPltRelocation(orbis::Process *process,
|
|||
}
|
||||
}
|
||||
|
||||
std::fprintf(stderr, "unimplemented relocation type %u\n",
|
||||
(unsigned)rel.relType);
|
||||
std::abort();
|
||||
return {};
|
||||
rx::die("unimplemented relocation type {}", rel.relType);
|
||||
}
|
||||
|
||||
static orbis::SysResult doRelocation(orbis::Process *process,
|
||||
|
|
@ -359,10 +356,7 @@ static orbis::SysResult doRelocation(orbis::Process *process,
|
|||
}
|
||||
}
|
||||
|
||||
std::fprintf(stderr, "unimplemented relocation type %u\n",
|
||||
(unsigned)rel.relType);
|
||||
std::abort();
|
||||
return {};
|
||||
rx::die("unimplemented relocation type {}", rel.relType);
|
||||
}
|
||||
|
||||
orbis::SysResult orbis::Module::relocate(Process *process) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "orbis-config.hpp"
|
||||
#include "rx/EnumBitSet.hpp"
|
||||
#include "rx/die.hpp"
|
||||
#include "rx/format.hpp"
|
||||
#include "sys/syscall.hpp"
|
||||
#include "sys/sysentry.hpp"
|
||||
|
|
@ -54,9 +55,10 @@ void orbis::syscall_entry(Thread *thread) {
|
|||
std::memcpy(args, regsptr,
|
||||
std::min(regcnt, sysent.narg) * sizeof(uint64_t));
|
||||
if (sysent.narg > regcnt) {
|
||||
if (sysent.narg > std::ssize(args)) {
|
||||
std::abort();
|
||||
}
|
||||
rx::dieIf(sysent.narg > std::ssize(args),
|
||||
"syscall {} uses unexpected number of "
|
||||
"arguments, narg = {}",
|
||||
syscall_num, sysent.narg);
|
||||
|
||||
error = int(
|
||||
ureadRaw(args + regcnt,
|
||||
|
|
|
|||
|
|
@ -140,14 +140,14 @@ uint UmtxChain::notify_all(const UmtxKey &key) {
|
|||
orbis::ErrorCode orbis::umtx_lock_umtx(Thread *thread, ptr<umtx> umtx, ulong id,
|
||||
std::uint64_t ut) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, thread->tid, umtx, id, ut);
|
||||
std::abort();
|
||||
rx::die("unimplemented umtx lock");
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::ErrorCode orbis::umtx_unlock_umtx(Thread *thread, ptr<umtx> umtx,
|
||||
ulong id) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, thread->tid, umtx, id);
|
||||
std::abort();
|
||||
rx::die("unimplemented umtx unlock");
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
AudioOut::AudioOut() {
|
||||
if (sox_init() != SOX_SUCCESS) {
|
||||
ORBIS_LOG_FATAL("Failed to initialize sox");
|
||||
std::abort();
|
||||
rx::die("Failed to initialize sox");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,34 +48,29 @@ void AudioOut::channelEntry(AudioOutChannelInfo info) {
|
|||
|
||||
int controlFd = ::open(control_shm_name, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
if (controlFd == -1) {
|
||||
perror("shm_open");
|
||||
std::abort();
|
||||
rx::die("shm_open failed, errc {}", std::errc{errno});
|
||||
}
|
||||
|
||||
struct stat controlStat;
|
||||
if (::fstat(controlFd, &controlStat)) {
|
||||
perror("fstat");
|
||||
std::abort();
|
||||
rx::die("fstat failed, errc {}", std::errc{errno});
|
||||
}
|
||||
|
||||
auto controlPtr = reinterpret_cast<std::uint8_t *>(
|
||||
::mmap(nullptr, controlStat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED,
|
||||
controlFd, 0));
|
||||
if (controlPtr == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
std::abort();
|
||||
rx::die("mmap failed, errc {}", std::errc{errno});
|
||||
}
|
||||
|
||||
int bufferFd = ::open(audio_shm_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (bufferFd == -1) {
|
||||
perror("open");
|
||||
std::abort();
|
||||
rx::die("buffer shm open failed, errc {}", std::errc{errno});
|
||||
}
|
||||
|
||||
struct stat bufferStat;
|
||||
if (::fstat(bufferFd, &bufferStat)) {
|
||||
perror("fstat");
|
||||
std::abort();
|
||||
rx::die("buffer shm fstat failed, errc {}", std::errc{errno});
|
||||
}
|
||||
|
||||
auto audioBuffer = ::mmap(NULL, bufferStat.st_size, PROT_READ | PROT_WRITE,
|
||||
|
|
@ -153,7 +147,7 @@ void AudioOut::channelEntry(AudioOutChannelInfo info) {
|
|||
soxMtx.unlock();
|
||||
|
||||
if (!output) {
|
||||
std::abort();
|
||||
rx::die("sox_open_write failed");
|
||||
}
|
||||
|
||||
std::vector<sox_sample_t> samples(inSamples * inChannels);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "AlsaDevice.hpp"
|
||||
#include "orbis/utils/Logs.hpp"
|
||||
#include "rx/hexdump.hpp"
|
||||
#include "rx/format.hpp"
|
||||
|
||||
void AlsaDevice::start() {
|
||||
if (mWorking) {
|
||||
|
|
@ -19,9 +19,7 @@ void AlsaDevice::start() {
|
|||
break;
|
||||
case AudioFormat::AC3:
|
||||
default:
|
||||
ORBIS_LOG_FATAL("Format is not supported", int(mFormat));
|
||||
std::abort();
|
||||
break;
|
||||
rx::die("Format is not supported, {}", mFormat);
|
||||
}
|
||||
mAlsaFormat = fmt;
|
||||
}
|
||||
|
|
@ -29,60 +27,51 @@ void AlsaDevice::start() {
|
|||
if (auto err =
|
||||
snd_pcm_open(&mPCMHandle, "default", SND_PCM_STREAM_PLAYBACK, 0);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot open audio device", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot open audio device: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_hw_params_malloc(&mHWParams); err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot allocate hardware parameter structure",
|
||||
snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot allocate hardware parameter structure: {}",
|
||||
snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_hw_params_any(mPCMHandle, mHWParams); err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot initialize hardware parameter structure",
|
||||
snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot initialize hardware parameter structure: {}",
|
||||
snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_hw_params_set_rate_resample(mPCMHandle, mHWParams, 0);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot disable rate resampling", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot disable rate resampling: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_hw_params_set_access(mPCMHandle, mHWParams,
|
||||
SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot set access type", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot set access type: {}", snd_strerror(err));
|
||||
}
|
||||
if (auto err =
|
||||
snd_pcm_hw_params_set_format(mPCMHandle, mHWParams, mAlsaFormat);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot set sample format", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot set sample format: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err =
|
||||
snd_pcm_hw_params_set_rate(mPCMHandle, mHWParams, mFrequency, 0);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot set sample rate", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot set sample rate: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err =
|
||||
snd_pcm_hw_params_set_channels(mPCMHandle, mHWParams, mChannels);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set channel count", snd_strerror(err), mChannels);
|
||||
std::abort();
|
||||
rx::die("cannot set channel count: {}", snd_strerror(err), mChannels);
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_hw_params_set_periods(mPCMHandle, mHWParams,
|
||||
mSampleCount * 10, 0);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot set periods count", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot set periods count: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
int frameBytes = snd_pcm_format_physical_width(mAlsaFormat) * mChannels / 8;
|
||||
|
|
@ -109,8 +98,7 @@ void AlsaDevice::start() {
|
|||
}
|
||||
|
||||
if (err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot set buffer size", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot set buffer size: {}", snd_strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -135,8 +123,7 @@ void AlsaDevice::start() {
|
|||
}
|
||||
|
||||
if (err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot set period size", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot set period size: {}", snd_strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,63 +131,52 @@ void AlsaDevice::start() {
|
|||
if (auto err =
|
||||
snd_pcm_hw_params_get_period_size(mHWParams, &periodSize, nullptr);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set parameters", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot set parameters: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
snd_pcm_uframes_t bufferSize;
|
||||
if (auto err = snd_pcm_hw_params_get_buffer_size(mHWParams, &bufferSize);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set parameters", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot set parameters: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
ORBIS_LOG_TODO("period and buffer", periodSize, bufferSize);
|
||||
|
||||
if (auto err = snd_pcm_hw_params(mPCMHandle, mHWParams); err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set parameters", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot set parameters: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_sw_params_malloc(&mSWParams); err < 0) {
|
||||
ORBIS_LOG_FATAL("Cannot allocate software parameter structure",
|
||||
snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("Cannot allocate software parameter structure: {}",
|
||||
snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_sw_params_current(mPCMHandle, mSWParams); err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot sw params current", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot sw params current: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_sw_params_set_start_threshold(mPCMHandle, mSWParams,
|
||||
periodSize);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set start threshold", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot set start threshold: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_sw_params_set_stop_threshold(mPCMHandle, mSWParams,
|
||||
bufferSize);
|
||||
err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set stop threshold", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot set stop threshold: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_sw_params(mPCMHandle, mSWParams); err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot set parameters", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot set parameters: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_nonblock(mPCMHandle, 1); err < 0) {
|
||||
ORBIS_LOG_FATAL("set nonblock mode failed", snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("set nonblock mode failed: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
if (auto err = snd_pcm_prepare(mPCMHandle); err < 0) {
|
||||
ORBIS_LOG_FATAL("cannot prepare audio interface for use",
|
||||
snd_strerror(err));
|
||||
std::abort();
|
||||
rx::die("cannot prepare audio interface for use: {}", snd_strerror(err));
|
||||
}
|
||||
|
||||
mWorking = true;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ enum class AudioFormat : std::uint32_t {
|
|||
S16_LE = 0x10,
|
||||
AC3 = 0x400,
|
||||
S32_LE = 0x1000,
|
||||
_last = S32_LE,
|
||||
};
|
||||
|
||||
class AudioDevice : public rx::RcBase {
|
||||
|
|
|
|||
|
|
@ -9,5 +9,6 @@ std::filesystem::path getShmGuestPath(std::string_view path);
|
|||
void createGpuDevice();
|
||||
void shutdown();
|
||||
void attachProcess(int pid);
|
||||
void attachGpuProcess(int pid);
|
||||
void startWatchdog();
|
||||
} // namespace rx
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ enum class MessageId {
|
|||
};
|
||||
|
||||
static void runGPU() {
|
||||
if (g_gpuPid != 0 || orbis::g_context->gpuDevice != nullptr) {
|
||||
if (g_gpuPid != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -51,26 +51,16 @@ static void runGPU() {
|
|||
}
|
||||
}
|
||||
|
||||
amdgpu::DeviceCtl gpu;
|
||||
{
|
||||
pthread_setname_np(pthread_self(), "rpcsx-gpu");
|
||||
std::lock_guard lock(orbis::g_context->gpuDeviceMtx);
|
||||
if (orbis::g_context->gpuDevice != nullptr) {
|
||||
std::exit(0);
|
||||
}
|
||||
pthread_setname_np(pthread_self(), "rpcsx-gpu");
|
||||
|
||||
int logFd =
|
||||
::open("log-gpu.txt", O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
dup2(logFd, 1);
|
||||
dup2(logFd, 2);
|
||||
::close(logFd);
|
||||
int logFd =
|
||||
::open("log-gpu.txt", O_CREAT | O_RDWR | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||
dup2(logFd, 1);
|
||||
dup2(logFd, 2);
|
||||
::close(logFd);
|
||||
|
||||
gpu = amdgpu::DeviceCtl::createDevice();
|
||||
orbis::g_context->gpuDevice = gpu.getOpaque();
|
||||
}
|
||||
|
||||
gpu.start();
|
||||
std::exit(0);
|
||||
amdgpu::DeviceCtl{orbis::g_context->gpuDevice}.start();
|
||||
std::_Exit(0);
|
||||
}
|
||||
|
||||
static void handleManagementSignal(siginfo_t *info) {
|
||||
|
|
@ -121,6 +111,7 @@ void rx::createGpuDevice() {
|
|||
void rx::shutdown() { kill(g_watchdogPid, SIGQUIT); }
|
||||
|
||||
void rx::attachProcess(int pid) { sendMessage(MessageId::AttachProcess, pid); }
|
||||
void rx::attachGpuProcess(int pid) { g_gpuPid = pid; }
|
||||
|
||||
static void killProcesses(std::vector<int> list) {
|
||||
int iteration = 0;
|
||||
|
|
|
|||
|
|
@ -743,22 +743,19 @@ void ipmi::createShellCoreObjects(orbis::Process *process) {
|
|||
int shmFd =
|
||||
::open(hostPath.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
if (shmFd == -1) {
|
||||
perror("shm_open");
|
||||
std::abort();
|
||||
rx::die("shm_open failed, errc {}", std::errc{ errno });
|
||||
}
|
||||
|
||||
struct stat controlStat;
|
||||
if (::fstat(shmFd, &controlStat)) {
|
||||
perror("fstat");
|
||||
std::abort();
|
||||
rx::die("fstat failed, errc {}", std::errc{errno});
|
||||
}
|
||||
|
||||
auto shmAddress = reinterpret_cast<std::uint8_t *>(
|
||||
::mmap(nullptr, controlStat.st_size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, shmFd, 0));
|
||||
if (shmAddress == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
std::abort();
|
||||
rx::die("mmap failed, errc {}", std::errc{errno});
|
||||
}
|
||||
orbis::g_context->dialogs.emplace_back(shmAddress,
|
||||
controlStat.st_size);
|
||||
|
|
|
|||
|
|
@ -527,7 +527,7 @@ static rx::Ref<orbis::Module> loadModule(ElfFile *elf, orbis::Process *process,
|
|||
|
||||
Elf64_Phdr phdrsStorage[16];
|
||||
if (header.e_phnum > std::size(phdrsStorage)) {
|
||||
std::abort();
|
||||
rx::die("unexpected phnum {}", header.e_phnum);
|
||||
}
|
||||
|
||||
std::memcpy(phdrsStorage, elf->image.data() + header.e_phoff,
|
||||
|
|
@ -1004,7 +1004,7 @@ static rx::Ref<orbis::Module> loadModule(ElfFile *elf, orbis::Process *process,
|
|||
hashPos = moduleLibary.find('#');
|
||||
|
||||
if (hashPos == std::string_view::npos) {
|
||||
std::abort();
|
||||
rx::die("unexpected symbol name {}", fullName);
|
||||
}
|
||||
|
||||
library = moduleLibary.substr(0, hashPos);
|
||||
|
|
|
|||
Loading…
Reference in a new issue