Subversion Repositories HelenOS

Rev

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

Rev 4338 Rev 4348
Line 339... Line 339...
339
    112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,\
339
    112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,\
340
    127
340
    127
341
.org trap_table + (TT_TRAP_INSTRUCTION_0+\cur)*ENTRY_SIZE
341
.org trap_table + (TT_TRAP_INSTRUCTION_0+\cur)*ENTRY_SIZE
342
.global trap_instruction_\cur\()_tl0
342
.global trap_instruction_\cur\()_tl0
343
trap_instruction_\cur\()_tl0:
343
trap_instruction_\cur\()_tl0:
344
	ba trap_instruction_handler
344
	ba %xcc, trap_instruction_handler
345
	mov \cur, %g2
345
	mov \cur, %g2
346
.endr
346
.endr
347
 
347
 
348
/*
348
/*
349
 * Handlers for TL>0.
349
 * Handlers for TL>0.
Line 476... Line 476...
476
	/*
476
	/*
477
	 * ASSERT(%tl == 1)
477
	 * ASSERT(%tl == 1)
478
	 */
478
	 */
479
	rdpr %tl, %g3
479
	rdpr %tl, %g3
480
	cmp %g3, 1
480
	cmp %g3, 1
481
	be 1f
481
	be %xcc, 1f
482
	nop
482
	nop
483
0:	ba 0b					! this is for debugging, if we ever get here
483
0:	ba %xcc, 0b				! this is for debugging, if we ever get here
484
	nop					! it will be easy to find
484
	nop					! it will be easy to find
485
 
485
 
486
1:
486
1:
487
.if NOT(\is_syscall)
487
.if NOT(\is_syscall)
488
	rdpr %tstate, %g3
488
	rdpr %tstate, %g3
Line 497... Line 497...
497
	 */ 
497
	 */ 
498
	and %g3, TSTATE_CWP_MASK, %g4
498
	and %g3, TSTATE_CWP_MASK, %g4
499
	wrpr %g4, 0, %cwp			! resynchronize CWP
499
	wrpr %g4, 0, %cwp			! resynchronize CWP
500
 
500
 
501
	andcc %g3, TSTATE_PRIV_BIT, %g0		! if this trap came from the privileged mode...
501
	andcc %g3, TSTATE_PRIV_BIT, %g0		! if this trap came from the privileged mode...
502
	bnz 0f					! ...skip setting of kernel stack and primary context
502
	bnz %xcc, 0f				! ...skip setting of kernel stack and primary context
503
	nop
503
	nop
504
	
504
	
505
.endif
505
.endif
506
	/*
506
	/*
507
	 * Normal window spills will go to the userspace window buffer.
507
	 * Normal window spills will go to the userspace window buffer.
Line 543... Line 543...
543
	stxa %g0, [%l0] ASI_DMMU
543
	stxa %g0, [%l0] ASI_DMMU
544
	rd %pc, %l0
544
	rd %pc, %l0
545
	flush %l0
545
	flush %l0
546
 
546
 
547
.if NOT(\is_syscall)
547
.if NOT(\is_syscall)
548
	ba 1f
548
	ba %xcc, 1f
549
	nop
549
	nop
550
0:
550
0:
551
	save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
551
	save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
552
 
552
 
553
	/*
553
	/*
Line 670... Line 670...
670
	and %g1, TSTATE_CWP_MASK, %l0
670
	and %g1, TSTATE_CWP_MASK, %l0
671
	inc %l0
671
	inc %l0
672
	and %l0, NWINDOWS - 1, %l0	! %l0 mod NWINDOWS
672
	and %l0, NWINDOWS - 1, %l0	! %l0 mod NWINDOWS
673
	rdpr %cwp, %l1
673
	rdpr %cwp, %l1
674
	cmp %l0, %l1
674
	cmp %l0, %l1
675
	bz 0f				! CWP is ok
675
	bz %xcc, 0f			! CWP is ok
676
	nop
676
	nop
677
 
677
 
678
	/*
678
	/*
679
	 * Fix CWP.
679
	 * Fix CWP.
680
	 * In order to recapitulate, the input registers in the current
680
	 * In order to recapitulate, the input registers in the current
Line 710... Line 710...
710
	 */
710
	 */
711
0:
711
0:
712
.if NOT(\is_syscall)
712
.if NOT(\is_syscall)
713
	rdpr %tstate, %g1
713
	rdpr %tstate, %g1
714
	andcc %g1, TSTATE_PRIV_BIT, %g0		! if we are not returning to userspace...,
714
	andcc %g1, TSTATE_PRIV_BIT, %g0		! if we are not returning to userspace...,
715
	bnz 1f					! ...skip restoring userspace windows
715
	bnz %xcc, 1f				! ...skip restoring userspace windows
716
	nop
716
	nop
717
.endif
717
.endif
718
 
718
 
719
	/*
719
	/*
720
	 * Spills and fills will be processed by the {spill,fill}_1_normal
720
	 * Spills and fills will be processed by the {spill,fill}_1_normal
Line 747... Line 747...
747
	 * CWP is now in the window last saved in the userspace window buffer.
747
	 * CWP is now in the window last saved in the userspace window buffer.
748
	 * Fill all windows stored in the buffer.
748
	 * Fill all windows stored in the buffer.
749
	 */
749
	 */
750
	clr %g4
750
	clr %g4
751
0:	andcc %g7, UWB_ALIGNMENT - 1, %g0	! alignment check
751
0:	andcc %g7, UWB_ALIGNMENT - 1, %g0	! alignment check
752
	bz 0f					! %g7 is UWB_ALIGNMENT-aligned, no more windows to refill
752
	bz %xcc, 0f				! %g7 is UWB_ALIGNMENT-aligned, no more windows to refill
753
	nop
753
	nop
754
 
754
 
755
	add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
755
	add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
756
	ldx [%g7 + L0_OFFSET], %l0
756
	ldx [%g7 + L0_OFFSET], %l0
757
	ldx [%g7 + L1_OFFSET], %l1
757
	ldx [%g7 + L1_OFFSET], %l1
Line 772... Line 772...
772
 
772
 
773
	dec %g3
773
	dec %g3
774
	and %g3, NWINDOWS - 1, %g3
774
	and %g3, NWINDOWS - 1, %g3
775
	wrpr %g3, 0, %cwp			! switch to the preceeding window
775
	wrpr %g3, 0, %cwp			! switch to the preceeding window
776
 
776
 
777
	ba 0b
777
	ba %xcc, 0b
778
	inc %g4
778
	inc %g4
779
 
779
 
780
0:
780
0:
781
	/*
781
	/*
782
	 * Switch back to the proper current window and adjust
782
	 * Switch back to the proper current window and adjust
783
	 * OTHERWIN, CANRESTORE, CANSAVE and CLEANWIN.
783
	 * OTHERWIN, CANRESTORE, CANSAVE and CLEANWIN.
784
	 */
784
	 */
785
	wrpr %g1, 0, %cwp
785
	wrpr %g1, 0, %cwp
786
	add %g4, %g2, %g2
786
	add %g4, %g2, %g2
787
	cmp %g2, NWINDOWS - 2
787
	cmp %g2, NWINDOWS - 2
788
	bg 2f					! fix the CANRESTORE=NWINDOWS-1 anomaly
788
	bg %xcc, 2f				! fix the CANRESTORE=NWINDOWS-1 anomaly
789
	mov NWINDOWS - 2, %g1			! use dealy slot for both cases
789
	mov NWINDOWS - 2, %g1			! use dealy slot for both cases
790
	sub %g1, %g2, %g1
790
	sub %g1, %g2, %g1
791
	
791
	
792
	wrpr %g0, 0, %otherwin
792
	wrpr %g0, 0, %otherwin
793
	wrpr %g1, 0, %cansave			! NWINDOWS - 2 - CANRESTORE
793
	wrpr %g1, 0, %cansave			! NWINDOWS - 2 - CANRESTORE