* better
[mascara-docs.git] / hw / i386.reference / s15_02.htm
blob532b145fa98a6826fa51106da79c6bb33e2f0b50
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <HTML>
3 <HEAD>
4 <TITLE>80386 Programmer's Reference Manual -- Section 15.2</TITLE>
5 </HEAD>
6 <BODY>
7 <B>up:</B> <A HREF="c15.htm">
8 Chapter 15 -- Virtual 8086 Mode</A><BR>
9 <B>prev:</B> <A HREF="s15_01.htm">15.1 Executing 8086 Code</A><BR>
10 <B>next:</B> <A HREF="s15_03.htm">15.3 Entering and Leaving V86 Mode</A>
11 <P>
12 <HR>
13 <P>
14 <H1>15.2 Structure of a V86 Task</H1>
15 A V86 task consists partly of the 8086 program to be executed and partly of
16 80386 "native mode" code that serves as the virtual-machine monitor. The
17 task must be represented by an 80386 TSS (not an 80286 TSS). The processor
18 enters V86 mode to execute the 8086 program and returns to protected mode to
19 execute the monitor or other 80386 tasks.
20 <P>
21 To run successfully in V86 mode, an existing 8086 program needs the
22 following:
23 <UL>
24 <LI> A V86 monitor.
25 <LI> Operating-system services.
26 </UL>
27 The V86 monitor is 80386 protected-mode code that executes at
28 privilege-level zero. The monitor consists primarily of initialization and
29 exception-handling procedures. As for any other 80386 program,
30 executable-segment descriptors for the monitor must exist in the GDT or in
31 the task's LDT. The linear addresses above 10FFEFH are available for the
32 V86 monitor, the operating system, and other systems software. The monitor
33 may also need data-segment descriptors so that it can examine the interrupt
34 vector table or other parts of the 8086 program in the first megabyte of the
35 address space.
36 <P>
37 In general, there are two options for implementing the 8086 operating
38 system:
39 <OL>
40 <LI> The 8086 operating system may run as part of the 8086 code. This
41 approach is desirable for any of the following reasons:
42 <UL>
43 <LI> The 8086 applications code modifies the operating system.
44 <LI> There is not sufficient development time to reimplement the 8086
45 operating system as 80386 code.
46 </UL>
47 <LI> The 8086 operating system may be implemented or emulated in the V86
48 monitor. This approach is desirable for any of the following reasons:
49 <UL>
50 <LI> Operating system functions can be more easily coordinated among
51 several V86 tasks.
52 <LI> The functions of the 8086 operating system can be easily emulated
53 by calls to the 80386 operating system.
54 </UL>
55 </OL>
56 Note that, regardless of the approach chosen for implementing the 8086
57 operating system, different V86 tasks may use different 8086 operating
58 systems.
60 <H2>15.2.1 Using Paging for V86 Tasks</H2>
61 Paging is not necessary for a single V86 task, but paging is useful or
62 necessary for any of the following reasons:
63 <UL>
64 <LI> To create multiple V86 tasks. Each task must map the lower megabyte of
65 linear addresses to different physical locations.
66 <LI> To emulate the megabyte wrap. On members of the 8086 family, it is
67 possible to specify addresses larger than one megabyte. For example,
68 with a selector value of 0FFFFH and an offset of 0FFFFH, the effective
69 address would be 10FFEFH (one megabyte + 65519). The 8086, which can
70 form addresses only up to 20 bits long, truncates the high-order bit,
71 thereby "wrapping" this address to 0FFEFH. The 80386, however, which
72 can form addresses up to 32 bits long does not truncate such an
73 address. If any 8086 programs depend on this addressing anomaly, the
74 same effect can be achieved in a V86 task by mapping linear addresses
75 between 100000H and 110000H and linear addresses between 0 and 10000H
76 to the same physical addresses.
77 <LI> To create a virtual address space larger than the physical address
78 space.
79 <LI> To share 8086 OS code or ROM code that is common to several 8086
80 programs that are executing simultaneously.
81 <LI> To redirect or trap references to memory-mapped I/O devices.
82 </UL>
83 <H2>15.2.2 Protection within a V86 Task</H2>
84 Because it does not refer to descriptors while executing 8086 programs, the
85 processor also does not utilize the protection mechanisms offered by
86 descriptors. To protect the systems software that runs in a V86 task from
87 the 8086 program, software designers may follow either of these approaches:
88 <UL>
89 <LI> Reserve the first megabyte (plus 64 kilobytes) of each task's linear
90 address space for the 8086 program. An 8086 task cannot generate
91 addresses outside this range.
92 <LI> Use the U/S bit of page-table entries to protect the virtual-machine
93 monitor and other systems software in each virtual 8086 task's space.
94 When the processor is in V86 mode, CPL is 3. Therefore, an 8086 program
95 has only user privileges. If the pages of the virtual-machine monitor
96 have supervisor privilege, they cannot be accessed by the 8086 program.
97 </UL>
98 <P>
99 <HR>
101 <B>up:</B> <A HREF="c15.htm">
102 Chapter 15 -- Virtual 8086 Mode</A><BR>
103 <B>prev:</B> <A HREF="s15_01.htm">15.1 Executing 8086 Code</A><BR>
104 <B>next:</B> <A HREF="s15_03.htm">15.3 Entering and Leaving V86 Mode</A>
105 </BODY>