Rev 3536 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3536 | Rev 4377 | ||
---|---|---|---|
Line 36... | Line 36... | ||
36 | #include <cpu.h> |
36 | #include <cpu.h> |
37 | #include <proc/task.h> |
37 | #include <proc/task.h> |
38 | #include <proc/thread.h> |
38 | #include <proc/thread.h> |
39 | #include <arch.h> |
39 | #include <arch.h> |
40 | #include <arch/context.h> /* SP_DELTA */ |
40 | #include <arch/context.h> /* SP_DELTA */ |
41 | #include <arch/debugger.h> |
- | |
42 | #include <arch/pm.h> |
41 | #include <arch/pm.h> |
43 | #include <arch/asm.h> |
42 | #include <arch/asm.h> |
44 | #include <arch/ddi/ddi.h> |
43 | #include <arch/ddi/ddi.h> |
45 | 44 | ||
46 | /** Perform ia32 specific tasks needed before the new task is run. |
45 | /** Perform ia32 specific tasks needed before the new task is run. |
Line 58... | Line 57... | ||
58 | */ |
57 | */ |
59 | void before_thread_runs_arch(void) |
58 | void before_thread_runs_arch(void) |
60 | { |
59 | { |
61 | uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE - |
60 | uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE - |
62 | SP_DELTA]; |
61 | SP_DELTA]; |
63 | 62 | ||
64 | /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */ |
63 | /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */ |
65 | write_msr(IA32_MSR_SYSENTER_ESP, kstk); |
64 | write_msr(IA32_MSR_SYSENTER_ESP, kstk); |
66 | 65 | ||
67 | /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */ |
66 | /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */ |
68 | CPU->arch.tss->esp0 = kstk; |
67 | CPU->arch.tss->esp0 = kstk; |
69 | CPU->arch.tss->ss0 = selector(KDATA_DES); |
68 | CPU->arch.tss->ss0 = gdtselector(KDATA_DES); |
70 | 69 | ||
71 | /* Set up TLS in GS register */ |
70 | /* Set up TLS in GS register */ |
72 | set_tls_desc(THREAD->arch.tls); |
71 | set_tls_desc(THREAD->arch.tls); |
73 | - | ||
74 | #ifdef CONFIG_DEBUG_AS_WATCHPOINT |
- | |
75 | /* Set watchpoint on AS to ensure that nobody sets it to zero */ |
- | |
76 | if (CPU->id < BKPOINTS_MAX) { |
- | |
77 | the_t *the = THE; |
- | |
78 | breakpoint_add(&((the_t *) the->thread->kstack)->as, |
- | |
79 | BKPOINT_WRITE | BKPOINT_CHECK_ZERO, the->cpu->id); |
- | |
80 | } |
- | |
81 | #endif |
- | |
82 | } |
72 | } |
83 | 73 | ||
84 | void after_thread_ran_arch(void) |
74 | void after_thread_ran_arch(void) |
85 | { |
75 | { |
86 | } |
76 | } |