[GSP::GPU] We can now request interrupts

This commit is contained in:
wheremyfoodat 2022-09-20 23:22:35 +03:00
parent 194761ca54
commit 3ccba6db40
5 changed files with 37 additions and 0 deletions

View file

@ -57,5 +57,6 @@ void Kernel::waitSynchronization1() {
}
printf("WaitSynchronization1(handle = %X, ns = %lld) (STUBBED)\n", handle, ns);
serviceManager.requestGPUInterrupt(GPUInterrupt::VBlank0);
regs[0] = SVCResult::Success;
}

View file

@ -105,6 +105,7 @@ void Kernel::mapMemoryBlock() {
if (block == KernelHandles::GSPSharedMemHandle) {
mem.mapGSPSharedMemory(addr, myPerms, otherPerms);
serviceManager.setGSPSharedMem(static_cast<u8*>(mem.getReadPointer(addr)));
} else {
Helpers::panic("MapMemoryBlock where the handle does not refer to GSP memory");
}

View file

@ -18,6 +18,7 @@ namespace Result {
void GPUService::reset() {
privilegedProcess = 0xFFFFFFFF; // Set the privileged process to an invalid handle
sharedMem = nullptr;
}
void GPUService::handleSyncRequest(u32 messagePointer) {
@ -63,6 +64,19 @@ void GPUService::registerInterruptRelayQueue(u32 messagePointer) {
mem.write32(messagePointer + 16, KernelHandles::GSPSharedMemHandle);
}
void GPUService::requestInterrupt(GPUInterrupt type) {
if (sharedMem == nullptr) [[unlikely]] { // Shared memory hasn't been set up yet
return;
}
u8 index = sharedMem[0];
u8& interruptCount = sharedMem[1];
u8 flagIndex = (index + interruptCount) % 0x34;
interruptCount++;
sharedMem[0xC + flagIndex] = static_cast<u8>(type);
}
void GPUService::writeHwRegs(u32 messagePointer) {
u32 ioAddr = mem.read32(messagePointer + 4); // GPU address based at 0x1EB00000, word aligned
const u32 size = mem.read32(messagePointer + 8); // Size in bytes