mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
[Kernel & APT] Mutexes v0.1
This commit is contained in:
parent
41e01bbdd4
commit
3c55d88fab
7 changed files with 51 additions and 8 deletions
|
@ -46,6 +46,10 @@ class Kernel {
|
|||
Handle makeSession(Handle port);
|
||||
Handle makeThread(u32 entrypoint, u32 initialSP, u32 priority, s32 id, u32 arg,ThreadStatus status = ThreadStatus::Dormant);
|
||||
|
||||
public:
|
||||
Handle makeMutex(bool locked = false); // Needs to be public to be accessible to the APT/DSP services
|
||||
|
||||
private:
|
||||
void signalArbiter(u32 waitingAddress, s32 threadCount);
|
||||
void sleepThread(s64 ns);
|
||||
void sleepThreadOnArbiter(u32 waitingAddress);
|
||||
|
|
|
@ -150,6 +150,13 @@ static const char* kernelObjectTypeToString(KernelObjectType t) {
|
|||
}
|
||||
}
|
||||
|
||||
struct Mutex {
|
||||
Handle ownerThread = 0; // Index of the thread that holds the mutex if it's locked
|
||||
bool locked;
|
||||
|
||||
Mutex(bool lock = false) : locked(lock) {}
|
||||
};
|
||||
|
||||
// Generic kernel object class
|
||||
struct KernelObject {
|
||||
Handle handle = 0; // A u32 the OS will use to identify objects
|
||||
|
@ -166,4 +173,8 @@ struct KernelObject {
|
|||
T* getData() {
|
||||
return static_cast<T*>(data);
|
||||
}
|
||||
|
||||
const char* getTypeName() {
|
||||
return kernelObjectTypeToString(type);
|
||||
}
|
||||
};
|
|
@ -1,12 +1,20 @@
|
|||
#pragma once
|
||||
#include <optional>
|
||||
#include "helpers.hpp"
|
||||
#include "kernel_types.hpp"
|
||||
#include "logger.hpp"
|
||||
#include "memory.hpp"
|
||||
|
||||
// Yay, more circular dependencies
|
||||
class Kernel;
|
||||
|
||||
class APTService {
|
||||
Handle handle = KernelHandles::APT;
|
||||
Memory& mem;
|
||||
Kernel& kernel;
|
||||
|
||||
std::optional<Handle> lockHandle = std::nullopt;
|
||||
|
||||
MAKE_LOG_FUNCTION(log, aptLogger)
|
||||
|
||||
// Service commands
|
||||
|
@ -25,7 +33,7 @@ class APTService {
|
|||
u32 cpuTimeLimit;
|
||||
|
||||
public:
|
||||
APTService(Memory& mem) : mem(mem) {}
|
||||
APTService(Memory& mem, Kernel& kernel) : mem(mem), kernel(kernel) {}
|
||||
void reset();
|
||||
void handleSyncRequest(u32 messagePointer);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue