summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Liam2024-02-17 11:30:02 -0500
committerGravatar Liam2024-02-18 10:32:21 -0500
commit270d07be2fb0c190e3b52686dbe7d72c0394f54d (patch)
tree5946fea94dbfa149717946c1c6ad08a79c3360d8
parentns: rename results header (diff)
downloadyuzu-270d07be2fb0c190e3b52686dbe7d72c0394f54d.tar.gz
yuzu-270d07be2fb0c190e3b52686dbe7d72c0394f54d.tar.xz
yuzu-270d07be2fb0c190e3b52686dbe7d72c0394f54d.zip
ns: rewrite IPlatformServiceManager
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/file_sys/system_archive/shared_font.cpp2
-rw-r--r--src/core/hle/service/am/frontend/applet_web_browser.cpp2
-rw-r--r--src/core/hle/service/ns/ns.cpp2
-rw-r--r--src/core/hle/service/ns/platform_service_manager.cpp (renamed from src/core/hle/service/ns/iplatform_service_manager.cpp)130
-rw-r--r--src/core/hle/service/ns/platform_service_manager.h (renamed from src/core/hle/service/ns/iplatform_service_manager.h)33
6 files changed, 81 insertions, 92 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index c62555002..5eedaaf35 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -739,8 +739,6 @@ add_library(core STATIC
739 hle/service/nim/nim.h 739 hle/service/nim/nim.h
740 hle/service/npns/npns.cpp 740 hle/service/npns/npns.cpp
741 hle/service/npns/npns.h 741 hle/service/npns/npns.h
742 hle/service/ns/iplatform_service_manager.cpp
743 hle/service/ns/iplatform_service_manager.h
744 hle/service/ns/language.cpp 742 hle/service/ns/language.cpp
745 hle/service/ns/language.h 743 hle/service/ns/language.h
746 hle/service/ns/ns_results.h 744 hle/service/ns/ns_results.h
@@ -748,6 +746,8 @@ add_library(core STATIC
748 hle/service/ns/ns.h 746 hle/service/ns/ns.h
749 hle/service/ns/pdm_qry.cpp 747 hle/service/ns/pdm_qry.cpp
750 hle/service/ns/pdm_qry.h 748 hle/service/ns/pdm_qry.h
749 hle/service/ns/platform_service_manager.cpp
750 hle/service/ns/platform_service_manager.h
751 hle/service/nvdrv/core/container.cpp 751 hle/service/nvdrv/core/container.cpp
752 hle/service/nvdrv/core/container.h 752 hle/service/nvdrv/core/container.h
753 hle/service/nvdrv/core/heap_mapper.cpp 753 hle/service/nvdrv/core/heap_mapper.cpp
diff --git a/src/core/file_sys/system_archive/shared_font.cpp b/src/core/file_sys/system_archive/shared_font.cpp
index deb52069d..9ea16aa59 100644
--- a/src/core/file_sys/system_archive/shared_font.cpp
+++ b/src/core/file_sys/system_archive/shared_font.cpp
@@ -9,7 +9,7 @@
9#include "core/file_sys/system_archive/data/font_standard.h" 9#include "core/file_sys/system_archive/data/font_standard.h"
10#include "core/file_sys/system_archive/shared_font.h" 10#include "core/file_sys/system_archive/shared_font.h"
11#include "core/file_sys/vfs/vfs_vector.h" 11#include "core/file_sys/vfs/vfs_vector.h"
12#include "core/hle/service/ns/iplatform_service_manager.h" 12#include "core/hle/service/ns/platform_service_manager.h"
13 13
14namespace FileSys::SystemArchive { 14namespace FileSys::SystemArchive {
15 15
diff --git a/src/core/hle/service/am/frontend/applet_web_browser.cpp b/src/core/hle/service/am/frontend/applet_web_browser.cpp
index bb60260b4..835c20c4e 100644
--- a/src/core/hle/service/am/frontend/applet_web_browser.cpp
+++ b/src/core/hle/service/am/frontend/applet_web_browser.cpp
@@ -22,7 +22,7 @@
22#include "core/hle/service/am/frontend/applet_web_browser.h" 22#include "core/hle/service/am/frontend/applet_web_browser.h"
23#include "core/hle/service/am/service/storage.h" 23#include "core/hle/service/am/service/storage.h"
24#include "core/hle/service/filesystem/filesystem.h" 24#include "core/hle/service/filesystem/filesystem.h"
25#include "core/hle/service/ns/iplatform_service_manager.h" 25#include "core/hle/service/ns/platform_service_manager.h"
26#include "core/loader/loader.h" 26#include "core/loader/loader.h"
27 27
28namespace Service::AM::Frontend { 28namespace Service::AM::Frontend {
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 2b95cdae3..84961fc0c 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -11,11 +11,11 @@
11#include "core/hle/service/filesystem/filesystem.h" 11#include "core/hle/service/filesystem/filesystem.h"
12#include "core/hle/service/glue/glue_manager.h" 12#include "core/hle/service/glue/glue_manager.h"
13#include "core/hle/service/ipc_helpers.h" 13#include "core/hle/service/ipc_helpers.h"
14#include "core/hle/service/ns/iplatform_service_manager.h"
15#include "core/hle/service/ns/language.h" 14#include "core/hle/service/ns/language.h"
16#include "core/hle/service/ns/ns.h" 15#include "core/hle/service/ns/ns.h"
17#include "core/hle/service/ns/ns_results.h" 16#include "core/hle/service/ns/ns_results.h"
18#include "core/hle/service/ns/pdm_qry.h" 17#include "core/hle/service/ns/pdm_qry.h"
18#include "core/hle/service/ns/platform_service_manager.h"
19#include "core/hle/service/server_manager.h" 19#include "core/hle/service/server_manager.h"
20#include "core/hle/service/set/settings_server.h" 20#include "core/hle/service/set/settings_server.h"
21 21
diff --git a/src/core/hle/service/ns/iplatform_service_manager.cpp b/src/core/hle/service/ns/platform_service_manager.cpp
index 46268be95..23cf05005 100644
--- a/src/core/hle/service/ns/iplatform_service_manager.cpp
+++ b/src/core/hle/service/ns/platform_service_manager.cpp
@@ -18,9 +18,9 @@
18#include "core/hle/kernel/k_shared_memory.h" 18#include "core/hle/kernel/k_shared_memory.h"
19#include "core/hle/kernel/kernel.h" 19#include "core/hle/kernel/kernel.h"
20#include "core/hle/kernel/physical_memory.h" 20#include "core/hle/kernel/physical_memory.h"
21#include "core/hle/service/cmif_serialization.h"
21#include "core/hle/service/filesystem/filesystem.h" 22#include "core/hle/service/filesystem/filesystem.h"
22#include "core/hle/service/ipc_helpers.h" 23#include "core/hle/service/ns/platform_service_manager.h"
23#include "core/hle/service/ns/iplatform_service_manager.h"
24 24
25namespace Service::NS { 25namespace Service::NS {
26 26
@@ -37,11 +37,6 @@ constexpr u32 EXPECTED_MAGIC{0x36f81a1e}; // What we expect the encrypted bfttf
37constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000}; 37constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000};
38constexpr FontRegion EMPTY_REGION{0, 0}; 38constexpr FontRegion EMPTY_REGION{0, 0};
39 39
40enum class LoadState : u32 {
41 Loading = 0,
42 Done = 1,
43};
44
45static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMemory& output, 40static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMemory& output,
46 std::size_t& offset) { 41 std::size_t& offset) {
47 ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE, 42 ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE,
@@ -138,13 +133,13 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch
138 : ServiceFramework{system_, service_name_}, impl{std::make_unique<Impl>()} { 133 : ServiceFramework{system_, service_name_}, impl{std::make_unique<Impl>()} {
139 // clang-format off 134 // clang-format off
140 static const FunctionInfo functions[] = { 135 static const FunctionInfo functions[] = {
141 {0, &IPlatformServiceManager::RequestLoad, "RequestLoad"}, 136 {0, D<&IPlatformServiceManager::RequestLoad>, "RequestLoad"},
142 {1, &IPlatformServiceManager::GetLoadState, "GetLoadState"}, 137 {1, D<&IPlatformServiceManager::GetLoadState>, "GetLoadState"},
143 {2, &IPlatformServiceManager::GetSize, "GetSize"}, 138 {2, D<&IPlatformServiceManager::GetSize>, "GetSize"},
144 {3, &IPlatformServiceManager::GetSharedMemoryAddressOffset, "GetSharedMemoryAddressOffset"}, 139 {3, D<&IPlatformServiceManager::GetSharedMemoryAddressOffset>, "GetSharedMemoryAddressOffset"},
145 {4, &IPlatformServiceManager::GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"}, 140 {4, D<&IPlatformServiceManager::GetSharedMemoryNativeHandle>, "GetSharedMemoryNativeHandle"},
146 {5, &IPlatformServiceManager::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriority"}, 141 {5, D<&IPlatformServiceManager::GetSharedFontInOrderOfPriority>, "GetSharedFontInOrderOfPriority"},
147 {6, &IPlatformServiceManager::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriorityForSystem"}, 142 {6, D<&IPlatformServiceManager::GetSharedFontInOrderOfPriority>, "GetSharedFontInOrderOfPriorityForSystem"},
148 {100, nullptr, "RequestApplicationFunctionAuthorization"}, 143 {100, nullptr, "RequestApplicationFunctionAuthorization"},
149 {101, nullptr, "RequestApplicationFunctionAuthorizationByProcessId"}, 144 {101, nullptr, "RequestApplicationFunctionAuthorizationByProcessId"},
150 {102, nullptr, "RequestApplicationFunctionAuthorizationByApplicationId"}, 145 {102, nullptr, "RequestApplicationFunctionAuthorizationByApplicationId"},
@@ -208,47 +203,33 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch
208 203
209IPlatformServiceManager::~IPlatformServiceManager() = default; 204IPlatformServiceManager::~IPlatformServiceManager() = default;
210 205
211void IPlatformServiceManager::RequestLoad(HLERequestContext& ctx) { 206Result IPlatformServiceManager::RequestLoad(SharedFontType type) {
212 IPC::RequestParser rp{ctx};
213 const u32 shared_font_type{rp.Pop<u32>()};
214 // Games don't call this so all fonts should be loaded 207 // Games don't call this so all fonts should be loaded
215 LOG_DEBUG(Service_NS, "called, shared_font_type={}", shared_font_type); 208 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
216 209 R_SUCCEED();
217 IPC::ResponseBuilder rb{ctx, 2};
218 rb.Push(ResultSuccess);
219} 210}
220 211
221void IPlatformServiceManager::GetLoadState(HLERequestContext& ctx) { 212Result IPlatformServiceManager::GetLoadState(Out<LoadState> out_load_state, SharedFontType type) {
222 IPC::RequestParser rp{ctx}; 213 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
223 const u32 font_id{rp.Pop<u32>()}; 214 *out_load_state = LoadState::Loaded;
224 LOG_DEBUG(Service_NS, "called, font_id={}", font_id); 215 R_SUCCEED();
225
226 IPC::ResponseBuilder rb{ctx, 3};
227 rb.Push(ResultSuccess);
228 rb.Push<u32>(static_cast<u32>(LoadState::Done));
229} 216}
230 217
231void IPlatformServiceManager::GetSize(HLERequestContext& ctx) { 218Result IPlatformServiceManager::GetSize(Out<u32> out_size, SharedFontType type) {
232 IPC::RequestParser rp{ctx}; 219 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
233 const u32 font_id{rp.Pop<u32>()}; 220 *out_size = impl->GetSharedFontRegion(static_cast<size_t>(type)).size;
234 LOG_DEBUG(Service_NS, "called, font_id={}", font_id); 221 R_SUCCEED();
235
236 IPC::ResponseBuilder rb{ctx, 3};
237 rb.Push(ResultSuccess);
238 rb.Push<u32>(impl->GetSharedFontRegion(font_id).size);
239} 222}
240 223
241void IPlatformServiceManager::GetSharedMemoryAddressOffset(HLERequestContext& ctx) { 224Result IPlatformServiceManager::GetSharedMemoryAddressOffset(Out<u32> out_shared_memory_offset,
242 IPC::RequestParser rp{ctx}; 225 SharedFontType type) {
243 const u32 font_id{rp.Pop<u32>()}; 226 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
244 LOG_DEBUG(Service_NS, "called, font_id={}", font_id); 227 *out_shared_memory_offset = impl->GetSharedFontRegion(static_cast<size_t>(type)).offset;
245 228 R_SUCCEED();
246 IPC::ResponseBuilder rb{ctx, 3};
247 rb.Push(ResultSuccess);
248 rb.Push<u32>(impl->GetSharedFontRegion(font_id).offset);
249} 229}
250 230
251void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx) { 231Result IPlatformServiceManager::GetSharedMemoryNativeHandle(
232 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_native_handle) {
252 // Map backing memory for the font data 233 // Map backing memory for the font data
253 LOG_DEBUG(Service_NS, "called"); 234 LOG_DEBUG(Service_NS, "called");
254 235
@@ -256,50 +237,37 @@ void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx
256 std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(), 237 std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(),
257 impl->shared_font->size()); 238 impl->shared_font->size());
258 239
259 IPC::ResponseBuilder rb{ctx, 2, 1}; 240 // FIXME: this shouldn't belong to the kernel
260 rb.Push(ResultSuccess); 241 *out_shared_memory_native_handle = &kernel.GetFontSharedMem();
261 rb.PushCopyObjects(&kernel.GetFontSharedMem()); 242 R_SUCCEED();
262} 243}
263 244
264void IPlatformServiceManager::GetSharedFontInOrderOfPriority(HLERequestContext& ctx) { 245Result IPlatformServiceManager::GetSharedFontInOrderOfPriority(
246 OutArray<u32, BufferAttr_HipcMapAlias> out_font_codes,
247 OutArray<u32, BufferAttr_HipcMapAlias> out_font_offsets,
248 OutArray<u32, BufferAttr_HipcMapAlias> out_font_sizes, Out<bool> out_fonts_are_loaded,
249 Out<u32> out_font_count, Set::LanguageCode language_code) {
250 LOG_DEBUG(Service_NS, "called, language_code={:#x}", language_code);
251
265 // The maximum number of elements that can be returned is 6. Regardless of the available fonts 252 // The maximum number of elements that can be returned is 6. Regardless of the available fonts
266 // or buffer size. 253 // or buffer size.
267 constexpr std::size_t MaxElementCount = 6; 254 constexpr size_t MaxElementCount = 6;
268 IPC::RequestParser rp{ctx};
269 const u64 language_code{rp.Pop<u64>()}; // TODO(ogniK): Find out what this is used for
270 const std::size_t font_codes_count =
271 std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(0));
272 const std::size_t font_offsets_count =
273 std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(1));
274 const std::size_t font_sizes_count =
275 std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(2));
276 LOG_DEBUG(Service_NS, "called, language_code={:X}", language_code);
277
278 IPC::ResponseBuilder rb{ctx, 4};
279 std::vector<u32> font_codes;
280 std::vector<u32> font_offsets;
281 std::vector<u32> font_sizes;
282 255
283 // TODO(ogniK): Have actual priority order 256 // TODO(ogniK): Have actual priority order
284 for (std::size_t i = 0; i < impl->shared_font_regions.size(); i++) { 257 const auto max_size = std::min({MaxElementCount, out_font_codes.size(), out_font_offsets.size(),
285 font_codes.push_back(static_cast<u32>(i)); 258 out_font_sizes.size(), impl->shared_font_regions.size()});
286 auto region = impl->GetSharedFontRegion(i);
287 font_offsets.push_back(region.offset);
288 font_sizes.push_back(region.size);
289 }
290 259
291 // Resize buffers if game requests smaller size output 260 for (size_t i = 0; i < max_size; i++) {
292 font_codes.resize(std::min(font_codes.size(), font_codes_count)); 261 auto region = impl->GetSharedFontRegion(i);
293 font_offsets.resize(std::min(font_offsets.size(), font_offsets_count));
294 font_sizes.resize(std::min(font_sizes.size(), font_sizes_count));
295 262
296 ctx.WriteBuffer(font_codes, 0); 263 out_font_codes[i] = static_cast<u32>(i);
297 ctx.WriteBuffer(font_offsets, 1); 264 out_font_offsets[i] = region.offset;
298 ctx.WriteBuffer(font_sizes, 2); 265 out_font_sizes[i] = region.size;
266 }
299 267
300 rb.Push(ResultSuccess); 268 *out_fonts_are_loaded = true;
301 rb.Push<u8>(static_cast<u8>(LoadState::Done)); // Fonts Loaded 269 *out_font_count = static_cast<u32>(max_size);
302 rb.Push<u32>(static_cast<u32>(font_codes.size())); 270 R_SUCCEED();
303} 271}
304 272
305} // namespace Service::NS 273} // namespace Service::NS
diff --git a/src/core/hle/service/ns/iplatform_service_manager.h b/src/core/hle/service/ns/platform_service_manager.h
index 03071e02b..b82c385a6 100644
--- a/src/core/hle/service/ns/iplatform_service_manager.h
+++ b/src/core/hle/service/ns/platform_service_manager.h
@@ -5,7 +5,9 @@
5 5
6#include <memory> 6#include <memory>
7#include <vector> 7#include <vector>
8#include "core/hle/service/cmif_types.h"
8#include "core/hle/service/service.h" 9#include "core/hle/service/service.h"
10#include "core/hle/service/set/settings_types.h"
9 11
10namespace Service { 12namespace Service {
11 13
@@ -23,6 +25,20 @@ enum class FontArchives : u64 {
23 ChineseSimple = 0x0100000000000814, 25 ChineseSimple = 0x0100000000000814,
24}; 26};
25 27
28enum class SharedFontType : u32 {
29 JapanUSEuropeStandard = 0,
30 ChineseSimplified = 1,
31 ExtendedChineseSimplified = 2,
32 ChineseTraditional = 3,
33 KoreanHangul = 4,
34 NintendoExtended = 5,
35};
36
37enum class LoadState : u32 {
38 Loading = 0,
39 Loaded = 1,
40};
41
26constexpr std::array<std::pair<FontArchives, const char*>, 7> SHARED_FONTS{ 42constexpr std::array<std::pair<FontArchives, const char*>, 7> SHARED_FONTS{
27 std::make_pair(FontArchives::Standard, "nintendo_udsg-r_std_003.bfttf"), 43 std::make_pair(FontArchives::Standard, "nintendo_udsg-r_std_003.bfttf"),
28 std::make_pair(FontArchives::ChineseSimple, "nintendo_udsg-r_org_zh-cn_003.bfttf"), 44 std::make_pair(FontArchives::ChineseSimple, "nintendo_udsg-r_org_zh-cn_003.bfttf"),
@@ -42,12 +58,17 @@ public:
42 ~IPlatformServiceManager() override; 58 ~IPlatformServiceManager() override;
43 59
44private: 60private:
45 void RequestLoad(HLERequestContext& ctx); 61 Result RequestLoad(SharedFontType type);
46 void GetLoadState(HLERequestContext& ctx); 62 Result GetLoadState(Out<LoadState> out_load_state, SharedFontType type);
47 void GetSize(HLERequestContext& ctx); 63 Result GetSize(Out<u32> out_size, SharedFontType type);
48 void GetSharedMemoryAddressOffset(HLERequestContext& ctx); 64 Result GetSharedMemoryAddressOffset(Out<u32> out_shared_memory_offset, SharedFontType type);
49 void GetSharedMemoryNativeHandle(HLERequestContext& ctx); 65 Result GetSharedMemoryNativeHandle(
50 void GetSharedFontInOrderOfPriority(HLERequestContext& ctx); 66 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_native_handle);
67 Result GetSharedFontInOrderOfPriority(OutArray<u32, BufferAttr_HipcMapAlias> out_font_codes,
68 OutArray<u32, BufferAttr_HipcMapAlias> out_font_offsets,
69 OutArray<u32, BufferAttr_HipcMapAlias> out_font_sizes,
70 Out<bool> out_fonts_are_loaded, Out<u32> out_font_count,
71 Set::LanguageCode language_code);
51 72
52 struct Impl; 73 struct Impl;
53 std::unique_ptr<Impl> impl; 74 std::unique_ptr<Impl> impl;