save_and_restore_x87_environment.py (7087:fb8d5786ff30) | save_and_restore_x87_environment.py (9895:a1f661af9dc9) |
---|---|
1# Copyright (c) 2007 The Hewlett-Packard Development Company | 1# Copyright (c) 2013 Andreas Sandberg |
2# All rights reserved. 3# | 2# All rights reserved. 3# |
4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# | |
13# Redistribution and use in source and binary forms, with or without 14# modification, are permitted provided that the following conditions are 15# met: redistributions of source code must retain the above copyright 16# notice, this list of conditions and the following disclaimer; 17# redistributions in binary form must reproduce the above copyright 18# notice, this list of conditions and the following disclaimer in the 19# documentation and/or other materials provided with the distribution; 20# neither the name of the copyright holders nor the names of its --- 7 unchanged lines hidden (view full) --- 28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35# | 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution; 11# neither the name of the copyright holders nor the names of its --- 7 unchanged lines hidden (view full) --- 19# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# |
36# Authors: Gabe Black | 27# Authors: Andreas Sandberg |
37 | 28 |
29 30# Register usage: 31# t1, t2 == temporaries 32 33fldenvTemplate = """ 34 ld t1, seg, %(mode)s, "DISPLACEMENT + 0", dataSize=2 35 wrval fcw, t1 36 37 ld t1, seg, %(mode)s, "DISPLACEMENT + 4", dataSize=2 38 wrval fsw, t1 39 srli t1, t1, 11, dataSize=2 40 andi t1, t1, 0x7, dataSize=2 41 wrval "InstRegIndex(MISCREG_X87_TOP)", t1 42 43 ld t1, seg, %(mode)s, "DISPLACEMENT + 8", dataSize=2 44 wrval ftw, t1 45 46 ld t1, seg, %(mode)s, "DISPLACEMENT + 12", dataSize=4 47 wrval "InstRegIndex(MISCREG_FIOFF)", t1 48 49 ld t1, seg, %(mode)s, "DISPLACEMENT + 16 + 0", dataSize=2 50 wrval "InstRegIndex(MISCREG_FISEG)", t1 51 52 ld t1, seg, %(mode)s, "DISPLACEMENT + 16 + 2", dataSize=2 53 wrval "InstRegIndex(MISCREG_FOP)", t1 54 55 ld t1, seg, %(mode)s, "DISPLACEMENT + 20", dataSize=4 56 wrval "InstRegIndex(MISCREG_FOOFF)", t1 57 58 ld t1, seg, %(mode)s, "DISPLACEMENT + 24", dataSize=2 59 wrval "InstRegIndex(MISCREG_FOSEG)", t1 60""" 61 62fnstenvTemplate = """ 63 rdval t2, fcw 64 st t2, seg, %(mode)s, "DISPLACEMENT + 0", dataSize=2 65 66 # FSW includes TOP when read 67 rdval t1, fsw 68 st t1, seg, %(mode)s, "DISPLACEMENT + 4", dataSize=2 69 70 rdval t1, ftw 71 st t1, seg, %(mode)s, "DISPLACEMENT + 8", dataSize=2 72 73 rdval t1, "InstRegIndex(MISCREG_FIOFF)" 74 st t1, seg, %(mode)s, "DISPLACEMENT + 12", dataSize=4 75 76 rdval t1, "InstRegIndex(MISCREG_FISEG)" 77 st t1, seg, %(mode)s, "DISPLACEMENT + 16 + 0", dataSize=2 78 79 rdval t1, "InstRegIndex(MISCREG_FOP)" 80 st t1, seg, %(mode)s, "DISPLACEMENT + 16 + 2", dataSize=2 81 82 rdval t1, "InstRegIndex(MISCREG_FOOFF)" 83 st t1, seg, %(mode)s, "DISPLACEMENT + 20", dataSize=4 84 85 rdval t1, "InstRegIndex(MISCREG_FOSEG)" 86 st t1, seg, %(mode)s, "DISPLACEMENT + 24", dataSize=2 87 88 # Mask exceptions 89 ori t2, t2, 0x3F 90 wrval fcw, t2 91""" 92 |
|
38microcode = ''' | 93microcode = ''' |
39# FLDENV 40# FNSTENV 41# FSTENV | 94def macroop FLDENV_M { 95''' + fldenvTemplate % { "mode" : "sib" } + ''' 96}; 97 98def macroop FLDENV_P { 99 rdip t7 100''' + fldenvTemplate % { "mode" : "riprel" } + ''' 101}; 102 103def macroop FNSTENV_M { 104''' + fnstenvTemplate % { "mode" : "sib" } + ''' 105}; 106 107def macroop FNSTENV_P { 108 rdip t7 109''' + fnstenvTemplate % { "mode" : "riprel" } + ''' 110}; |
42''' | 111''' |