Changeset 65834 in vbox for trunk/src/VBox
- Timestamp:
- Feb 21, 2017 4:21:36 PM (8 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsOneByte.cpp.h
r65825 r65834 57 57 * @opstats add_Eb_Gb 58 58 * @opgroup op_gen_arith_bin 59 * @optest op1=1 op2=1 -> op1=2 efl &~=a?,p?60 * @optest o32 / op1=0xfffffffe :dw in2=1:dw -> out1=0xffffffff:dw efl&~=a?,p?59 * @optest op1=1 op2=1 -> op1=2 efl=of,sf,zf,af 60 * @optest o32 / op1=0xfffffffe op2=1 -> op1=0xffffffff efl=af,pe,up 61 61 */ 62 62 FNIEMOP_DEF(iemOp_add_Eb_Gb) -
trunk/src/VBox/VMM/VMMAll/IEMAllInstructionsPython.py
r65828 r65834 72 72 73 73 74 g_kdX86EFlagsConstants = { 75 'X86_EFL_CF': 0x00000001, # RT_BIT_32(0) 76 'X86_EFL_1': 0x00000002, # RT_BIT_32(1) 77 'X86_EFL_PF': 0x00000004, # RT_BIT_32(2) 78 'X86_EFL_AF': 0x00000010, # RT_BIT_32(4) 79 'X86_EFL_ZF': 0x00000040, # RT_BIT_32(6) 80 'X86_EFL_SF': 0x00000080, # RT_BIT_32(7) 81 'X86_EFL_TF': 0x00000100, # RT_BIT_32(8) 82 'X86_EFL_IF': 0x00000200, # RT_BIT_32(9) 83 'X86_EFL_DF': 0x00000400, # RT_BIT_32(10) 84 'X86_EFL_OF': 0x00000800, # RT_BIT_32(11) 85 'X86_EFL_IOPL': 0x00003000, # (RT_BIT_32(12) | RT_BIT_32(13)) 86 'X86_EFL_NT': 0x00004000, # RT_BIT_32(14) 87 'X86_EFL_RF': 0x00010000, # RT_BIT_32(16) 88 'X86_EFL_VM': 0x00020000, # RT_BIT_32(17) 89 'X86_EFL_AC': 0x00040000, # RT_BIT_32(18) 90 'X86_EFL_VIF': 0x00080000, # RT_BIT_32(19) 91 'X86_EFL_VIP': 0x00100000, # RT_BIT_32(20) 92 'X86_EFL_ID': 0x00200000, # RT_BIT_32(21) 93 'X86_EFL_LIVE_MASK': 0x003f7fd5, # UINT32_C(0x003f7fd5) 94 'X86_EFL_RA1_MASK': 0x00000002, # RT_BIT_32(1) 95 }; 96 97 74 98 def _isValidOpcodeByte(sOpcode): 75 99 """ … … 136 160 possible to override fUnsigned=True by prefixing the value with '+' or '-'. 137 161 """ 138 def __init__(self, sName, fUnsigned = True):162 def __init__(self, sName, acbSizes = None, fUnsigned = True): 139 163 self.sName = sName; 164 self.acbSizes = [1, 2, 4, 8, 16, 32] if acbSizes is None else acbSizes; # Normal sizes. 140 165 self.fUnsigned = fUnsigned; 141 166 … … 143 168 """ Bad value exception. """ 144 169 def __init__(self, sMessage): 145 Exception.__init__(s Message);170 Exception.__init__(self, sMessage); 146 171 self.sMessage = sMessage; 147 172 148 173 def get(self, sValue): 149 174 """ 150 Get the shortest byte representation of oValue. 151 152 Returns (fSignExtend, bytearray) 175 Get the shortest normal sized byte representation of oValue. 176 177 Returns ((fSignExtend, bytearray), ) or ((fSignExtend, bytearray), (fSignExtend, bytearray), ). 178 The latter form is for AND+OR pairs where the first entry is what to 179 AND with the field and the second the one or OR with. 180 153 181 Raises BadValue if invalid value. 154 155 The returned byte array is a reasonable size, e.g. for an integer type156 it's for instance 1, 2, 4, or 8 byte in size but never 3, 5 or 7 bytes.157 182 """ 158 183 if len(sValue) == 0: … … 163 188 if sValue[0] == '-' or sValue[0] == '+': 164 189 fSignExtend = True; 165 fHex = len(sValue) > 3 and sValue[1: 2].lower() == '0x';190 fHex = len(sValue) > 3 and sValue[1:3].lower() == '0x'; 166 191 else: 167 192 fHex = len(sValue) > 2 and sValue[0:2].lower() == '0x'; … … 170 195 try: 171 196 iValue = long(sValue, 16 if fHex else 10); 172 except :173 raise TestType.BadValue('failed to convert "%s" to integer ' % (iValue,));197 except Exception as oXcpt: 198 raise TestType.BadValue('failed to convert "%s" to integer (%s)' % (sValue, oXcpt)); 174 199 175 200 # Convert the hex string and pad it to a decent value. 176 sHex = hex(iValue); 201 if iValue >= 0: 202 sHex = hex(iValue); 203 else: 204 sHex = hex(iValue); 177 205 assert sHex[:2] == '0x', sHex; 178 206 if sys.version_info[0] >= 3: … … 183 211 184 212 cDigits = len(sHex); 185 if cDigits <= 2: 186 cDigits = (cDigits + 1) & ~1; 187 elif cDigits <= 4: 188 cDigits = (cDigits + 3) & ~3; 189 elif cDigits <= 8: 190 cDigits = (cDigits + 7) & ~7; 213 if cDigits <= self.acbSizes[-1] * 2: 214 for cb in self.acbSizes: 215 if cDigits <= cb * 2: 216 cDigits = int((cDigits + cb - 1) / cb) * cb; # Seems like integer division returns a float in python. 217 break; 191 218 else: 192 cDigits = (cDigits + 15) & ~15; 219 cDigits = int((cDigits + self.acbSizes[-1] - 1) / self.acbSizes[-1]) * self.acbSizes[-1]; 220 assert isinstance(cDigits, int) 193 221 194 222 if cDigits != len(sHex): 223 cNeeded = cDigits - len(sHex); 195 224 if iValue >= 0: 196 sHex = '0' * (cDigits - len(sHex)) + sHex;225 sHex = ('0' * cNeeded) + sHex; 197 226 else: 198 sHex = 'f' * (cDigits - len(sHex)) + sHex;227 sHex = ('f' * cNeeded) + sHex; 199 228 200 229 # Invert and convert to bytearray and return it. 201 230 abValue = bytearray([int(sHex[offHex - 2 : offHex], 16) for offHex in range(len(sHex), 0, -2)]); 202 231 203 return ( fSignExtend, abValue);232 return ((fSignExtend, abValue),); 204 233 205 234 def validate(self, sValue): … … 213 242 return True; 214 243 244 def isAndOrPair(self, sValue): 245 """ 246 Checks if sValue is a pair. 247 """ 248 return False; 215 249 216 250 … … 220 254 """ 221 255 256 kdZeroValueFlags = { 'nv': 0, 'pl': 0, 'nz': 0, 'na': 0, 'pe': 0, 'nc': 0, 'di': 0, 'up': 0 }; 257 222 258 def __init__(self, sName): 223 TestType.__init__(self, sName, fUnsigned = True);259 TestType.__init__(self, sName, acbSizes = [1, 2, 4, 8], fUnsigned = True); 224 260 225 261 def get(self, sValue): 226 227 return None; 262 print('get(%s)' % (sValue,)); 263 fClear = 0; 264 fSet = 0; 265 for sFlag in sValue.split(','): 266 sConstant = SimpleParser.kdEFlags.get(sFlag, None); 267 if sConstant is None: 268 print('get(%s) raise for %s/%s' % (sValue, sFlag,sConstant)); 269 raise self.BadValue('Unknown flag "%s" in "%s"' % (sFlag, sValue)) 270 if sConstant[0] == '!': 271 fClear |= g_kdX86EFlagsConstants[sConstant[1:]]; 272 else: 273 fSet |= g_kdX86EFlagsConstants[sConstant]; 274 275 print('get -> TestType.get'); 276 aoSet = TestType.get(self, '0x%x' % (fSet,)); 277 print('get: aoSet=%s' % (aoSet,)); 278 if fClear != 0: 279 print('get -> TestType.get(%#x)' % (~fClear)); 280 try: 281 aoClear = TestType.get(self, '%#x' % (~fClear)) 282 except Exception as oXcpt: 283 print( '%s' % (oXcpt,)) 284 raise; 285 print('get: aoClear=%s' % (aoSet,)); 286 assert self.isAndOrPair(sValue) == True; 287 return (aoClear[0], aoSet[0]); 288 assert self.isAndOrPair(sValue) == False; 289 return aoSet; 290 291 def isAndOrPair(self, sValue): 292 for sZeroFlag in self.kdZeroValueFlags.keys(): 293 if sValue.find(sZeroFlag) >= 0: 294 print('isAndOrPair(%s) -> True' % (sValue,)); 295 return True; 296 print('isAndOrPair(%s) -> False' % (sValue,)); 297 return False; 228 298 229 299 … … 427 497 assert sVariable in self.kdVariables; 428 498 assert sOp in self.kasCompareOps; 429 assert sValue in self.kdVariables[sVa lue];499 assert sValue in self.kdVariables[sVariable]; 430 500 self.sVariable = sVariable; 431 501 self.sOp = sOp; … … 1514 1584 oValid = TestInOut.kdTypes[sType].validate(sValue); 1515 1585 if oValid is True: 1516 oItem = TestInOut(sField, sOp, sValue, sType); 1586 if not TestInOut.kdTypes[sType].isAndOrPair(sValue) or sOp == '!=': 1587 oItem = TestInOut(sField, sOp, sValue, sType); 1588 else: 1589 self.errorComment(iTagLine, 1590 '%s: and-or value "%s" can only be used with the "="' 1591 % ( sTag, sDesc, sValue, sItem, sType, )); 1517 1592 else: 1518 1593 self.errorComment(iTagLine, '%s: invalid %s value "%s" in "%s" (type: %s)' … … 1533 1608 aoDst.append(oItem); 1534 1609 else: 1535 fRc = self.errorComment(iTagLine, '%s: failed to parse selector: %s' % ( sTag, sItem,));1610 fRc = self.errorComment(iTagLine, '%s: failed to parse assignment: %s' % ( sTag, sItem,)); 1536 1611 1537 1612 # … … 1694 1769 1695 1770 # 1771 # Process the final tag. 1772 # 1773 if sCurTag in self.dTagHandlers: 1774 self.dTagHandlers[sCurTag](sCurTag, aasSections, iCurTagLine, iLine); 1775 cOpTags += 1; 1776 elif sCurTag.startswith('@op'): 1777 self.errorComment(iCurTagLine, 'Unknown tag: %s' % (sCurTag)); 1778 elif sCurTag == '@default': 1779 sFlatDefault = self.flattenAllSections(aasSections); 1780 1781 # 1696 1782 # Don't allow default text in blocks containing @op*. 1697 1783 #
Note:
See TracChangeset
for help on using the changeset viewer.