mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
[Y2R] Add transfer event
This commit is contained in:
parent
5a8416f87e
commit
82b986bbc0
3 changed files with 22 additions and 2 deletions
|
@ -1,23 +1,30 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <optional>
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "kernel_types.hpp"
|
#include "kernel_types.hpp"
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
|
|
||||||
|
// Circular dependencies go br
|
||||||
|
class Kernel;
|
||||||
|
|
||||||
class Y2RService {
|
class Y2RService {
|
||||||
Handle handle = KernelHandles::Y2R;
|
Handle handle = KernelHandles::Y2R;
|
||||||
Memory& mem;
|
Memory& mem;
|
||||||
|
Kernel& kernel;
|
||||||
MAKE_LOG_FUNCTION(log, y2rLogger)
|
MAKE_LOG_FUNCTION(log, y2rLogger)
|
||||||
|
|
||||||
|
std::optional<Handle> transferEndEvent;
|
||||||
bool transferEndInterruptEnabled;
|
bool transferEndInterruptEnabled;
|
||||||
|
|
||||||
// Service commands
|
// Service commands
|
||||||
void driverInitialize(u32 messagePointer);
|
void driverInitialize(u32 messagePointer);
|
||||||
void pingProcess(u32 messagePointer);
|
void pingProcess(u32 messagePointer);
|
||||||
void setTransferEndInterrupt(u32 messagePointer);
|
void setTransferEndInterrupt(u32 messagePointer);
|
||||||
|
void getTransferEndEvent(u32 messagePointer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Y2RService(Memory& mem) : mem(mem) {}
|
Y2RService(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
||||||
void reset();
|
void reset();
|
||||||
void handleSyncRequest(u32 messagePointer);
|
void handleSyncRequest(u32 messagePointer);
|
||||||
};
|
};
|
|
@ -5,7 +5,7 @@
|
||||||
ServiceManager::ServiceManager(std::array<u32, 16>& regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
ServiceManager::ServiceManager(std::array<u32, 16>& regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel)
|
||||||
: regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), apt(mem, kernel), cam(mem), cecd(mem), cfg(mem),
|
: regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), apt(mem, kernel), cam(mem), cecd(mem), cfg(mem),
|
||||||
dsp(mem), hid(mem), frd(mem), fs(mem, kernel), gsp_gpu(mem, gpu, currentPID), gsp_lcd(mem), ldr(mem), mic(mem),
|
dsp(mem), hid(mem), frd(mem), fs(mem, kernel), gsp_gpu(mem, gpu, currentPID), gsp_lcd(mem), ldr(mem), mic(mem),
|
||||||
nim(mem), ndm(mem), ptm(mem), y2r(mem) {}
|
nim(mem), ndm(mem), ptm(mem), y2r(mem, kernel) {}
|
||||||
|
|
||||||
static constexpr int MAX_NOTIFICATION_COUNT = 16;
|
static constexpr int MAX_NOTIFICATION_COUNT = 16;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "services/y2r.hpp"
|
#include "services/y2r.hpp"
|
||||||
|
#include "kernel.hpp"
|
||||||
|
|
||||||
namespace Y2RCommands {
|
namespace Y2RCommands {
|
||||||
enum : u32 {
|
enum : u32 {
|
||||||
SetTransferEndInterrupt = 0x000D0040,
|
SetTransferEndInterrupt = 0x000D0040,
|
||||||
|
GetTransferEndEvent = 0x000F0000,
|
||||||
PingProcess = 0x002A0000,
|
PingProcess = 0x002A0000,
|
||||||
DriverInitialize = 0x002B0000
|
DriverInitialize = 0x002B0000
|
||||||
};
|
};
|
||||||
|
@ -16,12 +18,14 @@ namespace Result {
|
||||||
|
|
||||||
void Y2RService::reset() {
|
void Y2RService::reset() {
|
||||||
transferEndInterruptEnabled = false;
|
transferEndInterruptEnabled = false;
|
||||||
|
transferEndEvent = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Y2RService::handleSyncRequest(u32 messagePointer) {
|
void Y2RService::handleSyncRequest(u32 messagePointer) {
|
||||||
const u32 command = mem.read32(messagePointer);
|
const u32 command = mem.read32(messagePointer);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case Y2RCommands::DriverInitialize: driverInitialize(messagePointer); break;
|
case Y2RCommands::DriverInitialize: driverInitialize(messagePointer); break;
|
||||||
|
case Y2RCommands::GetTransferEndEvent: getTransferEndEvent(messagePointer); break;
|
||||||
case Y2RCommands::PingProcess: pingProcess(messagePointer); break;
|
case Y2RCommands::PingProcess: pingProcess(messagePointer); break;
|
||||||
case Y2RCommands::SetTransferEndInterrupt: setTransferEndInterrupt(messagePointer); break;
|
case Y2RCommands::SetTransferEndInterrupt: setTransferEndInterrupt(messagePointer); break;
|
||||||
default: Helpers::panic("Y2R service requested. Command: %08X\n", command);
|
default: Helpers::panic("Y2R service requested. Command: %08X\n", command);
|
||||||
|
@ -39,6 +43,15 @@ void Y2RService::driverInitialize(u32 messagePointer) {
|
||||||
mem.write32(messagePointer + 4, Result::Success);
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Y2RService::getTransferEndEvent(u32 messagePointer) {
|
||||||
|
log("Y2R::GetTransferEndEvent\n");
|
||||||
|
if (!transferEndEvent.has_value())
|
||||||
|
transferEndEvent = kernel.makeEvent(ResetType::OneShot);
|
||||||
|
|
||||||
|
mem.write32(messagePointer + 4, Result::Success);
|
||||||
|
mem.write32(messagePointer + 12, transferEndEvent.value());
|
||||||
|
}
|
||||||
|
|
||||||
void Y2RService::setTransferEndInterrupt(u32 messagePointer) {
|
void Y2RService::setTransferEndInterrupt(u32 messagePointer) {
|
||||||
const bool enable = mem.read32(messagePointer + 4) != 0;
|
const bool enable = mem.read32(messagePointer + 4) != 0;
|
||||||
log("Y2R::SetTransferEndInterrupt (enabled: %s)\n", enable ? "yes" : "no");
|
log("Y2R::SetTransferEndInterrupt (enabled: %s)\n", enable ? "yes" : "no");
|
||||||
|
|
Loading…
Add table
Reference in a new issue