mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-23 06:25:46 +00:00
ns: rewrite IPlatformServiceManager
This commit is contained in:
parent
947cdbe4b1
commit
270d07be2f
|
@ -739,8 +739,6 @@ add_library(core STATIC
|
||||||
hle/service/nim/nim.h
|
hle/service/nim/nim.h
|
||||||
hle/service/npns/npns.cpp
|
hle/service/npns/npns.cpp
|
||||||
hle/service/npns/npns.h
|
hle/service/npns/npns.h
|
||||||
hle/service/ns/iplatform_service_manager.cpp
|
|
||||||
hle/service/ns/iplatform_service_manager.h
|
|
||||||
hle/service/ns/language.cpp
|
hle/service/ns/language.cpp
|
||||||
hle/service/ns/language.h
|
hle/service/ns/language.h
|
||||||
hle/service/ns/ns_results.h
|
hle/service/ns/ns_results.h
|
||||||
|
@ -748,6 +746,8 @@ add_library(core STATIC
|
||||||
hle/service/ns/ns.h
|
hle/service/ns/ns.h
|
||||||
hle/service/ns/pdm_qry.cpp
|
hle/service/ns/pdm_qry.cpp
|
||||||
hle/service/ns/pdm_qry.h
|
hle/service/ns/pdm_qry.h
|
||||||
|
hle/service/ns/platform_service_manager.cpp
|
||||||
|
hle/service/ns/platform_service_manager.h
|
||||||
hle/service/nvdrv/core/container.cpp
|
hle/service/nvdrv/core/container.cpp
|
||||||
hle/service/nvdrv/core/container.h
|
hle/service/nvdrv/core/container.h
|
||||||
hle/service/nvdrv/core/heap_mapper.cpp
|
hle/service/nvdrv/core/heap_mapper.cpp
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "core/file_sys/system_archive/data/font_standard.h"
|
#include "core/file_sys/system_archive/data/font_standard.h"
|
||||||
#include "core/file_sys/system_archive/shared_font.h"
|
#include "core/file_sys/system_archive/shared_font.h"
|
||||||
#include "core/file_sys/vfs/vfs_vector.h"
|
#include "core/file_sys/vfs/vfs_vector.h"
|
||||||
#include "core/hle/service/ns/iplatform_service_manager.h"
|
#include "core/hle/service/ns/platform_service_manager.h"
|
||||||
|
|
||||||
namespace FileSys::SystemArchive {
|
namespace FileSys::SystemArchive {
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "core/hle/service/am/frontend/applet_web_browser.h"
|
#include "core/hle/service/am/frontend/applet_web_browser.h"
|
||||||
#include "core/hle/service/am/service/storage.h"
|
#include "core/hle/service/am/service/storage.h"
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/ns/iplatform_service_manager.h"
|
#include "core/hle/service/ns/platform_service_manager.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
|
|
||||||
namespace Service::AM::Frontend {
|
namespace Service::AM::Frontend {
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/glue/glue_manager.h"
|
#include "core/hle/service/glue/glue_manager.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ipc_helpers.h"
|
||||||
#include "core/hle/service/ns/iplatform_service_manager.h"
|
|
||||||
#include "core/hle/service/ns/language.h"
|
#include "core/hle/service/ns/language.h"
|
||||||
#include "core/hle/service/ns/ns.h"
|
#include "core/hle/service/ns/ns.h"
|
||||||
#include "core/hle/service/ns/ns_results.h"
|
#include "core/hle/service/ns/ns_results.h"
|
||||||
#include "core/hle/service/ns/pdm_qry.h"
|
#include "core/hle/service/ns/pdm_qry.h"
|
||||||
|
#include "core/hle/service/ns/platform_service_manager.h"
|
||||||
#include "core/hle/service/server_manager.h"
|
#include "core/hle/service/server_manager.h"
|
||||||
#include "core/hle/service/set/settings_server.h"
|
#include "core/hle/service/set/settings_server.h"
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
#include "core/hle/kernel/k_shared_memory.h"
|
#include "core/hle/kernel/k_shared_memory.h"
|
||||||
#include "core/hle/kernel/kernel.h"
|
#include "core/hle/kernel/kernel.h"
|
||||||
#include "core/hle/kernel/physical_memory.h"
|
#include "core/hle/kernel/physical_memory.h"
|
||||||
|
#include "core/hle/service/cmif_serialization.h"
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/ipc_helpers.h"
|
#include "core/hle/service/ns/platform_service_manager.h"
|
||||||
#include "core/hle/service/ns/iplatform_service_manager.h"
|
|
||||||
|
|
||||||
namespace Service::NS {
|
namespace Service::NS {
|
||||||
|
|
||||||
|
@ -37,11 +37,6 @@ constexpr u32 EXPECTED_MAGIC{0x36f81a1e}; // What we expect the encrypted bfttf
|
||||||
constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000};
|
constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000};
|
||||||
constexpr FontRegion EMPTY_REGION{0, 0};
|
constexpr FontRegion EMPTY_REGION{0, 0};
|
||||||
|
|
||||||
enum class LoadState : u32 {
|
|
||||||
Loading = 0,
|
|
||||||
Done = 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMemory& output,
|
static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMemory& output,
|
||||||
std::size_t& offset) {
|
std::size_t& offset) {
|
||||||
ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE,
|
ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE,
|
||||||
|
@ -138,13 +133,13 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch
|
||||||
: ServiceFramework{system_, service_name_}, impl{std::make_unique<Impl>()} {
|
: ServiceFramework{system_, service_name_}, impl{std::make_unique<Impl>()} {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IPlatformServiceManager::RequestLoad, "RequestLoad"},
|
{0, D<&IPlatformServiceManager::RequestLoad>, "RequestLoad"},
|
||||||
{1, &IPlatformServiceManager::GetLoadState, "GetLoadState"},
|
{1, D<&IPlatformServiceManager::GetLoadState>, "GetLoadState"},
|
||||||
{2, &IPlatformServiceManager::GetSize, "GetSize"},
|
{2, D<&IPlatformServiceManager::GetSize>, "GetSize"},
|
||||||
{3, &IPlatformServiceManager::GetSharedMemoryAddressOffset, "GetSharedMemoryAddressOffset"},
|
{3, D<&IPlatformServiceManager::GetSharedMemoryAddressOffset>, "GetSharedMemoryAddressOffset"},
|
||||||
{4, &IPlatformServiceManager::GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"},
|
{4, D<&IPlatformServiceManager::GetSharedMemoryNativeHandle>, "GetSharedMemoryNativeHandle"},
|
||||||
{5, &IPlatformServiceManager::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriority"},
|
{5, D<&IPlatformServiceManager::GetSharedFontInOrderOfPriority>, "GetSharedFontInOrderOfPriority"},
|
||||||
{6, &IPlatformServiceManager::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriorityForSystem"},
|
{6, D<&IPlatformServiceManager::GetSharedFontInOrderOfPriority>, "GetSharedFontInOrderOfPriorityForSystem"},
|
||||||
{100, nullptr, "RequestApplicationFunctionAuthorization"},
|
{100, nullptr, "RequestApplicationFunctionAuthorization"},
|
||||||
{101, nullptr, "RequestApplicationFunctionAuthorizationByProcessId"},
|
{101, nullptr, "RequestApplicationFunctionAuthorizationByProcessId"},
|
||||||
{102, nullptr, "RequestApplicationFunctionAuthorizationByApplicationId"},
|
{102, nullptr, "RequestApplicationFunctionAuthorizationByApplicationId"},
|
||||||
|
@ -208,47 +203,33 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch
|
||||||
|
|
||||||
IPlatformServiceManager::~IPlatformServiceManager() = default;
|
IPlatformServiceManager::~IPlatformServiceManager() = default;
|
||||||
|
|
||||||
void IPlatformServiceManager::RequestLoad(HLERequestContext& ctx) {
|
Result IPlatformServiceManager::RequestLoad(SharedFontType type) {
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const u32 shared_font_type{rp.Pop<u32>()};
|
|
||||||
// Games don't call this so all fonts should be loaded
|
// Games don't call this so all fonts should be loaded
|
||||||
LOG_DEBUG(Service_NS, "called, shared_font_type={}", shared_font_type);
|
LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
|
||||||
|
R_SUCCEED();
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPlatformServiceManager::GetLoadState(HLERequestContext& ctx) {
|
Result IPlatformServiceManager::GetLoadState(Out<LoadState> out_load_state, SharedFontType type) {
|
||||||
IPC::RequestParser rp{ctx};
|
LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
|
||||||
const u32 font_id{rp.Pop<u32>()};
|
*out_load_state = LoadState::Loaded;
|
||||||
LOG_DEBUG(Service_NS, "called, font_id={}", font_id);
|
R_SUCCEED();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u32>(static_cast<u32>(LoadState::Done));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPlatformServiceManager::GetSize(HLERequestContext& ctx) {
|
Result IPlatformServiceManager::GetSize(Out<u32> out_size, SharedFontType type) {
|
||||||
IPC::RequestParser rp{ctx};
|
LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
|
||||||
const u32 font_id{rp.Pop<u32>()};
|
*out_size = impl->GetSharedFontRegion(static_cast<size_t>(type)).size;
|
||||||
LOG_DEBUG(Service_NS, "called, font_id={}", font_id);
|
R_SUCCEED();
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u32>(impl->GetSharedFontRegion(font_id).size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPlatformServiceManager::GetSharedMemoryAddressOffset(HLERequestContext& ctx) {
|
Result IPlatformServiceManager::GetSharedMemoryAddressOffset(Out<u32> out_shared_memory_offset,
|
||||||
IPC::RequestParser rp{ctx};
|
SharedFontType type) {
|
||||||
const u32 font_id{rp.Pop<u32>()};
|
LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
|
||||||
LOG_DEBUG(Service_NS, "called, font_id={}", font_id);
|
*out_shared_memory_offset = impl->GetSharedFontRegion(static_cast<size_t>(type)).offset;
|
||||||
|
R_SUCCEED();
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u32>(impl->GetSharedFontRegion(font_id).offset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx) {
|
Result IPlatformServiceManager::GetSharedMemoryNativeHandle(
|
||||||
|
OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_native_handle) {
|
||||||
// Map backing memory for the font data
|
// Map backing memory for the font data
|
||||||
LOG_DEBUG(Service_NS, "called");
|
LOG_DEBUG(Service_NS, "called");
|
||||||
|
|
||||||
|
@ -256,50 +237,37 @@ void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx
|
||||||
std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(),
|
std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(),
|
||||||
impl->shared_font->size());
|
impl->shared_font->size());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
// FIXME: this shouldn't belong to the kernel
|
||||||
rb.Push(ResultSuccess);
|
*out_shared_memory_native_handle = &kernel.GetFontSharedMem();
|
||||||
rb.PushCopyObjects(&kernel.GetFontSharedMem());
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IPlatformServiceManager::GetSharedFontInOrderOfPriority(HLERequestContext& ctx) {
|
Result IPlatformServiceManager::GetSharedFontInOrderOfPriority(
|
||||||
|
OutArray<u32, BufferAttr_HipcMapAlias> out_font_codes,
|
||||||
|
OutArray<u32, BufferAttr_HipcMapAlias> out_font_offsets,
|
||||||
|
OutArray<u32, BufferAttr_HipcMapAlias> out_font_sizes, Out<bool> out_fonts_are_loaded,
|
||||||
|
Out<u32> out_font_count, Set::LanguageCode language_code) {
|
||||||
|
LOG_DEBUG(Service_NS, "called, language_code={:#x}", language_code);
|
||||||
|
|
||||||
// The maximum number of elements that can be returned is 6. Regardless of the available fonts
|
// The maximum number of elements that can be returned is 6. Regardless of the available fonts
|
||||||
// or buffer size.
|
// or buffer size.
|
||||||
constexpr std::size_t MaxElementCount = 6;
|
constexpr size_t MaxElementCount = 6;
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const u64 language_code{rp.Pop<u64>()}; // TODO(ogniK): Find out what this is used for
|
|
||||||
const std::size_t font_codes_count =
|
|
||||||
std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(0));
|
|
||||||
const std::size_t font_offsets_count =
|
|
||||||
std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(1));
|
|
||||||
const std::size_t font_sizes_count =
|
|
||||||
std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(2));
|
|
||||||
LOG_DEBUG(Service_NS, "called, language_code={:X}", language_code);
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
|
||||||
std::vector<u32> font_codes;
|
|
||||||
std::vector<u32> font_offsets;
|
|
||||||
std::vector<u32> font_sizes;
|
|
||||||
|
|
||||||
// TODO(ogniK): Have actual priority order
|
// TODO(ogniK): Have actual priority order
|
||||||
for (std::size_t i = 0; i < impl->shared_font_regions.size(); i++) {
|
const auto max_size = std::min({MaxElementCount, out_font_codes.size(), out_font_offsets.size(),
|
||||||
font_codes.push_back(static_cast<u32>(i));
|
out_font_sizes.size(), impl->shared_font_regions.size()});
|
||||||
|
|
||||||
|
for (size_t i = 0; i < max_size; i++) {
|
||||||
auto region = impl->GetSharedFontRegion(i);
|
auto region = impl->GetSharedFontRegion(i);
|
||||||
font_offsets.push_back(region.offset);
|
|
||||||
font_sizes.push_back(region.size);
|
out_font_codes[i] = static_cast<u32>(i);
|
||||||
|
out_font_offsets[i] = region.offset;
|
||||||
|
out_font_sizes[i] = region.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resize buffers if game requests smaller size output
|
*out_fonts_are_loaded = true;
|
||||||
font_codes.resize(std::min(font_codes.size(), font_codes_count));
|
*out_font_count = static_cast<u32>(max_size);
|
||||||
font_offsets.resize(std::min(font_offsets.size(), font_offsets_count));
|
R_SUCCEED();
|
||||||
font_sizes.resize(std::min(font_sizes.size(), font_sizes_count));
|
|
||||||
|
|
||||||
ctx.WriteBuffer(font_codes, 0);
|
|
||||||
ctx.WriteBuffer(font_offsets, 1);
|
|
||||||
ctx.WriteBuffer(font_sizes, 2);
|
|
||||||
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push<u8>(static_cast<u8>(LoadState::Done)); // Fonts Loaded
|
|
||||||
rb.Push<u32>(static_cast<u32>(font_codes.size()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::NS
|
} // namespace Service::NS
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "core/hle/service/cmif_types.h"
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
#include "core/hle/service/set/settings_types.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
|
|
||||||
|
@ -23,6 +25,20 @@ enum class FontArchives : u64 {
|
||||||
ChineseSimple = 0x0100000000000814,
|
ChineseSimple = 0x0100000000000814,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class SharedFontType : u32 {
|
||||||
|
JapanUSEuropeStandard = 0,
|
||||||
|
ChineseSimplified = 1,
|
||||||
|
ExtendedChineseSimplified = 2,
|
||||||
|
ChineseTraditional = 3,
|
||||||
|
KoreanHangul = 4,
|
||||||
|
NintendoExtended = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class LoadState : u32 {
|
||||||
|
Loading = 0,
|
||||||
|
Loaded = 1,
|
||||||
|
};
|
||||||
|
|
||||||
constexpr std::array<std::pair<FontArchives, const char*>, 7> SHARED_FONTS{
|
constexpr std::array<std::pair<FontArchives, const char*>, 7> SHARED_FONTS{
|
||||||
std::make_pair(FontArchives::Standard, "nintendo_udsg-r_std_003.bfttf"),
|
std::make_pair(FontArchives::Standard, "nintendo_udsg-r_std_003.bfttf"),
|
||||||
std::make_pair(FontArchives::ChineseSimple, "nintendo_udsg-r_org_zh-cn_003.bfttf"),
|
std::make_pair(FontArchives::ChineseSimple, "nintendo_udsg-r_org_zh-cn_003.bfttf"),
|
||||||
|
@ -42,12 +58,17 @@ public:
|
||||||
~IPlatformServiceManager() override;
|
~IPlatformServiceManager() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RequestLoad(HLERequestContext& ctx);
|
Result RequestLoad(SharedFontType type);
|
||||||
void GetLoadState(HLERequestContext& ctx);
|
Result GetLoadState(Out<LoadState> out_load_state, SharedFontType type);
|
||||||
void GetSize(HLERequestContext& ctx);
|
Result GetSize(Out<u32> out_size, SharedFontType type);
|
||||||
void GetSharedMemoryAddressOffset(HLERequestContext& ctx);
|
Result GetSharedMemoryAddressOffset(Out<u32> out_shared_memory_offset, SharedFontType type);
|
||||||
void GetSharedMemoryNativeHandle(HLERequestContext& ctx);
|
Result GetSharedMemoryNativeHandle(
|
||||||
void GetSharedFontInOrderOfPriority(HLERequestContext& ctx);
|
OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_native_handle);
|
||||||
|
Result GetSharedFontInOrderOfPriority(OutArray<u32, BufferAttr_HipcMapAlias> out_font_codes,
|
||||||
|
OutArray<u32, BufferAttr_HipcMapAlias> out_font_offsets,
|
||||||
|
OutArray<u32, BufferAttr_HipcMapAlias> out_font_sizes,
|
||||||
|
Out<bool> out_fonts_are_loaded, Out<u32> out_font_count,
|
||||||
|
Set::LanguageCode language_code);
|
||||||
|
|
||||||
struct Impl;
|
struct Impl;
|
||||||
std::unique_ptr<Impl> impl;
|
std::unique_ptr<Impl> impl;
|
Loading…
Reference in a new issue