background image

Vol. 3B 20-11

8086 EMULATION

20.2.8.1   I/O-Port-Mapped I/O

The I/O permission bit map in the TSS can be used to generate exceptions on attempts to access specific I/O port 
addresses. The I/O permission bit map of each virtual-8086-mode task determines which I/O addresses generate 
exceptions for that task. Because each task may have a different I/O permission bit map, the addresses that 
generate exceptions for one task may be different from the addresses 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 permis-
sion bit map. See Chapter 18, “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.

20.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 excep-
tions 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 intervention 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.

20.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.

20.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.
In virtual-8086 mode, the interrupts and exceptions are divided into three classes for the purposes of handling:

•

Class 1 â€” All processor-generated exceptions and all hardware interrupts, including the NMI interrupt and the 
hardware interrupts sent to the processor’s external interrupt delivery pins. All class 1 exceptions and 
interrupts are handled by the protected-mode exception and interrupt handlers.

•

Class 2 â€” Special case for maskable hardware interrupts (Section 6.3.2, â€śMaskable Hardware Interrupts”) 
when the virtual mode extensions are enabled.

•

Class 3 â€” All software-generated interrupts, that is interrupts generated with the INT n instruction

1

.

The method the processor uses to handle class 2 and 3 interrupts depends on the setting of the following flags and 
fields:

•

IOPL field (bits 12 and 13 in the EFLAGS register) â€” Controls how class 3 software interrupts are handled 
when the processor is in virtual-8086 mode (see Section 2.3, â€śSystem Flags and Fields in the EFLAGS 

1. The INT 3 instruction is a special case (see the description of the INT n instruction in Chapter 3, â€śInstruction Set Reference, A-L”, of 

the Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A).