summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/core.vcxproj4
-rw-r--r--src/core/core.vcxproj.filters15
-rw-r--r--src/core/src/arm/arm_interface.h49
-rw-r--r--src/core/src/arm/interpreter/arm_interpreter.cpp44
-rw-r--r--src/core/src/arm/interpreter/arm_interpreter.h7
-rw-r--r--src/core/src/core.cpp6
-rw-r--r--src/core/src/core.h3
-rw-r--r--src/core/src/hw/hw.cpp69
-rw-r--r--src/core/src/hw/hw.h44
-rw-r--r--src/core/src/hw/hw_lcd.cpp65
-rw-r--r--src/core/src/hw/hw_lcd.h64
-rw-r--r--src/core/src/mem_map_funcs.cpp54
-rw-r--r--src/core/src/system.cpp9
13 files changed, 386 insertions, 47 deletions
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index bee9f3046..2edb51214 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -152,6 +152,8 @@
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\hw.cpp" />
156 <ClCompile Include="src\hw\hw_lcd.cpp" />
155 <ClCompile Include="src\loader.cpp" /> 157 <ClCompile Include="src\loader.cpp" />
156 <ClCompile Include="src\mem_map.cpp" /> 158 <ClCompile Include="src\mem_map.cpp" />
157 <ClCompile Include="src\mem_map_funcs.cpp" /> 159 <ClCompile Include="src\mem_map_funcs.cpp" />
@@ -180,6 +182,8 @@
180 <ClInclude Include="src\file_sys\directory_file_system.h" /> 182 <ClInclude Include="src\file_sys\directory_file_system.h" />
181 <ClInclude Include="src\file_sys\file_sys.h" /> 183 <ClInclude Include="src\file_sys\file_sys.h" />
182 <ClInclude Include="src\file_sys\meta_file_system.h" /> 184 <ClInclude Include="src\file_sys\meta_file_system.h" />
185 <ClInclude Include="src\hw\hw.h" />
186 <ClInclude Include="src\hw\hw_lcd.h" />
183 <ClInclude Include="src\loader.h" /> 187 <ClInclude Include="src\loader.h" />
184 <ClInclude Include="src\mem_map.h" /> 188 <ClInclude Include="src\mem_map.h" />
185 <ClInclude Include="src\system.h" /> 189 <ClInclude Include="src\system.h" />
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index 45ddf8cf6..0cd208dd6 100644
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -46,6 +46,12 @@
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\hw.cpp">
50 <Filter>hw</Filter>
51 </ClCompile>
52 <ClCompile Include="src\hw\hw_lcd.cpp">
53 <Filter>hw</Filter>
54 </ClCompile>
49 </ItemGroup> 55 </ItemGroup>
50 <ItemGroup> 56 <ItemGroup>
51 <Filter Include="arm"> 57 <Filter Include="arm">
@@ -69,6 +75,9 @@
69 <Filter Include="arm\interpreter"> 75 <Filter Include="arm\interpreter">
70 <UniqueIdentifier>{cca8b763-8a80-4478-9bcc-3c979293c357}</UniqueIdentifier> 76 <UniqueIdentifier>{cca8b763-8a80-4478-9bcc-3c979293c357}</UniqueIdentifier>
71 </Filter> 77 </Filter>
78 <Filter Include="hw">
79 <UniqueIdentifier>{d1158fc4-3e0f-431f-9d3b-f30bbfeb4ad5}</UniqueIdentifier>
80 </Filter>
72 </ItemGroup> 81 </ItemGroup>
73 <ItemGroup> 82 <ItemGroup>
74 <ClInclude Include="src\arm\disassembler\arm_disasm.h"> 83 <ClInclude Include="src\arm\disassembler\arm_disasm.h">
@@ -136,6 +145,12 @@
136 <ClInclude Include="src\arm\interpreter\arm_interpreter.h"> 145 <ClInclude Include="src\arm\interpreter\arm_interpreter.h">
137 <Filter>arm\interpreter</Filter> 146 <Filter>arm\interpreter</Filter>
138 </ClInclude> 147 </ClInclude>
148 <ClInclude Include="src\hw\hw.h">
149 <Filter>hw</Filter>
150 </ClInclude>
151 <ClInclude Include="src\hw\hw_lcd.h">
152 <Filter>hw</Filter>
153 </ClInclude>
139 </ItemGroup> 154 </ItemGroup>
140 <ItemGroup> 155 <ItemGroup>
141 <None Include="CMakeLists.txt" /> 156 <None Include="CMakeLists.txt" />
diff --git a/src/core/src/arm/arm_interface.h b/src/core/src/arm/arm_interface.h
index 785234396..daf35b51d 100644
--- a/src/core/src/arm/arm_interface.h
+++ b/src/core/src/arm/arm_interface.h
@@ -24,24 +24,65 @@
24 24
25#pragma once 25#pragma once
26 26
27#include "common.h"
27#include "common_types.h" 28#include "common_types.h"
28 29
29/// Generic ARM11 CPU interface 30/// Generic ARM11 CPU interface
30class ARM_Interface { 31class ARM_Interface {
31public: 32public:
32 ARM_Interface() { 33 ARM_Interface() {
34 num_instructions_ = 0;
33 } 35 }
34 36
35 ~ARM_Interface() { 37 ~ARM_Interface() {
36 } 38 }
37 39
38 virtual void ExecuteInstruction() = 0; 40 /// Step CPU by one instruction
39 41 void Step() {
40 virtual void SetPC(u32 pc) = 0; 42 ExecuteInstruction();
43 num_instructions_++;
44 }
45
46 /**
47 * Set the Program Counter to an address
48 * @param addr Address to set PC to
49 */
50 virtual void SetPC(u32 addr) = 0;
41 51
52 /*
53 * Get the current Program Counter
54 * @return Returns current PC
55 */
42 virtual u32 PC() = 0; 56 virtual u32 PC() = 0;
43 57
58 /**
59 * Get an ARM register
60 * @param index Register index (0-15)
61 * @return Returns the value in the register
62 */
44 virtual u32 Reg(int index) = 0; 63 virtual u32 Reg(int index) = 0;
45 64
46 virtual u32 CPSR() = 0; 65 /**
66 * Get the current CPSR register
67 * @return Returns the value of the CPSR register
68 */
69 virtual u32 CPSR() = 0;
70
71 /**
72 * Returns the number of clock ticks since the last rese
73 * @return Returns number of clock ticks
74 */
75 virtual u64 GetTicks() = 0;
76
77 /// Getter for num_instructions_
78 u64 num_instructions() { return num_instructions_; }
79
80private:
81
82 /// Execture next instruction
83 virtual void ExecuteInstruction() = 0;
84
85 u64 num_instructions_; ///< Number of instructions executed
86
87 DISALLOW_COPY_AND_ASSIGN(ARM_Interface);
47}; 88};
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/arm/interpreter/arm_interpreter.h b/src/core/src/arm/interpreter/arm_interpreter.h
index 89f871fa9..074149f1b 100644
--- a/src/core/src/arm/interpreter/arm_interpreter.h
+++ b/src/core/src/arm/interpreter/arm_interpreter.h
@@ -24,6 +24,7 @@
24 24
25#pragma once 25#pragma once
26 26
27#include "common.h"
27#include "common_types.h" 28#include "common_types.h"
28#include "arm/arm_interface.h" 29#include "arm/arm_interface.h"
29 30
@@ -45,6 +46,12 @@ public:
45 46
46 u32 CPSR(); 47 u32 CPSR();
47 48
49 u64 GetTicks() {
50 return ARMul_Time(state);
51 }
52
48private: 53private:
49 ARMul_State* state; 54 ARMul_State* state;
55
56 DISALLOW_COPY_AND_ASSIGN(ARM_Interpreter);
50}; 57};
diff --git a/src/core/src/core.cpp b/src/core/src/core.cpp
index 592805134..4261ff3ef 100644
--- a/src/core/src/core.cpp
+++ b/src/core/src/core.cpp
@@ -25,6 +25,7 @@
25#include "log.h" 25#include "log.h"
26#include "core.h" 26#include "core.h"
27#include "mem_map.h" 27#include "mem_map.h"
28#include "hw/hw.h"
28#include "arm/disassembler/arm_disasm.h" 29#include "arm/disassembler/arm_disasm.h"
29#include "arm/interpreter/arm_interpreter.h" 30#include "arm/interpreter/arm_interpreter.h"
30 31
@@ -41,7 +42,8 @@ void RunLoop() {
41 42
42/// Step the CPU one instruction 43/// Step the CPU one instruction
43void SingleStep() { 44void SingleStep() {
44 g_app_core->ExecuteInstruction(); 45 g_app_core->Step();
46 HW::Update();
45} 47}
46 48
47/// Halt the core 49/// Halt the core
@@ -69,6 +71,8 @@ void Shutdown() {
69 delete g_disasm; 71 delete g_disasm;
70 delete g_app_core; 72 delete g_app_core;
71 delete g_sys_core; 73 delete g_sys_core;
74
75 NOTICE_LOG(MASTER_LOG, "Core shutdown OK");
72} 76}
73 77
74} // namespace 78} // namespace
diff --git a/src/core/src/core.h b/src/core/src/core.h
index 2e7b355f2..a71e4ed8d 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
56int Init(); 56int Init();
57 57
58/// Shutdown the core
59void Shutdown();
60
58} // namespace 61} // namespace
59 62
60//////////////////////////////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/src/hw/hw.cpp b/src/core/src/hw/hw.cpp
new file mode 100644
index 000000000..50001c87a
--- /dev/null
+++ b/src/core/src/hw/hw.cpp
@@ -0,0 +1,69 @@
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#include "hw/hw_lcd.h"
28
29namespace HW {
30
31template <typename T>
32inline void Read(T &var, const u32 addr) {
33 NOTICE_LOG(HW, "Hardware read from address %08X", addr);
34}
35
36template <typename T>
37inline void Write(u32 addr, const T data) {
38 NOTICE_LOG(HW, "Hardware write to address %08X", addr);
39}
40
41// Explicitly instantiate template functions because we aren't defining this in the header:
42
43template void Read<u64>(u64 &var, const u32 addr);
44template void Read<u32>(u32 &var, const u32 addr);
45template void Read<u16>(u16 &var, const u32 addr);
46template void Read<u8>(u8 &var, const u32 addr);
47
48template void Write<const u64>(u32 addr, const u64 data);
49template void Write<const u32>(u32 addr, const u32 data);
50template void Write<const u16>(u32 addr, const u16 data);
51template void Write<const u8>(u32 addr, const u8 data);
52
53/// Update hardware
54void Update() {
55 LCD::Update();
56}
57
58/// Initialize hardware
59void Init() {
60 LCD::Init();
61 NOTICE_LOG(HW, "Hardware initialized OK");
62}
63
64/// Shutdown hardware
65void Shutdown() {
66 NOTICE_LOG(HW, "Hardware shutdown OK");
67}
68
69} \ 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..245822423
--- /dev/null
+++ b/src/core/src/hw/hw.h
@@ -0,0 +1,44 @@
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
27namespace HW {
28
29template <typename T>
30inline void Read(T &var, const u32 addr);
31
32template <typename T>
33inline void Write(u32 addr, const T data);
34
35/// Update hardware
36void Update();
37
38/// Initialize hardware
39void Init();
40
41/// Shutdown hardware
42void Shutdown();
43
44} // namespace
diff --git a/src/core/src/hw/hw_lcd.cpp b/src/core/src/hw/hw_lcd.cpp
new file mode 100644
index 000000000..ee806d5dc
--- /dev/null
+++ b/src/core/src/hw/hw_lcd.cpp
@@ -0,0 +1,65 @@
1/**
2 * Copyright (C) 2013 Citrus Emulator
3 *
4 * @file hw_lcd.cpp
5 * @author bunnei
6 * @date 2014-04-05
7 * @brief Hardware LCD 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 "core.h"
27#include "hw_lcd.h"
28#include "video_core.h"
29
30namespace LCD {
31
32static const u32 kFrameTicks = 268123480 / 60; ///< 268MHz / 60 frames per second
33
34u64 g_last_ticks = 0; ///< Last CPU ticks
35
36template <typename T>
37inline void Read(T &var, const u32 addr) {
38}
39
40template <typename T>
41inline void Write(u32 addr, const T data) {
42}
43
44/// Update hardware
45void Update() {
46 u64 current_ticks = Core::g_app_core->GetTicks();
47
48 if ((current_ticks - g_last_ticks) >= kFrameTicks) {
49 g_last_ticks = current_ticks;
50 VideoCore::g_renderer->SwapBuffers();
51 }
52}
53
54/// Initialize hardware
55void Init() {
56 g_last_ticks = Core::g_app_core->GetTicks();
57 NOTICE_LOG(LCD, "LCD initialized OK");
58}
59
60/// Shutdown hardware
61void Shutdown() {
62 NOTICE_LOG(LCD, "LCD shutdown OK");
63}
64
65} // namespace
diff --git a/src/core/src/hw/hw_lcd.h b/src/core/src/hw/hw_lcd.h
new file mode 100644
index 000000000..fa19b1cd4
--- /dev/null
+++ b/src/core/src/hw/hw_lcd.h
@@ -0,0 +1,64 @@
1/**
2 * Copyright (C) 2013 Citrus Emulator
3 *
4 * @file hw_lcd.h
5 * @author bunnei
6 * @date 2014-04-05
7 * @brief Hardware LCD 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#pragma once
26
27#include "common_types.h"
28
29namespace LCD {
30
31enum {
32 TOP_ASPECT_X = 0x5,
33 TOP_ASPECT_Y = 0x3,
34
35 TOP_HEIGHT = 240,
36 TOP_WIDTH = 400,
37 BOTTOM_WIDTH = 320,
38
39 FRAMEBUFFER_SEL = 0x20184E59,
40 TOP_LEFT_FRAME1 = 0x20184E60,
41 TOP_LEFT_FRAME2 = 0x201CB370,
42 TOP_RIGHT_FRAME1 = 0x20282160,
43 TOP_RIGHT_FRAME2 = 0x202C8670,
44 SUB_FRAME1 = 0x202118E0,
45 SUB_FRAME2 = 0x20249CF0,
46};
47
48template <typename T>
49inline void Read(T &var, const u32 addr);
50
51template <typename T>
52inline void Write(u32 addr, const T data);
53
54/// Update hardware
55void Update();
56
57/// Initialize hardware
58void Init();
59
60/// Shutdown hardware
61void Shutdown();
62
63
64} // namespace
diff --git a/src/core/src/mem_map_funcs.cpp b/src/core/src/mem_map_funcs.cpp
index 18959dc70..ee2f79278 100644
--- a/src/core/src/mem_map_funcs.cpp
+++ b/src/core/src/mem_map_funcs.cpp
@@ -25,17 +25,23 @@
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
29namespace Memory { 30namespace Memory {
30 31
31template <typename T> 32template <typename T>
32inline void ReadFromHardware(T &var, const u32 addr) { 33inline 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
@@ -54,15 +60,20 @@ inline void ReadFromHardware(T &var, const u32 addr) {
54 var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]); 60 var = *((const T*)&g_fcram[addr & MEM_FCRAM_MASK]);
55 61
56 } else { 62 } else {
57 _assert_msg_(MEMMAP, false, "unknown hardware read"); 63 _assert_msg_(MEMMAP, false, "unknown memory read");
58 // WARN_LOG(MEMMAP, "ReadFromHardware: Invalid addr %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
59 } 64 }
60} 65}
61 66
62template <typename T> 67template <typename T>
63inline void WriteToHardware(u32 addr, const T data) { 68inline 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
64 // ExeFS:/.code is loaded here: 75 // ExeFS:/.code is loaded here:
65 if ((addr & 0xFFF00000) == 0x00100000) { 76 } else if ((addr & 0xFFF00000) == 0x00100000) {
66 // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew: 77 // TODO(ShizZy): This is dumb... handle correctly. From 3DBrew:
67 // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions 78 // http://3dbrew.org/wiki/Memory_layout#ARM11_User-land_memory_regions
68 // 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
@@ -104,7 +115,7 @@ inline void WriteToHardware(u32 addr, const T data) {
104 115
105 // Error out... 116 // Error out...
106 } else { 117 } else {
107 _assert_msg_(MEMMAP, false, "unknown hardware write"); 118 _assert_msg_(MEMMAP, false, "unknown memory write");
108 } 119 }
109} 120}
110 121
@@ -126,14 +137,21 @@ u8 *GetPointer(const u32 addr) {
126 // TODO(bunnei): Just a stub for now... ImplementMe! 137 // TODO(bunnei): Just a stub for now... ImplementMe!
127 if ((addr & 0x3E000000) == 0x08000000) { 138 if ((addr & 0x3E000000) == 0x08000000) {
128 return g_fcram + (addr & MEM_FCRAM_MASK); 139 return g_fcram + (addr & MEM_FCRAM_MASK);
129 } 140
141 // HACK(bunnei): There is no layer yet to translate virtual addresses to physical addresses.
142 // Until we progress far enough along, we'll accept all physical address reads here. I think
143 // that this is typically a corner-case from usermode software unless they are trying to do
144 // bare-metal things (e.g. early 3DS homebrew writes directly to the FB @ 0x20184E60, etc.
145 } else if (((addr & 0xF0000000) == MEM_FCRAM_PADDR) && (addr < (MEM_FCRAM_PADDR_END))) {
146 return g_fcram + (addr & MEM_FCRAM_MASK);
147
130 //else if ((addr & 0x3F800000) == 0x04000000) { 148 //else if ((addr & 0x3F800000) == 0x04000000) {
131 // return g_vram + (addr & MEM_VRAM_MASK); 149 // return g_vram + (addr & MEM_VRAM_MASK);
132 //} 150 //}
133 //else if ((addr & 0x3F000000) >= 0x08000000 && (addr & 0x3F000000) < 0x08000000 + g_MemorySize) { 151 //else if ((addr & 0x3F000000) >= 0x08000000 && (addr & 0x3F000000) < 0x08000000 + g_MemorySize) {
134 // return m_pRAM + (addr & g_MemoryMask); 152 // return m_pRAM + (addr & g_MemoryMask);
135 //} 153 //}
136 else { 154 } else {
137 //ERROR_LOG(MEMMAP, "Unknown GetPointer %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]); 155 //ERROR_LOG(MEMMAP, "Unknown GetPointer %08x PC %08x LR %08x", addr, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
138 ERROR_LOG(MEMMAP, "Unknown GetPointer %08x", addr); 156 ERROR_LOG(MEMMAP, "Unknown GetPointer %08x", addr);
139 static bool reported = false; 157 static bool reported = false;
@@ -151,25 +169,25 @@ u8 *GetPointer(const u32 addr) {
151 169
152u8 Read8(const u32 addr) { 170u8 Read8(const u32 addr) {
153 u8 _var = 0; 171 u8 _var = 0;
154 ReadFromHardware<u8>(_var, addr); 172 _Read<u8>(_var, addr);
155 return (u8)_var; 173 return (u8)_var;
156} 174}
157 175
158u16 Read16(const u32 addr) { 176u16 Read16(const u32 addr) {
159 u16_le _var = 0; 177 u16_le _var = 0;
160 ReadFromHardware<u16_le>(_var, addr); 178 _Read<u16_le>(_var, addr);
161 return (u16)_var; 179 return (u16)_var;
162} 180}
163 181
164u32 Read32(const u32 addr) { 182u32 Read32(const u32 addr) {
165 u32_le _var = 0; 183 u32_le _var = 0;
166 ReadFromHardware<u32_le>(_var, addr); 184 _Read<u32_le>(_var, addr);
167 return _var; 185 return _var;
168} 186}
169 187
170u64 Read64(const u32 addr) { 188u64 Read64(const u32 addr) {
171 u64_le _var = 0; 189 u64_le _var = 0;
172 ReadFromHardware<u64_le>(_var, addr); 190 _Read<u64_le>(_var, addr);
173 return _var; 191 return _var;
174} 192}
175 193
@@ -182,19 +200,19 @@ u32 Read16_ZX(const u32 addr) {
182} 200}
183 201
184void Write8(const u32 addr, const u8 data) { 202void Write8(const u32 addr, const u8 data) {
185 WriteToHardware<u8>(addr, data); 203 _Write<u8>(addr, data);
186} 204}
187 205
188void Write16(const u32 addr, const u16 data) { 206void Write16(const u32 addr, const u16 data) {
189 WriteToHardware<u16_le>(addr, data); 207 _Write<u16_le>(addr, data);
190} 208}
191 209
192void Write32(const u32 addr, const u32 data) { 210void Write32(const u32 addr, const u32 data) {
193 WriteToHardware<u32_le>(addr, data); 211 _Write<u32_le>(addr, data);
194} 212}
195 213
196void Write64(const u32 addr, const u64 data) { 214void Write64(const u32 addr, const u64 data) {
197 WriteToHardware<u64_le>(addr, data); 215 _Write<u64_le>(addr, data);
198} 216}
199 217
200} // namespace 218} // namespace
diff --git a/src/core/src/system.cpp b/src/core/src/system.cpp
index 6a2c13c96..7c829d609 100644
--- a/src/core/src/system.cpp
+++ b/src/core/src/system.cpp
@@ -23,9 +23,11 @@
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"
30#include "video_core.h"
29 31
30namespace System { 32namespace System {
31 33
@@ -38,7 +40,9 @@ void UpdateState(State state) {
38void Init(EmuWindow* emu_window) { 40void Init(EmuWindow* emu_window) {
39 Core::Init(); 41 Core::Init();
40 Memory::Init(); 42 Memory::Init();
43 HW::Init();
41 CoreTiming::Init(); 44 CoreTiming::Init();
45 VideoCore::Init(emu_window);
42} 46}
43 47
44void RunLoopFor(int cycles) { 48void RunLoopFor(int cycles) {
@@ -49,9 +53,10 @@ void RunLoopUntil(u64 global_cycles) {
49} 53}
50 54
51void Shutdown() { 55void Shutdown() {
56 Core::Shutdown();
57 HW::Shutdown();
58 VideoCore::Shutdown();
52 g_ctr_file_system.Shutdown(); 59 g_ctr_file_system.Shutdown();
53} 60}
54 61
55
56
57} // namespace 62} // namespace