Deleted Added
sdiff udiff text old ( 10544:049273bc03f6 ) new ( 10959:30c700ee0d47 )
full compact
1# Copyright (c) 2007 The Hewlett-Packard Development Company
2# Copyright (c) 2012-2013 AMD
3# All rights reserved.
4#
5# The license below extends only to copyright in the software and shall
6# not be construed as granting a license to any other intellectual
7# property including but not limited to intellectual property relating
8# to a hardware implementation of the functionality of the software
9# licensed hereunder. You may use the software subject to the license
10# terms below provided that you ensure that this notice is replicated
11# unmodified and in its entirety in all distributions of the software,
12# modified or unmodified, in source code or in binary form.
13#
14# Redistribution and use in source and binary forms, with or without
15# modification, are permitted provided that the following conditions are
16# met: redistributions of source code must retain the above copyright
17# notice, this list of conditions and the following disclaimer;
18# redistributions in binary form must reproduce the above copyright
19# notice, this list of conditions and the following disclaimer in the
20# documentation and/or other materials provided with the distribution;
21# neither the name of the copyright holders nor the names of its
22# contributors may be used to endorse or promote products derived from
23# this software without specific prior written permission.
24#
25# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36#
37# Authors: Gabe Black
38
39microcode = '''
40def macroop JMP_I
41{
42 # Make the default data size of jumps 64 bits in 64 bit mode
43 .adjust_env oszIn64Override
44
45 rdip t1
46 limm t2, imm
47 wrip t1, t2
48};
49
50def macroop JMP_R
51{
52 # Make the default data size of jumps 64 bits in 64 bit mode
53 .adjust_env oszIn64Override
54
55 wripi reg, 0
56};
57
58def macroop JMP_M
59{
60 # Make the default data size of jumps 64 bits in 64 bit mode
61 .adjust_env oszIn64Override
62
63 ld t1, seg, sib, disp
64 wripi t1, 0
65};
66
67def macroop JMP_P
68{
69 # Make the default data size of jumps 64 bits in 64 bit mode
70 .adjust_env oszIn64Override
71
72 rdip t7
73 ld t1, seg, riprel, disp
74 wripi t1, 0
75};
76
77def macroop JMP_FAR_M
78{
79 limm t1, 0, dataSize=8
80 limm t2, 0, dataSize=8
81 lea t1, seg, sib, disp, dataSize=asz
82 ld t2, seg, [1, t0, t1], dsz
83 ld t1, seg, [1, t0, t1]
84 br rom_label("jmpFarWork")
85};
86
87def macroop JMP_FAR_P
88{
89 limm t1, 0, dataSize=8
90 limm t2, 0, dataSize=8
91 rdip t7, dataSize=asz
92 lea t1, seg, riprel, disp, dataSize=asz
93 ld t2, seg, [1, t0, t1], dsz
94 ld t1, seg, [1, t0, t1]
95 br rom_label("jmpFarWork")
96};
97
98def macroop JMP_FAR_I
99{
100 # Put the whole far pointer into a register.
101 limm t2, imm, dataSize=8
102 # Figure out the width of the offset.
103 limm t3, dsz, dataSize=8
104 slli t3, t3, 3, dataSize=8
105 # Get the offset into t1.
106 mov t1, t0, t2
107 # Get the selector into t2.
108 srl t2, t2, t3, dataSize=8
109 mov t2, t0, t2, dataSize=2
110 br rom_label("jmpFarWork")
111};
112
113def rom
114{
115 extern jmpFarWork:
116 # t1 has the offset and t2 has the new selector.
117 # This is intended to run in protected mode.
118 andi t0, t2, 0xFC, flags=(EZF,), dataSize=2
119 fault "std::make_shared<GeneralProtection>(0)", flags=(CEZF,)
120 andi t3, t2, 0xF8, dataSize=8
121 andi t0, t2, 0x4, flags=(EZF,), dataSize=2
122 br rom_local_label("farJmpGlobalDescriptor"), flags=(CEZF,)
123 ld t4, tsl, [1, t0, t3], dataSize=8, addressSize=8, atCPL0=True
124 br rom_local_label("farJmpProcessDescriptor")
125farJmpGlobalDescriptor:
126 ld t4, tsg, [1, t0, t3], dataSize=8, addressSize=8, atCPL0=True
127farJmpProcessDescriptor:
128 rcri t0, t4, 13, flags=(ECF,), dataSize=2
129 br rom_local_label("farJmpSystemDescriptor"), flags=(nCECF,)
130 chks t2, t4, CSCheck, dataSize=8
131 wrdl cs, t4, t2, dataSize=4
132 wrsel cs, t2, dataSize=4
133 wrip t0, t1, dataSize=4
134 eret
135
136farJmpSystemDescriptor:
137 panic "Far jumps to system descriptors aren't implemented"
138 eret
139};
140
141def macroop JMP_FAR_REAL_M
142{
143 lea t1, seg, sib, disp, dataSize=asz
144 ld t2, seg, [1, t0, t1], dsz
145 ld t1, seg, [1, t0, t1]
146 zexti t3, t1, 15, dataSize=8
147 slli t3, t3, 4, dataSize=8
148 wrsel cs, t1, dataSize=2
149 wrbase cs, t3, dataSize=8
150 wrip t0, t2, dataSize=asz
151};
152
153def macroop JMP_FAR_REAL_P
154{
155 panic "Real mode far jump executed in 64 bit mode!"
156};
157
158def macroop JMP_FAR_REAL_I
159{
160 # Put the whole far pointer into a register.
161 limm t2, imm, dataSize=8
162 # Figure out the width of the offset.
163 limm t3, dsz, dataSize=8
164 slli t3, t3, 3, dataSize=8
165 # Get the selector into t1.
166 srl t1, t2, t3, dataSize=8
167 mov t1, t0, t1, dataSize=2
168 # And get the offset into t2
169 mov t2, t0, t2
170 slli t3, t1, 4, dataSize=8
171 wrsel cs, t1, dataSize=2
172 wrbase cs, t3, dataSize=8
173 wrip t0, t2, dataSize=asz
174};
175'''