summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-08-06 01:31:02 -0300
committerGravatar Yuri Kunde Schlesner2015-08-16 01:03:48 -0300
commit38bfbe1b2b6a19ec4449a1ac19ba1f735aa5d279 (patch)
treebef4f5e9214ca62e4b7f6542001e320d8b7e68f2 /src/core
parentKernel: Implement svcGetProcessInfo in a basic way (diff)
downloadyuzu-38bfbe1b2b6a19ec4449a1ac19ba1f735aa5d279.tar.gz
yuzu-38bfbe1b2b6a19ec4449a1ac19ba1f735aa5d279.tar.xz
yuzu-38bfbe1b2b6a19ec4449a1ac19ba1f735aa5d279.zip
APT: Adjust shared font hack so it works with the new linear heap code
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/apt/apt.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 35402341b..6a2fdea2b 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -16,6 +16,7 @@
16#include "core/hle/hle.h" 16#include "core/hle/hle.h"
17#include "core/hle/kernel/event.h" 17#include "core/hle/kernel/event.h"
18#include "core/hle/kernel/mutex.h" 18#include "core/hle/kernel/mutex.h"
19#include "core/hle/kernel/process.h"
19#include "core/hle/kernel/shared_memory.h" 20#include "core/hle/kernel/shared_memory.h"
20#include "core/hle/kernel/thread.h" 21#include "core/hle/kernel/thread.h"
21 22
@@ -37,7 +38,7 @@ static Kernel::SharedPtr<Kernel::Mutex> lock;
37static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event 38static Kernel::SharedPtr<Kernel::Event> notification_event; ///< APT notification event
38static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event 39static Kernel::SharedPtr<Kernel::Event> parameter_event; ///< APT parameter event
39 40
40static std::vector<u8> shared_font; 41static std::shared_ptr<std::vector<u8>> shared_font;
41 42
42static u32 cpu_percent; ///< CPU time available to the running application 43static u32 cpu_percent; ///< CPU time available to the running application
43 44
@@ -74,11 +75,12 @@ void Initialize(Service::Interface* self) {
74void GetSharedFont(Service::Interface* self) { 75void GetSharedFont(Service::Interface* self) {
75 u32* cmd_buff = Kernel::GetCommandBuffer(); 76 u32* cmd_buff = Kernel::GetCommandBuffer();
76 77
77 if (!shared_font.empty()) { 78 if (shared_font != nullptr) {
78 // TODO(bunnei): This function shouldn't copy the shared font every time it's called. 79 // TODO(yuriks): This is a hack to keep this working right now even with our completely
79 // Instead, it should probably map the shared font as RO memory. We don't currently have 80 // broken shared memory system.
80 // an easy way to do this, but the copy should be sufficient for now. 81 shared_font_mem->base_address = SHARED_FONT_VADDR;
81 memcpy(Memory::GetPointer(SHARED_FONT_VADDR), shared_font.data(), shared_font.size()); 82 Kernel::g_current_process->vm_manager.MapMemoryBlock(shared_font_mem->base_address,
83 shared_font, 0, shared_font_mem->size, Kernel::MemoryState::Shared);
82 84
83 cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2); 85 cmd_buff[0] = IPC::MakeHeader(0x44, 2, 2);
84 cmd_buff[1] = RESULT_SUCCESS.raw; // No error 86 cmd_buff[1] = RESULT_SUCCESS.raw; // No error
@@ -391,7 +393,6 @@ void Init() {
391 // a homebrew app to do this: https://github.com/citra-emu/3dsutils. Put the resulting file 393 // a homebrew app to do this: https://github.com/citra-emu/3dsutils. Put the resulting file
392 // "shared_font.bin" in the Citra "sysdata" directory. 394 // "shared_font.bin" in the Citra "sysdata" directory.
393 395
394 shared_font.clear();
395 std::string filepath = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT; 396 std::string filepath = FileUtil::GetUserPath(D_SYSDATA_IDX) + SHARED_FONT;
396 397
397 FileUtil::CreateFullPath(filepath); // Create path if not already created 398 FileUtil::CreateFullPath(filepath); // Create path if not already created
@@ -399,8 +400,8 @@ void Init() {
399 400
400 if (file.IsOpen()) { 401 if (file.IsOpen()) {
401 // Read shared font data 402 // Read shared font data
402 shared_font.resize((size_t)file.GetSize()); 403 shared_font = std::make_shared<std::vector<u8>>((size_t)file.GetSize());
403 file.ReadBytes(shared_font.data(), (size_t)file.GetSize()); 404 file.ReadBytes(shared_font->data(), shared_font->size());
404 405
405 // Create shared font memory object 406 // Create shared font memory object
406 using Kernel::MemoryPermission; 407 using Kernel::MemoryPermission;
@@ -424,7 +425,7 @@ void Init() {
424} 425}
425 426
426void Shutdown() { 427void Shutdown() {
427 shared_font.clear(); 428 shared_font = nullptr;
428 shared_font_mem = nullptr; 429 shared_font_mem = nullptr;
429 lock = nullptr; 430 lock = nullptr;
430 notification_event = nullptr; 431 notification_event = nullptr;