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