More tasking stub

This commit is contained in:
Alex 2022-10-20 05:32:15 +03:00
parent 51c096c743
commit 2f7b871aa0
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
5 changed files with 93 additions and 1 deletions

8
KThread.cpp Normal file
View File

@ -0,0 +1,8 @@
#include "kernel.h"
void KernelMainThread()
{
KPrint("Kernel main thread started!");
// asm("int $0x1");
CPU::Stop();
}

View File

@ -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();
}

26
Tasking/Task.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <task.hpp>
#include <debug.h>
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()
{
}
}

View File

@ -3,6 +3,60 @@
#include <types.h>
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__

View File

@ -9,6 +9,7 @@
#include <symbols.hpp>
#include <kconfig.hpp>
#include <power.hpp>
#include <task.hpp>
#include <pci.hpp>
#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__