added initial support for hw.cpp module

This commit is contained in:
bunnei 2014-04-05 00:01:07 -04:00
parent 670ac5643a
commit 31abc42d3d
8 changed files with 69 additions and 52 deletions

View file

@ -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" />

View file

@ -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>

View file

@ -55,6 +55,9 @@ void Stop();
/// Initialize the core
int Init();
/// Shutdown the core
void Shutdown();
ARMul_State* GetState();
} // namespace

View file

@ -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");
}
}

View file

@ -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

View file

@ -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

View file

@ -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();
}