summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/logging/filter.cpp2
-rw-r--r--src/common/logging/types.h2
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/service/ngc/ngc.cpp150
-rw-r--r--src/core/hle/service/ngc/ngc.h (renamed from src/core/hle/service/ngct/ngct.h)4
-rw-r--r--src/core/hle/service/ngct/ngct.cpp62
-rw-r--r--src/core/hle/service/service.cpp4
7 files changed, 158 insertions, 70 deletions
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index c95909561..4e3a614a4 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -112,7 +112,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
112 SUB(Service, NCM) \ 112 SUB(Service, NCM) \
113 SUB(Service, NFC) \ 113 SUB(Service, NFC) \
114 SUB(Service, NFP) \ 114 SUB(Service, NFP) \
115 SUB(Service, NGCT) \ 115 SUB(Service, NGC) \
116 SUB(Service, NIFM) \ 116 SUB(Service, NIFM) \
117 SUB(Service, NIM) \ 117 SUB(Service, NIM) \
118 SUB(Service, NOTIF) \ 118 SUB(Service, NOTIF) \
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
index 8356e3183..08af50ee0 100644
--- a/src/common/logging/types.h
+++ b/src/common/logging/types.h
@@ -80,7 +80,7 @@ enum class Class : u8 {
80 Service_NCM, ///< The NCM service 80 Service_NCM, ///< The NCM service
81 Service_NFC, ///< The NFC (Near-field communication) service 81 Service_NFC, ///< The NFC (Near-field communication) service
82 Service_NFP, ///< The NFP service 82 Service_NFP, ///< The NFP service
83 Service_NGCT, ///< The NGCT (No Good Content for Terra) service 83 Service_NGC, ///< The NGC (No Good Content) service
84 Service_NIFM, ///< The NIFM (Network interface) service 84 Service_NIFM, ///< The NIFM (Network interface) service
85 Service_NIM, ///< The NIM service 85 Service_NIM, ///< The NIM service
86 Service_NOTIF, ///< The NOTIF (Notification) service 86 Service_NOTIF, ///< The NOTIF (Notification) service
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c33910ade..6cd1a28f2 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -627,8 +627,8 @@ add_library(core STATIC
627 hle/service/nfp/nfp_interface.h 627 hle/service/nfp/nfp_interface.h
628 hle/service/nfp/nfp_result.h 628 hle/service/nfp/nfp_result.h
629 hle/service/nfp/nfp_types.h 629 hle/service/nfp/nfp_types.h
630 hle/service/ngct/ngct.cpp 630 hle/service/ngc/ngc.cpp
631 hle/service/ngct/ngct.h 631 hle/service/ngc/ngc.h
632 hle/service/nifm/nifm.cpp 632 hle/service/nifm/nifm.cpp
633 hle/service/nifm/nifm.h 633 hle/service/nifm/nifm.h
634 hle/service/nim/nim.cpp 634 hle/service/nim/nim.cpp
diff --git a/src/core/hle/service/ngc/ngc.cpp b/src/core/hle/service/ngc/ngc.cpp
new file mode 100644
index 000000000..c26019ec0
--- /dev/null
+++ b/src/core/hle/service/ngc/ngc.cpp
@@ -0,0 +1,150 @@
1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/string_util.h"
5#include "core/core.h"
6#include "core/hle/service/ipc_helpers.h"
7#include "core/hle/service/ngc/ngc.h"
8#include "core/hle/service/server_manager.h"
9#include "core/hle/service/service.h"
10
11namespace Service::NGC {
12
13class NgctServiceImpl final : public ServiceFramework<NgctServiceImpl> {
14public:
15 explicit NgctServiceImpl(Core::System& system_) : ServiceFramework{system_, "ngct:u"} {
16 // clang-format off
17 static const FunctionInfo functions[] = {
18 {0, &NgctServiceImpl::Match, "Match"},
19 {1, &NgctServiceImpl::Filter, "Filter"},
20 };
21 // clang-format on
22
23 RegisterHandlers(functions);
24 }
25
26private:
27 void Match(HLERequestContext& ctx) {
28 const auto buffer = ctx.ReadBuffer();
29 const auto text = Common::StringFromFixedZeroTerminatedBuffer(
30 reinterpret_cast<const char*>(buffer.data()), buffer.size());
31
32 LOG_WARNING(Service_NGC, "(STUBBED) called, text={}", text);
33
34 IPC::ResponseBuilder rb{ctx, 3};
35 rb.Push(ResultSuccess);
36 // Return false since we don't censor anything
37 rb.Push(false);
38 }
39
40 void Filter(HLERequestContext& ctx) {
41 const auto buffer = ctx.ReadBuffer();
42 const auto text = Common::StringFromFixedZeroTerminatedBuffer(
43 reinterpret_cast<const char*>(buffer.data()), buffer.size());
44
45 LOG_WARNING(Service_NGC, "(STUBBED) called, text={}", text);
46
47 // Return the same string since we don't censor anything
48 ctx.WriteBuffer(buffer);
49
50 IPC::ResponseBuilder rb{ctx, 2};
51 rb.Push(ResultSuccess);
52 }
53};
54
55class NgcServiceImpl final : public ServiceFramework<NgcServiceImpl> {
56public:
57 explicit NgcServiceImpl(Core::System& system_) : ServiceFramework(system_, "ngc:u") {
58 // clang-format off
59 static const FunctionInfo functions[] = {
60 {0, &NgcServiceImpl::GetContentVersion, "GetContentVersion"},
61 {1, &NgcServiceImpl::Check, "Check"},
62 {2, &NgcServiceImpl::Mask, "Mask"},
63 {3, &NgcServiceImpl::Reload, "Reload"},
64 };
65 // clang-format on
66
67 RegisterHandlers(functions);
68 }
69
70private:
71 static constexpr u32 NgcContentVersion = 1;
72
73 // This is nn::ngc::detail::ProfanityFilterOption
74 struct ProfanityFilterOption {
75 INSERT_PADDING_BYTES_NOINIT(0x20);
76 };
77 static_assert(sizeof(ProfanityFilterOption) == 0x20,
78 "ProfanityFilterOption has incorrect size");
79
80 void GetContentVersion(HLERequestContext& ctx) {
81 LOG_INFO(Service_NGC, "(STUBBED) called");
82
83 // This calls nn::ngc::ProfanityFilter::GetContentVersion
84 const u32 version = NgcContentVersion;
85
86 IPC::ResponseBuilder rb{ctx, 3};
87 rb.Push(ResultSuccess);
88 rb.Push(version);
89 }
90
91 void Check(HLERequestContext& ctx) {
92 LOG_INFO(Service_NGC, "(STUBBED) called");
93
94 struct InputParameters {
95 u32 flags;
96 ProfanityFilterOption option;
97 };
98
99 IPC::RequestParser rp{ctx};
100 [[maybe_unused]] const auto params = rp.PopRaw<InputParameters>();
101 [[maybe_unused]] const auto input = ctx.ReadBuffer(0);
102
103 // This calls nn::ngc::ProfanityFilter::CheckProfanityWords
104 const u32 out_flags = 0;
105
106 IPC::ResponseBuilder rb{ctx, 3};
107 rb.Push(ResultSuccess);
108 rb.Push(out_flags);
109 }
110
111 void Mask(HLERequestContext& ctx) {
112 LOG_INFO(Service_NGC, "(STUBBED) called");
113
114 struct InputParameters {
115 u32 flags;
116 ProfanityFilterOption option;
117 };
118
119 IPC::RequestParser rp{ctx};
120 [[maybe_unused]] const auto params = rp.PopRaw<InputParameters>();
121 const auto input = ctx.ReadBuffer(0);
122
123 // This calls nn::ngc::ProfanityFilter::MaskProfanityWordsInText
124 const u32 out_flags = 0;
125 ctx.WriteBuffer(input);
126
127 IPC::ResponseBuilder rb{ctx, 3};
128 rb.Push(ResultSuccess);
129 rb.Push(out_flags);
130 }
131
132 void Reload(HLERequestContext& ctx) {
133 LOG_INFO(Service_NGC, "(STUBBED) called");
134
135 // This reloads the database.
136
137 IPC::ResponseBuilder rb{ctx, 2};
138 rb.Push(ResultSuccess);
139 }
140};
141
142void LoopProcess(Core::System& system) {
143 auto server_manager = std::make_unique<ServerManager>(system);
144
145 server_manager->RegisterNamedService("ngct:u", std::make_shared<NgctServiceImpl>(system));
146 server_manager->RegisterNamedService("ngc:u", std::make_shared<NgcServiceImpl>(system));
147 ServerManager::RunServer(std::move(server_manager));
148}
149
150} // namespace Service::NGC
diff --git a/src/core/hle/service/ngct/ngct.h b/src/core/hle/service/ngc/ngc.h
index 27c34dad4..823b1aa81 100644
--- a/src/core/hle/service/ngct/ngct.h
+++ b/src/core/hle/service/ngc/ngc.h
@@ -7,8 +7,8 @@ namespace Core {
7class System; 7class System;
8} 8}
9 9
10namespace Service::NGCT { 10namespace Service::NGC {
11 11
12void LoopProcess(Core::System& system); 12void LoopProcess(Core::System& system);
13 13
14} // namespace Service::NGCT 14} // namespace Service::NGC
diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp
deleted file mode 100644
index 493c80ed2..000000000
--- a/src/core/hle/service/ngct/ngct.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/string_util.h"
5#include "core/core.h"
6#include "core/hle/service/ipc_helpers.h"
7#include "core/hle/service/ngct/ngct.h"
8#include "core/hle/service/server_manager.h"
9#include "core/hle/service/service.h"
10
11namespace Service::NGCT {
12
13class IService final : public ServiceFramework<IService> {
14public:
15 explicit IService(Core::System& system_) : ServiceFramework{system_, "ngct:u"} {
16 // clang-format off
17 static const FunctionInfo functions[] = {
18 {0, &IService::Match, "Match"},
19 {1, &IService::Filter, "Filter"},
20 };
21 // clang-format on
22
23 RegisterHandlers(functions);
24 }
25
26private:
27 void Match(HLERequestContext& ctx) {
28 const auto buffer = ctx.ReadBuffer();
29 const auto text = Common::StringFromFixedZeroTerminatedBuffer(
30 reinterpret_cast<const char*>(buffer.data()), buffer.size());
31
32 LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text);
33
34 IPC::ResponseBuilder rb{ctx, 3};
35 rb.Push(ResultSuccess);
36 // Return false since we don't censor anything
37 rb.Push(false);
38 }
39
40 void Filter(HLERequestContext& ctx) {
41 const auto buffer = ctx.ReadBuffer();
42 const auto text = Common::StringFromFixedZeroTerminatedBuffer(
43 reinterpret_cast<const char*>(buffer.data()), buffer.size());
44
45 LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text);
46
47 // Return the same string since we don't censor anything
48 ctx.WriteBuffer(buffer);
49
50 IPC::ResponseBuilder rb{ctx, 2};
51 rb.Push(ResultSuccess);
52 }
53};
54
55void LoopProcess(Core::System& system) {
56 auto server_manager = std::make_unique<ServerManager>(system);
57
58 server_manager->RegisterNamedService("ngct:u", std::make_shared<IService>(system));
59 ServerManager::RunServer(std::move(server_manager));
60}
61
62} // namespace Service::NGCT
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 69cdb5918..0ad607391 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -43,7 +43,7 @@
43#include "core/hle/service/ncm/ncm.h" 43#include "core/hle/service/ncm/ncm.h"
44#include "core/hle/service/nfc/nfc.h" 44#include "core/hle/service/nfc/nfc.h"
45#include "core/hle/service/nfp/nfp.h" 45#include "core/hle/service/nfp/nfp.h"
46#include "core/hle/service/ngct/ngct.h" 46#include "core/hle/service/ngc/ngc.h"
47#include "core/hle/service/nifm/nifm.h" 47#include "core/hle/service/nifm/nifm.h"
48#include "core/hle/service/nim/nim.h" 48#include "core/hle/service/nim/nim.h"
49#include "core/hle/service/npns/npns.h" 49#include "core/hle/service/npns/npns.h"
@@ -257,7 +257,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
257 kernel.RunOnGuestCoreProcess("NCM", [&] { NCM::LoopProcess(system); }); 257 kernel.RunOnGuestCoreProcess("NCM", [&] { NCM::LoopProcess(system); });
258 kernel.RunOnGuestCoreProcess("nfc", [&] { NFC::LoopProcess(system); }); 258 kernel.RunOnGuestCoreProcess("nfc", [&] { NFC::LoopProcess(system); });
259 kernel.RunOnGuestCoreProcess("nfp", [&] { NFP::LoopProcess(system); }); 259 kernel.RunOnGuestCoreProcess("nfp", [&] { NFP::LoopProcess(system); });
260 kernel.RunOnGuestCoreProcess("ngct", [&] { NGCT::LoopProcess(system); }); 260 kernel.RunOnGuestCoreProcess("ngc", [&] { NGC::LoopProcess(system); });
261 kernel.RunOnGuestCoreProcess("nifm", [&] { NIFM::LoopProcess(system); }); 261 kernel.RunOnGuestCoreProcess("nifm", [&] { NIFM::LoopProcess(system); });
262 kernel.RunOnGuestCoreProcess("nim", [&] { NIM::LoopProcess(system); }); 262 kernel.RunOnGuestCoreProcess("nim", [&] { NIM::LoopProcess(system); });
263 kernel.RunOnGuestCoreProcess("npns", [&] { NPNS::LoopProcess(system); }); 263 kernel.RunOnGuestCoreProcess("npns", [&] { NPNS::LoopProcess(system); });