MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm86_emulate

Function vm86_emulate

freebsd/i386/i386/vm86.c:181–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181int
182vm86_emulate(struct vm86frame *vmf)
183{
184 struct vm86_kernel *vm86;
185 caddr_t addr;
186 u_char i_byte;
187 u_int temp_flags;
188 int inc_ip = 1;
189 int retcode = 0;
190
191 /*
192 * pcb_ext contains the address of the extension area, or zero if
193 * the extension is not present. (This check should not be needed,
194 * as we can't enter vm86 mode until we set up an extension area)
195 */
196 if (curpcb->pcb_ext == 0)
197 return (SIGBUS);
198 vm86 = &curpcb->pcb_ext->ext_vm86;
199
200 if (vmf->vmf_eflags & PSL_T)
201 retcode = SIGTRAP;
202
203 addr = MAKE_ADDR(vmf->vmf_cs, vmf->vmf_ip);
204 i_byte = vm86_fubyte(addr);
205 if (i_byte == ADDRESS_SIZE_PREFIX) {
206 i_byte = vm86_fubyte(++addr);
207 inc_ip++;
208 }
209
210 if (vm86->vm86_has_vme) {
211 switch (i_byte) {
212 case OPERAND_SIZE_PREFIX:
213 i_byte = vm86_fubyte(++addr);
214 inc_ip++;
215 switch (i_byte) {
216 case PUSHF:
217 if (vmf->vmf_eflags & PSL_VIF)
218 PUSHL((vmf->vmf_eflags & PUSH_MASK)
219 | PSL_IOPL | PSL_I, vmf);
220 else
221 PUSHL((vmf->vmf_eflags & PUSH_MASK)
222 | PSL_IOPL, vmf);
223 vmf->vmf_ip += inc_ip;
224 return (retcode);
225
226 case POPF:
227 temp_flags = POPL(vmf) & POP_MASK;
228 vmf->vmf_eflags = (vmf->vmf_eflags & ~POP_MASK)
229 | temp_flags | PSL_VM | PSL_I;
230 vmf->vmf_ip += inc_ip;
231 if (temp_flags & PSL_I) {
232 vmf->vmf_eflags |= PSL_VIF;
233 if (vmf->vmf_eflags & PSL_VIP)
234 break;
235 } else {
236 vmf->vmf_eflags &= ~PSL_VIF;
237 }
238 return (retcode);

Callers 1

trapFunction · 0.85

Calls 9

MAKE_ADDRFunction · 0.85
vm86_fubyteFunction · 0.85
PUSHLFunction · 0.85
POPLFunction · 0.85
uprintfFunction · 0.85
POPFunction · 0.85
PUSHFunction · 0.85
GET_VECFunction · 0.85
vm86_fuwordFunction · 0.85

Tested by

no test coverage detected