early-access version 3941

This commit is contained in:
pineappleEA 2023-10-22 02:31:32 +02:00
parent e3b48b1c46
commit 6ae374100b
6 changed files with 77 additions and 48 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3940. This is the source code for early-access 3941.
## Legal Notice ## Legal Notice

View File

@ -11,6 +11,7 @@
#include <mach/mach.h> #include <mach/mach.h>
#elif defined(_WIN32) #elif defined(_WIN32)
#include <windows.h> #include <windows.h>
#include "common/string_util.h"
#else #else
#if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__) #if defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <pthread_np.h> #include <pthread_np.h>
@ -82,29 +83,8 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
#ifdef _MSC_VER #ifdef _MSC_VER
// Sets the debugger-visible name of the current thread. // Sets the debugger-visible name of the current thread.
// Uses trick documented in:
// https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-set-a-thread-name-in-native-code
void SetCurrentThreadName(const char* name) { void SetCurrentThreadName(const char* name) {
static const DWORD MS_VC_EXCEPTION = 0x406D1388; SetThreadDescription(GetCurrentThread(), UTF8ToUTF16W(name).data());
#pragma pack(push, 8)
struct THREADNAME_INFO {
DWORD dwType; // must be 0x1000
LPCSTR szName; // pointer to name (in user addr space)
DWORD dwThreadID; // thread ID (-1=caller thread)
DWORD dwFlags; // reserved for future use, must be zero
} info;
#pragma pack(pop)
info.dwType = 0x1000;
info.szName = name;
info.dwThreadID = std::numeric_limits<DWORD>::max();
info.dwFlags = 0;
__try {
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
} __except (EXCEPTION_CONTINUE_EXECUTION) {
}
} }
#else // !MSVC_VER, so must be POSIX threads #else // !MSVC_VER, so must be POSIX threads

View File

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/logging/log.h"
#include "core/file_sys/system_archive/system_version.h" #include "core/file_sys/system_archive/system_version.h"
#include "core/file_sys/vfs_vector.h" #include "core/file_sys/vfs_vector.h"
#include "core/hle/api_version.h" #include "core/hle/api_version.h"
@ -12,6 +13,9 @@ std::string GetLongDisplayVersion() {
} }
VirtualDir SystemVersion() { VirtualDir SystemVersion() {
LOG_WARNING(Common_Filesystem, "called - Using hardcoded firmware version '{}'",
GetLongDisplayVersion());
VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file"); VirtualFile file = std::make_shared<VectorVfsFile>(std::vector<u8>(0x100), "file");
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0); file->WriteObject(HLE::ApiVersion::HOS_VERSION_MAJOR, 0);
file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1); file->WriteObject(HLE::ApiVersion::HOS_VERSION_MINOR, 1);

View File

@ -9,6 +9,35 @@
namespace Service::PTM { namespace Service::PTM {
enum class Location : u8 {
Internal,
External,
};
class ISession : public ServiceFramework<ISession> {
public:
explicit ISession(Core::System& system_) : ServiceFramework{system_, "ISession"} {
// clang-format off
static const FunctionInfo functions[] = {
{0, nullptr, "GetTemperatureRange"},
{2, nullptr, "SetMeasurementMode"},
{4, &ISession::GetTemperature, "GetTemperature"},
};
// clang-format on
RegisterHandlers(functions);
}
private:
void GetTemperature(HLERequestContext& ctx) {
constexpr f32 temperature = 35;
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(temperature);
}
};
TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} { TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -16,7 +45,7 @@ TS::TS(Core::System& system_) : ServiceFramework{system_, "ts"} {
{1, &TS::GetTemperature, "GetTemperature"}, {1, &TS::GetTemperature, "GetTemperature"},
{2, nullptr, "SetMeasurementMode"}, {2, nullptr, "SetMeasurementMode"},
{3, &TS::GetTemperatureMilliC, "GetTemperatureMilliC"}, {3, &TS::GetTemperatureMilliC, "GetTemperatureMilliC"},
{4, nullptr, "OpenSession"}, {4, &TS::OpenSession, "OpenSession"},
}; };
// clang-format on // clang-format on
@ -47,4 +76,13 @@ void TS::GetTemperatureMilliC(HLERequestContext& ctx) {
rb.Push(temperature); rb.Push(temperature);
} }
void TS::OpenSession(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
[[maybe_unused]] const u32 device_code = rp.Pop<u32>();
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
rb.Push(ResultSuccess);
rb.PushIpcInterface<ISession>(system);
}
} // namespace Service::PTM } // namespace Service::PTM

View File

@ -14,13 +14,9 @@ public:
~TS() override; ~TS() override;
private: private:
enum class Location : u8 {
Internal,
External,
};
void GetTemperature(HLERequestContext& ctx); void GetTemperature(HLERequestContext& ctx);
void GetTemperatureMilliC(HLERequestContext& ctx); void GetTemperatureMilliC(HLERequestContext& ctx);
void OpenSession(HLERequestContext& ctx);
}; };
} // namespace Service::PTM } // namespace Service::PTM

View File

@ -5,8 +5,13 @@
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/settings.h" #include "common/settings.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "core/core.h"
#include "core/file_sys/content_archive.h"
#include "core/file_sys/errors.h" #include "core/file_sys/errors.h"
#include "core/file_sys/system_archive/system_version.h" #include "core/file_sys/nca_metadata.h"
#include "core/file_sys/registered_cache.h"
#include "core/file_sys/romfs.h"
#include "core/file_sys/system_archive/system_archive.h"
#include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ipc_helpers.h"
#include "core/hle/service/set/set.h" #include "core/hle/service/set/set.h"
@ -22,18 +27,30 @@ enum class GetFirmwareVersionType {
Version2, Version2,
}; };
void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type) { void GetFirmwareVersionImpl(Core::System& system, HLERequestContext& ctx,
LOG_WARNING(Service_SET, "called - Using hardcoded firmware version '{}'", GetFirmwareVersionType type) {
FileSys::SystemArchive::GetLongDisplayVersion());
ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100, ASSERT_MSG(ctx.GetWriteBufferSize() == 0x100,
"FirmwareVersion output buffer must be 0x100 bytes in size!"); "FirmwareVersion output buffer must be 0x100 bytes in size!");
// Instead of using the normal procedure of checking for the real system archive and if it constexpr u64 FirmwareVersionSystemDataId = 0x0100000000000809;
// doesn't exist, synthesizing one, I feel that that would lead to strange bugs because a auto& fsc = system.GetFileSystemController();
// used is using a really old or really new SystemVersion title. The synthesized one ensures
// consistence (currently reports as 5.1.0-0.0) // Attempt to load version data from disk
const auto archive = FileSys::SystemArchive::SystemVersion(); const FileSys::RegisteredCache* bis_system{};
std::unique_ptr<FileSys::NCA> nca{};
FileSys::VirtualDir romfs{};
bis_system = fsc.GetSystemNANDContents();
if (bis_system) {
nca = bis_system->GetEntry(FirmwareVersionSystemDataId, FileSys::ContentRecordType::Data);
}
if (nca) {
romfs = FileSys::ExtractRomFS(nca->GetRomFS());
}
if (!romfs) {
romfs = FileSys::ExtractRomFS(
FileSys::SystemArchive::SynthesizeSystemArchive(FirmwareVersionSystemDataId));
}
const auto early_exit_failure = [&ctx](std::string_view desc, Result code) { const auto early_exit_failure = [&ctx](std::string_view desc, Result code) {
LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).", LOG_ERROR(Service_SET, "General failure while attempting to resolve firmware version ({}).",
@ -42,13 +59,7 @@ void GetFirmwareVersionImpl(HLERequestContext& ctx, GetFirmwareVersionType type)
rb.Push(code); rb.Push(code);
}; };
if (archive == nullptr) { const auto ver_file = romfs->GetFile("file");
early_exit_failure("The system version archive couldn't be synthesized.",
FileSys::ERROR_FAILED_MOUNT_ARCHIVE);
return;
}
const auto ver_file = archive->GetFile("file");
if (ver_file == nullptr) { if (ver_file == nullptr) {
early_exit_failure("The system version archive didn't contain the file 'file'.", early_exit_failure("The system version archive didn't contain the file 'file'.",
FileSys::ERROR_INVALID_ARGUMENT); FileSys::ERROR_INVALID_ARGUMENT);
@ -87,12 +98,12 @@ void SET_SYS::SetLanguageCode(HLERequestContext& ctx) {
void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) { void SET_SYS::GetFirmwareVersion(HLERequestContext& ctx) {
LOG_DEBUG(Service_SET, "called"); LOG_DEBUG(Service_SET, "called");
GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version1); GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version1);
} }
void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) { void SET_SYS::GetFirmwareVersion2(HLERequestContext& ctx) {
LOG_DEBUG(Service_SET, "called"); LOG_DEBUG(Service_SET, "called");
GetFirmwareVersionImpl(ctx, GetFirmwareVersionType::Version2); GetFirmwareVersionImpl(system, ctx, GetFirmwareVersionType::Version2);
} }
void SET_SYS::GetAccountSettings(HLERequestContext& ctx) { void SET_SYS::GetAccountSettings(HLERequestContext& ctx) {