summaryrefslogtreecommitdiff
path: root/src/core/hw
diff options
context:
space:
mode:
authorGravatar bunnei2014-04-17 23:43:55 -0400
committerGravatar bunnei2014-04-17 23:43:55 -0400
commitc3a4b4bfca154f3f27830fe747c0fd74f8459d84 (patch)
tree3c91454f16cafa94f2076d55998d411236eaf066 /src/core/hw
parentadded GSP heap memory allocation (diff)
downloadyuzu-c3a4b4bfca154f3f27830fe747c0fd74f8459d84.tar.gz
yuzu-c3a4b4bfca154f3f27830fe747c0fd74f8459d84.tar.xz
yuzu-c3a4b4bfca154f3f27830fe747c0fd74f8459d84.zip
added NDMA hardware interface
Diffstat (limited to 'src/core/hw')
-rw-r--r--src/core/hw/hw.cpp61
-rw-r--r--src/core/hw/ndma.cpp48
-rw-r--r--src/core/hw/ndma.h26
3 files changed, 133 insertions, 2 deletions
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 59c348ca9..1f240f09c 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -7,17 +7,72 @@
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/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, "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, "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:
@@ -35,11 +90,13 @@ template void Write<u8>(u32 addr, const u8 data);
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();
99 NDMA::Init();
43 NOTICE_LOG(HW, "initialized OK"); 100 NOTICE_LOG(HW, "initialized OK");
44} 101}
45 102
diff --git a/src/core/hw/ndma.cpp b/src/core/hw/ndma.cpp
new file mode 100644
index 000000000..52e459ebd
--- /dev/null
+++ b/src/core/hw/ndma.cpp
@@ -0,0 +1,48 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#include "common/common_types.h"
6#include "common/log.h"
7
8#include "core/hw/ndma.h"
9
10namespace NDMA {
11
12template <typename T>
13inline void Read(T &var, const u32 addr) {
14 ERROR_LOG(NDMA, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr);
15}
16
17template <typename T>
18inline void Write(u32 addr, const T data) {
19 ERROR_LOG(NDMA, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr);
20}
21
22// Explicitly instantiate template functions because we aren't defining this in the header:
23
24template void Read<u64>(u64 &var, const u32 addr);
25template void Read<u32>(u32 &var, const u32 addr);
26template void Read<u16>(u16 &var, const u32 addr);
27template void Read<u8>(u8 &var, const u32 addr);
28
29template void Write<u64>(u32 addr, const u64 data);
30template void Write<u32>(u32 addr, const u32 data);
31template void Write<u16>(u32 addr, const u16 data);
32template void Write<u8>(u32 addr, const u8 data);
33
34/// Update hardware
35void Update() {
36}
37
38/// Initialize hardware
39void Init() {
40 NOTICE_LOG(LCD, "initialized OK");
41}
42
43/// Shutdown hardware
44void Shutdown() {
45 NOTICE_LOG(LCD, "shutdown OK");
46}
47
48} // namespace
diff --git a/src/core/hw/ndma.h b/src/core/hw/ndma.h
new file mode 100644
index 000000000..d8fa3d40b
--- /dev/null
+++ b/src/core/hw/ndma.h
@@ -0,0 +1,26 @@
1// Copyright 2014 Citra Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9namespace NDMA {
10
11template <typename T>
12inline void Read(T &var, const u32 addr);
13
14template <typename T>
15inline void Write(u32 addr, const T data);
16
17/// Update hardware
18void Update();
19
20/// Initialize hardware
21void Init();
22
23/// Shutdown hardware
24void Shutdown();
25
26} // namespace