
80386
In Virtual 8086 Mode, a slightly different set of in- structions are made
INT n; STI;
PUSHF; eLI;
POPF; IRET
The PUSHF, POPF, and IRET instructions are 10PL- sensitive in Virtual 8086 Mode only. This provision allows the IF flag (interrupt enable flag) to be virtual- ized to the Virtual 8086 Mode program. The INT n software interrupt instruction is also
EXAMPLE OF BITMAP FOR I/O PORTS
+1"l [0' see note below] will allow a
"IMPORTANT IMPLEMENTATION NOTE: Beyond the last byte of I/O mapping information in the I/O Permission Bitmap must be a byte containing all 1'so The byte of all 1'smust be within the limit of the 386 TSS segment (see Figure
4.6.5 Interrupt Handling
Note that the I/O instructions (IN, OUT, INS, OUTS, REP INS, and REP OUTS) are not
The I/O Permission Bitmap can be viewed as a 0- 64 Kbit bit string, which begins in memory at offset BiLMap_Offset in the current TSS. the
Each bit in the I/O Permission Bitmap corresponds to a single
Due to the use of a pointer to the base of the I/O Permission Bitmap, the bitmap may be located any- where within the TSS, or may be ignored completely by pointing the BiLMap_Offset (15:0) beyond the limit of the TSS segment. In the same manner, only a small portion of the 64K I/O space need have an associated map bit, by adjusting the TSS limit to truncate the bitmap. This eliminates the commitment of 8K of memory when a complete bitmap is not required, while allowing the fully general case if de- sired.
In order to fully support the emulation of an 8086 machine, interrupts in Virtual 8086 Mode are han- dled in a unique fashion. When running in Virtual Mode all interrupts and exceptions involve a privi- lege change back to the host 80386 operating sys- tem. The 80386 operating system determines if the interrupt comes from a Protected Mode application or from a Virtual Mode program by examining the VM bit in the EFLAGS image stored on the stack.
When a Virtual Mode program is interrupted and ex- ecution passes to the interrupt routine at level 0, the VM bit is cleared. However, the VM bit is still set in the EFLAG image on the stack.
The 80386 operating system in turn handles the ex- ception or interrupt and then returns control to the 8086 program. The 80386 operating system may choose to let the 8086 operating system handle the interrupt or it may emulate the function of the inter- rupt handler. For example, many 8086 operating system calls are accessed by PUSHing parameters on the stack, and then executing an INT n instruc- tion. If the 10PL is set to a then all INT n instructions will be intercepted by the 80386 operating system. The 80386 operating system could emulate the 8086 operating system'scall. Figure
An 80386 operating system can provide a Virtual 8086 Environment which is totally transparent to the application software via intercepting and then emu- lating 8086 operating system'scalls, and intercept- ing IN and OUT instructions.
4.6.6Entering and Leaving Virtual
8086 Mode
Virtual 8086 mode is entered by executing an IRET instruction (at CPL=O), or Task Switch (at any CPL) to a 386 task whose 386 TSS has a FLAGS image containing a 1 in the VM bit position while the proc-
57