mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-07 03:21:38 +12:00
Hopefully we're good to start sending commands to services now
This commit is contained in:
parent
208c18356b
commit
6154a360c6
10 changed files with 110 additions and 32 deletions
include
31
include/kernel/handles.hpp
Normal file
31
include/kernel/handles.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#include "helpers.hpp"
|
||||
|
||||
using Handle = u32;
|
||||
|
||||
namespace KernelHandles {
|
||||
enum : u32 {
|
||||
Max = 0xFFFF7FFF, // Max handle the kernel can automagically allocate
|
||||
|
||||
// Hardcoded handles
|
||||
CurrentThread = 0xFFFF8000, // Used by the original kernel
|
||||
CurrentProcess = 0xFFFF8001, // Used by the original kernel
|
||||
APT = 0xFFFF8002, // App Title something service?
|
||||
|
||||
MinServiceHandle = APT,
|
||||
MaxServiceHandle = APT
|
||||
};
|
||||
|
||||
// Returns whether "handle" belongs to one of the OS services
|
||||
static constexpr bool isServiceHandle(Handle handle) {
|
||||
return handle >= MinServiceHandle && handle <= MaxServiceHandle;
|
||||
}
|
||||
|
||||
// Returns the name of a handle as a string based on the given handle
|
||||
static const char* getServiceName(Handle handle) {
|
||||
switch (handle) {
|
||||
case APT: return "APT";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,7 +40,7 @@ class Kernel {
|
|||
}
|
||||
|
||||
Handle makeObject(KernelObjectType type) {
|
||||
if (handleCounter == std::numeric_limits<Handle>::max()) [[unlikely]] {
|
||||
if (handleCounter > KernelHandles::Max) [[unlikely]] {
|
||||
Helpers::panic("Hlep we somehow created enough kernel objects to overflow this thing");
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ class Kernel {
|
|||
Handle makeProcess();
|
||||
Handle makePort(const char* name);
|
||||
Handle makeSession(Handle port);
|
||||
|
||||
std::optional<Handle> getPortHandle(const char* name);
|
||||
void deleteObjectData(KernelObject& object);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include "handles.hpp"
|
||||
#include "helpers.hpp"
|
||||
|
||||
namespace SVCResult {
|
||||
|
@ -13,13 +14,6 @@ namespace SVCResult {
|
|||
};
|
||||
}
|
||||
|
||||
namespace KernelHandles {
|
||||
enum : u32 {
|
||||
CurrentThread = 0xFFFF8000,
|
||||
CurrentProcess = 0xFFFF8001
|
||||
};
|
||||
}
|
||||
|
||||
enum class KernelObjectType : u8 {
|
||||
Port, Process, ResourceLimit, Session, Dummy
|
||||
};
|
||||
|
@ -44,8 +38,6 @@ enum ResourceTypes {
|
|||
CPU_TIME = 9
|
||||
};
|
||||
|
||||
using Handle = u32;
|
||||
|
||||
struct ResourceLimits {
|
||||
Handle handle;
|
||||
|
||||
|
|
11
include/services/apt.hpp
Normal file
11
include/services/apt.hpp
Normal file
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
#include "helpers.hpp"
|
||||
#include "kernel_types.hpp"
|
||||
|
||||
class APTService {
|
||||
Handle handle = KernelHandles::APT;
|
||||
|
||||
public:
|
||||
void reset();
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
};
|
|
@ -2,11 +2,14 @@
|
|||
#include <array>
|
||||
#include "helpers.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "services/apt.hpp"
|
||||
|
||||
class ServiceManager {
|
||||
std::array<u32, 16>& regs;
|
||||
Memory& mem;
|
||||
|
||||
APTService apt;
|
||||
|
||||
// "srv:" commands
|
||||
void getServiceHandle(u32 messagePointer);
|
||||
void registerClient(u32 messagePointer);
|
||||
|
@ -14,5 +17,8 @@ class ServiceManager {
|
|||
public:
|
||||
ServiceManager(std::array<u32, 16>& regs, Memory& mem);
|
||||
void reset();
|
||||
void handleSyncRequest(u32 TLSPointer);
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
|
||||
// Forward a SendSyncRequest IPC message to the service with the respective handle
|
||||
void sendCommandToService(u32 messagePointer, Handle handle);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue