Intel architecture ia-32 Manuale Utente

Pagina di 636
Vol. 3A 15-13
8086 EMULATION
15.2.6
Leaving Virtual-8086 Mode
The processor can leave the virtual-8086 mode only through an interrupt or exception. The
following are situations where an interrupt or exception will lead to the processor leaving
virtual-8086 mode (see Figure 15-3):
The processor services a hardware interrupt generated to signal the suspension of execution
of the virtual-8086 application. This hardware interrupt may be generated by a timer or
other external mechanism. Upon receiving the hardware interrupt, the processor enters
protected mode and switches to a protected-mode (or another virtual-8086 mode) task
either through a task gate in the protected-mode IDT or through a trap or interrupt gate that
points to a handler that initiates a task switch. A task switch from a virtual-8086 task to
another task loads the EFLAGS register from the TSS of the new task. The value of the VM
flag in the new EFLAGS determines if the new task executes in virtual-8086 mode or not.
The processor services an exception caused by code executing the virtual-8086 task or
services a hardware interrupt that “belongs to” the virtual-8086 task. Here, the processor
enters protected mode and services the exception or hardware interrupt through the
protected-mode IDT (normally through an interrupt or trap gate) and the protected-mode
exception- and interrupt-handlers. The processor may handle the exception or interrupt
within the context of the virtual 8086 task and return to virtual-8086 mode on a return from
the handler procedure. The processor may also execute a task switch and handle the
exception or interrupt in the context of another task.
The processor services a software interrupt generated by code executing in the virtual-
8086 task (such as a software interrupt to call a MS-DOS* operating system routine). The
processor provides several methods of handling these software interrupts, which are
discussed in detail in Section 15.3.3, “Class 3—Software Interrupt Handling in Virtual-
8086 Mode”. Mo
st of them involve the processor entering protected mode, often by means
of a general-protection (#GP) exception. In protected mode, the processor can send the
interrupt to the virtual-8086 monitor for handling and/or redirect the interrupt back to the
application program running in virtual-8086 mode task for handling.
IA-32 processors that incorporate the virtual mode extension (enabled with the VME flag
in control register CR4) are capable of redirecting software-generated interrupts back to
the program’s interrupt handlers without leaving virtual-8086 mode. See Section 15.3.3.4,
“Method 5: Software Interrupt Handling”, fo
r more information on this mechanism.
A hardware reset initiated by asserting the RESET or INIT pin is a special kind of
interrupt. When a RESET or INIT is signaled while the processor is in virtual-8086 mode,
the processor leaves virtual-8086 mode and enters real-address mode.
Execution of the HLT instruction in virtual-8086 mode will cause a general-protection
(GP#) fault, which the protected-mode handler generally sends to the virtual-8086 monitor.
The virtual-8086 monitor then determines the correct execution sequence after verifying
that it was entered as a result of a HLT execution.
See Section 15.3, “Interrupt and Exception Handling in Virtual-8086 Mode”, for information on
leaving virtual-8086 mode to handle an interrupt or exception generated in virtual-8086 mode.