From 2f7b871aa0c97b78a5c6aca93956931de4437dc7 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Oct 2022 05:32:15 +0300 Subject: [PATCH] More tasking stub --- KThread.cpp | 8 +++++++ Kernel.cpp | 3 ++- Tasking/Task.cpp | 26 +++++++++++++++++++++++ include/task.hpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel.h | 3 +++ 5 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 KThread.cpp create mode 100644 Tasking/Task.cpp diff --git a/KThread.cpp b/KThread.cpp new file mode 100644 index 00000000..0c8b8d16 --- /dev/null +++ b/KThread.cpp @@ -0,0 +1,8 @@ +#include "kernel.h" + +void KernelMainThread() +{ + KPrint("Kernel main thread started!"); + // asm("int $0x1"); + CPU::Stop(); +} diff --git a/Kernel.cpp b/Kernel.cpp index 75a163f4..57abc5d7 100644 --- a/Kernel.cpp +++ b/Kernel.cpp @@ -19,6 +19,7 @@ Video::Display *Display = nullptr; SymbolResolver::Symbols *KernelSymbolTable = nullptr; Power::Power *PowerManager = nullptr; PCI::PCI *PCIManager = nullptr; +Tasking::Task *TaskManager = nullptr; KernelConfig Config; Time BootClock; @@ -83,6 +84,6 @@ EXTERNC void Entry(BootInfo *Info) SMP::Initialize(PowerManager->GetMADT()); KPrint("\e058C19######## \eE85230END \e058C19########"); CPU::Interrupts(CPU::Enable); - // asm("int $0x1"); + TaskManager = new Tasking::Task((Tasking::IP)KernelMainThread); CPU::Stop(); } diff --git a/Tasking/Task.cpp b/Tasking/Task.cpp new file mode 100644 index 00000000..e4d7c01c --- /dev/null +++ b/Tasking/Task.cpp @@ -0,0 +1,26 @@ +#include +#include + +namespace Tasking +{ + PCB *Task::CreateProcess(char *Name, ExecutionElevation Elevation) + { + PCB *Process = new PCB; + return Process; + } + + TCB *Task::CreateThread(PCB *Parent, IP EntryPoint) + { + TCB *Thread = new TCB; + return Thread; + } + + Task::Task(const IP EntryPoint) + { + trace("Starting tasking with IP: %#lx", EntryPoint); + } + + Task::~Task() + { + } +} diff --git a/include/task.hpp b/include/task.hpp index 5d163be0..65ab651a 100644 --- a/include/task.hpp +++ b/include/task.hpp @@ -3,6 +3,60 @@ #include +namespace Tasking +{ + typedef unsigned long IP; + typedef unsigned long UPID; + typedef unsigned long UTID; + enum ExecutionElevation + { + UnknownElevation, + Kernel, + System, + Idle, + User + }; + + enum ExecutionStatus + { + UnknownStatus, + Running, + Sleeping, + Waiting, + Stopped, + Terminated + }; + + struct ExecutionSecurity + { + ExecutionElevation Elevation; + }; + + struct PCB + { + UPID PID; + char Name[256]; + ExecutionSecurity Security; + ExecutionStatus Status; + }; + + struct TCB + { + UTID TID; + PCB *Parent; + IP EntryPoint; + }; + + class Task + { + public: + PCB *CreateProcess(char *Name, ExecutionElevation Elevation); + TCB *CreateThread(PCB *Parent, IP EntryPoint); + + Task(const IP EntryPoint); + ~Task(); + }; +} #endif // !__FENNIX_KERNEL_TASKING_H__ diff --git a/kernel.h b/kernel.h index c3451fef..4a8cde42 100644 --- a/kernel.h +++ b/kernel.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #endif @@ -19,9 +20,11 @@ extern SymbolResolver::Symbols *KernelSymbolTable; extern Power::Power *PowerManager; extern PCI::PCI *PCIManager; extern KernelConfig Config; +extern Tasking::Task *TaskManager; #endif EXTERNC void KPrint(const char *format, ...); EXTERNC void Entry(struct BootInfo *Info); +EXTERNC void KernelMainThread(); #endif // !__FENNIX_KERNEL_KERNEL_H__