summaryrefslogtreecommitdiff
path: root/src/audio_core/hle
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-04-30 21:36:00 -0700
committerGravatar Yuri Kunde Schlesner2017-05-09 21:44:00 -0700
commitb4a93cfddecdb939562e56d7609657d2f14b6702 (patch)
tree75da1f521209b74fa82a982356b878bd1c475562 /src/audio_core/hle
parentMemory: Add constants for the n3DS additional RAM (diff)
downloadyuzu-b4a93cfddecdb939562e56d7609657d2f14b6702.tar.gz
yuzu-b4a93cfddecdb939562e56d7609657d2f14b6702.tar.xz
yuzu-b4a93cfddecdb939562e56d7609657d2f14b6702.zip
DSP: Create backing memory for entire DSP RAM
Also move address space mapping out of video_core.
Diffstat (limited to 'src/audio_core/hle')
-rw-r--r--src/audio_core/hle/dsp.cpp14
-rw-r--r--src/audio_core/hle/dsp.h21
2 files changed, 26 insertions, 9 deletions
diff --git a/src/audio_core/hle/dsp.cpp b/src/audio_core/hle/dsp.cpp
index 31421fdc6..260b182ed 100644
--- a/src/audio_core/hle/dsp.cpp
+++ b/src/audio_core/hle/dsp.cpp
@@ -16,31 +16,33 @@ namespace HLE {
16 16
17// Region management 17// Region management
18 18
19std::array<SharedMemory, 2> g_regions; 19DspMemory g_dsp_memory;
20 20
21static size_t CurrentRegionIndex() { 21static size_t CurrentRegionIndex() {
22 // The region with the higher frame counter is chosen unless there is wraparound. 22 // The region with the higher frame counter is chosen unless there is wraparound.
23 // This function only returns a 0 or 1. 23 // This function only returns a 0 or 1.
24 u16 frame_counter_0 = g_dsp_memory.region_0.frame_counter;
25 u16 frame_counter_1 = g_dsp_memory.region_1.frame_counter;
24 26
25 if (g_regions[0].frame_counter == 0xFFFFu && g_regions[1].frame_counter != 0xFFFEu) { 27 if (frame_counter_0 == 0xFFFFu && frame_counter_1 != 0xFFFEu) {
26 // Wraparound has occurred. 28 // Wraparound has occurred.
27 return 1; 29 return 1;
28 } 30 }
29 31
30 if (g_regions[1].frame_counter == 0xFFFFu && g_regions[0].frame_counter != 0xFFFEu) { 32 if (frame_counter_1 == 0xFFFFu && frame_counter_0 != 0xFFFEu) {
31 // Wraparound has occurred. 33 // Wraparound has occurred.
32 return 0; 34 return 0;
33 } 35 }
34 36
35 return (g_regions[0].frame_counter > g_regions[1].frame_counter) ? 0 : 1; 37 return (frame_counter_0 > frame_counter_1) ? 0 : 1;
36} 38}
37 39
38static SharedMemory& ReadRegion() { 40static SharedMemory& ReadRegion() {
39 return g_regions[CurrentRegionIndex()]; 41 return CurrentRegionIndex() == 0 ? g_dsp_memory.region_0 : g_dsp_memory.region_1;
40} 42}
41 43
42static SharedMemory& WriteRegion() { 44static SharedMemory& WriteRegion() {
43 return g_regions[1 - CurrentRegionIndex()]; 45 return CurrentRegionIndex() != 0 ? g_dsp_memory.region_0 : g_dsp_memory.region_1;
44} 46}
45 47
46// Audio processing and mixing 48// Audio processing and mixing
diff --git a/src/audio_core/hle/dsp.h b/src/audio_core/hle/dsp.h
index 0a0f60ac1..94ce48863 100644
--- a/src/audio_core/hle/dsp.h
+++ b/src/audio_core/hle/dsp.h
@@ -31,8 +31,8 @@ namespace HLE {
31// double-buffer. The frame counter is located as the very last u16 of each region and is 31// double-buffer. The frame counter is located as the very last u16 of each region and is
32// incremented each audio tick. 32// incremented each audio tick.
33 33
34constexpr VAddr region0_base = 0x1FF50000; 34constexpr u32 region0_offset = 0x50000;
35constexpr VAddr region1_base = 0x1FF70000; 35constexpr u32 region1_offset = 0x70000;
36 36
37/** 37/**
38 * The DSP is native 16-bit. The DSP also appears to be big-endian. When reading 32-bit numbers from 38 * The DSP is native 16-bit. The DSP also appears to be big-endian. When reading 32-bit numbers from
@@ -512,7 +512,22 @@ struct SharedMemory {
512}; 512};
513ASSERT_DSP_STRUCT(SharedMemory, 0x8000); 513ASSERT_DSP_STRUCT(SharedMemory, 0x8000);
514 514
515extern std::array<SharedMemory, 2> g_regions; 515union DspMemory {
516 std::array<u8, 0x80000> raw_memory;
517 struct {
518 u8 unused_0[0x50000];
519 SharedMemory region_0;
520 u8 unused_1[0x18000];
521 SharedMemory region_1;
522 u8 unused_2[0x8000];
523 };
524};
525static_assert(offsetof(DspMemory, region_0) == region0_offset,
526 "DSP region 0 is at the wrong offset");
527static_assert(offsetof(DspMemory, region_1) == region1_offset,
528 "DSP region 1 is at the wrong offset");
529
530extern DspMemory g_dsp_memory;
516 531
517// Structures must have an offset that is a multiple of two. 532// Structures must have an offset that is a multiple of two.
518static_assert(offsetof(SharedMemory, frame_counter) % 2 == 0, 533static_assert(offsetof(SharedMemory, frame_counter) % 2 == 0,