mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
Add FRD service
This commit is contained in:
parent
94fe205c48
commit
9f07286de8
7 changed files with 91 additions and 4 deletions
|
@ -58,7 +58,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services
|
|||
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/dsp.cpp src/core/services/cfg.cpp
|
||||
src/core/services/ptm.cpp src/core/services/mic.cpp src/core/services/cecd.cpp
|
||||
src/core/services/ac.cpp
|
||||
src/core/services/ac.cpp src/core/services/frd.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
|
||||
|
@ -82,6 +82,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc
|
|||
include/fs/archive_save_data.hpp include/fs/archive_sdmc.hpp include/services/ptm.hpp
|
||||
include/services/mic.hpp include/services/cecd.hpp include/renderer_gl/renderer_gl.hpp
|
||||
include/renderer_gl/surfaces.hpp include/renderer_gl/surface_cache.hpp include/services/ac.hpp
|
||||
include/services/frd.hpp
|
||||
)
|
||||
|
||||
set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp
|
||||
|
|
|
@ -10,11 +10,12 @@ namespace KernelHandles {
|
|||
// Hardcoded handles
|
||||
CurrentThread = 0xFFFF8000, // Used by the original kernel
|
||||
CurrentProcess = 0xFFFF8001, // Used by the original kernel
|
||||
AC,
|
||||
AC, // Something network related
|
||||
APT, // App Title something service?
|
||||
CECD, // Streetpass stuff?
|
||||
CFG, // CFG service (Console & region info)
|
||||
HID, // HID service (Handles everything input-related including gyro)
|
||||
FRD, // Friend service (Miiverse friend service)
|
||||
FS, // Filesystem service
|
||||
GPU, // GPU service
|
||||
DSP, // DSP service (Used for audio decoding and output)
|
||||
|
|
|
@ -28,10 +28,12 @@ namespace Log {
|
|||
static Logger<false> rendererLogger;
|
||||
|
||||
// Service loggers
|
||||
static Logger<false> acLogger;
|
||||
static Logger<false> aptLogger;
|
||||
static Logger<false> cecdLogger;
|
||||
static Logger<false> cfgLogger;
|
||||
static Logger<false> dspServiceLogger;
|
||||
static Logger<false> frdLogger;
|
||||
static Logger<false> fsLogger;
|
||||
static Logger<false> hidLogger;
|
||||
static Logger<false> gspGPULogger;
|
||||
|
|
21
include/services/frd.hpp
Normal file
21
include/services/frd.hpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#include "helpers.hpp"
|
||||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
|
||||
class FRDService {
|
||||
Handle handle = KernelHandles::FRD;
|
||||
Memory& mem;
|
||||
MAKE_LOG_FUNCTION(log, frdLogger)
|
||||
|
||||
// Service commands
|
||||
void getMyFriendKey(u32 messagePointer);
|
||||
void getMyPresence(u32 messagePointer);
|
||||
void setClientSDKVersion(u32 messagePointer);
|
||||
|
||||
public:
|
||||
FRDService(Memory& mem) : mem(mem) {}
|
||||
void reset();
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
};
|
|
@ -10,6 +10,7 @@
|
|||
#include "services/cfg.hpp"
|
||||
#include "services/dsp.hpp"
|
||||
#include "services/hid.hpp"
|
||||
#include "services/frd.hpp"
|
||||
#include "services/fs.hpp"
|
||||
#include "services/gsp_gpu.hpp"
|
||||
#include "services/gsp_lcd.hpp"
|
||||
|
@ -35,6 +36,7 @@ class ServiceManager {
|
|||
CFGService cfg;
|
||||
DSPService dsp;
|
||||
HIDService hid;
|
||||
FRDService frd;
|
||||
FSService fs;
|
||||
GPUService gsp_gpu;
|
||||
LCDService gsp_lcd;
|
||||
|
|
56
src/core/services/frd.cpp
Normal file
56
src/core/services/frd.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "services/frd.hpp"
|
||||
|
||||
namespace FRDCommands {
|
||||
enum : u32 {
|
||||
SetClientSdkVersion = 0x00320042,
|
||||
GetMyFriendKey = 0x00050000,
|
||||
GetMyPresence = 0x00080000
|
||||
};
|
||||
}
|
||||
|
||||
namespace Result {
|
||||
enum : u32 {
|
||||
Success = 0,
|
||||
};
|
||||
}
|
||||
|
||||
void FRDService::reset() {}
|
||||
|
||||
void FRDService::handleSyncRequest(u32 messagePointer) {
|
||||
const u32 command = mem.read32(messagePointer);
|
||||
switch (command) {
|
||||
case FRDCommands::GetMyFriendKey: getMyFriendKey(messagePointer); break;
|
||||
case FRDCommands::GetMyPresence: getMyPresence(messagePointer); break;
|
||||
case FRDCommands::SetClientSdkVersion: setClientSDKVersion(messagePointer); break;
|
||||
default: Helpers::panic("FRD service requested. Command: %08X\n", command);
|
||||
}
|
||||
}
|
||||
|
||||
void FRDService::getMyFriendKey(u32 messagePointer) {
|
||||
log("FRD::GetMyFriendKey");
|
||||
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
mem.write32(messagePointer + 8, 0); // Principal ID
|
||||
mem.write32(messagePointer + 12, 0); // Padding (?)
|
||||
mem.write32(messagePointer + 16, 0); // Local friend code
|
||||
mem.write32(messagePointer + 20, 0);
|
||||
}
|
||||
|
||||
void FRDService::getMyPresence(u32 messagePointer) {
|
||||
static constexpr u32 presenceSize = 0x12C; // A presence seems to be 12C bytes of data, not sure what it contains
|
||||
log("FRD::GetMyPresence\n");
|
||||
u32 buffer = mem.read32(messagePointer + 0x104); // Buffer to write presence info to.
|
||||
|
||||
for (u32 i = 0; i < presenceSize; i += 4) { // Clear presence info with 0s for now
|
||||
mem.write32(buffer + i, 0);
|
||||
}
|
||||
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
}
|
||||
|
||||
void FRDService::setClientSDKVersion(u32 messagePointer) {
|
||||
u32 version = mem.read32(messagePointer + 4);
|
||||
log("FRD::SetClientSdkVersion (version = %d)\n", version);
|
||||
|
||||
mem.write32(messagePointer + 4, Result::Success);
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
ServiceManager::ServiceManager(std::array<u32, 16>& regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
||||
: regs(regs), mem(mem), kernel(kernel), ac(mem), apt(mem, kernel), cecd(mem), cfg(mem), dsp(mem), hid(mem),
|
||||
fs(mem, kernel), gsp_gpu(mem, gpu, currentPID), gsp_lcd(mem), mic(mem), ndm(mem), ptm(mem) {}
|
||||
frd(mem), fs(mem, kernel), gsp_gpu(mem, gpu, currentPID), gsp_lcd(mem), mic(mem), ndm(mem), ptm(mem) {}
|
||||
|
||||
static constexpr int MAX_NOTIFICATION_COUNT = 16;
|
||||
|
||||
|
@ -14,6 +14,7 @@ void ServiceManager::reset() {
|
|||
cfg.reset();
|
||||
dsp.reset();
|
||||
hid.reset();
|
||||
frd.reset();
|
||||
fs.reset();
|
||||
gsp_gpu.reset();
|
||||
gsp_lcd.reset();
|
||||
|
@ -96,7 +97,9 @@ void ServiceManager::getServiceHandle(u32 messagePointer) {
|
|||
handle = KernelHandles::DSP;
|
||||
} else if (service == "hid:USER") {
|
||||
handle = KernelHandles::HID;
|
||||
} else if (service == "fs:USER") {
|
||||
} else if (service == "frd:u") {
|
||||
handle = KernelHandles::FRD;
|
||||
} else if (service == "fs:USER") {
|
||||
handle = KernelHandles::FS;
|
||||
} else if (service == "gsp::Gpu") {
|
||||
handle = KernelHandles::GPU;
|
||||
|
@ -145,6 +148,7 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) {
|
|||
case KernelHandles::CFG: cfg.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::DSP: dsp.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::HID: hid.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::FRD: frd.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::FS: fs.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::GPU: [[likely]] gsp_gpu.handleSyncRequest(messagePointer); break;
|
||||
case KernelHandles::LCD: gsp_lcd.handleSyncRequest(messagePointer); break;
|
||||
|
|
Loading…
Add table
Reference in a new issue