2 #include <aros/config.h>
3 #include "aros/m68k/asm.h"
5 #define STACKOFFSET (4 + 4*4)
11 /* 68030 bus error handling is so simple.. */
14 movem.l %d0-%d1/%a0-%a1,-(%sp)
18 move.w STACKOFFSET+0x0a(%sp),%d1
20 move.l STACKOFFSET+0x10(%sp),%a0
24 /* DATA (DF) + READ + LONG? */
28 and.w #~0x0100,STACKOFFSET+0x0a(%sp)
30 /* Fetch execbase from VBR */
31 move.l 4(%a0),STACKOFFSET+0x2c(%sp)
32 /* 68030 continues the execution using above fetched value */
33 movem.l (%sp)+,%d0-%d1/%a0-%a1
42 movem.l %d0-%d1/%a0-%a1,-(%sp)
46 move.w STACKOFFSET+0x0c(%sp),%d1
48 move.l STACKOFFSET+0x14(%sp),%a0
52 /* LONG DATA READ + ATC fault? */
56 /* It was long read from address 4. Special handling required.
58 * Because 68040 (and 060) restart instruction after read fault,
59 * we need to mark zeropage as valid and re-run faulting
60 * instruction in trace mode. Trace exception is used to restore
61 * zero page descriptor back to original invalid state.
65 /* Zero page -> resident */
70 /* Store old trace vector in "safe" place */
71 move.l 9*4(%a0),254*4(%a0)
73 move.w STACKOFFSET(%sp),255*4(%a0)
74 /* Set temporary trace */
75 move.l #trace040,9*4(%a0)
76 movem.l (%sp)+,%d0-%d1/%a0-%a1
78 /* Modify SR in stack, trace on, interrupts disabled! */
81 /* Re-run the instruction */
89 /* Zero page -> invalid */
94 /* Original trace vector */
95 move.l 254*4(%a0),9*4(%a0)
97 move.w 255*4(%a0),4(%sp)
106 movem.l %d0-%d1/%a0-%a1,-(%sp)
109 move.l STACKOFFSET+0x0c(%sp),%d1
111 move.l STACKOFFSET+0x08(%sp),%a0
114 and.l #0x07000200,%d1
115 /* DATA READ PAGE FAULT? */
116 cmp.l #0x01000200,%d1
121 #define STACK_RESERVE 80
123 #if AROS_SERIAL_DEBUG
124 sub.w #STACK_RESERVE,%sp
125 move.l %sp@(STACK_RESERVE+0),%sp@(16+0) // stacked D0 -> regs[0]
126 move.l %sp@(STACK_RESERVE+4),%sp@(16+4) // stacked D1 -> regs[1]
127 move.l %sp@(STACK_RESERVE+8),%sp@(16+8*4+0) // stacked A0 -> regs[8]
128 move.l %sp@(STACK_RESERVE+12),%sp@(16+8*4+4) // stacked A1 -> regs[9]
130 add.w #STACK_RESERVE+STACKOFFSET,%a0
131 move.l %a0,%sp@ // 0 Bus error stack frame
134 move.l %d0,(%a0)+ // 4 CPU type
136 move.l %d0,(%a0)+ // 8 USP
138 move.l %d0,(%a0)+ // 12 VBR
140 add.l #STACK_RESERVE+STACKOFFSET,%d0
142 move.l %d0,%a0@(8*4+7*4) // SSP -> regs[15]
143 movem.l %d2-%d7,%a0@(8) // regs[2]-regs[7]
144 movem.l %a2-%a6,%a0@(8*4+8) // regs[10]-regs[14]
147 add.w #STACK_RESERVE+4,%sp
150 /* jump to original exception vector
151 * we assume illegal instruction uses same address
153 * TODO: Handle 68040 writebacks. Not really important at this
154 * point because this is meant to be kernel debugger that simply
155 * crashes the system if access fault happens.
159 move.l 4*4(%a0),STACKOFFSET-4(%sp)
160 movem.l (%sp)+,%d0-%d1/%a0-%a1
169 movem.l %d0-%d1/%a0-%a1,-(%sp)
170 move.w STACKOFFSET-4(%sp),%d0
188 .globl mmu_valid_check_030
191 ptestr #5,(%a0),#7 // FC=5, all levels
200 .globl mmu_valid_check_040
213 .globl mmu_valid_check_060
221 lea mmu_invalid_060(%pc),%a1