Fixed minor bug in sharedmem writing

This commit is contained in:
inspuration 2014-06-11 00:12:54 -04:00
parent 5f6fa13af6
commit c180fd4003
5 changed files with 13 additions and 23 deletions

View file

@ -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[] = {

View file

@ -14,6 +14,8 @@
namespace HID_User {
Handle getMemIPCHandle();
class Interface : public Service::Interface {
public:

View file

@ -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 <typename T>
inline void Read(T &var, const u32 addr) {
ERROR_LOG(HID, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr);
}
template <typename T>
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

View file

@ -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 <typename T>
inline void Read(T &var, const u32 addr);
template <typename T>
inline void Write(u32 addr, const T data);
void SetButtonReg(u32 buttonData);
/// Update hardware

View file

@ -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<u32, MemoryBlock>::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<T>(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)) {