Subversion Repositories HelenOS-historic

Rev

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

Rev 902 Rev 903
Line 31... Line 31...
31
#include <arch.h>
31
#include <arch.h>
32
#include <arch/mm/tlb.h>
32
#include <arch/mm/tlb.h>
33
#include <config.h>
33
#include <config.h>
34
#include <align.h>
34
#include <align.h>
35
 
35
 
36
/** Ensure that thread's kernel stack is locked in TLB. */
36
/** Record kernel stack address in ar.k7 and make sure it is mapped in DTR. */
37
void before_thread_runs_arch(void)
37
void before_thread_runs_arch(void)
38
{
38
{
39
    __address base;
39
    __address base;
40
   
40
   
41
    base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
41
    base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
42
 
42
 
43
    if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + (1<<KERNEL_PAGE_WIDTH)) {
43
    if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + (1<<KERNEL_PAGE_WIDTH)) {
44
        /*
44
        /*
45
         * Kernel stack of this thread is not locked in DTLB.
45
         * Kernel stack of this thread is not mapped by DTR[TR_KERNEL].
46
         * First, make sure it is not mapped already.
46
         * Use DTR[TR_KSTACK] to map it.
47
         * If not, fill respective tranlsation register.
-
 
48
         */
47
         */
49
         dtlb_kernel_mapping_insert((__address) THREAD->kstack, KA2PA(THREAD->kstack), true, DTR_KSTACK);
48
         dtlb_kernel_mapping_insert((__address) THREAD->kstack, KA2PA(THREAD->kstack), true, DTR_KSTACK);
50
    }
49
    }
-
 
50
   
-
 
51
    /*
-
 
52
     * Record address of kernel stack to ar.k7
-
 
53
     * where it will be found after switch
-
 
54
     * from userspace.
-
 
55
     */
-
 
56
    __asm__ volatile ("mov ar.k7 = %0\n" : : "r" (THREAD->kstack));
51
}
57
}
52
 
58
 
53
void after_thread_ran_arch(void)
59
void after_thread_ran_arch(void)
54
{
60
{
55
}
61
}