1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
4 .\" Copyright 1997 Andries E. Brouwer (aeb@cwi.nl)
5 .\" Copyright 2009 Samuel Bronson <naesten@gmail.com>
7 .\" Permission is granted to make and distribute verbatim copies of this
8 .\" manual provided the copyright notice and this permission notice are
9 .\" preserved on all copies.
11 .\" Permission is granted to copy and distribute modified versions of this
12 .\" manual under the conditions for verbatim copying, provided that the
13 .\" entire resulting derived work is distributed under the terms of a
14 .\" permission notice identical to this one.
16 .\" Since the Linux kernel and libraries are constantly changing, this
17 .\" manual page may be incorrect or out-of-date. The author(s) assume no
18 .\" responsibility for errors or omissions, or for damages resulting from
19 .\" the use of the information contained herein. The author(s) may not
20 .\" have taken the same level of care in the production of this manual,
21 .\" which is licensed free of charge, as they might when working
24 .\" Formatted or processed versions of this manual, if unaccompanied by
25 .\" the source, must acknowledge the copyright and authors of this work.
27 .TH VM86 2 2009-05-07 "Linux" "Linux Programmer's Manual"
29 vm86old, vm86 \- enter virtual 8086 mode
31 .B #include <sys/vm86.h>
33 .BI "int vm86old(struct vm86_struct *" info );
35 .BI "int vm86(unsigned long " fn ", struct vm86plus_struct *" v86 );
37 These calls cause the process to enter VM86 mode (virtual-8086 in Intel
38 literature), and are used by
41 VM86 mode is an emulation of real mode within a protected mode task.
44 performs one of the following operations based on the function code given in
46 .SS Checking Availability
48 .B VM86_PLUS_INSTALL_CHECK
49 For testing if the new
53 If the architecture is wrong or
55 was left out of the kernel to save a few k, returns \-1 and sets errno
58 .\" Comments in the source describe using VM86_PLUS_INSTALL_CHECK
59 .\" also to make sure that it's the *new* vm86 that got called, but
60 .\" that hardly seems relevant today
63 .\" The information in this section was gleaned from a combination of
64 .\" * The kernel sources
65 .\" * An email from Bart Oldeman
66 .\" http://sourceforge.net/mailarchive/message.php?msg_name=c3d607cc0905011152o384ee165t986a96c56b7c868c%40mail.gmail.com
67 .\" (at least one other email in this thread was used for other
68 .\" portions of what I've added to this page)
70 .\" src/arch/linux/async/signal.c
71 .\" which Bart pointed me to in the above email
74 .BR VM86_REQUEST_IRQ ", " VM86_FREE_IRQ ", "
75 .BR VM86_GET_IRQ_BITS ", and " VM86_GET_AND_RESET_IRQ
76 are used to intercept real hardware IRQs from interrupt vectors 3
78 They treat the second argument to
81 the rest of this subsection will act as if it were declared as
82 .BI "unsigned\ long\ " irqnumber \fR.
86 function code requires the
89 (superuser for Linux versions before the introduction of
90 capabilities in 2.1.100);
91 since none of the other function codes actually do anything without
92 being preceded by a successful
93 .BR VM86_REQUEST_IRQ ,
94 this effectively limits the entire facility to programs running with
97 This facility actually has little to do with VM86 mode;
98 you can use it independantly to e.g. implement hardware drivers in
100 The main thing the two have in common is that
102 can use them both, which is probably why this facility included in this
103 system call rather than implemented as a seperate system call.
107 Arrange for hardware interrupt
109 to be delivered as signal
114 .IR irqnumber "\ =\ " sig "\ <<\ 8 +\ " irq .
124 or, if no signal should be generated for this IRQ, 0.
126 Upon receipt of this interrupt, the kernel will send the requested
127 signal (if any) to the requesting process and disable the interrupt
129 .B VM86_GET_AND_RESET_IRQ
131 The kernel may become displeased if the interrupt is not handled in a
136 End delivery of interrupt
138 to this process, and allow other processes to request it.
142 Returns a bitmap where 1 <<
146 has been recieved on behalf of, but not handled by,
147 a process that requested it with
148 .BR VM86_REQUEST_IRQ .
151 .B VM86_GET_AND_RESET_IRQ
154 since the last time either
156 or this function code was called on it
157 and, if so, clear it's bit in the bitmap returned by
158 .BR VM86_GET_IRQ_BITS
159 and re-enable the IRQ.
161 The above assumes that the calling process has requested the given
164 without having subsequently released it with
166 If this is not the case, this function code just returns 0.
168 .SS Entering VM86 mode
172 .B VM86_ENTER_NO_BYPASS
173 function codes are used to enter VM86 mode.
175 .I "struct\ vm86plus_struct"
176 both to control operation and to maintain the virtual machine's
178 This structure is defined as follows:
185 * normal regs, with special meaning for the segment descriptors..
200 unsigned short cs, __csh;
203 unsigned short ss, __ssh;
206 * these are specific to v86 mode:
208 unsigned short es, __esh;
209 unsigned short ds, __dsh;
210 unsigned short fs, __fsh;
211 unsigned short gs, __gsh;
214 struct revectored_struct {
215 unsigned long __map[8]; /* 256 bits */
218 struct vm86plus_info_struct {
219 unsigned long force_return_for_pic:1;
220 unsigned long vm86dbg_active:1; /* for debugger */
221 unsigned long vm86dbg_TFpendig:1; /* for debugger */
222 unsigned long unused:28;
223 unsigned long is_vm86pus:1; /* for vm86 internal use */
224 unsigned char vm86dbg_intxxtab[32]; /* for debugger */
226 struct vm86plus_struct {
227 struct vm86_regs regs;
229 unsigned long screen_bitmap;
230 unsigned long cpu_type;
231 struct revectored_struct int_revectored;
232 struct revectored_struct int21_revectored;
233 struct vm86plus_info_struct vm86plus;
240 structure holds the register values of the virtual machine.
242 .IR __null_ds ", " __null_es ", " __null_fs ", and " __null_gs
243 fields are generally zero, since the CPU clears these registers
244 (after saving them to the stack)
245 when leaving VM86 mode in order to allow the OS to safely save and
246 restore these registers in interrupt/exception handlers regardless of
247 whether the interrupted process was running in VM86 mode \(em it is not
248 safe to load arbitrary values into these registers in protected mode.
249 The real segment register values are kept in fields
250 .IR es ", " ds ", " fs ", and " gs .
251 The CS and SS segment registers, on the other hand, get pushed on the
252 kernel stack on exit from VM86 mode "before" being loaded with new
253 values from the IDT and TSS, respectively.
256 before, since the CPU needs to use the new SS to do the push, but it
257 is the old value that is pushed.)
258 Because valid protected-mode values for these registers are loaded by
260 .IR __null_cs " or " __null_ss
264 FIXME: Document more of the fields.
267 The return value of a successful
269 call consists of a type code, accessed using the macro
270 .BR VM86_TYPE "(\fIretval\fP),"
271 and an argument, accessed using the macro
272 .BR VM86_ARG "(\fIretval\fP)."
273 The type code is one of the following:
275 .BR "VM86_SIGNAL = 0" " (no argument)"
276 The process left VM86 mode because it recieved a signal.
278 .BR VM86_UNKNOWN " (no argument)"
279 There was a GP fault that the kernel did not not know how to handle.
280 .\" There is presumably no exception error code, since that is only
281 .\" relevent for GP faults when triggered by a bad segment selector
283 .BR VM86_INTx " (interrupt number)"
284 The VM encountered an INT instruction.
285 CS:IP points to the following instruction.
287 .BR VM86_STI " (no argument)"
288 An instruction (sti/popf/iret) enabled interrupts for the VM, and
289 the VIP (virtual interrupt pending) flag was set in EFLAGS.
290 (Neither the kernel nor the CPU set VIP directly, so this can only
291 happen if it is set by the application in the passed structure.
294 the kernel still does not actually use the VME extension in which VIP
295 is defined to implement this, though that shouldn't affect the behaviour.)
297 The return value of a successful
299 call depends on the function code:
301 .B VM86_PLUS_INSTALL_CHECK
307 except that the following additional return types are possible:
310 .BR VM86_PICRETURN " (no argument)"
311 The VM encountered a PUSHF, POPF, IRET, STI, or CLI instruction, and the
312 .I v86->vm86plus.force_return_for_pic
315 .BR VM86_TRAP " (exception number)"
316 The VM generated exception number 1 (DB \(en debug exception) or 3 (BP
321 On error, \-1 is returned, and
323 is set appropriately.
327 This return value is specific to i386 and indicates a problem with getting
331 This return value indicates the call is not implemented on the present
332 architecture (or that the kernel was built without support for it).
335 Saved kernel stack exists.
336 (This is a kernel sanity check; the saved
337 stack should only exist within vm86 mode itself.)
341 was introduced in Linux 0.97p2.
342 In Linux 2.1.15 and 2.0.28 it was renamed to
347 The definition of \fIstruct vm86_struct\fP was changed
350 This call is specific to Linux on 32-bit Intel processors,
351 and should not be used in programs intended to be portable.
353 .BR capabilities (7),
354 \fIIA-32 Intel\*[R] Architecture Software Developer's Manual\fP