summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/apt
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2017-10-10 23:32:14 +0200
committerbunnei <bunneidev@gmail.com>2017-10-10 23:32:14 +0200
commit0906de9a14b735d1d409290ca050eb7d2c2d3d84 (patch)
tree79bb57d3a4dc4ca377e7a62744c3941de29e785b /src/core/hle/service/apt
parentMerge remote-tracking branch 'upstream/master' into nx (diff)
downloadyuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.gz
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.bz2
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.lz
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.xz
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.tar.zst
yuzu-0906de9a14b735d1d409290ca050eb7d2c2d3d84.zip
Diffstat (limited to 'src/core/hle/service/apt')
-rw-r--r--src/core/hle/service/apt/apt.cpp1124
-rw-r--r--src/core/hle/service/apt/apt.h533
-rw-r--r--src/core/hle/service/apt/apt_a.cpp110
-rw-r--r--src/core/hle/service/apt/apt_a.h22
-rw-r--r--src/core/hle/service/apt/apt_s.cpp110
-rw-r--r--src/core/hle/service/apt/apt_s.h29
-rw-r--r--src/core/hle/service/apt/apt_u.cpp107
-rw-r--r--src/core/hle/service/apt/apt_u.h29
-rw-r--r--src/core/hle/service/apt/bcfnt/bcfnt.cpp110
-rw-r--r--src/core/hle/service/apt/bcfnt/bcfnt.h92
10 files changed, 0 insertions, 2266 deletions
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
deleted file mode 100644
index 912ab550d..000000000
--- a/src/core/hle/service/apt/apt.cpp
+++ /dev/null
@@ -1,1124 +0,0 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include <boost/optional.hpp>
-#include "common/common_paths.h"
-#include "common/file_util.h"
-#include "common/logging/log.h"
-#include "core/core.h"
-#include "core/file_sys/file_backend.h"
-#include "core/hle/applets/applet.h"
-#include "core/hle/kernel/event.h"
-#include "core/hle/kernel/mutex.h"
-#include "core/hle/kernel/process.h"
-#include "core/hle/kernel/shared_memory.h"
-#include "core/hle/romfs.h"
-#include "core/hle/service/apt/apt.h"
-#include "core/hle/service/apt/apt_a.h"
-#include "core/hle/service/apt/apt_s.h"
-#include "core/hle/service/apt/apt_u.h"
-#include "core/hle/service/apt/bcfnt/bcfnt.h"
-#include "core/hle/service/cfg/cfg.h"
-#include "core/hle/service/fs/archive.h"
-#include "core/hle/service/ptm/ptm.h"
-#include "core/hle/service/service.h"
-#include "core/hw/aes/ccm.h"
-#include "core/hw/aes/key.h"
-
-namespace Service {
-namespace APT {
-
-/// Handle to shared memory region designated to for shared system font
-static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem;
-static bool shared_font_loaded = false;
-static bool shared_font_relocated = false;
-
-static Kernel::SharedPtr<Kernel::Mutex> lock;
-
-static u32 cpu_percent; ///< CPU time available to the running application
-
-// APT::CheckNew3DSApp will check this unknown_ns_state_field to determine processing mode
-static u8 unknown_ns_state_field;
-
-static ScreencapPostPermission screen_capture_post_permission;
-
-/// Parameter data to be returned in the next call to Glance/ReceiveParameter.
-/// TODO(Subv): Use std::optional once we migrate to C++17.
-static boost::optional<MessageParameter> next_parameter;
-
-enum class AppletPos { Application = 0, Library = 1, System = 2, SysLibrary = 3, Resident = 4 };
-
-static constexpr size_t NumAppletSlot = 4;
-
-enum class AppletSlot : u8 {
- Application,
- SystemApplet,
- HomeMenu,
- LibraryApplet,
-
- // An invalid tag
- Error,
-};
-
-union AppletAttributes {
- u32 raw;
-
- BitField<0, 3, u32> applet_pos;
- BitField<29, 1, u32> is_home_menu;
-
- AppletAttributes() : raw(0) {}
- AppletAttributes(u32 attributes) : raw(attributes) {}
-};
-
-struct AppletSlotData {
- AppletId applet_id;
- AppletSlot slot;
- bool registered;
- AppletAttributes attributes;
- Kernel::SharedPtr<Kernel::Event> notification_event;
- Kernel::SharedPtr<Kernel::Event> parameter_event;
-};
-
-// Holds data about the concurrently running applets in the system.
-static std::array<AppletSlotData, NumAppletSlot> applet_slots = {};
-
-// This overload returns nullptr if no applet with the specified id has been started.
-static AppletSlotData* GetAppletSlotData(AppletId id) {
- auto GetSlot = [](AppletSlot slot) -> AppletSlotData* {
- return &applet_slots[static_cast<size_t>(slot)];
- };
-
- if (id == AppletId::Application) {
- auto* slot = GetSlot(AppletSlot::Application);
- if (slot->applet_id != AppletId::None)
- return slot;
-
- return nullptr;
- }
-
- if (id == AppletId::AnySystemApplet) {
- auto* system_slot = GetSlot(AppletSlot::SystemApplet);
- if (system_slot->applet_id != AppletId::None)
- return system_slot;
-
- // The Home Menu is also a system applet, but it lives in its own slot to be able to run
- // concurrently with other system applets.
- auto* home_slot = GetSlot(AppletSlot::HomeMenu);
- if (home_slot->applet_id != AppletId::None)
- return home_slot;
-
- return nullptr;
- }
-
- if (id == AppletId::AnyLibraryApplet || id == AppletId::AnySysLibraryApplet) {
- auto* slot = GetSlot(AppletSlot::LibraryApplet);
- if (slot->applet_id == AppletId::None)
- return nullptr;
-
- u32 applet_pos = slot->attributes.applet_pos;
-
- if (id == AppletId::AnyLibraryApplet && applet_pos == static_cast<u32>(AppletPos::Library))
- return slot;
-
- if (id == AppletId::AnySysLibraryApplet &&
- applet_pos == static_cast<u32>(AppletPos::SysLibrary))
- return slot;
-
- return nullptr;
- }
-
- if (id == AppletId::HomeMenu || id == AppletId::AlternateMenu) {
- auto* slot = GetSlot(AppletSlot::HomeMenu);
- if (slot->applet_id != AppletId::None)
- return slot;
-
- return nullptr;
- }
-
- for (auto& slot : applet_slots) {
- if (slot.applet_id == id)
- return &slot;
- }
-
- return nullptr;
-}
-
-static AppletSlotData* GetAppletSlotData(AppletAttributes attributes) {
- // Mapping from AppletPos to AppletSlot
- static constexpr std::array<AppletSlot, 6> applet_position_slots = {
- AppletSlot::Application, AppletSlot::LibraryApplet, AppletSlot::SystemApplet,
- AppletSlot::LibraryApplet, AppletSlot::Error, AppletSlot::LibraryApplet};
-
- u32 applet_pos = attributes.applet_pos;
- if (applet_pos >= applet_position_slots.size())
- return nullptr;
-
- AppletSlot slot = applet_position_slots[applet_pos];
-
- if (slot == AppletSlot::Error)
- return nullptr;
-
- // The Home Menu is a system applet, however, it has its own applet slot so that it can run
- // concurrently with other system applets.
- if (slot == AppletSlot::SystemApplet && attributes.is_home_menu)
- return &applet_slots[static_cast<size_t>(AppletSlot::HomeMenu)];
-
- return &applet_slots[static_cast<size_t>(slot)];
-}
-
-void SendParameter(const MessageParameter& parameter) {
- next_parameter = parameter;
- // Signal the event to let the receiver know that a new parameter is ready to be read
- auto* const slot_data = GetAppletSlotData(static_cast<AppletId>(parameter.destination_id));
- if (slot_data == nullptr) {
- LOG_DEBUG(Service_APT, "No applet was registered with the id %03X",
- parameter.destination_id);
- return;
- }
-
- slot_data->parameter_event->Signal();
-}
-
-void Initialize(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x2, 2, 0); // 0x20080
- u32 app_id = rp.Pop<u32>();
- u32 attributes = rp.Pop<u32>();
-
- LOG_DEBUG(Service_APT, "called app_id=0x%08X, attributes=0x%08X", app_id, attributes);
-
- auto* const slot_data = GetAppletSlotData(attributes);
-
- // Note: The real NS service does not check if the attributes value is valid before accessing
- // the data in the array
- ASSERT_MSG(slot_data, "Invalid application attributes");
-
- if (slot_data->registered) {
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet,
- ErrorSummary::InvalidState, ErrorLevel::Status));
- return;
- }
-
- slot_data->applet_id = static_cast<AppletId>(app_id);
- slot_data->attributes.raw = attributes;
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 3);
- rb.Push(RESULT_SUCCESS);
- rb.PushCopyHandles(Kernel::g_handle_table.Create(slot_data->notification_event).Unwrap(),
- Kernel::g_handle_table.Create(slot_data->parameter_event).Unwrap());
-
- if (slot_data->applet_id == AppletId::Application ||
- slot_data->applet_id == AppletId::HomeMenu) {
- // Initialize the APT parameter to wake up the application.
- next_parameter.emplace();
- next_parameter->signal = static_cast<u32>(SignalType::Wakeup);
- next_parameter->sender_id = static_cast<u32>(AppletId::None);
- next_parameter->destination_id = app_id;
- // Not signaling the parameter event will cause the application (or Home Menu) to hang
- // during startup. In the real console, it is usually the Kernel and Home Menu who cause NS
- // to signal the HomeMenu and Application parameter events, respectively.
- slot_data->parameter_event->Signal();
- }
-}
-
-static u32 DecompressLZ11(const u8* in, u8* out) {
- u32_le decompressed_size;
- memcpy(&decompressed_size, in, sizeof(u32));
- in += 4;
-
- u8 type = decompressed_size & 0xFF;
- ASSERT(type == 0x11);
- decompressed_size >>= 8;
-
- u32 current_out_size = 0;
- u8 flags = 0, mask = 1;
- while (current_out_size < decompressed_size) {
- if (mask == 1) {
- flags = *(in++);
- mask = 0x80;
- } else {
- mask >>= 1;
- }
-
- if (flags & mask) {
- u8 byte1 = *(in++);
- u32 length = byte1 >> 4;
- u32 offset;
- if (length == 0) {
- u8 byte2 = *(in++);
- u8 byte3 = *(in++);
- length = (((byte1 & 0x0F) << 4) | (byte2 >> 4)) + 0x11;
- offset = (((byte2 & 0x0F) << 8) | byte3) + 0x1;
- } else if (length == 1) {
- u8 byte2 = *(in++);
- u8 byte3 = *(in++);
- u8 byte4 = *(in++);
- length = (((byte1 & 0x0F) << 12) | (byte2 << 4) | (byte3 >> 4)) + 0x111;
- offset = (((byte3 & 0x0F) << 8) | byte4) + 0x1;
- } else {
- u8 byte2 = *(in++);
- length = (byte1 >> 4) + 0x1;
- offset = (((byte1 & 0x0F) << 8) | byte2) + 0x1;
- }
-
- for (u32 i = 0; i < length; i++) {
- *out = *(out - offset);
- ++out;
- }
-
- current_out_size += length;
- } else {
- *(out++) = *(in++);
- current_out_size++;
- }
- }
- return decompressed_size;
-}
-
-static bool LoadSharedFont() {
- u8 font_region_code;
- switch (CFG::GetRegionValue()) {
- case 4: // CHN
- font_region_code = 2;
- break;
- case 5: // KOR
- font_region_code = 3;
- break;
- case 6: // TWN
- font_region_code = 4;
- break;
- default: // JPN/EUR/USA
- font_region_code = 1;
- break;
- }
-
- const u64_le shared_font_archive_id_low = 0x0004009b00014002 | ((font_region_code - 1) << 8);
- const u64_le shared_font_archive_id_high = 0x00000001ffffff00;
- std::vector<u8> shared_font_archive_id(16);
- std::memcpy(&shared_font_archive_id[0], &shared_font_archive_id_low, sizeof(u64));
- std::memcpy(&shared_font_archive_id[8], &shared_font_archive_id_high, sizeof(u64));
- FileSys::Path archive_path(shared_font_archive_id);
- auto archive_result = Service::FS::OpenArchive(Service::FS::ArchiveIdCode::NCCH, archive_path);
- if (archive_result.Failed())
- return false;
-
- std::vector<u8> romfs_path(20, 0); // 20-byte all zero path for opening RomFS
- FileSys::Path file_path(romfs_path);
- FileSys::Mode open_mode = {};
- open_mode.read_flag.Assign(1);
- auto file_result = Service::FS::OpenFileFromArchive(*archive_result, file_path, open_mode);
- if (file_result.Failed())
- return false;
-
- auto romfs = std::move(file_result).Unwrap();
- std::vector<u8> romfs_buffer(romfs->backend->GetSize());
- romfs->backend->Read(0, romfs_buffer.size(), romfs_buffer.data());
- romfs->backend->Close();
-
- const char16_t* file_name[4] = {u"cbf_std.bcfnt.lz", u"cbf_zh-Hans-CN.bcfnt.lz",
- u"cbf_ko-Hang-KR.bcfnt.lz", u"cbf_zh-Hant-TW.bcfnt.lz"};
- const u8* font_file =
- RomFS::GetFilePointer(romfs_buffer.data(), {file_name[font_region_code - 1]});
- if (font_file == nullptr)
- return false;
-
- struct {
- u32_le status;
- u32_le region;
- u32_le decompressed_size;
- INSERT_PADDING_WORDS(0x1D);
- } shared_font_header{};
- static_assert(sizeof(shared_font_header) == 0x80, "shared_font_header has incorrect size");
-
- shared_font_header.status = 2; // successfully loaded
- shared_font_header.region = font_region_code;
- shared_font_header.decompressed_size =
- DecompressLZ11(font_file, shared_font_mem->GetPointer(0x80));
- std::memcpy(shared_font_mem->GetPointer(), &shared_font_header, sizeof(shared_font_header));
- *shared_font_mem->GetPointer(0x83) = 'U'; // Change the magic from "CFNT" to "CFNU"
-
- return true;
-}
-
-static bool LoadLegacySharedFont() {
- // This is the legacy method to load shared font.
- // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header
- // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided
- // a homebrew app to do this: https://github.com/citra-emu/3dsutils. Put the resulting file
- // "shared_font.bin" in the Citra "sysdata" directory.
- std::string filepath = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
-
- FileUtil::CreateFullPath(filepath); // Create path if not already created
- FileUtil::IOFile file(filepath, "rb");
- if (file.IsOpen()) {
- file.ReadBytes(shared_font_mem->GetPointer(), file.GetSize());
- return true;
- }
-
- return false;
-}
-
-void GetSharedFont(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x44, 0, 0); // 0x00440000
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
-
- // Log in telemetry if the game uses the shared font
- Core::Telemetry().AddField(Telemetry::FieldType::Session, "RequiresSharedFont", true);
-
- if (!shared_font_loaded) {
- // On real 3DS, font loading happens on booting. However, we load it on demand to coordinate
- // with CFG region auto configuration, which happens later than APT initialization.
- if (LoadSharedFont()) {
- shared_font_loaded = true;
- } else if (LoadLegacySharedFont()) {
- LOG_WARNING(Service_APT, "Loaded shared font by legacy method");
- shared_font_loaded = true;
- } else {
- LOG_ERROR(Service_APT, "shared font file missing - go dump it from your 3ds");
- rb.Push<u32>(-1); // TODO: Find the right error code
- rb.Skip(1 + 2, true);
- Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSharedFont);
- return;
- }
- }
-
- // The shared font has to be relocated to the new address before being passed to the
- // application.
- VAddr target_address =
- Memory::PhysicalToVirtualAddress(shared_font_mem->linear_heap_phys_address).value();
- if (!shared_font_relocated) {
- BCFNT::RelocateSharedFont(shared_font_mem, target_address);
- shared_font_relocated = true;
- }
-
- rb.Push(RESULT_SUCCESS); // No error
- // Since the SharedMemory interface doesn't provide the address at which the memory was
- // allocated, the real APT service calculates this address by scanning the entire address space
- // (using svcQueryMemory) and searches for an allocation of the same size as the Shared Font.
- rb.Push(target_address);
- rb.PushCopyHandles(Kernel::g_handle_table.Create(shared_font_mem).Unwrap());
-}
-
-void NotifyToWait(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x43, 1, 0); // 0x430040
- u32 app_id = rp.Pop<u32>();
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(RESULT_SUCCESS); // No error
- LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id);
-}
-
-void GetLockHandle(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1, 1, 0); // 0x10040
-
- // Bits [0:2] are the applet type (System, Library, etc)
- // Bit 5 tells the application that there's a pending APT parameter,
- // this will cause the app to wait until parameter_event is signaled.
- u32 applet_attributes = rp.Pop<u32>();
- IPC::RequestBuilder rb = rp.MakeBuilder(3, 2);
- rb.Push(RESULT_SUCCESS); // No error
-
- // TODO(Subv): The output attributes should have an AppletPos of either Library or System |
- // Library (depending on the type of the last launched applet) if the input attributes'
- // AppletPos has the Library bit set.
-
- rb.Push(applet_attributes); // Applet Attributes, this value is passed to Enable.
- rb.Push<u32>(0); // Least significant bit = power button state
- Kernel::Handle handle_copy = Kernel::g_handle_table.Create(lock).Unwrap();
- rb.PushCopyHandles(handle_copy);
-
- LOG_WARNING(Service_APT, "(STUBBED) called handle=0x%08X applet_attributes=0x%08X", handle_copy,
- applet_attributes);
-}
-
-void Enable(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x3, 1, 0); // 0x30040
- u32 attributes = rp.Pop<u32>();
-
- LOG_DEBUG(Service_APT, "called attributes=0x%08X", attributes);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
-
- auto* const slot_data = GetAppletSlotData(attributes);
-
- if (!slot_data) {
- rb.Push(ResultCode(ErrCodes::InvalidAppletSlot, ErrorModule::Applet,
- ErrorSummary::InvalidState, ErrorLevel::Status));
- return;
- }
-
- slot_data->registered = true;
-
- rb.Push(RESULT_SUCCESS);
-}
-
-void GetAppletManInfo(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x5, 1, 0); // 0x50040
- u32 unk = rp.Pop<u32>();
- IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push<u32>(0);
- rb.Push<u32>(0);
- rb.Push(static_cast<u32>(AppletId::HomeMenu)); // Home menu AppID
- rb.Push(static_cast<u32>(AppletId::Application)); // TODO(purpasmart96): Do this correctly
-
- LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk);
-}
-
-void IsRegistered(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x9, 1, 0); // 0x90040
- AppletId app_id = static_cast<AppletId>(rp.Pop<u32>());
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
- rb.Push(RESULT_SUCCESS); // No error
-
- auto* const slot_data = GetAppletSlotData(app_id);
-
- // Check if an LLE applet was registered first, then fallback to HLE applets
- bool is_registered = slot_data && slot_data->registered;
-
- if (!is_registered) {
- if (app_id == AppletId::AnyLibraryApplet) {
- is_registered = HLE::Applets::IsLibraryAppletRunning();
- } else if (auto applet = HLE::Applets::Applet::Get(app_id)) {
- // The applet exists, set it as registered.
- is_registered = true;
- }
- }
-
- rb.Push(is_registered);
-
- LOG_DEBUG(Service_APT, "called app_id=0x%08X", static_cast<u32>(app_id));
-}
-
-void InquireNotification(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xB, 1, 0); // 0xB0040
- u32 app_id = rp.Pop<u32>();
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push(static_cast<u32>(SignalType::None)); // Signal type
- LOG_WARNING(Service_APT, "(STUBBED) called app_id=0x%08X", app_id);
-}
-
-void SendParameter(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xC, 4, 4); // 0xC0104
- u32 src_app_id = rp.Pop<u32>();
- u32 dst_app_id = rp.Pop<u32>();
- u32 signal_type = rp.Pop<u32>();
- u32 buffer_size = rp.Pop<u32>();
- Kernel::Handle handle = rp.PopHandle();
- size_t size;
- VAddr buffer = rp.PopStaticBuffer(&size);
-
- LOG_DEBUG(Service_APT,
- "called src_app_id=0x%08X, dst_app_id=0x%08X, signal_type=0x%08X,"
- "buffer_size=0x%08X, handle=0x%08X, size=0x%08zX, in_param_buffer_ptr=0x%08X",
- src_app_id, dst_app_id, signal_type, buffer_size, handle, size, buffer);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
-
- // A new parameter can not be sent if the previous one hasn't been consumed yet
- if (next_parameter) {
- rb.Push(ResultCode(ErrCodes::ParameterPresent, ErrorModule::Applet,
- ErrorSummary::InvalidState, ErrorLevel::Status));
- return;
- }
-
- MessageParameter param;
- param.destination_id = dst_app_id;
- param.sender_id = src_app_id;
- param.object = Kernel::g_handle_table.GetGeneric(handle);
- param.signal = signal_type;
- param.buffer.resize(buffer_size);
- Memory::ReadBlock(buffer, param.buffer.data(), param.buffer.size());
-
- SendParameter(param);
-
- // If the applet is running in HLE mode, use the HLE interface to communicate with it.
- if (auto dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id))) {
- rb.Push(dest_applet->ReceiveParameter(param));
- } else {
- rb.Push(RESULT_SUCCESS);
- }
-}
-
-void ReceiveParameter(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xD, 2, 0); // 0xD0080
- u32 app_id = rp.Pop<u32>();
- u32 buffer_size = rp.Pop<u32>();
-
- size_t static_buff_size;
- VAddr buffer = rp.PeekStaticBuffer(0, &static_buff_size);
- if (buffer_size > static_buff_size)
- LOG_WARNING(
- Service_APT,
- "buffer_size is bigger than the size in the buffer descriptor (0x%08X > 0x%08zX)",
- buffer_size, static_buff_size);
-
- LOG_DEBUG(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size);
-
- if (!next_parameter) {
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::Applet,
- ErrorSummary::InvalidState, ErrorLevel::Status));
- return;
- }
-
- if (next_parameter->destination_id != app_id) {
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
- ErrorLevel::Status));
- return;
- }
-
- IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
-
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push(next_parameter->sender_id);
- rb.Push(next_parameter->signal); // Signal type
- ASSERT_MSG(next_parameter->buffer.size() <= buffer_size, "Input static buffer is too small !");
- rb.Push(static_cast<u32>(next_parameter->buffer.size())); // Parameter buffer size
-
- rb.PushMoveHandles((next_parameter->object != nullptr)
- ? Kernel::g_handle_table.Create(next_parameter->object).Unwrap()
- : 0);
-
- rb.PushStaticBuffer(buffer, next_parameter->buffer.size(), 0);
-
- Memory::WriteBlock(buffer, next_parameter->buffer.data(), next_parameter->buffer.size());
-
- // Clear the parameter
- next_parameter = boost::none;
-}
-
-void GlanceParameter(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xE, 2, 0); // 0xE0080
- u32 app_id = rp.Pop<u32>();
- u32 buffer_size = rp.Pop<u32>();
-
- size_t static_buff_size;
- VAddr buffer = rp.PeekStaticBuffer(0, &static_buff_size);
- if (buffer_size > static_buff_size)
- LOG_WARNING(
- Service_APT,
- "buffer_size is bigger than the size in the buffer descriptor (0x%08X > 0x%08zX)",
- buffer_size, static_buff_size);
-
- LOG_DEBUG(Service_APT, "called app_id=0x%08X, buffer_size=0x%08zX", app_id, buffer_size);
-
- if (!next_parameter) {
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(ResultCode(ErrorDescription::NoData, ErrorModule::Applet,
- ErrorSummary::InvalidState, ErrorLevel::Status));
- return;
- }
-
- if (next_parameter->destination_id != app_id) {
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
- ErrorLevel::Status));
- return;
- }
-
- IPC::RequestBuilder rb = rp.MakeBuilder(4, 4);
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push(next_parameter->sender_id);
- rb.Push(next_parameter->signal); // Signal type
- ASSERT_MSG(next_parameter->buffer.size() <= buffer_size, "Input static buffer is too small !");
- rb.Push(static_cast<u32>(next_parameter->buffer.size())); // Parameter buffer size
-
- rb.PushMoveHandles((next_parameter->object != nullptr)
- ? Kernel::g_handle_table.Create(next_parameter->object).Unwrap()
- : 0);
-
- rb.PushStaticBuffer(buffer, next_parameter->buffer.size(), 0);
-
- Memory::WriteBlock(buffer, next_parameter->buffer.data(), next_parameter->buffer.size());
-
- // Note: The NS module always clears the DSPSleep and DSPWakeup signals even in GlanceParameter.
- if (next_parameter->signal == static_cast<u32>(SignalType::DspSleep) ||
- next_parameter->signal == static_cast<u32>(SignalType::DspWakeup))
- next_parameter = boost::none;
-}
-
-void CancelParameter(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0xF, 4, 0); // 0xF0100
-
- bool check_sender = rp.Pop<bool>();
- u32 sender_appid = rp.Pop<u32>();
- bool check_receiver = rp.Pop<bool>();
- u32 receiver_appid = rp.Pop<u32>();
-
- bool cancellation_success = true;
-
- if (!next_parameter) {
- cancellation_success = false;
- } else {
- if (check_sender && next_parameter->sender_id != sender_appid)
- cancellation_success = false;
-
- if (check_receiver && next_parameter->destination_id != receiver_appid)
- cancellation_success = false;
- }
-
- if (cancellation_success)
- next_parameter = boost::none;
-
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
-
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push(cancellation_success);
-
- LOG_DEBUG(Service_APT, "called check_sender=%u, sender_appid=0x%08X, "
- "check_receiver=%u, receiver_appid=0x%08X",
- check_sender, sender_appid, check_receiver, receiver_appid);
-}
-
-void PrepareToStartApplication(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x15, 5, 0); // 0x00150140
- u32 title_info1 = rp.Pop<u32>();
- u32 title_info2 = rp.Pop<u32>();
- u32 title_info3 = rp.Pop<u32>();
- u32 title_info4 = rp.Pop<u32>();
- u32 flags = rp.Pop<u32>();
-
- if (flags & 0x00000100) {
- unknown_ns_state_field = 1;
- }
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(RESULT_SUCCESS); // No error
-
- LOG_WARNING(Service_APT,
- "(STUBBED) called title_info1=0x%08X, title_info2=0x%08X, title_info3=0x%08X,"
- "title_info4=0x%08X, flags=0x%08X",
- title_info1, title_info2, title_info3, title_info4, flags);
-}
-
-void StartApplication(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1B, 3, 4); // 0x001B00C4
- u32 buffer1_size = rp.Pop<u32>();
- u32 buffer2_size = rp.Pop<u32>();
- u32 flag = rp.Pop<u32>();
- size_t size1;
- VAddr buffer1_ptr = rp.PopStaticBuffer(&size1);
- size_t size2;
- VAddr buffer2_ptr = rp.PopStaticBuffer(&size2);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(RESULT_SUCCESS); // No error
-
- LOG_WARNING(Service_APT,
- "(STUBBED) called buffer1_size=0x%08X, buffer2_size=0x%08X, flag=0x%08X,"
- "size1=0x%08zX, buffer1_ptr=0x%08X, size2=0x%08zX, buffer2_ptr=0x%08X",
- buffer1_size, buffer2_size, flag, size1, buffer1_ptr, size2, buffer2_ptr);
-}
-
-void AppletUtility(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x4B, 3, 2); // 0x004B00C2
-
- // These are from 3dbrew - I'm not really sure what they're used for.
- u32 utility_command = rp.Pop<u32>();
- u32 input_size = rp.Pop<u32>();
- u32 output_size = rp.Pop<u32>();
- VAddr input_addr = rp.PopStaticBuffer();
-
- VAddr output_addr = rp.PeekStaticBuffer(0);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(RESULT_SUCCESS); // No error
-
- LOG_WARNING(Service_APT,
- "(STUBBED) called command=0x%08X, input_size=0x%08X, output_size=0x%08X, "
- "input_addr=0x%08X, output_addr=0x%08X",
- utility_command, input_size, output_size, input_addr, output_addr);
-}
-
-void SetAppCpuTimeLimit(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x4F, 2, 0); // 0x4F0080
- u32 value = rp.Pop<u32>();
- cpu_percent = rp.Pop<u32>();
-
- if (value != 1) {
- LOG_ERROR(Service_APT, "This value should be one, but is actually %u!", value);
- }
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(RESULT_SUCCESS); // No error
-
- LOG_WARNING(Service_APT, "(STUBBED) called cpu_percent=%u, value=%u", cpu_percent, value);
-}
-
-void GetAppCpuTimeLimit(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x50, 1, 0); // 0x500040
- u32 value = rp.Pop<u32>();
-
- if (value != 1) {
- LOG_ERROR(Service_APT, "This value should be one, but is actually %u!", value);
- }
-
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push(cpu_percent);
-
- LOG_WARNING(Service_APT, "(STUBBED) called value=%u", value);
-}
-
-void PrepareToStartLibraryApplet(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x18, 1, 0); // 0x180040
- AppletId applet_id = static_cast<AppletId>(rp.Pop<u32>());
-
- LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
-
- // TODO(Subv): Launch the requested applet application.
-
- auto applet = HLE::Applets::Applet::Get(applet_id);
- if (applet) {
- LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
- rb.Push(RESULT_SUCCESS);
- } else {
- rb.Push(HLE::Applets::Applet::Create(applet_id));
- }
-}
-
-void PrepareToStartNewestHomeMenu(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1A, 0, 0); // 0x1A0000
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
-
- // TODO(Subv): This command can only be called by a System Applet (return 0xC8A0CC04 otherwise).
-
- // This command must return an error when called, otherwise the Home Menu will try to reboot the
- // system.
- rb.Push(ResultCode(ErrorDescription::AlreadyExists, ErrorModule::Applet,
- ErrorSummary::InvalidState, ErrorLevel::Status));
-
- LOG_DEBUG(Service_APT, "called");
-}
-
-void PreloadLibraryApplet(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x16, 1, 0); // 0x160040
- AppletId applet_id = static_cast<AppletId>(rp.Pop<u32>());
-
- LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
-
- // TODO(Subv): Launch the requested applet application.
-
- auto applet = HLE::Applets::Applet::Get(applet_id);
- if (applet) {
- LOG_WARNING(Service_APT, "applet has already been started id=%08X", applet_id);
- rb.Push(RESULT_SUCCESS);
- } else {
- rb.Push(HLE::Applets::Applet::Create(applet_id));
- }
-}
-
-void StartLibraryApplet(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1E, 2, 4); // 0x1E0084
- AppletId applet_id = static_cast<AppletId>(rp.Pop<u32>());
-
- size_t buffer_size = rp.Pop<u32>();
- Kernel::Handle handle = rp.PopHandle();
- VAddr buffer_addr = rp.PopStaticBuffer();
-
- LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
-
- // Send the Wakeup signal to the applet
- MessageParameter param;
- param.destination_id = static_cast<u32>(applet_id);
- param.sender_id = static_cast<u32>(AppletId::Application);
- param.object = Kernel::g_handle_table.GetGeneric(handle);
- param.signal = static_cast<u32>(SignalType::Wakeup);
- param.buffer.resize(buffer_size);
- Memory::ReadBlock(buffer_addr, param.buffer.data(), param.buffer.size());
- SendParameter(param);
-
- // In case the applet is being HLEd, attempt to communicate with it.
- if (auto applet = HLE::Applets::Applet::Get(applet_id)) {
- AppletStartupParameter parameter;
- parameter.object = Kernel::g_handle_table.GetGeneric(handle);
- parameter.buffer.resize(buffer_size);
- Memory::ReadBlock(buffer_addr, parameter.buffer.data(), parameter.buffer.size());
- rb.Push(applet->Start(parameter));
- } else {
- rb.Push(RESULT_SUCCESS);
- }
-}
-
-void CancelLibraryApplet(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x3B, 1, 0); // 0x003B0040
- bool exiting = rp.Pop<bool>();
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push<u32>(1); // TODO: Find the return code meaning
-
- LOG_WARNING(Service_APT, "(STUBBED) called exiting=%d", exiting);
-}
-
-void SetScreenCapPostPermission(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x55, 1, 0); // 0x00550040
-
- screen_capture_post_permission = static_cast<ScreencapPostPermission>(rp.Pop<u32>() & 0xF);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(RESULT_SUCCESS); // No error
- LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u",
- screen_capture_post_permission);
-}
-
-void GetScreenCapPostPermission(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x56, 0, 0); // 0x00560000
-
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
- rb.Push(RESULT_SUCCESS); // No error
- rb.Push(static_cast<u32>(screen_capture_post_permission));
- LOG_WARNING(Service_APT, "(STUBBED) screen_capture_post_permission=%u",
- screen_capture_post_permission);
-}
-
-void GetAppletInfo(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x6, 1, 0); // 0x60040
- auto app_id = static_cast<AppletId>(rp.Pop<u32>());
-
- if (auto applet = HLE::Applets::Applet::Get(app_id)) {
- // TODO(Subv): Get the title id for the current applet and write it in the response[2-3]
- IPC::RequestBuilder rb = rp.MakeBuilder(7, 0);
- rb.Push(RESULT_SUCCESS);
- u64 title_id = 0;
- rb.Push(title_id);
- rb.Push(static_cast<u32>(Service::FS::MediaType::NAND));
- rb.Push(true); // Registered
- rb.Push(true); // Loaded
- rb.Push<u32>(0); // Applet Attributes
- } else {
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
- rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::Applet, ErrorSummary::NotFound,
- ErrorLevel::Status));
- }
- LOG_WARNING(Service_APT, "(stubbed) called appid=%u", app_id);
-}
-
-void GetStartupArgument(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x51, 2, 0); // 0x00510080
- u32 parameter_size = rp.Pop<u32>();
- StartupArgumentType startup_argument_type = static_cast<StartupArgumentType>(rp.Pop<u8>());
-
- if (parameter_size >= 0x300) {
- LOG_ERROR(
- Service_APT,
- "Parameter size is outside the valid range (capped to 0x300): parameter_size=0x%08x",
- parameter_size);
- return;
- }
-
- size_t static_buff_size;
- VAddr addr = rp.PeekStaticBuffer(0, &static_buff_size);
- if (parameter_size > static_buff_size)
- LOG_WARNING(
- Service_APT,
- "parameter_size is bigger than the size in the buffer descriptor (0x%08X > 0x%08zX)",
- parameter_size, static_buff_size);
-
- if (addr && parameter_size) {
- Memory::ZeroBlock(addr, parameter_size);
- }
-
- LOG_WARNING(Service_APT, "(stubbed) called startup_argument_type=%u , parameter_size=0x%08x",
- startup_argument_type, parameter_size);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 2);
- rb.Push(RESULT_SUCCESS);
- rb.Push<u32>(0);
- rb.PushStaticBuffer(addr, parameter_size, 0);
-}
-
-void Wrap(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x46, 4, 4);
- const u32 output_size = rp.Pop<u32>();
- const u32 input_size = rp.Pop<u32>();
- const u32 nonce_offset = rp.Pop<u32>();
- u32 nonce_size = rp.Pop<u32>();
- size_t desc_size;
- IPC::MappedBufferPermissions desc_permission;
- const VAddr input = rp.PopMappedBuffer(&desc_size, &desc_permission);
- ASSERT(desc_size == input_size && desc_permission == IPC::MappedBufferPermissions::R);
- const VAddr output = rp.PopMappedBuffer(&desc_size, &desc_permission);
- ASSERT(desc_size == output_size && desc_permission == IPC::MappedBufferPermissions::W);
-
- // Note: real 3DS still returns SUCCESS when the sizes don't match. It seems that it doesn't
- // check the buffer size and writes data with potential overflow.
- ASSERT_MSG(output_size == input_size + HW::AES::CCM_MAC_SIZE,
- "input_size (%d) doesn't match to output_size (%d)", input_size, output_size);
-
- LOG_DEBUG(Service_APT, "called, output_size=%u, input_size=%u, nonce_offset=%u, nonce_size=%u",
- output_size, input_size, nonce_offset, nonce_size);
-
- // Note: This weird nonce size modification is verified against real 3DS
- nonce_size = std::min<u32>(nonce_size & ~3, HW::AES::CCM_NONCE_SIZE);
-
- // Reads nonce and concatenates the rest of the input as plaintext
- HW::AES::CCMNonce nonce{};
- Memory::ReadBlock(input + nonce_offset, nonce.data(), nonce_size);
- u32 pdata_size = input_size - nonce_size;
- std::vector<u8> pdata(pdata_size);
- Memory::ReadBlock(input, pdata.data(), nonce_offset);
- Memory::ReadBlock(input + nonce_offset + nonce_size, pdata.data() + nonce_offset,
- pdata_size - nonce_offset);
-
- // Encrypts the plaintext using AES-CCM
- auto cipher = HW::AES::EncryptSignCCM(pdata, nonce, HW::AES::KeySlotID::APTWrap);
-
- // Puts the nonce to the beginning of the output, with ciphertext followed
- Memory::WriteBlock(output, nonce.data(), nonce_size);
- Memory::WriteBlock(output + nonce_size, cipher.data(), cipher.size());
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
- rb.Push(RESULT_SUCCESS);
-
- // Unmap buffer
- rb.PushMappedBuffer(input, input_size, IPC::MappedBufferPermissions::R);
- rb.PushMappedBuffer(output, output_size, IPC::MappedBufferPermissions::W);
-}
-
-void Unwrap(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x47, 4, 4);
- const u32 output_size = rp.Pop<u32>();
- const u32 input_size = rp.Pop<u32>();
- const u32 nonce_offset = rp.Pop<u32>();
- u32 nonce_size = rp.Pop<u32>();
- size_t desc_size;
- IPC::MappedBufferPermissions desc_permission;
- const VAddr input = rp.PopMappedBuffer(&desc_size, &desc_permission);
- ASSERT(desc_size == input_size && desc_permission == IPC::MappedBufferPermissions::R);
- const VAddr output = rp.PopMappedBuffer(&desc_size, &desc_permission);
- ASSERT(desc_size == output_size && desc_permission == IPC::MappedBufferPermissions::W);
-
- // Note: real 3DS still returns SUCCESS when the sizes don't match. It seems that it doesn't
- // check the buffer size and writes data with potential overflow.
- ASSERT_MSG(output_size == input_size - HW::AES::CCM_MAC_SIZE,
- "input_size (%d) doesn't match to output_size (%d)", input_size, output_size);
-
- LOG_DEBUG(Service_APT, "called, output_size=%u, input_size=%u, nonce_offset=%u, nonce_size=%u",
- output_size, input_size, nonce_offset, nonce_size);
-
- // Note: This weird nonce size modification is verified against real 3DS
- nonce_size = std::min<u32>(nonce_size & ~3, HW::AES::CCM_NONCE_SIZE);
-
- // Reads nonce and cipher text
- HW::AES::CCMNonce nonce{};
- Memory::ReadBlock(input, nonce.data(), nonce_size);
- u32 cipher_size = input_size - nonce_size;
- std::vector<u8> cipher(cipher_size);
- Memory::ReadBlock(input + nonce_size, cipher.data(), cipher_size);
-
- // Decrypts the ciphertext using AES-CCM
- auto pdata = HW::AES::DecryptVerifyCCM(cipher, nonce, HW::AES::KeySlotID::APTWrap);
-
- IPC::RequestBuilder rb = rp.MakeBuilder(1, 4);
- if (!pdata.empty()) {
- // Splits the plaintext and put the nonce in between
- Memory::WriteBlock(output, pdata.data(), nonce_offset);
- Memory::WriteBlock(output + nonce_offset, nonce.data(), nonce_size);
- Memory::WriteBlock(output + nonce_offset + nonce_size, pdata.data() + nonce_offset,
- pdata.size() - nonce_offset);
- rb.Push(RESULT_SUCCESS);
- } else {
- LOG_ERROR(Service_APT, "Failed to decrypt data");
- rb.Push(ResultCode(static_cast<ErrorDescription>(1), ErrorModule::PS,
- ErrorSummary::WrongArgument, ErrorLevel::Status));
- }
-
- // Unmap buffer
- rb.PushMappedBuffer(input, input_size, IPC::MappedBufferPermissions::R);
- rb.PushMappedBuffer(output, output_size, IPC::MappedBufferPermissions::W);
-}
-
-void CheckNew3DSApp(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x101, 0, 0); // 0x01010000
-
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
- if (unknown_ns_state_field) {
- rb.Push(RESULT_SUCCESS);
- rb.Push<u32>(0);
- } else {
- PTM::CheckNew3DS(rb);
- }
-
- LOG_WARNING(Service_APT, "(STUBBED) called");
-}
-
-void CheckNew3DS(Service::Interface* self) {
- IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x102, 0, 0); // 0x01020000
- IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
-
- PTM::CheckNew3DS(rb);
-
- LOG_WARNING(Service_APT, "(STUBBED) called");
-}
-
-void Init() {
- AddService(new APT_A_Interface);
- AddService(new APT_S_Interface);
- AddService(new APT_U_Interface);
-
- HLE::Applets::Init();
-
- using Kernel::MemoryPermission;
- shared_font_mem =
- Kernel::SharedMemory::Create(nullptr, 0x332000, // 3272 KB
- MemoryPermission::ReadWrite, MemoryPermission::Read, 0,
- Kernel::MemoryRegion::SYSTEM, "APT:SharedFont");
-
- if (LoadSharedFont()) {
- shared_font_loaded = true;
- } else if (LoadLegacySharedFont()) {
- LOG_WARNING(Service_APT, "Loaded shared font by legacy method");
- shared_font_loaded = true;
- } else {
- LOG_WARNING(Service_APT, "Unable to load shared font");
- shared_font_loaded = false;
- }
-
- lock = Kernel::Mutex::Create(false, 0, "APT_U:Lock");
-
- cpu_percent = 0;
- unknown_ns_state_field = 0;
- screen_capture_post_permission =
- ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
-
- for (size_t slot = 0; slot < applet_slots.size(); ++slot) {
- auto& slot_data = applet_slots[slot];
- slot_data.slot = static_cast<AppletSlot>(slot);
- slot_data.applet_id = AppletId::None;
- slot_data.attributes.raw = 0;
- slot_data.registered = false;
- slot_data.notification_event =
- Kernel::Event::Create(Kernel::ResetType::OneShot, "APT:Notification");
- slot_data.parameter_event =
- Kernel::Event::Create(Kernel::ResetType::OneShot, "APT:Parameter");
- }
-}
-
-void Shutdown() {
- shared_font_mem = nullptr;
- shared_font_loaded = false;
- shared_font_relocated = false;
- lock = nullptr;
-
- for (auto& slot : applet_slots) {
- slot.registered = false;
- slot.notification_event = nullptr;
- slot.parameter_event = nullptr;
- }
-
- next_parameter = boost::none;
-
- HLE::Applets::Shutdown();
-}
-
-} // namespace APT
-} // namespace Service
diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h
deleted file mode 100644
index 7b79e1f3e..000000000
--- a/src/core/hle/service/apt/apt.h
+++ /dev/null
@@ -1,533 +0,0 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#pragma once
-
-#include <vector>
-#include "common/common_funcs.h"
-#include "common/common_types.h"
-#include "common/swap.h"
-#include "core/hle/kernel/kernel.h"
-
-namespace Service {
-
-class Interface;
-
-namespace APT {
-
-/// Each APT service can only have up to 2 sessions connected at the same time.
-static const u32 MaxAPTSessions = 2;
-
-/// Holds information about the parameters used in Send/Glance/ReceiveParameter
-struct MessageParameter {
- u32 sender_id = 0;
- u32 destination_id = 0;
- u32 signal = 0;
- Kernel::SharedPtr<Kernel::Object> object = nullptr;
- std::vector<u8> buffer;
-};
-
-/// Holds information about the parameters used in StartLibraryApplet
-struct AppletStartupParameter {
- Kernel::SharedPtr<Kernel::Object> object = nullptr;
- std::vector<u8> buffer;
-};
-
-/// Used by the application to pass information about the current framebuffer to applets.
-struct CaptureBufferInfo {
- u32_le size;
- u8 is_3d;
- INSERT_PADDING_BYTES(0x3); // Padding for alignment
- u32_le top_screen_left_offset;
- u32_le top_screen_right_offset;
- u32_le top_screen_format;
- u32_le bottom_screen_left_offset;
- u32_le bottom_screen_right_offset;
- u32_le bottom_screen_format;
-};
-static_assert(sizeof(CaptureBufferInfo) == 0x20, "CaptureBufferInfo struct has incorrect size");
-
-/// Signals used by APT functions
-enum class SignalType : u32 {
- None = 0x0,
- Wakeup = 0x1,
- Request = 0x2,
- Response = 0x3,
- Exit = 0x4,
- Message = 0x5,
- HomeButtonSingle = 0x6,
- HomeButtonDouble = 0x7,
- DspSleep = 0x8,
- DspWakeup = 0x9,
- WakeupByExit = 0xA,
- WakeupByPause = 0xB,
- WakeupByCancel = 0xC,
- WakeupByCancelAll = 0xD,
- WakeupByPowerButtonClick = 0xE,
- WakeupToJumpHome = 0xF,
- RequestForSysApplet = 0x10,
- WakeupToLaunchApplication = 0x11,
-};
-
-/// App Id's used by APT functions
-enum class AppletId : u32 {
- None = 0,
- AnySystemApplet = 0x100,
- HomeMenu = 0x101,
- AlternateMenu = 0x103,
- Camera = 0x110,
- FriendsList = 0x112,
- GameNotes = 0x113,
- InternetBrowser = 0x114,
- InstructionManual = 0x115,
- Notifications = 0x116,
- Miiverse = 0x117,
- MiiversePost = 0x118,
- AmiiboSettings = 0x119,
- AnySysLibraryApplet = 0x200,
- SoftwareKeyboard1 = 0x201,
- Ed1 = 0x202,
- PnoteApp = 0x204,
- SnoteApp = 0x205,
- Error = 0x206,
- Mint = 0x207,
- Extrapad = 0x208,
- Memolib = 0x209,
- Application = 0x300,
- AnyLibraryApplet = 0x400,
- SoftwareKeyboard2 = 0x401,
- Ed2 = 0x402,
- PnoteApp2 = 0x404,
- SnoteApp2 = 0x405,
- Error2 = 0x406,
- Mint2 = 0x407,
- Extrapad2 = 0x408,
- Memolib2 = 0x409,
-};
-
-enum class StartupArgumentType : u32 {
- OtherApp = 0,
- Restart = 1,
- OtherMedia = 2,
-};
-
-enum class ScreencapPostPermission : u32 {
- CleanThePermission = 0, // TODO(JamePeng): verify what "zero" means
- NoExplicitSetting = 1,
- EnableScreenshotPostingToMiiverse = 2,
- DisableScreenshotPostingToMiiverse = 3
-};
-
-namespace ErrCodes {
-enum {
- ParameterPresent = 2,
- InvalidAppletSlot = 4,
-};
-} // namespace ErrCodes
-
-/// Send a parameter to the currently-running application, which will read it via ReceiveParameter
-void SendParameter(const MessageParameter& parameter);
-
-/**
- * APT::Initialize service function
- * Service function that initializes the APT process for the running application
- * Outputs:
- * 1 : Result of the function, 0 on success, otherwise error code
- * 3 : Handle to the notification event
- * 4 : Handle to the pause event
- */
-void Initialize(Service::Interface* self);
-
-/**
- * APT::GetSharedFont service function
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Virtual address of where shared font will be loaded in memory
- * 4 : Handle to shared font memory
- */
-void GetSharedFont(Service::Interface* self);
-
-/**
- * APT::Wrap service function
- * Inputs:
- * 1 : Output buffer size
- * 2 : Input buffer size
- * 3 : Nonce offset to the input buffer
- * 4 : Nonce size
- * 5 : Buffer mapping descriptor ((input_buffer_size << 4) | 0xA)
- * 6 : Input buffer address
- * 7 : Buffer mapping descriptor ((input_buffer_size << 4) | 0xC)
- * 8 : Output buffer address
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Buffer unmapping descriptor ((input_buffer_size << 4) | 0xA)
- * 3 : Input buffer address
- * 4 : Buffer unmapping descriptor ((input_buffer_size << 4) | 0xC)
- * 5 : Output buffer address
- */
-void Wrap(Service::Interface* self);
-
-/**
- * APT::Unwrap service function
- * Inputs:
- * 1 : Output buffer size
- * 2 : Input buffer size
- * 3 : Nonce offset to the output buffer
- * 4 : Nonce size
- * 5 : Buffer mapping descriptor ((input_buffer_size << 4) | 0xA)
- * 6 : Input buffer address
- * 7 : Buffer mapping descriptor ((input_buffer_size << 4) | 0xC)
- * 8 : Output buffer address
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Buffer unmapping descriptor ((input_buffer_size << 4) | 0xA)
- * 3 : Input buffer address
- * 4 : Buffer unmapping descriptor ((input_buffer_size << 4) | 0xC)
- * 5 : Output buffer address
- */
-void Unwrap(Service::Interface* self);
-
-/**
- * APT::NotifyToWait service function
- * Inputs:
- * 1 : AppID
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void NotifyToWait(Service::Interface* self);
-
-/**
- * APT::GetLockHandle service function
- * Inputs:
- * 1 : Applet attributes
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Applet attributes
- * 3 : Power button state
- * 4 : IPC handle descriptor
- * 5 : APT mutex handle
- */
-void GetLockHandle(Service::Interface* self);
-
-/**
- * APT::Enable service function
- * Inputs:
- * 1 : Applet attributes
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void Enable(Service::Interface* self);
-
-/**
- * APT::GetAppletManInfo service function.
- * Inputs:
- * 1 : Unknown
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Unknown u32 value
- * 3 : Unknown u8 value
- * 4 : Home Menu AppId
- * 5 : AppID of currently active app
- */
-void GetAppletManInfo(Service::Interface* self);
-
-/**
- * APT::GetAppletInfo service function.
- * Inputs:
- * 1 : AppId
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2-3 : Title ID
- * 4 : Media Type
- * 5 : Registered
- * 6 : Loaded
- * 7 : Attributes
- */
-void GetAppletInfo(Service::Interface* self);
-
-/**
- * APT::IsRegistered service function. This returns whether the specified AppID is registered with
- * NS yet. An AppID is "registered" once the process associated with the AppID uses APT:Enable. Home
- * Menu uses this command to determine when the launched process is running and to determine when to
- * stop using GSP, etc., while displaying the "Nintendo 3DS" loading screen.
- *
- * Inputs:
- * 1 : AppID
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Output, 0 = not registered, 1 = registered.
- */
-void IsRegistered(Service::Interface* self);
-
-void InquireNotification(Service::Interface* self);
-
-/**
- * APT::SendParameter service function. This sets the parameter data state.
- * Inputs:
- * 1 : Source AppID
- * 2 : Destination AppID
- * 3 : Signal type
- * 4 : Parameter buffer size, max size is 0x1000 (this can be zero)
- * 5 : Value
- * 6 : Handle to the destination process, likely used for shared memory (this can be zero)
- * 7 : (Size<<14) | 2
- * 8 : Input parameter buffer ptr
- * Outputs:
- * 0 : Return Header
- * 1 : Result of function, 0 on success, otherwise error code
-*/
-void SendParameter(Service::Interface* self);
-
-/**
- * APT::ReceiveParameter service function. This returns the current parameter data from NS state,
- * from the source process which set the parameters. Once finished, NS will clear a flag in the NS
- * state so that this command will return an error if this command is used again if parameters were
- * not set again. This is called when the second Initialize event is triggered. It returns a signal
- * type indicating why it was triggered.
- * Inputs:
- * 1 : AppID
- * 2 : Parameter buffer size, max size is 0x1000
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : AppID of the process which sent these parameters
- * 3 : Signal type
- * 4 : Actual parameter buffer size, this is <= to the the input size
- * 5 : Value
- * 6 : Handle from the source process which set the parameters, likely used for shared memory
- * 7 : Size
- * 8 : Output parameter buffer ptr
- */
-void ReceiveParameter(Service::Interface* self);
-
-/**
- * APT::GlanceParameter service function. This is exactly the same as APT_U::ReceiveParameter
- * (except for the word value prior to the output handle), except this will not clear the flag
- * (except when responseword[3]==8 || responseword[3]==9) in NS state.
- * Inputs:
- * 1 : AppID
- * 2 : Parameter buffer size, max size is 0x1000
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Unknown, for now assume AppID of the process which sent these parameters
- * 3 : Unknown, for now assume Signal type
- * 4 : Actual parameter buffer size, this is <= to the the input size
- * 5 : Value
- * 6 : Handle from the source process which set the parameters, likely used for shared memory
- * 7 : Size
- * 8 : Output parameter buffer ptr
- */
-void GlanceParameter(Service::Interface* self);
-
-/**
- * APT::CancelParameter service function. When the parameter data is available, and when the above
- * specified fields match the ones in NS state(for the ones where the checks are enabled), this
- * clears the flag which indicates that parameter data is available
- * (same flag cleared by APT:ReceiveParameter).
- * Inputs:
- * 1 : Flag, when non-zero NS will compare the word after this one with a field in the NS
- * state.
- * 2 : Unknown, this is the same as the first unknown field returned by APT:ReceiveParameter.
- * 3 : Flag, when non-zero NS will compare the word after this one with a field in the NS
- * state.
- * 4 : AppID
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Status flag, 0 = failure due to no parameter data being available, or the above enabled
- * fields don't match the fields in NS state. 1 = success.
- */
-void CancelParameter(Service::Interface* self);
-
-/**
- * APT::PrepareToStartApplication service function. When the input title-info programID is zero,
- * NS will load the actual program ID via AMNet:GetTitleIDList. After doing some checks with the
- * programID, NS will then set a NS state flag to value 1, then set the programID for AppID
- * 0x300(application) to the input program ID(or the one from GetTitleIDList). A media-type field
- * in the NS state is also set to the input media-type value
- * (other state fields are set at this point as well). With 8.0.0-18, NS will set an u8 NS state
- * field to value 1 when input flags bit8 is set
- * Inputs:
- * 1-4 : 0x10-byte title-info struct
- * 4 : Flags
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void PrepareToStartApplication(Service::Interface* self);
-
-/**
- * APT::StartApplication service function. Buf0 is copied to NS FIRMparams+0x0, then Buf1 is copied
- * to the NS FIRMparams+0x480. Then the application is launched.
- * Inputs:
- * 1 : Buffer 0 size, max size is 0x300
- * 2 : Buffer 1 size, max size is 0x20 (this can be zero)
- * 3 : u8 flag
- * 4 : (Size0<<14) | 2
- * 5 : Buffer 0 pointer
- * 6 : (Size1<<14) | 0x802
- * 7 : Buffer 1 pointer
- * Outputs:
- * 0 : Return Header
- * 1 : Result of function, 0 on success, otherwise error code
-*/
-void StartApplication(Service::Interface* self);
-
-/**
- * APT::AppletUtility service function
- * Inputs:
- * 1 : Unknown, but clearly used for something
- * 2 : Buffer 1 size (purpose is unknown)
- * 3 : Buffer 2 size (purpose is unknown)
- * 5 : Buffer 1 address (purpose is unknown)
- * 65 : Buffer 2 address (purpose is unknown)
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void AppletUtility(Service::Interface* self);
-
-/**
- * APT::SetAppCpuTimeLimit service function
- * Inputs:
- * 1 : Value, must be one
- * 2 : Percentage of CPU time from 5 to 80
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void SetAppCpuTimeLimit(Service::Interface* self);
-
-/**
- * APT::GetAppCpuTimeLimit service function
- * Inputs:
- * 1 : Value, must be one
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : System core CPU time percentage
- */
-void GetAppCpuTimeLimit(Service::Interface* self);
-
-/**
- * APT::PrepareToStartLibraryApplet service function
- * Inputs:
- * 0 : Command header [0x00180040]
- * 1 : Id of the applet to start
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void PrepareToStartLibraryApplet(Service::Interface* self);
-
-/**
- * APT::PrepareToStartNewestHomeMenu service function
- * Inputs:
- * 0 : Command header [0x001A0000]
- * Outputs:
- * 0 : Return header
- * 1 : Result of function
- */
-void PrepareToStartNewestHomeMenu(Service::Interface* self);
-
-/**
- * APT::PreloadLibraryApplet service function
- * Inputs:
- * 0 : Command header [0x00160040]
- * 1 : Id of the applet to start
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void PreloadLibraryApplet(Service::Interface* self);
-
-/**
- * APT::StartLibraryApplet service function
- * Inputs:
- * 0 : Command header [0x001E0084]
- * 1 : Id of the applet to start
- * 2 : Buffer size
- * 3 : Always 0?
- * 4 : Handle passed to the applet
- * 5 : (Size << 14) | 2
- * 6 : Input buffer virtual address
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void StartLibraryApplet(Service::Interface* self);
-
-/**
- * APT::CancelLibraryApplet service function
- * Inputs:
- * 0 : Command header [0x003B0040]
- * 1 : u8, Application exiting (0 = not exiting, 1 = exiting)
- * Outputs:
- * 0 : Header code
- * 1 : Result code
- */
-void CancelLibraryApplet(Service::Interface* self);
-
-/**
- * APT::GetStartupArgument service function
- * Inputs:
- * 1 : Parameter Size (capped to 0x300)
- * 2 : StartupArgumentType
- * 65 : Output buffer for startup argument
- * Outputs:
- * 0 : Return header
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : u8, Exists (0 = does not exist, 1 = exists)
- */
-void GetStartupArgument(Service::Interface* self);
-
-/**
- * APT::SetScreenCapPostPermission service function
- * Inputs:
- * 0 : Header Code[0x00550040]
- * 1 : u8 The screenshot posting permission
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- */
-void SetScreenCapPostPermission(Service::Interface* self);
-
-/**
- * APT::GetScreenCapPostPermission service function
- * Inputs:
- * 0 : Header Code[0x00560000]
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : u8 The screenshot posting permission
- */
-void GetScreenCapPostPermission(Service::Interface* self);
-
-/**
- * APT::CheckNew3DSApp service function
- * Outputs:
- * 1: Result code, 0 on success, otherwise error code
- * 2: u8 output: 0 = Old3DS, 1 = New3DS.
- * Note:
- * This uses PTMSYSM:CheckNew3DS.
- * When a certain NS state field is non-zero, the output value is zero,
- * Otherwise the output is from PTMSYSM:CheckNew3DS.
- * Normally this NS state field is zero, however this state field is set to 1
- * when APT:PrepareToStartApplication is used with flags bit8 is set.
- */
-void CheckNew3DSApp(Service::Interface* self);
-
-/**
- * Wrapper for PTMSYSM:CheckNew3DS
- * APT::CheckNew3DS service function
- * Outputs:
- * 1: Result code, 0 on success, otherwise error code
- * 2: u8 output: 0 = Old3DS, 1 = New3DS.
- */
-void CheckNew3DS(Service::Interface* self);
-
-/// Initialize the APT service
-void Init();
-
-/// Shutdown the APT service
-void Shutdown();
-
-} // namespace APT
-} // namespace Service
diff --git a/src/core/hle/service/apt/apt_a.cpp b/src/core/hle/service/apt/apt_a.cpp
deleted file mode 100644
index c496cba8d..000000000
--- a/src/core/hle/service/apt/apt_a.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "core/hle/service/apt/apt.h"
-#include "core/hle/service/apt/apt_a.h"
-
-namespace Service {
-namespace APT {
-
-const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetLockHandle, "GetLockHandle"},
- {0x00020080, Initialize, "Initialize"},
- {0x00030040, Enable, "Enable"},
- {0x00040040, nullptr, "Finalize"},
- {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
- {0x00060040, GetAppletInfo, "GetAppletInfo"},
- {0x00070000, nullptr, "GetLastSignaledAppletId"},
- {0x00080000, nullptr, "CountRegisteredApplet"},
- {0x00090040, IsRegistered, "IsRegistered"},
- {0x000A0040, nullptr, "GetAttribute"},
- {0x000B0040, InquireNotification, "InquireNotification"},
- {0x000C0104, SendParameter, "SendParameter"},
- {0x000D0080, ReceiveParameter, "ReceiveParameter"},
- {0x000E0080, GlanceParameter, "GlanceParameter"},
- {0x000F0100, CancelParameter, "CancelParameter"},
- {0x001000C2, nullptr, "DebugFunc"},
- {0x001100C0, nullptr, "MapProgramIdForDebug"},
- {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
- {0x00130000, nullptr, "GetPreparationState"},
- {0x00140040, nullptr, "SetPreparationState"},
- {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
- {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
- {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
- {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
- {0x00190040, nullptr, "PrepareToStartSystemApplet"},
- {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
- {0x001B00C4, nullptr, "StartApplication"},
- {0x001C0000, nullptr, "WakeupApplication"},
- {0x001D0000, nullptr, "CancelApplication"},
- {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
- {0x001F0084, nullptr, "StartSystemApplet"},
- {0x00200044, nullptr, "StartNewestHomeMenu"},
- {0x00210000, nullptr, "OrderToCloseApplication"},
- {0x00220040, nullptr, "PrepareToCloseApplication"},
- {0x00230040, nullptr, "PrepareToJumpToApplication"},
- {0x00240044, nullptr, "JumpToApplication"},
- {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
- {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
- {0x00270044, nullptr, "CloseApplication"},
- {0x00280044, nullptr, "CloseLibraryApplet"},
- {0x00290044, nullptr, "CloseSystemApplet"},
- {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
- {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
- {0x002C0044, nullptr, "JumpToHomeMenu"},
- {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
- {0x002E0044, nullptr, "LeaveHomeMenu"},
- {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
- {0x00300044, nullptr, "LeaveResidentApplet"},
- {0x00310100, nullptr, "PrepareToDoApplicationJump"},
- {0x00320084, nullptr, "DoApplicationJump"},
- {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
- {0x00340084, nullptr, "SendDeliverArg"},
- {0x00350080, nullptr, "ReceiveDeliverArg"},
- {0x00360040, nullptr, "LoadSysMenuArg"},
- {0x00370042, nullptr, "StoreSysMenuArg"},
- {0x00380040, nullptr, "PreloadResidentApplet"},
- {0x00390040, nullptr, "PrepareToStartResidentApplet"},
- {0x003A0044, nullptr, "StartResidentApplet"},
- {0x003B0040, CancelLibraryApplet, "CancelLibraryApplet"},
- {0x003C0042, nullptr, "SendDspSleep"},
- {0x003D0042, nullptr, "SendDspWakeUp"},
- {0x003E0080, nullptr, "ReplySleepQuery"},
- {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
- {0x00400042, nullptr, "SendCaptureBufferInfo"},
- {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
- {0x00420080, nullptr, "SleepSystem"},
- {0x00430040, NotifyToWait, "NotifyToWait"},
- {0x00440000, GetSharedFont, "GetSharedFont"},
- {0x00450040, nullptr, "GetWirelessRebootInfo"},
- {0x00460104, Wrap, "Wrap"},
- {0x00470104, Unwrap, "Unwrap"},
- {0x00480100, nullptr, "GetProgramInfo"},
- {0x00490180, nullptr, "Reboot"},
- {0x004A0040, nullptr, "GetCaptureInfo"},
- {0x004B00C2, AppletUtility, "AppletUtility"},
- {0x004C0000, nullptr, "SetFatalErrDispMode"},
- {0x004D0080, nullptr, "GetAppletProgramInfo"},
- {0x004E0000, nullptr, "HardwareResetAsync"},
- {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
- {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
- {0x00510080, GetStartupArgument, "GetStartupArgument"},
- {0x00520104, nullptr, "Wrap1"},
- {0x00530104, nullptr, "Unwrap1"},
- {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
- {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
- {0x00570044, nullptr, "WakeupApplication2"},
- {0x00580002, nullptr, "GetProgramID"},
- {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
- {0x01020000, CheckNew3DS, "CheckNew3DS"},
- {0x01040000, nullptr, "IsStandardMemoryLayout"},
- {0x01050100, nullptr, "IsTitleAllowed"},
-};
-
-APT_A_Interface::APT_A_Interface() : Interface(MaxAPTSessions) {
- Register(FunctionTable);
-}
-
-} // namespace APT
-} // namespace Service
diff --git a/src/core/hle/service/apt/apt_a.h b/src/core/hle/service/apt/apt_a.h
deleted file mode 100644
index 331fb5586..000000000
--- a/src/core/hle/service/apt/apt_a.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2014 Citra Emulator Project
-// 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 APT {
-
-class APT_A_Interface : public Service::Interface {
-public:
- APT_A_Interface();
-
- std::string GetPortName() const override {
- return "APT:A";
- }
-};
-
-} // namespace APT
-} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp
deleted file mode 100644
index bb78ee7d7..000000000
--- a/src/core/hle/service/apt/apt_s.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "core/hle/service/apt/apt.h"
-#include "core/hle/service/apt/apt_s.h"
-
-namespace Service {
-namespace APT {
-
-const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetLockHandle, "GetLockHandle"},
- {0x00020080, Initialize, "Initialize"},
- {0x00030040, Enable, "Enable"},
- {0x00040040, nullptr, "Finalize"},
- {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
- {0x00060040, GetAppletInfo, "GetAppletInfo"},
- {0x00070000, nullptr, "GetLastSignaledAppletId"},
- {0x00080000, nullptr, "CountRegisteredApplet"},
- {0x00090040, IsRegistered, "IsRegistered"},
- {0x000A0040, nullptr, "GetAttribute"},
- {0x000B0040, InquireNotification, "InquireNotification"},
- {0x000C0104, SendParameter, "SendParameter"},
- {0x000D0080, ReceiveParameter, "ReceiveParameter"},
- {0x000E0080, GlanceParameter, "GlanceParameter"},
- {0x000F0100, nullptr, "CancelParameter"},
- {0x001000C2, nullptr, "DebugFunc"},
- {0x001100C0, nullptr, "MapProgramIdForDebug"},
- {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
- {0x00130000, nullptr, "GetPreparationState"},
- {0x00140040, nullptr, "SetPreparationState"},
- {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
- {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
- {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
- {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
- {0x00190040, nullptr, "PrepareToStartSystemApplet"},
- {0x001A0000, PrepareToStartNewestHomeMenu, "PrepareToStartNewestHomeMenu"},
- {0x001B00C4, nullptr, "StartApplication"},
- {0x001C0000, nullptr, "WakeupApplication"},
- {0x001D0000, nullptr, "CancelApplication"},
- {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
- {0x001F0084, nullptr, "StartSystemApplet"},
- {0x00200044, nullptr, "StartNewestHomeMenu"},
- {0x00210000, nullptr, "OrderToCloseApplication"},
- {0x00220040, nullptr, "PrepareToCloseApplication"},
- {0x00230040, nullptr, "PrepareToJumpToApplication"},
- {0x00240044, nullptr, "JumpToApplication"},
- {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
- {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
- {0x00270044, nullptr, "CloseApplication"},
- {0x00280044, nullptr, "CloseLibraryApplet"},
- {0x00290044, nullptr, "CloseSystemApplet"},
- {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
- {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
- {0x002C0044, nullptr, "JumpToHomeMenu"},
- {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
- {0x002E0044, nullptr, "LeaveHomeMenu"},
- {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
- {0x00300044, nullptr, "LeaveResidentApplet"},
- {0x00310100, nullptr, "PrepareToDoApplicationJump"},
- {0x00320084, nullptr, "DoApplicationJump"},
- {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
- {0x00340084, nullptr, "SendDeliverArg"},
- {0x00350080, nullptr, "ReceiveDeliverArg"},
- {0x00360040, nullptr, "LoadSysMenuArg"},
- {0x00370042, nullptr, "StoreSysMenuArg"},
- {0x00380040, nullptr, "PreloadResidentApplet"},
- {0x00390040, nullptr, "PrepareToStartResidentApplet"},
- {0x003A0044, nullptr, "StartResidentApplet"},
- {0x003B0040, nullptr, "CancelLibraryApplet"},
- {0x003C0042, nullptr, "SendDspSleep"},
- {0x003D0042, nullptr, "SendDspWakeUp"},
- {0x003E0080, nullptr, "ReplySleepQuery"},
- {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
- {0x00400042, nullptr, "SendCaptureBufferInfo"},
- {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
- {0x00420080, nullptr, "SleepSystem"},
- {0x00430040, NotifyToWait, "NotifyToWait"},
- {0x00440000, GetSharedFont, "GetSharedFont"},
- {0x00450040, nullptr, "GetWirelessRebootInfo"},
- {0x00460104, Wrap, "Wrap"},
- {0x00470104, Unwrap, "Unwrap"},
- {0x00480100, nullptr, "GetProgramInfo"},
- {0x00490180, nullptr, "Reboot"},
- {0x004A0040, nullptr, "GetCaptureInfo"},
- {0x004B00C2, AppletUtility, "AppletUtility"},
- {0x004C0000, nullptr, "SetFatalErrDispMode"},
- {0x004D0080, nullptr, "GetAppletProgramInfo"},
- {0x004E0000, nullptr, "HardwareResetAsync"},
- {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
- {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
- {0x00510080, GetStartupArgument, "GetStartupArgument"},
- {0x00520104, nullptr, "Wrap1"},
- {0x00530104, nullptr, "Unwrap1"},
- {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
- {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
- {0x00570044, nullptr, "WakeupApplication2"},
- {0x00580002, nullptr, "GetProgramID"},
- {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
- {0x01020000, CheckNew3DS, "CheckNew3DS"},
- {0x01040000, nullptr, "IsStandardMemoryLayout"},
- {0x01050100, nullptr, "IsTitleAllowed"},
-};
-
-APT_S_Interface::APT_S_Interface() : Interface(MaxAPTSessions) {
- Register(FunctionTable);
-}
-
-} // namespace APT
-} // namespace Service
diff --git a/src/core/hle/service/apt/apt_s.h b/src/core/hle/service/apt/apt_s.h
deleted file mode 100644
index 8e87b69af..000000000
--- a/src/core/hle/service/apt/apt_s.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2015 Citra Emulator Project
-// 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 APT {
-
-// Application and title launching service. These services handle signaling for home/power button as
-// well. Only one session for either APT service can be open at a time, normally processes close the
-// service handle immediately once finished using the service. The commands for APT:U and APT:S are
-// exactly the same, however certain commands are only accessible with APT:S(NS module will call
-// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services.
-
-/// Interface to "APT:S" service
-class APT_S_Interface : public Service::Interface {
-public:
- APT_S_Interface();
-
- std::string GetPortName() const override {
- return "APT:S";
- }
-};
-
-} // namespace APT
-} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp
deleted file mode 100644
index 9dd002590..000000000
--- a/src/core/hle/service/apt/apt_u.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2014 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "core/hle/service/apt/apt.h"
-#include "core/hle/service/apt/apt_u.h"
-
-namespace Service {
-namespace APT {
-
-const Interface::FunctionInfo FunctionTable[] = {
- {0x00010040, GetLockHandle, "GetLockHandle"},
- {0x00020080, Initialize, "Initialize"},
- {0x00030040, Enable, "Enable"},
- {0x00040040, nullptr, "Finalize"},
- {0x00050040, GetAppletManInfo, "GetAppletManInfo"},
- {0x00060040, GetAppletInfo, "GetAppletInfo"},
- {0x00070000, nullptr, "GetLastSignaledAppletId"},
- {0x00080000, nullptr, "CountRegisteredApplet"},
- {0x00090040, IsRegistered, "IsRegistered"},
- {0x000A0040, nullptr, "GetAttribute"},
- {0x000B0040, InquireNotification, "InquireNotification"},
- {0x000C0104, SendParameter, "SendParameter"},
- {0x000D0080, ReceiveParameter, "ReceiveParameter"},
- {0x000E0080, GlanceParameter, "GlanceParameter"},
- {0x000F0100, CancelParameter, "CancelParameter"},
- {0x001000C2, nullptr, "DebugFunc"},
- {0x001100C0, nullptr, "MapProgramIdForDebug"},
- {0x00120040, nullptr, "SetHomeMenuAppletIdForDebug"},
- {0x00130000, nullptr, "GetPreparationState"},
- {0x00140040, nullptr, "SetPreparationState"},
- {0x00150140, PrepareToStartApplication, "PrepareToStartApplication"},
- {0x00160040, PreloadLibraryApplet, "PreloadLibraryApplet"},
- {0x00170040, nullptr, "FinishPreloadingLibraryApplet"},
- {0x00180040, PrepareToStartLibraryApplet, "PrepareToStartLibraryApplet"},
- {0x00190040, nullptr, "PrepareToStartSystemApplet"},
- {0x001A0000, nullptr, "PrepareToStartNewestHomeMenu"},
- {0x001B00C4, nullptr, "StartApplication"},
- {0x001C0000, nullptr, "WakeupApplication"},
- {0x001D0000, nullptr, "CancelApplication"},
- {0x001E0084, StartLibraryApplet, "StartLibraryApplet"},
- {0x001F0084, nullptr, "StartSystemApplet"},
- {0x00200044, nullptr, "StartNewestHomeMenu"},
- {0x00210000, nullptr, "OrderToCloseApplication"},
- {0x00220040, nullptr, "PrepareToCloseApplication"},
- {0x00230040, nullptr, "PrepareToJumpToApplication"},
- {0x00240044, nullptr, "JumpToApplication"},
- {0x002500C0, nullptr, "PrepareToCloseLibraryApplet"},
- {0x00260000, nullptr, "PrepareToCloseSystemApplet"},
- {0x00270044, nullptr, "CloseApplication"},
- {0x00280044, nullptr, "CloseLibraryApplet"},
- {0x00290044, nullptr, "CloseSystemApplet"},
- {0x002A0000, nullptr, "OrderToCloseSystemApplet"},
- {0x002B0000, nullptr, "PrepareToJumpToHomeMenu"},
- {0x002C0044, nullptr, "JumpToHomeMenu"},
- {0x002D0000, nullptr, "PrepareToLeaveHomeMenu"},
- {0x002E0044, nullptr, "LeaveHomeMenu"},
- {0x002F0040, nullptr, "PrepareToLeaveResidentApplet"},
- {0x00300044, nullptr, "LeaveResidentApplet"},
- {0x00310100, nullptr, "PrepareToDoApplicationJump"},
- {0x00320084, nullptr, "DoApplicationJump"},
- {0x00330000, nullptr, "GetProgramIdOnApplicationJump"},
- {0x00340084, nullptr, "SendDeliverArg"},
- {0x00350080, nullptr, "ReceiveDeliverArg"},
- {0x00360040, nullptr, "LoadSysMenuArg"},
- {0x00370042, nullptr, "StoreSysMenuArg"},
- {0x00380040, nullptr, "PreloadResidentApplet"},
- {0x00390040, nullptr, "PrepareToStartResidentApplet"},
- {0x003A0044, nullptr, "StartResidentApplet"},
- {0x003B0040, CancelLibraryApplet, "CancelLibraryApplet"},
- {0x003C0042, nullptr, "SendDspSleep"},
- {0x003D0042, nullptr, "SendDspWakeUp"},
- {0x003E0080, nullptr, "ReplySleepQuery"},
- {0x003F0040, nullptr, "ReplySleepNotificationComplete"},
- {0x00400042, nullptr, "SendCaptureBufferInfo"},
- {0x00410040, nullptr, "ReceiveCaptureBufferInfo"},
- {0x00420080, nullptr, "SleepSystem"},
- {0x00430040, NotifyToWait, "NotifyToWait"},
- {0x00440000, GetSharedFont, "GetSharedFont"},
- {0x00450040, nullptr, "GetWirelessRebootInfo"},
- {0x00460104, Wrap, "Wrap"},
- {0x00470104, Unwrap, "Unwrap"},
- {0x00480100, nullptr, "GetProgramInfo"},
- {0x00490180, nullptr, "Reboot"},
- {0x004A0040, nullptr, "GetCaptureInfo"},
- {0x004B00C2, AppletUtility, "AppletUtility"},
- {0x004C0000, nullptr, "SetFatalErrDispMode"},
- {0x004D0080, nullptr, "GetAppletProgramInfo"},
- {0x004E0000, nullptr, "HardwareResetAsync"},
- {0x004F0080, SetAppCpuTimeLimit, "SetAppCpuTimeLimit"},
- {0x00500040, GetAppCpuTimeLimit, "GetAppCpuTimeLimit"},
- {0x00510080, GetStartupArgument, "GetStartupArgument"},
- {0x00520104, nullptr, "Wrap1"},
- {0x00530104, nullptr, "Unwrap1"},
- {0x00550040, SetScreenCapPostPermission, "SetScreenCapPostPermission"},
- {0x00560000, GetScreenCapPostPermission, "GetScreenCapPostPermission"},
- {0x00580002, nullptr, "GetProgramID"},
- {0x01010000, CheckNew3DSApp, "CheckNew3DSApp"},
- {0x01020000, CheckNew3DS, "CheckNew3DS"},
-};
-
-APT_U_Interface::APT_U_Interface() : Interface(MaxAPTSessions) {
- Register(FunctionTable);
-}
-
-} // namespace APT
-} // namespace Service
diff --git a/src/core/hle/service/apt/apt_u.h b/src/core/hle/service/apt/apt_u.h
deleted file mode 100644
index 8c7fe0ccb..000000000
--- a/src/core/hle/service/apt/apt_u.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 Citra Emulator Project
-// 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 APT {
-
-// Application and title launching service. These services handle signaling for home/power button as
-// well. Only one session for either APT service can be open at a time, normally processes close the
-// service handle immediately once finished using the service. The commands for APT:U and APT:S are
-// exactly the same, however certain commands are only accessible with APT:S(NS module will call
-// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services.
-
-/// Interface to "APT:U" service
-class APT_U_Interface : public Service::Interface {
-public:
- APT_U_Interface();
-
- std::string GetPortName() const override {
- return "APT:U";
- }
-};
-
-} // namespace APT
-} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/apt/bcfnt/bcfnt.cpp b/src/core/hle/service/apt/bcfnt/bcfnt.cpp
deleted file mode 100644
index 6d2474702..000000000
--- a/src/core/hle/service/apt/bcfnt/bcfnt.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "core/hle/service/apt/bcfnt/bcfnt.h"
-#include "core/hle/service/service.h"
-
-namespace Service {
-namespace APT {
-namespace BCFNT {
-
-void RelocateSharedFont(Kernel::SharedPtr<Kernel::SharedMemory> shared_font, VAddr new_address) {
- static const u32 SharedFontStartOffset = 0x80;
- const u8* cfnt_ptr = shared_font->GetPointer(SharedFontStartOffset);
-
- CFNT cfnt;
- memcpy(&cfnt, cfnt_ptr, sizeof(cfnt));
-
- u32 assumed_cmap_offset = 0;
- u32 assumed_cwdh_offset = 0;
- u32 assumed_tglp_offset = 0;
- u32 first_cmap_offset = 0;
- u32 first_cwdh_offset = 0;
- u32 first_tglp_offset = 0;
-
- // First discover the location of sections so that the rebase offset can be auto-detected
- u32 current_offset = SharedFontStartOffset + cfnt.header_size;
- for (unsigned block = 0; block < cfnt.num_blocks; ++block) {
- const u8* data = shared_font->GetPointer(current_offset);
-
- SectionHeader section_header;
- memcpy(&section_header, data, sizeof(section_header));
-
- if (first_cmap_offset == 0 && memcmp(section_header.magic, "CMAP", 4) == 0) {
- first_cmap_offset = current_offset;
- } else if (first_cwdh_offset == 0 && memcmp(section_header.magic, "CWDH", 4) == 0) {
- first_cwdh_offset = current_offset;
- } else if (first_tglp_offset == 0 && memcmp(section_header.magic, "TGLP", 4) == 0) {
- first_tglp_offset = current_offset;
- } else if (memcmp(section_header.magic, "FINF", 4) == 0) {
- BCFNT::FINF finf;
- memcpy(&finf, data, sizeof(finf));
-
- assumed_cmap_offset = finf.cmap_offset - sizeof(SectionHeader);
- assumed_cwdh_offset = finf.cwdh_offset - sizeof(SectionHeader);
- assumed_tglp_offset = finf.tglp_offset - sizeof(SectionHeader);
- }
-
- current_offset += section_header.section_size;
- }
-
- u32 previous_base = assumed_cmap_offset - first_cmap_offset;
- ASSERT(previous_base == assumed_cwdh_offset - first_cwdh_offset);
- ASSERT(previous_base == assumed_tglp_offset - first_tglp_offset);
-
- u32 offset = new_address - previous_base;
-
- // Reset pointer back to start of sections and do the actual rebase
- current_offset = SharedFontStartOffset + cfnt.header_size;
- for (unsigned block = 0; block < cfnt.num_blocks; ++block) {
- u8* data = shared_font->GetPointer(current_offset);
-
- SectionHeader section_header;
- memcpy(&section_header, data, sizeof(section_header));
-
- if (memcmp(section_header.magic, "FINF", 4) == 0) {
- BCFNT::FINF finf;
- memcpy(&finf, data, sizeof(finf));
-
- // Relocate the offsets in the FINF section
- finf.cmap_offset += offset;
- finf.cwdh_offset += offset;
- finf.tglp_offset += offset;
-
- memcpy(data, &finf, sizeof(finf));
- } else if (memcmp(section_header.magic, "CMAP", 4) == 0) {
- BCFNT::CMAP cmap;
- memcpy(&cmap, data, sizeof(cmap));
-
- // Relocate the offsets in the CMAP section
- if (cmap.next_cmap_offset != 0)
- cmap.next_cmap_offset += offset;
-
- memcpy(data, &cmap, sizeof(cmap));
- } else if (memcmp(section_header.magic, "CWDH", 4) == 0) {
- BCFNT::CWDH cwdh;
- memcpy(&cwdh, data, sizeof(cwdh));
-
- // Relocate the offsets in the CWDH section
- if (cwdh.next_cwdh_offset != 0)
- cwdh.next_cwdh_offset += offset;
-
- memcpy(data, &cwdh, sizeof(cwdh));
- } else if (memcmp(section_header.magic, "TGLP", 4) == 0) {
- BCFNT::TGLP tglp;
- memcpy(&tglp, data, sizeof(tglp));
-
- // Relocate the offsets in the TGLP section
- tglp.sheet_data_offset += offset;
-
- memcpy(data, &tglp, sizeof(tglp));
- }
-
- current_offset += section_header.section_size;
- }
-}
-
-} // namespace BCFNT
-} // namespace APT
-} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/apt/bcfnt/bcfnt.h b/src/core/hle/service/apt/bcfnt/bcfnt.h
deleted file mode 100644
index 453bf7606..000000000
--- a/src/core/hle/service/apt/bcfnt/bcfnt.h
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2016 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#pragma once
-
-#include "common/swap.h"
-#include "core/hle/kernel/shared_memory.h"
-#include "core/hle/service/service.h"
-
-namespace Service {
-namespace APT {
-namespace BCFNT { ///< BCFNT Shared Font file structures
-
-struct CFNT {
- u8 magic[4];
- u16_le endianness;
- u16_le header_size;
- u32_le version;
- u32_le file_size;
- u32_le num_blocks;
-};
-
-struct SectionHeader {
- u8 magic[4];
- u32_le section_size;
-};
-
-struct FINF {
- u8 magic[4];
- u32_le section_size;
- u8 font_type;
- u8 line_feed;
- u16_le alter_char_index;
- u8 default_width[3];
- u8 encoding;
- u32_le tglp_offset;
- u32_le cwdh_offset;
- u32_le cmap_offset;
- u8 height;
- u8 width;
- u8 ascent;
- u8 reserved;
-};
-
-struct TGLP {
- u8 magic[4];
- u32_le section_size;
- u8 cell_width;
- u8 cell_height;
- u8 baseline_position;
- u8 max_character_width;
- u32_le sheet_size;
- u16_le num_sheets;
- u16_le sheet_image_format;
- u16_le num_columns;
- u16_le num_rows;
- u16_le sheet_width;
- u16_le sheet_height;
- u32_le sheet_data_offset;
-};
-
-struct CMAP {
- u8 magic[4];
- u32_le section_size;
- u16_le code_begin;
- u16_le code_end;
- u16_le mapping_method;
- u16_le reserved;
- u32_le next_cmap_offset;
-};
-
-struct CWDH {
- u8 magic[4];
- u32_le section_size;
- u16_le start_index;
- u16_le end_index;
- u32_le next_cwdh_offset;
-};
-
-/**
- * Relocates the internal addresses of the BCFNT Shared Font to the new base. The current base will
- * be auto-detected based on the file headers.
- *
- * @param shared_font SharedMemory object that contains the Shared Font
- * @param new_address New base for the offsets in the structure.
- */
-void RelocateSharedFont(Kernel::SharedPtr<Kernel::SharedMemory> shared_font, VAddr new_address);
-
-} // namespace BCFNT
-} // namespace APT
-} // namespace Service