From c43f1ed08866dab5bd2cdd27b12bb3a4f6678fcb Mon Sep 17 00:00:00 2001
From: NarcolepticK <NarcolepticKrias@gmail.com>
Date: Wed, 27 Jun 2018 03:44:09 -0400
Subject: [PATCH 1/3] service/gsp: Move service/gsp_lcd.* into service/gsp/
 folder

---
 src/core/CMakeLists.txt                    | 4 ++--
 src/core/hle/service/{ => gsp}/gsp_lcd.cpp | 2 +-
 src/core/hle/service/{ => gsp}/gsp_lcd.h   | 0
 src/core/hle/service/service.cpp           | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
 rename src/core/hle/service/{ => gsp}/gsp_lcd.cpp (94%)
 rename src/core/hle/service/{ => gsp}/gsp_lcd.h (100%)

diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index d5b78b29d..f16e3dcd7 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -242,8 +242,8 @@ add_library(core STATIC
     hle/service/gsp/gsp.h
     hle/service/gsp/gsp_gpu.cpp
     hle/service/gsp/gsp_gpu.h
-    hle/service/gsp_lcd.cpp
-    hle/service/gsp_lcd.h
+    hle/service/gsp/gsp_lcd.cpp
+    hle/service/gsp/gsp_lcd.h
     hle/service/hid/hid.cpp
     hle/service/hid/hid.h
     hle/service/hid/hid_spvr.cpp
diff --git a/src/core/hle/service/gsp_lcd.cpp b/src/core/hle/service/gsp/gsp_lcd.cpp
similarity index 94%
rename from src/core/hle/service/gsp_lcd.cpp
rename to src/core/hle/service/gsp/gsp_lcd.cpp
index 89cb4a3cc..cd0de1637 100644
--- a/src/core/hle/service/gsp_lcd.cpp
+++ b/src/core/hle/service/gsp/gsp_lcd.cpp
@@ -2,7 +2,7 @@
 // Licensed under GPLv2 or any later version
 // Refer to the license.txt file included.
 
-#include "core/hle/service/gsp_lcd.h"
+#include "core/hle/service/gsp/gsp_lcd.h"
 
 namespace Service {
 namespace GSP {
diff --git a/src/core/hle/service/gsp_lcd.h b/src/core/hle/service/gsp/gsp_lcd.h
similarity index 100%
rename from src/core/hle/service/gsp_lcd.h
rename to src/core/hle/service/gsp/gsp_lcd.h
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 7defd40b4..d0f28127d 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -30,7 +30,7 @@
 #include "core/hle/service/fs/archive.h"
 #include "core/hle/service/fs/fs_user.h"
 #include "core/hle/service/gsp/gsp.h"
-#include "core/hle/service/gsp_lcd.h"
+#include "core/hle/service/gsp/gsp_lcd.h"
 #include "core/hle/service/hid/hid.h"
 #include "core/hle/service/http_c.h"
 #include "core/hle/service/ir/ir.h"

From c6554f1fbc5fd58e64ff64f374c33cf4734343a1 Mon Sep 17 00:00:00 2001
From: NarcolepticK <NarcolepticKrias@gmail.com>
Date: Wed, 27 Jun 2018 04:01:35 -0400
Subject: [PATCH 2/3] service/gsp: Fixed typo in FlushDataCache
 IPC::RequestParser creation

---
 src/core/hle/service/gsp/gsp_gpu.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp
index 112a07195..d52339b7c 100644
--- a/src/core/hle/service/gsp/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp/gsp_gpu.cpp
@@ -309,7 +309,7 @@ void GSP_GPU::SetBufferSwap(Kernel::HLERequestContext& ctx) {
 }
 
 void GSP_GPU::FlushDataCache(Kernel::HLERequestContext& ctx) {
-    IPC::RequestParser rp(ctx, 0x9, 2, 2);
+    IPC::RequestParser rp(ctx, 0x8, 2, 2);
     u32 address = rp.Pop<u32>();
     u32 size = rp.Pop<u32>();
     auto process = rp.PopObject<Kernel::Process>();

From b94cb61de88f09f8629df913cd04d5c104041636 Mon Sep 17 00:00:00 2001
From: NarcolepticK <NarcolepticKrias@gmail.com>
Date: Wed, 27 Jun 2018 04:14:23 -0400
Subject: [PATCH 3/3] service/gsp: Add Stub for InvalidateDataCache

---
 src/core/hle/service/gsp/gsp_gpu.cpp | 17 ++++++++++++++++-
 src/core/hle/service/gsp/gsp_gpu.h   | 15 +++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp
index d52339b7c..73b4bc109 100644
--- a/src/core/hle/service/gsp/gsp_gpu.cpp
+++ b/src/core/hle/service/gsp/gsp_gpu.cpp
@@ -323,6 +323,21 @@ void GSP_GPU::FlushDataCache(Kernel::HLERequestContext& ctx) {
                 address, size, process->process_id);
 }
 
+void GSP_GPU::InvalidateDataCache(Kernel::HLERequestContext& ctx) {
+    IPC::RequestParser rp(ctx, 0x9, 2, 2);
+    u32 address = rp.Pop<u32>();
+    u32 size = rp.Pop<u32>();
+    auto process = rp.PopObject<Kernel::Process>();
+
+    // TODO(purpasmart96): Verify return header on HW
+
+    IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
+    rb.Push(RESULT_SUCCESS);
+
+    NGLOG_DEBUG(Service_GSP, "(STUBBED) called address=0x{:08X}, size=0x{:08X}, process={}",
+                address, size, process->process_id);
+}
+
 void GSP_GPU::SetAxiConfigQoSMode(Kernel::HLERequestContext& ctx) {
     IPC::RequestParser rp(ctx, 0x10, 1, 0);
     u32 mode = rp.Pop<u32>();
@@ -747,7 +762,7 @@ GSP_GPU::GSP_GPU() : ServiceFramework("gsp::Gpu", 2) {
         {0x00060082, nullptr, "SetCommandList"},
         {0x000700C2, nullptr, "RequestDma"},
         {0x00080082, &GSP_GPU::FlushDataCache, "FlushDataCache"},
-        {0x00090082, nullptr, "InvalidateDataCache"},
+        {0x00090082, &GSP_GPU::InvalidateDataCache, "InvalidateDataCache"},
         {0x000A0044, nullptr, "RegisterInterruptEvents"},
         {0x000B0040, &GSP_GPU::SetLcdForceBlack, "SetLcdForceBlack"},
         {0x000C0000, &GSP_GPU::TriggerCmdReqQueue, "TriggerCmdReqQueue"},
diff --git a/src/core/hle/service/gsp/gsp_gpu.h b/src/core/hle/service/gsp/gsp_gpu.h
index 484b1a332..01c747d41 100644
--- a/src/core/hle/service/gsp/gsp_gpu.h
+++ b/src/core/hle/service/gsp/gsp_gpu.h
@@ -279,6 +279,21 @@ private:
      */
     void FlushDataCache(Kernel::HLERequestContext& ctx);
 
+    /**
+     * GSP_GPU::InvalidateDataCache service function
+     *
+     * This Function is a no-op, We aren't emulating the CPU cache any time soon.
+     *
+     *  Inputs:
+     *      1 : Address
+     *      2 : Size
+     *      3 : Value 0, some descriptor for the KProcess Handle
+     *      4 : KProcess handle
+     *  Outputs:
+     *      1 : Result of function, 0 on success, otherwise error code
+     */
+    void InvalidateDataCache(Kernel::HLERequestContext& ctx);
+
     /**
      * GSP_GPU::SetLcdForceBlack service function
      *