View Javadoc

1   // jq_RegisterState.java, created Mon Feb  5 23:23:21 2001 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Scheduler;
5   
6   import joeq.Assembler.x86.x86Constants;
7   import joeq.Class.jq_DontAlign;
8   import joeq.Memory.CodeAddress;
9   import joeq.Memory.StackAddress;
10  
11  /*
12   * @author  John Whaley <jwhaley@alum.mit.edu>
13   * @version $Id: jq_x86RegisterState.java 1470 2004-03-10 23:30:51Z jwhaley $
14   */
15  public class jq_x86RegisterState extends jq_RegisterState implements x86Constants, jq_DontAlign {
16  
17      // WARNING: the layout of this object should match the CONTEXT data structure
18      // used in GetThreadContext/SetThreadContext.  see "winnt.h".
19  
20      // Used as a param in GetThreadContext/SetThreadContext
21      int ContextFlags;
22      // debug registers
23      int Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
24      // floating point
25      int ControlWord, StatusWord, TagWord, ErrorOffset, ErrorSelector, DataOffset, DataSelector;
26      long fp0_L; short fp0_H;  // fp are 80 bits, so it is split across two fields.
27      long fp1_L; short fp1_H;
28      long fp2_L; short fp2_H;
29      long fp3_L; short fp3_H;
30      long fp4_L; short fp4_H;
31      long fp5_L; short fp5_H;
32      long fp6_L; short fp6_H;
33      long fp7_L; short fp7_H;
34      int Cr0NpxState;
35      // segment registers
36      int SegGs, SegFs, SegEs, SegDs;
37      // integer registers
38      int Edi, Esi, Ebx, Edx, Ecx, Eax;
39      // control registers
40      StackAddress Ebp;
41      CodeAddress Eip;
42      int SegCs, EFlags;
43      StackAddress Esp;
44      int SegSs;
45  
46      public static final int EFLAGS_CARRY      = 0x00000001;
47      public static final int EFLAGS_PARITY     = 0x00000004;
48      public static final int EFLAGS_AUXCARRY   = 0x00000010;
49      public static final int EFLAGS_ZERO       = 0x00000040;
50      public static final int EFLAGS_SIGN       = 0x00000080;
51      public static final int EFLAGS_TRAP       = 0x00000100;
52      public static final int EFLAGS_INTERRUPT  = 0x00000200;
53      public static final int EFLAGS_DIRECTION  = 0x00000400;
54      public static final int EFLAGS_OVERFLOW   = 0x00000800;
55      public static final int EFLAGS_NESTEDTASK = 0x00004000;
56  
57      public static final int EFLAGS_IOPRIV_MASK = 0x00003000;
58      public static final int EFLAGS_IOPRIV_SHIFT = 12;
59  
60      public jq_x86RegisterState() {
61          ControlWord = 0x027f;
62          StatusWord = 0x4000;
63          TagWord = 0xffff;
64      }
65  
66      public StackAddress getEbp() {
67          return Ebp;
68      }
69  
70      public StackAddress getEsp() {
71          return Esp;
72      }
73  
74      public CodeAddress getEip() {
75          return Eip;
76      }
77      
78      public void setEbp(StackAddress a) {
79          Ebp = a;
80      }
81  
82      public void setEip(CodeAddress a) {
83          Eip = a;
84      }
85  
86      public void setEsp(StackAddress a) {
87          Esp = a;
88      }
89  
90      public void setControlWord(int x) {
91          ControlWord = x;
92      }
93  
94      public void setStatusWord(int x) {
95          StatusWord = x;
96      }
97  
98      public void setTagWord(int x) {
99          TagWord = x;
100     }
101 
102     public void setContextFlags(int x) {
103         ContextFlags = x;
104     }
105     
106     static {
107         initFactory();
108     }
109     
110     public static void initFactory() {
111         // Set jq_x86RegisterState as the default type of register state,
112         //  if there is no default yet.
113         if (factory == null) {
114             factory = new Factory() {
115                 public jq_RegisterState create() {
116                     return new jq_x86RegisterState();
117                 }
118             };
119         }
120     }
121     
122 }