5 #include "v86_x86emu.h"
14 void printk(const char *fmt
, ...)
17 va_start(argptr
, fmt
);
18 vsyslog(LOG_INFO
, fmt
, argptr
);
25 wrw(((u32
) X86_SS
<< 4) + X86_SP
, val
);
28 static void x86emu_do_int(int num
)
33 eflags
= eflags
| X86_IF_MASK
;
35 /* Return address and flags */
39 X86_EFLAGS
= X86_EFLAGS
& ~(X86_VIF_MASK
| X86_TF_MASK
);
41 X86_CS
= rdw((num
<< 2) + 2);
42 X86_IP
= rdw((num
<< 2));
47 X86EMU_intrFuncs intFuncs
[256];
48 X86EMU_pioFuncs pioFuncs
= {
60 stack
= v86_mem_alloc(DEFAULT_STACK_SIZE
);
61 X86_SS
= (u32
)stack
>> 4;
64 halt
= v86_mem_alloc(0x100);
67 /* Setup x86emu I/O functions */
68 X86EMU_setupPioFuncs(&pioFuncs
);
70 /* Setup interrupt handlers */
71 for (i
= 0; i
< 256; i
++) {
72 intFuncs
[i
] = x86emu_do_int
;
74 X86EMU_setupIntrFuncs(intFuncs
);
76 /* Set the default flags */
77 X86_EFLAGS
= X86_IF_MASK
| X86_IOPL_MASK
;
79 /* M is a macro poiting to the global virtual machine state
82 M
.mem_size
= 0x100000;
95 void rconv_vm86_to_x86emu(struct vm86_regs
*rs
)
105 X86_EFLAGS
= rs
->eflags
;
114 void rconv_x86emu_to_vm86(struct vm86_regs
*rd
)
124 rd
->eflags
= X86_EFLAGS
;
134 * Perform a simulated interrupt call.
136 int v86_int(int num
, struct vm86_regs
*regs
)
140 rconv_vm86_to_x86emu(regs
);
143 X86_CS
= get_int_seg(num
);
144 X86_EIP
= get_int_off(num
);
145 X86_SS
= (u32
)stack
>> 4;
147 X86_EFLAGS
= DEFAULT_V86_FLAGS
| X86_IF_MASK
;
148 X86_EFLAGS
&= ~(X86_VIF_MASK
| X86_TF_MASK
| X86_IF_MASK
| X86_NT_MASK
);
150 pushw(DEFAULT_V86_FLAGS
);
151 pushw(((u32
)halt
>> 4));
156 rconv_x86emu_to_vm86(regs
);