xref: /freebsd/lib/libsys/i386/i386_vm86.2 (revision 96190b4fef3b4a0cc3ca0606b0c4e3e69a5e6717)
1.\" Copyright (c) 1998 Jonathan Lemon
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd July 27, 1998
26.Dt I386_VM86 2
27.Os
28.Sh NAME
29.Nm i386_vm86
30.Nd control vm86-related functions
31.Sh LIBRARY
32.Lb libc
33.Sh SYNOPSIS
34.In sys/types.h
35.In machine/sysarch.h
36.In machine/vm86.h
37.Ft int
38.Fn i386_vm86 "int function" "void *data"
39.Sh DESCRIPTION
40The
41.Fn i386_vm86
42system call
43is used to call various vm86 related functions.
44The
45.Fa function
46argument
47can be one of the following values:
48.Bl -tag -offset indent -width VM86_SET_VME
49.It Dv VM86_INIT
50This will initialize the kernel's vm86 parameter area for the
51process, and permit the process to make vm86 calls.
52The
53.Fa data
54argument
55points to the following structure:
56.Bd -literal
57struct vm86_init_args {
58        int     debug;
59        int     cpu_type;
60        u_char  int_map[32];
61};
62.Ed
63.Pp
64The
65.Fa debug
66argument
67is used to turn on debugging code.
68The
69.Fa cpu_type
70argument
71controls the type of CPU being emulated, and is currently unimplemented.
72The
73.Fa int_map
74argument
75is a bitmap which determines whether vm86 interrupts should be handled
76in vm86 mode, or reflected back to the process.
77If the
78.Em Nth
79bit is set, the interrupt will be reflected to the process, otherwise
80it will be dispatched by the vm86 interrupt table.
81.It Dv VM86_INTCALL
82This allows calls to be made to vm86 interrupt handlers by the process.
83It effectively simulates an INT instruction.
84.Fa data
85should point to the following structure:
86.Bd -literal
87struct vm86_intcall_args {
88	int	intnum;
89	struct	vm86frame vmf;
90};
91.Ed
92.Pp
93.Fa intnum
94specifies the operand of INT for the simulated call.
95A value of 0x10, for example, would often be used to call into the VGA BIOS.
96.Fa vmf
97is used to initialize CPU registers according to the calling convention for
98the interrupt handler.
99.It Dv VM86_GET_VME
100This is used to retrieve the current state of the Pentium(r) processor's
101VME (Virtual-8086 Mode Extensions) flag, which is bit 0 of CR4.
102.Fa data
103should be initialized to point to the following:
104.Bd -literal
105struct vm86_vme_args {
106	int	state;			/* status */
107};
108.Ed
109.Pp
110.Fa state
111will contain the state of the VME flag on return.
112.\" .It Dv VM86_SET_VME
113.El
114.Pp
115vm86 mode is entered by calling
116.Xr sigreturn 2
117with the correct machine context for vm86, and with the
118.Dv PSL_VM
119bit set.
120Control returns to the process upon delivery of a signal.
121.Sh RETURN VALUES
122.Rv -std i386_vm86
123.Sh ERRORS
124The
125.Fn i386_vm86
126system call
127will fail if:
128.Bl -tag -width Er
129.It Bq Er EINVAL
130The kernel does not have vm86 support, or an invalid function was specified.
131.It Bq Er ENOMEM
132There is not enough memory to initialize the kernel data structures.
133.El
134.Sh AUTHORS
135.An -nosplit
136This man page was written by
137.An Jonathan Lemon ,
138and updated by
139.An Bruce M Simpson .
140