diff options
| author | 2018-03-22 09:54:16 +0300 | |
|---|---|---|
| committer | 2018-03-22 09:55:14 +0300 | |
| commit | 95e747cd06810b0e95ee6cd379772a4e36ab9794 (patch) | |
| tree | c1c76fedd5bc3b5815b2eac9b7f83b6bbc5b37bb /src/core/hle/service/spl | |
| parent | Merge pull request #258 from Subv/gpu_attribs (diff) | |
| download | yuzu-95e747cd06810b0e95ee6cd379772a4e36ab9794.tar.gz yuzu-95e747cd06810b0e95ee6cd379772a4e36ab9794.tar.xz yuzu-95e747cd06810b0e95ee6cd379772a4e36ab9794.zip | |
Service/spl: add module and services
Diffstat (limited to 'src/core/hle/service/spl')
| -rw-r--r-- | src/core/hle/service/spl/csrng.cpp | 18 | ||||
| -rw-r--r-- | src/core/hle/service/spl/csrng.h | 18 | ||||
| -rw-r--r-- | src/core/hle/service/spl/module.cpp | 42 | ||||
| -rw-r--r-- | src/core/hle/service/spl/module.h | 29 | ||||
| -rw-r--r-- | src/core/hle/service/spl/spl.cpp | 41 | ||||
| -rw-r--r-- | src/core/hle/service/spl/spl.h | 18 |
6 files changed, 166 insertions, 0 deletions
diff --git a/src/core/hle/service/spl/csrng.cpp b/src/core/hle/service/spl/csrng.cpp new file mode 100644 index 000000000..cde05717a --- /dev/null +++ b/src/core/hle/service/spl/csrng.cpp | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/service/spl/csrng.h" | ||
| 6 | |||
| 7 | namespace Service { | ||
| 8 | namespace SPL { | ||
| 9 | |||
| 10 | CSRNG::CSRNG(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "csrng") { | ||
| 11 | static const FunctionInfo functions[] = { | ||
| 12 | {0, &CSRNG::GetRandomBytes, "GetRandomBytes"}, | ||
| 13 | }; | ||
| 14 | RegisterHandlers(functions); | ||
| 15 | } | ||
| 16 | |||
| 17 | } // namespace SPL | ||
| 18 | } // namespace Service | ||
diff --git a/src/core/hle/service/spl/csrng.h b/src/core/hle/service/spl/csrng.h new file mode 100644 index 000000000..59ca794dd --- /dev/null +++ b/src/core/hle/service/spl/csrng.h | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/spl/module.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | namespace SPL { | ||
| 11 | |||
| 12 | class CSRNG final : public Module::Interface { | ||
| 13 | public: | ||
| 14 | explicit CSRNG(std::shared_ptr<Module> module); | ||
| 15 | }; | ||
| 16 | |||
| 17 | } // namespace SPL | ||
| 18 | } // namespace Service | ||
diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp new file mode 100644 index 000000000..fc1bcd94c --- /dev/null +++ b/src/core/hle/service/spl/module.cpp | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <cstdlib> | ||
| 7 | #include <vector> | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "core/hle/ipc_helpers.h" | ||
| 10 | #include "core/hle/service/spl/csrng.h" | ||
| 11 | #include "core/hle/service/spl/module.h" | ||
| 12 | #include "core/hle/service/spl/spl.h" | ||
| 13 | |||
| 14 | namespace Service { | ||
| 15 | namespace SPL { | ||
| 16 | |||
| 17 | Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) | ||
| 18 | : ServiceFramework(name), module(std::move(module)) {} | ||
| 19 | |||
| 20 | void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) { | ||
| 21 | IPC::RequestParser rp{ctx}; | ||
| 22 | |||
| 23 | size_t size = ctx.GetWriteBufferSize(); | ||
| 24 | |||
| 25 | std::vector<u8> data(size); | ||
| 26 | std::generate(data.begin(), data.end(), std::rand); | ||
| 27 | |||
| 28 | ctx.WriteBuffer(data); | ||
| 29 | |||
| 30 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 31 | rb.Push(RESULT_SUCCESS); | ||
| 32 | LOG_DEBUG(Service_SPL, "called"); | ||
| 33 | } | ||
| 34 | |||
| 35 | void InstallInterfaces(SM::ServiceManager& service_manager) { | ||
| 36 | auto module = std::make_shared<Module>(); | ||
| 37 | std::make_shared<CSRNG>(module)->InstallAsService(service_manager); | ||
| 38 | std::make_shared<SPL>(module)->InstallAsService(service_manager); | ||
| 39 | } | ||
| 40 | |||
| 41 | } // namespace SPL | ||
| 42 | } // namespace Service | ||
diff --git a/src/core/hle/service/spl/module.h b/src/core/hle/service/spl/module.h new file mode 100644 index 000000000..12cdb2980 --- /dev/null +++ b/src/core/hle/service/spl/module.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | namespace SPL { | ||
| 11 | |||
| 12 | class Module final { | ||
| 13 | public: | ||
| 14 | class Interface : public ServiceFramework<Interface> { | ||
| 15 | public: | ||
| 16 | Interface(std::shared_ptr<Module> module, const char* name); | ||
| 17 | |||
| 18 | void GetRandomBytes(Kernel::HLERequestContext& ctx); | ||
| 19 | |||
| 20 | protected: | ||
| 21 | std::shared_ptr<Module> module; | ||
| 22 | }; | ||
| 23 | }; | ||
| 24 | |||
| 25 | /// Registers all SPL services with the specified service manager. | ||
| 26 | void InstallInterfaces(SM::ServiceManager& service_manager); | ||
| 27 | |||
| 28 | } // namespace SPL | ||
| 29 | } // namespace Service | ||
diff --git a/src/core/hle/service/spl/spl.cpp b/src/core/hle/service/spl/spl.cpp new file mode 100644 index 000000000..deab29b91 --- /dev/null +++ b/src/core/hle/service/spl/spl.cpp | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/hle/service/spl/spl.h" | ||
| 6 | |||
| 7 | namespace Service { | ||
| 8 | namespace SPL { | ||
| 9 | |||
| 10 | SPL::SPL(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "spl:") { | ||
| 11 | static const FunctionInfo functions[] = { | ||
| 12 | {0, nullptr, "GetConfig"}, | ||
| 13 | {1, nullptr, "UserExpMod"}, | ||
| 14 | {2, nullptr, "GenerateAesKek"}, | ||
| 15 | {3, nullptr, "LoadAesKey"}, | ||
| 16 | {4, nullptr, "GenerateAesKey"}, | ||
| 17 | {5, nullptr, "SetConfig"}, | ||
| 18 | {7, &SPL::GetRandomBytes, "GetRandomBytes"}, | ||
| 19 | {9, nullptr, "LoadSecureExpModKey"}, | ||
| 20 | {10, nullptr, "SecureExpMod"}, | ||
| 21 | {11, nullptr, "IsDevelopment"}, | ||
| 22 | {12, nullptr, "GenerateSpecificAesKey"}, | ||
| 23 | {13, nullptr, "DecryptPrivk"}, | ||
| 24 | {14, nullptr, "DecryptAesKey"}, | ||
| 25 | {15, nullptr, "DecryptAesCtr"}, | ||
| 26 | {16, nullptr, "ComputeCmac"}, | ||
| 27 | {17, nullptr, "LoadRsaOaepKey"}, | ||
| 28 | {18, nullptr, "UnwrapRsaOaepWrappedTitleKey"}, | ||
| 29 | {19, nullptr, "LoadTitleKey"}, | ||
| 30 | {20, nullptr, "UnwrapAesWrappedTitleKey"}, | ||
| 31 | {21, nullptr, "LockAesEngine"}, | ||
| 32 | {22, nullptr, "UnlockAesEngine"}, | ||
| 33 | {23, nullptr, "GetSplWaitEvent"}, | ||
| 34 | {24, nullptr, "SetSharedData"}, | ||
| 35 | {25, nullptr, "GetSharedData"}, | ||
| 36 | }; | ||
| 37 | RegisterHandlers(functions); | ||
| 38 | } | ||
| 39 | |||
| 40 | } // namespace SPL | ||
| 41 | } // namespace Service | ||
diff --git a/src/core/hle/service/spl/spl.h b/src/core/hle/service/spl/spl.h new file mode 100644 index 000000000..9fd6059af --- /dev/null +++ b/src/core/hle/service/spl/spl.h | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/service/spl/module.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | namespace SPL { | ||
| 11 | |||
| 12 | class SPL final : public Module::Interface { | ||
| 13 | public: | ||
| 14 | explicit SPL(std::shared_ptr<Module> module); | ||
| 15 | }; | ||
| 16 | |||
| 17 | } // namespace SPL | ||
| 18 | } // namespace Service | ||