From 2b52ec4829dce2801e4a507b81e9d302aae08735 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Jul 2014 19:46:10 -0400 Subject: MemMap: Fix Read32 for unaligned memory reads. MemMap: Cleaned up Read32 unaligned memory access. --- src/core/mem_map_funcs.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index 0342122df..e9533a0c5 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -224,27 +224,38 @@ u32 MapBlock_HeapGSP(u32 size, u32 operation, u32 permissions) { } u8 Read8(const u32 addr) { - u8 _var = 0; - Read(_var, addr); - return (u8)_var; + u8 data = 0; + Read(data, addr); + return (u8)data; } u16 Read16(const u32 addr) { - u16_le _var = 0; - Read(_var, addr); - return (u16)_var; + u16_le data = 0; + Read(data, addr); + return (u16)data; } u32 Read32(const u32 addr) { - u32_le _var = 0; - Read(_var, addr); - return _var; + u32_le data = 0; + Read(data, addr); + + // Check for 32-bit unaligned memory reads... + if (addr & 3) { + // ARM allows for unaligned memory reads, however older ARM architectures read out memory + // from unaligned addresses in a shifted way. Our ARM CPU core (SkyEye) corrects for this, + // so therefore expects the memory to be read out in this manner. + // TODO(bunnei): Determine if this is necessary - perhaps it is OK to remove this from both + // SkyEye and here? + int shift = (addr & 3) * 8; + data = (data << shift) | (data >> (32 - shift)); + } + return (u32)data; } u64 Read64(const u32 addr) { - u64_le _var = 0; - Read(_var, addr); - return _var; + u64_le data = 0; + Read(data, addr); + return data; } u32 Read8_ZX(const u32 addr) { -- cgit v1.2.3 From 81fa804b3cc16312deb2230b14c317b852b835fa Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Jul 2014 19:46:48 -0400 Subject: FS: Fix port name (old port name was based on an unaligned memory read). --- src/core/hle/service/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/hle/service/fs.h b/src/core/hle/service/fs.h index 34b0610ad..fabf5ac7e 100644 --- a/src/core/hle/service/fs.h +++ b/src/core/hle/service/fs.h @@ -24,7 +24,7 @@ public: * @return Port name of service */ const char *GetPortName() const { - return "Ufs:"; + return "fs:USER"; } }; -- cgit v1.2.3 From da81742439ba61d832c0d1c98b736308bfe0f58c Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 5 Aug 2014 20:01:55 -0400 Subject: MemMap: Removed Read64 function. - Unused code - Was not correct for unaligned memory reads --- src/core/mem_map_funcs.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/core') diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index e9533a0c5..b4884d9d9 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -252,12 +252,6 @@ u32 Read32(const u32 addr) { return (u32)data; } -u64 Read64(const u32 addr) { - u64_le data = 0; - Read(data, addr); - return data; -} - u32 Read8_ZX(const u32 addr) { return (u32)Read8(addr); } -- cgit v1.2.3 From 967e5629de4ffb49a193e73df388efae7b3eaa43 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 5 Aug 2014 20:05:06 -0400 Subject: MemMap: Added an error for unaligned 16-bit memory reads. --- src/core/mem_map_funcs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/core') diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp index b4884d9d9..038d3bffa 100644 --- a/src/core/mem_map_funcs.cpp +++ b/src/core/mem_map_funcs.cpp @@ -232,6 +232,13 @@ u8 Read8(const u32 addr) { u16 Read16(const u32 addr) { u16_le data = 0; Read(data, addr); + + // Check for 16-bit unaligned memory reads... + if (addr & 1) { + // TODO(bunnei): Implement 16-bit unaligned memory reads + ERROR_LOG(MEMMAP, "16-bit unaligned memory reads are not implemented!"); + } + return (u16)data; } -- cgit v1.2.3