jump.py (5081:2ccce8600a9d) jump.py (6060:3d524dc980a8)
1# Copyright (c) 2007 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use of this software in source and binary forms,
5# with or without modification, are permitted provided that the
6# following conditions are met:
7#
8# The software must be used only for Non-Commercial Use which means any

--- 76 unchanged lines hidden (view full) ---

85{
86 # Make the default data size of jumps 64 bits in 64 bit mode
87 .adjust_env oszIn64Override
88
89 rdip t7
90 ld t1, seg, riprel, disp
91 wripi t1, 0
92};
1# Copyright (c) 2007 The Hewlett-Packard Development Company
2# All rights reserved.
3#
4# Redistribution and use of this software in source and binary forms,
5# with or without modification, are permitted provided that the
6# following conditions are met:
7#
8# The software must be used only for Non-Commercial Use which means any

--- 76 unchanged lines hidden (view full) ---

85{
86 # Make the default data size of jumps 64 bits in 64 bit mode
87 .adjust_env oszIn64Override
88
89 rdip t7
90 ld t1, seg, riprel, disp
91 wripi t1, 0
92};
93
94def macroop JMP_FAR_M
95{
96 limm t1, 0, dataSize=8
97 limm t2, 0, dataSize=8
98 lea t1, seg, sib, disp, dataSize=asz
99 ld t2, seg, [1, t0, t1], dsz
100 ld t1, seg, [1, t0, t1]
101 br rom_label("jmpFarWork")
102};
103
104def macroop JMP_FAR_P
105{
106 limm t1, 0, dataSize=8
107 limm t2, 0, dataSize=8
108 rdip t7, dataSize=asz
109 lea t1, seg, riprel, disp, dataSize=asz
110 ld t2, seg, [1, t0, t1], dsz
111 ld t1, seg, [1, t0, t1]
112 br rom_label("jmpFarWork")
113};
114
115def macroop JMP_FAR_I
116{
117 # Put the whole far pointer into a register.
118 limm t2, imm, dataSize=8
119 # Figure out the width of the offset.
120 limm t3, dsz, dataSize=8
121 sll t3, t3, 3, dataSize=8
122 # Get the selector into t1.
123 sll t1, t2, t3, dataSize=8
124 mov t1, t0, t1, dataSize=2
125 # And get the offset into t2
126 mov t2, t0, t2
127 br rom_label("jmpFarWork")
128};
129
130def rom
131{
132 extern jmpFarWork:
133 # t1 has the offset and t2 has the new selector.
134 # This is intended to run in protected mode.
135 andi t0, t2, 0xFC, flags=(EZF,), dataSize=2
136 fault "new GeneralProtection(0)", flags=(CEZF,)
137 andi t3, t2, 0xF8, dataSize=8
138 andi t0, t2, 0x4, flags=(EZF,), dataSize=2
139 br rom_local_label("farJmpGlobalDescriptor"), flags=(CEZF,)
140 ld t4, tsl, [1, t0, t3], dataSize=8, addressSize=8, atCPL0=True
141 br rom_local_label("farJmpProcessDescriptor")
142farJmpGlobalDescriptor:
143 ld t4, tsg, [1, t0, t3], dataSize=8, addressSize=8, atCPL0=True
144farJmpProcessDescriptor:
145 rcri t0, t4, 13, flags=(ECF,), dataSize=2
146 br rom_local_label("farJmpSystemDescriptor"), flags=(nCECF,)
147 chks t2, t4, CSCheck, dataSize=8
148 wrdl cs, t4, t2
149 wrsel cs, t2
150 wrip t0, t1
151 eret
152
153farJmpSystemDescriptor:
154 panic "Far jumps to system descriptors aren't implemented"
155 eret
156};
157
158def macroop JMP_FAR_REAL_M
159{
160 lea t1, seg, sib, disp, dataSize=asz
161 ld t2, seg, [1, t0, t1], dsz
162 ld t1, seg, [1, t0, t1]
163 zexti t3, t1, 15, dataSize=8
164 slli t3, t3, 4, dataSize=8
165 wrsel cs, t1, dataSize=2
166 wrbase cs, t3
167 wrip t0, t2, dataSize=asz
168};
169
170def macroop JMP_FAR_REAL_P
171{
172 panic "Real mode far jump executed in 64 bit mode!"
173};
174
175def macroop JMP_FAR_REAL_I
176{
177 # Put the whole far pointer into a register.
178 limm t2, imm, dataSize=8
179 # Figure out the width of the offset.
180 limm t3, dsz, dataSize=8
181 sll t3, t3, 3, dataSize=8
182 # Get the selector into t1.
183 sll t1, t2, t3, dataSize=8
184 mov t1, t0, t1, dataSize=2
185 # And get the offset into t2
186 mov t2, t0, t2
187 slli t3, t3, 4, dataSize=8
188 wrsel cs, t1, dataSize=2
189 wrbase cs, t3
190 wrip t0, t2, dataSize=asz
191};
93'''
192'''