diff options
-rw-r--r-- | src/core/core.vcxproj | 2 | ||||
-rw-r--r-- | src/core/core.vcxproj.filters | 2 | ||||
-rw-r--r-- | src/core/src/arm/interpreter/arm_interpreter.cpp | 44 | ||||
-rw-r--r-- | src/core/src/core.h | 3 | ||||
-rw-r--r-- | src/core/src/hw/hw.cpp | 42 | ||||
-rw-r--r-- | src/core/src/hw/hw.h | 6 | ||||
-rw-r--r-- | src/core/src/mem_map_funcs.cpp | 18 | ||||
-rw-r--r-- | src/core/src/system.cpp | 4 |
8 files changed, 69 insertions, 52 deletions
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index eb1272b23..60ce2427d 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -152,7 +152,7 @@ <ClCompile Include="src\elf\elf_reader.cpp" /> <ClCompile Include="src\file_sys\directory_file_system.cpp" /> <ClCompile Include="src\file_sys\meta_file_system.cpp" /> - <ClCompile Include="src\hw\hardware.cpp" /> + <ClCompile Include="src\hw\hw.cpp" /> <ClCompile Include="src\loader.cpp" /> <ClCompile Include="src\mem_map.cpp" /> <ClCompile Include="src\mem_map_funcs.cpp" /> diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index f3237ed05..7b47f5cbf 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -46,7 +46,7 @@ <ClCompile Include="src\arm\interpreter\arm_interpreter.cpp"> <Filter>arm\interpreter</Filter> </ClCompile> - <ClCompile Include="src\hw\hardware.cpp"> + <ClCompile Include="src\hw\hw.cpp"> <Filter>hw</Filter> </ClCompile> </ItemGroup> diff --git a/src/core/src/arm/interpreter/arm_interpreter.cpp b/src/core/src/arm/interpreter/arm_interpreter.cpp index 930506963..a74aa26cc 100644 --- a/src/core/src/arm/interpreter/arm_interpreter.cpp +++ b/src/core/src/arm/interpreter/arm_interpreter.cpp @@ -1,26 +1,26 @@ /** -* Copyright (C) 2013 Citrus Emulator -* -* @file arm_interpreter.h -* @author bunnei -* @date 2014-04-04 -* @brief ARM interface instance for SkyEye interprerer -* -* @section LICENSE -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details at -* http://www.gnu.org/copyleft/gpl.html -* -* Official project repository can be found at: -* http://code.google.com/p/gekko-gc-emu/ -*/ + * Copyright (C) 2013 Citrus Emulator + * + * @file arm_interpreter.h + * @author bunnei + * @date 2014-04-04 + * @brief ARM interface instance for SkyEye interprerer + * + * @section LICENSE + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details at + * http://www.gnu.org/copyleft/gpl.html + * + * Official project repository can be found at: + * http://code.google.com/p/gekko-gc-emu/ + */ #include "arm_interpreter.h" diff --git a/src/core/src/core.h b/src/core/src/core.h index f41daca6a..a7d96e4a4 100644 --- a/src/core/src/core.h +++ b/src/core/src/core.h @@ -55,6 +55,9 @@ void Stop(); /// Initialize the core int Init(); +/// Shutdown the core +void Shutdown(); + ARMul_State* GetState(); } // namespace diff --git a/src/core/src/hw/hw.cpp b/src/core/src/hw/hw.cpp index 7250bc237..3e4f2c435 100644 --- a/src/core/src/hw/hw.cpp +++ b/src/core/src/hw/hw.cpp @@ -29,42 +29,34 @@ namespace HW { template <typename T> inline void Read(T &var, const u32 addr) { - // TODO: Figure out the fastest order of tests for both read and write (they are probably different). - // TODO: Make sure this represents the mirrors in a correct way. - - // Could just do a base-relative read, too.... TODO - - //if ((addr & 0x3E000000) == 0x08000000) { - // var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); - - //} else { - // _assert_msg_(HW, false, "unknown hardware read"); - //} + NOTICE_LOG(HW, "Hardware read from address %08X", addr); } template <typename T> inline void Write(u32 addr, const T data) { - //// ExeFS:/.code is loaded here: - //if ((addr & 0xFFF00000) == 0x00100000) { - // // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: - // // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions - // // The ExeFS:/.code is loaded here, executables must be loaded to the 0x00100000 region when - // // the exheader "special memory" flag is clear. The 0x03F00000-byte size restriction only - // // applies when this flag is clear. Executables are usually loaded to 0x14000000 when the - // // exheader "special memory" flag is set, however this address can be arbitrary. - // *(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data; - - //// Error out... - //} else { - // _assert_msg_(HW, false, "unknown hardware write"); - //} + NOTICE_LOG(HW, "Hardware write to address %08X", addr); } +// Explicitly instantiate template functions because we aren't defining this in the header: + +template void Read<u64>(u64 &var, const u32 addr); +template void Read<u32>(u32 &var, const u32 addr); +template void Read<u16>(u16 &var, const u32 addr); +template void Read<u8>(u8 &var, const u32 addr); + +template void Write<const u64>(u32 addr, const u64 data); +template void Write<const u32>(u32 addr, const u32 data); +template void Write<const u16>(u32 addr, const u16 data); +template void Write<const u8>(u32 addr, const u8 data); +/// Initialize hardware void Init() { + NOTICE_LOG(HW, "Hardware initialized OK"); } +/// Shutdown hardware void Shutdown() { + NOTICE_LOG(HW, "Hardware shutdown OK"); } }
\ No newline at end of file diff --git a/src/core/src/hw/hw.h b/src/core/src/hw/hw.h index dacad4924..c69d6525f 100644 --- a/src/core/src/hw/hw.h +++ b/src/core/src/hw/hw.h @@ -32,4 +32,10 @@ inline void Read(T &var, const u32 addr); template <typename T> inline void Write(u32 addr, const T data); +/// Initialize hardware +void Init(); + +/// Shutdown hardware +void Shutdown(); + } // namespace diff --git a/src/core/src/mem_map_funcs.cpp b/src/core/src/mem_map_funcs.cpp index b000571e5..dc4c2381d 100644 --- a/src/core/src/mem_map_funcs.cpp +++ b/src/core/src/mem_map_funcs.cpp @@ -25,6 +25,7 @@ #include "common.h" #include "mem_map.h" +#include "hw/hw.h" namespace Memory { @@ -32,10 +33,15 @@ template <typename T> inline void _Read(T &var, const u32 addr) { // TODO: Figure out the fastest order of tests for both read and write (they are probably different). // TODO: Make sure this represents the mirrors in a correct way. - // Could just do a base-relative read, too.... TODO - if ((addr & 0x3E000000) == 0x08000000) { + // Hardware I/O register reads + // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space + if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { + HW::Read<T>(var, addr); + + // FCRAM virtual address reads + } else if ((addr & 0x3E000000) == 0x08000000) { var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); // Scratchpad memory @@ -60,8 +66,14 @@ inline void _Read(T &var, const u32 addr) { template <typename T> inline void _Write(u32 addr, const T data) { + + // Hardware I/O register writes + // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space + if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { + HW::Write<const T>(addr, data); + // ExeFS:/.code is loaded here: - if ((addr & 0xFFF00000) == 0x00100000) { + } else if ((addr & 0xFFF00000) == 0x00100000) { // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions // The ExeFS:/.code is loaded here, executables must be loaded to the 0x00100000 region when diff --git a/src/core/src/system.cpp b/src/core/src/system.cpp index 6a2c13c96..1477bab32 100644 --- a/src/core/src/system.cpp +++ b/src/core/src/system.cpp @@ -23,6 +23,7 @@ */ #include "core.h" +#include "hw/hw.h" #include "core_timing.h" #include "mem_map.h" #include "system.h" @@ -38,6 +39,7 @@ void UpdateState(State state) { void Init(EmuWindow* emu_window) { Core::Init(); Memory::Init(); + HW::Init(); CoreTiming::Init(); } @@ -49,6 +51,8 @@ void RunLoopUntil(u64 global_cycles) { } void Shutdown() { + Core::Shutdown(); + HW::Shutdown(); g_ctr_file_system.Shutdown(); } |