mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
Add KThread::StackParameters
This commit is contained in:
parent
e57203a7d4
commit
dffb233423
1 changed files with 39 additions and 2 deletions
|
@ -13,6 +13,8 @@
|
||||||
namespace mesosphere
|
namespace mesosphere
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct KThreadContext;
|
||||||
|
|
||||||
struct ThreadWaitListTag;
|
struct ThreadWaitListTag;
|
||||||
struct ThreadMutexWaitListTag;
|
struct ThreadMutexWaitListTag;
|
||||||
using ThreadWaitListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<ThreadWaitListTag> >;
|
using ThreadWaitListBaseHook = boost::intrusive::list_base_hook<boost::intrusive::tag<ThreadWaitListTag> >;
|
||||||
|
@ -29,9 +31,35 @@ class KThread final :
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Thread);
|
MESOSPHERE_AUTO_OBJECT_TRAITS(AutoObject, Thread);
|
||||||
virtual bool IsAlive() const override;
|
|
||||||
|
|
||||||
virtual void OnAlarm() override;
|
class StackParameters {
|
||||||
|
public:
|
||||||
|
StackParameters(std::array<u64, 4> svcPermissionMask, KThreadContext *threadCtx) :
|
||||||
|
svcPermissionMask{svcPermissionMask}, threadCtx{threadCtx} {}
|
||||||
|
|
||||||
|
void Initialize(std::array<u64, 4> svcPermissionMask, KThreadContext *threadCtx)
|
||||||
|
{
|
||||||
|
*this = StackParameters{svcPermissionMask, threadCtx};
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr bool IsExecutingSvc() const { return isExecutingSvc; }
|
||||||
|
constexpr u8 GetCurrentSvcId() const { return currentSvcId; }
|
||||||
|
|
||||||
|
constexpr uint GetBottomHalfLockCount() const { return bottomHalfLockCount; }
|
||||||
|
void IncrementBottomHalfLockCount() { ++bottomHalfLockCount; }
|
||||||
|
void DecrementBottomHalfLockCount() { --bottomHalfLockCount; }
|
||||||
|
|
||||||
|
KThreadContext *GetThreadContext() const { return threadCtx; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::array<u64, 4> svcPermissionMask[256/64]{};
|
||||||
|
u8 stateFlags = 0;
|
||||||
|
u8 currentSvcId = 0;
|
||||||
|
bool isExecutingSvc = false;
|
||||||
|
bool isNotStarted = true;
|
||||||
|
uint bottomHalfLockCount = 1;
|
||||||
|
KThreadContext *threadCtx = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
struct SchedulerValueTraits {
|
struct SchedulerValueTraits {
|
||||||
using node_traits = boost::intrusive::list_node_traits<KThread *>;
|
using node_traits = boost::intrusive::list_node_traits<KThread *>;
|
||||||
|
@ -94,6 +122,9 @@ class KThread final :
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual bool IsAlive() const override;
|
||||||
|
virtual void OnAlarm() override;
|
||||||
|
|
||||||
static constexpr uint GetPriorityOf(const KThread &thread)
|
static constexpr uint GetPriorityOf(const KThread &thread)
|
||||||
{
|
{
|
||||||
return thread.priority;
|
return thread.priority;
|
||||||
|
@ -105,6 +136,11 @@ class KThread final :
|
||||||
constexpr ulong GetAffinityMask() const { return affinityMask; }
|
constexpr ulong GetAffinityMask() const { return affinityMask; }
|
||||||
constexpr long GetLastScheduledTime() const { return lastScheduledTime; }
|
constexpr long GetLastScheduledTime() const { return lastScheduledTime; }
|
||||||
|
|
||||||
|
StackParameters &GetStackParameters()
|
||||||
|
{
|
||||||
|
return *(StackParameters *)(kernelStackTop - sizeof(StackParameters));
|
||||||
|
}
|
||||||
|
|
||||||
KProcess *GetOwner() const { return owner; }
|
KProcess *GetOwner() const { return owner; }
|
||||||
bool IsSchedulerOperationRedundant() const { return owner != nullptr && owner->GetSchedulerOperationCount() == redundantSchedulerOperationCount; }
|
bool IsSchedulerOperationRedundant() const { return owner != nullptr && owner->GetSchedulerOperationCount() == redundantSchedulerOperationCount; }
|
||||||
|
|
||||||
|
@ -256,6 +292,7 @@ private:
|
||||||
KThread *wantedMutexOwner = nullptr;
|
KThread *wantedMutexOwner = nullptr;
|
||||||
MutexWaitList mutexWaitList{};
|
MutexWaitList mutexWaitList{};
|
||||||
size_t numKernelMutexWaiters = 0;
|
size_t numKernelMutexWaiters = 0;
|
||||||
|
uiptr kernelStackTop = 0;
|
||||||
|
|
||||||
KSynchronizationObject *signaledSyncObject = nullptr;
|
KSynchronizationObject *signaledSyncObject = nullptr;
|
||||||
Result syncResult = ResultSuccess{};
|
Result syncResult = ResultSuccess{};
|
||||||
|
|
Loading…
Reference in a new issue