--- cci/d/event/prvinstr.s 2019/07/28 12:24:19 1.1.1.1 +++ cci/d/event/prvinstr.s 2019/07/28 12:30:55 1.1.1.2 @@ -117,13 +117,15 @@ _prvinstr: movab (sp),_savvec0 /* Save current SP */ movpsl _savvec1 /* Save current PSL */ movl fp,_savvec2 /* Save current FP */ + mfpr $KSP,_savvec9 /* Save kernal stack pointer */ + mfpr $USP,_savveca /* Save user stack pointer */ mtpr $0,$ISP /* Init ISP to 0 */ movab _pcb0,r1 /* Init PCB0 */ mtpr r1,$PCBB /* Set PCBB to pcb0 */ - movl _savvec0,PCB_KSP(r1) /* PCB_KSP = current SP */ - movl $-1,PCB_USP(r1) /* PCB_USP = -1 */ + movl _savvec9,PCB_KSP(r1) /* PCB_KSP = saved value of KSP */ + movl _savveca,PCB_USP(r1) /* PCB_USP = -1 */ movl $0,PCB_R0(r1) movl $0x11111111,PCB_R1(r1) movl $0x22222222,PCB_R2(r1) @@ -338,7 +340,9 @@ rtnld: #/* the stack. So svpctx can use it */ 9: -nxts: mtpr _savvec0,$ISP /* Init ISP = original SP */ +nxts: mtpr _savvec0,$ISP /* Init ISP = original ISP */ + mtpr _savvec9,$KSP /* Init KSP = original KSP */ + mtpr _savveca,$USP /* Init USP = original USP */ movab _pcb1,r6 movl r6,r7 /* r7 = address of Pcb1 */ mtpr r7,$PCBB /* Set PCBB = physical address PCB1 */ @@ -461,7 +465,7 @@ nxts: mtpr _savvec0,$ISP /* Init ISP = o mtpr $0,$ISP /* Init ISP to 0 */ movab _pcb0,r1 /* Init PCB0 */ mtpr r1,$PCBB /* Set PCBB to pcb0 */ - movl _savvec0,PCB_KSP(r1) /* PCB_KSP = current SP */ + movl _savvec9,PCB_KSP(r1) /* PCB_KSP = saved value of KSP */ movl $-1,PCB_USP(r1) /* PCB_USP = -1 */ movl $0x5e5e5e5e,PCB_ACCM(r1) /* set MS of fpp's acc. */ movl $0x6f6f6f6f,PCB_ACCL(r1) /* set LS of fpp's acc. */ @@ -560,8 +564,6 @@ nxts: mtpr _savvec0,$ISP /* Init ISP = o movab _pcb0,r1 /* Set PCBB to pcb0 */ mtpr r1,$PCBB - movl $0,_pcb0+PCB_KSP /* PCB_KSP = PCB_USP = 0 */ - movl $0,_pcb0+PCB_USP movl $0x041d0000,-(sp) /* Set PSL,PC on stack for next REI */ /* REI to K mode and IPL == 0x1d */ movab rei1,r3 @@ -594,8 +596,8 @@ rei1: # # REI K mode to K mode; is =0; ipl = 1d 1: - subl3 $16,r2,_pcb0 /* set PCB_KSP to SP-16 */ - subl3 $24,r2,_pcb0+PCB_USP /* Set PCB_USP to SP-24 */ + mtpr _savvec9,$KSP /* restore kernal stack pointer */ + mtpr _savveca,$USP /* restore user stack pointer */ mtpr $0,$ISP pushl $0x001d0000 /* Set up PSL,PC on stack for REI */ pushab 1f /* PSL_IS = 0; PSL_IPL = 1d; K mode */ @@ -633,14 +635,14 @@ rei2: # ** SISR = bit 7 & 2 ON # 1: - movl $0x140004,*$HSR /* Set HISR : pending console transmit */ - /* interrupt at IPL#0x14 */ - movl $0x82,*$SSR /* Set SISR : pending IPL#7, IPL#2 */ movl _scb+44,_savvec4 /* Save int vector for console trans int. */ movl _scb+SIVEC1-24,_savvec6 /* Save int vector for IPL# 7 */ movab hs14,_scb+44 /* New vector for HISR #0x14 */ movab ss7,_scb+SIVEC1-24 /* New vector soft int. #7 */ + movl $0x140004,*$HSR /* Set HISR : pending console transmit */ + /* interrupt at IPL#0x14 */ + movl $0x82,*$SSR /* Set SISR : pending IPL#7, IPL#2 */ brw 1f # # ************** @@ -678,6 +680,7 @@ rei3: pushl $0x00130000 /* Set up PSL,PC for REI */ pushab 9f movab rei4,r3 + mfpr $ISP,r4 /* save interrupt stack pointer */ rei4: rei /* Should take pending hardware int. #0x14 */ movl $14,r0 /* error : REI fell thru */ @@ -712,7 +715,7 @@ hsr_hdl: /* This is where REI should c # 1: movab (sp),r1 /* check if current SP = (ISP-8) */ - mfpr $ISP,r2 + movl r4,r2 /* r4 is saved ISP */ subl2 $8,r2 cmpl r1,r2 beql 1f @@ -776,6 +779,7 @@ sw7: /* This is where REI comes */ movl _savvec6,_scb+SIVEC1-24 /*restore original vector for */ /*ipl #7 */ movl _savvec0,sp + mtpr _savveca,$USP /* Restore user stack pointer */ pushl $0x1000000 /* Set up to REI to user, IPL = 0, IS = 0 */ pushab 1f mtpr $0,$ISP /* Set ISP to 0 */ @@ -814,7 +818,7 @@ rei6: # still running in user mode # 1: - movl _savvec0,sp + movl _savveca,sp /* restore stack pointer (user stack) */ pushl $0x1000000 /* Set up to REI to another user */ pushab 1f movab rei7,r3 @@ -836,13 +840,14 @@ rei7: beql 1f movl $33,r0 jmp *badrtn /*sp not set to USP when mode = U*/ -1: - movl $2,*$SSR /* This is cheating : Set SISR */ - movl _scb+SIVEC1,r4 /* directly in PSA */ +1: + movl _scb+SIVEC1,r4 movab sw2,_scb+SIVEC1 /* New handler for software int.#2 */ pushl $0x01000000 /* Set PSL,PC to REI to user ipl0 */ pushab 1f movab rei8,r3 + movl $2,*$SSR /* This is cheating : Set SISR */ + /* directly in PSA */ rei8: rei /* Use REI with pending int #2 in SISR to get back */ movl $14,r0 @@ -854,12 +859,14 @@ rei8: # .align 2 sw2: - movl r4,_scb+SIVEC1 mtpr $31,$IPL + movl r4,_scb+SIVEC1 /* restore software vector for int#2 */ movl (sp)+,r0 movl (sp)+,r0 movl _savvec0,sp /* Original SP */ movl _savvec2,fp + mtpr _savvec9,$KSP /* Restore kernal stack pointer */ + mtpr _savveca,$USP /* Restore user stack pointer */ ret # #