mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
added hw module to interface h/w register reads/writes
This commit is contained in:
parent
006bb834df
commit
670ac5643a
|
@ -152,6 +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\loader.cpp" />
|
||||
<ClCompile Include="src\mem_map.cpp" />
|
||||
<ClCompile Include="src\mem_map_funcs.cpp" />
|
||||
|
@ -180,6 +181,7 @@
|
|||
<ClInclude Include="src\file_sys\directory_file_system.h" />
|
||||
<ClInclude Include="src\file_sys\file_sys.h" />
|
||||
<ClInclude Include="src\file_sys\meta_file_system.h" />
|
||||
<ClInclude Include="src\hw\hw.h" />
|
||||
<ClInclude Include="src\loader.h" />
|
||||
<ClInclude Include="src\mem_map.h" />
|
||||
<ClInclude Include="src\system.h" />
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
<ClCompile Include="src\arm\interpreter\arm_interpreter.cpp">
|
||||
<Filter>arm\interpreter</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\hw\hardware.cpp">
|
||||
<Filter>hw</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="arm">
|
||||
|
@ -69,6 +72,9 @@
|
|||
<Filter Include="arm\interpreter">
|
||||
<UniqueIdentifier>{cca8b763-8a80-4478-9bcc-3c979293c357}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="hw">
|
||||
<UniqueIdentifier>{d1158fc4-3e0f-431f-9d3b-f30bbfeb4ad5}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\arm\disassembler\arm_disasm.h">
|
||||
|
@ -136,6 +142,9 @@
|
|||
<ClInclude Include="src\arm\interpreter\arm_interpreter.h">
|
||||
<Filter>arm\interpreter</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\hw\hw.h">
|
||||
<Filter>hw</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
|
70
src/core/src/hw/hw.cpp
Normal file
70
src/core/src/hw/hw.cpp
Normal file
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* Copyright (C) 2013 Citrus Emulator
|
||||
*
|
||||
* @file hw.cpp
|
||||
* @author bunnei
|
||||
* @date 2014-04-04
|
||||
* @brief Hardware interface
|
||||
*
|
||||
* @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 "log.h"
|
||||
#include "hw/hw.h"
|
||||
|
||||
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");
|
||||
//}
|
||||
}
|
||||
|
||||
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");
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
void Init() {
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
}
|
||||
|
||||
}
|
35
src/core/src/hw/hw.h
Normal file
35
src/core/src/hw/hw.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* Copyright (C) 2013 Citrus Emulator
|
||||
*
|
||||
* @file hw.h
|
||||
* @author bunnei
|
||||
* @date 2014-04-04
|
||||
* @brief Hardware interface
|
||||
*
|
||||
* @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 "common_types.h"
|
||||
|
||||
namespace HW {
|
||||
|
||||
template <typename T>
|
||||
inline void Read(T &var, const u32 addr);
|
||||
|
||||
template <typename T>
|
||||
inline void Write(u32 addr, const T data);
|
||||
|
||||
} // namespace
|
|
@ -54,8 +54,7 @@ inline void _Read(T &var, const u32 addr) {
|
|||
var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]);
|
||||
|
||||
} else {
|
||||
_assert_msg_(MEMMAP, false, "unknown hardware read");
|
||||
// WARN_LOG(MEMMAP, "_Read: Invalid addr %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
|
||||
_assert_msg_(MEMMAP, false, "unknown memory read");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +103,7 @@ inline void _Write(u32 addr, const T data) {
|
|||
|
||||
// Error out...
|
||||
} else {
|
||||
_assert_msg_(MEMMAP, false, "unknown hardware write");
|
||||
_assert_msg_(MEMMAP, false, "unknown memory write");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue