mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-15 15:58:23 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f9944d8968 | |||
| 04ad3bd9e1 | |||
| 9ac2ac8808 | |||
| 3b9a2a3a86 |
@@ -76,6 +76,7 @@ add_library(
|
||||
logging.h
|
||||
lz4_compression.cpp
|
||||
lz4_compression.h
|
||||
make_unique_for_overwrite.h
|
||||
math_util.h
|
||||
memory_detect.cpp
|
||||
memory_detect.h
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace Common {
|
||||
|
||||
template <class T>
|
||||
requires(!std::is_array_v<T>)
|
||||
std::unique_ptr<T> make_unique_for_overwrite() {
|
||||
return std::unique_ptr<T>(new T);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
requires std::is_unbounded_array_v<T>
|
||||
std::unique_ptr<T> make_unique_for_overwrite(std::size_t n) {
|
||||
return std::unique_ptr<T>(new std::remove_extent_t<T>[n]);
|
||||
}
|
||||
|
||||
template <class T, class... Args>
|
||||
requires std::is_bounded_array_v<T>
|
||||
void make_unique_for_overwrite(Args&&...) = delete;
|
||||
|
||||
} // namespace Common
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include <iterator>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
|
||||
#include "common/make_unique_for_overwrite.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
@@ -37,9 +38,8 @@ public:
|
||||
ScratchBuffer() = default;
|
||||
|
||||
explicit ScratchBuffer(size_type initial_capacity)
|
||||
: last_requested_size{initial_capacity}
|
||||
, buffer_capacity{initial_capacity}
|
||||
, buffer{std::make_unique_for_overwrite<T[]>(initial_capacity)} {}
|
||||
: last_requested_size{initial_capacity}, buffer_capacity{initial_capacity},
|
||||
buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
|
||||
|
||||
~ScratchBuffer() = default;
|
||||
ScratchBuffer(const ScratchBuffer&) = delete;
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
/// The previously held data will remain intact.
|
||||
void resize(size_type size) {
|
||||
if (size > buffer_capacity) {
|
||||
auto new_buffer = std::make_unique_for_overwrite<T[]>(size);
|
||||
auto new_buffer = Common::make_unique_for_overwrite<T[]>(size);
|
||||
std::memcpy(new_buffer.get(), buffer.get(), buffer_capacity * sizeof(T));
|
||||
buffer = std::move(new_buffer);
|
||||
buffer_capacity = size;
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
void resize_destructive(size_type size) {
|
||||
if (size > buffer_capacity) {
|
||||
buffer_capacity = size;
|
||||
buffer = std::make_unique_for_overwrite<T[]>(buffer_capacity);
|
||||
buffer = Common::make_unique_for_overwrite<T[]>(buffer_capacity);
|
||||
}
|
||||
last_requested_size = size;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,8 @@ VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::op
|
||||
auto reference = std::make_unique<FileReference>();
|
||||
this->InsertReferenceIntoListLocked(*reference);
|
||||
|
||||
auto file = std::make_shared<RealVfsFile>(*this, std::move(reference), path, perms, size, std::move(parent_path));
|
||||
auto file = std::shared_ptr<RealVfsFile>(
|
||||
new RealVfsFile(*this, std::move(reference), path, perms, size, std::move(parent_path)));
|
||||
cache[path] = file;
|
||||
|
||||
return file;
|
||||
@@ -176,7 +177,7 @@ bool RealVfsFilesystem::DeleteFile(std::string_view path_) {
|
||||
|
||||
VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) {
|
||||
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
|
||||
return std::make_shared<RealVfsDirectory>(*this, path, perms);
|
||||
return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms));
|
||||
}
|
||||
|
||||
VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) {
|
||||
@@ -184,7 +185,7 @@ VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode p
|
||||
if (!FS::CreateDirs(path)) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_shared<RealVfsDirectory>(*this, path, perms);
|
||||
return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms));
|
||||
}
|
||||
|
||||
VirtualDir RealVfsFilesystem::CopyDirectory(std::string_view old_path_,
|
||||
|
||||
@@ -82,9 +82,6 @@ class RealVfsFile : public VfsFile {
|
||||
friend class RealVfsFilesystem;
|
||||
|
||||
public:
|
||||
RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference,
|
||||
const std::string& path, OpenMode perms = OpenMode::Read,
|
||||
std::optional<u64> size = {}, std::optional<std::string> parent_path = {});
|
||||
~RealVfsFile() override;
|
||||
|
||||
std::string GetName() const override;
|
||||
@@ -98,6 +95,9 @@ public:
|
||||
bool Rename(std::string_view name) override;
|
||||
|
||||
private:
|
||||
RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference,
|
||||
const std::string& path, OpenMode perms = OpenMode::Read,
|
||||
std::optional<u64> size = {}, std::optional<std::string> parent_path = {});
|
||||
|
||||
RealVfsFilesystem& base;
|
||||
std::unique_ptr<FileReference> reference;
|
||||
@@ -113,8 +113,6 @@ class RealVfsDirectory : public VfsDirectory {
|
||||
friend class RealVfsFilesystem;
|
||||
|
||||
public:
|
||||
RealVfsDirectory(RealVfsFilesystem& base, const std::string& path,
|
||||
OpenMode perms = OpenMode::Read);
|
||||
~RealVfsDirectory() override;
|
||||
|
||||
VirtualFile GetFileRelative(std::string_view relative_path) const override;
|
||||
@@ -140,6 +138,9 @@ public:
|
||||
std::map<std::string, VfsEntryType, std::less<>> GetEntries() const override;
|
||||
|
||||
private:
|
||||
RealVfsDirectory(RealVfsFilesystem& base, const std::string& path,
|
||||
OpenMode perms = OpenMode::Read);
|
||||
|
||||
template <typename T, typename R>
|
||||
std::vector<std::shared_ptr<R>> IterateEntries() const;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
namespace IPC {
|
||||
|
||||
constexpr Result ResultNotSupported{ErrorModule::HIPC, 1};
|
||||
constexpr Result ResultSessionClosed{ErrorModule::HIPC, 301};
|
||||
|
||||
struct ResponseBuilder {
|
||||
|
||||
@@ -6,10 +6,15 @@
|
||||
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/kernel/k_client_session.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/ngc/ngc.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "frontend_common/firmware_manager.h"
|
||||
|
||||
namespace Service::NGC {
|
||||
|
||||
@@ -166,12 +171,117 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct UndefinedIUserShimScopedObjectParam {
|
||||
std::array<u8, 0x10> unk0;
|
||||
};
|
||||
static_assert(sizeof(UndefinedIUserShimScopedObjectParam) == 0x10);
|
||||
|
||||
class IUserShimScopedObject final : public ServiceFramework<IUserShimScopedObject> {
|
||||
public:
|
||||
explicit IUserShimScopedObject(Core::System& system_) : ServiceFramework(system_, "IUserShimScopedObject") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{450, nullptr, "Cmd450"},
|
||||
{451, nullptr, "Cmd451"},
|
||||
{452, D<&IUserShimScopedObject::Cmd452>, "Cmd451"},
|
||||
{453, nullptr, "Cmd453"},
|
||||
{454, D<&IUserShimScopedObject::Cmd454>, "Cmd454"},
|
||||
{455, nullptr, "Cmd455"},
|
||||
{456, nullptr, "Cmd456"},
|
||||
{457, nullptr, "Cmd457"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Result Cmd452(UndefinedIUserShimScopedObjectParam unk0, Out<u64> unk1) {
|
||||
LOG_WARNING(Service_NGC, "stubbed");
|
||||
R_THROW(IPC::ResultNotSupported);
|
||||
}
|
||||
|
||||
Result Cmd454(UndefinedIUserShimScopedObjectParam unk0, Out<u32> unk1, OutBuffer<BufferAttr_HipcAutoSelect> unk2) {
|
||||
LOG_WARNING(Service_NGC, "stubbed");
|
||||
R_THROW(IPC::ResultNotSupported);
|
||||
}
|
||||
};
|
||||
|
||||
class IUserService final : public ServiceFramework<IUserService> {
|
||||
public:
|
||||
explicit IUserService(Core::System& system_) : ServiceFramework(system_, "stpl:u") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0 , D<&IUserService::Cmd0>, "Cmd0"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
Result Cmd0(OutInterface<IUserShimScopedObject> out_interface) {
|
||||
LOG_WARNING(Service_NGC, "stubbed");
|
||||
*out_interface = std::make_shared<IUserShimScopedObject>(system);
|
||||
R_SUCCEED();
|
||||
}
|
||||
};
|
||||
|
||||
class ISystemShimScopedObject final : public ServiceFramework<ISystemShimScopedObject> {
|
||||
public:
|
||||
explicit ISystemShimScopedObject(Core::System& system_) : ServiceFramework(system_, "ISystemShimScopedObject") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{106, nullptr, "Cmd106"},
|
||||
{107, nullptr, "Cmd107"},
|
||||
{108, D<&ISystemShimScopedObject::Cmd108>, "Cmd108"},
|
||||
{207, nullptr, "Cmd207"},
|
||||
{208, D<&ISystemShimScopedObject::Cmd208>, "Cmd208"},
|
||||
{209, nullptr, "Cmd209"},
|
||||
{210, nullptr, "Cmd210"},
|
||||
{211, nullptr, "Cmd211"},
|
||||
{212, nullptr, "Cmd212"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
Result Cmd108() {
|
||||
LOG_WARNING(Service_NGC, "stubbed");
|
||||
R_THROW(IPC::ResultNotSupported);
|
||||
}
|
||||
|
||||
Result Cmd208(Out<std::array<u8, 0x20>> unk0) {
|
||||
LOG_WARNING(Service_NGC, "stubbed");
|
||||
R_THROW(IPC::ResultNotSupported);
|
||||
}
|
||||
};
|
||||
|
||||
class ISystemService final : public ServiceFramework<ISystemService> {
|
||||
public:
|
||||
explicit ISystemService(Core::System& system_) : ServiceFramework(system_, "stpl:sys") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0 , D<&ISystemService::Cmd0>, "Cmd0"},
|
||||
};
|
||||
// clang-format on
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
Result Cmd0(OutInterface<ISystemShimScopedObject> out_interface) {
|
||||
LOG_WARNING(Service_NGC, "stubbed");
|
||||
*out_interface = std::make_shared<ISystemShimScopedObject>(system);
|
||||
R_SUCCEED();
|
||||
}
|
||||
};
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("ngct:u", std::make_shared<IService>(system), 4);
|
||||
server_manager->RegisterNamedService("ngct:s", std::make_shared<IServiceWithManagementApi>(system), 4);
|
||||
server_manager->RegisterNamedService("ngc:u", std::make_shared<NgcServiceImpl>(system), 4);
|
||||
|
||||
// +23.0.0
|
||||
if (FirmwareManager::GetFirmwareVersion(system).first.major >= 23) {
|
||||
server_manager->RegisterNamedService("stpl:u", std::make_shared<IUserService>(system), 4);
|
||||
server_manager->RegisterNamedService("stpl:sys", std::make_shared<ISystemService>(system), 4);
|
||||
}
|
||||
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
@@ -24,7 +24,7 @@ IReceiverService::~IReceiverService() = default;
|
||||
|
||||
Result IReceiverService::OpenReceiver(Out<SharedPointer<IReceiver>> out_receiver) {
|
||||
LOG_DEBUG(Service_PSC, "called");
|
||||
*out_receiver = std::make_shared<IReceiver>(system);
|
||||
*out_receiver = std::shared_ptr<IReceiver>(new IReceiver(system));
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user