diff options
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/apt_u.cpp | 8 | ||||
-rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 16 | ||||
-rw-r--r-- | src/core/hle/service/hid/hid.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/service/hid/hid.h | 6 | ||||
-rw-r--r-- | src/core/hle/service/hid/hid_user.cpp | 4 |
5 files changed, 24 insertions, 16 deletions
diff --git a/src/core/hle/service/apt_u.cpp b/src/core/hle/service/apt_u.cpp index 001b0d183..1f6b148e8 100644 --- a/src/core/hle/service/apt_u.cpp +++ b/src/core/hle/service/apt_u.cpp @@ -26,7 +26,7 @@ namespace APT_U { static const VAddr SHARED_FONT_VADDR = 0x18000000; /// Handle to shared memory region designated to for shared system font -static Handle shared_font_mem = 0; +static Kernel::SharedPtr<Kernel::SharedMemory> shared_font_mem; static Handle lock_handle = 0; static Handle notification_event_handle = 0; ///< APT notification event handle @@ -354,7 +354,7 @@ void GetSharedFont(Service::Interface* self) { cmd_buff[0] = 0x00440082; cmd_buff[1] = RESULT_SUCCESS.raw; // No error cmd_buff[2] = SHARED_FONT_VADDR; - cmd_buff[4] = shared_font_mem; + cmd_buff[4] = Kernel::g_handle_table.Create(shared_font_mem).MoveFrom(); } else { cmd_buff[1] = -1; // Generic error (not really possible to verify this on hardware) LOG_ERROR(Kernel_SVC, "called, but %s has not been loaded!", SHARED_FONT); @@ -514,10 +514,10 @@ Interface::Interface() { file.ReadBytes(shared_font.data(), (size_t)file.GetSize()); // Create shared font memory object - shared_font_mem = Kernel::CreateSharedMemory("APT_U:shared_font_mem"); + shared_font_mem = Kernel::SharedMemory::Create("APT_U:shared_font_mem").MoveFrom(); } else { LOG_WARNING(Service_APT, "Unable to load shared font: %s", filepath.c_str()); - shared_font_mem = 0; + shared_font_mem = nullptr; } lock_handle = 0; diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 4ca2b9bd0..1be2438c8 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -23,12 +23,12 @@ GraphicsDebugger g_debugger; namespace GSP_GPU { Handle g_interrupt_event = 0; ///< Handle to event triggered when GSP interrupt has been signalled -Handle g_shared_memory = 0; ///< Handle to GSP shared memorys +Kernel::SharedPtr<Kernel::SharedMemory> g_shared_memory; ///< GSP shared memoryings u32 g_thread_id = 1; ///< Thread index into interrupt relay queue, 1 is arbitrary /// Gets a pointer to a thread command buffer in GSP shared memory static inline u8* GetCommandBuffer(u32 thread_id) { - ResultVal<u8*> ptr = Kernel::GetSharedMemoryPointer(g_shared_memory, 0x800 + (thread_id * sizeof(CommandBuffer))); + ResultVal<u8*> ptr = g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); return ptr.ValueOr(nullptr); } @@ -37,13 +37,13 @@ static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_in // For each thread there are two FrameBufferUpdate fields u32 offset = 0x200 + (2 * thread_id + screen_index) * sizeof(FrameBufferUpdate); - ResultVal<u8*> ptr = Kernel::GetSharedMemoryPointer(g_shared_memory, offset); + ResultVal<u8*> ptr = g_shared_memory->GetPointer(offset); return reinterpret_cast<FrameBufferUpdate*>(ptr.ValueOr(nullptr)); } /// Gets a pointer to the interrupt relay queue for a given thread index static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) { - ResultVal<u8*> ptr = Kernel::GetSharedMemoryPointer(g_shared_memory, sizeof(InterruptRelayQueue) * thread_id); + ResultVal<u8*> ptr = g_shared_memory->GetPointer(sizeof(InterruptRelayQueue) * thread_id); return reinterpret_cast<InterruptRelayQueue*>(ptr.ValueOr(nullptr)); } @@ -182,13 +182,15 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); u32 flags = cmd_buff[1]; g_interrupt_event = cmd_buff[3]; - g_shared_memory = Kernel::CreateSharedMemory("GSPSharedMem"); + g_shared_memory = Kernel::SharedMemory::Create("GSPSharedMem").MoveFrom(); _assert_msg_(GSP, (g_interrupt_event != 0), "handle is not valid!"); + Handle shmem_handle = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom(); + cmd_buff[1] = 0x2A07; // Value verified by 3dmoo team, purpose unknown, but needed for GSP init cmd_buff[2] = g_thread_id++; // Thread ID - cmd_buff[4] = g_shared_memory; // GSP shared memory + cmd_buff[4] = shmem_handle; // GSP shared memory Kernel::SignalEvent(g_interrupt_event); // TODO(bunnei): Is this correct? } @@ -204,7 +206,7 @@ void SignalInterrupt(InterruptId interrupt_id) { LOG_WARNING(Service_GSP, "cannot synchronize until GSP event has been created!"); return; } - if (0 == g_shared_memory) { + if (nullptr == g_shared_memory) { LOG_WARNING(Service_GSP, "cannot synchronize until GSP shared memory has been created!"); return; } diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 5abcb2596..ee2ba7e01 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -12,7 +12,7 @@ namespace Service { namespace HID { -Handle g_shared_mem = 0; +Kernel::SharedPtr<Kernel::SharedMemory> g_shared_mem = nullptr; Handle g_event_pad_or_touch_1 = 0; Handle g_event_pad_or_touch_2 = 0; @@ -30,7 +30,7 @@ static s16 next_circle_y = 0; * Gets a pointer to the PadData structure inside HID shared memory */ static inline PadData* GetPadData() { - return reinterpret_cast<PadData*>(Kernel::GetSharedMemoryPointer(g_shared_mem, 0).ValueOr(nullptr)); + return reinterpret_cast<PadData*>(g_shared_mem->GetPointer().ValueOr(nullptr)); } /** @@ -120,7 +120,7 @@ void PadUpdateComplete() { } void HIDInit() { - g_shared_mem = Kernel::CreateSharedMemory("HID:SharedMem"); // Create shared memory object + g_shared_mem = Kernel::SharedMemory::Create("HID:SharedMem").MoveFrom(); // Create event handles g_event_pad_or_touch_1 = Kernel::CreateEvent(RESETTYPE_ONESHOT, "HID:EventPadOrTouch1"); diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 73cdaa527..5e6236647 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -9,11 +9,15 @@ #include "core/hle/kernel/kernel.h" #include "common/bit_field.h" +namespace Kernel { + class SharedMemory; +} + namespace Service { namespace HID { // Handle to shared memory region designated to HID_User service -extern Handle g_shared_mem; +extern Kernel::SharedPtr<Kernel::SharedMemory> g_shared_mem; // Event handles extern Handle g_event_pad_or_touch_1; diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp index 3a6275707..c167927ea 100644 --- a/src/core/hle/service/hid/hid_user.cpp +++ b/src/core/hle/service/hid/hid_user.cpp @@ -5,6 +5,7 @@ #include "common/log.h" #include "core/hle/hle.h" +#include "core/hle/kernel/shared_memory.h" #include "core/hle/service/hid/hid.h" #include "hid_user.h" @@ -46,7 +47,8 @@ void GetIPCHandles(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = 0; // No error - cmd_buff[3] = Service::HID::g_shared_mem; + // TODO(yuriks): Return error from SendSyncRequest is this fails (part of IPC marshalling) + cmd_buff[3] = Kernel::g_handle_table.Create(Service::HID::g_shared_mem).MoveFrom(); cmd_buff[4] = Service::HID::g_event_pad_or_touch_1; cmd_buff[5] = Service::HID::g_event_pad_or_touch_2; cmd_buff[6] = Service::HID::g_event_accelerometer; |