[DSP] Add empty service

This commit is contained in:
wheremyfoodat 2022-10-10 17:50:26 +03:00
parent 6c3acda34e
commit 4c8ddd2f10
7 changed files with 50 additions and 4 deletions

View file

@ -55,7 +55,7 @@ set(KERNEL_SOURCE_FILES src/core/kernel/kernel.cpp src/core/kernel/resource_limi
)
set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services/apt.cpp src/core/services/hid.cpp
src/core/services/fs.cpp src/core/services/gsp_gpu.cpp src/core/services/gsp_lcd.cpp
src/core/services/ndm.cpp
src/core/services/ndm.cpp src/core/services/dsp.cpp
)
set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp
src/core/PICA/shader_interpreter.cpp src/core/PICA/renderer_opengl.cpp
@ -73,6 +73,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc
include/PICA/shader.hpp include/PICA/shader_unit.hpp include/PICA/float_types.hpp
include/logger.hpp include/loader/ncch.hpp include/loader/ncsd.hpp include/io_file.hpp
include/loader/lz77.hpp include/fs/archive_base.hpp include/fs/archive_ncch.hpp
include/services/dsp.hpp
)
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp

View file

@ -14,8 +14,9 @@ namespace KernelHandles {
HID = 0xFFFF8003, // Handles everything input-related including gyro
FS = 0xFFFF8004, // Filesystem service
GPU = 0xFFFF8005, // GPU service
LCD = 0xFFFF8006, // LCD service
NDM = 0xFFFF8007, // ?????
DSP = 0xFFFF8006, // DSP service (Used for audio decoding and output)
LCD = 0xFFFF8007, // LCD service (Used for configuring the displays)
NDM = 0xFFFF8008, // ?????
MinServiceHandle = APT,
MaxServiceHandle = NDM,
@ -49,6 +50,7 @@ namespace KernelHandles {
case APT: return "APT";
case HID: return "HID";
case FS: return "FS";
case DSP: return "DSP";
case GPU: return "GPU";
case LCD: return "LCD";
case NDM: return "NDM";

View file

@ -27,6 +27,7 @@ namespace Log {
// Service loggers
static Logger<true> aptLogger;
static Logger<true> dspServiceLogger;
static Logger<true> fsLogger;
static Logger<true> hidLogger;
static Logger<true> gspGPULogger;

15
include/services/dsp.hpp Normal file
View file

@ -0,0 +1,15 @@
#pragma once
#include "helpers.hpp"
#include "logger.hpp"
#include "memory.hpp"
class DSPService {
Handle handle = KernelHandles::DSP;
Memory& mem;
MAKE_LOG_FUNCTION(log, dspServiceLogger)
public:
DSPService(Memory& mem) : mem(mem) {}
void reset();
void handleSyncRequest(u32 messagePointer);
};

View file

@ -4,6 +4,7 @@
#include "logger.hpp"
#include "memory.hpp"
#include "services/apt.hpp"
#include "services/dsp.hpp"
#include "services/hid.hpp"
#include "services/fs.hpp"
#include "services/gsp_gpu.hpp"
@ -18,6 +19,7 @@ class ServiceManager {
MAKE_LOG_FUNCTION(log, srvLogger)
APTService apt;
DSPService dsp;
HIDService hid;
FSService fs;
GPUService gsp_gpu;

21
src/core/services/dsp.cpp Normal file
View file

@ -0,0 +1,21 @@
#include "services/dsp.hpp"
namespace DSPCommands {
enum : u32 {
};
}
namespace Result {
enum : u32 {
Success = 0,
};
}
void DSPService::reset() {}
void DSPService::handleSyncRequest(u32 messagePointer) {
const u32 command = mem.read32(messagePointer);
switch (command) {
default: Helpers::panic("LCD service requested. Command: %08X\n", command);
}
}

View file

@ -1,10 +1,11 @@
#include "services/service_manager.hpp"
ServiceManager::ServiceManager(std::array<u32, 16>& regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
: regs(regs), mem(mem), apt(mem), hid(mem), fs(mem, kernel), gsp_gpu(mem, gpu, currentPID), gsp_lcd(mem), ndm(mem) {}
: regs(regs), mem(mem), apt(mem), dsp(mem), hid(mem), fs(mem, kernel), gsp_gpu(mem, gpu, currentPID), gsp_lcd(mem), ndm(mem) {}
void ServiceManager::reset() {
apt.reset();
dsp.reset();
hid.reset();
fs.reset();
gsp_gpu.reset();
@ -74,6 +75,8 @@ void ServiceManager::getServiceHandle(u32 messagePointer) {
handle = KernelHandles::APT;
} else if (service == "APT:U") {
handle = KernelHandles::APT;
} else if (service == "dsp::DSP") {
handle = KernelHandles::DSP;
} else if (service == "hid:USER") {
handle = KernelHandles::HID;
} else if (service == "fs:USER") {
@ -111,6 +114,7 @@ void ServiceManager::receiveNotification(u32 messagePointer) {
void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) {
switch (handle) {
case KernelHandles::APT: apt.handleSyncRequest(messagePointer); break;
case KernelHandles::DSP: dsp.handleSyncRequest(messagePointer); break;
case KernelHandles::HID: hid.handleSyncRequest(messagePointer); break;
case KernelHandles::FS: fs.handleSyncRequest(messagePointer); break;
case KernelHandles::GPU: [[likely]] gsp_gpu.handleSyncRequest(messagePointer); break;