From c6d7da88c7ab125279ea4ccad0e3e839632b2f7a Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Wed, 14 Jul 2021 00:52:17 -0400 Subject: service: Append service name prefix to common filenames --- src/core/hle/service/spl/csrng.h | 2 +- src/core/hle/service/spl/module.cpp | 175 -------------------------------- src/core/hle/service/spl/module.h | 48 --------- src/core/hle/service/spl/spl.h | 2 +- src/core/hle/service/spl/spl_module.cpp | 175 ++++++++++++++++++++++++++++++++ src/core/hle/service/spl/spl_module.h | 48 +++++++++ 6 files changed, 225 insertions(+), 225 deletions(-) delete mode 100644 src/core/hle/service/spl/module.cpp delete mode 100644 src/core/hle/service/spl/module.h create mode 100644 src/core/hle/service/spl/spl_module.cpp create mode 100644 src/core/hle/service/spl/spl_module.h (limited to 'src/core/hle/service/spl') diff --git a/src/core/hle/service/spl/csrng.h b/src/core/hle/service/spl/csrng.h index 5c0bd2199..0d03cc6cb 100644 --- a/src/core/hle/service/spl/csrng.h +++ b/src/core/hle/service/spl/csrng.h @@ -4,7 +4,7 @@ #pragma once -#include "core/hle/service/spl/module.h" +#include "core/hle/service/spl/spl_module.h" namespace Core { class System; diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp deleted file mode 100644 index ebb179aa8..000000000 --- a/src/core/hle/service/spl/module.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include -#include -#include -#include -#include -#include -#include "common/logging/log.h" -#include "common/settings.h" -#include "core/hle/api_version.h" -#include "core/hle/ipc_helpers.h" -#include "core/hle/service/spl/csrng.h" -#include "core/hle/service/spl/module.h" -#include "core/hle/service/spl/spl.h" - -namespace Service::SPL { - -Module::Interface::Interface(Core::System& system_, std::shared_ptr module_, - const char* name) - : ServiceFramework{system_, name}, module{std::move(module_)}, - rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {} - -Module::Interface::~Interface() = default; - -void Module::Interface::GetConfig(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto config_item = rp.PopEnum(); - - // This should call svcCallSecureMonitor with the appropriate args. - // Since we do not have it implemented yet, we will use this for now. - const auto smc_result = GetConfigImpl(config_item); - const auto result_code = smc_result.Code(); - - if (smc_result.Failed()) { - LOG_ERROR(Service_SPL, "called, config_item={}, result_code={}", config_item, - result_code.raw); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(result_code); - } - - LOG_DEBUG(Service_SPL, "called, config_item={}, result_code={}, smc_result={}", config_item, - result_code.raw, *smc_result); - - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(result_code); - rb.Push(*smc_result); -} - -void Module::Interface::ModularExponentiate(Kernel::HLERequestContext& ctx) { - UNIMPLEMENTED_MSG("ModularExponentiate is not implemented!"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSecureMonitorNotImplemented); -} - -void Module::Interface::SetConfig(Kernel::HLERequestContext& ctx) { - UNIMPLEMENTED_MSG("SetConfig is not implemented!"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSecureMonitorNotImplemented); -} - -void Module::Interface::GenerateRandomBytes(Kernel::HLERequestContext& ctx) { - LOG_DEBUG(Service_SPL, "called"); - - const std::size_t size = ctx.GetWriteBufferSize(); - - std::uniform_int_distribution distribution(0, std::numeric_limits::max()); - std::vector data(size); - std::generate(data.begin(), data.end(), [&] { return static_cast(distribution(rng)); }); - - ctx.WriteBuffer(data); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); -} - -void Module::Interface::IsDevelopment(Kernel::HLERequestContext& ctx) { - UNIMPLEMENTED_MSG("IsDevelopment is not implemented!"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSecureMonitorNotImplemented); -} - -void Module::Interface::SetBootReason(Kernel::HLERequestContext& ctx) { - UNIMPLEMENTED_MSG("SetBootReason is not implemented!"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSecureMonitorNotImplemented); -} - -void Module::Interface::GetBootReason(Kernel::HLERequestContext& ctx) { - UNIMPLEMENTED_MSG("GetBootReason is not implemented!"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSecureMonitorNotImplemented); -} - -ResultVal Module::Interface::GetConfigImpl(ConfigItem config_item) const { - switch (config_item) { - case ConfigItem::DisableProgramVerification: - case ConfigItem::DramId: - case ConfigItem::SecurityEngineInterruptNumber: - case ConfigItem::FuseVersion: - case ConfigItem::HardwareType: - case ConfigItem::HardwareState: - case ConfigItem::IsRecoveryBoot: - case ConfigItem::DeviceId: - case ConfigItem::BootReason: - case ConfigItem::MemoryMode: - case ConfigItem::IsDevelopmentFunctionEnabled: - case ConfigItem::KernelConfiguration: - case ConfigItem::IsChargerHiZModeEnabled: - case ConfigItem::QuestState: - case ConfigItem::RegulatorType: - case ConfigItem::DeviceUniqueKeyGeneration: - case ConfigItem::Package2Hash: - return ResultSecureMonitorNotImplemented; - case ConfigItem::ExosphereApiVersion: - // Get information about the current exosphere version. - return MakeResult((u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) | - (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) | - (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) | - (static_cast(HLE::ApiVersion::GetTargetFirmware()))); - case ConfigItem::ExosphereNeedsReboot: - // We are executing, so we aren't in the process of rebooting. - return MakeResult(u64{0}); - case ConfigItem::ExosphereNeedsShutdown: - // We are executing, so we aren't in the process of shutting down. - return MakeResult(u64{0}); - case ConfigItem::ExosphereGitCommitHash: - // Get information about the current exosphere git commit hash. - return MakeResult(u64{0}); - case ConfigItem::ExosphereHasRcmBugPatch: - // Get information about whether this unit has the RCM bug patched. - return MakeResult(u64{0}); - case ConfigItem::ExosphereBlankProdInfo: - // Get whether this unit should simulate a "blanked" PRODINFO. - return MakeResult(u64{0}); - case ConfigItem::ExosphereAllowCalWrites: - // Get whether this unit should allow writing to the calibration partition. - return MakeResult(u64{0}); - case ConfigItem::ExosphereEmummcType: - // Get what kind of emummc this unit has active. - return MakeResult(u64{0}); - case ConfigItem::ExospherePayloadAddress: - // Gets the physical address of the reboot payload buffer, if one exists. - return ResultSecureMonitorNotInitialized; - case ConfigItem::ExosphereLogConfiguration: - // Get the log configuration. - return MakeResult(u64{0}); - case ConfigItem::ExosphereForceEnableUsb30: - // Get whether usb 3.0 should be force-enabled. - return MakeResult(u64{0}); - default: - return ResultSecureMonitorInvalidArgument; - } -} - -void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { - auto module = std::make_shared(); - std::make_shared(system, module)->InstallAsService(service_manager); - std::make_shared(system, module)->InstallAsService(service_manager); - std::make_shared(system, module)->InstallAsService(service_manager); - std::make_shared(system, module)->InstallAsService(service_manager); - std::make_shared(system, module)->InstallAsService(service_manager); - std::make_shared(system, module)->InstallAsService(service_manager); - std::make_shared(system, module)->InstallAsService(service_manager); -} - -} // namespace Service::SPL diff --git a/src/core/hle/service/spl/module.h b/src/core/hle/service/spl/module.h deleted file mode 100644 index 61630df80..000000000 --- a/src/core/hle/service/spl/module.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include "core/hle/service/service.h" -#include "core/hle/service/spl/spl_results.h" -#include "core/hle/service/spl/spl_types.h" - -namespace Core { -class System; -} - -namespace Service::SPL { - -class Module final { -public: - class Interface : public ServiceFramework { - public: - explicit Interface(Core::System& system_, std::shared_ptr module_, - const char* name); - ~Interface() override; - - // General - void GetConfig(Kernel::HLERequestContext& ctx); - void ModularExponentiate(Kernel::HLERequestContext& ctx); - void SetConfig(Kernel::HLERequestContext& ctx); - void GenerateRandomBytes(Kernel::HLERequestContext& ctx); - void IsDevelopment(Kernel::HLERequestContext& ctx); - void SetBootReason(Kernel::HLERequestContext& ctx); - void GetBootReason(Kernel::HLERequestContext& ctx); - - protected: - std::shared_ptr module; - - private: - ResultVal GetConfigImpl(ConfigItem config_item) const; - - std::mt19937 rng; - }; -}; - -/// Registers all SPL services with the specified service manager. -void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); - -} // namespace Service::SPL diff --git a/src/core/hle/service/spl/spl.h b/src/core/hle/service/spl/spl.h index 9b35012ed..5599c0c01 100644 --- a/src/core/hle/service/spl/spl.h +++ b/src/core/hle/service/spl/spl.h @@ -4,7 +4,7 @@ #pragma once -#include "core/hle/service/spl/module.h" +#include "core/hle/service/spl/spl_module.h" namespace Core { class System; diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp new file mode 100644 index 000000000..918633af5 --- /dev/null +++ b/src/core/hle/service/spl/spl_module.cpp @@ -0,0 +1,175 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include +#include +#include "common/logging/log.h" +#include "common/settings.h" +#include "core/hle/api_version.h" +#include "core/hle/ipc_helpers.h" +#include "core/hle/service/spl/csrng.h" +#include "core/hle/service/spl/spl.h" +#include "core/hle/service/spl/spl_module.h" + +namespace Service::SPL { + +Module::Interface::Interface(Core::System& system_, std::shared_ptr module_, + const char* name) + : ServiceFramework{system_, name}, module{std::move(module_)}, + rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {} + +Module::Interface::~Interface() = default; + +void Module::Interface::GetConfig(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto config_item = rp.PopEnum(); + + // This should call svcCallSecureMonitor with the appropriate args. + // Since we do not have it implemented yet, we will use this for now. + const auto smc_result = GetConfigImpl(config_item); + const auto result_code = smc_result.Code(); + + if (smc_result.Failed()) { + LOG_ERROR(Service_SPL, "called, config_item={}, result_code={}", config_item, + result_code.raw); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result_code); + } + + LOG_DEBUG(Service_SPL, "called, config_item={}, result_code={}, smc_result={}", config_item, + result_code.raw, *smc_result); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(result_code); + rb.Push(*smc_result); +} + +void Module::Interface::ModularExponentiate(Kernel::HLERequestContext& ctx) { + UNIMPLEMENTED_MSG("ModularExponentiate is not implemented!"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSecureMonitorNotImplemented); +} + +void Module::Interface::SetConfig(Kernel::HLERequestContext& ctx) { + UNIMPLEMENTED_MSG("SetConfig is not implemented!"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSecureMonitorNotImplemented); +} + +void Module::Interface::GenerateRandomBytes(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_SPL, "called"); + + const std::size_t size = ctx.GetWriteBufferSize(); + + std::uniform_int_distribution distribution(0, std::numeric_limits::max()); + std::vector data(size); + std::generate(data.begin(), data.end(), [&] { return static_cast(distribution(rng)); }); + + ctx.WriteBuffer(data); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void Module::Interface::IsDevelopment(Kernel::HLERequestContext& ctx) { + UNIMPLEMENTED_MSG("IsDevelopment is not implemented!"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSecureMonitorNotImplemented); +} + +void Module::Interface::SetBootReason(Kernel::HLERequestContext& ctx) { + UNIMPLEMENTED_MSG("SetBootReason is not implemented!"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSecureMonitorNotImplemented); +} + +void Module::Interface::GetBootReason(Kernel::HLERequestContext& ctx) { + UNIMPLEMENTED_MSG("GetBootReason is not implemented!"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSecureMonitorNotImplemented); +} + +ResultVal Module::Interface::GetConfigImpl(ConfigItem config_item) const { + switch (config_item) { + case ConfigItem::DisableProgramVerification: + case ConfigItem::DramId: + case ConfigItem::SecurityEngineInterruptNumber: + case ConfigItem::FuseVersion: + case ConfigItem::HardwareType: + case ConfigItem::HardwareState: + case ConfigItem::IsRecoveryBoot: + case ConfigItem::DeviceId: + case ConfigItem::BootReason: + case ConfigItem::MemoryMode: + case ConfigItem::IsDevelopmentFunctionEnabled: + case ConfigItem::KernelConfiguration: + case ConfigItem::IsChargerHiZModeEnabled: + case ConfigItem::QuestState: + case ConfigItem::RegulatorType: + case ConfigItem::DeviceUniqueKeyGeneration: + case ConfigItem::Package2Hash: + return ResultSecureMonitorNotImplemented; + case ConfigItem::ExosphereApiVersion: + // Get information about the current exosphere version. + return MakeResult((u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MAJOR} << 56) | + (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MINOR} << 48) | + (u64{HLE::ApiVersion::ATMOSPHERE_RELEASE_VERSION_MICRO} << 40) | + (static_cast(HLE::ApiVersion::GetTargetFirmware()))); + case ConfigItem::ExosphereNeedsReboot: + // We are executing, so we aren't in the process of rebooting. + return MakeResult(u64{0}); + case ConfigItem::ExosphereNeedsShutdown: + // We are executing, so we aren't in the process of shutting down. + return MakeResult(u64{0}); + case ConfigItem::ExosphereGitCommitHash: + // Get information about the current exosphere git commit hash. + return MakeResult(u64{0}); + case ConfigItem::ExosphereHasRcmBugPatch: + // Get information about whether this unit has the RCM bug patched. + return MakeResult(u64{0}); + case ConfigItem::ExosphereBlankProdInfo: + // Get whether this unit should simulate a "blanked" PRODINFO. + return MakeResult(u64{0}); + case ConfigItem::ExosphereAllowCalWrites: + // Get whether this unit should allow writing to the calibration partition. + return MakeResult(u64{0}); + case ConfigItem::ExosphereEmummcType: + // Get what kind of emummc this unit has active. + return MakeResult(u64{0}); + case ConfigItem::ExospherePayloadAddress: + // Gets the physical address of the reboot payload buffer, if one exists. + return ResultSecureMonitorNotInitialized; + case ConfigItem::ExosphereLogConfiguration: + // Get the log configuration. + return MakeResult(u64{0}); + case ConfigItem::ExosphereForceEnableUsb30: + // Get whether usb 3.0 should be force-enabled. + return MakeResult(u64{0}); + default: + return ResultSecureMonitorInvalidArgument; + } +} + +void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { + auto module = std::make_shared(); + std::make_shared(system, module)->InstallAsService(service_manager); + std::make_shared(system, module)->InstallAsService(service_manager); + std::make_shared(system, module)->InstallAsService(service_manager); + std::make_shared(system, module)->InstallAsService(service_manager); + std::make_shared(system, module)->InstallAsService(service_manager); + std::make_shared(system, module)->InstallAsService(service_manager); + std::make_shared(system, module)->InstallAsService(service_manager); +} + +} // namespace Service::SPL diff --git a/src/core/hle/service/spl/spl_module.h b/src/core/hle/service/spl/spl_module.h new file mode 100644 index 000000000..61630df80 --- /dev/null +++ b/src/core/hle/service/spl/spl_module.h @@ -0,0 +1,48 @@ +// Copyright 2018 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include "core/hle/service/service.h" +#include "core/hle/service/spl/spl_results.h" +#include "core/hle/service/spl/spl_types.h" + +namespace Core { +class System; +} + +namespace Service::SPL { + +class Module final { +public: + class Interface : public ServiceFramework { + public: + explicit Interface(Core::System& system_, std::shared_ptr module_, + const char* name); + ~Interface() override; + + // General + void GetConfig(Kernel::HLERequestContext& ctx); + void ModularExponentiate(Kernel::HLERequestContext& ctx); + void SetConfig(Kernel::HLERequestContext& ctx); + void GenerateRandomBytes(Kernel::HLERequestContext& ctx); + void IsDevelopment(Kernel::HLERequestContext& ctx); + void SetBootReason(Kernel::HLERequestContext& ctx); + void GetBootReason(Kernel::HLERequestContext& ctx); + + protected: + std::shared_ptr module; + + private: + ResultVal GetConfigImpl(ConfigItem config_item) const; + + std::mt19937 rng; + }; +}; + +/// Registers all SPL services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); + +} // namespace Service::SPL -- cgit v1.2.3