summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/KernelKit
diff options
context:
space:
mode:
Diffstat (limited to 'dev/kernel/KernelKit')
-rw-r--r--dev/kernel/KernelKit/BinaryMutex.h8
-rw-r--r--dev/kernel/KernelKit/CodeMgr.h4
-rw-r--r--dev/kernel/KernelKit/CoreProcessScheduler.h36
-rw-r--r--dev/kernel/KernelKit/DebugOutput.h16
-rw-r--r--dev/kernel/KernelKit/DriveMgr.h4
-rw-r--r--dev/kernel/KernelKit/FileMgr.h19
-rw-r--r--dev/kernel/KernelKit/HardwareThreadScheduler.h2
-rw-r--r--dev/kernel/KernelKit/KPC.h3
-rw-r--r--dev/kernel/KernelKit/KernelTaskScheduler.h19
-rw-r--r--dev/kernel/KernelKit/LoaderInterface.h6
-rw-r--r--dev/kernel/KernelKit/LockDelegate.h8
-rw-r--r--dev/kernel/KernelKit/PCI/DMA.h2
-rw-r--r--dev/kernel/KernelKit/PEF.h23
-rw-r--r--dev/kernel/KernelKit/PEFCodeMgr.h8
-rw-r--r--dev/kernel/KernelKit/Semaphore.h97
-rw-r--r--dev/kernel/KernelKit/ThreadLocalStorage.h16
-rw-r--r--dev/kernel/KernelKit/UserProcessScheduler.h9
-rw-r--r--dev/kernel/KernelKit/UserProcessScheduler.inl2
18 files changed, 209 insertions, 73 deletions
diff --git a/dev/kernel/KernelKit/BinaryMutex.h b/dev/kernel/KernelKit/BinaryMutex.h
index 45d4bd8d..f2c15af0 100644
--- a/dev/kernel/KernelKit/BinaryMutex.h
+++ b/dev/kernel/KernelKit/BinaryMutex.h
@@ -24,16 +24,16 @@ class BinaryMutex final {
bool Unlock() noexcept;
public:
- BOOL WaitForProcess(const Int16& sec) noexcept;
+ BOOL WaitForProcess(const UInt32& sec) noexcept;
public:
- bool Lock(USER_PROCESS& process);
- bool LockOrWait(USER_PROCESS& process, TimerInterface* timer);
+ bool Lock(USER_PROCESS* process);
+ bool LockOrWait(USER_PROCESS* process, TimerInterface* timer);
public:
NE_COPY_DEFAULT(BinaryMutex)
private:
- USER_PROCESS& fLockingProcess;
+ USER_PROCESS* fLockingProcess{nullptr};
};
} // namespace Kernel
diff --git a/dev/kernel/KernelKit/CodeMgr.h b/dev/kernel/KernelKit/CodeMgr.h
index 072ba4d5..c733bc47 100644
--- a/dev/kernel/KernelKit/CodeMgr.h
+++ b/dev/kernel/KernelKit/CodeMgr.h
@@ -18,6 +18,10 @@
#include <KernelKit/PECodeMgr.h>
#include <KernelKit/PEFCodeMgr.h>
+/// @file CodeMgr.h
+/// @brief Code Manager header file.
+/// @author Amlal El Mahrouss (amlal@nekernel.org)
+
namespace Kernel {
/// @brief Main process entrypoint.
typedef void (*rtl_main_kind)(void);
diff --git a/dev/kernel/KernelKit/CoreProcessScheduler.h b/dev/kernel/KernelKit/CoreProcessScheduler.h
index c06ef92c..a7908b7d 100644
--- a/dev/kernel/KernelKit/CoreProcessScheduler.h
+++ b/dev/kernel/KernelKit/CoreProcessScheduler.h
@@ -9,13 +9,17 @@
#include <NeKit/Defines.h>
#include <NeKit/ErrorOr.h>
+/// @file CoreProcessScheduler.h
+/// @brief Core Process Scheduler header file.
+/// @author Amlal El Mahrouss (amlal@nekernel.org)
+
#define kSchedMinMicroTime (AffinityKind::kStandard)
#define kSchedInvalidPID (-1)
#define kSchedProcessLimitPerTeam (32U)
#define kSchedTeamCount (256U)
-#define kSchedMaxMemoryLimit gib_cast(128) /* max physical memory limit */
-#define kSchedMaxStackSz (kib_cast(8)) /* maximum stack size */
+#define kSchedMaxMemoryLimit (gib_cast(128)) /* max physical memory limit */
+#define kSchedMaxStackSz (kib_cast(8)) /* maximum stack size */
#define kSchedNameLen (128U)
@@ -32,19 +36,23 @@ template <typename T>
struct PROCESS_HEAP_TREE;
template <typename T>
+struct PROCESS_SPECIAL_TREE;
+
+template <typename T>
struct PROCESS_FILE_TREE;
enum {
kInvalidTreeKind = 0U,
kRedTreeKind = 100U,
kBlackTreeKind = 101U,
- kTreeKindCount = 2U,
+ kTreeKindCount = 3U,
};
template <typename T>
struct PROCESS_HEAP_TREE {
- static constexpr auto kPtr = true;
- static constexpr auto kFD = false;
+ static constexpr auto kHeap = true;
+ static constexpr auto kFile = false;
+ static constexpr auto kSpecial = false;
T Entry{nullptr};
SizeT EntrySize{0UL};
@@ -69,8 +77,9 @@ struct PROCESS_HEAP_TREE {
template <typename T>
struct PROCESS_FILE_TREE {
- static constexpr auto kPtr = false;
- static constexpr auto kFD = true;
+ static constexpr auto kHeap = false;
+ static constexpr auto kFile = true;
+ static constexpr auto kSpecial = false;
T Entry{nullptr};
SizeT EntrySize{0UL};
@@ -81,6 +90,7 @@ struct PROCESS_FILE_TREE {
struct PROCESS_FILE_TREE<T>* Parent {
nullptr
};
+
struct PROCESS_FILE_TREE<T>* Child {
nullptr
};
@@ -88,6 +98,7 @@ struct PROCESS_FILE_TREE {
struct PROCESS_FILE_TREE<T>* Prev {
nullptr
};
+
struct PROCESS_FILE_TREE<T>* Next {
nullptr
};
@@ -106,8 +117,6 @@ enum class ProcessSubsystem : Int32 {
kProcessSubsystemCount = 4,
};
-typedef UInt64 PTime;
-
/***********************************************************************************/
//! @brief Local Process identifier.
/***********************************************************************************/
@@ -170,7 +179,8 @@ inline bool operator>=(AffinityKind lhs, AffinityKind rhs) {
return lhs_int >= rhs_int;
}
-using ProcessTime = UInt64;
+using PTime = UInt64;
+using ProcessTime = PTime;
using PID = Int64;
/***********************************************************************************/
@@ -180,7 +190,7 @@ enum class ProcessLevelRing : Int32 {
kRingStdUser = 1,
kRingSuperUser = 2,
kRingGuestUser = 5,
- kRingCount = 5,
+ kRingCount = 3,
};
/***********************************************************************************/
@@ -200,8 +210,8 @@ struct PROCESS_IMAGE final {
friend class UserProcessScheduler;
- ImagePtr fCode;
- ImagePtr fBlob;
+ ImagePtr fCode{};
+ ImagePtr fBlob{};
public:
Bool HasCode() const { return this->fCode != nullptr; }
diff --git a/dev/kernel/KernelKit/DebugOutput.h b/dev/kernel/KernelKit/DebugOutput.h
index de3bc997..992d1ca7 100644
--- a/dev/kernel/KernelKit/DebugOutput.h
+++ b/dev/kernel/KernelKit/DebugOutput.h
@@ -12,7 +12,7 @@
#include <NeKit/Stream.h>
#include <NeKit/Utils.h>
-#define kDebugUnboundPort 0x0FEED
+#define kDebugPort (51820U)
#define kDebugMag0 'K'
#define kDebugMag1 'D'
@@ -27,7 +27,7 @@
namespace Kernel {
class TerminalDevice;
class DTraceDevice;
-class DebugDevice;
+class NeDebugDevice;
class Utf8TerminalDevice;
inline TerminalDevice end_line();
@@ -180,17 +180,9 @@ inline TerminalDevice get_console_in(Char* buf) {
return self;
}
-inline constexpr SizeT kDebugTypeLen = 256U;
+inline constexpr SizeT kDebugCmdLen = 256U;
-typedef Char rt_debug_type[kDebugTypeLen];
-
-/// @brief KDBG's packet header.
-class KernelDebugHeader final {
- public:
- Int16 fPort;
- Int16 fPortKind;
- rt_debug_type fPortBlob;
-};
+typedef Char rt_debug_cmd[kDebugCmdLen];
inline TerminalDevice& operator<<(TerminalDevice& src, const Long& num) {
src = number(num);
diff --git a/dev/kernel/KernelKit/DriveMgr.h b/dev/kernel/KernelKit/DriveMgr.h
index 4a530deb..69df1cec 100644
--- a/dev/kernel/KernelKit/DriveMgr.h
+++ b/dev/kernel/KernelKit/DriveMgr.h
@@ -7,6 +7,10 @@
#ifndef INC_DRIVE_MANAGER_H
#define INC_DRIVE_MANAGER_H
+/// @file DriveMgr.h
+/// @brief Drive Manager.
+/// @author Amlal El Mahrouss (amlal@nekernel.org)
+
#include <CompilerKit/CompilerKit.h>
#include <KernelKit/DebugOutput.h>
#include <KernelKit/DeviceMgr.h>
diff --git a/dev/kernel/KernelKit/FileMgr.h b/dev/kernel/KernelKit/FileMgr.h
index 13eeabdf..f925a96c 100644
--- a/dev/kernel/KernelKit/FileMgr.h
+++ b/dev/kernel/KernelKit/FileMgr.h
@@ -4,6 +4,7 @@
File: FileMgr.h
Purpose: Kernel file manager.
+ Author: Amlal El Mahrouss (amlal@nekernel.org)
------------------------------------------- */
@@ -21,7 +22,11 @@
#ifndef INC_FILEMGR_H
#define INC_FILEMGR_H
-//! Include filesystems that neoskrnl supports.
+/// @file FileMgr.h
+/// @brief File Manager.
+/// @author Amlal El Mahrouss (amlal@nekernel.org)
+
+//! Include filesystems that NeKernel supports.
#include <FSKit/Ext2.h>
#include <FSKit/HeFS.h>
#include <FSKit/NeFS.h>
@@ -48,11 +53,6 @@
#define rtl_node_cast(PTR) reinterpret_cast<Kernel::NodePtr>(PTR)
-/**
- @note Refer to first enum.
-*/
-#define kFileOpsCount (4U)
-
#define kFileMimeGeneric "ne-application-kind/all"
/** @brief invalid position. (n-pos) */
@@ -65,10 +65,10 @@ enum {
kFileReadAll = 101,
kFileReadChunk = 102,
kFileWriteChunk = 103,
- kFileIOCnt = (kFileWriteChunk - kFileWriteAll) + 1,
// File flags (HFS+, NeFS specific)
kFileFlagRsrc = 104,
kFileFlagData = 105,
+ kFileIOCnt = (kFileFlagData - kFileWriteAll) + 1,
};
typedef VoidPtr NodePtr;
@@ -284,12 +284,10 @@ class FileStream final {
this->fFileRestrict != kFileMgrRestrictReadBinary)
return nullptr;
- NE_UNUSED(sz);
-
auto man = FSClass::GetMounted();
if (man) {
- VoidPtr ret = man->Read(name, fFile, kFileReadAll, 0);
+ VoidPtr ret = man->Read(name, fFile, kFileReadAll, sz);
return ret;
}
@@ -394,6 +392,7 @@ inline FileStream<Encoding, Class>::FileStream(const Encoding* path, const Encod
template <typename Encoding, typename Class>
inline FileStream<Encoding, Class>::~FileStream() {
mm_free_ptr(fFile);
+ fFile = nullptr;
}
} // namespace Kernel
diff --git a/dev/kernel/KernelKit/HardwareThreadScheduler.h b/dev/kernel/KernelKit/HardwareThreadScheduler.h
index 76327a93..168a0cc1 100644
--- a/dev/kernel/KernelKit/HardwareThreadScheduler.h
+++ b/dev/kernel/KernelKit/HardwareThreadScheduler.h
@@ -100,7 +100,7 @@ class HardwareThreadScheduler final : public ISchedulable {
public:
Ref<HardwareThread*> operator[](SizeT idx);
bool operator!() noexcept;
- operator bool() noexcept;
+ operator bool() noexcept;
Bool IsUser() override { return Yes; }
diff --git a/dev/kernel/KernelKit/KPC.h b/dev/kernel/KernelKit/KPC.h
index a3b13de6..794197e2 100644
--- a/dev/kernel/KernelKit/KPC.h
+++ b/dev/kernel/KernelKit/KPC.h
@@ -65,6 +65,9 @@ inline constexpr KPCError kErrorFileLocked = 64;
inline constexpr KPCError kErrorDiskIsTooTiny = 65;
inline constexpr KPCError kErrorDmaExhausted = 66;
inline constexpr KPCError kErrorOutOfBitMapMemory = 67;
+inline constexpr KPCError kErrorTimeout = 68;
+inline constexpr KPCError kErrorAccessDenied = 69;
+inline constexpr KPCError kErrorUnavailable = 70;
/// Generic errors.
inline constexpr KPCError kErrorUnimplemented = -1;
diff --git a/dev/kernel/KernelKit/KernelTaskScheduler.h b/dev/kernel/KernelKit/KernelTaskScheduler.h
index 57b83ccb..c0879769 100644
--- a/dev/kernel/KernelKit/KernelTaskScheduler.h
+++ b/dev/kernel/KernelKit/KernelTaskScheduler.h
@@ -15,6 +15,12 @@
#include <KernelKit/LockDelegate.h>
namespace Kernel {
+class KernelTaskHelper;
+
+typedef PID KID;
+
+/// @brief Equivalent of USER_PROCESS, but for kernel tasks.
+/// @author Amlal
class KERNEL_TASK final {
public:
Char Name[kSchedNameLen] = {"KERNEL_TASK"};
@@ -23,5 +29,18 @@ class KERNEL_TASK final {
UInt8* StackReserve{nullptr};
SizeT StackSize{kSchedMaxStackSz};
PROCESS_IMAGE Image{};
+ /// @brief a KID is a Kernel Identification Descriptor, it is used to find a task running within
+ /// the kernel.
+ KID Kid{0};
+};
+
+/// @brief Equivalent of UserProcessHelper, but for kernel tasks.
+/// @author Amlal
+class KernelTaskHelper final {
+ public:
+ STATIC Bool Switch(HAL::StackFramePtr frame_ptr, PID new_kid);
+ STATIC Bool CanBeScheduled(const KERNEL_TASK& process);
+ STATIC ErrorOr<PID> TheCurrentKID();
+ STATIC SizeT StartScheduling();
};
} // namespace Kernel \ No newline at end of file
diff --git a/dev/kernel/KernelKit/LoaderInterface.h b/dev/kernel/KernelKit/LoaderInterface.h
index 1f9b1e56..ed7d8364 100644
--- a/dev/kernel/KernelKit/LoaderInterface.h
+++ b/dev/kernel/KernelKit/LoaderInterface.h
@@ -23,9 +23,9 @@ class LoaderInterface {
public:
virtual _Output ErrorOr<VoidPtr> GetBlob() = 0;
- virtual _Output const Char* AsString() = 0;
- virtual _Output const Char* MIME() = 0;
- virtual _Output const Char* Path() = 0;
+ virtual _Output const Char* AsString() = 0;
+ virtual _Output const Char* MIME() = 0;
+ virtual _Output const Char* Path() = 0;
virtual _Output ErrorOr<VoidPtr> FindStart() = 0;
virtual _Output ErrorOr<VoidPtr> FindSymbol(_Input const Char* name, _Input Int32 kind) = 0;
};
diff --git a/dev/kernel/KernelKit/LockDelegate.h b/dev/kernel/KernelKit/LockDelegate.h
index b5977c92..a8c36de7 100644
--- a/dev/kernel/KernelKit/LockDelegate.h
+++ b/dev/kernel/KernelKit/LockDelegate.h
@@ -11,10 +11,10 @@
namespace Kernel {
enum {
- kLockInvalid = 0,
- kLockDone = 200,
- kLockTimedOut,
- kLockCount = 3,
+ kLockInvalid = 0,
+ kLockDone = 200,
+ kLockTimedOut = 300,
+ kLockCount = 3,
};
/// @brief Lock condition pointer.
diff --git a/dev/kernel/KernelKit/PCI/DMA.h b/dev/kernel/KernelKit/PCI/DMA.h
index 7e7d3f0c..c4e3b61a 100644
--- a/dev/kernel/KernelKit/PCI/DMA.h
+++ b/dev/kernel/KernelKit/PCI/DMA.h
@@ -47,7 +47,7 @@ class DMAWrapper final {
T* Get(UIntPtr off = 0);
public:
- operator bool();
+ operator bool();
bool operator!();
public:
diff --git a/dev/kernel/KernelKit/PEF.h b/dev/kernel/KernelKit/PEF.h
index c28c8f8c..fd39392e 100644
--- a/dev/kernel/KernelKit/PEF.h
+++ b/dev/kernel/KernelKit/PEF.h
@@ -11,19 +11,19 @@
------------------------------------------- */
-#ifndef KERNELKIT_PEF_H
-#define KERNELKIT_PEF_H
+#ifndef __KERNELKIT_PEF_H__
+#define __KERNELKIT_PEF_H__
#include <CompilerKit/CompilerKit.h>
#include <KernelKit/LoaderInterface.h>
#include <NeKit/Defines.h>
-#define kPefMagic "Joy!"
-#define kPefMagicFat "yoJ!"
+#define kPefMagic "Open"
+#define kPefMagicFat "nepO"
#define kPefMagicLen (5)
-#define kPefVersion (4)
+#define kPefVersion (0x0500)
#define kPefNameLen (256U)
/* not mandatory, only for non fork based filesystems. */
@@ -54,15 +54,15 @@ enum {
kPefArch32x0, /* 32x0. ISA */
kPefArchPowerPC,
kPefArchARM64,
- kPefArchCount = (kPefArchPowerPC - kPefArchIntel86S) + 1,
+ kPefArchCount = (kPefArchARM64 - kPefArchIntel86S) + 1,
kPefArchInvalid = 0xFF,
};
enum {
+ kPefSubArchGeneric,
kPefSubArchAMD = 200,
kPefSubArchIntel,
kPefSubArchARM,
- kPefSubArchGeneric,
kPefSubArchIBM,
};
@@ -98,16 +98,19 @@ typedef struct PEFCommandHeader final {
UInt32 Flags; /* container flags */
UInt16 Kind; /* container kind */
UIntPtr Offset; /* content offset */
- UIntPtr VMAddress; /* VM offset */
- SizeT Size; /* content Size */
+ SizeT OffsetSize; /* offset size (physical size inside the file) */
+ UIntPtr VMAddress; /* Virtual Address */
+ SizeT VMSize; /* Virtual Size */
} PACKED PEFCommandHeader;
enum {
+ kPefInvalid = 0x0,
kPefCode = 0xC,
kPefData = 0xD,
kPefZero = 0xE,
kPefLinkerID = 0x1,
+ kPefCount = 4,
};
} // namespace Kernel
-#endif /* ifndef KERNELKIT_PEF_H */
+#endif /* ifndef __KERNELKIT_PEF_H__ */
diff --git a/dev/kernel/KernelKit/PEFCodeMgr.h b/dev/kernel/KernelKit/PEFCodeMgr.h
index 18041f8f..d61aa863 100644
--- a/dev/kernel/KernelKit/PEFCodeMgr.h
+++ b/dev/kernel/KernelKit/PEFCodeMgr.h
@@ -7,6 +7,10 @@
#ifndef _INC_CODE_MANAGER_PEF_H_
#define _INC_CODE_MANAGER_PEF_H_
+/// @file PEFCodeMgr.h
+/// @brief PEF Code Manager header file.
+/// @author Amlal El Mahrouss (amlal@nekernel.org)
+
#include <KernelKit/FileMgr.h>
#include <KernelKit/PEF.h>
#include <NeKit/ErrorOr.h>
@@ -59,8 +63,8 @@ class PEFLoader : public LoaderInterface {
Ref<KString> fPath;
VoidPtr fCachedBlob;
- bool fFatBinary;
- bool fBad;
+ BOOL fFatBinary{};
+ BOOL fBad{};
};
namespace Utils {
diff --git a/dev/kernel/KernelKit/Semaphore.h b/dev/kernel/KernelKit/Semaphore.h
index a1b5ecad..f73f36ed 100644
--- a/dev/kernel/KernelKit/Semaphore.h
+++ b/dev/kernel/KernelKit/Semaphore.h
@@ -6,10 +6,105 @@
#pragma once
+/// @author Amlal El Mahrouss
+/// @file Semaphore.h
+/// @brief Semaphore structure and functions for synchronization in the kernel.
+
#include <CompilerKit/CompilerKit.h>
#include <KernelKit/Timer.h>
#include <NeKit/Defines.h>
+#define kSemaphoreOwnerIndex (0U)
+#define kSemaphoreCountIndex (1U)
+
+#define kSemaphoreCount (2U)
+
+#define kSemaphoreIncrementOwner(sem) (sem[kSemaphoreOwnerIndex]++)
+#define kSemaphoreDecrementOwner(sem) (sem[kSemaphoreOwnerIndex]--)
+
namespace Kernel {
-typedef Int64 Semaphore;
+/// @brief Semaphore structure used for synchronization.
+typedef UInt64 SemaphoreArr[kSemaphoreCount];
+
+/// @brief Checks if the semaphore is valid.
+inline BOOL rtl_sem_is_valid(const SemaphoreArr& sem, UInt64 owner = 0) {
+ return sem[kSemaphoreOwnerIndex] == owner && sem[kSemaphoreCountIndex] > 0;
+}
+
+/// @brief Releases the semaphore, resetting its owner and count.
+/// @param sem
+/// @return
+inline BOOL rtl_sem_release(SemaphoreArr& sem) {
+ sem[kSemaphoreOwnerIndex] = 0;
+ sem[kSemaphoreCountIndex] = 0;
+
+ return TRUE;
+}
+
+/// @brief Initializes the semaphore with an owner and a count of zero.
+/// @param sem the semaphore array to use.
+/// @param owner the owner to set, could be anything identifitable.
+/// @return
+inline BOOL rtl_sem_acquire(SemaphoreArr& sem, UInt64 owner) {
+ if (!owner) {
+ err_global_get() = kErrorInvalidData;
+ return FALSE; // Invalid owner
+ }
+
+ sem[kSemaphoreOwnerIndex] = owner;
+ sem[kSemaphoreCountIndex] = 0;
+
+ return TRUE;
+}
+
+/// @brief Waits for the semaphore to be available, blocking until it is.
+/// @param sem
+/// @param timeout
+/// @param condition condition pointer.
+/// @return
+inline BOOL rtl_sem_wait(SemaphoreArr& sem, UInt64 owner, UInt64 timeout,
+ BOOL* condition = nullptr) {
+ if (!rtl_sem_is_valid(sem, owner)) {
+ return FALSE;
+ }
+
+ if (timeout <= 0) {
+ err_global_get() = kErrorTimeout;
+
+ return FALSE;
+ }
+
+ if (!condition || *condition) {
+ if (sem[kSemaphoreCountIndex] == 0) {
+ err_global_get() = kErrorUnavailable;
+ return FALSE;
+ }
+
+ err_global_get() = kErrorSuccess;
+ sem[kSemaphoreCountIndex]--;
+
+ return TRUE;
+ }
+
+ HardwareTimer timer(timeout);
+ BOOL ret = timer.Wait();
+
+ if (ret) {
+ if (!condition || *condition) {
+ if (sem[kSemaphoreCountIndex] == 0) {
+ err_global_get() = kErrorUnavailable;
+ return FALSE;
+ }
+
+ err_global_get() = kErrorSuccess;
+ sem[kSemaphoreCountIndex]--;
+
+ return TRUE;
+ }
+ }
+
+ err_global_get() = kErrorTimeout;
+
+ return FALSE; // Failed to acquire semaphore
+}
} // namespace Kernel \ No newline at end of file
diff --git a/dev/kernel/KernelKit/ThreadLocalStorage.h b/dev/kernel/KernelKit/ThreadLocalStorage.h
index 1b8e4821..47ff526c 100644
--- a/dev/kernel/KernelKit/ThreadLocalStorage.h
+++ b/dev/kernel/KernelKit/ThreadLocalStorage.h
@@ -10,24 +10,24 @@
#include <NeKit/Defines.h>
#include <NeKit/ErrorOr.h>
-///! @brief Thread Local Storage for neoskrnl.
+///! @brief Thread Local Storage for NeKernel.
-#define kCookieMag0Idx 0
-#define kCookieMag1Idx 1
-#define kCookieMag2Idx 2
+#define kCookieMag0Idx (0U)
+#define kCookieMag1Idx (1U)
+#define kCookieMag2Idx (2U)
-#define kCookieMag0 'Z'
+#define kCookieMag0 'N'
#define kCookieMag1 'K'
-#define kCookieMag2 'A'
+#define kCookieMag2 'O'
-#define kTLSCookieLen (3U)
+#define kCookieMagLen (3U)
struct THREAD_INFORMATION_BLOCK;
/// @brief Thread Information Block.
/// Located in GS on AMD64, other architectures have their own stuff. (64x0, 32x0, ARM64)
struct PACKED THREAD_INFORMATION_BLOCK final {
- Kernel::Char Cookie[kTLSCookieLen]{0}; //! Thread Magic Number.
+ Kernel::Char Cookie[kCookieMagLen]{0}; //! Thread Magic Number.
Kernel::VoidPtr UserData{nullptr}; //! Thread Information Record (User defined canary structure)
};
diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h
index 5bc5b8d2..3dae178a 100644
--- a/dev/kernel/KernelKit/UserProcessScheduler.h
+++ b/dev/kernel/KernelKit/UserProcessScheduler.h
@@ -62,7 +62,7 @@ class USER_PROCESS final {
};
USER_PROCESS_SIGNAL Signal;
- PROCESS_FILE_TREE<UInt32*>* FileTree{nullptr};
+ PROCESS_FILE_TREE<VoidPtr>* FileTree{nullptr};
PROCESS_HEAP_TREE<VoidPtr>* HeapTree{nullptr};
UserProcessTeam* ParentTeam;
@@ -93,7 +93,10 @@ class USER_PROCESS final {
/***********************************************************************************/
Void Crash();
- Bool SpawnDylib();
+ /***********************************************************************************/
+ ///! @brief Spawns a dynamic library handle if dylib.
+ /***********************************************************************************/
+ Bool InitDylib();
/***********************************************************************************/
///! @brief Exits the app.
@@ -189,7 +192,7 @@ class UserProcessScheduler final : public ISchedulable {
NE_MOVE_DELETE(UserProcessScheduler)
public:
- operator bool();
+ operator bool();
bool operator!();
public:
diff --git a/dev/kernel/KernelKit/UserProcessScheduler.inl b/dev/kernel/KernelKit/UserProcessScheduler.inl
index df35e037..0605a5e0 100644
--- a/dev/kernel/KernelKit/UserProcessScheduler.inl
+++ b/dev/kernel/KernelKit/UserProcessScheduler.inl
@@ -17,7 +17,7 @@
namespace Kernel {
/***********************************************************************************/
-/** @brief Free pointer from usage. */
+/** @brief Free pointer/file from usage. */
/***********************************************************************************/
template <typename T>