flat assembler
Message board for the users of flat assembler.

flat assembler > DOS > History of DPMI

Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7362
Location: Kraków, Poland
I've posted this link in the other thread, however it perhaps got lost in a vast discussion there. I am reposting it here, because I consider it to be really important reading for anyone who ever did any DOS protected mode programming:
http://lists.gnu.org/archive/html/lynx-dev/1998-04/msg00773.html

If first stumbled upon the above message when it was mentioned on the freedos-dev list back in early 2000, about the same time when I was posting the announcements of the very first releases of fasm there. Since then I was hoping I would one day see some True DPMI specification, however it never happened and it seems the knowledge about it limited to a small amount of people.

There are a few follow-up messages in the same archives about this (with even more interesting notes):
http://lists.gnu.org/archive/html/lynx-dev/1998-05/msg00157.html
http://lists.gnu.org/archive/html/lynx-dev/1998-05/msg00159.html
However I never found it mentioned in any other place of internet.

Myself I anyway always rely only on the basic DPMI 0.9 functionality, since I don't even know a method to detect whether the DPMI is True or not - the Michael Sokolov in the first message linked here states that he used such method, but CWSDPMI was "screwed" in a way that it was not working with it. If anyone has some deeper knowledge about the topic, please let me know.
Post 17 Dec 2006, 20:36
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
someone please mention this in wikipedia (i don't have experience editing it)

http://en.wikipedia.org/wiki/DPMI
Post 17 Dec 2006, 21:52
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
> since I don't even know a method to detect whether the DPMI is True or not

I don't know if "true DPMI" is indeed "DPMI v0.9 + full int 21h API", but if a call of int 2Fh, ax=168Ah, DS:ESI->"MS-DOS" in protected-mode returns with AL=0, the full int 21h API should be implemented.
Post 17 Dec 2006, 21:57
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7362
Location: Kraków, Poland
Indeed, I tested with QDPMI and HDPMI and they both report as "MS-DOS" vendor (correctly, as they both support 32-bit INT 21h API), while CWSDPMI does not. Is it possible that some old version of CWSDPMI was reporting this way and this was what was "broken" about it? Or was he referring to some other detection method?
Anyway, this method seems to be reliable. Thanks!

Code:
; A True DPMI example Wink

format MZ
heap 0                                  ; no additional memory

segment loader use16

        push    cs
        pop     ds

        mov     ax,1687h
        int     2Fh
        or      ax,ax                   ; DPMI installed?
        jnz     error
        test    bl,1                    ; 32-bit programs supported?
        jz      error
        mov     word [mode_switch],di
        mov     word [mode_switch+2],es
        mov     bx,si                   ; allocate memory for DPMI data
        mov     ah,48h
        int     21h
        jc      error
        mov     es,ax
        mov     ax,1
        call    far [mode_switch]       ; switch to protected mode
        jc      error

        mov     ax,168Ah
        mov     esi,_msdos              ; True DPMI functionality supported?
        int     2Fh
        or      al,al
        jnz     error

        mov     cx,1
        xor     ax,ax
        int     31h                     ; allocate descriptor for code
        mov     si,ax
        xor     ax,ax
        int     31h                     ; allocate descriptor for data
        mov     di,ax
        mov     dx,cs
        lar     cx,dx
        shr     cx,8
        or      cx,0C000h
        mov     bx,si
        mov     ax,9
        int     31h                     ; set code descriptor access rights
        mov     dx,ds
        lar     cx,dx
        shr     cx,8
        or      cx,0C000h
        mov     bx,di
        int     31h                     ; set data descriptor access rights
        mov     ecx,main
        shl     ecx,4
        mov     dx,cx
        shr     ecx,16
        mov     ax,7                    ; set descriptor base address
        int     31h
        mov     bx,si
        int     31h
        mov     cx,0FFFFh
        mov     dx,0FFFFh
        mov     ax,8                    ; set segment limit to 4 GB
        int     31h
        mov     bx,di
        int     31h

        mov     ds,di
        mov     es,di
        mov     fs,di
        mov     gs,di
        push    0
        push    si
        push    dword start
        retfd

    error:
        mov     ax,4CFFh
        int     21h

  _msdos db 'MS-DOS',0

  mode_switch dd ?

segment main use32

  start:

        mov     ah,9
        mov     edx,hello
        int     21h

        mov     ax,4C00h
        int     21h

  hello db 'Hello from protected mode!',0Dh,0Ah,'$'    
Post 17 Dec 2006, 23:36
View user's profile Send private message Visit poster's website Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: usa
some commented code from tomasz! maybe he'll develope the habit in fasm source Wink
Post 18 Dec 2006, 03:28
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7108
Location: Slovakia
Quote:
i wouldn't be afraid of that...
Post 18 Dec 2006, 06:20
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
> Indeed, I tested with QDPMI and HDPMI

the "MS-DOS" vendor call is also supported by DPMIONE (+386MAX), 32RTM, DosEmu, OS/2 VDMs and Windows DOS boxes.
Post 18 Dec 2006, 08:35
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1904
Download now: http://board.flatassembler.net/download.php?id=3651

Applied 2 "critical" fixes to the code Laughing

Code:
           mov   eax,$168A       ; 5
           lea   ebx,[eax+$30C5] ; 6
           push  ebx             ; 1
           xor   ebx,$442D1402   ; 6
           push  ebx             ; 1
           mov   esi,esp         ; 2
           push  eax             ; 1
           int   $2F             ; 2 -> 24 Test, may destroy EAX and ES
             ; We have result in AL
           cmp   al,0            ; 2 Sets ZF, AL=0 -> found !!!
           pop   eax             ; 1 Doesn't affect ZF
           je    @f              ; 2 Found Smile
           pop   ecx             ; 1
           pop   ebx             ; 1
           mov   bh,ch           ; 2
           push  ebx             ; 1
           push  ecx             ; 1
           int   $2F             ; 2 -> 37 Recheck
@@:          ; We have result in AL
           pop   ebx             ; 1
           pop   ebx             ; 1 -> 39 Done !
           ; Here our result is in AL : AL=0 -> "API" found
    
Post 06 Mar 2008, 06:56
View user's profile Send private message Reply with quote
Goplat



Joined: 15 Sep 2006
Posts: 181
What's wrong with "push dword 'OG', push dword 'MS-D'", and what DPMI host has that entry point?
Post 07 Mar 2008, 00:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.