mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2024-12-25 12:31:21 -08:00
Merge pull request #261 from mailwl/spl
Service/spl: add module and services
This commit is contained in:
commit
b5c03088bc
@ -48,6 +48,7 @@ namespace Log {
|
|||||||
SUB(Service, PCTL) \
|
SUB(Service, PCTL) \
|
||||||
SUB(Service, SET) \
|
SUB(Service, SET) \
|
||||||
SUB(Service, SM) \
|
SUB(Service, SM) \
|
||||||
|
SUB(Service, SPL) \
|
||||||
SUB(Service, Time) \
|
SUB(Service, Time) \
|
||||||
SUB(Service, VI) \
|
SUB(Service, VI) \
|
||||||
CLS(HW) \
|
CLS(HW) \
|
||||||
|
@ -65,6 +65,7 @@ enum class Class : ClassType {
|
|||||||
Service_PCTL, ///< The PCTL (Parental control) service
|
Service_PCTL, ///< The PCTL (Parental control) service
|
||||||
Service_SET, ///< The SET (Settings) service
|
Service_SET, ///< The SET (Settings) service
|
||||||
Service_SM, ///< The SM (Service manager) service
|
Service_SM, ///< The SM (Service manager) service
|
||||||
|
Service_SPL, ///< The SPL service
|
||||||
Service_Time, ///< The time service
|
Service_Time, ///< The time service
|
||||||
Service_VI, ///< The VI (Video interface) service
|
Service_VI, ///< The VI (Video interface) service
|
||||||
HW, ///< Low-level hardware emulation
|
HW, ///< Low-level hardware emulation
|
||||||
|
@ -193,6 +193,12 @@ add_library(core STATIC
|
|||||||
hle/service/sockets/sfdnsres.h
|
hle/service/sockets/sfdnsres.h
|
||||||
hle/service/sockets/sockets.cpp
|
hle/service/sockets/sockets.cpp
|
||||||
hle/service/sockets/sockets.h
|
hle/service/sockets/sockets.h
|
||||||
|
hle/service/spl/csrng.cpp
|
||||||
|
hle/service/spl/csrng.h
|
||||||
|
hle/service/spl/module.cpp
|
||||||
|
hle/service/spl/module.h
|
||||||
|
hle/service/spl/spl.cpp
|
||||||
|
hle/service/spl/spl.h
|
||||||
hle/service/time/time.cpp
|
hle/service/time/time.cpp
|
||||||
hle/service/time/time.h
|
hle/service/time/time.h
|
||||||
hle/service/time/time_s.cpp
|
hle/service/time/time_s.cpp
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "core/hle/service/sm/controller.h"
|
#include "core/hle/service/sm/controller.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
#include "core/hle/service/sockets/sockets.h"
|
#include "core/hle/service/sockets/sockets.h"
|
||||||
|
#include "core/hle/service/spl/module.h"
|
||||||
#include "core/hle/service/time/time.h"
|
#include "core/hle/service/time/time.h"
|
||||||
#include "core/hle/service/vi/vi.h"
|
#include "core/hle/service/vi/vi.h"
|
||||||
|
|
||||||
@ -190,6 +191,7 @@ void Init() {
|
|||||||
Nvidia::InstallInterfaces(*SM::g_service_manager);
|
Nvidia::InstallInterfaces(*SM::g_service_manager);
|
||||||
PCTL::InstallInterfaces(*SM::g_service_manager);
|
PCTL::InstallInterfaces(*SM::g_service_manager);
|
||||||
Sockets::InstallInterfaces(*SM::g_service_manager);
|
Sockets::InstallInterfaces(*SM::g_service_manager);
|
||||||
|
SPL::InstallInterfaces(*SM::g_service_manager);
|
||||||
Time::InstallInterfaces(*SM::g_service_manager);
|
Time::InstallInterfaces(*SM::g_service_manager);
|
||||||
VI::InstallInterfaces(*SM::g_service_manager, nv_flinger);
|
VI::InstallInterfaces(*SM::g_service_manager, nv_flinger);
|
||||||
Set::InstallInterfaces(*SM::g_service_manager);
|
Set::InstallInterfaces(*SM::g_service_manager);
|
||||||
|
18
src/core/hle/service/spl/csrng.cpp
Normal file
18
src/core/hle/service/spl/csrng.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "core/hle/service/spl/csrng.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace SPL {
|
||||||
|
|
||||||
|
CSRNG::CSRNG(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "csrng") {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, &CSRNG::GetRandomBytes, "GetRandomBytes"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace SPL
|
||||||
|
} // namespace Service
|
18
src/core/hle/service/spl/csrng.h
Normal file
18
src/core/hle/service/spl/csrng.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/spl/module.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace SPL {
|
||||||
|
|
||||||
|
class CSRNG final : public Module::Interface {
|
||||||
|
public:
|
||||||
|
explicit CSRNG(std::shared_ptr<Module> module);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SPL
|
||||||
|
} // namespace Service
|
42
src/core/hle/service/spl/module.cpp
Normal file
42
src/core/hle/service/spl/module.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <vector>
|
||||||
|
#include "common/logging/log.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 {
|
||||||
|
namespace SPL {
|
||||||
|
|
||||||
|
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
||||||
|
: ServiceFramework(name), module(std::move(module)) {}
|
||||||
|
|
||||||
|
void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) {
|
||||||
|
IPC::RequestParser rp{ctx};
|
||||||
|
|
||||||
|
size_t size = ctx.GetWriteBufferSize();
|
||||||
|
|
||||||
|
std::vector<u8> data(size);
|
||||||
|
std::generate(data.begin(), data.end(), std::rand);
|
||||||
|
|
||||||
|
ctx.WriteBuffer(data);
|
||||||
|
|
||||||
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
LOG_DEBUG(Service_SPL, "called");
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||||
|
auto module = std::make_shared<Module>();
|
||||||
|
std::make_shared<CSRNG>(module)->InstallAsService(service_manager);
|
||||||
|
std::make_shared<SPL>(module)->InstallAsService(service_manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace SPL
|
||||||
|
} // namespace Service
|
29
src/core/hle/service/spl/module.h
Normal file
29
src/core/hle/service/spl/module.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace SPL {
|
||||||
|
|
||||||
|
class Module final {
|
||||||
|
public:
|
||||||
|
class Interface : public ServiceFramework<Interface> {
|
||||||
|
public:
|
||||||
|
Interface(std::shared_ptr<Module> module, const char* name);
|
||||||
|
|
||||||
|
void GetRandomBytes(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<Module> module;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Registers all SPL services with the specified service manager.
|
||||||
|
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||||
|
|
||||||
|
} // namespace SPL
|
||||||
|
} // namespace Service
|
41
src/core/hle/service/spl/spl.cpp
Normal file
41
src/core/hle/service/spl/spl.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "core/hle/service/spl/spl.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace SPL {
|
||||||
|
|
||||||
|
SPL::SPL(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "spl:") {
|
||||||
|
static const FunctionInfo functions[] = {
|
||||||
|
{0, nullptr, "GetConfig"},
|
||||||
|
{1, nullptr, "UserExpMod"},
|
||||||
|
{2, nullptr, "GenerateAesKek"},
|
||||||
|
{3, nullptr, "LoadAesKey"},
|
||||||
|
{4, nullptr, "GenerateAesKey"},
|
||||||
|
{5, nullptr, "SetConfig"},
|
||||||
|
{7, &SPL::GetRandomBytes, "GetRandomBytes"},
|
||||||
|
{9, nullptr, "LoadSecureExpModKey"},
|
||||||
|
{10, nullptr, "SecureExpMod"},
|
||||||
|
{11, nullptr, "IsDevelopment"},
|
||||||
|
{12, nullptr, "GenerateSpecificAesKey"},
|
||||||
|
{13, nullptr, "DecryptPrivk"},
|
||||||
|
{14, nullptr, "DecryptAesKey"},
|
||||||
|
{15, nullptr, "DecryptAesCtr"},
|
||||||
|
{16, nullptr, "ComputeCmac"},
|
||||||
|
{17, nullptr, "LoadRsaOaepKey"},
|
||||||
|
{18, nullptr, "UnwrapRsaOaepWrappedTitleKey"},
|
||||||
|
{19, nullptr, "LoadTitleKey"},
|
||||||
|
{20, nullptr, "UnwrapAesWrappedTitleKey"},
|
||||||
|
{21, nullptr, "LockAesEngine"},
|
||||||
|
{22, nullptr, "UnlockAesEngine"},
|
||||||
|
{23, nullptr, "GetSplWaitEvent"},
|
||||||
|
{24, nullptr, "SetSharedData"},
|
||||||
|
{25, nullptr, "GetSharedData"},
|
||||||
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace SPL
|
||||||
|
} // namespace Service
|
18
src/core/hle/service/spl/spl.h
Normal file
18
src/core/hle/service/spl/spl.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2018 yuzu emulator team
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/hle/service/spl/module.h"
|
||||||
|
|
||||||
|
namespace Service {
|
||||||
|
namespace SPL {
|
||||||
|
|
||||||
|
class SPL final : public Module::Interface {
|
||||||
|
public:
|
||||||
|
explicit SPL(std::shared_ptr<Module> module);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SPL
|
||||||
|
} // namespace Service
|
Loading…
Reference in New Issue
Block a user