summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/KernelKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-13 08:46:49 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-05-13 08:50:20 +0200
commitf5f62b145d472a2a2c388c385be9d1c4e5b5d84c (patch)
treecf7fef087fd16ea345f44bb9e796327462141b98 /dev/kernel/KernelKit
parent609698e032f4d110004908d4eefcc77c43553258 (diff)
feat(kernel): see below for the commit's details.
what? - UserProcessScheduler and CoreProcessScheduler have been extended for FILE_TREE and also HEAP_TREE structures. - DDK device's API will use dk_ calls instead of sk_ calls. - SIGTRAP and Interrupt handlers have been fixed to handle when no process is being run, and the kernel is instead raising the interrupt. - Add file for HeFS formating in DiskImage.fwrk - Replace generic handler with breakpoint handler in int 3. why? - These changes are bug fixes and improvements. Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/KernelKit')
-rw-r--r--dev/kernel/KernelKit/CoreProcessScheduler.h59
-rw-r--r--dev/kernel/KernelKit/UserProcessScheduler.h30
-rw-r--r--dev/kernel/KernelKit/UserProcessScheduler.inl10
3 files changed, 69 insertions, 30 deletions
diff --git a/dev/kernel/KernelKit/CoreProcessScheduler.h b/dev/kernel/KernelKit/CoreProcessScheduler.h
index 643c5479..830f17f9 100644
--- a/dev/kernel/KernelKit/CoreProcessScheduler.h
+++ b/dev/kernel/KernelKit/CoreProcessScheduler.h
@@ -24,6 +24,65 @@ class USER_PROCESS;
class KERNEL_TASK;
class UserProcessTeam;
+enum {
+ kInvalidTreeKind = 0U,
+ kRedTreeKind = 100U,
+ kBlackTreeKind = 101U,
+ kTreeKindCount = 2U,
+};
+
+template <typename T>
+struct PROCESS_HEAP_TREE {
+ static constexpr auto kPtr = true;
+ static constexpr auto kFD = false;
+
+ T Entry{nullptr};
+ SizeT EntrySize{0UL};
+ SizeT EntryPad{0UL};
+
+ UInt32 Color{kBlackTreeKind};
+
+ struct PROCESS_HEAP_TREE<T>* Parent {
+ nullptr
+ };
+ struct PROCESS_HEAP_TREE<T>* Child {
+ nullptr
+ };
+
+ struct PROCESS_HEAP_TREE<T>* Prev {
+ nullptr
+ };
+ struct PROCESS_HEAP_TREE<T>* Next {
+ nullptr
+ };
+};
+
+template <typename T>
+struct PROCESS_FILE_TREE {
+ static constexpr auto kPtr = false;
+ static constexpr auto kFD = true;
+
+ T Entry{nullptr};
+ SizeT EntrySize{0UL};
+ SizeT EntryPad{0UL};
+
+ UInt32 Color{kBlackTreeKind};
+
+ struct PROCESS_FILE_TREE<T>* Parent {
+ nullptr
+ };
+ struct PROCESS_FILE_TREE<T>* Child {
+ nullptr
+ };
+
+ struct PROCESS_FILE_TREE<T>* Prev {
+ nullptr
+ };
+ struct PROCESS_FILE_TREE<T>* Next {
+ nullptr
+ };
+};
+
/***********************************************************************************/
/// @brief Subsystem enum type.
/***********************************************************************************/
diff --git a/dev/kernel/KernelKit/UserProcessScheduler.h b/dev/kernel/KernelKit/UserProcessScheduler.h
index 42855e11..f04f4a0a 100644
--- a/dev/kernel/KernelKit/UserProcessScheduler.h
+++ b/dev/kernel/KernelKit/UserProcessScheduler.h
@@ -55,37 +55,16 @@ class USER_PROCESS final {
SizeT MemoryLimit{kSchedMaxMemoryLimit};
SizeT UsedMemory{0UL};
- /// @brief Allocation tracker structure.
- struct USER_HEAP_TREE final {
- VoidPtr MemoryEntry{nullptr};
- SizeT MemoryEntrySize{0UL};
- SizeT MemoryEntryPad{0UL};
-
- enum {
- kInvalidMemory = 0,
- kRedMemory = 100,
- kBlackMemory = 101,
- kCountMemory = 2,
- };
-
- Int32 MemoryColor{kBlackMemory};
-
- struct USER_HEAP_TREE* MemoryParent{nullptr};
- struct USER_HEAP_TREE* MemoryChild{nullptr};
-
- struct USER_HEAP_TREE* MemoryPrev{nullptr};
- struct USER_HEAP_TREE* MemoryNext{nullptr};
- };
-
struct USER_PROCESS_SIGNAL final {
UIntPtr SignalArg;
ProcessStatusKind Status;
UIntPtr SignalID;
};
- USER_PROCESS_SIGNAL Signal;
- USER_HEAP_TREE* HeapTree{nullptr};
- UserProcessTeam* ParentTeam;
+ USER_PROCESS_SIGNAL Signal;
+ PROCESS_FILE_TREE<UInt32*>* FileTree{nullptr};
+ PROCESS_HEAP_TREE<VoidPtr>* HeapTree{nullptr};
+ UserProcessTeam* ParentTeam;
VoidPtr VMRegister{0UL};
@@ -205,6 +184,7 @@ class UserProcessScheduler final : public ISchedulable {
NE_COPY_DELETE(UserProcessScheduler)
NE_MOVE_DELETE(UserProcessScheduler)
+ public:
operator bool();
bool operator!();
diff --git a/dev/kernel/KernelKit/UserProcessScheduler.inl b/dev/kernel/KernelKit/UserProcessScheduler.inl
index 2333b898..7bf98d78 100644
--- a/dev/kernel/KernelKit/UserProcessScheduler.inl
+++ b/dev/kernel/KernelKit/UserProcessScheduler.inl
@@ -25,18 +25,18 @@ Boolean USER_PROCESS::Delete(ErrorOr<T*> ptr) {
return No;
}
- USER_HEAP_TREE* entry = this->HeapTree;
+ PROCESS_HEAP_TREE<VoidPtr>* entry = this->HeapTree;
while (entry != nullptr) {
- if (entry->MemoryEntry == ptr.Leak().Leak()) {
- this->UsedMemory -= entry->MemoryEntrySize;
+ if (entry->Entry == ptr.Leak().Leak()) {
+ this->UsedMemory -= entry->EntrySize;
#ifdef __NE_AMD64__
auto pd = hal_read_cr3();
hal_write_cr3(this->VMRegister);
- auto ret = mm_delete_heap(entry->MemoryEntry);
+ auto ret = mm_delete_heap(entry->Entry);
hal_write_cr3(pd);
@@ -48,7 +48,7 @@ Boolean USER_PROCESS::Delete(ErrorOr<T*> ptr) {
#endif
}
- entry = entry->MemoryNext;
+ entry = entry->Next;
}
kout << "USER_PROCESS: Trying to free a pointer which doesn't exist.\r";