^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) | skeleton.sa 3.2 4/26/91
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) | This file contains code that is system dependent and will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) | need to be modified to install the FPSP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) | Each entry point for exception 'xxxx' begins with a 'jmp fpsp_xxxx'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) | Put any target system specific handling that must be done immediately
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) | before the jump instruction. If there no handling necessary, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) | the 'fpsp_xxxx' handler entry point should be placed in the exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) | table so that the 'jmp' can be eliminated. If the FPSP determines that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) | exception is one that must be reported then there will be a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) | return from the package by a 'jmp real_xxxx'. At that point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) | the machine state will be identical to the state before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) | the FPSP was entered. In particular, whatever condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) | that caused the exception will still be pending when the FPSP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) | package returns. Thus, there will be system specific code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) | to handle the exception.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) | If the exception was completely handled by the package, then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) | the return will be via a 'jmp fpsp_done'. Unless there is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) | OS specific work to be done (such as handling a context switch or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) | interrupt) the user program can be resumed via 'rte'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) | In the following skeleton code, some typical 'real_xxxx' handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) | code is shown. This code may need to be moved to an appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) | place in the target system, or rewritten.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) | Copyright (C) Motorola, Inc. 1990
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) | All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) | For details on the license for this file, please see the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) | file, README, in this same directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) | Modified for Linux-1.3.x by Jes Sorensen (jds@kom.auc.dk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <asm/entry.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) |SKELETON idnt 2,1 | Motorola 040 Floating Point Software Package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) |section 15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) | The following counters are used for standalone testing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) |section 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #include "fpsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) |xref b1238_fix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) | Divide by Zero exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) | All dz exceptions are 'real', hence no fpsp_dz entry point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) .global dz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .global real_dz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) dz:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) real_dz:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) bclrb #E1,E_BYTE(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) | Inexact exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) | All inexact exceptions are real, but the 'real' handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) | will probably want to clear the pending exception.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) | The provided code will clear the E3 exception (if pending),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) | otherwise clear the E1 exception. The frestore is not really
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) | necessary for E1 exceptions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) | Code following the 'inex' label is to handle bug #1232. In this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) | bug, if an E1 snan, ovfl, or unfl occurred, and the process was
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) | swapped out before taking the exception, the exception taken on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) | return was inex, rather than the correct exception. The snan, ovfl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) | and unfl exception to be taken must not have been enabled. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) | fix is to check for E1, and the existence of one of snan, ovfl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) | or unfl bits set in the fpsr. If any of these are set, branch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) | to the appropriate handler for the exception in the fpsr. Note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) | that this fix is only for d43b parts, and is skipped if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) | version number is not $40.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .global real_inex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .global inex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) inex:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) cmpib #VER_40,(%sp) |test version number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) bnes not_fmt40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) fmovel %fpsr,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) btstb #E1,E_BYTE(%a6) |test for E1 set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) beqs not_b1232
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) btstb #snan_bit,2(%sp) |test for snan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) beq inex_ckofl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) addl #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) bra snan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) inex_ckofl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) btstb #ovfl_bit,2(%sp) |test for ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) beq inex_ckufl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) addl #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) bra ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) inex_ckufl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) btstb #unfl_bit,2(%sp) |test for unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) beq not_b1232
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) addl #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) bra unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) | We do not have the bug 1232 case. Clean up the stack and call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) | real_inex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) not_b1232:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) addl #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) real_inex:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) not_fmt40:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) bclrb #E3,E_BYTE(%a6) |clear and test E3 flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) beqs inex_cke1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) | Clear dirty bit on dest resister in the frame before branching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) | to b1238_fix.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) moveml %d0/%d1,USER_DA(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) bfextu CMDREG1B(%a6){#6:#3},%d0 |get dest reg no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) bclrb %d0,FPR_DIRTY_BITS(%a6) |clr dest dirty bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) bsrl b1238_fix |test for bug1238 case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) moveml USER_DA(%a6),%d0/%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) bras inex_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) inex_cke1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) bclrb #E1,E_BYTE(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) inex_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) | Overflow exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) |xref fpsp_ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) .global real_ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) .global ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ovfl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) jmp fpsp_ovfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) real_ovfl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) bclrb #E3,E_BYTE(%a6) |clear and test E3 flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) bnes ovfl_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) bclrb #E1,E_BYTE(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) ovfl_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) | Underflow exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) |xref fpsp_unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) .global real_unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) .global unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) unfl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) jmp fpsp_unfl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) real_unfl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) bclrb #E3,E_BYTE(%a6) |clear and test E3 flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) bnes unfl_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) bclrb #E1,E_BYTE(%a6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) unfl_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) | Signalling NAN exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) |xref fpsp_snan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) .global real_snan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .global snan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) snan:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) jmp fpsp_snan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) real_snan:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) bclrb #E1,E_BYTE(%a6) |snan is always an E1 exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) | Operand Error exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) |xref fpsp_operr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) .global real_operr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .global operr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) operr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) jmp fpsp_operr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) real_operr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) bclrb #E1,E_BYTE(%a6) |operr is always an E1 exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) | BSUN exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) | This sample handler simply clears the nan bit in the FPSR.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) |xref fpsp_bsun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) .global real_bsun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .global bsun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) bsun:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) jmp fpsp_bsun
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) real_bsun:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) bclrb #E1,E_BYTE(%a6) |bsun is always an E1 exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) fmovel %FPSR,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) bclrb #nan_bit,(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) fmovel (%sp)+,%FPSR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) | F-line exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) | A 'real' F-line exception is one that the FPSP isn't supposed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) | handle. E.g. an instruction with a co-processor ID that is not 1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) |xref fpsp_fline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) .global real_fline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) .global fline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) fline:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) jmp fpsp_fline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) real_fline:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) | Unsupported data type exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) |xref fpsp_unsupp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) .global real_unsupp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) .global unsupp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unsupp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) jmp fpsp_unsupp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) real_unsupp:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) link %a6,#-LOCAL_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) fsave -(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) bclrb #E1,E_BYTE(%a6) |unsupp is always an E1 exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) frestore (%sp)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) unlk %a6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) movel %sp,%sp@- | stack frame pointer argument
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) bsrl trap_c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) addql #4,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) bral ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) | Trace exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) .global real_trace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) real_trace:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) bral trap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) | fpsp_fmt_error --- exit point for frame format error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) | The fpu stack frame does not match the frames existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) | or planned at the time of this writing. The fpsp is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) | unable to handle frame sizes not in the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) | version:size pairs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) | {4060, 4160} - busy frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) | {4028, 4130} - unimp frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) | {4000, 4100} - idle frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) | This entry point simply holds an f-line illegal value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) | Replace this with a call to your kernel panic code or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) | code to handle future revisions of the fpu.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) .global fpsp_fmt_error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) fpsp_fmt_error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) .long 0xf27f0000 |f-line illegal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) | fpsp_done --- FPSP exit point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) | The exception has been handled by the package and we are ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) | to return to user mode, but there may be OS specific code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) | to execute before we do. If there is, do it now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) .global fpsp_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) fpsp_done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) btst #0x5,%sp@ | supervisor bit set in saved SR?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) beq .Lnotkern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) rte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) .Lnotkern:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) SAVE_ALL_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) GET_CURRENT(%d0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) | deliver signals, reschedule etc..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) jra ret_from_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) | mem_write --- write to user or supervisor address space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) | Writes to memory while in supervisor mode. copyout accomplishes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) | this via a 'moves' instruction. copyout is a UNIX SVR3 (and later) function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) | If you don't have copyout, use the local copy of the function below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) | a0 - supervisor source address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) | a1 - user destination address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) | d0 - number of bytes to write (maximum count is 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) | The supervisor source address is guaranteed to point into the supervisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) | stack. The result is that a UNIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) | process is allowed to sleep as a consequence of a page fault during
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) | copyout. The probability of a page fault is exceedingly small because
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) | the 68040 always reads the destination address and thus the page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) | faults should have already been handled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) | If the EXC_SR shows that the exception was from supervisor space,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) | then just do a dumb (and slow) memory move. In a UNIX environment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) | there shouldn't be any supervisor mode floating point exceptions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) .global mem_write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) mem_write:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) btstb #5,EXC_SR(%a6) |check for supervisor state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) beqs user_write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) super_write:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) moveb (%a0)+,(%a1)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) subql #1,%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) bnes super_write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) user_write:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) movel %d1,-(%sp) |preserve d1 just in case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) movel %d0,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) movel %a1,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) movel %a0,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) jsr copyout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) addw #12,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) movel (%sp)+,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) | mem_read --- read from user or supervisor address space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) | Reads from memory while in supervisor mode. copyin accomplishes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) | this via a 'moves' instruction. copyin is a UNIX SVR3 (and later) function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) | If you don't have copyin, use the local copy of the function below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) | The FPSP calls mem_read to read the original F-line instruction in order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) | to extract the data register number when the 'Dn' addressing mode is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) | used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) |Input:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) | a0 - user source address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) | a1 - supervisor destination address
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) | d0 - number of bytes to read (maximum count is 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) | Like mem_write, mem_read always reads with a supervisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) | destination address on the supervisor stack. Also like mem_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) | the EXC_SR is checked and a simple memory copy is done if reading
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) | from supervisor space is indicated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) .global mem_read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) mem_read:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) btstb #5,EXC_SR(%a6) |check for supervisor state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) beqs user_read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) super_read:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) moveb (%a0)+,(%a1)+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) subql #1,%d0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) bnes super_read
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) user_read:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) movel %d1,-(%sp) |preserve d1 just in case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) movel %d0,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) movel %a1,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) movel %a0,-(%sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) jsr copyin
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) addw #12,%sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) movel (%sp)+,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) | Use these routines if your kernel doesn't have copyout/copyin equivalents.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) | Assumes that D0/D1/A0/A1 are scratch registers. copyout overwrites DFC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) | and copyin overwrites SFC.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) copyout:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) movel 4(%sp),%a0 | source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) movel 8(%sp),%a1 | destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) movel 12(%sp),%d0 | count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) subl #1,%d0 | dec count by 1 for dbra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) movel #1,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) | DFC is already set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) | movec %d1,%DFC | set dfc for user data space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) moreout:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) moveb (%a0)+,%d1 | fetch supervisor byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) out_ea:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) movesb %d1,(%a1)+ | write user byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) dbf %d0,moreout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) copyin:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) movel 4(%sp),%a0 | source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) movel 8(%sp),%a1 | destination
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) movel 12(%sp),%d0 | count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) subl #1,%d0 | dec count by 1 for dbra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) movel #1,%d1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) | SFC is already set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) | movec %d1,%SFC | set sfc for user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) morein:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) in_ea:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) movesb (%a0)+,%d1 | fetch user byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) moveb %d1,(%a1)+ | write supervisor byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) dbf %d0,morein
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) rts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) .section .fixup,#alloc,#execinstr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) .even
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) jbra fpsp040_die
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) .section __ex_table,#alloc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) .align 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) .long in_ea,1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) .long out_ea,1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) |end