17-16 Vol. 3
8086 EMULATION
for another task. This differs from protected mode in which, if the CPL is less than or
equal to the IOPL, I/O access is allowed without checking the I/O permission bit map.
See Chapter 13, “Input/Output”, in the Intel® 64 and IA-32 Architectures Software
Developer’s Manual, Volume 1, for more information about the I/O permission bit
map.
17.2.8.2 Memory-Mapped I/O
In systems which use memory-mapped I/O, the paging facilities of the processor can
be used to generate exceptions for attempts to access I/O ports. The virtual-8086
monitor may use paging to control memory-mapped I/O in these ways:
• Map part of the linear address space of each task that needs to perform I/O to the
physical address space where I/O ports are placed. By putting the I/O ports at
different addresses (in different pages), the paging mechanism can enforce
isolation between tasks.
• Map part of the linear address space to pages that are not-present. This
generates an exception whenever a task attempts to perform I/O to those pages.
System software then can interpret the I/O operation being attempted.
Software emulation of the I/O space may require too much operating system inter-
vention under some conditions. In these cases, it may be possible to generate an
exception for only the first attempt to access I/O. The system software then may
determine whether a program can be given exclusive control of I/O temporarily, the
protection of the I/O space may be lifted, and the program allowed to run at full
speed.
17.2.8.3 Special I/O Buffers
Buffers of intelligent controllers (for example, a bit-mapped frame buffer) also can be
emulated using page mapping. The linear space for the buffer can be mapped to a
different physical space for each virtual-8086-mode task. The virtual-8086 monitor
then can control which virtual buffer to copy onto the real buffer in the physical
address space.
17.3 INTERRUPT AND EXCEPTION HANDLING
IN VIRTUAL-8086 MODE
When the processor receives an interrupt or detects an exception condition while in
virtual-8086 mode, it invokes an interrupt or exception handler, just as it does in
protected or real-address mode. The interrupt or exception handler that is invoked
and the mechanism used to invoke it depends on the class of interrupt or exception
that has been detected or generated and the state of various system flags and fields.