Subversion Repositories HelenOS

Rev

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

Rev 1863 Rev 1864
Line 216... Line 216...
216
.org trap_table + TT_SPILL_2_NORMAL*ENTRY_SIZE
216
.org trap_table + TT_SPILL_2_NORMAL*ENTRY_SIZE
217
.global spill_2_normal
217
.global spill_2_normal
218
spill_2_normal:
218
spill_2_normal:
219
	SPILL_TO_USPACE_WINDOW_BUFFER
219
	SPILL_TO_USPACE_WINDOW_BUFFER
220
 
220
 
-
 
221
/* TT = 0xa0, TL = 0, spill_0_other handler */
-
 
222
.org trap_table + TT_SPILL_0_OTHER*ENTRY_SIZE
-
 
223
.global spill_0_other
-
 
224
spill_0_other:
-
 
225
	SPILL_TO_USPACE_WINDOW_BUFFER
-
 
226
 
221
/* TT = 0xc0, TL = 0, fill_0_normal handler */
227
/* TT = 0xc0, TL = 0, fill_0_normal handler */
222
.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE
228
.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE
223
.global fill_0_normal
229
.global fill_0_normal
224
fill_0_normal:
230
fill_0_normal:
225
	FILL_NORMAL_HANDLER_KERNEL
231
	FILL_NORMAL_HANDLER_KERNEL
Line 545... Line 551...
545
	mov %i2, %o4
551
	mov %i2, %o4
546
	mov %i3, %o5
552
	mov %i3, %o5
547
.endif
553
.endif
548
 
554
 
549
	/*
555
	/*
550
	 * Mark the CANSAVE windows as OTHER windows.
556
	 * Mark the CANRESTORE windows as OTHER windows.
551
	 * Set CLEANWIN to NWINDOW-1 so that clean_window traps do not occur.
557
	 * Set CLEANWIN to NWINDOW-1 so that clean_window traps do not occur.
552
	 */
558
	 */
553
	rdpr %cansave, %l0
559
	rdpr %canrestore, %l0
554
	wrpr %l0, %otherwin
560
	wrpr %l0, %otherwin
555
	wrpr %g0, %cansave
561
	wrpr %g0, %canrestore
556
	wrpr %g0, NWINDOW - 1, %cleanwin
562
	wrpr %g0, NWINDOW - 1, %cleanwin
557
 
563
 
558
	/*
564
	/*
559
	 * Switch to primary context 0.
565
	 * Switch to primary context 0.
560
	 */
566
	 */
Line 639... Line 645...
639
	wrpr %g2, 0, %tpc
645
	wrpr %g2, 0, %tpc
640
	wrpr %g3, 0, %tnpc
646
	wrpr %g3, 0, %tnpc
641
 
647
 
642
	/*
648
	/*
643
	 * If OTHERWIN is zero, then all the userspace windows have been
649
	 * If OTHERWIN is zero, then all the userspace windows have been
644
	 * spilled to kernel memory (i.e. register window buffer). If
650
	 * spilled to kernel memory (i.e. register window buffer). Moreover,
-
 
651
	 * if the scheduler was called in the meantime, all valid windows
-
 
652
	 * belonging to other threads were spilled by context_restore().
645
	 * OTHERWIN is non-zero, then some userspace windows are still
653
	 * If OTHERWIN is non-zero, then some userspace windows are still
646
	 * valid. Others might have been spilled. However, the CWP pointer
654
	 * valid. Others might have been spilled. However, the CWP pointer
647
	 * needs no fixing because the scheduler had not been called.
655
	 * needs no fixing because the scheduler had not been called.
648
	 */
656
	 */
649
	rdpr %otherwin, %l0
657
	rdpr %otherwin, %l0
650
	brnz %l0, 0f
658
	brnz %l0, 0f
Line 657... Line 665...
657
	/*
665
	/*
658
	 * If TSTATE.CWP + 1 == CWP, then we still do not have to fix CWP.
666
	 * If TSTATE.CWP + 1 == CWP, then we still do not have to fix CWP.
659
	 */
667
	 */
660
	and %g1, TSTATE_CWP_MASK, %l0
668
	and %g1, TSTATE_CWP_MASK, %l0
661
	inc %l0
669
	inc %l0
662
	and %l0, TSTATE_CWP_MASK, %l0	! %l0 mod NWINDOW
670
	and %l0, NWINDOW - 1, %l0	! %l0 mod NWINDOW
663
	rdpr %cwp, %l1
671
	rdpr %cwp, %l1
664
	cmp %l0, %l1
672
	cmp %l0, %l1
665
	bz 0f				! CWP is ok
673
	bz 0f				! CWP is ok
666
	nop
674
	nop
667
 
675
 
668
	/*
676
	/*
669
	 * Fix CWP.
677
	 * Fix CWP.
670
	 * Just for reminder, the input registers in the current window
678
	 * In order to recapitulate, the input registers in the current
671
	 * are the output registers of the window to which we want to
679
	 * window are the output registers of the window to which we want
672
	 * restore. Because the fill trap fills only input and local
680
	 * to restore. Because the fill trap fills only input and local
673
	 * registers of a window, we need to preserve those output
681
	 * registers of a window, we need to preserve those output
674
	 * registers manually.
682
	 * registers manually.
675
	 */
683
	 */
676
	flushw
-
 
677
	mov %sp, %g2
684
	mov %sp, %g2
678
	stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
685
	stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
679
	stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
686
	stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
680
	stx %i2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2]
687
	stx %i2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2]
681
	stx %i3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3]
688
	stx %i3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3]
Line 736... Line 743...
736
	/*
743
	/*
737
	 * CWP is now in the window last saved in the userspace window buffer.
744
	 * CWP is now in the window last saved in the userspace window buffer.
738
	 * Fill all windows stored in the buffer.
745
	 * Fill all windows stored in the buffer.
739
	 */
746
	 */
740
	clr %g4
747
	clr %g4
-
 
748
	set PAGE_SIZE - 1, %g5
741
0:	andcc %g7, PAGE_WIDTH - 1, %g0		! PAGE_SIZE alignment check
749
0:	andcc %g7, %g5, %g0			! PAGE_SIZE alignment check
742
	bz 0f					! %g7 is page-aligned, no more windows to refill
750
	bz 0f					! %g7 is page-aligned, no more windows to refill
743
	nop
751
	nop
744
 
752
 
745
	add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
753
	add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
746
	ldx [%g7 + L0_OFFSET], %l0
754
	ldx [%g7 + L0_OFFSET], %l0