rtc errors (#485)

* rtc errors

* add system libs to cmakelists

* this.[func]

* fix errors

* declaration

* log handle addr

* missed

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
This commit is contained in:
Lizardy 2024-08-20 21:47:17 +00:00 committed by GitHub
parent c60bfbe2a5
commit 32cb3649d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 14 deletions

View File

@ -193,6 +193,7 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/app_content/app_content.h
src/core/libraries/rtc/rtc.cpp
src/core/libraries/rtc/rtc.h
src/core/libraries/rtc/rtc_error.h
src/core/libraries/disc_map/disc_map.cpp
src/core/libraries/disc_map/disc_map.h
src/core/libraries/disc_map/disc_map_codes.h
@ -208,6 +209,11 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/avplayer/avplayer_state.h
src/core/libraries/avplayer/avplayer.cpp
src/core/libraries/avplayer/avplayer.h
src/core/libraries/ngs2/ngs2.cpp
src/core/libraries/ngs2/ngs2.h
src/core/libraries/ngs2/ngs2_error.h
src/core/libraries/ngs2/ngs2_impl.cpp
src/core/libraries/ngs2/ngs2_impl.h
)
set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h

View File

@ -12,22 +12,23 @@ using namespace Libraries::Kernel;
namespace Libraries::Ngs2 {
s32 Ngs2::ReportInvalid(u32 handle_type) const {
s32 Ngs2::ReportInvalid(Ngs2Handle* handle, u32 handle_type) const {
uintptr_t hAddress = reinterpret_cast<uintptr_t>(handle);
switch (handle_type) {
case 1:
LOG_ERROR(Lib_Ngs2, "Invalid system handle {}", this);
LOG_ERROR(Lib_Ngs2, "Invalid system handle {}", hAddress);
return ORBIS_NGS2_ERROR_INVALID_SYSTEM_HANDLE;
case 2:
LOG_ERROR(Lib_Ngs2, "Invalid rack handle {}", this);
LOG_ERROR(Lib_Ngs2, "Invalid rack handle {}", hAddress);
return ORBIS_NGS2_ERROR_INVALID_RACK_HANDLE;
case 4:
LOG_ERROR(Lib_Ngs2, "Invalid voice handle {}", this);
LOG_ERROR(Lib_Ngs2, "Invalid voice handle {}", hAddress);
return ORBIS_NGS2_ERROR_INVALID_VOICE_HANDLE;
case 8:
LOG_ERROR(Lib_Ngs2, "Invalid report handle {}", this);
LOG_ERROR(Lib_Ngs2, "Invalid report handle {}", hAddress);
return ORBIS_NGS2_ERROR_INVALID_REPORT_HANDLE;
default:
LOG_ERROR(Lib_Ngs2, "Invalid handle {}", this);
LOG_ERROR(Lib_Ngs2, "Invalid handle {}", hAddress);
return ORBIS_NGS2_ERROR_INVALID_HANDLE;
}
}
@ -58,24 +59,24 @@ s32 Ngs2::HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut) {
}
}
}
return HandleReportInvalid(handle, hType);
return this->ReportInvalid(handle, hType);
}
s32 Ngs2::HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut) {
if (!handle) {
return HandleReportInvalid(handle, 0);
return this->ReportInvalid(handle, 0);
}
if (handle->selfPointer != handle || !handle->atomicPtr || !handle->dataPointer ||
(~hType & handle->handleType)) {
return HandleReportInvalid(handle, handle->handleType);
return this->ReportInvalid(handle, handle->handleType);
}
std::atomic<u32>* atomic = handle->atomicPtr;
while (true) {
u32 i = atomic->load();
if (i == 0) {
return HandleReportInvalid(handle, handle->handleType);
return this->ReportInvalid(handle, handle->handleType);
}
if (atomic->compare_exchange_strong(i, i + 1)) {
break;
@ -83,7 +84,7 @@ s32 Ngs2::HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut) {
}
if (handleOut) {
*handleOut = handle;
handleOut = handle;
}
return ORBIS_OK;
}

View File

@ -9,7 +9,7 @@ namespace Libraries::Ngs2 {
class Ngs2 {
public:
s32 ReportInvalid(u32 handle_type) const;
s32 ReportInvalid(Ngs2Handle* handle, u32 handle_type) const;
s32 HandleSetup(Ngs2Handle* handle, void* data, std::atomic<u32>* atomic, u32 type, u32 flags);
s32 HandleCleanup(Ngs2Handle* handle, u32 hType, void* dataOut);
s32 HandleEnter(Ngs2Handle* handle, u32 hType, Ngs2Handle* handleOut);

View File

@ -7,6 +7,7 @@
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "rtc.h"
#include "rtc_error.h"
namespace Libraries::Rtc {
@ -123,8 +124,7 @@ int PS4_SYSV_ABI sceRtcGetTick() {
}
int PS4_SYSV_ABI sceRtcGetTickResolution() {
LOG_ERROR(Lib_Rtc, "(STUBBED) called");
return ORBIS_OK;
return 1000000;
}
int PS4_SYSV_ABI sceRtcGetTime_t() {

View File

@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
constexpr int ORBIS_RTC_ERROR_INVALID_PARAMETER = 0x80010602;
constexpr int ORBIS_RTC_ERROR_INVALID_TICK_PARAMETER = 0x80010603;
constexpr int ORBIS_RTC_ERROR_INVALID_DATE_PARAMETER = 0x80010604;
constexpr int ORBIS_RTC_ERROR_NOT_IMPLEMENTED = 0x80010605;
constexpr int ORBIS_RTC_ERROR_INVALID_TIMEZONE_FORMAT = 0x80010607;
constexpr int ORBIS_RTC_ERROR_INVALID_YEARS_PARAMETER = 0x80010621;
constexpr int ORBIS_RTC_ERROR_INVALID_MONTHS_PARAMETER = 0x80010622;
constexpr int ORBIS_RTC_ERROR_INVALID_DAYS_PARAMETER = 0x80010623;
constexpr int ORBIS_RTC_ERROR_INVALID_HOURS_PARAMETER = 0x80010624;
constexpr int ORBIS_RTC_ERROR_INVALID_MINUTES_PARAMETER = 0x80010625;
constexpr int ORBIS_RTC_ERROR_INVALID_SECONDS_PARAMETER = 0x80010626;
constexpr int ORBIS_RTC_ERROR_INVALID_MILLISECONDS_PARAMETER = 0x80010627;