context: CTX_INIT interrupt flag

This commit is contained in:
Matheus
2024-04-28 14:32:28 -03:00
parent 1fc3791bc9
commit 8deb3a1144
2 changed files with 5 additions and 5 deletions
+3 -3
View File
@@ -44,7 +44,7 @@ typedef struct {
uint32_t mxcsr;
} extracontext_t __attribute__((aligned(16)));
#define CTX_INIT(x,u) \
#define CTX_INIT(x,u,interrupts) \
if (u) { \
(x)->cs = 0x23; \
(x)->ds = (x)->es = (x)->ss = 0x1b; \
@@ -52,12 +52,12 @@ typedef struct {
(x)->cs = 0x8; \
(x)->ds = (x)->es = (x)->ss = 0x10; \
} \
(x)->rflags = 0x200;
(x)->rflags = interrupts ? 0x200 : 0;
// all sse exceptions masked
// initialise the x87 FPU state as it would be after the FNINIT instruction
#define CTX_XINIT(x, u) {\
(x)->mxcsr = 0x1F80; \
(x)->mxcsr = 0x1f80; \
*((uint16_t *)&(x)->fx[0]) = 0x37f; \
*((uint16_t *)&(x)->fx[2]) = 0; \
(x)->fx[4] = 0; \
+2 -2
View File
@@ -91,7 +91,7 @@ thread_t *sched_newthread(void *ip, size_t kstacksize, int priority, proc_t *pro
thread->tid = __atomic_fetch_add(&currpid, 1, __ATOMIC_SEQ_CST);
CTX_INIT(&thread->context, proc != NULL);
CTX_INIT(&thread->context, proc != NULL, true);
CTX_XINIT(&thread->extracontext, proc != NULL);
CTX_SP(&thread->context) = proc ? (ctxreg_t)ustack : (ctxreg_t)thread->kernelstacktop;
CTX_IP(&thread->context) = (ctxreg_t)ip;
@@ -482,7 +482,7 @@ static void timerhook(context_t *context, dpcarg_t arg) {
current->flags |= SCHED_THREAD_FLAGS_PREEMPTED;
ARCH_CONTEXT_THREADSAVE(current, context);
CTX_INIT(context, false);
CTX_INIT(context, false, false);
CTX_SP(context) = (uintptr_t)_cpu()->schedulerstack;
CTX_IP(context) = (uintptr_t)dopreempt;
}