diff options
| author | 2014-04-04 23:02:59 -0400 | |
|---|---|---|
| committer | 2014-04-04 23:02:59 -0400 | |
| commit | 670ac5643a7cda55b7c5d68c99495ade0d14e6e4 (patch) | |
| tree | 4744930d71e738aef3edf7f3fbd114c81e30a508 /src/core | |
| parent | added a HW option to logging (diff) | |
| download | yuzu-670ac5643a7cda55b7c5d68c99495ade0d14e6e4.tar.gz yuzu-670ac5643a7cda55b7c5d68c99495ade0d14e6e4.tar.xz yuzu-670ac5643a7cda55b7c5d68c99495ade0d14e6e4.zip | |
added hw module to interface h/w register reads/writes
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.vcxproj | 2 | ||||
| -rw-r--r-- | src/core/core.vcxproj.filters | 9 | ||||
| -rw-r--r-- | src/core/src/hw/hw.cpp | 70 | ||||
| -rw-r--r-- | src/core/src/hw/hw.h | 35 | ||||
| -rw-r--r-- | src/core/src/mem_map_funcs.cpp | 5 |
5 files changed, 118 insertions, 3 deletions
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index bee9f3046..eb1272b23 100644 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj | |||
| @@ -152,6 +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\loader.cpp" /> | 156 | <ClCompile Include="src\loader.cpp" /> |
| 156 | <ClCompile Include="src\mem_map.cpp" /> | 157 | <ClCompile Include="src\mem_map.cpp" /> |
| 157 | <ClCompile Include="src\mem_map_funcs.cpp" /> | 158 | <ClCompile Include="src\mem_map_funcs.cpp" /> |
| @@ -180,6 +181,7 @@ | |||
| 180 | <ClInclude Include="src\file_sys\directory_file_system.h" /> | 181 | <ClInclude Include="src\file_sys\directory_file_system.h" /> |
| 181 | <ClInclude Include="src\file_sys\file_sys.h" /> | 182 | <ClInclude Include="src\file_sys\file_sys.h" /> |
| 182 | <ClInclude Include="src\file_sys\meta_file_system.h" /> | 183 | <ClInclude Include="src\file_sys\meta_file_system.h" /> |
| 184 | <ClInclude Include="src\hw\hw.h" /> | ||
| 183 | <ClInclude Include="src\loader.h" /> | 185 | <ClInclude Include="src\loader.h" /> |
| 184 | <ClInclude Include="src\mem_map.h" /> | 186 | <ClInclude Include="src\mem_map.h" /> |
| 185 | <ClInclude Include="src\system.h" /> | 187 | <ClInclude Include="src\system.h" /> |
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index 45ddf8cf6..f3237ed05 100644 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters | |||
| @@ -46,6 +46,9 @@ | |||
| 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"> | ||
| 50 | <Filter>hw</Filter> | ||
| 51 | </ClCompile> | ||
| 49 | </ItemGroup> | 52 | </ItemGroup> |
| 50 | <ItemGroup> | 53 | <ItemGroup> |
| 51 | <Filter Include="arm"> | 54 | <Filter Include="arm"> |
| @@ -69,6 +72,9 @@ | |||
| 69 | <Filter Include="arm\interpreter"> | 72 | <Filter Include="arm\interpreter"> |
| 70 | <UniqueIdentifier>{cca8b763-8a80-4478-9bcc-3c979293c357}</UniqueIdentifier> | 73 | <UniqueIdentifier>{cca8b763-8a80-4478-9bcc-3c979293c357}</UniqueIdentifier> |
| 71 | </Filter> | 74 | </Filter> |
| 75 | <Filter Include="hw"> | ||
| 76 | <UniqueIdentifier>{d1158fc4-3e0f-431f-9d3b-f30bbfeb4ad5}</UniqueIdentifier> | ||
| 77 | </Filter> | ||
| 72 | </ItemGroup> | 78 | </ItemGroup> |
| 73 | <ItemGroup> | 79 | <ItemGroup> |
| 74 | <ClInclude Include="src\arm\disassembler\arm_disasm.h"> | 80 | <ClInclude Include="src\arm\disassembler\arm_disasm.h"> |
| @@ -136,6 +142,9 @@ | |||
| 136 | <ClInclude Include="src\arm\interpreter\arm_interpreter.h"> | 142 | <ClInclude Include="src\arm\interpreter\arm_interpreter.h"> |
| 137 | <Filter>arm\interpreter</Filter> | 143 | <Filter>arm\interpreter</Filter> |
| 138 | </ClInclude> | 144 | </ClInclude> |
| 145 | <ClInclude Include="src\hw\hw.h"> | ||
| 146 | <Filter>hw</Filter> | ||
| 147 | </ClInclude> | ||
| 139 | </ItemGroup> | 148 | </ItemGroup> |
| 140 | <ItemGroup> | 149 | <ItemGroup> |
| 141 | <None Include="CMakeLists.txt" /> | 150 | <None Include="CMakeLists.txt" /> |
diff --git a/src/core/src/hw/hw.cpp b/src/core/src/hw/hw.cpp new file mode 100644 index 000000000..7250bc237 --- /dev/null +++ b/src/core/src/hw/hw.cpp | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | /** | ||
| 2 | * Copyright (C) 2013 Citrus Emulator | ||
| 3 | * | ||
| 4 | * @file hw.cpp | ||
| 5 | * @author bunnei | ||
| 6 | * @date 2014-04-04 | ||
| 7 | * @brief Hardware interface | ||
| 8 | * | ||
| 9 | * @section LICENSE | ||
| 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 | ||
| 12 | * published by the Free Software Foundation; either version 2 of | ||
| 13 | * the License, or (at your option) any later version. | ||
| 14 | * | ||
| 15 | * This program is distributed in the hope that it will be useful, but | ||
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 18 | * General Public License for more details at | ||
| 19 | * http://www.gnu.org/copyleft/gpl.html | ||
| 20 | * | ||
| 21 | * Official project repository can be found at: | ||
| 22 | * http://code.google.com/p/gekko-gc-emu/ | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include "log.h" | ||
| 26 | #include "hw/hw.h" | ||
| 27 | |||
| 28 | namespace HW { | ||
| 29 | |||
| 30 | template <typename T> | ||
| 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). | ||
| 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 | } | ||
| 44 | |||
| 45 | template <typename T> | ||
| 46 | inline void Write(u32 addr, const T data) { | ||
| 47 | //// ExeFS:/.code is loaded here: | ||
| 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 | } | ||
| 62 | |||
| 63 | |||
| 64 | void Init() { | ||
| 65 | } | ||
| 66 | |||
| 67 | void Shutdown() { | ||
| 68 | } | ||
| 69 | |||
| 70 | } \ No newline at end of file | ||
diff --git a/src/core/src/hw/hw.h b/src/core/src/hw/hw.h new file mode 100644 index 000000000..dacad4924 --- /dev/null +++ b/src/core/src/hw/hw.h | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | /** | ||
| 2 | * Copyright (C) 2013 Citrus Emulator | ||
| 3 | * | ||
| 4 | * @file hw.h | ||
| 5 | * @author bunnei | ||
| 6 | * @date 2014-04-04 | ||
| 7 | * @brief Hardware interface | ||
| 8 | * | ||
| 9 | * @section LICENSE | ||
| 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 | ||
| 12 | * published by the Free Software Foundation; either version 2 of | ||
| 13 | * the License, or (at your option) any later version. | ||
| 14 | * | ||
| 15 | * This program is distributed in the hope that it will be useful, but | ||
| 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 18 | * General Public License for more details at | ||
| 19 | * http://www.gnu.org/copyleft/gpl.html | ||
| 20 | * | ||
| 21 | * Official project repository can be found at: | ||
| 22 | * http://code.google.com/p/gekko-gc-emu/ | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include "common_types.h" | ||
| 26 | |||
| 27 | namespace HW { | ||
| 28 | |||
| 29 | template <typename T> | ||
| 30 | inline void Read(T &var, const u32 addr); | ||
| 31 | |||
| 32 | template <typename T> | ||
| 33 | inline void Write(u32 addr, const T data); | ||
| 34 | |||
| 35 | } // namespace | ||
diff --git a/src/core/src/mem_map_funcs.cpp b/src/core/src/mem_map_funcs.cpp index 446d3ac97..b000571e5 100644 --- a/src/core/src/mem_map_funcs.cpp +++ b/src/core/src/mem_map_funcs.cpp | |||
| @@ -54,8 +54,7 @@ inline void _Read(T &var, const u32 addr) { | |||
| 54 | var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); | 54 | var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); |
| 55 | 55 | ||
| 56 | } else { | 56 | } else { |
| 57 | _assert_msg_(MEMMAP, false, "unknown hardware read"); | 57 | _assert_msg_(MEMMAP, false, "unknown memory read"); |
| 58 | // WARN_LOG(MEMMAP, "_Read: Invalid addr %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]); | ||
| 59 | } | 58 | } |
| 60 | } | 59 | } |
| 61 | 60 | ||
| @@ -104,7 +103,7 @@ inline void _Write(u32 addr, const T data) { | |||
| 104 | 103 | ||
| 105 | // Error out... | 104 | // Error out... |
| 106 | } else { | 105 | } else { |
| 107 | _assert_msg_(MEMMAP, false, "unknown hardware write"); | 106 | _assert_msg_(MEMMAP, false, "unknown memory write"); |
| 108 | } | 107 | } |
| 109 | } | 108 | } |
| 110 | 109 | ||