1* $NetBSD: x_fline.sa,v 1.2 1994/10/26 07:50:23 cgd Exp $ 2 3* MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP 4* M68000 Hi-Performance Microprocessor Division 5* M68040 Software Package 6* 7* M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc. 8* All rights reserved. 9* 10* THE SOFTWARE is provided on an "AS IS" basis and without warranty. 11* To the maximum extent permitted by applicable law, 12* MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, 13* INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A 14* PARTICULAR PURPOSE and any warranty against infringement with 15* regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) 16* and any accompanying written materials. 17* 18* To the maximum extent permitted by applicable law, 19* IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER 20* (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS 21* PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR 22* OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE 23* SOFTWARE. Motorola assumes no responsibility for the maintenance 24* and support of the SOFTWARE. 25* 26* You are hereby granted a copyright license to use, modify, and 27* distribute the SOFTWARE so long as this entire notice is retained 28* without alteration in any modified and/or redistributed versions, 29* and that such modified versions are clearly identified as such. 30* No licenses are granted by implication, estoppel or otherwise 31* under any patents or trademarks of Motorola, Inc. 32 33* 34* x_fline.sa 3.3 1/10/91 35* 36* fpsp_fline --- FPSP handler for fline exception 37* 38* First determine if the exception is one of the unimplemented 39* floating point instructions. If so, let fpsp_unimp handle it. 40* Next, determine if the instruction is an fmovecr with a non-zero 41* <ea> field. If so, handle here and return. Otherwise, it 42* must be a real F-line exception. 43* 44 45X_FLINE IDNT 2,1 Motorola 040 Floating Point Software Package 46 47 section 8 48 49 include fpsp.h 50 51 xref real_fline 52 xref fpsp_unimp 53 xref uni_2 54 xref mem_read 55 xref fpsp_fmt_error 56 57 xdef fpsp_fline 58fpsp_fline: 59* 60* check for unimplemented vector first. Use EXC_VEC-4 because 61* the equate is valid only after a 'link a6' has pushed one more 62* long onto the stack. 63* 64 cmp.w #UNIMP_VEC,EXC_VEC-4(a7) 65 beq.l fpsp_unimp 66 67* 68* fmovecr with non-zero <ea> handling here 69* 70 sub.l #4,a7 ;4 accounts for 2-word difference 71* ;between six word frame (unimp) and 72* ;four word frame 73 link a6,#-LOCAL_SIZE 74 fsave -(a7) 75 movem.l d0-d1/a0-a1,USER_DA(a6) 76 movea.l EXC_PC+4(a6),a0 ;get address of fline instruction 77 lea.l L_SCR1(a6),a1 ;use L_SCR1 as scratch 78 move.l #4,d0 79 add.l #4,a6 ;to offset the sub.l #4,a7 above so that 80* ;a6 can point correctly to the stack frame 81* ;before branching to mem_read 82 bsr.l mem_read 83 sub.l #4,a6 84 move.l L_SCR1(a6),d0 ;d0 contains the fline and command word 85 bfextu d0{4:3},d1 ;extract coprocessor id 86 cmpi.b #1,d1 ;check if cpid=1 87 bne.w not_mvcr ;exit if not 88 bfextu d0{16:6},d1 89 cmpi.b #$17,d1 ;check if it is an FMOVECR encoding 90 bne.w not_mvcr 91* ;if an FMOVECR instruction, fix stack 92* ;and go to FPSP_UNIMP 93fix_stack: 94 cmpi.b #VER_40,(a7) ;test for orig unimp frame 95 bne.b ck_rev 96 sub.l #UNIMP_40_SIZE-4,a7 ;emulate an orig fsave 97 move.b #VER_40,(a7) 98 move.b #UNIMP_40_SIZE-4,1(a7) 99 clr.w 2(a7) 100 bra.b fix_con 101ck_rev: 102 cmpi.b #VER_41,(a7) ;test for rev unimp frame 103 bne.l fpsp_fmt_error ;if not $40 or $41, exit with error 104 sub.l #UNIMP_41_SIZE-4,a7 ;emulate a rev fsave 105 move.b #VER_41,(a7) 106 move.b #UNIMP_41_SIZE-4,1(a7) 107 clr.w 2(a7) 108fix_con: 109 move.w EXC_SR+4(a6),EXC_SR(a6) ;move stacked sr to new position 110 move.l EXC_PC+4(a6),EXC_PC(a6) ;move stacked pc to new position 111 fmove.l EXC_PC(a6),FPIAR ;point FPIAR to fline inst 112 move.l #4,d1 113 add.l d1,EXC_PC(a6) ;increment stacked pc value to next inst 114 move.w #$202c,EXC_VEC(a6) ;reformat vector to unimp 115 clr.l EXC_EA(a6) ;clear the EXC_EA field 116 move.w d0,CMDREG1B(a6) ;move the lower word into CMDREG1B 117 clr.l E_BYTE(a6) 118 bset.b #UFLAG,T_BYTE(a6) 119 movem.l USER_DA(a6),d0-d1/a0-a1 ;restore data registers 120 bra.l uni_2 121 122not_mvcr: 123 movem.l USER_DA(a6),d0-d1/a0-a1 ;restore data registers 124 frestore (a7)+ 125 unlk a6 126 add.l #4,a7 127 bra.l real_fline 128 129 end 130