From c96f22490a4a459d477f446fd4e5f894f580b69c Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 10 May 2015 19:47:07 -0300 Subject: Kernel: Capture SharedMemory attributes at creation, not when mapping --- src/core/hle/service/gsp_gpu.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/core/hle/service/gsp_gpu.cpp') diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 8da063bd2..e2b6b0b02 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -35,8 +35,7 @@ u32 g_thread_id = 1; /// Gets a pointer to a thread command buffer in GSP shared memory static inline u8* GetCommandBuffer(u32 thread_id) { - ResultVal ptr = g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); - return ptr.ValueOr(nullptr); + return g_shared_memory->GetPointer(0x800 + (thread_id * sizeof(CommandBuffer))); } static inline FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index) { @@ -44,14 +43,14 @@ 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 ptr = g_shared_memory->GetPointer(offset); - return reinterpret_cast(ptr.ValueOr(nullptr)); + u8* ptr = g_shared_memory->GetPointer(offset); + return reinterpret_cast(ptr); } /// Gets a pointer to the interrupt relay queue for a given thread index static inline InterruptRelayQueue* GetInterruptRelayQueue(u32 thread_id) { - ResultVal ptr = g_shared_memory->GetPointer(sizeof(InterruptRelayQueue) * thread_id); - return reinterpret_cast(ptr.ValueOr(nullptr)); + u8* ptr = g_shared_memory->GetPointer(sizeof(InterruptRelayQueue) * thread_id); + return reinterpret_cast(ptr); } /** @@ -288,7 +287,10 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) { g_interrupt_event = Kernel::g_handle_table.Get(cmd_buff[3]); ASSERT_MSG((g_interrupt_event != nullptr), "handle is not valid!"); - g_shared_memory = Kernel::SharedMemory::Create("GSPSharedMem"); + + using Kernel::MemoryPermission; + g_shared_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, + MemoryPermission::ReadWrite, "GSPSharedMem"); Handle shmem_handle = Kernel::g_handle_table.Create(g_shared_memory).MoveFrom(); -- cgit v1.2.3 From 1538a34eda324782bf88fa382201e1e5cf8a237c Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 10 May 2015 19:51:37 -0300 Subject: GSP: Small tweaks to shared memory initialization --- src/core/hle/service/gsp_gpu.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/core/hle/service/gsp_gpu.cpp') diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index e2b6b0b02..917f4685f 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -31,7 +31,7 @@ Kernel::SharedPtr g_interrupt_event; /// GSP shared memoryings Kernel::SharedPtr g_shared_memory; /// Thread index into interrupt relay queue, 1 is arbitrary -u32 g_thread_id = 1; +u32 g_thread_id = 0; /// Gets a pointer to a thread command buffer in GSP shared memory static inline u8* GetCommandBuffer(u32 thread_id) { @@ -277,7 +277,7 @@ static void FlushDataCache(Service::Interface* self) { * 1 : "Flags" field, purpose is unknown * 3 : Handle to GSP synchronization event * Outputs: - * 0 : Result of function, 0 on success, otherwise error code + * 1 : Result of function, 0x2A07 on success, otherwise error code * 2 : Thread index into GSP command buffer * 4 : Handle to GSP shared memory */ @@ -288,13 +288,11 @@ static void RegisterInterruptRelayQueue(Service::Interface* self) { g_interrupt_event = Kernel::g_handle_table.Get(cmd_buff[3]); ASSERT_MSG((g_interrupt_event != nullptr), "handle is not valid!"); - using Kernel::MemoryPermission; - g_shared_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, - MemoryPermission::ReadWrite, "GSPSharedMem"); - 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 + // This specific code is required for a successful initialization, rather than 0 + cmd_buff[1] = ResultCode((ErrorDescription)519, ErrorModule::GX, + ErrorSummary::Success, ErrorLevel::Success).raw; cmd_buff[2] = g_thread_id++; // Thread ID cmd_buff[4] = shmem_handle; // GSP shared memory @@ -529,8 +527,12 @@ Interface::Interface() { Register(FunctionTable); g_interrupt_event = 0; - g_shared_memory = 0; - g_thread_id = 1; + + using Kernel::MemoryPermission; + g_shared_memory = Kernel::SharedMemory::Create(0x1000, MemoryPermission::ReadWrite, + MemoryPermission::ReadWrite, "GSPSharedMem"); + + g_thread_id = 0; } } // namespace -- cgit v1.2.3 From fd85367621a1428552ed4d8f43605dd0d7b5f100 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 10 May 2015 20:09:41 -0300 Subject: fixup! GSP: Small tweaks to shared memory initialization --- src/core/hle/service/gsp_gpu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/hle/service/gsp_gpu.cpp') diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 917f4685f..c6252a03b 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp @@ -30,7 +30,7 @@ namespace GSP_GPU { Kernel::SharedPtr g_interrupt_event; /// GSP shared memoryings Kernel::SharedPtr g_shared_memory; -/// Thread index into interrupt relay queue, 1 is arbitrary +/// Thread index into interrupt relay queue u32 g_thread_id = 0; /// Gets a pointer to a thread command buffer in GSP shared memory -- cgit v1.2.3