diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index eb1272b23c..60ce2427d1 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -152,7 +152,7 @@
-
+
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index f3237ed05f..7b47f5cbf8 100644
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -46,7 +46,7 @@
arm\interpreter
-
+
hw
diff --git a/src/core/src/arm/interpreter/arm_interpreter.cpp b/src/core/src/arm/interpreter/arm_interpreter.cpp
index 9305069634..a74aa26cc4 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 f41daca6ab..a7d96e4a43 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 7250bc237d..3e4f2c4350 100644
--- a/src/core/src/hw/hw.cpp
+++ b/src/core/src/hw/hw.cpp
@@ -29,42 +29,34 @@ namespace HW {
template
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
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 &var, const u32 addr);
+template void Read(u32 &var, const u32 addr);
+template void Read(u16 &var, const u32 addr);
+template void Read(u8 &var, const u32 addr);
+
+template void Write(u32 addr, const u64 data);
+template void Write(u32 addr, const u32 data);
+template void Write(u32 addr, const u16 data);
+template void Write(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 dacad49246..c69d6525f8 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
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 b000571e5c..dc4c2381d9 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
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(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
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(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 6a2c13c961..1477bab32f 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();
}