diff options
| -rw-r--r-- | src/core/hle/applets/applet.cpp | 38 | ||||
| -rw-r--r-- | src/core/hle/applets/applet.h | 43 | ||||
| -rw-r--r-- | src/core/hle/applets/swkbd.cpp | 45 | ||||
| -rw-r--r-- | src/core/hle/applets/swkbd.h | 16 | ||||
| -rw-r--r-- | src/core/hle/service/apt/apt.cpp | 45 | ||||
| -rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/gsp_gpu.h | 10 |
7 files changed, 162 insertions, 39 deletions
diff --git a/src/core/hle/applets/applet.cpp b/src/core/hle/applets/applet.cpp index 1f447e5fc..689f5adc8 100644 --- a/src/core/hle/applets/applet.cpp +++ b/src/core/hle/applets/applet.cpp | |||
| @@ -5,15 +5,35 @@ | |||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | 7 | ||
| 8 | #include "core/core_timing.h" | ||
| 8 | #include "core/hle/applets/applet.h" | 9 | #include "core/hle/applets/applet.h" |
| 9 | #include "core/hle/applets/swkbd.h" | 10 | #include "core/hle/applets/swkbd.h" |
| 10 | 11 | ||
| 11 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 12 | 13 | ||
| 14 | // Specializes std::hash for AppletId, so that we can use it in std::unordered_map. | ||
| 15 | // Workaround for libstdc++ bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60970 | ||
| 16 | namespace std { | ||
| 17 | template <> | ||
| 18 | struct hash<Service::APT::AppletId> { | ||
| 19 | typedef Service::APT::AppletId argument_type; | ||
| 20 | typedef std::size_t result_type; | ||
| 21 | |||
| 22 | result_type operator()(const argument_type& id_code) const { | ||
| 23 | typedef std::underlying_type<argument_type>::type Type; | ||
| 24 | return std::hash<Type>()(static_cast<Type>(id_code)); | ||
| 25 | } | ||
| 26 | }; | ||
| 27 | } | ||
| 28 | |||
| 13 | namespace HLE { | 29 | namespace HLE { |
| 14 | namespace Applets { | 30 | namespace Applets { |
| 15 | 31 | ||
| 16 | static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets; | 32 | static std::unordered_map<Service::APT::AppletId, std::shared_ptr<Applet>> applets; |
| 33 | static u32 applet_update_event = -1; ///< The CoreTiming event identifier for the Applet update callback. | ||
| 34 | /// The interval at which the Applet update callback will be called. | ||
| 35 | static const u64 applet_update_interval_microseconds = 16666; | ||
| 36 | std::shared_ptr<Applet> g_current_applet = nullptr; ///< The applet that is currently executing | ||
| 17 | 37 | ||
| 18 | ResultCode Applet::Create(Service::APT::AppletId id) { | 38 | ResultCode Applet::Create(Service::APT::AppletId id) { |
| 19 | switch (id) { | 39 | switch (id) { |
| @@ -36,5 +56,23 @@ std::shared_ptr<Applet> Applet::Get(Service::APT::AppletId id) { | |||
| 36 | return nullptr; | 56 | return nullptr; |
| 37 | } | 57 | } |
| 38 | 58 | ||
| 59 | /// Handles updating the current Applet every time it's called. | ||
| 60 | static void AppletUpdateEvent(u64, int cycles_late) { | ||
| 61 | if (g_current_applet && g_current_applet->IsRunning()) | ||
| 62 | g_current_applet->Update(); | ||
| 63 | |||
| 64 | CoreTiming::ScheduleEvent(usToCycles(applet_update_interval) - cycles_late, | ||
| 65 | applet_update_event); | ||
| 66 | } | ||
| 67 | |||
| 68 | void Init() { | ||
| 69 | applet_update_event = CoreTiming::RegisterEvent("HLE Applet Update Event", AppletUpdateEvent); | ||
| 70 | CoreTiming::ScheduleEvent(usToCycles(applet_update_interval), applet_update_event); | ||
| 71 | } | ||
| 72 | |||
| 73 | void Shutdown() { | ||
| 74 | CoreTiming::UnscheduleEvent(applet_update_event, 0); | ||
| 75 | } | ||
| 76 | |||
| 39 | } | 77 | } |
| 40 | } // namespace | 78 | } // namespace |
diff --git a/src/core/hle/applets/applet.h b/src/core/hle/applets/applet.h index 221348d9c..f50f7d604 100644 --- a/src/core/hle/applets/applet.h +++ b/src/core/hle/applets/applet.h | |||
| @@ -12,42 +12,59 @@ | |||
| 12 | namespace HLE { | 12 | namespace HLE { |
| 13 | namespace Applets { | 13 | namespace Applets { |
| 14 | 14 | ||
| 15 | class Applet { | 15 | class Applet : public std::enable_shared_from_this<Applet> { |
| 16 | public: | 16 | public: |
| 17 | virtual ~Applet() {}; | 17 | virtual ~Applet() {}; |
| 18 | Applet(Service::APT::AppletId id) : id(id) {}; | 18 | Applet(Service::APT::AppletId id) : id(id) {}; |
| 19 | 19 | ||
| 20 | /** | 20 | /** |
| 21 | * Creates an instance of the Applet subclass identified by the parameter | 21 | * Creates an instance of the Applet subclass identified by the parameter. |
| 22 | * and stores it in a global map. | 22 | * and stores it in a global map. |
| 23 | * @param id Id of the applet to create | 23 | * @param id Id of the applet to create. |
| 24 | * @returns ResultCode Whether the operation was successful or not | 24 | * @returns ResultCode Whether the operation was successful or not. |
| 25 | */ | 25 | */ |
| 26 | static ResultCode Create(Service::APT::AppletId id); | 26 | static ResultCode Create(Service::APT::AppletId id); |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | * Retrieves the Applet instance identified by the specified id | 29 | * Retrieves the Applet instance identified by the specified id. |
| 30 | * @param id Id of the Applet to retrieve | 30 | * @param id Id of the Applet to retrieve. |
| 31 | * @returns Requested Applet or nullptr if not found | 31 | * @returns Requested Applet or nullptr if not found. |
| 32 | */ | 32 | */ |
| 33 | static std::shared_ptr<Applet> Get(Service::APT::AppletId id); | 33 | static std::shared_ptr<Applet> Get(Service::APT::AppletId id); |
| 34 | 34 | ||
| 35 | /** | 35 | /** |
| 36 | * Handles a parameter from the application | 36 | * Handles a parameter from the application. |
| 37 | * @param parameter Parameter data to handle | 37 | * @param parameter Parameter data to handle. |
| 38 | * @returns ResultCode Whether the operation was successful or not | 38 | * @returns ResultCode Whether the operation was successful or not. |
| 39 | */ | 39 | */ |
| 40 | virtual ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) = 0; | 40 | virtual ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) = 0; |
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | * Handles the Applet start event, triggered from the application | 43 | * Handles the Applet start event, triggered from the application. |
| 44 | * @param parameter Parameter data to handle | 44 | * @param parameter Parameter data to handle. |
| 45 | * @returns ResultCode Whether the operation was successful or not | 45 | * @returns ResultCode Whether the operation was successful or not. |
| 46 | */ | 46 | */ |
| 47 | virtual ResultCode Start(Service::APT::AppletStartupParameter const& parameter) = 0; | 47 | virtual ResultCode Start(Service::APT::AppletStartupParameter const& parameter) = 0; |
| 48 | 48 | ||
| 49 | /** | ||
| 50 | * Whether the applet is currently executing instead of the host application or not. | ||
| 51 | */ | ||
| 52 | virtual bool IsRunning() = 0; | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Handles an update tick for the Applet, lets it update the screen, send commands, etc. | ||
| 56 | */ | ||
| 57 | virtual void Update() = 0; | ||
| 58 | |||
| 49 | Service::APT::AppletId id; ///< Id of this Applet | 59 | Service::APT::AppletId id; ///< Id of this Applet |
| 50 | }; | 60 | }; |
| 51 | 61 | ||
| 62 | /// Initializes the HLE applets | ||
| 63 | void Init(); | ||
| 64 | |||
| 65 | /// Shuts down the HLE applets | ||
| 66 | void Shutdown(); | ||
| 67 | |||
| 68 | extern std::shared_ptr<Applet> g_current_applet; ///< Applet that is currently executing | ||
| 52 | } | 69 | } |
| 53 | } // namespace | 70 | } // namespace |
diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 224aeb096..b800e0eb4 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp | |||
| @@ -6,13 +6,16 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | 7 | ||
| 8 | #include "core/hle/applets/swkbd.h" | 8 | #include "core/hle/applets/swkbd.h" |
| 9 | #include "core/hle/service/hid/hid.h" | ||
| 10 | #include "core/hle/service/gsp_gpu.h" | ||
| 11 | #include "video_core/video_core.h" | ||
| 9 | 12 | ||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 11 | 14 | ||
| 12 | namespace HLE { | 15 | namespace HLE { |
| 13 | namespace Applets { | 16 | namespace Applets { |
| 14 | 17 | ||
| 15 | SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id) { | 18 | SoftwareKeyboard::SoftwareKeyboard(Service::APT::AppletId id) : Applet(id), started(false) { |
| 16 | // Create the SharedMemory that will hold the framebuffer data | 19 | // Create the SharedMemory that will hold the framebuffer data |
| 17 | // TODO(Subv): What size should we use here? | 20 | // TODO(Subv): What size should we use here? |
| 18 | using Kernel::MemoryPermission; | 21 | using Kernel::MemoryPermission; |
| @@ -47,17 +50,45 @@ ResultCode SoftwareKeyboard::Start(Service::APT::AppletStartupParameter const& p | |||
| 47 | // TODO(Subv): Verify if this is the correct behavior | 50 | // TODO(Subv): Verify if this is the correct behavior |
| 48 | memset(text_memory->GetPointer(), 0, text_memory->size); | 51 | memset(text_memory->GetPointer(), 0, text_memory->size); |
| 49 | 52 | ||
| 53 | DrawScreenKeyboard(); | ||
| 54 | |||
| 55 | // Update the current applet so we can get update events | ||
| 56 | started = true; | ||
| 57 | g_current_applet = shared_from_this(); | ||
| 58 | return RESULT_SUCCESS; | ||
| 59 | } | ||
| 60 | |||
| 61 | void SoftwareKeyboard::Update() { | ||
| 62 | // TODO(Subv): Handle input using the touch events from the HID module | ||
| 63 | |||
| 50 | // TODO(Subv): Remove this hardcoded text | 64 | // TODO(Subv): Remove this hardcoded text |
| 51 | const wchar_t str[] = L"Subv"; | 65 | std::u16string text = Common::UTF8ToUTF16("Citra"); |
| 52 | memcpy(text_memory->GetPointer(), str, 4 * sizeof(wchar_t)); | 66 | memcpy(text_memory->GetPointer(), text.c_str(), text.length() * sizeof(char16_t)); |
| 53 | 67 | ||
| 54 | // TODO(Subv): Ask for input and write it to the shared memory | 68 | // TODO(Subv): Ask for input and write it to the shared memory |
| 55 | // TODO(Subv): Find out what are the possible values for the return code, | 69 | // TODO(Subv): Find out what are the possible values for the return code, |
| 56 | // some games seem to check for a hardcoded 2 | 70 | // some games seem to check for a hardcoded 2 |
| 57 | config.return_code = 2; | 71 | config.return_code = 2; |
| 58 | config.text_length = 5; | 72 | config.text_length = 6; |
| 59 | config.text_offset = 0; | 73 | config.text_offset = 0; |
| 60 | 74 | ||
| 75 | // TODO(Subv): We're finalizing the applet immediately after it's started, | ||
| 76 | // but we should defer this call until after all the input has been collected. | ||
| 77 | Finalize(); | ||
| 78 | } | ||
| 79 | |||
| 80 | void SoftwareKeyboard::DrawScreenKeyboard() { | ||
| 81 | auto bottom_screen = GSP_GPU::GetFrameBufferInfo(0, 1); | ||
| 82 | auto info = bottom_screen->framebuffer_info[bottom_screen->index]; | ||
| 83 | |||
| 84 | // TODO(Subv): Draw the HLE keyboard, for now just zero-fill the framebuffer | ||
| 85 | memset(Memory::GetPointer(info.address_left), 0, info.stride * 320); | ||
| 86 | |||
| 87 | GSP_GPU::SetBufferSwap(1, info); | ||
| 88 | } | ||
| 89 | |||
| 90 | void SoftwareKeyboard::Finalize() { | ||
| 91 | // Let the application know that we're closing | ||
| 61 | Service::APT::MessageParameter message; | 92 | Service::APT::MessageParameter message; |
| 62 | message.buffer_size = sizeof(SoftwareKeyboardConfig); | 93 | message.buffer_size = sizeof(SoftwareKeyboardConfig); |
| 63 | message.data = reinterpret_cast<u8*>(&config); | 94 | message.data = reinterpret_cast<u8*>(&config); |
| @@ -66,7 +97,9 @@ ResultCode SoftwareKeyboard::Start(Service::APT::AppletStartupParameter const& p | |||
| 66 | message.sender_id = static_cast<u32>(id); | 97 | message.sender_id = static_cast<u32>(id); |
| 67 | Service::APT::SendParameter(message); | 98 | Service::APT::SendParameter(message); |
| 68 | 99 | ||
| 69 | return RESULT_SUCCESS; | 100 | started = false; |
| 101 | // Unset the current applet, we are not running anymore | ||
| 102 | g_current_applet = nullptr; | ||
| 70 | } | 103 | } |
| 71 | 104 | ||
| 72 | } | 105 | } |
diff --git a/src/core/hle/applets/swkbd.h b/src/core/hle/applets/swkbd.h index d7199690c..5970390c6 100644 --- a/src/core/hle/applets/swkbd.h +++ b/src/core/hle/applets/swkbd.h | |||
| @@ -51,6 +51,19 @@ public: | |||
| 51 | 51 | ||
| 52 | ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) override; | 52 | ResultCode ReceiveParameter(Service::APT::MessageParameter const& parameter) override; |
| 53 | ResultCode Start(Service::APT::AppletStartupParameter const& parameter) override; | 53 | ResultCode Start(Service::APT::AppletStartupParameter const& parameter) override; |
| 54 | void Update() override; | ||
| 55 | bool IsRunning() override { return started; } | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Draws a keyboard to the current bottom screen framebuffer. | ||
| 59 | */ | ||
| 60 | void DrawScreenKeyboard(); | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Sends the LibAppletClosing signal to the application, | ||
| 64 | * along with the relevant data buffers. | ||
| 65 | */ | ||
| 66 | void Finalize(); | ||
| 54 | 67 | ||
| 55 | /// TODO(Subv): Find out what this is actually used for. | 68 | /// TODO(Subv): Find out what this is actually used for. |
| 56 | // It is believed that the application stores the current screen image here. | 69 | // It is believed that the application stores the current screen image here. |
| @@ -61,6 +74,9 @@ public: | |||
| 61 | 74 | ||
| 62 | /// Configuration of this instance of the SoftwareKeyboard, as received from the application | 75 | /// Configuration of this instance of the SoftwareKeyboard, as received from the application |
| 63 | SoftwareKeyboardConfig config; | 76 | SoftwareKeyboardConfig config; |
| 77 | |||
| 78 | /// Whether this applet is currently running instead of the host application or not. | ||
| 79 | bool started; | ||
| 64 | }; | 80 | }; |
| 65 | 81 | ||
| 66 | } | 82 | } |
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 0c3889e83..783fad7ca 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp | |||
| @@ -68,7 +68,7 @@ void Initialize(Service::Interface* self) { | |||
| 68 | 68 | ||
| 69 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 69 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 70 | 70 | ||
| 71 | LOG_WARNING(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags); | 71 | LOG_DEBUG(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | void GetSharedFont(Service::Interface* self) { | 74 | void GetSharedFont(Service::Interface* self) { |
| @@ -95,7 +95,6 @@ void GetSharedFont(Service::Interface* self) { | |||
| 95 | void NotifyToWait(Service::Interface* self) { | 95 | void NotifyToWait(Service::Interface* self) { |
| 96 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 96 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 97 | u32 app_id = cmd_buff[1]; | 97 | u32 app_id = cmd_buff[1]; |
| 98 | |||
| 99 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 98 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 100 | LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id); | 99 | LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id); |
| 101 | } | 100 | } |
| @@ -108,7 +107,7 @@ void GetLockHandle(Service::Interface* self) { | |||
| 108 | 107 | ||
| 109 | // Not sure what these parameters are used for, but retail apps check that they are 0 after | 108 | // Not sure what these parameters are used for, but retail apps check that they are 0 after |
| 110 | // GetLockHandle has been called. | 109 | // GetLockHandle has been called. |
| 111 | cmd_buff[2] = 0; | 110 | cmd_buff[2] = 0; // Applet Attributes, this value is passed to Enable. |
| 112 | cmd_buff[3] = 0; | 111 | cmd_buff[3] = 0; |
| 113 | cmd_buff[4] = 0; | 112 | cmd_buff[4] = 0; |
| 114 | 113 | ||
| @@ -118,10 +117,10 @@ void GetLockHandle(Service::Interface* self) { | |||
| 118 | 117 | ||
| 119 | void Enable(Service::Interface* self) { | 118 | void Enable(Service::Interface* self) { |
| 120 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 119 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 121 | u32 unk = cmd_buff[1]; // TODO(bunnei): What is this field used for? | 120 | u32 attributes = cmd_buff[1]; |
| 122 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 121 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 123 | parameter_event->Signal(); // Let the application know that it has been started | 122 | parameter_event->Signal(); // Let the application know that it has been started |
| 124 | LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X", unk); | 123 | LOG_WARNING(Service_APT, "(STUBBED) called attributes=0x%08X", attributes); |
| 125 | } | 124 | } |
| 126 | 125 | ||
| 127 | void GetAppletManInfo(Service::Interface* self) { | 126 | void GetAppletManInfo(Service::Interface* self) { |
| @@ -160,19 +159,20 @@ void InquireNotification(Service::Interface* self) { | |||
| 160 | 159 | ||
| 161 | void SendParameter(Service::Interface* self) { | 160 | void SendParameter(Service::Interface* self) { |
| 162 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 161 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 163 | u32 src_app_id = cmd_buff[1]; | 162 | u32 src_app_id = cmd_buff[1]; |
| 164 | u32 dst_app_id = cmd_buff[2]; | 163 | u32 dst_app_id = cmd_buff[2]; |
| 165 | u32 signal_type = cmd_buff[3]; | 164 | u32 signal_type = cmd_buff[3]; |
| 166 | u32 buffer_size = cmd_buff[4]; | 165 | u32 buffer_size = cmd_buff[4]; |
| 167 | u32 value = cmd_buff[5]; | 166 | u32 value = cmd_buff[5]; |
| 168 | u32 handle = cmd_buff[6]; | 167 | u32 handle = cmd_buff[6]; |
| 169 | u32 size = cmd_buff[7]; | 168 | u32 size = cmd_buff[7]; |
| 170 | u32 buffer = cmd_buff[8]; | 169 | u32 buffer = cmd_buff[8]; |
| 171 | 170 | ||
| 172 | std::shared_ptr<HLE::Applets::Applet> dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id)); | 171 | std::shared_ptr<HLE::Applets::Applet> dest_applet = HLE::Applets::Applet::Get(static_cast<AppletId>(dst_app_id)); |
| 173 | 172 | ||
| 174 | if (dest_applet == nullptr) { | 173 | if (dest_applet == nullptr) { |
| 175 | LOG_ERROR(Service_APT, "Unknown applet id=0x%08X", dst_app_id); | 174 | LOG_ERROR(Service_APT, "Unknown applet id=0x%08X", dst_app_id); |
| 175 | cmd_buff[1] = -1; // TODO(Subv): Find the right error code | ||
| 176 | return; | 176 | return; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| @@ -286,7 +286,7 @@ void AppletUtility(Service::Interface* self) { | |||
| 286 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 286 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 287 | 287 | ||
| 288 | // These are from 3dbrew - I'm not really sure what they're used for. | 288 | // These are from 3dbrew - I'm not really sure what they're used for. |
| 289 | u32 unk = cmd_buff[1]; | 289 | u32 command = cmd_buff[1]; |
| 290 | u32 buffer1_size = cmd_buff[2]; | 290 | u32 buffer1_size = cmd_buff[2]; |
| 291 | u32 buffer2_size = cmd_buff[3]; | 291 | u32 buffer2_size = cmd_buff[3]; |
| 292 | u32 buffer1_addr = cmd_buff[5]; | 292 | u32 buffer1_addr = cmd_buff[5]; |
| @@ -294,8 +294,8 @@ void AppletUtility(Service::Interface* self) { | |||
| 294 | 294 | ||
| 295 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error | 295 | cmd_buff[1] = RESULT_SUCCESS.raw; // No error |
| 296 | 296 | ||
| 297 | LOG_WARNING(Service_APT, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " | 297 | LOG_WARNING(Service_APT, "(STUBBED) called command=0x%08X, buffer1_size=0x%08X, buffer2_size=0x%08X, " |
| 298 | "buffer1_addr=0x%08X, buffer2_addr=0x%08X", unk, buffer1_size, buffer2_size, | 298 | "buffer1_addr=0x%08X, buffer2_addr=0x%08X", command, buffer1_size, buffer2_size, |
| 299 | buffer1_addr, buffer2_addr); | 299 | buffer1_addr, buffer2_addr); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| @@ -329,14 +329,20 @@ void GetAppCpuTimeLimit(Service::Interface* self) { | |||
| 329 | 329 | ||
| 330 | void PrepareToStartLibraryApplet(Service::Interface* self) { | 330 | void PrepareToStartLibraryApplet(Service::Interface* self) { |
| 331 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 331 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 332 | cmd_buff[1] = HLE::Applets::Applet::Create(static_cast<AppletId>(cmd_buff[1])).raw; | 332 | AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); |
| 333 | cmd_buff[1] = HLE::Applets::Applet::Create(applet_id).raw; | ||
| 334 | LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); | ||
| 333 | } | 335 | } |
| 334 | 336 | ||
| 335 | void StartLibraryApplet(Service::Interface* self) { | 337 | void StartLibraryApplet(Service::Interface* self) { |
| 336 | u32* cmd_buff = Kernel::GetCommandBuffer(); | 338 | u32* cmd_buff = Kernel::GetCommandBuffer(); |
| 337 | std::shared_ptr<HLE::Applets::Applet> applet = HLE::Applets::Applet::Get(static_cast<AppletId>(cmd_buff[1])); | 339 | AppletId applet_id = static_cast<AppletId>(cmd_buff[1]); |
| 340 | std::shared_ptr<HLE::Applets::Applet> applet = HLE::Applets::Applet::Get(applet_id); | ||
| 338 | 341 | ||
| 342 | LOG_DEBUG(Service_APT, "called applet_id=%08X", applet_id); | ||
| 343 | |||
| 339 | if (applet == nullptr) { | 344 | if (applet == nullptr) { |
| 345 | LOG_ERROR(Service_APT, "unknown applet id=%08X", applet_id); | ||
| 340 | cmd_buff[1] = -1; // TODO(Subv): Find the right error code | 346 | cmd_buff[1] = -1; // TODO(Subv): Find the right error code |
| 341 | return; | 347 | return; |
| 342 | } | 348 | } |
| @@ -354,6 +360,8 @@ void Init() { | |||
| 354 | AddService(new APT_S_Interface); | 360 | AddService(new APT_S_Interface); |
| 355 | AddService(new APT_U_Interface); | 361 | AddService(new APT_U_Interface); |
| 356 | 362 | ||
| 363 | HLE::Applets::Init(); | ||
| 364 | |||
| 357 | // Load the shared system font (if available). | 365 | // Load the shared system font (if available). |
| 358 | // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header | 366 | // The expected format is a decrypted, uncompressed BCFNT file with the 0x80 byte header |
| 359 | // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided | 367 | // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided |
| @@ -398,6 +406,7 @@ void Shutdown() { | |||
| 398 | lock = nullptr; | 406 | lock = nullptr; |
| 399 | notification_event = nullptr; | 407 | notification_event = nullptr; |
| 400 | parameter_event = nullptr; | 408 | parameter_event = nullptr; |
| 409 | HLE::Applets::Shutdown(); | ||
| 401 | } | 410 | } |
| 402 | 411 | ||
| 403 | } // namespace APT | 412 | } // namespace APT |
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index f56bbe50f..f175085e8 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp | |||
| @@ -42,7 +42,7 @@ static inline u8* GetCommandBuffer(u32 thread_id) { | |||
| 42 | return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); | 42 | return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { | 45 | FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { |
| 46 | DEBUG_ASSERT_MSG(screen_index < 2, "Invalid screen index"); | 46 | DEBUG_ASSERT_MSG(screen_index < 2, "Invalid screen index"); |
| 47 | 47 | ||
| 48 | // For each thread there are two FrameBufferUpdate fields | 48 | // For each thread there are two FrameBufferUpdate fields |
| @@ -205,7 +205,7 @@ static void ReadHWRegs(Service::Interface* self) { | |||
| 205 | } | 205 | } |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { | 208 | void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { |
| 209 | u32 base_address = 0x400000; | 209 | u32 base_address = 0x400000; |
| 210 | PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); | 210 | PAddr phys_address_left = Memory::VirtualToPhysicalAddress(info.address_left); |
| 211 | PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); | 211 | PAddr phys_address_right = Memory::VirtualToPhysicalAddress(info.address_right); |
diff --git a/src/core/hle/service/gsp_gpu.h b/src/core/hle/service/gsp_gpu.h index d9e9a1a60..9fcf6f06f 100644 --- a/src/core/hle/service/gsp_gpu.h +++ b/src/core/hle/service/gsp_gpu.h | |||
| @@ -173,4 +173,14 @@ public: | |||
| 173 | */ | 173 | */ |
| 174 | void SignalInterrupt(InterruptId interrupt_id); | 174 | void SignalInterrupt(InterruptId interrupt_id); |
| 175 | 175 | ||
| 176 | void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info); | ||
| 177 | |||
| 178 | /** | ||
| 179 | * Retrieves the framebuffer info stored in the GSP shared memory for the | ||
| 180 | * specified screen index and thread id. | ||
| 181 | * @param thread_id GSP thread id of the process that accesses the structure that we are requesting. | ||
| 182 | * @param screen_index Index of the screen we are requesting (Top = 0, Bottom = 1). | ||
| 183 | * @returns FramebufferUpdate Information about the specified framebuffer. | ||
| 184 | */ | ||
| 185 | FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index); | ||
| 176 | } // namespace | 186 | } // namespace |