;       SCCSID = @(#)d_ioctl2.asm	6.1 91/02/15
;       SCCSID = @(#)d_ioctl2.asm	6.2 90/01/22
; ****************************************************************************
; *									     *
; *			  IBM/Microsoft Confidential			     *
; *									     *
; *		    Copyright (c) IBM Corporation  1987, 1990		     *
; *		    Copyright (c) Microsoft Corp.  1987, 1990		     *
; *			      All Rights Reserved			     *
; *									     *
; ****************************************************************************
;/********************** START OF SPECIFICATIONS *********************/
;/*                                                                  */
;/* SUBROUTINE NAME: DosDevIOCtl2                                    */
;/*                                                                  */
;/* DESCRIPTIVE NAME: Dos Device I/O Control 2                       */
;/*                                                                  */
;/* FUNCTION: Handles conversion from DosDevIOCtl2 to DosDevIOCtl    */
;/*                                                                  */
;/* NOTES:    Real Mode Only                                         */
;/*           Simulates OS/2 call from DOS 2.x,3.x environment       */
;/*                                                                  */
;/* ENTRY POINT: DosDevIOCtl2                                        */
;/*                                                                  */
;/*    LINKAGE: Call Far                                             */
;/*                                                                  */
;/*                                                                  */
;/* INPUT: Stack Frame in form of:                                   */
;/*                                                                  */
;/*                                                                  */
;/*  PUSH    @OTHER  Data - Data Area                                */
;/*  PUSH    WORD    DataLength - Data Area Length                   */
;/*  PUSH    @OTHER  ParmList - Command Arguments                    */
;/*  PUSH    WORD    ParmListLength - Command Argument list length   */
;/*  PUSH    WORD    Function - Device Function                      */
;/*  PUSH    WORD    Category - Device Category                      */
;/*  PUSH    WORD    DevHandle - Specifies the device                */
;/*                                                                  */
;/* EXIT-NORMAL:   AX = 0                                            */
;/*                                                                  */
;/* EXIT-ERROR:    AX = Errorcode                                    */
;/*       may return error code from Dos 2.x, 3.x, OS/2              */
;/*                                                                  */
;/* EFFECTS:  AX, all other registers preserved                      */
;/*                                                                  */
;/* INTERNAL REFERENCES: none                                        */
;/*                                                                  */
;/*    ROUTINES:                                                     */
;/*                                                                  */
;/* EXTERNAL REFERENCES:                                             */
;/*                                                                  */
;/*    ROUTINES: DosDevIOCtl                                         */
;/*                                                                  */
;/*********************** END OF SPECIFICATIONS **********************/

EXTRN  DOSDEVIOCTL:FAR

_TEXT   segment byte public 'CODE'

        assume  CS:_TEXT, DS:nothing

        public  DOSDEVIOCTL2

; Stack Frame for DosDevIOCtl

DataArea        equ     [BP+16]
ParmList        equ     [BP+12]
Function        equ     [BP+10]
Category        equ     [BP+8]
DevHandle       equ     [BP+6]

; Stack Frame for DosDevIOCtl2

DataArea2       equ     [BP+20]
DataAreaLength2 equ     [BP+18]
ParmList2       equ     [BP+14]
ParmListLength2 equ     [BP+12]
Function2       equ     [BP+10]
Category2       equ     [BP+8]
DevHandle2      equ     [BP+6]

UserCS          dw      ?
UserIP          dw      ?
userBP          dw      ?


DOSDEVIOCTL2    proc    far
        push    bp                      ; Set up stack frame
        mov     bp,sp

        pop     UserBp                  ; pop off the old bp
        pop     UserCS                  ; pop off the old cs
        pop     UserIP                  ; pop off the old ip

        mov     ax,ParmList2
        mov     ParmList,ax

        mov     ax,ParmList2+2
        mov     ParmList+2,ax

        mov     ax,DataArea2+2
        mov     DataArea+2,ax

        mov     ax,DataArea2
        mov     DataArea,ax


        call    far ptr DosDevIOCtl     ; Call the Worker

        push    UserIP                  ; Restore Users IP
        push    UserCS                  ; Restore Users CS
        mov     bp,UserBp               ; Restore Users BP
        ret     4                       ; Return to User
DOSDEVIOCTL2    endp


_TEXT   ends
        end
