ptos/amd64: ps: Add context switching stub
Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
@@ -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");
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <hal/page.h>
|
#include <hal/page.h>
|
||||||
#include <ps/thread.h>
|
#include <ps/thread.h>
|
||||||
#include <machine/gdt.h>
|
#include <machine/gdt.h>
|
||||||
|
#include <machine/lapic.h>
|
||||||
#include <mm/vm.h>
|
#include <mm/vm.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -79,3 +80,9 @@ HalThreadInit(THREAD *Thread, ULONG Flags, UPTR Ip)
|
|||||||
ThreadInitTcb(Thread, Tcb, Ip);
|
ThreadInitTcb(Thread, Tcb, Ip);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID
|
||||||
|
HalPrimeThreadTimer(ULONG Usec)
|
||||||
|
{
|
||||||
|
MdLapicTimerOneshotUs(Usec);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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_ */
|
||||||
@@ -22,4 +22,11 @@
|
|||||||
*/
|
*/
|
||||||
PT_STATUS HalThreadInit(THREAD *Thread, ULONG Flags, UPTR Ip);
|
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_ */
|
#endif /* !_HAL_THREAD_H_ */
|
||||||
|
|||||||
@@ -14,6 +14,9 @@
|
|||||||
#include <ptdef.h>
|
#include <ptdef.h>
|
||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
|
|
||||||
|
/* Minimum scheduler quantum in microseconds */
|
||||||
|
#define SCHED_MIN_QUANTUM 900
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Represents a scheduler queue that threads can be pulled
|
* Represents a scheduler queue that threads can be pulled
|
||||||
* from and added to.
|
* from and added to.
|
||||||
|
|||||||
@@ -9,11 +9,14 @@
|
|||||||
#include <ptdef.h>
|
#include <ptdef.h>
|
||||||
#include <ke/bpal.h>
|
#include <ke/bpal.h>
|
||||||
#include <ke/bugcheck.h>
|
#include <ke/bugcheck.h>
|
||||||
|
#include <ke/sched.h>
|
||||||
#include <ex/trace.h>
|
#include <ex/trace.h>
|
||||||
#include <ps/process.h>
|
#include <ps/process.h>
|
||||||
#include <mm/pm.h>
|
#include <mm/pm.h>
|
||||||
#include <mm/vm.h>
|
#include <mm/vm.h>
|
||||||
|
#include <hal/prim.h>
|
||||||
#include <hal/serial.h>
|
#include <hal/serial.h>
|
||||||
|
#include <hal/thread.h>
|
||||||
#include <hal/kpcr.h>
|
#include <hal/kpcr.h>
|
||||||
#include <drivers/bootvid/fbio.h>
|
#include <drivers/bootvid/fbio.h>
|
||||||
#include <drivers/acpi/acpi.h>
|
#include <drivers/acpi/acpi.h>
|
||||||
@@ -95,4 +98,11 @@ KiKernelInit(VOID)
|
|||||||
|
|
||||||
/* Initialize the root process */
|
/* Initialize the root process */
|
||||||
InitializeRootProcess();
|
InitializeRootProcess();
|
||||||
|
|
||||||
|
/* Prime the scheduler timer */
|
||||||
|
HalPrimeThreadTimer(SCHED_MIN_QUANTUM);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
HalCpuSpinWait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user