1// Copyright (c) 2007-2008 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 --- 1016 unchanged lines hidden (view full) --- 1025 1026 class Chks(RegOp): 1027 def __init__(self, dest, src1, src2=0, 1028 flags=None, dataSize="env.dataSize"): 1029 super(Chks, self).__init__(dest, 1030 src1, src2, flags, dataSize) 1031 code = ''' 1032 // The selector is in source 1 and can be at most 16 bits. |
1033 SegSelector selector = DestReg; 1034 SegDescriptor desc = SrcReg1; 1035 HandyM5Reg m5reg = M5Reg; |
1036 1037 switch (imm8) 1038 { 1039 case SegNoCheck: 1040 break; 1041 case SegCSCheck: 1042 panic("CS checks for far calls/jumps not implemented.\\n"); 1043 break; 1044 case SegCallGateCheck: 1045 panic("CS checks for far calls/jumps through call gates" 1046 "not implemented.\\n"); 1047 break; 1048 case SegSSCheck: |
1049 if (selector.si || selector.ti) { 1050 if (!desc.p) { 1051 //FIXME This needs to also push the selector. 1052 return new StackFault; 1053 } 1054 } else { 1055 if ((m5reg.mode != SixtyFourBitMode || m5reg.cpl == 3) || 1056 !(desc.s == 1 && 1057 desc.type.codeOrData == 0 && desc.type.w) || 1058 (desc.dpl != m5reg.cpl) || 1059 (selector.rpl != m5reg.cpl)) { 1060 return new GeneralProtection(psrc1 & 0xFFFF); 1061 } 1062 } |
1063 break; 1064 case SegIretCheck: 1065 { |
1066 if ((!selector.si && !selector.ti) || 1067 (selector.rpl < m5reg.cpl) || 1068 !(desc.s == 1 && desc.type.codeOrData == 1) || 1069 (!desc.type.c && desc.dpl != selector.rpl) || 1070 (desc.type.c && desc.dpl > selector.rpl)) |
1071 return new GeneralProtection(psrc1 & 0xFFFF); |
1072 if (!desc.p) 1073 return new SegmentNotPresent; |
1074 break; 1075 } 1076 case SegIntCSCheck: 1077 panic("CS selector checks for interrupts and exceptions" 1078 "not implemented.\\n"); 1079 break; 1080 default: 1081 panic("Undefined segment check type.\\n"); 1082 } |
1083 ''' 1084 flag_code = ''' 1085 // Check for a NULL selector and set ZF,EZF appropriately. 1086 ccFlagBits = ccFlagBits & ~(ext & (ZFBit | EZFBit)); 1087 if (!selector.si && !selector.ti) 1088 ccFlagBits = ccFlagBits | (ext & (ZFBit | EZFBit)); 1089 ''' 1090 --- 15 unchanged lines hidden (view full) --- 1106 class Rdm5reg(RdRegOp): 1107 code = ''' 1108 DestReg = M5Reg; 1109 ''' 1110 1111 class Wrdl(RegOp): 1112 code = ''' 1113 SegDescriptor desc = SrcReg1; |
1114 SegSelector selector = SrcReg2; 1115 if (selector.si || selector.ti) { 1116 SegAttr attr = 0; 1117 attr.dpl = desc.dpl; 1118 attr.defaultSize = desc.d; 1119 if (!desc.s) { 1120 SegBaseDest = SegBaseDest; 1121 SegLimitDest = SegLimitDest; 1122 SegAttrDest = SegAttrDest; 1123 panic("System segment encountered.\\n"); 1124 } else { 1125 if (!desc.p) 1126 panic("Segment not present.\\n"); 1127 if (desc.type.codeOrData) { 1128 attr.readable = desc.type.r; 1129 attr.longMode = desc.l; 1130 } else { 1131 attr.expandDown = desc.type.e; 1132 attr.readable = 1; 1133 attr.writable = desc.type.w; 1134 } 1135 Addr base = desc.baseLow | (desc.baseHigh << 24); 1136 Addr limit = desc.limitLow | (desc.limitHigh << 16); 1137 if (desc.g) 1138 limit = (limit << 12) | mask(12); 1139 SegBaseDest = base; 1140 SegLimitDest = limit; 1141 SegAttrDest = attr; 1142 } 1143 } else { |
1144 SegBaseDest = SegBaseDest; 1145 SegLimitDest = SegLimitDest; 1146 SegAttrDest = SegAttrDest; |
1147 } 1148 ''' 1149}}; |