diff options
| author | 2014-04-05 00:01:07 -0400 | |
|---|---|---|
| committer | 2014-04-05 00:01:07 -0400 | |
| commit | 31abc42d3dd8ea6ba23b14afa276bae684d694ef (patch) | |
| tree | 5bd30c1294b869ba75eb2491f9ba7a1ad5f6c68c /src | |
| parent | added hw module to interface h/w register reads/writes (diff) | |
| download | yuzu-31abc42d3dd8ea6ba23b14afa276bae684d694ef.tar.gz yuzu-31abc42d3dd8ea6ba23b14afa276bae684d694ef.tar.xz yuzu-31abc42d3dd8ea6ba23b14afa276bae684d694ef.zip | |
added initial support for hw.cpp module
Diffstat (limited to 'src')
| -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 @@ | |||
| 152 | <ClCompile Include="src\elf\elf_reader.cpp" /> | 152 | <ClCompile Include="src\elf\elf_reader.cpp" /> |
| 153 | <ClCompile Include="src\file_sys\directory_file_system.cpp" /> | 153 | <ClCompile Include="src\file_sys\directory_file_system.cpp" /> |
| 154 | <ClCompile Include="src\file_sys\meta_file_system.cpp" /> | 154 | <ClCompile Include="src\file_sys\meta_file_system.cpp" /> |
| 155 | <ClCompile Include="src\hw\hardware.cpp" /> | 155 | <ClCompile Include="src\hw\hw.cpp" /> |
| 156 | <ClCompile Include="src\loader.cpp" /> | 156 | <ClCompile Include="src\loader.cpp" /> |
| 157 | <ClCompile Include="src\mem_map.cpp" /> | 157 | <ClCompile Include="src\mem_map.cpp" /> |
| 158 | <ClCompile Include="src\mem_map_funcs.cpp" /> | 158 | <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 @@ | |||
| 46 | <ClCompile Include="src\arm\interpreter\arm_interpreter.cpp"> | 46 | <ClCompile Include="src\arm\interpreter\arm_interpreter.cpp"> |
| 47 | <Filter>arm\interpreter</Filter> | 47 | <Filter>arm\interpreter</Filter> |
| 48 | </ClCompile> | 48 | </ClCompile> |
| 49 | <ClCompile Include="src\hw\hardware.cpp"> | 49 | <ClCompile Include="src\hw\hw.cpp"> |
| 50 | <Filter>hw</Filter> | 50 | <Filter>hw</Filter> |
| 51 | </ClCompile> | 51 | </ClCompile> |
| 52 | </ItemGroup> | 52 | </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 @@ | |||
| 1 | /** | 1 | /** |
| 2 | * Copyright (C) 2013 Citrus Emulator | 2 | * Copyright (C) 2013 Citrus Emulator |
| 3 | * | 3 | * |
| 4 | * @file arm_interpreter.h | 4 | * @file arm_interpreter.h |
| 5 | * @author bunnei | 5 | * @author bunnei |
| 6 | * @date 2014-04-04 | 6 | * @date 2014-04-04 |
| 7 | * @brief ARM interface instance for SkyEye interprerer | 7 | * @brief ARM interface instance for SkyEye interprerer |
| 8 | * | 8 | * |
| 9 | * @section LICENSE | 9 | * @section LICENSE |
| 10 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as | 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of | 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. | 13 | * the License, or (at your option) any later version. |
| 14 | * | 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, but | 15 | * This program is distributed in the hope that it will be useful, but |
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * General Public License for more details at | 18 | * General Public License for more details at |
| 19 | * http://www.gnu.org/copyleft/gpl.html | 19 | * http://www.gnu.org/copyleft/gpl.html |
| 20 | * | 20 | * |
| 21 | * Official project repository can be found at: | 21 | * Official project repository can be found at: |
| 22 | * http://code.google.com/p/gekko-gc-emu/ | 22 | * http://code.google.com/p/gekko-gc-emu/ |
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include "arm_interpreter.h" | 25 | #include "arm_interpreter.h" |
| 26 | 26 | ||
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(); | |||
| 55 | /// Initialize the core | 55 | /// Initialize the core |
| 56 | int Init(); | 56 | int Init(); |
| 57 | 57 | ||
| 58 | /// Shutdown the core | ||
| 59 | void Shutdown(); | ||
| 60 | |||
| 58 | ARMul_State* GetState(); | 61 | ARMul_State* GetState(); |
| 59 | 62 | ||
| 60 | } // namespace | 63 | } // 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 { | |||
| 29 | 29 | ||
| 30 | template <typename T> | 30 | template <typename T> |
| 31 | inline void Read(T &var, const u32 addr) { | 31 | inline void Read(T &var, const u32 addr) { |
| 32 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). | 32 | NOTICE_LOG(HW, "Hardware read from address %08X", addr); |
| 33 | // TODO: Make sure this represents the mirrors in a correct way. | ||
| 34 | |||
| 35 | // Could just do a base-relative read, too.... TODO | ||
| 36 | |||
| 37 | //if ((addr & 0x3E000000) == 0x08000000) { | ||
| 38 | // var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); | ||
| 39 | |||
| 40 | //} else { | ||
| 41 | // _assert_msg_(HW, false, "unknown hardware read"); | ||
| 42 | //} | ||
| 43 | } | 33 | } |
| 44 | 34 | ||
| 45 | template <typename T> | 35 | template <typename T> |
| 46 | inline void Write(u32 addr, const T data) { | 36 | inline void Write(u32 addr, const T data) { |
| 47 | //// ExeFS:/.code is loaded here: | 37 | NOTICE_LOG(HW, "Hardware write to address %08X", addr); |
| 48 | //if ((addr & 0xFFF00000) == 0x00100000) { | ||
| 49 | // // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: | ||
| 50 | // // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions | ||
| 51 | // // The ExeFS:/.code is loaded here, executables must be loaded to the 0x00100000 region when | ||
| 52 | // // the exheader "special memory" flag is clear. The 0x03F00000-byte size restriction only | ||
| 53 | // // applies when this flag is clear. Executables are usually loaded to 0x14000000 when the | ||
| 54 | // // exheader "special memory" flag is set, however this address can be arbitrary. | ||
| 55 | // *(T*)&g_fcram[addr & MEM_FCRAM_MASK] = data; | ||
| 56 | |||
| 57 | //// Error out... | ||
| 58 | //} else { | ||
| 59 | // _assert_msg_(HW, false, "unknown hardware write"); | ||
| 60 | //} | ||
| 61 | } | 38 | } |
| 62 | 39 | ||
| 40 | // Explicitly instantiate template functions because we aren't defining this in the header: | ||
| 41 | |||
| 42 | template void Read<u64>(u64 &var, const u32 addr); | ||
| 43 | template void Read<u32>(u32 &var, const u32 addr); | ||
| 44 | template void Read<u16>(u16 &var, const u32 addr); | ||
| 45 | template void Read<u8>(u8 &var, const u32 addr); | ||
| 46 | |||
| 47 | template void Write<const u64>(u32 addr, const u64 data); | ||
| 48 | template void Write<const u32>(u32 addr, const u32 data); | ||
| 49 | template void Write<const u16>(u32 addr, const u16 data); | ||
| 50 | template void Write<const u8>(u32 addr, const u8 data); | ||
| 63 | 51 | ||
| 52 | /// Initialize hardware | ||
| 64 | void Init() { | 53 | void Init() { |
| 54 | NOTICE_LOG(HW, "Hardware initialized OK"); | ||
| 65 | } | 55 | } |
| 66 | 56 | ||
| 57 | /// Shutdown hardware | ||
| 67 | void Shutdown() { | 58 | void Shutdown() { |
| 59 | NOTICE_LOG(HW, "Hardware shutdown OK"); | ||
| 68 | } | 60 | } |
| 69 | 61 | ||
| 70 | } \ No newline at end of file | 62 | } \ 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); | |||
| 32 | template <typename T> | 32 | template <typename T> |
| 33 | inline void Write(u32 addr, const T data); | 33 | inline void Write(u32 addr, const T data); |
| 34 | 34 | ||
| 35 | /// Initialize hardware | ||
| 36 | void Init(); | ||
| 37 | |||
| 38 | /// Shutdown hardware | ||
| 39 | void Shutdown(); | ||
| 40 | |||
| 35 | } // namespace | 41 | } // 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 @@ | |||
| 25 | #include "common.h" | 25 | #include "common.h" |
| 26 | 26 | ||
| 27 | #include "mem_map.h" | 27 | #include "mem_map.h" |
| 28 | #include "hw/hw.h" | ||
| 28 | 29 | ||
| 29 | namespace Memory { | 30 | namespace Memory { |
| 30 | 31 | ||
| @@ -32,10 +33,15 @@ template <typename T> | |||
| 32 | inline void _Read(T &var, const u32 addr) { | 33 | inline void _Read(T &var, const u32 addr) { |
| 33 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). | 34 | // TODO: Figure out the fastest order of tests for both read and write (they are probably different). |
| 34 | // TODO: Make sure this represents the mirrors in a correct way. | 35 | // TODO: Make sure this represents the mirrors in a correct way. |
| 35 | |||
| 36 | // Could just do a base-relative read, too.... TODO | 36 | // Could just do a base-relative read, too.... TODO |
| 37 | 37 | ||
| 38 | if ((addr & 0x3E000000) == 0x08000000) { | 38 | // Hardware I/O register reads |
| 39 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space | ||
| 40 | if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { | ||
| 41 | HW::Read<T>(var, addr); | ||
| 42 | |||
| 43 | // FCRAM virtual address reads | ||
| 44 | } else if ((addr & 0x3E000000) == 0x08000000) { | ||
| 39 | var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); | 45 | var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); |
| 40 | 46 | ||
| 41 | // Scratchpad memory | 47 | // Scratchpad memory |
| @@ -60,8 +66,14 @@ inline void _Read(T &var, const u32 addr) { | |||
| 60 | 66 | ||
| 61 | template <typename T> | 67 | template <typename T> |
| 62 | inline void _Write(u32 addr, const T data) { | 68 | inline void _Write(u32 addr, const T data) { |
| 69 | |||
| 70 | // Hardware I/O register writes | ||
| 71 | // 0x10XXXXXX- is physical address space, 0x1EXXXXXX is virtual address space | ||
| 72 | if ((addr & 0xFF000000) == 0x10000000 || (addr & 0xFF000000) == 0x1E000000) { | ||
| 73 | HW::Write<const T>(addr, data); | ||
| 74 | |||
| 63 | // ExeFS:/.code is loaded here: | 75 | // ExeFS:/.code is loaded here: |
| 64 | if ((addr & 0xFFF00000) == 0x00100000) { | 76 | } else if ((addr & 0xFFF00000) == 0x00100000) { |
| 65 | // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: | 77 | // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: |
| 66 | // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions | 78 | // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions |
| 67 | // The ExeFS:/.code is loaded here, executables must be loaded to the 0x00100000 region when | 79 | // 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 @@ | |||
| 23 | */ | 23 | */ |
| 24 | 24 | ||
| 25 | #include "core.h" | 25 | #include "core.h" |
| 26 | #include "hw/hw.h" | ||
| 26 | #include "core_timing.h" | 27 | #include "core_timing.h" |
| 27 | #include "mem_map.h" | 28 | #include "mem_map.h" |
| 28 | #include "system.h" | 29 | #include "system.h" |
| @@ -38,6 +39,7 @@ void UpdateState(State state) { | |||
| 38 | void Init(EmuWindow* emu_window) { | 39 | void Init(EmuWindow* emu_window) { |
| 39 | Core::Init(); | 40 | Core::Init(); |
| 40 | Memory::Init(); | 41 | Memory::Init(); |
| 42 | HW::Init(); | ||
| 41 | CoreTiming::Init(); | 43 | CoreTiming::Init(); |
| 42 | } | 44 | } |
| 43 | 45 | ||
| @@ -49,6 +51,8 @@ void RunLoopUntil(u64 global_cycles) { | |||
| 49 | } | 51 | } |
| 50 | 52 | ||
| 51 | void Shutdown() { | 53 | void Shutdown() { |
| 54 | Core::Shutdown(); | ||
| 55 | HW::Shutdown(); | ||
| 52 | g_ctr_file_system.Shutdown(); | 56 | g_ctr_file_system.Shutdown(); |
| 53 | } | 57 | } |
| 54 | 58 | ||