X86: Implement an wrdh microop which loads bases/offsets from 16 byte descriptors.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 13 Oct 2008 05:16:53 +0000 (22:16 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 13 Oct 2008 05:16:53 +0000 (22:16 -0700)
src/arch/x86/isa/microops/regop.isa

index ba996060c79b808363022c47efe5a96db4e2b573..d7d1e3063ab1a4aba5eae2872d3eefeaafa6f0d0 100644 (file)
@@ -236,6 +236,15 @@ output header {{
       SegNoCheck, SegCSCheck, SegCallGateCheck, SegIntGateCheck,
       SegSSCheck, SegIretCheck, SegIntCSCheck
     };
+
+    enum LongModeDescriptorType {
+        LDT64 = 2,
+        AvailableTSS64 = 9,
+        BusyTSS64 = 0xb,
+        CallGate64 = 0xc,
+        IntGate64 = 0xe,
+        TrapGate64 = 0xf
+    };
 }};
 
 output decoder {{
@@ -1098,7 +1107,26 @@ let {{
 
     class Wrdh(RegOp):
         code = '''
+            SegDescriptor desc = SrcReg1;
 
+            uint64_t target = bits(SrcReg2, 31, 0) << 32;
+            switch(desc.type) {
+              case LDT64:
+              case AvailableTSS64:
+              case BusyTSS64:
+                replaceBits(target, 23, 0, desc.baseLow);
+                replaceBits(target, 31, 24, desc.baseHigh);
+                break;
+              case CallGate64:
+              case IntGate64:
+              case TrapGate64:
+                replaceBits(target, 15, 0, bits(desc, 15, 0));
+                replaceBits(target, 31, 16, bits(desc, 63, 48));
+                break;
+              default:
+                panic("Wrdh used with wrong descriptor type!\\n");
+            }
+            DestReg = target;
         '''
 
     class Wrtsc(WrRegOp):