Subversion Repositories HelenOS-historic

Rev

Rev 1705 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1705 Rev 1780
Line 48... Line 48...
48
}
48
}
49
 
49
 
50
/** Prepare kernel stack pointers in bank 0 r22 and r23 and make sure the stack is mapped in DTR. */
50
/** Prepare kernel stack pointers in bank 0 r22 and r23 and make sure the stack is mapped in DTR. */
51
void before_thread_runs_arch(void)
51
void before_thread_runs_arch(void)
52
{
52
{
53
    __address base;
53
    uintptr_t base;
54
   
54
   
55
    base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
55
    base = ALIGN_DOWN(config.base, 1<<KERNEL_PAGE_WIDTH);
56
 
56
 
57
    if ((__address) THREAD->kstack < base || (__address) THREAD->kstack > base + (1<<(KERNEL_PAGE_WIDTH))) {
57
    if ((uintptr_t) THREAD->kstack < base || (uintptr_t) THREAD->kstack > base + (1<<(KERNEL_PAGE_WIDTH))) {
58
        /*
58
        /*
59
         * Kernel stack of this thread is not mapped by DTR[TR_KERNEL].
59
         * Kernel stack of this thread is not mapped by DTR[TR_KERNEL].
60
         * Use DTR[TR_KSTACK1] and DTR[TR_KSTACK2] to map it.
60
         * Use DTR[TR_KSTACK1] and DTR[TR_KSTACK2] to map it.
61
         */
61
         */
62
         
62
         
63
        /* purge DTR[TR_STACK1] and DTR[TR_STACK2] */
63
        /* purge DTR[TR_STACK1] and DTR[TR_STACK2] */
64
        dtr_purge((__address) THREAD->kstack, PAGE_WIDTH+1);
64
        dtr_purge((uintptr_t) THREAD->kstack, PAGE_WIDTH+1);
65
       
65
       
66
        /* insert DTR[TR_STACK1] and DTR[TR_STACK2] */
66
        /* insert DTR[TR_STACK1] and DTR[TR_STACK2] */
67
        dtlb_kernel_mapping_insert((__address) THREAD->kstack, KA2PA(THREAD->kstack), true, DTR_KSTACK1);
67
        dtlb_kernel_mapping_insert((uintptr_t) THREAD->kstack, KA2PA(THREAD->kstack), true, DTR_KSTACK1);
68
        dtlb_kernel_mapping_insert((__address) THREAD->kstack + PAGE_SIZE, KA2PA(THREAD->kstack) + FRAME_SIZE, true, DTR_KSTACK2);
68
        dtlb_kernel_mapping_insert((uintptr_t) THREAD->kstack + PAGE_SIZE, KA2PA(THREAD->kstack) + FRAME_SIZE, true, DTR_KSTACK2);
69
    }
69
    }
70
   
70
   
71
    /*
71
    /*
72
     * Record address of kernel backing store to bank 0 r22.
72
     * Record address of kernel backing store to bank 0 r22.
73
     * Record address of kernel stack to bank 0 r23.
73
     * Record address of kernel stack to bank 0 r23.