xref: /freebsd/sys/i386/include/vm86.h (revision 0de89efe5c443f213c7ea28773ef2dc6cf3af2ed)
1 /*-
2  * Copyright (c) 1997 Jonathan Lemon
3  * All rights reserved.
4  *
5  * Derived from register.h, which is
6  *     Copyright (c) 1996 Michael Smith.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *	$Id: vm86.h,v 1.2 1997/08/20 19:57:24 jlemon Exp $
30  */
31 
32 #ifndef _MACHINE_VM86_H_
33 #define _MACHINE_VM86_H_ 1
34 
35 struct vm86_kernel {
36 	caddr_t	vm86_intmap;			/* interrupt map */
37         u_long	vm86_eflags;			/* emulated flags */
38 	int	vm86_has_vme;			/* VME support */
39 	int	vm86_inited;			/* we were initialized */
40 	int	vm86_debug;
41 };
42 
43 struct i386_vm86_args {
44 	int	sub_op;			/* sub-operation to perform */
45 	char 	*sub_args;		/* args */
46 };
47 
48 #define VM86_INIT	1
49 #define VM86_SET_VME	2
50 #define VM86_GET_VME	3
51 
52 struct vm86_init_args {
53         int     debug;                  /* debug flag */
54         int     cpu_type;               /* cpu type to emulate */
55         u_char  int_map[32];            /* interrupt map */
56 };
57 
58 struct vm86_vme_args {
59 	int	state;			/* status */
60 };
61 
62 /* standard register representation */
63 typedef union {
64 	u_long	r_ex;
65 	struct {
66 		u_short	r_x;
67 		u_short	:16;
68 	} r_w;
69 	struct {
70 		u_char	r_l;
71 		u_char	r_h;
72 		u_short	:16;
73 	} r_b;
74 } reg86_t;
75 
76 /* layout must match definition of struct trapframe_vm86 in <machine/frame.h> */
77 
78 struct vm86frame {
79 	int	:32;			/* kernel ES */
80 	int	:32;			/* kernel DS */
81 	reg86_t	edi;
82 	reg86_t	esi;
83 	reg86_t	ebp;
84 	reg86_t	isp;
85 	reg86_t	ebx;
86 	reg86_t	edx;
87 	reg86_t	ecx;
88 	reg86_t	eax;
89 	int	:32;			/* trapno */
90 	int	:32;			/* err */
91 	reg86_t	eip;
92 	reg86_t	cs;
93 	reg86_t	eflags;
94 	reg86_t	esp;
95 	reg86_t	ss;
96 	reg86_t	es;
97 	reg86_t	ds;
98 	reg86_t	fs;
99 	reg86_t	gs;
100 #define vmf_cs		cs.r_w.r_x
101 #define vmf_ss		ss.r_w.r_x
102 #define vmf_sp		esp.r_w.r_x
103 #define vmf_ip		eip.r_w.r_x
104 #define vmf_flags	eflags.r_w.r_x
105 #define vmf_eflags	eflags.r_ex
106 };
107 
108 struct proc;
109 extern	int vm86_emulate __P((struct vm86frame *));
110 extern	int vm86_sysarch __P((struct proc *, char *, int *));
111 
112 #endif /* _MACHINE_VM86_H_ */
113