|
|
1.1 root 1: /* panic.s - panic, panic0, _panic, panvec0, panvec1, panvec2, panvec3,
2: panvec4, panvec5, panvec6, panvec7, panvec8, panvec9, panvec10,
3: panvec11, panvec12, panvec13, panvec14, panvec15 */
4:
5: #include <procreg.h>
6: #include <conf.h>
7:
8: #define REGMASK 0x3fff /* mask for pushr reg13-reg0 */
9: #define STKPRNT 12 /* # of stack items to print */
10: #define PSLDISAB 0x001f0000 /* disable saved psl interrupts */
11:
12: /*------------------------------------------------------------------------
13: * panic0 -- entry point for "branch to zero" error; never called
14: *------------------------------------------------------------------------
15: */
16: .text
17: .align 2 /* align on longword */
18: .globl panic0
19: panic0:
20: /* no entry mask -- not called */
21: movpsl kernstk-4 /* push psl for message print */
22: mtpr $DISABLE, $IPL /* disable interrupts */
23: movl sp, kernstk /* save old sp for message */
24: movl $kernstk-4, sp /* use kernel stack for printing*/
25: pushl _currpid /* print process id */
26: pushal panmsg1 /* message address */
27: calls $4, _kprintf /* print message */
28: jmp __halt /* halt cpu */
29:
30: /*-------------------------------------------------------------------------
31: * panvec0 -- execute panic -- machine check (probably bus error)
32: * must be taken on interrupt stack (low bit of vector == 1)
33: * number of bytes of parameters is topmost on stack
34: * interrupts are (supposed to be) disabled by hardware
35: *-------------------------------------------------------------------------
36: */
37: .align 2 /* align on longword bdry */
38: .globl panvec0
39: panvec0: /* (now on interrupt stack) */
40: mtpr $DISABLE, $IPL /* disable, just in case */
41: /* clear history of machine chk */
42: #if defined(VAX780) || defined(VAX785)
43: mtpr $SBIFSCLR, $SBIFS/* clr SBI's machchk history */
44: #endif VAX78X
45:
46: #if defined(UVAX) || defined(VAX725) || defined(VAX730) \
47: || defined(VAX750)
48: mtpr $MCESRCLR, $MCESR/* clear mach chk history reg. */
49: #endif UVAXX || VAX7X0
50:
51: #if defined(VAX8600)
52: mtpr $0, $EHSR /* clear error handler stat. reg*/
53: #endif VAX8600
54:
55: addl2 (sp)+, sp /* pop error parameters */
56: pushl r0 /* save old r0 value */
57: mfpr $KSP, r0 /* r0 = old kernel stk ptr */
58: movl 8(sp), -(r0) /* psl from int stk on kern stk */
59: movl 4(sp), -(r0) /* pc from int stk on kern stk */
60: mtpr r0, $KSP /* revised kernel stack pointer */
61: movl (sp)+, r0 /* restore old r0 value */
62: bisl2 $PSLDISAB, 4(sp) /* disable psl interrupts */
63: moval vec0cont, (sp) /* get back on kernel stk, */
64: rei /* continue at vec0cont */
65: vec0cont: /* stack dump can now be */
66: pushal pmsg0 /* meaningful */
67: mtpr $intstk, $ISP /* reset interrupt stack */
68: jbr panic
69:
70: /*------------------------------------------------------------------------
71: * panvec1 -- execute panic -- kernel stack not valid
72: * must be taken on interrupt stack (low bit of vector == 1)
73: * interrupts are (supposed to be) disabled by hardware
74: *------------------------------------------------------------------------
75: */
76: .align 2
77: .globl panvec1
78: panvec1: /* (now on interrupt stack) */
79: mtpr $DISABLE, $IPL /* disable interrupts (safety) */
80: mfpr $KSP, -(sp) /* push args to kprintf--old sp */
81: pushr $REGMASK /* r13-r0 */
82: pushl 64(sp) /* old psl */
83: pushl 60(sp) /* old pc */
84: pushl _currpid /* process id */
85: pushal pmsg1 /* exception type message */
86: pushal panmsg2 /* format string */
87: calls $20, _kprintf /* print reg dump */
88: pushal panmsg4 /* no stack dump */
89: calls $1, _kprintf
90: jmp __halt /* halt cpu */
91:
92: /*------------------------------------------------------------------------
93: * panvec2 -- execute panic -- power fail
94: *------------------------------------------------------------------------
95: */
96: .align 2
97: .globl panvec2
98: panvec2:
99: mtpr $DISABLE, $IPL /* disable interrupts */
100: pushal pmsg2
101: jbr panic
102:
103: /*-------------------------------------------------------------------------
104: * panvec3 -- execute panic -- reserved/privileged instruction
105: *-------------------------------------------------------------------------
106: */
107: .align 2
108: .globl panvec3
109: panvec3:
110: mtpr $DISABLE, $IPL /* disable interrupts */
111: pushal pmsg3
112: jbr panic
113:
114: /*-------------------------------------------------------------------------
115: * panvec4 -- execute panic -- virtual memory fault
116: *-------------------------------------------------------------------------
117: */
118: .align 2
119: .globl panvec4
120: panvec4:
121: mtpr $DISABLE, $IPL /* disable interrupts */
122: addl2 $8, sp /* pop parameters */
123: pushal pmsg4
124: jbr panic
125:
126: /*-------------------------------------------------------------------------
127: * panvec5 -- execute panic -- trace pending
128: *-------------------------------------------------------------------------
129: */
130: .align 2
131: .globl panvec5
132: panvec5:
133: mtpr $DISABLE, $IPL /* disable interrupts */
134: pushal pmsg5
135: jbr panic
136:
137: /*-------------------------------------------------------------------------
138: * panvec6 -- execute panic -- breakpoint fault
139: *-------------------------------------------------------------------------
140: */
141: .align 2
142: .globl panvec6
143: panvec6:
144: mtpr $DISABLE, $IPL /* disable interrupts */
145: pushal pmsg6
146: jbr panic
147:
148: /*-------------------------------------------------------------------------
149: * panvec7 -- execute panic -- compatibility mode
150: *-------------------------------------------------------------------------
151: */
152: .align 2
153: .globl panvec7
154: panvec7:
155: mtpr $DISABLE, $IPL /* disable interrupts */
156: tstl (sp)+ /* pop parameter */
157: pushal pmsg7
158: jbr panic
159:
160: /*-----------------------------------------------------------------------
161: * panvec8 -- execute panic -- arithmetic trap/fault
162: *-----------------------------------------------------------------------
163: */
164: .align 2
165: .globl panvec8
166: panvec8:
167: mtpr $DISABLE, $IPL /* disable interrupts */
168: pushl r0 /* save copy of r0 */
169: subl3 $1, 4(sp), r0 /* get trap type code-1 */
170: movl arithvec[r0], 4(sp) /* replace type code w */
171: /* address of trap mesg */
172: movl (sp)+, r0 /* pop saved r0 */
173: jbr panic
174:
175: /*----------------------------------------------------------------------
176: * panvec9 -- execute panic -- unused exception vector
177: *----------------------------------------------------------------------
178: */
179: .align 2
180: .globl panvec9
181: panvec9:
182: mtpr $DISABLE, $IPL /* disable interrupts */
183: pushal pmsg9
184: jbr panic
185:
186: /*-----------------------------------------------------------------------
187: * panvec10 -- execute panic -- corrected memory read
188: *-----------------------------------------------------------------------
189: */
190: .align 2
191: .globl panvec10
192: panvec10:
193: mtpr $DISABLE, $IPL /* disable interrupts */
194: pushal pmsg10
195: jbr panic
196:
197: /*------------------------------------------------------------------------
198: * panvec11 -- execute panic -- write bus timeout
199: *------------------------------------------------------------------------
200: */
201: .align 2
202: .globl panvec11
203: panvec11:
204: mtpr $DISABLE, $IPL /* disable interrupts */
205: pushal pmsg11
206: jbr panic
207:
208: /*------------------------------------------------------------------------
209: * panvec12 -- execute panic -- unknown device
210: *------------------------------------------------------------------------
211: */
212: .align 2
213: .globl panvec12
214: panvec12:
215: mtpr $DISABLE, $IPL /* disable interrupts */
216: pushal pmsg12
217: jbr panic
218:
219: /*------------------------------------------------------------------------
220: * panvec13 -- execute panic -- change mode instruction
221: * must be executed on kernel stack (vector bits 1:0 == 0)
222: *------------------------------------------------------------------------
223: */
224: .align 2
225: .globl panvec13
226: panvec13:
227: mtpr $DISABLE, $IPL /* disable interrupts */
228: tstl (sp)+ /* pop parameter */
229: pushal pmsg13
230: jbr panic
231:
232: /*------------------------------------------------------------------------
233: * panvec14 -- execute panic -- reserved or illegal operand
234: *------------------------------------------------------------------------
235: */
236: .align 2
237: .globl panvec14
238: panvec14:
239: mtpr $DISABLE, $IPL /* disable interrupts */
240: pushal pmsg14
241: jbr panic
242:
243: /*------------------------------------------------------------------------
244: * panvec15 -- execute panic -- reserved or illegal addressing mode
245: *------------------------------------------------------------------------
246: */
247: .align 2
248: .globl panvec15
249: panvec15:
250: mtpr $DISABLE, $IPL /* disable interrupts */
251: pushal pmsg15
252: jbr panic
253:
254: /*------------------------------------------------------------------------
255: * _panic -- entry point when called by user programs
256: *------------------------------------------------------------------------
257: */
258: .align 1
259: .globl _panic
260: _panic: /* Note: "_panic" pushes the */
261: /* PC and PS, since it jumps to */
262: /* "panic" (the trap entry */
263: /* point, below) */
264: .word 0x0 /* save no registers */
265: movpsl -(sp) /* old PS for trap simulation */
266: mtpr $DISABLE, $IPL /* disable interrupts */
267: pushl 16(fp) /* push ret. address for trap */
268: pushl 4(ap) /* address of users message */
269: jbr panic
270:
271: /*----------------------------------------------------------------------------
272: * panic -- entry point for traps and exceptions only; not called
273: * contents of stack on call:
274: * (sp):message address, (sp+4):old pc, (sp+8):old ps
275: *----------------------------------------------------------------------------
276: */
277: .align 1
278: panic:
279: movl (sp)+, pansav /* save message address */
280: movl 4(sp), kernstk /* push on kernel stack: old psl*/
281: movl (sp), kernstk-4 /* old pc */
282: addl3 $8, sp, kernstk-8 /* old sp(from before trap)*/
283: movl $kernstk-8, sp /* switch stack to kernstk */
284: pushr $REGMASK /* save registers r13-r0 */
285: calls $0, sizmem /* size up memory (needed later)*/
286:
287: /* set up call to kprintf to print register and stack dump */
288: pushl kernstk /* user's psl */
289: pushl kernstk-4 /* user's pc */
290: pushl _currpid /* process id */
291: pushl pansav /* message address */
292: pushal panmsg2 /* format address */
293: calls $5, _kprintf /* print message, then pop until*/
294: /* saved regs on stack top */
295: /* dump stack as long as sp was valid */
296: movl kernstk-8, r3 /* r3=user's stk before trap */
297: tstl -(sp) /* space for arg to kprintf */
298: moval panmsg3, -(sp) /* format arg for kprintf */
299: movl $STKPRNT, r4 /* count of stack items to print*/
300: movl _maxaddr, r5 /* r5 = copy of _maxaddr */
301: panloop:
302: cmpl r3, r5 /* avoid references beyond */
303: jgtru pandone /* valid memory addresses */
304: movl (r3)+, 4(sp) /* insert value to print as arg */
305: calls $0, _kprintf /* print; pop no values */
306: sobgtr r4, panloop /* decr count, print more if >0 */
307: pandone:
308: addl2 $8, sp /* pop off kprintf args */
309: popr $REGMASK /* pop off registers saved */
310: subl3 $8, (sp), sp /* restore user's sp, with psl */
311: /* and pc from trap on top */
312: jmp __halt /* halt processor */
313: /* user probably won't continue */
314: /* pc & psl on top in case */
315: /* of console "C" command */
316: rei /* especially for call to _panic*/
317: .data 1
318: pansav:
319: .space 4 /* save location for messg addr */
320: panmsg1:
321: .ascii "\n\nPanic: branch to location 0:\n"
322: .ascii "\tpid = (dec) %d\n"
323: .ascii "\tpsl = (hex) %0x\n"
324: .ascii "\tsp = (hex) %0x\n\n\0"
325: panmsg2:
326: .ascii "\n\nPanic: trap type: %s\n"
327: .ascii "pid = %d\n"
328: .ascii "State: pc = %x psl = %08x\n"
329: .ascii "r0 = %8x r1 = %8x r2 = %8x r3 = %8x\n"
330: .ascii "r4 = %8x r5 = %8x r6 = %8x r7 = %8x\n"
331: .ascii "r8 = %8x r9 = %8x r10 = %8x r11 = %8x\n"
332: .ascii "r12 = %8x r13 = %8x\n"
333: .ascii "Stack: (top at %x)\n\0"
334: panmsg3:
335: .ascii "%8x\n\0"
336: panmsg4:
337: .ascii "(can't dump stack)\n\0"
338: pmsg0:
339: .ascii "bus error or machine check\0"
340: pmsg1:
341: .ascii "invalid kernel stack pointer\0"
342: pmsg2:
343: .ascii "power fail\0"
344: pmsg3:
345: .ascii "reserved or privileged instruction\0"
346: pmsg4:
347: .ascii "virtual address fault\0"
348: pmsg5:
349: .ascii "trace pending\0"
350: pmsg6:
351: .ascii "breakpoint instruction\0"
352: pmsg7:
353: .ascii "PDP-11 compatibility mode trap\0"
354: pmsg9:
355: .ascii "unused exception vector\0"
356: pmsg10:
357: .ascii "corrected memory read\0"
358: pmsg11:
359: .ascii "write bus timeout\0"
360: pmsg12:
361: .ascii "unknown device\0"
362: pmsg13:
363: .ascii "CHMx instruction\0"
364: pmsg14:
365: .ascii "reserved or illegal operand\0"
366: pmsg15:
367: .ascii "reserved or illegal addressing mode\0"
368: arith1:
369: .ascii "integer overflow\0"
370: arith2:
371: .ascii "integer divide by 0\0"
372: arith3:
373: .ascii "floating overflow\0"
374: arith4:
375: .ascii "floating/decimal divide by 0\0"
376: arith5:
377: .ascii "floating underflow\0"
378: arith6:
379: .ascii "decimal overflow\0"
380: arith7:
381: .ascii "subscript range\0"
382: arith8:
383: .ascii "floating overflow fault\0"
384: arith9:
385: .ascii "floating divide by 0 fault\0"
386: arith10:
387: .ascii "floating underflow fault\0"
388: arithvec:
389: .long arith1
390: .long arith2
391: .long arith3
392: .long arith4
393: .long arith5
394: .long arith6
395: .long arith7
396: .long arith8
397: .long arith9
398: .long arith10
399:
400: /* Stack used by kernel at startup and to handle panic messages. */
401:
402: .data 1 /* kernstk & intstk are in */
403: /* initialized data segment */
404: .align 2 /* align on fullword boundary */
405: .globl kernstk
406: .space 512 /* decimal bytes in kernel stack*/
407: kernstk:
408:
409: /* Intstk is used as interrupt stack (temporarily) by processor. */
410: /* It is used during startup and temporarily during context switch, */
411: /* also when processing certain exceptions. */
412: .align 2
413: .space 128
414: .globl intstk
415: intstk:
416: .space 4 /* no overlap of next symbol */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.