Subversion Repositories HelenOS

Rev

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

Rev 1855 Rev 1856
Line 34... Line 34...
34
 
34
 
35
#include <proc/scheduler.h>
35
#include <proc/scheduler.h>
36
#include <proc/thread.h>
36
#include <proc/thread.h>
37
#include <arch.h>
37
#include <arch.h>
38
#include <arch/asm.h>
38
#include <arch/asm.h>
-
 
39
#include <arch/regdef.h>
-
 
40
#include <arch/stack.h>
39
#include <arch/mm/tlb.h>
41
#include <arch/mm/tlb.h>
40
#include <arch/mm/page.h>
42
#include <arch/mm/page.h>
41
#include <config.h>
43
#include <config.h>
42
#include <align.h>
44
#include <align.h>
43
#include <macros.h>
45
#include <macros.h>
Line 49... Line 51...
49
 
51
 
50
/** Perform sparc64 specific steps before scheduling a thread.
52
/** Perform sparc64 specific steps before scheduling a thread.
51
 *
53
 *
52
 * Ensure that thread's kernel stack, as well as userspace window
54
 * Ensure that thread's kernel stack, as well as userspace window
53
 * buffer for userspace threads, are locked in DTLB.
55
 * buffer for userspace threads, are locked in DTLB.
-
 
56
 * For userspace threads, initialize reserved global registers
-
 
57
 * in the alternate and interrupt sets.
54
 */
58
 */
55
void before_thread_runs_arch(void)
59
void before_thread_runs_arch(void)
56
{
60
{
57
    uintptr_t base;
61
    uintptr_t base;
58
   
62
   
Line 80... Line 84...
80
             * The buffer is not covered by the 4M locked kernel DTLB entry.
84
             * The buffer is not covered by the 4M locked kernel DTLB entry.
81
             */
85
             */
82
            dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) uw_buf);
86
            dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) uw_buf);
83
            dtlb_insert_mapping(uw_buf, KA2PA(uw_buf), PAGESIZE_8K, true, true);
87
            dtlb_insert_mapping(uw_buf, KA2PA(uw_buf), PAGESIZE_8K, true, true);
84
        }
88
        }
-
 
89
       
-
 
90
        /*
-
 
91
         * Write kernel stack address to %g6 and a pointer to the last item
-
 
92
         * in the userspace window buffer to %g7 in the alternate and interrupt sets.
-
 
93
         */
-
 
94
        write_to_ig_g6((uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS);
-
 
95
        write_to_ag_g6((uintptr_t) THREAD->kstack + STACK_SIZE - STACK_BIAS);
-
 
96
        write_to_ag_g7((uintptr_t) THREAD->arch.uspace_window_buffer);
85
    }
97
    }
86
}
98
}
87
 
99
 
88
/** Perform sparc64 specific steps before a thread stops running.
100
/** Perform sparc64 specific steps before a thread stops running.
89
 *
101
 *
Line 121... Line 133...
121
             * and therefore it was given a dedicated locked DTLB entry.
133
             * and therefore it was given a dedicated locked DTLB entry.
122
             * Demap it.
134
             * Demap it.
123
             */
135
             */
124
            dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) uw_buf);
136
            dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, (uintptr_t) uw_buf);
125
        }
137
        }
-
 
138
   
-
 
139
        /* sample the state of the userspace window buffer */  
-
 
140
        THREAD->arch.uspace_window_buffer = (uint8_t *) read_from_ag_g7();
126
    }
141
    }
127
}
142
}
128
 
143
 
129
/** @}
144
/** @}
130
 */
145
 */