|
|
1.1 root 1: #
2: # reserved operand event test
3: #
4: # includes mtpr,mfpr,&rei
5: #
6: # R7 = which instruction is testing
7: # 1 - MTPR
8: # 2 - MFPR
9: # 3 - REI
10: # R3 = PC that force fault
11: # R0 = error code
12: # 1 : expected reserved operand fault didnot happen
13: # 2 : error in PC pushed on stack
14: # R1 = actual, R2 = expected
15: # 3 : error in PSL pushed on stack
16: # R1 = actual, R2 = expected
17: # 4 : Too many parameters pushed on the stack
18: # 5 : REI did not catch bad PC/PSL on the stack
19: #
20:
21: .set N_EXIST_PR,255
22:
23: .globl _roprnd_evt
24: _roprnd_evt:
25: .word 0x1fff
1.1.1.2 ! root 26: mtpr $31,$IPL /* disable interrupts */
! 27: movab (sp),_savvec0 /* Save current SP (ISP) */
1.1 root 28: mtpr _savvec0,$ISP /* Set ISP = current SP */
1.1.1.2 ! root 29: mfpr $KSP,_savvec9 /* Save kernal stack pointer */
! 30: mfpr $USP,_savveca /* Save user stack pointer */
1.1 root 31: movl _scb+ROVEC,_savvec2 /* Save vector of Resr. oprd fault */
32: movab ropflt1,_scb+ROVEC /* Set new vector */
33: movl $-1,-(sp) /* Push marker on stack */
34:
35:
1.1.1.2 ! root 36: movl _scb+PINSTVEC,_savvec3
1.1 root 37: movpsl r1 /* If PSL_MODE != Kernel then */
38: bitl $0x01000000,r1 /* change to Kernel mode by */
39: beql 1f /* executing a privilege inst. */
1.1.1.2 ! root 40: movab tempvec,_scb+PINSTVEC /* as HALT */
1.1 root 41: halt
42:
43: .align 2
44: tempvec:
45: addl2 $8,sp /* Get rid of trash on the stack */
46: movl _savvec3,_scb+PINSTVEC /* Restore original vector */
47: #
48: # We are running in Kernel mode; Interrupt stack
49: # MTPR to non existent privileged register */
50: #
51: 1:
52: movl $0,r11 /* Set flag to be checked in event handler */
53: movab mfprt,r6 /* R6 = return address after exception */
54: movab mtprt,r5 /* R5 = expected PC on stack after fault */
55: movl r5,r3
56: movl $1,r7 /* R7 = 1; testing MTPR */
57: movpsl r4 /* R4 = expected PSL */
58: mtprt:
59: mtpr $0,$N_EXIST_PR /* Should cause reserved operand fault !! */
60: movl $1,r0 /* R0 = error code; expected reserved */
61: jmp *badrtn /* operand fault did not happen */
62:
63: .align 2 /* Event handler for reserved oprd. fault */
64: ropflt1:
65: movl (sp)+,r1 /* R1 = actual PC from stack */
66: movl r5,r2 /* R5 = expected PC */
67: cmpl r1,r2
68: beql 1f
69: movl $2,r0 /* R0 = error code; PC saved on stack */
70: jmp *badrtn /* not equal to expexted PC */
71: /* R1 = actual; R2 = expected */
72:
73: 1: movl (sp)+,r1 /* R1 = actual PSL from stack */
74: movl r4,r2 /* R2 = expected PSL */
75: cmpl r2,r1 /* Are they the same ? */
76: beql 1f
77: movl $3,r0 /* Error in PSL !! */
78: jmp *badrtn
79: 1:
80: cmpl $1,r11 /* Is fault caused by REI or MTPR ? */
81: bneq 1f /* Skip this part if come here from MTPR */
1.1.1.2 ! root 82: movl (sp)+,r10 /* REI fault : get rid of PC,PSL on the */
1.1 root 83: movl (sp)+,r10 /* stack then check for marker */
84:
85: 1:
86: cmpl $-1,(sp) /* Is SP pointing at the marker on SP ? */
87: beql 1f
88: movl $4,r0 /* If not then error : pushed too many */
89: jmp *badrtn /* parameters on SP after fault .. */
90:
91: 1: movpsl r1 /* Get ready to return from fault */
92: movl r1,-(sp) /* Push current PSL on stack */
93: movl r6,-(sp) /* R6 = addr to return to */
94: rei
95: halt /* Should never come here !!!! */
96: #
97: #
98: # MFPR from non existent privileged register
99: #
100: mfprt:
101: movl $2,r7 /* R7 = 2; testing MFPR */
102: movab reit,r6 /* Set R6 = return adddress after fault */
103: movab mfprt0,r5 /* R5 = expected PC on stack */
104: movl r5,r3
105: movpsl r4 /* R4 = expected PSL */
106: mfprt0:
107: mfpr $N_EXIST_PR,r10 /* Should cause resr. oprd. fault .. */
108: movl $1,r0 /* Error; expected fault did not happen */
109: jmp *badrtn
110: #
111: # REI with illegal PSL on the stack : PSL_IS on and PSL_MODE is User
112: #
113: reit:
114: movl $3,r7 /* R7 = 3; testing REI */
115: movab reit1,r6 /* R6 = return address after exception */
116: movab reita,r5 /* R5 = expected PC on SP */
117: movl r5,r3
118: movl $0x05000000,r1 /* Push PSL on stack; PSL_IS on and */
119: movl r1,-(sp) /* and PSL_MODE = User */
120: movab reierr,-(sp) /* PC if REI doesn't catch bad PSL */
121: movl $1,r11 /* Set flag to be checked in event handler */
122: reita: rei /* should cause reserved opr. fault */
123: movl $1,r0 /* Error; expected fault did not happen */
124: jmp *badrtn /* Should never come here .. */
125: #
126: # REI with illegal PSL on the stack : PSL_IS on and PSL_IPL = 0
127: #
128: reit1:
129: movab reit2,r6 /* R6 = return address after exception */
130: movab reit1a,r5 /* R5 = expected PC on stack */
131: movl r5,r3
132: movl $0x04000000,r1 /* Set PSL, PC on stack for REI */
133: movl r1,-(sp)
134: movab reierr,-(sp) /* PC if REI doesn't catch bad PSL */
135: reit1a: rei /* Should cause fault */
136: movl $1,r0 /* Error; expected fault did not happen */
137: jmp *badrtn /* Should never come here .. */
138: #
139: # REI with illegal PSL on the stack : PSL_IS off,PSL_IPL > 0
140: # and PSL_MODE = User
141: #
142: reit2:
143: movab reit3,r6 /* R6 = return address after exception */
144: movab reit2a,r5 /* R5 = expected PC on stack */
145: movl r5,r3
146: movl $0x010f0000,r1 /* Set PSL, PC on stack for REI */
147: movl r1,-(sp)
148: movab reierr,-(sp) /* PC if REI doesn't catch bad PSl */
149: reit2a: rei /* Should cause fault */
150: movl $1,r0 /* Error; expected fault did not happen */
151: jmp *badrtn /* Should never come here .. */
152:
153: reit3:
154: movpsl r1
155: bitl $0x04000000,r1
156: beql 1f /* If IS is ON, turn it off by */
157: andl2 $0xfbffffff,r1 /* using REI */
158: movl r1,-(sp)
159: movab 1f,-(sp)
160: rei
161: jmp *badrtn
162:
163: #
1.1.1.2 ! root 164: # REI with illegal PSL on the stack : PSL_IS is off ; Try to switch
1.1 root 165: # to Interrupt stack by REI
166: #
167: 1: /* Current PSL_IS is OFF */
1.1.1.2 ! root 168: movl $-1,-(sp) /* push marker on stack (kernal stack) */
1.1 root 169: movab reit4,r6 /* R6 = return address after exception */
170: movab reit3a,r5 /* R5 = expected PC on stack */
171: movl r5,r3
172: movl $0x04000000,r1 /* Set PSL, PC on stack for REI */
173: movl r1,-(sp)
174: movab reierr,-(sp) /* PC if REI doesn't catch bad PSL */
175: movpsl r4
176: reit3a: rei /* Should cause fault */
177: movl $1,r0 /* Error; expected fault did not happen */
178: jmp *badrtn /* Should never come here .. */
179: #
180: # REI with illegal PSL on the stack : Current PSL_IPL is smaller
181: # than PSL_IPL on stack
182: #
183: reit4:
184: movab reit5,r6 /* R6 = return address after exception */
185: movab reit4a,r5 /* R5 = expected PC on stack */
186: movl r5,r3
187: mtpr $0x10,$IPL /* Set current PSL_IPL = 0x10 */
188: movpsl r4
189: movl $0x00180001,r1 /* Set PSL_IPL (on stack) to 0x18 */
190: movl r1,-(sp)
191: movab reierr,-(sp) /* PC if REI doesn't catch bad PSL */
192: reit4a: rei /* Should cause fault */
193: movl $1,r0 /* Error; expected fault did not happen */
194: jmp *badrtn /* Should never come here .. */
195: #
196: #
197: reit5:
198: movl $0x01000000,-(sp) /* Set up PSL, PC to use REI to */
199: movab usrmd,-(sp) /* switch to User mode */
200: rei
201: jmp *badrtn
202: #
203: # REI with illegal PSL on the stack : Try to switch from USER to
204: # KERNEL mode by REI
205: #
206: usrmd: /* We now running in User mode */
207: movab reit6,r6 /* R6 = return address after exception */
208: movab reit5a,r5 /* R5 = expected PC on stack */
209: movl r5,r3
210: movl $0x00000000,r1 /* Set up PSL, PC for REI */
211: movl r1,-(sp)
212: movab reierr,-(sp) /* PC if REI doesn't catch bad PSL */
213: clrl r11 /* Clear flag */
214: movpsl r4
215: reit5a: rei /* Should cause fault */
216: movl $1,r0
217: jmp *badrtn /* Should never come here .. */
218: #
219: #
220: #
221: reit6:
222: movl _savvec3,_scb+PINSTVEC /* Restore vectors */
223: movl _savvec2,_scb+ROVEC
224: pushl $0 /* Push dummy PSL,PC on stack */
225: pushl $0
1.1.1.2 ! root 226: mtpr $31,$IPL /* Reset IPL to HIGH */
1.1 root 227: svpctx /* Switch to ISP */
228: btisp:
229: movl _savvec0,sp /* Restore SP */
1.1.1.2 ! root 230: mtpr _savvec0,$ISP /* Restore ISP */
! 231: mtpr _savvec9,$KSP /* Restore KSP */
! 232: mtpr _savveca,$USP /* Restore USP */
1.1 root 233: ret
234: #
235: #
236: #
237: reierr:
238: movl $5,r0
239: jmp *badrtn /* REI error - REI did not catch illegal PSL*/
240: /* on the stack !*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.