summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp1
-rw-r--r--src/common/logging/log.h1
-rw-r--r--src/core/hle/service/csnd_snd.cpp128
-rw-r--r--src/core/hle/service/csnd_snd.h13
4 files changed, 94 insertions, 49 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 7fd397fe5..3ea102229 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -50,6 +50,7 @@ namespace Log {
50 SUB(Service, CAM) \ 50 SUB(Service, CAM) \
51 SUB(Service, CECD) \ 51 SUB(Service, CECD) \
52 SUB(Service, CFG) \ 52 SUB(Service, CFG) \
53 SUB(Service, CSND) \
53 SUB(Service, DSP) \ 54 SUB(Service, DSP) \
54 SUB(Service, DLP) \ 55 SUB(Service, DLP) \
55 SUB(Service, HID) \ 56 SUB(Service, HID) \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 96d0dfb8c..9d8c18d8e 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -67,6 +67,7 @@ enum class Class : ClassType {
67 Service_CAM, ///< The CAM (Camera) service 67 Service_CAM, ///< The CAM (Camera) service
68 Service_CECD, ///< The CECD (StreetPass) service 68 Service_CECD, ///< The CECD (StreetPass) service
69 Service_CFG, ///< The CFG (Configuration) service 69 Service_CFG, ///< The CFG (Configuration) service
70 Service_CSND, ///< The CSND (CWAV format process) service
70 Service_DSP, ///< The DSP (DSP control) service 71 Service_DSP, ///< The DSP (DSP control) service
71 Service_DLP, ///< The DLP (Download Play) service 72 Service_DLP, ///< The DLP (Download Play) service
72 Service_HID, ///< The HID (Human interface device) service 73 Service_HID, ///< The HID (Human interface device) service
diff --git a/src/core/hle/service/csnd_snd.cpp b/src/core/hle/service/csnd_snd.cpp
index 6544e89a2..6cf62f9bc 100644
--- a/src/core/hle/service/csnd_snd.cpp
+++ b/src/core/hle/service/csnd_snd.cpp
@@ -4,7 +4,6 @@
4 4
5#include <cstring> 5#include <cstring>
6#include "common/alignment.h" 6#include "common/alignment.h"
7#include "core/hle/hle.h"
8#include "core/hle/kernel/mutex.h" 7#include "core/hle/kernel/mutex.h"
9#include "core/hle/kernel/shared_memory.h" 8#include "core/hle/kernel/shared_memory.h"
10#include "core/hle/service/csnd_snd.h" 9#include "core/hle/service/csnd_snd.h"
@@ -12,72 +11,129 @@
12namespace Service { 11namespace Service {
13namespace CSND { 12namespace CSND {
14 13
15const Interface::FunctionInfo FunctionTable[] = { 14struct Type0Command {
16 {0x00010140, Initialize, "Initialize"}, 15 // command id and next command offset
17 {0x00020000, Shutdown, "Shutdown"}, 16 u32 command_id;
18 {0x00030040, ExecuteType0Commands, "ExecuteType0Commands"}, 17 u32 finished;
19 {0x00040080, nullptr, "ExecuteType1Commands"}, 18 u32 flags;
20 {0x00050000, AcquireSoundChannels, "AcquireSoundChannels"}, 19 u8 parameters[20];
21 {0x00060000, nullptr, "ReleaseSoundChannels"},
22 {0x00070000, nullptr, "AcquireCaptureDevice"},
23 {0x00080040, nullptr, "ReleaseCaptureDevice"},
24 {0x00090082, nullptr, "FlushDataCache"},
25 {0x000A0082, nullptr, "StoreDataCache"},
26 {0x000B0082, nullptr, "InvalidateDataCache"},
27 {0x000C0000, nullptr, "Reset"},
28}; 20};
29 21static_assert(sizeof(Type0Command) == 0x20, "Type0Command structure size is wrong");
30CSND_SND::CSND_SND() {
31 Register(FunctionTable);
32}
33 22
34static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr; 23static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory = nullptr;
35static Kernel::SharedPtr<Kernel::Mutex> mutex = nullptr; 24static Kernel::SharedPtr<Kernel::Mutex> mutex = nullptr;
36 25
37void Initialize(Interface* self) { 26/**
27 * CSND_SND::Initialize service function
28 * Inputs:
29 * 0 : Header Code[0x00010140]
30 * 1 : Shared memory block size, for mem-block creation
31 * Outputs:
32 * 1 : Result of function, 0 on success, otherwise error code
33 * 2 : Handle-list header
34 * 3 : Mutex handle
35 * 4 : Shared memory block handle
36 */
37static void Initialize(Interface* self) {
38 u32* cmd_buff = Kernel::GetCommandBuffer(); 38 u32* cmd_buff = Kernel::GetCommandBuffer();
39 39
40 u32 size = Common::AlignUp(cmd_buff[1], Memory::PAGE_SIZE); 40 u32 size = Common::AlignUp(cmd_buff[1], Memory::PAGE_SIZE);
41
41 using Kernel::MemoryPermission; 42 using Kernel::MemoryPermission;
42 shared_memory = Kernel::SharedMemory::Create(nullptr, size, MemoryPermission::ReadWrite, 43 shared_memory = Kernel::SharedMemory::Create(nullptr, size, MemoryPermission::ReadWrite,
43 MemoryPermission::ReadWrite, 0, 44 MemoryPermission::ReadWrite, 0,
44 Kernel::MemoryRegion::BASE, "CSND:SharedMemory"); 45 Kernel::MemoryRegion::BASE, "CSND:SharedMemory");
45 46
46 mutex = Kernel::Mutex::Create(false); 47 mutex = Kernel::Mutex::Create(false, "CSND:mutex");
47 48
48 cmd_buff[1] = RESULT_SUCCESS.raw; 49 cmd_buff[1] = RESULT_SUCCESS.raw;
49 cmd_buff[2] = IPC::CopyHandleDesc(2); 50 cmd_buff[2] = IPC::CopyHandleDesc(2);
50 cmd_buff[3] = Kernel::g_handle_table.Create(mutex).MoveFrom(); 51 cmd_buff[3] = Kernel::g_handle_table.Create(mutex).MoveFrom();
51 cmd_buff[4] = Kernel::g_handle_table.Create(shared_memory).MoveFrom(); 52 cmd_buff[4] = Kernel::g_handle_table.Create(shared_memory).MoveFrom();
53
54 LOG_WARNING(Service_CSND, "(STUBBED) called");
52} 55}
53 56
54void ExecuteType0Commands(Interface* self) { 57/**
55 u32* const cmd_buff = Kernel::GetCommandBuffer(); 58 * CSND_SND::Shutdown service function
56 u8* const ptr = shared_memory->GetPointer(cmd_buff[1]); 59 * Inputs:
60 * 0 : Header Code[0x00020000]
61 * Outputs:
62 * 1 : Result of function, 0 on success, otherwise error code
63 */
64static void Shutdown(Interface* self) {
65 u32* cmd_buff = Kernel::GetCommandBuffer();
66
67 shared_memory = nullptr;
68 mutex = nullptr;
57 69
58 if (shared_memory != nullptr && ptr != nullptr) { 70 cmd_buff[1] = RESULT_SUCCESS.raw;
59 Type0Command command; 71 LOG_WARNING(Service_CSND, "(STUBBED) called");
60 std::memcpy(&command, ptr, sizeof(Type0Command)); 72}
61 73
62 LOG_WARNING(Service, "(STUBBED) CSND_SND::ExecuteType0Commands"); 74/**
63 command.finished |= 1; 75 * CSND_SND::ExecuteCommands service function
64 cmd_buff[1] = 0; 76 * Inputs:
77 * 0 : Header Code[0x00030040]
78 * 1 : Command offset in shared memory.
79 * Outputs:
80 * 1 : Result of function, 0 on success, otherwise error code
81 * 2 : Available channel bit mask
82 */
83static void ExecuteCommands(Interface* self) {
84 u32* cmd_buff = Kernel::GetCommandBuffer();
65 85
66 std::memcpy(ptr, &command, sizeof(Type0Command)); 86 if (shared_memory == nullptr) {
67 } else {
68 cmd_buff[1] = 1; 87 cmd_buff[1] = 1;
88 LOG_ERROR(Service_CSND, "called, shared memory not allocated");
89 return;
69 } 90 }
91
92 VAddr addr = cmd_buff[1];
93 u8* ptr = shared_memory->GetPointer(addr);
94
95 Type0Command command;
96 std::memcpy(&command, ptr, sizeof(Type0Command));
97 command.finished |= 1;
98 std::memcpy(ptr, &command, sizeof(Type0Command));
99
100 cmd_buff[1] = RESULT_SUCCESS.raw;
101
102 LOG_WARNING(Service_CSND, "(STUBBED) called, addr=0x%08X", addr);
70} 103}
71 104
72void AcquireSoundChannels(Interface* self) { 105/**
106 * CSND_SND::AcquireSoundChannels service function
107 * Inputs:
108 * 0 : Header Code[0x00050000]
109 * Outputs:
110 * 1 : Result of function, 0 on success, otherwise error code
111 * 2 : Available channel bit mask
112 */
113static void AcquireSoundChannels(Interface* self) {
73 u32* cmd_buff = Kernel::GetCommandBuffer(); 114 u32* cmd_buff = Kernel::GetCommandBuffer();
74 cmd_buff[1] = 0; 115 cmd_buff[1] = RESULT_SUCCESS.raw;
75 cmd_buff[2] = 0xFFFFFF00; 116 cmd_buff[2] = 0xFFFFFF00;
117 LOG_WARNING(Service_CSND, "(STUBBED) called");
76} 118}
77 119
78void Shutdown(Interface* self) { 120const Interface::FunctionInfo FunctionTable[] = {
79 shared_memory = nullptr; 121 {0x00010140, Initialize, "Initialize"},
80 mutex = nullptr; 122 {0x00020000, Shutdown, "Shutdown"},
123 {0x00030040, ExecuteCommands, "ExecuteCommands"},
124 {0x00040080, nullptr, "ExecuteType1Commands"},
125 {0x00050000, AcquireSoundChannels, "AcquireSoundChannels"},
126 {0x00060000, nullptr, "ReleaseSoundChannels"},
127 {0x00070000, nullptr, "AcquireCaptureDevice"},
128 {0x00080040, nullptr, "ReleaseCaptureDevice"},
129 {0x00090082, nullptr, "FlushDataCache"},
130 {0x000A0082, nullptr, "StoreDataCache"},
131 {0x000B0082, nullptr, "InvalidateDataCache"},
132 {0x000C0000, nullptr, "Reset"},
133};
134
135CSND_SND::CSND_SND() {
136 Register(FunctionTable);
81} 137}
82 138
83} // namespace CSND 139} // namespace CSND
diff --git a/src/core/hle/service/csnd_snd.h b/src/core/hle/service/csnd_snd.h
index c8d83fa7d..ca6d4513e 100644
--- a/src/core/hle/service/csnd_snd.h
+++ b/src/core/hle/service/csnd_snd.h
@@ -18,18 +18,5 @@ public:
18 } 18 }
19}; 19};
20 20
21struct Type0Command {
22 // command id and next command offset
23 u32 command_id;
24 u32 finished;
25 u32 flags;
26 u8 parameters[20];
27};
28
29void Initialize(Interface* self);
30void ExecuteType0Commands(Interface* self);
31void AcquireSoundChannels(Interface* self);
32void Shutdown(Interface* self);
33
34} // namespace CSND 21} // namespace CSND
35} // namespace Service 22} // namespace Service