5 This is header file for x86_64 is broken in current versions
6 of klibc, so we temporarily comment it out.
10 #include "v86_x86emu.h"
19 void printk(const char *fmt
, ...)
22 va_start(argptr
, fmt
);
23 vsyslog(LOG_INFO
, fmt
, argptr
);
30 wrw(((u32
) X86_SS
<< 4) + X86_SP
, val
);
33 static void x86emu_do_int(int num
)
38 eflags
= eflags
| X86_IF_MASK
;
40 /* Return address and flags */
44 X86_EFLAGS
= X86_EFLAGS
& ~(X86_VIF_MASK
| X86_TF_MASK
);
46 X86_CS
= rdw((num
<< 2) + 2);
47 X86_IP
= rdw((num
<< 2));
52 X86EMU_intrFuncs intFuncs
[256];
53 X86EMU_pioFuncs pioFuncs
= {
65 stack
= v86_mem_alloc(DEFAULT_STACK_SIZE
);
66 X86_SS
= (u32
)stack
>> 4;
69 halt
= v86_mem_alloc(0x100);
72 /* Setup x86emu I/O functions */
73 X86EMU_setupPioFuncs(&pioFuncs
);
75 /* Setup interrupt handlers */
76 for (i
= 0; i
< 256; i
++) {
77 intFuncs
[i
] = x86emu_do_int
;
79 X86EMU_setupIntrFuncs(intFuncs
);
81 /* Set the default flags */
82 X86_EFLAGS
= X86_IF_MASK
| X86_IOPL_MASK
;
84 /* M is a macro poiting to the global virtual machine state
87 M
.mem_size
= 0x100000;
100 void rconv_v86_to_x86emu(struct v86_regs
*rs
)
110 X86_EFLAGS
= rs
->eflags
;
119 void rconv_x86emu_to_v86(struct v86_regs
*rd
)
129 rd
->eflags
= X86_EFLAGS
;
139 * Perform a simulated interrupt call.
141 int v86_int(int num
, struct v86_regs
*regs
)
143 rconv_v86_to_x86emu(regs
);
146 X86_CS
= get_int_seg(num
);
147 X86_EIP
= get_int_off(num
);
148 X86_SS
= (u32
)stack
>> 4;
150 X86_EFLAGS
= DEFAULT_V86_FLAGS
| X86_IF_MASK
;
151 X86_EFLAGS
&= ~(X86_VIF_MASK
| X86_TF_MASK
| X86_IF_MASK
| X86_NT_MASK
);
153 pushw(DEFAULT_V86_FLAGS
);
154 pushw(((u32
)halt
>> 4));
159 rconv_x86emu_to_v86(regs
);