1 /*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7 #include <object.h>
8 #include <machine.h>
9 #include <arch/model/statedata.h>
10 #include <arch/kernel/vspace.h>
11 #include <arch/kernel/thread.h>
12 #include <linker.h>
13
Arch_switchToThread(tcb_t * tcb)14 void Arch_switchToThread(tcb_t *tcb)
15 {
16 /* set PD */
17 setVMRoot(tcb);
18 if (config_set(CONFIG_KERNEL_X86_IBPB_ON_CONTEXT_SWITCH)) {
19 x86_ibpb();
20 }
21
22 if (config_set(CONFIG_KERNEL_X86_RSB_ON_CONTEXT_SWITCH)) {
23 x86_flush_rsb();
24 }
25 }
26
Arch_configureIdleThread(tcb_t * tcb)27 BOOT_CODE void Arch_configureIdleThread(tcb_t *tcb)
28 {
29 setRegister(tcb, FLAGS, FLAGS_USER_DEFAULT);
30 setRegister(tcb, NextIP, (word_t)idleThreadStart);
31 setRegister(tcb, CS, SEL_CS_0);
32 setRegister(tcb, SS, SEL_DS_0);
33 setRegister(tcb, FS_BASE, 0);
34 setRegister(tcb, GS_BASE, 0);
35 }
36
Arch_switchToIdleThread(void)37 void Arch_switchToIdleThread(void)
38 {
39 /* Force the idle thread to run on kernel page table */
40 setVMRoot(NODE_STATE(ksIdleThread));
41 }
42
Arch_activateIdleThread(tcb_t * tcb)43 void Arch_activateIdleThread(tcb_t *tcb)
44 {
45 /* Don't need to do anything */
46 }
47
Mode_postModifyRegisters(tcb_t * tptr)48 void Mode_postModifyRegisters(tcb_t *tptr)
49 {
50 /* Don't need to do anything */
51 }
52