diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d29183899..c6b32da93 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -37,6 +37,7 @@ set(SRCS core.cpp hle/kernel/kernel.cpp hle/kernel/mutex.cpp hle/kernel/thread.cpp + hle/kernel/shared_memory.cpp hle/service/apt.cpp hle/service/gsp.cpp hle/service/hid.cpp @@ -82,6 +83,7 @@ set(HEADERS core.h hle/svc.h hle/kernel/kernel.h hle/kernel/mutex.h + hle/kernel/shared_memory.h hle/kernel/thread.h hle/function_wrappers.h hle/service/apt.h diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index 621aa60b8..2989d001a 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -180,6 +180,7 @@ + @@ -230,6 +231,7 @@ + diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index 3cf702d44..bd86cc332 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -168,6 +168,9 @@ hw + + hle\kernel + @@ -301,6 +304,9 @@ hw + + hle\kernel + diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 7cd79c2c4..3c9a40286 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -94,6 +94,7 @@ public: template T *GetFast(Handle handle) { const Handle realHandle = handle - HANDLE_OFFSET; + //bravia note: there is a weird bug caused here which puts the processor into thumb mode _dbg_assert_(KERNEL, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); return static_cast(pool[realHandle]); } diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp new file mode 100644 index 000000000..dc9c66ea1 --- /dev/null +++ b/src/core/hle/kernel/shared_memory.cpp @@ -0,0 +1,48 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include + +#include "common/common.h" + +#include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/thread.h" + +namespace Kernel { + +class SharedMemory : public Object { +public: + const char* GetTypeName() { return "SharedMemory"; } + + static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::SharedMemory; } + Kernel::HandleType GetHandleType() const { return Kernel::HandleType::SharedMemory; } + + //TODO: implement +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + + + +/** +* Creates a mutex +* @param handle Reference to handle for the newly created mutex +* @param initial_locked Specifies if the mutex should be locked initially +*/ +SharedMemory* CreateSharedMemory(Handle& handle) { + SharedMemory* mem = new SharedMemory; + handle = Kernel::g_object_pool.Create(mem); + + return mem; +} + + +Handle CreateSharedMemory() { + Handle handle; + SharedMemory* mem = CreateSharedMemory(handle); + return handle; +} + +} // namespace diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h new file mode 100644 index 000000000..993e0a856 --- /dev/null +++ b/src/core/hle/kernel/shared_memory.h @@ -0,0 +1,20 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" + +#include "core/hle/kernel/kernel.h" + +namespace Kernel { + +/** +* Creates a shared memory object +* @param handle Reference to handle for the newly created mutex +* @param +*/ +Handle CreateSharedMemory(); + +} // namespace diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp index 50cee2c41..e59479f15 100644 --- a/src/core/hle/service/gsp.cpp +++ b/src/core/hle/service/gsp.cpp @@ -102,6 +102,7 @@ void RegisterInterruptRelayQueue(Service::Interface* self) { u32 flags = cmd_buff[1]; u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling cmd_buff[2] = g_thread_id; // ThreadID + //TODO(bravia): Implement shared memory handling } /// This triggers handling of the GX command written to the command buffer in shared memory. diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp index 5542e5bf2..4bada30b5 100644 --- a/src/core/hle/service/hid.cpp +++ b/src/core/hle/service/hid.cpp @@ -6,14 +6,21 @@ #include "core/hle/hle.h" #include "core/hle/service/hid.h" +#include "core/hle/kernel/shared_memory.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace HID_User namespace HID_User { +void GetIPCHandles(Service::Interface* self) { + u32* cmd_buff = Service::GetCommandBuffer(); + Handle memHandle = Kernel::CreateSharedMemory(); + cmd_buff[3] = memHandle; //TODO: return something coherent along with RegisterInterruptRelayQueue for mem handles +} + const Interface::FunctionInfo FunctionTable[] = { - {0x000A0000, NULL, "GetIPCHandles"}, + {0x000A0000, GetIPCHandles, "GetIPCHandles" }, {0x00110000, NULL, "EnableAccelerometer"}, {0x00130000, NULL, "EnableGyroscopeLow"}, {0x00150000, NULL, "GetGyroscopeLowRawToDpsCoefficient"}, diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 4cf2d96ad..c58ab594b 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -67,7 +67,7 @@ Result ControlMemory(void* _outaddr, u32 operation, u32 addr0, u32 addr1, u32 si /// Maps a memory block to specified address Result MapMemoryBlock(Handle memblock, u32 addr, u32 mypermissions, u32 otherpermission) { - DEBUG_LOG(SVC, "MapMemoryBlock called memblock=0x08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", + DEBUG_LOG(SVC, "MapMemoryBlock called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", memblock, addr, mypermissions, otherpermission); switch (mypermissions) { case MEMORY_PERMISSION_NORMAL: diff --git a/src/core/hw/hid.cpp b/src/core/hw/hid.cpp index a1b4b139c..8197b8394 100644 --- a/src/core/hw/hid.cpp +++ b/src/core/hw/hid.cpp @@ -1,6 +1,6 @@ #include "hid.h" - +//TODO: http://pastebin.com/kkGLQhHV namespace HID { template