mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
Initial implementation of ports and sessions
This commit is contained in:
parent
aa643c44bb
commit
0e66af8dae
7 changed files with 100 additions and 17 deletions
|
@ -14,6 +14,7 @@ class Kernel {
|
|||
// The handle number for the next kernel object to be created
|
||||
u32 handleCounter;
|
||||
std::vector<KernelObject> objects;
|
||||
std::vector<Handle> portHandles;
|
||||
|
||||
u32 currentProcess;
|
||||
|
||||
|
@ -47,6 +48,10 @@ class Kernel {
|
|||
}
|
||||
|
||||
Handle makeProcess();
|
||||
Handle makePort(const char* name);
|
||||
std::optional<Handle> getPortHandle(const char* name);
|
||||
void deleteObjectData(KernelObject& object);
|
||||
|
||||
KernelObject* getProcessFromPID(Handle handle);
|
||||
s32 getCurrentResourceValue(const KernelObject* limit, u32 resourceName);
|
||||
u32 getMaxForResource(const KernelObject* limit, u32 resourceName);
|
||||
|
@ -64,6 +69,7 @@ class Kernel {
|
|||
public:
|
||||
Kernel(std::array<u32, 16>& regs, Memory& mem) : regs(regs), mem(mem), handleCounter(0) {
|
||||
objects.reserve(512); // Make room for a few objects to avoid further memory allocs later
|
||||
portHandles.reserve(32);
|
||||
}
|
||||
void serviceSVC(u32 svc);
|
||||
void reset();
|
||||
|
|
|
@ -5,9 +5,11 @@ namespace SVCResult {
|
|||
enum : u32 {
|
||||
Success = 0,
|
||||
Failure = 0xFFFFFFFF,
|
||||
ObjectNotFound = 0xD88007FA,
|
||||
// Different calls return a different value
|
||||
BadHandle = 0xD8E007F7,
|
||||
BadHandleAlt = 0xD9001BF7
|
||||
BadHandleAlt = 0xD9001BF7,
|
||||
PortNameTooLong = 0xE0E0181E
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -19,7 +21,7 @@ namespace KernelHandles {
|
|||
}
|
||||
|
||||
enum class KernelObjectType : u8 {
|
||||
ResourceLimit, Process
|
||||
Port, Process, ResourceLimit, Session, Dummy
|
||||
};
|
||||
|
||||
enum class ResourceLimitCategory : int {
|
||||
|
@ -55,10 +57,24 @@ struct ProcessData {
|
|||
ResourceLimits limits;
|
||||
};
|
||||
|
||||
struct PortData {
|
||||
static constexpr u32 maxNameLen = 11;
|
||||
|
||||
char name[maxNameLen + 1] = {};
|
||||
bool isPublic = false; // Setting name=NULL creates a private port not accessible from svcConnectToPort.
|
||||
};
|
||||
|
||||
struct SessionData {
|
||||
|
||||
};
|
||||
|
||||
static const char* kernelObjectTypeToString(KernelObjectType t) {
|
||||
switch (t) {
|
||||
case KernelObjectType::Port: return "port";
|
||||
case KernelObjectType::Process: return "process";
|
||||
case KernelObjectType::ResourceLimit: return "resource limit";
|
||||
case KernelObjectType::Session: return "session";
|
||||
case KernelObjectType::Dummy: return "dummy";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue