1 | 1 | 2 | gen_except.sa 3.7 1/16/92 2 | gen_except.sa 3.7 1/16/92 3 | 3 | 4 | gen_except --- FPSP routine to detect 4 | gen_except --- FPSP routine to detect reportable exceptions 5 | 5 | 6 | This routine compares the exception en 6 | This routine compares the exception enable byte of the 7 | user_fpcr on the stack with the except 7 | user_fpcr on the stack with the exception status byte 8 | of the user_fpsr. 8 | of the user_fpsr. 9 | 9 | 10 | Any routine which may report an except 10 | Any routine which may report an exceptions must load 11 | the stack frame in memory with the exc 11 | the stack frame in memory with the exceptional operand(s). 12 | 12 | 13 | Priority for exceptions is: 13 | Priority for exceptions is: 14 | 14 | 15 | Highest: bsun 15 | Highest: bsun 16 | snan 16 | snan 17 | operr 17 | operr 18 | ovfl 18 | ovfl 19 | unfl 19 | unfl 20 | dz 20 | dz 21 | inex2 21 | inex2 22 | Lowest: inex1 22 | Lowest: inex1 23 | 23 | 24 | Note: The IEEE standard specifies that 24 | Note: The IEEE standard specifies that inex2 is to be 25 | reported if ovfl occurs and the ovfl e 25 | reported if ovfl occurs and the ovfl enable bit is not 26 | set but the inex2 enable bit is. 26 | set but the inex2 enable bit is. 27 | 27 | 28 | 28 | 29 | Copyright (C) Motorola, Inc. 1 29 | Copyright (C) Motorola, Inc. 1990 30 | All Rights Reserved 30 | All Rights Reserved 31 | 31 | 32 | For details on the license for this fi 32 | For details on the license for this file, please see the 33 | file, README, in this same directory. 33 | file, README, in this same directory. 34 34 35 GEN_EXCEPT: |idnt 2,1 | Motorola 040 Flo 35 GEN_EXCEPT: |idnt 2,1 | Motorola 040 Floating Point Software Package 36 36 37 |section 8 37 |section 8 38 38 39 #include "fpsp.h" 39 #include "fpsp.h" 40 40 41 |xref real_trace 41 |xref real_trace 42 |xref fpsp_done 42 |xref fpsp_done 43 |xref fpsp_fmt_error 43 |xref fpsp_fmt_error 44 44 45 exc_tbl: 45 exc_tbl: 46 .long bsun_exc 46 .long bsun_exc 47 .long commonE1 47 .long commonE1 48 .long commonE1 48 .long commonE1 49 .long ovfl_unfl 49 .long ovfl_unfl 50 .long ovfl_unfl 50 .long ovfl_unfl 51 .long commonE1 51 .long commonE1 52 .long commonE3 52 .long commonE3 53 .long commonE3 53 .long commonE3 54 .long no_match 54 .long no_match 55 55 56 .global gen_except 56 .global gen_except 57 gen_except: 57 gen_except: 58 cmpib #IDLE_SIZE-4,1(%a7) |test 58 cmpib #IDLE_SIZE-4,1(%a7) |test for idle frame 59 beq do_check |go ha 59 beq do_check |go handle idle frame 60 cmpib #UNIMP_40_SIZE-4,1(%a7) |test 60 cmpib #UNIMP_40_SIZE-4,1(%a7) |test for orig unimp frame 61 beqs unimp_x |go ha 61 beqs unimp_x |go handle unimp frame 62 cmpib #UNIMP_41_SIZE-4,1(%a7) |test 62 cmpib #UNIMP_41_SIZE-4,1(%a7) |test for rev unimp frame 63 beqs unimp_x |go ha 63 beqs unimp_x |go handle unimp frame 64 cmpib #BUSY_SIZE-4,1(%a7) |if si 64 cmpib #BUSY_SIZE-4,1(%a7) |if size <> $60, fmt error 65 bnel fpsp_fmt_error 65 bnel fpsp_fmt_error 66 leal BUSY_SIZE+LOCAL_SIZE(%a7),%a1 66 leal BUSY_SIZE+LOCAL_SIZE(%a7),%a1 |init a1 so fpsp.h 67 | ;equat 67 | ;equates will work 68 | Fix up the new busy frame with entries from 68 | Fix up the new busy frame with entries from the unimp frame 69 | 69 | 70 movel ETEMP_EX(%a6),ETEMP_EX(%a1) |c 70 movel ETEMP_EX(%a6),ETEMP_EX(%a1) |copy etemp from unimp 71 movel ETEMP_HI(%a6),ETEMP_HI(%a1) |f 71 movel ETEMP_HI(%a6),ETEMP_HI(%a1) |frame to busy frame 72 movel ETEMP_LO(%a6),ETEMP_LO(%a1) 72 movel ETEMP_LO(%a6),ETEMP_LO(%a1) 73 movel CMDREG1B(%a6),CMDREG1B(%a1) |s 73 movel CMDREG1B(%a6),CMDREG1B(%a1) |set inst in frame to unimp 74 movel CMDREG1B(%a6),%d0 74 movel CMDREG1B(%a6),%d0 |fix cmd1b to make it 75 andl #0x03c30000,%d0 |work 75 andl #0x03c30000,%d0 |work for cmd3b 76 bfextu CMDREG1B(%a6){#13:#1},%d1 76 bfextu CMDREG1B(%a6){#13:#1},%d1 |extract bit 2 77 lsll #5,%d1 77 lsll #5,%d1 78 swap %d1 78 swap %d1 79 orl %d1,%d0 |put i 79 orl %d1,%d0 |put it in the right place 80 bfextu CMDREG1B(%a6){#10:#3},%d1 80 bfextu CMDREG1B(%a6){#10:#3},%d1 |extract bit 3,4,5 81 lsll #2,%d1 81 lsll #2,%d1 82 swap %d1 82 swap %d1 83 orl %d1,%d0 |put t 83 orl %d1,%d0 |put them in the right place 84 movel %d0,CMDREG3B(%a1) 84 movel %d0,CMDREG3B(%a1) |in the busy frame 85 | 85 | 86 | Or in the FPSR from the emulation with the U 86 | Or in the FPSR from the emulation with the USER_FPSR on the stack. 87 | 87 | 88 fmovel %FPSR,%d0 88 fmovel %FPSR,%d0 89 orl %d0,USER_FPSR(%a6) 89 orl %d0,USER_FPSR(%a6) 90 movel USER_FPSR(%a6),FPSR_SHADOW(%a1 90 movel USER_FPSR(%a6),FPSR_SHADOW(%a1) |set exc bits 91 orl #sx_mask,E_BYTE(%a1) 91 orl #sx_mask,E_BYTE(%a1) 92 bra do_clean 92 bra do_clean 93 93 94 | 94 | 95 | Frame is an unimp frame possible resulting f 95 | Frame is an unimp frame possible resulting from an fmove <ea>,fp0 96 | that caused an exception 96 | that caused an exception 97 | 97 | 98 | a1 is modified to point into the new frame a 98 | a1 is modified to point into the new frame allowing fpsp equates 99 | to be valid. 99 | to be valid. 100 | 100 | 101 unimp_x: 101 unimp_x: 102 cmpib #UNIMP_40_SIZE-4,1(%a7) |test 102 cmpib #UNIMP_40_SIZE-4,1(%a7) |test for orig unimp frame 103 bnes test_rev 103 bnes test_rev 104 leal UNIMP_40_SIZE+LOCAL_SIZE(%a7), 104 leal UNIMP_40_SIZE+LOCAL_SIZE(%a7),%a1 105 bras unimp_con 105 bras unimp_con 106 test_rev: 106 test_rev: 107 cmpib #UNIMP_41_SIZE-4,1(%a7) |test 107 cmpib #UNIMP_41_SIZE-4,1(%a7) |test for rev unimp frame 108 bnel fpsp_fmt_error |if no 108 bnel fpsp_fmt_error |if not $28 or $30 109 leal UNIMP_41_SIZE+LOCAL_SIZE(%a7), 109 leal UNIMP_41_SIZE+LOCAL_SIZE(%a7),%a1 110 110 111 unimp_con: 111 unimp_con: 112 | 112 | 113 | Fix up the new unimp frame with entries from 113 | Fix up the new unimp frame with entries from the old unimp frame 114 | 114 | 115 movel CMDREG1B(%a6),CMDREG1B(%a1) |s 115 movel CMDREG1B(%a6),CMDREG1B(%a1) |set inst in frame to unimp 116 | 116 | 117 | Or in the FPSR from the emulation with the U 117 | Or in the FPSR from the emulation with the USER_FPSR on the stack. 118 | 118 | 119 fmovel %FPSR,%d0 119 fmovel %FPSR,%d0 120 orl %d0,USER_FPSR(%a6) 120 orl %d0,USER_FPSR(%a6) 121 bra do_clean 121 bra do_clean 122 122 123 | 123 | 124 | Frame is idle, so check for exceptions repor 124 | Frame is idle, so check for exceptions reported through 125 | USER_FPSR and set the unimp frame accordingl 125 | USER_FPSR and set the unimp frame accordingly. 126 | A7 must be incremented to the point before t 126 | A7 must be incremented to the point before the 127 | idle fsave vector to the unimp vector. 127 | idle fsave vector to the unimp vector. 128 | 128 | 129 129 130 do_check: 130 do_check: 131 addl #4,%a7 |point 131 addl #4,%a7 |point A7 back to unimp frame 132 | 132 | 133 | Or in the FPSR from the emulation with the U 133 | Or in the FPSR from the emulation with the USER_FPSR on the stack. 134 | 134 | 135 fmovel %FPSR,%d0 135 fmovel %FPSR,%d0 136 orl %d0,USER_FPSR(%a6) 136 orl %d0,USER_FPSR(%a6) 137 | 137 | 138 | On a busy frame, we must clear the nmnexc bi 138 | On a busy frame, we must clear the nmnexc bits. 139 | 139 | 140 cmpib #BUSY_SIZE-4,1(%a7) |check 140 cmpib #BUSY_SIZE-4,1(%a7) |check frame type 141 bnes check_fr |if bu 141 bnes check_fr |if busy, clr nmnexc 142 clrw NMNEXC(%a6) |clr n 142 clrw NMNEXC(%a6) |clr nmnexc & nmcexc 143 btstb #5,CMDREG1B(%a6) 143 btstb #5,CMDREG1B(%a6) |test for fmove out 144 bnes frame_com 144 bnes frame_com 145 movel USER_FPSR(%a6),FPSR_SHADOW(%a6 145 movel USER_FPSR(%a6),FPSR_SHADOW(%a6) |set exc bits 146 orl #sx_mask,E_BYTE(%a6) 146 orl #sx_mask,E_BYTE(%a6) 147 bras frame_com 147 bras frame_com 148 check_fr: 148 check_fr: 149 cmpb #UNIMP_40_SIZE-4,1(%a7) 149 cmpb #UNIMP_40_SIZE-4,1(%a7) 150 beqs frame_com 150 beqs frame_com 151 clrw NMNEXC(%a6) 151 clrw NMNEXC(%a6) 152 frame_com: 152 frame_com: 153 moveb FPCR_ENABLE(%a6),%d0 |get f 153 moveb FPCR_ENABLE(%a6),%d0 |get fpcr enable byte 154 andb FPSR_EXCEPT(%a6),%d0 |and i 154 andb FPSR_EXCEPT(%a6),%d0 |and in the fpsr exc byte 155 bfffo %d0{#24:#8},%d1 |test 155 bfffo %d0{#24:#8},%d1 |test for first set bit 156 leal exc_tbl,%a0 |load 156 leal exc_tbl,%a0 |load jmp table address 157 subib #24,%d1 |norma 157 subib #24,%d1 |normalize bit offset to 0-8 158 movel (%a0,%d1.w*4),%a0 158 movel (%a0,%d1.w*4),%a0 |load routine address based 159 | ;based 159 | ;based on first enabled exc 160 jmp (%a0) |jump 160 jmp (%a0) |jump to routine 161 | 161 | 162 | Bsun is not possible in unimp or unsupp 162 | Bsun is not possible in unimp or unsupp 163 | 163 | 164 bsun_exc: 164 bsun_exc: 165 bra do_clean 165 bra do_clean 166 | 166 | 167 | The typical work to be done to the unimp fra 167 | The typical work to be done to the unimp frame to report an 168 | exception is to set the E1/E3 byte and clr t 168 | exception is to set the E1/E3 byte and clr the U flag. 169 | commonE1 does this for E1 exceptions, which 169 | commonE1 does this for E1 exceptions, which are snan, 170 | operr, and dz. commonE3 does this for E3 ex 170 | operr, and dz. commonE3 does this for E3 exceptions, which 171 | are inex2 and inex1, and also clears the E1 171 | are inex2 and inex1, and also clears the E1 exception bit 172 | left over from the unimp exception. 172 | left over from the unimp exception. 173 | 173 | 174 commonE1: 174 commonE1: 175 bsetb #E1,E_BYTE(%a6) |set E 175 bsetb #E1,E_BYTE(%a6) |set E1 flag 176 bra commonE |go cl 176 bra commonE |go clean and exit 177 177 178 commonE3: 178 commonE3: 179 tstb UFLG_TMP(%a6) |test 179 tstb UFLG_TMP(%a6) |test flag for unsup/unimp state 180 bnes unsE3 180 bnes unsE3 181 uniE3: 181 uniE3: 182 bsetb #E3,E_BYTE(%a6) |set E 182 bsetb #E3,E_BYTE(%a6) |set E3 flag 183 bclrb #E1,E_BYTE(%a6) |clr E 183 bclrb #E1,E_BYTE(%a6) |clr E1 from unimp 184 bra commonE 184 bra commonE 185 185 186 unsE3: 186 unsE3: 187 tstb RES_FLG(%a6) 187 tstb RES_FLG(%a6) 188 bnes unsE3_0 188 bnes unsE3_0 189 unsE3_1: 189 unsE3_1: 190 bsetb #E3,E_BYTE(%a6) |set E 190 bsetb #E3,E_BYTE(%a6) |set E3 flag 191 unsE3_0: 191 unsE3_0: 192 bclrb #E1,E_BYTE(%a6) |clr E 192 bclrb #E1,E_BYTE(%a6) |clr E1 flag 193 movel CMDREG1B(%a6),%d0 193 movel CMDREG1B(%a6),%d0 194 andl #0x03c30000,%d0 |work 194 andl #0x03c30000,%d0 |work for cmd3b 195 bfextu CMDREG1B(%a6){#13:#1},%d1 195 bfextu CMDREG1B(%a6){#13:#1},%d1 |extract bit 2 196 lsll #5,%d1 196 lsll #5,%d1 197 swap %d1 197 swap %d1 198 orl %d1,%d0 |put i 198 orl %d1,%d0 |put it in the right place 199 bfextu CMDREG1B(%a6){#10:#3},%d1 199 bfextu CMDREG1B(%a6){#10:#3},%d1 |extract bit 3,4,5 200 lsll #2,%d1 200 lsll #2,%d1 201 swap %d1 201 swap %d1 202 orl %d1,%d0 |put t 202 orl %d1,%d0 |put them in the right place 203 movel %d0,CMDREG3B(%a6) 203 movel %d0,CMDREG3B(%a6) |in the busy frame 204 204 205 commonE: 205 commonE: 206 bclrb #UFLAG,T_BYTE(%a6) |clr U 206 bclrb #UFLAG,T_BYTE(%a6) |clr U flag from unimp 207 bra do_clean |go cl 207 bra do_clean |go clean and exit 208 | 208 | 209 | No bits in the enable byte match existing ex 209 | No bits in the enable byte match existing exceptions. Check for 210 | the case of the ovfl exc without the ovfl en 210 | the case of the ovfl exc without the ovfl enabled, but with 211 | inex2 enabled. 211 | inex2 enabled. 212 | 212 | 213 no_match: 213 no_match: 214 btstb #inex2_bit,FPCR_ENABLE(%a6) |c 214 btstb #inex2_bit,FPCR_ENABLE(%a6) |check for ovfl/inex2 case 215 beqs no_exc |if cl 215 beqs no_exc |if clear, exit 216 btstb #ovfl_bit,FPSR_EXCEPT(%a6) |no 216 btstb #ovfl_bit,FPSR_EXCEPT(%a6) |now check ovfl 217 beqs no_exc |if cl 217 beqs no_exc |if clear, exit 218 bras ovfl_unfl |go to 218 bras ovfl_unfl |go to unfl_ovfl to determine if 219 | ;it is 219 | ;it is an unsupp or unimp exc 220 220 221 | No exceptions are to be reported. If the in 221 | No exceptions are to be reported. If the instruction was 222 | unimplemented, no FPU restore is necessary. 222 | unimplemented, no FPU restore is necessary. If it was 223 | unsupported, we must perform the restore. 223 | unsupported, we must perform the restore. 224 no_exc: 224 no_exc: 225 tstb UFLG_TMP(%a6) |test flag for 225 tstb UFLG_TMP(%a6) |test flag for unsupp/unimp state 226 beqs uni_no_exc 226 beqs uni_no_exc 227 uns_no_exc: 227 uns_no_exc: 228 tstb RES_FLG(%a6) |check if fres 228 tstb RES_FLG(%a6) |check if frestore is needed 229 bne do_clean |if clear, no 229 bne do_clean |if clear, no frestore needed 230 uni_no_exc: 230 uni_no_exc: 231 moveml USER_DA(%a6),%d0-%d1/%a0-%a1 231 moveml USER_DA(%a6),%d0-%d1/%a0-%a1 232 fmovemx USER_FP0(%a6),%fp0-%fp3 232 fmovemx USER_FP0(%a6),%fp0-%fp3 233 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fp 233 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar 234 unlk %a6 234 unlk %a6 235 bra finish_up 235 bra finish_up 236 | 236 | 237 | Unsupported Data Type Handler: 237 | Unsupported Data Type Handler: 238 | Ovfl: 238 | Ovfl: 239 | An fmoveout that results in an overflow is 239 | An fmoveout that results in an overflow is reported this way. 240 | Unfl: 240 | Unfl: 241 | An fmoveout that results in an underflow i 241 | An fmoveout that results in an underflow is reported this way. 242 | 242 | 243 | Unimplemented Instruction Handler: 243 | Unimplemented Instruction Handler: 244 | Ovfl: 244 | Ovfl: 245 | Only scosh, setox, ssinh, stwotox, and sca 245 | Only scosh, setox, ssinh, stwotox, and scale can set overflow in 246 | this manner. 246 | this manner. 247 | Unfl: 247 | Unfl: 248 | Stwotox, setox, and scale can set underflo 248 | Stwotox, setox, and scale can set underflow in this manner. 249 | Any of the other Library Routines such tha 249 | Any of the other Library Routines such that f(x)=x in which 250 | x is an extended denorm can report an unde 250 | x is an extended denorm can report an underflow exception. 251 | It is the responsibility of the exception- 251 | It is the responsibility of the exception-causing exception 252 | to make sure that WBTEMP is correct. 252 | to make sure that WBTEMP is correct. 253 | 253 | 254 | The exceptional operand is in FP_SCR1. 254 | The exceptional operand is in FP_SCR1. 255 | 255 | 256 ovfl_unfl: 256 ovfl_unfl: 257 tstb UFLG_TMP(%a6) |test flag for 257 tstb UFLG_TMP(%a6) |test flag for unsupp/unimp state 258 beqs ofuf_con 258 beqs ofuf_con 259 | 259 | 260 | The caller was from an unsupported data type 260 | The caller was from an unsupported data type trap. Test if the 261 | caller set CU_ONLY. If so, the exceptional 261 | caller set CU_ONLY. If so, the exceptional operand is expected in 262 | FPTEMP, rather than WBTEMP. 262 | FPTEMP, rather than WBTEMP. 263 | 263 | 264 tstb CU_ONLY(%a6) |test 264 tstb CU_ONLY(%a6) |test if inst is cu-only 265 beq unsE3 265 beq unsE3 266 | move.w #$fe,CU_SAVEPC(%a6) 266 | move.w #$fe,CU_SAVEPC(%a6) 267 clrb CU_SAVEPC(%a6) 267 clrb CU_SAVEPC(%a6) 268 bsetb #E1,E_BYTE(%a6) |set E 268 bsetb #E1,E_BYTE(%a6) |set E1 exception flag 269 movew ETEMP_EX(%a6),FPTEMP_EX(%a6) 269 movew ETEMP_EX(%a6),FPTEMP_EX(%a6) 270 movel ETEMP_HI(%a6),FPTEMP_HI(%a6) 270 movel ETEMP_HI(%a6),FPTEMP_HI(%a6) 271 movel ETEMP_LO(%a6),FPTEMP_LO(%a6) 271 movel ETEMP_LO(%a6),FPTEMP_LO(%a6) 272 bsetb #fptemp15_bit,DTAG(%a6) |set f 272 bsetb #fptemp15_bit,DTAG(%a6) |set fpte15 273 bclrb #UFLAG,T_BYTE(%a6) |clr U 273 bclrb #UFLAG,T_BYTE(%a6) |clr U flag from unimp 274 bra do_clean |go cl 274 bra do_clean |go clean and exit 275 275 276 ofuf_con: 276 ofuf_con: 277 moveb (%a7),VER_TMP(%a6) |save 277 moveb (%a7),VER_TMP(%a6) |save version number 278 cmpib #BUSY_SIZE-4,1(%a7) |check 278 cmpib #BUSY_SIZE-4,1(%a7) |check for busy frame 279 beqs busy_fr |if un 279 beqs busy_fr |if unimp, grow to busy 280 cmpib #VER_40,(%a7) |test 280 cmpib #VER_40,(%a7) |test for orig unimp frame 281 bnes try_41 |if no 281 bnes try_41 |if not, test for rev frame 282 moveql #13,%d0 |need 282 moveql #13,%d0 |need to zero 14 lwords 283 bras ofuf_fin 283 bras ofuf_fin 284 try_41: 284 try_41: 285 cmpib #VER_41,(%a7) |test 285 cmpib #VER_41,(%a7) |test for rev unimp frame 286 bnel fpsp_fmt_error |if ne 286 bnel fpsp_fmt_error |if neither, exit with error 287 moveql #11,%d0 |need 287 moveql #11,%d0 |need to zero 12 lwords 288 288 289 ofuf_fin: 289 ofuf_fin: 290 clrl (%a7) 290 clrl (%a7) 291 loop1: 291 loop1: 292 clrl -(%a7) |clear 292 clrl -(%a7) |clear and dec a7 293 dbra %d0,loop1 293 dbra %d0,loop1 294 moveb VER_TMP(%a6),(%a7) 294 moveb VER_TMP(%a6),(%a7) 295 moveb #BUSY_SIZE-4,1(%a7) 295 moveb #BUSY_SIZE-4,1(%a7) |write busy fmt word. 296 busy_fr: 296 busy_fr: 297 movel FP_SCR1(%a6),WBTEMP_EX(%a6) 297 movel FP_SCR1(%a6),WBTEMP_EX(%a6) |write 298 movel FP_SCR1+4(%a6),WBTEMP_HI(%a6) 298 movel FP_SCR1+4(%a6),WBTEMP_HI(%a6) |exceptional op to 299 movel FP_SCR1+8(%a6),WBTEMP_LO(%a6) 299 movel FP_SCR1+8(%a6),WBTEMP_LO(%a6) |wbtemp 300 bsetb #E3,E_BYTE(%a6) 300 bsetb #E3,E_BYTE(%a6) |set E3 flag 301 bclrb #E1,E_BYTE(%a6) 301 bclrb #E1,E_BYTE(%a6) |make sure E1 is clear 302 bclrb #UFLAG,T_BYTE(%a6) 302 bclrb #UFLAG,T_BYTE(%a6) |clr U flag 303 movel USER_FPSR(%a6),FPSR_SHADOW(%a6 303 movel USER_FPSR(%a6),FPSR_SHADOW(%a6) 304 orl #sx_mask,E_BYTE(%a6) 304 orl #sx_mask,E_BYTE(%a6) 305 movel CMDREG1B(%a6),%d0 305 movel CMDREG1B(%a6),%d0 |fix cmd1b to make it 306 andl #0x03c30000,%d0 |work 306 andl #0x03c30000,%d0 |work for cmd3b 307 bfextu CMDREG1B(%a6){#13:#1},%d1 307 bfextu CMDREG1B(%a6){#13:#1},%d1 |extract bit 2 308 lsll #5,%d1 308 lsll #5,%d1 309 swap %d1 309 swap %d1 310 orl %d1,%d0 |put i 310 orl %d1,%d0 |put it in the right place 311 bfextu CMDREG1B(%a6){#10:#3},%d1 311 bfextu CMDREG1B(%a6){#10:#3},%d1 |extract bit 3,4,5 312 lsll #2,%d1 312 lsll #2,%d1 313 swap %d1 313 swap %d1 314 orl %d1,%d0 |put t 314 orl %d1,%d0 |put them in the right place 315 movel %d0,CMDREG3B(%a6) 315 movel %d0,CMDREG3B(%a6) |in the busy frame 316 316 317 | 317 | 318 | Check if the frame to be restored is busy or 318 | Check if the frame to be restored is busy or unimp. 319 |** NOTE *** Bug fix for errata (0d43b #3) 319 |** NOTE *** Bug fix for errata (0d43b #3) 320 | If the frame is unimp, we must create a busy 320 | If the frame is unimp, we must create a busy frame to 321 | fix the bug with the nmnexc bits in cases in 321 | fix the bug with the nmnexc bits in cases in which they 322 | are set by a previous instruction and not cl 322 | are set by a previous instruction and not cleared by 323 | the save. The frame will be unimp only if th 323 | the save. The frame will be unimp only if the final 324 | instruction in an emulation routine caused t 324 | instruction in an emulation routine caused the exception 325 | by doing an fmove <ea>,fp0. The exception o 325 | by doing an fmove <ea>,fp0. The exception operand, in 326 | internal format, is in fptemp. 326 | internal format, is in fptemp. 327 | 327 | 328 do_clean: 328 do_clean: 329 cmpib #UNIMP_40_SIZE-4,1(%a7) 329 cmpib #UNIMP_40_SIZE-4,1(%a7) 330 bnes do_con 330 bnes do_con 331 moveql #13,%d0 |in or 331 moveql #13,%d0 |in orig, need to zero 14 lwords 332 bras do_build 332 bras do_build 333 do_con: 333 do_con: 334 cmpib #UNIMP_41_SIZE-4,1(%a7) 334 cmpib #UNIMP_41_SIZE-4,1(%a7) 335 bnes do_restore |frame 335 bnes do_restore |frame must be busy 336 moveql #11,%d0 |in re 336 moveql #11,%d0 |in rev, need to zero 12 lwords 337 337 338 do_build: 338 do_build: 339 moveb (%a7),VER_TMP(%a6) 339 moveb (%a7),VER_TMP(%a6) 340 clrl (%a7) 340 clrl (%a7) 341 loop2: 341 loop2: 342 clrl -(%a7) |clear 342 clrl -(%a7) |clear and dec a7 343 dbra %d0,loop2 343 dbra %d0,loop2 344 | 344 | 345 | Use a1 as pointer into new frame. a6 is not 345 | Use a1 as pointer into new frame. a6 is not correct if an unimp or 346 | busy frame was created as the result of an e 346 | busy frame was created as the result of an exception on the final 347 | instruction of an emulation routine. 347 | instruction of an emulation routine. 348 | 348 | 349 | We need to set the nmcexc bits if the except 349 | We need to set the nmcexc bits if the exception is E1. Otherwise, 350 | the exc taken will be inex2. 350 | the exc taken will be inex2. 351 | 351 | 352 leal BUSY_SIZE+LOCAL_SIZE(%a7),%a1 352 leal BUSY_SIZE+LOCAL_SIZE(%a7),%a1 |init a1 for new frame 353 moveb VER_TMP(%a6),(%a7) |write 353 moveb VER_TMP(%a6),(%a7) |write busy fmt word 354 moveb #BUSY_SIZE-4,1(%a7) 354 moveb #BUSY_SIZE-4,1(%a7) 355 movel FP_SCR1(%a6),WBTEMP_EX(%a1) 355 movel FP_SCR1(%a6),WBTEMP_EX(%a1) |write 356 movel FP_SCR1+4(%a6),WBTEMP_HI(%a1) 356 movel FP_SCR1+4(%a6),WBTEMP_HI(%a1) |exceptional op to 357 movel FP_SCR1+8(%a6),WBTEMP_LO(%a1) 357 movel FP_SCR1+8(%a6),WBTEMP_LO(%a1) |wbtemp 358 | btst.b #E1,E_BYTE(%a1) 358 | btst.b #E1,E_BYTE(%a1) 359 | beq.b do_restore 359 | beq.b do_restore 360 bfextu USER_FPSR(%a6){#17:#4},%d0 360 bfextu USER_FPSR(%a6){#17:#4},%d0 |get snan/operr/ovfl/unfl bits 361 bfins %d0,NMCEXC(%a1){#4:#4} |and i 361 bfins %d0,NMCEXC(%a1){#4:#4} |and insert them in nmcexc 362 movel USER_FPSR(%a6),FPSR_SHADOW(%a1 362 movel USER_FPSR(%a6),FPSR_SHADOW(%a1) |set exc bits 363 orl #sx_mask,E_BYTE(%a1) 363 orl #sx_mask,E_BYTE(%a1) 364 364 365 do_restore: 365 do_restore: 366 moveml USER_DA(%a6),%d0-%d1/%a0-%a1 366 moveml USER_DA(%a6),%d0-%d1/%a0-%a1 367 fmovemx USER_FP0(%a6),%fp0-%fp3 367 fmovemx USER_FP0(%a6),%fp0-%fp3 368 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fp 368 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar 369 frestore (%a7)+ 369 frestore (%a7)+ 370 tstb RES_FLG(%a6) |RES_FLG indic 370 tstb RES_FLG(%a6) |RES_FLG indicates a "continuation" frame 371 beq cont 371 beq cont 372 bsr bug1384 372 bsr bug1384 373 cont: 373 cont: 374 unlk %a6 374 unlk %a6 375 | 375 | 376 | If trace mode enabled, then go to trace hand 376 | If trace mode enabled, then go to trace handler. This handler 377 | cannot have any fp instructions. If there a 377 | cannot have any fp instructions. If there are fp inst's and an 378 | exception has been restored into the machine 378 | exception has been restored into the machine then the exception 379 | will occur upon execution of the fp inst. T 379 | will occur upon execution of the fp inst. This is not desirable 380 | in the kernel (supervisor mode). See MC6804 380 | in the kernel (supervisor mode). See MC68040 manual Section 9.3.8. 381 | 381 | 382 finish_up: 382 finish_up: 383 btstb #7,(%a7) |test 383 btstb #7,(%a7) |test T1 in SR 384 bnes g_trace 384 bnes g_trace 385 btstb #6,(%a7) |test 385 btstb #6,(%a7) |test T0 in SR 386 bnes g_trace 386 bnes g_trace 387 bral fpsp_done 387 bral fpsp_done 388 | 388 | 389 | Change integer stack to look like trace stac 389 | Change integer stack to look like trace stack 390 | The address of the instruction that caused t 390 | The address of the instruction that caused the 391 | exception is already in the integer stack (i 391 | exception is already in the integer stack (is 392 | the same as the saved friar) 392 | the same as the saved friar) 393 | 393 | 394 | If the current frame is already a 6-word sta 394 | If the current frame is already a 6-word stack then all 395 | that needs to be done is to change the vecto 395 | that needs to be done is to change the vector# to TRACE. 396 | If the frame is only a 4-word stack (meaning 396 | If the frame is only a 4-word stack (meaning we got here 397 | on an Unsupported data type exception), then 397 | on an Unsupported data type exception), then we need to grow 398 | the stack an extra 2 words and get the FPIAR 398 | the stack an extra 2 words and get the FPIAR from the FPU. 399 | 399 | 400 g_trace: 400 g_trace: 401 bftst EXC_VEC-4(%sp){#0:#4} 401 bftst EXC_VEC-4(%sp){#0:#4} 402 bne g_easy 402 bne g_easy 403 403 404 subw #4,%sp | make room 404 subw #4,%sp | make room 405 movel 4(%sp),(%sp) 405 movel 4(%sp),(%sp) 406 movel 8(%sp),4(%sp) 406 movel 8(%sp),4(%sp) 407 subw #BUSY_SIZE,%sp 407 subw #BUSY_SIZE,%sp 408 fsave (%sp) 408 fsave (%sp) 409 fmovel %fpiar,BUSY_SIZE+EXC_EA-4(%sp) 409 fmovel %fpiar,BUSY_SIZE+EXC_EA-4(%sp) 410 frestore (%sp) 410 frestore (%sp) 411 addw #BUSY_SIZE,%sp 411 addw #BUSY_SIZE,%sp 412 412 413 g_easy: 413 g_easy: 414 movew #TRACE_VEC,EXC_VEC-4(%a7) 414 movew #TRACE_VEC,EXC_VEC-4(%a7) 415 bral real_trace 415 bral real_trace 416 | 416 | 417 | This is a work-around for hardware bug 1384 417 | This is a work-around for hardware bug 1384. 418 | 418 | 419 bug1384: 419 bug1384: 420 link %a5,#0 420 link %a5,#0 421 fsave -(%sp) 421 fsave -(%sp) 422 cmpib #0x41,(%sp) | check for co 422 cmpib #0x41,(%sp) | check for correct frame 423 beq frame_41 423 beq frame_41 424 bgt nofix | if more adva 424 bgt nofix | if more advanced mask, do nada 425 425 426 frame_40: 426 frame_40: 427 tstb 1(%sp) | check to see 427 tstb 1(%sp) | check to see if idle 428 bne notidle 428 bne notidle 429 idle40: 429 idle40: 430 clrl (%sp) | get rid of o 430 clrl (%sp) | get rid of old fsave frame 431 movel %d1,USER_D1(%a6) | save d1 431 movel %d1,USER_D1(%a6) | save d1 432 movew #8,%d1 | place unimp 432 movew #8,%d1 | place unimp frame instead 433 loop40: clrl -(%sp) 433 loop40: clrl -(%sp) 434 dbra %d1,loop40 434 dbra %d1,loop40 435 movel USER_D1(%a6),%d1 | restore d1 435 movel USER_D1(%a6),%d1 | restore d1 436 movel #0x40280000,-(%sp) 436 movel #0x40280000,-(%sp) 437 frestore (%sp)+ 437 frestore (%sp)+ 438 unlk %a5 438 unlk %a5 439 rts 439 rts 440 440 441 frame_41: 441 frame_41: 442 tstb 1(%sp) | check to see 442 tstb 1(%sp) | check to see if idle 443 bne notidle 443 bne notidle 444 idle41: 444 idle41: 445 clrl (%sp) | get rid of o 445 clrl (%sp) | get rid of old fsave frame 446 movel %d1,USER_D1(%a6) | save d1 446 movel %d1,USER_D1(%a6) | save d1 447 movew #10,%d1 | place unimp 447 movew #10,%d1 | place unimp frame instead 448 loop41: clrl -(%sp) 448 loop41: clrl -(%sp) 449 dbra %d1,loop41 449 dbra %d1,loop41 450 movel USER_D1(%a6),%d1 | restore d1 450 movel USER_D1(%a6),%d1 | restore d1 451 movel #0x41300000,-(%sp) 451 movel #0x41300000,-(%sp) 452 frestore (%sp)+ 452 frestore (%sp)+ 453 unlk %a5 453 unlk %a5 454 rts 454 rts 455 455 456 notidle: 456 notidle: 457 bclrb #etemp15_bit,-40(%a5) 457 bclrb #etemp15_bit,-40(%a5) 458 frestore (%sp)+ 458 frestore (%sp)+ 459 unlk %a5 459 unlk %a5 460 rts 460 rts 461 461 462 nofix: 462 nofix: 463 frestore (%sp)+ 463 frestore (%sp)+ 464 unlk %a5 464 unlk %a5 465 rts 465 rts 466 466 467 |end 467 |end
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.