DPMI Introduction

Most processor instructions that are available in real mode may also be executed from a protected mode task. Hence an application may overcome the limitations of real mode simply by executing in protected mode. However, direct access to physical hardware and interrupts is typically not permitted from a protected mode task running at Ring 3 privilege, and therefore DOS itself and many TSR programs must run in real mode. Protected mode specifications are such that communication between protected mode and real mode programs is difficult, making it difficult for an application to request services from DOS or a device driver.

For example, a TSR, with which an application communicates through a software interrupt or a shared buffer, cannot run in protected mode. The real mode address of the TSR, if used by the protected mode application, will not point to the same location in memory as would the same address if used in real mode, since the segment portion of the address is interpreted differently in the two modes. Address conversion is therefore required when passing between the two modes.

DPMI provides an interface between protected mode and real mode programs. DPMI consists of a set of protected mode functions which allow a DOS application to enter protected mode, allocate real mode memory, simulate real mode interrupts and function calls, intercept real mode interrupt vectors, etc. By using these calls, an application running in protected mode can communicate with DOS or a TSR running in real mode.

DPMI facilitates the following:

  • Allows DOS applications to run in protected mode

  • Provides DOS applications with access to a large memory address space

  • Provides DOS applications with mode switching and calls between real mode and protected mode

  • Provides DOS applications running in protected mode with access to hardware facilities such as debug registers, in a way that maintains system integrity.

    The term real mode is used to refer to code that runs in the low 1MB address space and uses segment:offset addressing. Under many implementations of DPMI, so-called real mode software is actually executed in virtual 8086 mode. Since virtual 8086 mode closely approximates real mode, V86 mode and real mode are interchangeable in the DPMI context.

    One of the major benefits offered by DPMI is that of allowing DOS extenders to work effectively in a multitasking, protected mode environment. DOS extenders allow DOS applications to access extended memory while running in protected mode. These extenders switch between modes as required to:

  • Execute application code in protected mode, in order to realize the enhanced addressing capabilities and protection facilities of protected mode

  • Access DOS services and TSRs in real mode, to perform functions which cannot be performed in protected mode.

    The Microsoft Windows/286 DOS extender (running under DOS on an 80286 processor) was able to switch modes of its own accord. However, when running in virtual 8086 mode on an 80386 processor, a task cannot switch to protected mode; the required instruction is not legal for a V86 mode task. The architecture of DPMI, however, allows DOS extenders to request services using INT 31h DPMI calls; DPMI itself handles the mode switching and address conversion necessary to invoke the real mode services.


    [Back: DOS Protected Mode Interface]
    [Next: Virtual Control Program Interface]