summaryrefslogtreecommitdiff
path: root/src/core/hw/hw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hw/hw.cpp')
-rw-r--r--src/core/hw/hw.cpp75
1 files changed, 66 insertions, 9 deletions
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 44625e3af..16bd70125 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -6,18 +6,73 @@
6#include "common/log.h" 6#include "common/log.h"
7 7
8#include "core/hw/hw.h" 8#include "core/hw/hw.h"
9#include "core/hw/hw_lcd.h" 9#include "core/hw/lcd.h"
10#include "core/hw/ndma.h"
10 11
11namespace HW { 12namespace HW {
12 13
14enum {
15 ADDRESS_CONFIG = 0x10000000,
16 ADDRESS_IRQ = 0x10001000,
17 ADDRESS_NDMA = 0x10002000,
18 ADDRESS_TIMER = 0x10003000,
19 ADDRESS_CTRCARD = 0x10004000,
20 ADDRESS_CTRCARD_2 = 0x10005000,
21 ADDRESS_SDMC_NAND = 0x10006000,
22 ADDRESS_SDMC_NAND_2 = 0x10007000, // Apparently not used on retail
23 ADDRESS_PXI = 0x10008000,
24 ADDRESS_AES = 0x10009000,
25 ADDRESS_SHA = 0x1000A000,
26 ADDRESS_RSA = 0x1000B000,
27 ADDRESS_XDMA = 0x1000C000,
28 ADDRESS_SPICARD = 0x1000D800,
29 ADDRESS_CONFIG_2 = 0x10010000,
30 ADDRESS_HASH = 0x10101000,
31 ADDRESS_CSND = 0x10103000,
32 ADDRESS_DSP = 0x10140000,
33 ADDRESS_PDN = 0x10141000,
34 ADDRESS_CODEC = 0x10141000,
35 ADDRESS_SPI = 0x10142000,
36 ADDRESS_SPI_2 = 0x10143000,
37 ADDRESS_I2C = 0x10144000,
38 ADDRESS_CODEC_2 = 0x10145000,
39 ADDRESS_HID = 0x10146000,
40 ADDRESS_PAD = 0x10146000,
41 ADDRESS_PTM = 0x10146000,
42 ADDRESS_I2C_2 = 0x10148000,
43 ADDRESS_SPI_3 = 0x10160000,
44 ADDRESS_I2C_3 = 0x10161000,
45 ADDRESS_MIC = 0x10162000,
46 ADDRESS_PXI_2 = 0x10163000,
47 ADDRESS_NTRCARD = 0x10164000,
48 ADDRESS_DSP_2 = 0x10203000,
49 ADDRESS_HASH_2 = 0x10301000,
50};
51
13template <typename T> 52template <typename T>
14inline void Read(T &var, const u32 addr) { 53inline void Read(T &var, const u32 addr) {
15 NOTICE_LOG(HW, "Hardware read from address %08X", addr); 54 switch (addr & 0xFFFFF000) {
55
56 case ADDRESS_NDMA:
57 NDMA::Read(var, addr);
58 break;
59
60 default:
61 ERROR_LOG(HW, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr);
62 }
16} 63}
17 64
18template <typename T> 65template <typename T>
19inline void Write(u32 addr, const T data) { 66inline void Write(u32 addr, const T data) {
20 NOTICE_LOG(HW, "Hardware write to address %08X", addr); 67 switch (addr & 0xFFFFF000) {
68
69 case ADDRESS_NDMA:
70 NDMA::Write(addr, data);
71 break;
72
73 default:
74 ERROR_LOG(HW, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr);
75 }
21} 76}
22 77
23// Explicitly instantiate template functions because we aren't defining this in the header: 78// Explicitly instantiate template functions because we aren't defining this in the header:
@@ -27,25 +82,27 @@ template void Read<u32>(u32 &var, const u32 addr);
27template void Read<u16>(u16 &var, const u32 addr); 82template void Read<u16>(u16 &var, const u32 addr);
28template void Read<u8>(u8 &var, const u32 addr); 83template void Read<u8>(u8 &var, const u32 addr);
29 84
30template void Write<const u64>(u32 addr, const u64 data); 85template void Write<u64>(u32 addr, const u64 data);
31template void Write<const u32>(u32 addr, const u32 data); 86template void Write<u32>(u32 addr, const u32 data);
32template void Write<const u16>(u32 addr, const u16 data); 87template void Write<u16>(u32 addr, const u16 data);
33template void Write<const u8>(u32 addr, const u8 data); 88template void Write<u8>(u32 addr, const u8 data);
34 89
35/// Update hardware 90/// Update hardware
36void Update() { 91void Update() {
37 LCD::Update(); 92 LCD::Update();
93 NDMA::Update();
38} 94}
39 95
40/// Initialize hardware 96/// Initialize hardware
41void Init() { 97void Init() {
42 LCD::Init(); 98 LCD::Init();
43 NOTICE_LOG(HW, "Hardware initialized OK"); 99 NDMA::Init();
100 NOTICE_LOG(HW, "initialized OK");
44} 101}
45 102
46/// Shutdown hardware 103/// Shutdown hardware
47void Shutdown() { 104void Shutdown() {
48 NOTICE_LOG(HW, "Hardware shutdown OK"); 105 NOTICE_LOG(HW, "shutdown OK");
49} 106}
50 107
51} \ No newline at end of file 108} \ No newline at end of file