|
|
1.1 root 1: #
2: #
3: # *arithmetic exception evnt test
4: # *divide by zero & integer overflow
5: # *divl2,divl3,ediv
6: # *are tested.
7: #
8: # R3 = PC that failed
9: # R0 = error code
10: # 1 - Expected fault did not happen
11: # R1 = current PSL
12: # 2 - PSL_V bit is not set
13: # R1 = current PSL
14: # 3 - Unexpected arithmetic fault
15: # R1 = error code, R2 = actual PC on the stack
16: # 4 - Wrong error code on the stack
17: # R1 = actual, R2 = expected
18: # 5 - Error in PC pushed on the stack
19: # R1 = actual, R2 = expected
20: # 6 - Error in PSL pushed on the stack
21: # R1 = actual, R2 = expected
22: # 7 - Too many parameters pushed on the stack
23: # 8 - PSL_V on the stack is not reset
24: # R1 = PSL on the stack
25:
26: .globl _arith_evt
27: _arith_evt:
28: .word 0x1fff
29: mtpr $31,$IPL /* Set IPL to HIGH */
30: movab (sp),_savvec0 /* Save current SP */
31: mtpr _savvec0,$ISP /* Set ISP = current SP */
32: movl _scb+ARITHVEC,_savvec2 /* Save arith. fault vector */
33: movab arthflt,_scb+ARITHVEC /* Set new vector */
34: movl $-1,-(sp) /* Push marker on stack */
35: movab _pcb0,r1
36: mtpr r1,$PCBB /* Set PCBB */
37: movab (sp),_pcb0 /* Set KSP in PCB0 */
38: movab (sp),_pcb0+4 /* Set USP in PCB0 */
39:
40: movpsl r1 /* If not KERNEL mode, then */
41: bitl $0x01000000,r1 /* force KERNEL mode */
42: beql 1f
43: movl _scb+PINSTVEC,_savvec3
44: movab forckmd,_scb+PINSTVEC
45: halt /* HALT in USER mode to force */
46: /* KERNEL mode */
47: .align 2
48: forckmd:
49: addl2 $8,sp /*get rid of trash on the stack */
50: movl _savvec3,_scb+PINSTVEC /*restore vector */
51: #
52: # We are now running in KERNEL mode; IPL = 0x1f
53: # try to force PSW_V bit set without causing fault
54: # by dividing MAX. negative no by -1
55: 1:
56: bicpsw $0x3f /* Disable overflow event (PSW) */
57: movab epc2,r3 /* R5 = expected PC */
58: movl $-1,r4 /* R4 = -1; Donot expect fault */
59: movl $0x80000000,r8
60: clrl r9
61: epc2:
62: divl2 $-1,r8 /* Should not get overflow exception */
63: movpsl r1
64: bitl $2,r1 /* Check if PSW_V bit is on */
65: bneq 1f
66: movl $2,r0 /* Error : PSW_V not set */
67: jmp *badrtn
68: #
69: # We are now running in KERNEL mode; IPL = 0x1f
70: # forcing arithmetic fault by dividing by 0
71: #
72: 1:
73: movl $0x300,r0 /* R0 = error code */
74: bicpsw $0x3f /* Reset PSW */
75: bispsw $0x20 /* Enable Overflow fault (in PSW) */
76: movab epc3,r5 /* R5 = expected PC */
77: movl r5,r3 /* R3 = PC that failed */
78: movab pc4,r6 /* R6 = return addr from evt handler */
79: movl $2,r4 /* R4 = expected error code on SP */
80: movl $0x80000000,r8 /* divide by zero exception */
81: clrl r9
82: movpsl r7 /* R7 = expected PSL */
83:
84: epc3: divl2 $0,r8 /* Should cause fault .. */
85: movpsl r1
86: movl $1,r0 /* Error : No fault happen */
87: jmp *badrtn
88: #
89: # forcing arithmetic fault (int. overflow) by dividing
90: # MAX negative no. by -1
91: #
92: pc4:
93: movab epc4,r5 /* R5 = expected PC; next inst. */
94: movab epc40,r3 /* R3 = PC that failed */
95: movab pc5,r6 /* R6 = return addr from evt handler */
96: movl $1,r4 /* R4 = expected code on stack */
97: movl $0x80000000,r8
98: clrl r9
99: epc40:
100: divl2 $-1,r8 /* Should get overflow exception */
101: epc4:
102: movpsl r1 /* R7 = expected PSL */
103: movl $1,r0 /* Error : No fault happen */
104: jmp *badrtn
105: #
106: # forcing arithmetic fault (int. overflow) by dividing
107: # MAX negative no. by 0 (using DIVL3)
108: #
109: pc5:
110: movl $0x500,r0 /* R0 = error code */
111: movab epc5,r5 /* R5 = expected PC */
112: movl r5,r3
113: movab pc6,r6 /* R6 = return addr from evt handler */
114: movl $2,r4 /* R4 = expected error code on stack */
115: movl $0x80000000,r8
116: clrl r9
117: movpsl r7 /* R7 = expected PSL */
118: epc5: divl3 $0,r8,r9 /* Should cause fault .. */
119: movpsl r1
120: movl $1,r0 /* Error : No fault happen */
121: jmp *badrtn
122: #
123: # forcing arithmetic fault (int. overflow) by dividing
124: # MAX negative no. by -1 (using DIVL3)
125: #
126: pc6:
127: movl $0x600,r0 /* R0 = error code */
128: bicpsw $0x3f /* Clear PSW */
129: bispsw $0x20 /* Enable overflow exception */
130: movab epc6,r5 /* R5 = expected PC */
131: movab epc60,r3
132: movab pc11,r6 /* R7 = return addr from evt handler */
133: movl $1,r4 /* R4 = expected error code on stack */
134: movl $0x80000000,r8
135: clrl r9
136: movpsl r7 /* R7 = expected PSL */
137: epc60:
138: divl3 $-1,r8,r9 /* Should get overflow exception */
139: epc6:
140: movpsl r1
141: movl $1,r0 /* Error : No fault happen */
142: jmp *badrtn
143: #
144: # forcing arithmetic fault (int. overflow) by dividing
145: # MAX negative no. by 0 (using EDIV)
146: #
147: pc11:
148: movl $0xb00,r0 /* R0 = error code */
149: movab epc11,r5 /* R5 = expected PC */
150: movl r5,r3
151: movab pc12,r6 /* R6 = return addr from evt handler*/
152: movl $2,r4 /* R4 = expected code on stack */
153: movl $0x80000000,r8
154: clrl r10
155: clrl r9
156: movpsl r7 /* R7 = expected PSL */
157: epc11: ediv $0,r8,r9,r10 /* Should cause fault .. */
158: movpsl r1
159: movl $1,r0 /* Error : No fault happen */
160: jmp *badrtn
161: #
162: # forcing arithmetic fault (int. overflow) by dividing
163: # MAX negative no. by -1 (using EDIV)
164: #
165: pc12:
166: movl $0xc00,r0 /* R0 = error code */
167: bispsw $0x20 /* Enable overflow exception */
168: movab epc12,r5 /* R5 = expected PC */
169: movab epc120,r3
170: movab eee,r6 /* R6 = return addr from evt handler*/
171: movl $1,r4 /* R4 = expected code on stack */
172: movl $0x80000000,r8
173: clrl r9
174: clrl r10
175: movpsl r7 /* R7 = expected PSL */
176: epc120:
177: ediv $-1,r8,r9,r10 /* Should get overflow exception */
178: epc12:
179: movpsl r1
180: movl $1,r0 /* Error : No fault happen */
181: jmp *badrtn
182: #
183: # **********************************
184: # Event handler for arithmetic fault
185: # **********************************
186: .align 2
187: arthflt:
188: cmpl $-1,r4 /* Is fault expected ? */
189: bneq 1f /* if YES then skip to 1f */
190: movl $3,r0 /* Error : exception not expected */
191: movl (sp)+,r1 /* R1 = fault type */
192: movl (sp),r2 /* R2 = PC on the stack */
193: jmp *badrtn
194: 1:
195: movl (sp)+,r1 /* Get actual error code from stack */
196: movl r4,r2 /* R2 = expected error code */
197: cmpl r1,r2
198: beql 1f
199: movl $4,r0 /* Error : wrong error code on stack */
200: jmp *badrtn
201: 1:
202: movl (sp)+,r1 /* R1 = actual PC pop from stack */
203: movl r5,r2 /* R5 = expected PC */
204: cmpl r1,r2
205: beql 1f
206: movl $5,r0 /* Error : wrong PC on stack */
207: jmp *badrtn /* R1 = actual; R2 = expected */
208: #
209: 1:
210: movl (sp)+,r1 /* R1 = actual PSL pop from stack */
211: andl2 $0xfffffff0,r1 /* Mask out PSW flags */
212: andl3 $0xfffffff0,r7,r2 /* R2 = actual PSL */
213: cmpl r2,r1
214: beql 1f
215: movl $6,r0 /* Error : wrong PSL on stack */
216: jmp *badrtn
217: #
218: 1:
219: cmpl $-1,(sp) /* SP should point at the marker */
220: beql 1f
221: movl $7,r0 /* Error : too many lgwords pushed on SP */
222: jmp *badrtn
223: #
224: 1:
225: bitl $2,r1 /* Check if PSL_V on stack is reset */
226: beql 1f
227: movl $8,r0 /* Error : PSL_V on SP is not OFF */
228: jmp *badrtn
229: #
230: 1:
231: movl r1,-(sp) /* Set up PSL, PC to return from fault */
232: movl r6,-(sp)
233: rei
234: halt /* Should never come here */
235: #
236: # ***************************
237: # All done; return to monitor
238: #
239: eee:
240: mtpr $31,$IPL
241: movl _savvec0,sp /* Restore stack, vector */
242: movl _savvec2,_scb+ARITHVEC
243: ret
244:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.