ptos/amd64: ps: Add context switching stub

Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
2026-07-14 16:40:06 -04:00
parent 093061f2ad
commit a029f0de5d
6 changed files with 65 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: MD context management
* Author: Chloe M.
*/
#include <hal/context.h>
#include <ex/trace.h>
VOID
HalContextSwitch(TRAP_FRAME *Frame)
{
TRACE("CONTEXT SWITCHING IS A TODO\n");
}
+7
View File
@@ -10,6 +10,7 @@
#include <hal/page.h>
#include <ps/thread.h>
#include <machine/gdt.h>
#include <machine/lapic.h>
#include <mm/vm.h>
#include <string.h>
@@ -79,3 +80,9 @@ HalThreadInit(THREAD *Thread, ULONG Flags, UPTR Ip)
ThreadInitTcb(Thread, Tcb, Ip);
return STATUS_SUCCESS;
}
VOID
HalPrimeThreadTimer(ULONG Usec)
{
MdLapicTimerOneshotUs(Usec);
}
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: HAL context management
* Author: Chloe M.
*/
#ifndef _HAL_CONTEXT_H_
#define _HAL_CONTEXT_H_ 1
#include <machine/frame.h>
#include <ptdef.h>
/*
* Perform a context switch from one thread to another
*
* @Frame: Current processor context
*/
VOID HalContextSwitch(TRAP_FRAME *Frame);
#endif /* !_HAL_CONTEXT_H_ */
+7
View File
@@ -22,4 +22,11 @@
*/
PT_STATUS HalThreadInit(THREAD *Thread, ULONG Flags, UPTR Ip);
/*
* Prime the scheduler timer
*
* @Usec: Number of microseconds to prime for
*/
VOID HalPrimeThreadTimer(ULONG Usec);
#endif /* !_HAL_THREAD_H_ */
+3
View File
@@ -14,6 +14,9 @@
#include <ptdef.h>
#include <queue.h>
/* Minimum scheduler quantum in microseconds */
#define SCHED_MIN_QUANTUM 900
/*
* Represents a scheduler queue that threads can be pulled
* from and added to.
+10
View File
@@ -9,11 +9,14 @@
#include <ptdef.h>
#include <ke/bpal.h>
#include <ke/bugcheck.h>
#include <ke/sched.h>
#include <ex/trace.h>
#include <ps/process.h>
#include <mm/pm.h>
#include <mm/vm.h>
#include <hal/prim.h>
#include <hal/serial.h>
#include <hal/thread.h>
#include <hal/kpcr.h>
#include <drivers/bootvid/fbio.h>
#include <drivers/acpi/acpi.h>
@@ -95,4 +98,11 @@ KiKernelInit(VOID)
/* Initialize the root process */
InitializeRootProcess();
/* Prime the scheduler timer */
HalPrimeThreadTimer(SCHED_MIN_QUANTUM);
for (;;) {
HalCpuSpinWait();
}
}