;       SCCSID = @(#)smrequs.inc	6.8 92/03/15
;       SCCSID @(#)smrequs.inc	6.8 92/03/15
PAGE 60,132    ;
; ****************************************************************************
; *                                                                          *
; *                       IBM/Microsoft Confidential                         *
; *                                                                          *
; *                 Copyright (c) IBM Corporation  1987, 1990                *
; *                 Copyright (c) Microsoft Corp.  1987, 1990                *
; *                           All Rights Reserved                            *
; *                                                                          *
; ****************************************************************************

;******************************************************************************
;                                                                             *
; Source File Name:   SMREQU.INC                                              *
;                                                                             *
; Descriptive Name:   General Equates                                         *
;                                                                             *
; Notes:                                                                      *
;     Dependencies:   None                                                    *
;                                                                             *
;     Restrictions:   None                                                    *
;                                                                             *
; Change History:                                                             *
;   @CJ9   04/24/90  PTR B712698 Keyboard not registered and can't            *
;                    register 16 DD's.                                        *
;   @D969  06/18/90  DCR 969 Add help option to harderrors.                   *
;   @D1088 07/07/90  DCR 1088 Add support for special needs.                  *
;   @D981  08/27/90  DCR 981 Notification for DLLs.                           *
;   @MHW   09/13/90  PTR B715818 Removed MMIO references.                     *
;   @D1200 01/23/91  CJJ, DCR 1200 Call Dos32WriteQueue for Dos32StartSes.    *
;   CJ26   05/12/91  PTR B722846 Free memory allocated for Cwait thread stack.*
;   VDMSRV 01/29/92  PTR B733051 Start VDMServer during creation of 1st VDM.  *
;                                                                             *
;******************************************************************************

INCL_ERRORS         EQU -1   ; Define this for BSEERR.INC
INCL_WINPROGRAMLIST EQU -1   ; Define this for the PROG_ equates
INCLUDE PMSHL.INC            ; Use same program types as the shell does

; **********************************************
; *  Equates for DosStartSession Program Type  *
; **********************************************
;                     PROG_xxx defined in PMSHL.INC
Default_Type      EQU PROG_DEFAULT
FS_Type           EQU PROG_FULLSCREEN      ; Full Screen OS/2 Session
Window_Type       EQU PROG_WINDOWABLEVIO   ; VIO Windowed OS/2 Session
PM_Type           EQU PROG_PM              ; PM Session
VDM_Type          EQU PROG_VDM             ; Full Screen VDM Session
Windowed_VDM_Type EQU PROG_WINDOWEDVDM     ; Windowed VDM Session
Illegal_Type_1    EQU PROG_GROUP           ; Illegal Start Type
Illegal_Type_2    EQU PROG_DLL             ; Illegal Start Type

; ***************************
; *  Start Related Equates  *
; ***************************
Start_Original_Len      EQU    24       ; Bytes in original start request
Start_Inherit_Len       EQU    30       ; Bytes in start inherited request
Start_PgmType_Len       EQU    32       ; Version 2.0 length
Start_PM_Len            EQU    50       ; Presentation Manager Start
Start_Object_Len        EQU    60       ; Start with buffer for object failure

Max_Start_Related_Opt    EQU  1         ; Max # for a start related option
Max_Start_Mode_Opt       EQU  1         ; Max # for a start mode option
Max_Start_Async_Ind      EQU  2         ; Max # for a start async option
Max_Start_Pgm_Control    EQU  4         ; Max # for start program control
Max_Start_Pgm_Type       EQU  Windowed_VDM_Type ; Max # for program type
Bad_Start_Pgm_Cntrl_Bits EQU  0111111111110000B ; Bad bits for Program Control

;  ***************************************
;  *  Other Equates for DosStartSession  *
;  ***************************************
Inherited       EQU   1
UnRelated       EQU   0
Related         EQU   1
ForeGround      EQU   0                ; DosStartSession Mode
BackGround      EQU   1                ; DosStartSession Mode

; *******************
; *  Other equates  *
; *******************
Try_Again       EQU   0ABCDH
Enable_Signals  EQU   0                ; For DOSHOLDSIGNAL
Disable_Signals EQU   1                ; For DOSHOLDSIGNAL
Fixed_Disk      EQU   1                ; Boot drive is a fixed disk     @D969;VR8

Hard_Error_SG   EQU   0
Shell_SG        EQU   1

Null            EQU   BYTE PTR 0
No_Error        EQU   0
No              EQU   0
Yes             EQU   1
MaxSMSegments   EQU   4                ; # of 64K segments in SM heap
First_Available_Session   EQU   4      ; First non-reserved session #

; ****************************************
; *  Screen Group Control Block Equates  *
; ****************************************
MaxTotalSessions    EQU 256
NumOfDWords         EQU MaxTotalSessions / 32
SGID_Lookup         EQU 0              ; Look up SGID not PID
PID_Lookup          EQU 1              ; Look up PID not SGID
SGID_Next_Lookup    EQU 2              ; Look up SGID, but return NEXT SGCB
ThreadStackSize     EQU 1024           ; Stack for spowned CWAIT thread @CJ10
Selectable          EQU   0

;****************************
;*  Equates for SGCB_Flags  *
;****************************
Not_Saved            EQU  1             ; SG not saved before going bkgd @D1200
Start_Failed         EQU  2             ; Exec or Switch failed for start@D1200
Top_by_Deletion      EQU  4             ; TopMost cause last one died    @D1200
API_32bit            EQU  8             ; 32 Bit API called              @D1200

;*********************************
;*  Equates for SGCB_FamilyType  *
;*********************************
Independant          EQU  0
Parent               EQU  1             ; Parent session (SG)
Child                EQU  2             ; Child session (SG)
Windowed             EQU  1             ; Windowed session (SG)

;*********************************
;*  Equates for SGCB_ParentExit  *
;*********************************
Parent_In_ExitList        EQU  1
Parent_Is_Debugger        EQU  2

; *****************************************************                 ;CJ26
; * Structure for SMArray (OS2CHAR)/ SGCB_Array (SMG) *                 ;CJ26
; *****************************************************                 ;CJ26
SMArray_Struc           STRUC                                           ;CJ26
SGCB_ptr                DD      0       ; Ptr to SGCB                   ;CJ26
CWaitStackPtr           DD      0       ; Ptr to dedicated Cwait stack  ;CJ26
SMArray_STruc           ENDS                                            ;CJ26

; ******************************
; *  Flag for SMG_Flags Byte.  *
; ******************************
InitDone                  EQU   000000001B  ; 1
Notify_Thread_Start       EQU   000000010B  ; 2
Protect_Mode_Only         EQU   000000100B  ; 4
VDMServ_Started           EQU   000001000B  ; 8                        ;VDMSRV

;**************************                                             ;@D1200
;*  Equates for ReqFlags  *  **** MOVED TO SMRREQB.INC ****      ;@D1200;D1545
;**************************                                             ;@D1200
;Req_32bit           EQU  1             ; 32 Bit API called      ;@D1200;D1545


;@D981 Max_Name_Length      EQU  14 ; # of bytes in max. size name + 1 for 0 for Device Drivers
Default_Path_Length  EQU 260 ; Default max path length                    @D981
Max_Registered_DDs   EQU  16 ; Max Number of Device Drivers we'll support
Max_File_Handles     EQU  30 ; Max Number of file handles                 @CJ9
Char_DD              EQU   1 ; DosQHandType flag for a character device   @D981


; ***********************
; *  Switching Equates  *
; ***********************
; Actions
Switch_To_SG       EQU 0                ; Switch to specified screen group
Switch_To_Next_SG  EQU 1                ; Switch to next screen group
Skip_SG_Save       EQU 2                ; Skip SG save for foreground SG
Skip_SG_Restore    EQU 3                ; Skip SG restore for new foreground SG
Do_PopUp           EQU 4                ; Do popup switch
End_PopUp          EQU 5                ; End popup switch
SG_Start_Switch    EQU 6                ; Screen group start switch

; Start Action
Save_Foreground    EQU 0                ; Save foreground SG
Skip_Save          EQU 1                ; Skip save of foreground SG
Transparent_PopUp  EQU 80H              ; Transparent popup


; *********************************************
; *  EQUates for Device Driver Notification.  *
; *********************************************
INCLUDE SMREXTRN.INC
NotDDLen            EQU  4              ; Bytes to pop on exit          ;@D1088
Version_1_2_Len     EQU  8              ; Data Bytes for ParmList       ;@D1088
Session_2_0_Len     EQU 12              ; new 2.0 session notifies      ;@D1088
AIM_Len             EQU 24              ; AIM notifies length           ;@D1088

; *************************************                                 ;@D981
; * Structure for DD/DLL registration *                                 ;@D981
; *************************************                                 ;@D981
RegDD_Struc             STRUC                                           ;@D981
reg_DLL                 DW      0       ; Flag set if DLL               ;@D981
reg_bitmap              DW      0       ; notification bitmap           ;@D981
reg_name                DW      0       ; DD or DLL name                ;@D981
RegDD_Struc             ENDS                                            ;@D981

; ***********************************************                       ;@D1088
; * Structures for Device Driver IOCtl calldata *                       ;@D1088
; ***********************************************                       ;@D1088

AIM_notifydd            STRUC           ; structure for AIM_Pre_save    ;@D1088
notdd_AIM_Length        DW      0       ; and AIM_Post_Save             ;@D1088
notdd_AIM_Type          DW      0       ; DosSMNotifyDD notifications   ;@D1088
notdd_AIM_Errors        DD      0                                       ;@D1088
notdd_AIM_Active        DW      0                                       ;@D1088
notdd_AIM_TimeOut       DW      0                                       ;@D1088
notdd_AIM_FKAccept      DD      0                                       ;@D1088
notdd_AIM_FKRate        DD      0                                       ;@D1088
notdd_AIM_FKDelay       DD      0                                       ;@D1088
AIM_notifydd            ENDS                                            ;@D1088

; ******************************************
; *  Notification Bitmap for the keyboard  *
; ******************************************
KBD_Notifications EQU Termination_Notification+Creation_Notification+Pre_Switch_Notification+AIM_Pre_Save_Notification+AIM_Post_Save_Notification ;@D1088

; ******************************************************
; *  Stack frame for ENTER (or MOV BP, SP) then PUSHA  *
; ******************************************************
DI_Reg  EQU  SS:[BP-16]
SI_Reg  EQU  SS:[BP-14]
BP_Reg  EQU  SS:[BP-12]
SP_Reg  EQU  SS:[BP-10]
BX_Reg  EQU  SS:[BP-8]
DX_Reg  EQU  SS:[BP-6]
CX_Reg  EQU  SS:[BP-4]
AX_Reg  EQU  SS:[BP-2]


; ************
; *  Macros  *
; ************
Clear   MACRO   What          ; Best way to 0 a register changes.
          XOR  What, What     ; My best bet for now.
        ENDM

Int3    MACRO
        ifdef DEBUG
          INT 3
        endif
        ENDM

Move_AsciiZ  MACRO  Source, Destination
            PUSH  DS
            PUSH  SI                    ; Remember starting place of src
            LDS   SI, Source
            .REPEAT
                LODSB                   ; MOV AL, ES:[SI]
                STOSB                   ; MOV DS:[DI], AL
            .UNTIL < AL eq 0 >          ; Until we get to 00H termination
            POP   SI
            POP   DS

; Here is a possible replacement for the above code
;;;;;;;;;;; PUSH ES           ; Save pointer to Destination
;;;;;;;;;;; PUSH DI
;;;;;;;;;;; LES  DI, DS:[SI+BX].startstrings  ; For SCASB
;;;;;;;;;;; MOV  CX, -1       ;
;;;;;;;;;;; REPNZ SCASB       ; Scan for a 0
;;;;;;;;;;; NEG  CX           ; Convert CX to a positive number
;;;;;;;;;;; DEC  CX           ; # Of bytes including trailing 0
;;;;;;;;;;;
;;;;;;;;;;; LDS  SI, DS:[SI+BX].startstrings  ; For MOVSB
;;;;;;;;;;; POP  DI           ; Pointer to destination
;;;;;;;;;;; POP  ES           ; ES:DI --> Destination
;;;;;;;;;;; REP  MOVSB        ; Copy the bytes

             ENDM


; Stack frames for DosWinProc calls

winproc1                STRUC             ; Used if DosLoadModule is needed
w1_oldbp                DW      0
w1_retnearaddr          DW      0
dummy                   DW      0
module_handle_lo        DW      0
module_handle_hi        DW      0
module_name_lo          DW      0
module_name_hi          DW      0
winproc1                ENDS

winproc2                STRUC             ; Used if DosGetProcAddr is needed
w2_oldbp                DW      0
w2_retnearaddr          DW      0
procaddr_lo             DW      0
procaddr_hi             DW      0
procname_lo             DW      0
procname_hi             DW      0
module_handle           DW      0
winproc2                ENDS
