feat: scheduling, usermode, shell
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <Io/IoPort.hpp>
|
||||
#include <Terminal/Terminal.hpp>
|
||||
#include <CppLib/Stream.hpp>
|
||||
#include <Sched/Scheduler.hpp>
|
||||
|
||||
using namespace Kt;
|
||||
|
||||
@@ -34,9 +35,15 @@ namespace Timekeeping {
|
||||
static volatile uint64_t g_tickCount = 0;
|
||||
static uint32_t g_ticksPerMs = 0;
|
||||
|
||||
// Timer IRQ handler: increment tick count
|
||||
static bool g_schedEnabled = false;
|
||||
|
||||
// Timer IRQ handler: increment tick count and drive scheduler
|
||||
static void TimerHandler(uint8_t) {
|
||||
g_tickCount = g_tickCount + 1;
|
||||
|
||||
if (g_schedEnabled) {
|
||||
Sched::Tick();
|
||||
}
|
||||
}
|
||||
|
||||
// Use PIT channel 2 to create a precise delay for calibration.
|
||||
@@ -128,10 +135,14 @@ namespace Timekeeping {
|
||||
return g_tickCount; // 1 tick = 1 ms at 1000 Hz
|
||||
}
|
||||
|
||||
void EnableSchedulerTick() {
|
||||
g_schedEnabled = true;
|
||||
}
|
||||
|
||||
void Sleep(uint64_t ms) {
|
||||
uint64_t target = g_tickCount + ms;
|
||||
while (g_tickCount < target) {
|
||||
asm volatile("hlt");
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace Timekeeping {
|
||||
// Get elapsed milliseconds since timer initialization
|
||||
uint64_t GetMilliseconds();
|
||||
|
||||
// Enable scheduler tick (called after scheduler is initialized)
|
||||
void EnableSchedulerTick();
|
||||
|
||||
// Busy-wait sleep for the given number of milliseconds
|
||||
void Sleep(uint64_t ms);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user