Subversion Repositories HelenOS

Rev

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

Rev 3343 Rev 3743
Line 26... Line 26...
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
27
#
28
 
28
 
29
#include <arch/arch.h>
29
#include <arch/arch.h>
30
#include <arch/stack.h>
30
#include <arch/stack.h>
31
#include <arch/regdef.h>
-
 
32
#include <arch/mm/mmu.h>
-
 
33
 
31
 
34
.text
32
.text
35
 
33
 
36
.register       %g2, #scratch
34
.register       %g2, #scratch
37
.register       %g3, #scratch
35
.register       %g3, #scratch
Line 227... Line 225...
227
memsetb:
225
memsetb:
228
	b _memsetb
226
	b _memsetb
229
	nop
227
	nop
230
 
228
 
231
 
229
 
232
.macro WRITE_ALTERNATE_REGISTER reg, bit
-
 
233
	rdpr %pstate, %g1				! save PSTATE.PEF
-
 
234
	wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate
-
 
235
	mov %o0, \reg
-
 
236
	wrpr %g0, PSTATE_PRIV_BIT, %pstate
-
 
237
	retl
-
 
238
	wrpr %g1, 0, %pstate				! restore PSTATE.PEF
-
 
239
.endm
-
 
240
 
-
 
241
.macro READ_ALTERNATE_REGISTER reg, bit
-
 
242
	rdpr %pstate, %g1				! save PSTATE.PEF
-
 
243
	wrpr %g0, (\bit | PSTATE_PRIV_BIT), %pstate
-
 
244
	mov \reg, %o0
-
 
245
	wrpr %g0, PSTATE_PRIV_BIT, %pstate
-
 
246
	retl
-
 
247
	wrpr %g1, 0, %pstate				! restore PSTATE.PEF
-
 
248
.endm
-
 
249
 
-
 
250
.global write_to_ag_g6
-
 
251
write_to_ag_g6:
-
 
252
	WRITE_ALTERNATE_REGISTER %g6, PSTATE_AG_BIT
-
 
253
 
-
 
254
.global write_to_ag_g7
-
 
255
write_to_ag_g7:
-
 
256
	WRITE_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
-
 
257
 
-
 
258
.global write_to_ig_g6
-
 
259
write_to_ig_g6:
-
 
260
	WRITE_ALTERNATE_REGISTER %g6, PSTATE_IG_BIT
-
 
261
 
-
 
262
.global read_from_ag_g7
-
 
263
read_from_ag_g7:
-
 
264
	READ_ALTERNATE_REGISTER %g7, PSTATE_AG_BIT
-
 
265
 
-
 
266
 
-
 
267
/** Switch to userspace.
-
 
268
 *
-
 
269
 * %o0	Userspace entry address.
-
 
270
 * %o1	Userspace stack pointer address.
-
 
271
 * %o2  Userspace address of uarg structure.
-
 
272
 */
-
 
273
.global switch_to_userspace
-
 
274
switch_to_userspace:
-
 
275
	save %o1, -STACK_WINDOW_SAVE_AREA_SIZE, %sp
-
 
276
	flushw
-
 
277
	wrpr %g0, 0, %cleanwin		! avoid information leak
-
 
278
 
-
 
279
	mov %i2, %o0			! uarg
-
 
280
	xor %o1, %o1, %o1		! %o1 is defined to hold pcb_ptr
-
 
281
					! set it to 0
-
 
282
 
-
 
283
	clr %i2
-
 
284
	clr %i3
-
 
285
	clr %i4
-
 
286
	clr %i5
-
 
287
	clr %i6
-
 
288
 
-
 
289
	wrpr %g0, 1, %tl		! enforce mapping via nucleus
-
 
290
 
-
 
291
	rdpr %cwp, %g1
-
 
292
	wrpr %g1, TSTATE_IE_BIT, %tstate
-
 
293
	wrpr %i0, 0, %tnpc
-
 
294
	
-
 
295
	/*
-
 
296
	 * Set primary context according to secondary context.
-
 
297
	 * Secondary context has been already installed by
-
 
298
	 * higher-level functions.
-
 
299
	 */
-
 
300
	wr %g0, ASI_DMMU, %asi
-
 
301
	ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
-
 
302
	stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
-
 
303
	flush %i7
-
 
304
 
-
 
305
	/*
-
 
306
	 * Spills and fills will be handled by the userspace handlers.
-
 
307
	 */
-
 
308
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
-
 
309
	
-
 
310
	done				! jump to userspace
-
 
311
 
-