Initial impl for createEvent SVC

This commit is contained in:
wheremyfoodat 2022-09-18 18:17:41 +03:00
parent 68698ae7a7
commit a91035abf4
6 changed files with 28 additions and 2 deletions

View file

@ -47,6 +47,7 @@ endif()
set(SOURCE_FILES src/main.cpp src/emulator.cpp src/core/CPU/cpu_dynarmic.cpp src/core/memory.cpp src/core/elf.cpp)
set(KERNEL_SOURCE_FILES src/core/kernel/kernel.cpp src/core/kernel/resource_limits.cpp
src/core/kernel/memory_management.cpp src/core/kernel/ports.cpp
src/core/kernel/events.cpp src/core/kernel/threads.cpp
)
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

View file

@ -49,6 +49,7 @@ class Kernel {
return handleCounter++;
}
Handle makeEvent(u32 resetType);
Handle makeProcess();
Handle makePort(const char* name);
Handle makeSession(Handle port);
@ -63,8 +64,9 @@ class Kernel {
std::string getProcessName(u32 pid);
// SVC implementations
void controlMemory();
void createAddressArbiter();
void createEvent();
void controlMemory();
void getResourceLimit();
void getResourceLimitLimitValues();
void getResourceLimitCurrentValues();

View file

@ -15,7 +15,7 @@ namespace SVCResult {
}
enum class KernelObjectType : u8 {
Port, Process, ResourceLimit, Session, Dummy
Event, Port, Process, ResourceLimit, Session, Dummy
};
enum class ResourceLimitCategory : int {
@ -68,6 +68,7 @@ struct SessionData {
static const char* kernelObjectTypeToString(KernelObjectType t) {
switch (t) {
case KernelObjectType::Event: return "event";
case KernelObjectType::Port: return "port";
case KernelObjectType::Process: return "process";
case KernelObjectType::ResourceLimit: return "resource limit";

View file

@ -0,0 +1,21 @@
#include "kernel.hpp"
// TODO: What the fuck is resetType meant to be?
Handle Kernel::makeEvent(u32 resetType) {
Handle ret = makeObject(KernelObjectType::Event);
return ret;
}
// Result CreateEvent(Handle* event, ResetType resetType)
// TODO: Just like getResourceLimit this seems to output the handle in r1 even though 3dbrew doesn't mention this
// Should the handle be written both in memory and r1, or just r1?
void Kernel::createEvent() {
const u32 outPointer = regs[0];
const u32 resetType = regs[1];
printf("CreateEvent(handle pointer = %08X, resetType = %d)\n", outPointer, resetType);
Handle handle = makeEvent(resetType);
regs[0] = SVCResult::Success;
regs[1] = handle;
mem.write32(outPointer, handle);
}

View file

@ -5,6 +5,7 @@
void Kernel::serviceSVC(u32 svc) {
switch (svc) {
case 0x01: controlMemory(); break;
case 0x17: createEvent(); break;
case 0x21: createAddressArbiter(); break;
case 0x23: svcCloseHandle(); break;
case 0x2D: connectToPort(); break;

View file