This source file includes following definitions.
- clr_vif
- set_vif
- set_vflags
- get_vflags
- set_vflags_short
- get_vflags_short
1
2
3
4 #undef VM86_USE_VIF
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 #define SETFLAGS(targ, new, newmask) (targ) = ((targ) & ~(newmask)) | ((new) & (newmask))
43
44 #define VM86_TYPE(x) ((x) & 0xff)
45 #define VM86_ARG(x) (((x) & 0xff00) >> 8)
46 #define VM86_MAKEVAL(type,arg) ((type) | (((arg) & 0xff) << 8))
47 #define VM86_STI 0
48 #define VM86_INTx 1
49 #define VM86_SIGNAL 2
50 #define VM86_UNKNOWN 3
51
52 #define VM86_REALFLAGS (~PSL_USERSTATIC)
53 #define VM86_VIRTFLAGS (PSL_USERSTATIC & ~(PSL_MBO | PSL_MBZ))
54
55 struct vm86_regs {
56 struct sigcontext vmsc;
57 };
58
59 struct vm86_kern {
60 struct vm86_regs regs;
61 unsigned long ss_cpu_type;
62 };
63 #define cpu_type substr.ss_cpu_type
64
65
66
67
68 struct vm86_struct {
69 struct vm86_kern substr;
70 unsigned long screen_bitmap;
71 unsigned long flags;
72 unsigned char int_byuser[32];
73 unsigned char int21_byuser[32];
74 };
75
76 #define VCPU_086 0
77 #define VCPU_186 1
78 #define VCPU_286 2
79 #define VCPU_386 3
80 #define VCPU_486 4
81 #define VCPU_586 5
82
83 #ifdef _KERNEL
84 int i386_vm86(struct proc *, char *, register_t *);
85 void vm86_gpfault(struct proc *, int);
86 void vm86_return(struct proc *, int);
87 static __inline void clr_vif(struct proc *);
88 static __inline void set_vif(struct proc *);
89 static __inline void set_vflags(struct proc *, int);
90 static __inline int get_vflags(struct proc *);
91 static __inline void set_vflags_short(struct proc *, int);
92 static __inline int get_vflags_short(struct proc *);
93
94 static __inline void
95 clr_vif(p)
96 struct proc *p;
97 {
98 struct pcb *pcb = &p->p_addr->u_pcb;
99
100 #ifndef VM86_USE_VIF
101 pcb->vm86_eflags &= ~PSL_I;
102 #else
103 pcb->vm86_eflags &= ~PSL_VIF;
104 #endif
105 }
106
107 static __inline void
108 set_vif(p)
109 struct proc *p;
110 {
111 struct pcb *pcb = &p->p_addr->u_pcb;
112
113 #ifndef VM86_USE_VIF
114 pcb->vm86_eflags |= PSL_I;
115 if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
116 #else
117 pcb->vm86_eflags |= PSL_VIF;
118 if ((pcb->vm86_eflags & (PSL_VIF|PSL_VIP)) == (PSL_VIF|PSL_VIP))
119 #endif
120 vm86_return(p, VM86_STI);
121 }
122
123 static __inline void
124 set_vflags(p, flags)
125 struct proc *p;
126 int flags;
127 {
128 struct trapframe *tf = p->p_md.md_regs;
129 struct pcb *pcb = &p->p_addr->u_pcb;
130
131 flags &= ~pcb->vm86_flagmask;
132 SETFLAGS(pcb->vm86_eflags, flags, VM86_VIRTFLAGS);
133 SETFLAGS(tf->tf_eflags, flags, VM86_REALFLAGS);
134 #ifndef VM86_USE_VIF
135 if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
136 #else
137 if ((pcb->vm86_eflags & (PSL_VIF|PSL_VIP)) == (PSL_VIF|PSL_VIP))
138 #endif
139 vm86_return(p, VM86_STI);
140 }
141
142 static __inline int
143 get_vflags(p)
144 struct proc *p;
145 {
146 struct trapframe *tf = p->p_md.md_regs;
147 struct pcb *pcb = &p->p_addr->u_pcb;
148 int flags = PSL_MBO;
149
150 SETFLAGS(flags, pcb->vm86_eflags, VM86_VIRTFLAGS);
151 SETFLAGS(flags, tf->tf_eflags, VM86_REALFLAGS);
152 return (flags);
153 }
154
155 static __inline void
156 set_vflags_short(p, flags)
157 struct proc *p;
158 int flags;
159 {
160 struct trapframe *tf = p->p_md.md_regs;
161 struct pcb *pcb = &p->p_addr->u_pcb;
162
163 flags &= ~pcb->vm86_flagmask;
164 SETFLAGS(pcb->vm86_eflags, flags, VM86_VIRTFLAGS & 0xffff);
165 SETFLAGS(tf->tf_eflags, flags, VM86_REALFLAGS & 0xffff);
166 #ifndef VM86_USE_VIF
167 if ((pcb->vm86_eflags & (PSL_I|PSL_VIP)) == (PSL_I|PSL_VIP))
168 vm86_return(p, VM86_STI);
169 #endif
170 }
171
172 static __inline int
173 get_vflags_short(p)
174 struct proc *p;
175 {
176 struct trapframe *tf = p->p_md.md_regs;
177 struct pcb *pcb = &p->p_addr->u_pcb;
178 int flags = PSL_MBO;
179
180 SETFLAGS(flags, pcb->vm86_eflags, VM86_VIRTFLAGS & 0xffff);
181 SETFLAGS(flags, tf->tf_eflags, VM86_REALFLAGS & 0xffff);
182 return (flags);
183 }
184 #else
185 int i386_vm86(struct vm86_struct *vmcp);
186 #endif