From c180fd4003f78edadaa77818bf44ce8baf844968 Mon Sep 17 00:00:00 2001 From: inspuration Date: Wed, 11 Jun 2014 00:12:54 -0400 Subject: [PATCH] Fixed minor bug in sharedmem writing --- src/core/hle/service/hid.cpp | 6 +++++- src/core/hle/service/hid.h | 2 ++ src/core/hw/hid.cpp | 17 ++++------------- src/core/hw/hid.h | 8 +------- src/core/mem_map_funcs.cpp | 3 +-- 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/core/hle/service/hid.cpp b/src/core/hle/service/hid.cpp index fd2c6c80d..85a58563a 100644 --- a/src/core/hle/service/hid.cpp +++ b/src/core/hle/service/hid.cpp @@ -15,10 +15,14 @@ namespace HID_User { Handle memIPC; +Handle getMemIPCHandle() { + return memIPC; +} + void GetIPCHandles(Service::Interface* self) { u32* cmd_buff = Service::GetCommandBuffer(); memIPC = Kernel::CreateSharedMemory(0x1000); //page size for now - cmd_buff[3] = memIPC; //TODO: return something coherent along with RegisterInterruptRelayQueue for mem handles + cmd_buff[3] = memIPC; } const Interface::FunctionInfo FunctionTable[] = { diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h index 81c29eb2e..76e609479 100644 --- a/src/core/hle/service/hid.h +++ b/src/core/hle/service/hid.h @@ -14,6 +14,8 @@ namespace HID_User { +Handle getMemIPCHandle(); + class Interface : public Service::Interface { public: diff --git a/src/core/hw/hid.cpp b/src/core/hw/hid.cpp index 8197b8394..f904a7e44 100644 --- a/src/core/hw/hid.cpp +++ b/src/core/hw/hid.cpp @@ -1,21 +1,12 @@ #include "hid.h" +#include "core/hle/service/hid.h" +#include "core/hle/kernel/shared_memory.h" + -//TODO: http://pastebin.com/kkGLQhHV namespace HID { -template -inline void Read(T &var, const u32 addr) { - ERROR_LOG(HID, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); -} - -template -inline void Write(u32 addr, const T data) { - ERROR_LOG(HID, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); -} - -//TODO: replace with an interface that doesnt suck (bravia) void SetButtonReg(u32 buttonData) { - Memory::Write32(VADDR_BUTTONS, buttonData); + Kernel::WriteSharedMemory(HID_User::getMemIPCHandle(), buttonData, OFFSET_BUTTONS); } /// Update hardware diff --git a/src/core/hw/hid.h b/src/core/hw/hid.h index 1a89c9b41..1e45c479a 100644 --- a/src/core/hw/hid.h +++ b/src/core/hw/hid.h @@ -13,7 +13,7 @@ struct Registers { extern Registers g_regs; enum { - VADDR_BUTTONS = 0x1000001c, //TODO: it works using the shared mem mapping with all homebrew tested, however the wiki states 0x10146000 as the paddr + OFFSET_BUTTONS = 0x1c, //TODO: it works using the shared mem mapping with all homebrew tested, however the wiki states 0x10146000 as the paddr }; @@ -53,12 +53,6 @@ char * const PAD_NAMES[] = { "PAD_Y" }; -template -inline void Read(T &var, const u32 addr); - -template -inline void Write(u32 addr, const T data); - void SetButtonReg(u32 buttonData); /// Update hardware diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index e596e0984..c8ef8dbf6 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -128,14 +128,13 @@ inline void _Write(u32 addr, const T data) { } else if ((vaddr >= SHARED_MEMORY_VADDR) && (vaddr < SHARED_MEMORY_VADDR_END)) { for (std::map::iterator it = g_shared_map.begin(); it != g_shared_map.end(); it++) { MemoryBlock block = it->second; - if ((vaddr >= block.base_address) && (vaddr < block.GetVirtualAddress())) { + if ((vaddr >= block.base_address) && (vaddr < block.base_address + block.size)) { Handle handle = block.handle; Kernel::WriteSharedMemory(handle, data, addr); return; } } ERROR_LOG(MEMMAP, "Write to unknown shared mapping : Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, vaddr); - *(T*)&g_shared_mem[vaddr & SHARED_MEMORY_MASK] = data; // System memory } else if ((vaddr >= SYSTEM_MEMORY_VADDR) && (vaddr < SYSTEM_MEMORY_VADDR_END)) {