This DPMI 0.9 Specification is hosted by Tenberry Software, Inc.

5. Loading DPMI Clients and Extended Applications


[Next Section] * [Previous Section] * [DPMI Index]
[Tenberry Home] * [Software Quality] * [DOS/4G] * [DOS/4GW] * [DOS/16M]

All DPMI applications begin execution in real mode. An application must run first as a standard real mode DOS program but it can switch to protected execution by making a few simple calls.

DPMI does not define an executable file format for protected mode programs. Instead, programs must provide their own mechanism for loading and fixing up protected mode code.


5.1 Obtaining the Real to Protected Mode Switch Entry Point

This function can be called in real mode to detect the presence of DPMI services and to obtain an address that can be used to begin execution in protected mode.

To Call

     AX = 1687h
     Execute an Int 2Fh (not an Int 31h)

Returns

     If function was successful:
     AX = 0
     BX = Flags
          Bit 0 = 1 if 32-bit programs are supported
     CL = Processor type
          02h = 80286
          03h = 80386
          04h = 80486
     DH = DPMI major version number
     DL = DPMI minor version number
     SI =  Number  of  paragraphs  required  for  DPMI  host
          private data (may be 0)
     ES:DI = Address of procedure to call to enter protected
          mode

     If function was not successful:
     AX != 0

Programmer's Notes


5.2 Calling the Real to Protected Mode Switch Entry Point

After using Int 2Fh function 1687h, to obtain the protected mode entry point, the DPMI client must call the entry point address as described in this section.

To Call

     AX = Flags
     Bit 0 = 1 if program is a 32-bit application
     ES =  Real mode  segment of  DPMI host data area.  This
          must be  the size  of the data area returned in SI
          from the previous function.  ES will be ignored if
          the required data size is zero.
     Call the  address returned  in ES:DI  by  the  previous
          function

Returns

     If function was successful:
     Carry flag is clear.
     Program is now executing in protected mode.
     CS =  16-bit selector  with base  of real mode CS and a
          64K limit
     SS = Selector with base of real mode SS and a 64K limit
     DS = Selector with base of real mode DS and a 64K limit
     ES = Selector to program's PSP with a 100h byte limit
     FS and GS = 0 (if running on an 80386 or 80486)
     If the program is a 32-bit application the high word of
          ESP will be 0
     All other registers are preserved

     If function was not successful:
     Carry flag is set.
     Program is executing in real mode

Programmer's Notes

Example Code

;
; Get the entry point address and save it
;
        mov     ax, 1687h
        int     2Fh
        test    ax, ax
        jnz     Cant_Enter_PMode
        mov     [PMode_Entry_Seg], es
        mov     [PMode_Entry_Off], di

;
; Allocate memory for use by DOS extender if necessary
; NOTE:  This code assumes that the program has already
;        shrunk its memory block so that the DOS
;        memory allocation call will work
;
        test    si, si
        jz      Enter_PMode_Now
        mov     bx, si
        mov     ah, 48h
        int     21h
        jc      Cant_Enter_PMode
        mov     es, ax

;
; Enter protected mode as a 16-bit program
;
Enter_PMode_Now:
        xor     ax, ax
        call    DWORD PTR [PMode_Entry_Off]
        jc      Cant_Enter_PMode

;
; The program is running in protected mode now!
; Protected mode initialization code would go here.
; Mark program's real mode memory as pageable, etc.
;
        .
        .
        .

;
; Quit the program and return to real mode DOS
;
        mov     ax, 4C00h
        int     21h

[Next Section] * [Previous Section] * [DPMI Index]
[Tenberry Home] * [Software Quality] * [DOS/4G] * [DOS/4GW] * [DOS/16M]
This HTML edition of the DPMI 0.9 Specification is hosted by Tenberry Software, Inc., makers of the DOS/16M and the DOS/4G family of DOS extenders. Page last modified 2003.1.28, <webmaster@tenberry.com>