Subversion Repositories HelenOS

Rev

Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3022 Rev 4055
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 56... Line 55...
56
 *
55
 *
57
 * THREAD is locked and interrupts are disabled.
56
 * THREAD is locked and interrupts are disabled.
58
 */
57
 */
59
void before_thread_runs_arch(void)
58
void before_thread_runs_arch(void)
60
{
59
{
61
    CPU->arch.tss->esp0 = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE -
60
    uintptr_t kstk = (uintptr_t) &THREAD->kstack[THREAD_STACK_SIZE -
62
        SP_DELTA];
61
        SP_DELTA];
-
 
62
 
-
 
63
    /* Set kernel stack for CP3 -> CPL0 switch via SYSENTER */
-
 
64
    write_msr(IA32_MSR_SYSENTER_ESP, kstk);
-
 
65
 
-
 
66
    /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */
-
 
67
    CPU->arch.tss->esp0 = kstk;
63
    CPU->arch.tss->ss0 = selector(KDATA_DES);
68
    CPU->arch.tss->ss0 = selector(KDATA_DES);
64
 
69
 
65
    /* Set up TLS in GS register */
70
    /* Set up TLS in GS register */
66
    set_tls_desc(THREAD->arch.tls);
71
    set_tls_desc(THREAD->arch.tls);
67
 
-
 
68
#ifdef CONFIG_DEBUG_AS_WATCHPOINT
-
 
69
    /* Set watchpoint on AS to ensure that nobody sets it to zero */
-
 
70
    if (CPU->id < BKPOINTS_MAX) {
-
 
71
        the_t *the = THE;
-
 
72
        breakpoint_add(&((the_t *) the->thread->kstack)->as,
-
 
73
            BKPOINT_WRITE | BKPOINT_CHECK_ZERO, the->cpu->id);
-
 
74
    }
-
 
75
#endif
-
 
76
}
72
}
77
 
73
 
78
void after_thread_ran_arch(void)
74
void after_thread_ran_arch(void)
79
{
75
{
80
}
76
}