mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
context: CTX_INIT interrupt flag
This commit is contained in:
@@ -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; \
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user