Add soc:u

This commit is contained in:
wheremyfoodat 2023-08-10 17:44:42 +03:00
parent 01a7985324
commit 2bb751110b
7 changed files with 66 additions and 2 deletions

View file

@ -134,7 +134,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services
src/core/services/frd.cpp src/core/services/nim.cpp src/core/services/shared_font.cpp
src/core/services/y2r.cpp src/core/services/cam.cpp src/core/services/ldr_ro.cpp
src/core/services/act.cpp src/core/services/nfc.cpp src/core/services/dlp_srvr.cpp
src/core/services/ir_user.cpp src/core/services/http.cpp
src/core/services/ir_user.cpp src/core/services/http.cpp src/core/services/soc.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/dynapica/shader_rec.cpp
@ -175,6 +175,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp
include/config.hpp include/services/ir_user.hpp include/http_server.hpp include/cheats.hpp
include/action_replay.hpp include/renderer_sw/renderer_sw.hpp include/compiler_builtins.hpp
include/fs/romfs.hpp include/fs/ivfc.hpp include/discord_rpc.hpp include/services/http.hpp include/result/result_cfg.hpp
include/services/soc.hpp
)
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp

View file

@ -33,6 +33,7 @@ namespace KernelHandles {
NIM, // Updates, DLC, etc
NDM, // ?????
PTM, // PTM service (Used for accessing various console info, such as battery, shell and pedometer state)
SOC, // Socket service
Y2R, // Also does camera stuff
MinServiceHandle = AC,
@ -82,6 +83,7 @@ namespace KernelHandles {
case NFC: return "NFC";
case NIM: return "NIM";
case PTM: return "PTM";
case SOC: return "SOC";
case Y2R: return "Y2R";
default: return "Unknown";
}

View file

@ -53,6 +53,7 @@ namespace Log {
static Logger<false> nimLogger;
static Logger<false> ndmLogger;
static Logger<false> ptmLogger;
static Logger<false> socLogger;
static Logger<false> y2rLogger;
static Logger<false> srvLogger;

View file

@ -29,6 +29,7 @@
#include "services/nfc.hpp"
#include "services/nim.hpp"
#include "services/ptm.hpp"
#include "services/soc.hpp"
#include "services/y2r.hpp"
// More circular dependencies!!
@ -66,6 +67,7 @@ class ServiceManager {
NIMService nim;
NDMService ndm;
PTMService ptm;
SOCService soc;
Y2RService y2r;
// "srv:" commands

21
include/services/soc.hpp Normal file
View file

@ -0,0 +1,21 @@
#pragma once
#include "helpers.hpp"
#include "kernel_types.hpp"
#include "logger.hpp"
#include "memory.hpp"
class SOCService {
Handle handle = KernelHandles::SOC;
Memory& mem;
MAKE_LOG_FUNCTION(log, socLogger)
bool initialized = false;
// Service commands
void initializeSockets(u32 messagePointer);
public:
SOCService(Memory& mem) : mem(mem) {}
void reset();
void handleSyncRequest(u32 messagePointer);
};

View file

@ -8,7 +8,8 @@
ServiceManager::ServiceManager(std::span<u32, 16> regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
: regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), act(mem), apt(mem, kernel), cam(mem), cecd(mem, kernel), cfg(mem),
dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), http(mem), ir_user(mem, kernel), frd(mem), fs(mem, kernel),
gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem), ptm(mem), y2r(mem, kernel) {}
gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem), ptm(mem), soc(mem),
y2r(mem, kernel) {}
static constexpr int MAX_NOTIFICATION_COUNT = 16;
@ -36,6 +37,7 @@ void ServiceManager::reset() {
nim.reset();
ndm.reset();
ptm.reset();
soc.reset();
y2r.reset();
notificationSemaphore = std::nullopt;
@ -112,6 +114,7 @@ static std::map<std::string, Handle> serviceMap = {
{ "nim:aoc", KernelHandles::NIM },
{ "ptm:u", KernelHandles::PTM }, // TODO: ptm:u and ptm:sysm have very different command sets
{ "ptm:sysm", KernelHandles::PTM },
{ "soc:U", KernelHandles::SOC },
{ "y2r:u", KernelHandles::Y2R }
};
// clang-format on
@ -194,6 +197,7 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) {
case KernelHandles::NIM: nim.handleSyncRequest(messagePointer); break;
case KernelHandles::NDM: ndm.handleSyncRequest(messagePointer); break;
case KernelHandles::PTM: ptm.handleSyncRequest(messagePointer); break;
case KernelHandles::SOC: soc.handleSyncRequest(messagePointer); break;
case KernelHandles::Y2R: y2r.handleSyncRequest(messagePointer); break;
default: Helpers::panic("Sent IPC message to unknown service %08X\n Command: %08X", handle, mem.read32(messagePointer));
}

33
src/core/services/soc.cpp Normal file
View file

@ -0,0 +1,33 @@
#include "services/soc.hpp"
#include "ipc.hpp"
#include "result/result.hpp"
namespace SOCCommands {
enum : u32 {
InitializeSockets = 0x00010044,
};
}
void SOCService::reset() { initialized = false; }
void SOCService::handleSyncRequest(u32 messagePointer) {
const u32 command = mem.read32(messagePointer);
switch (command) {
case SOCCommands::InitializeSockets: initializeSockets(messagePointer); break;
default: Helpers::panic("SOC service requested. Command: %08X\n", command);
}
}
void SOCService::initializeSockets(u32 messagePointer) {
const u32 memoryBlockSize = mem.read32(messagePointer + 4);
const Handle sharedMemHandle = mem.read32(messagePointer + 20);
log("SOC::InitializeSockets (memory block size = %08X, shared mem handle = %08X)\n", memoryBlockSize, sharedMemHandle);
// TODO: Does double initialization return an error code?
// TODO: Implement the rest of this stuff when it's time to do online. Also implement error checking for the size, shared mem handle, and so on
initialized = true;
mem.write32(messagePointer, IPC::responseHeader(0x01, 1, 0));
mem.write32(messagePointer + 4, Result::Success);
}