;       SCCSID = @(#)os2char.asm        6.3 91/08/29
PAGE 60,132    ;
;************************************************************************
;
; Source File Name:     OS2BASE.ASM
;
; Subroutine Name:      OS2BASE Inititialization Entry
;
; Descriptive Name:     Full Screen Subsystem Initialization
;
; Function:     Per process initialization for VIO and Session Management
;               based applications.
;
; Notes:
;       Dependencies:   None
;
;       Restrictions:
;
; Change History:
;
;      @TL6 - 03/01/90 - DCR 704 - Declare SMG/SSW instance data here
;      @T14 - 03/30/90 - Remove duplication of functions
;      @T15 - 04/02/90 - PTR B788719 - Use ordinal number instead of ASCIIZ
;                                      procedure name
;      @T16 - 04/23/90 - PTR B712629 - A temporary hack to circumvent a
;                                      problem with starting a VIO window
;                                      without a mouse
;      @T18 - 04/30/90 - PTR B712103 - Optimize screen switching by saving the
;                                      Array selector in the instance data seg.
;      @D1200 01/23/91 CJJ, DCR 1200.2 Call Dos32WriteQueue for Dos32StartSess.
;      @GDW - 08/29/91 - PTR B726157 - Combine KIO and MIO into MKIO router
;
;      Defect 60843 03/21/93 LWB     - Added pmvdmp entries to sesmgr instance
;                                      data.
;      MDLL - 01/10/94 - BJN         - Page Tune segments for Merged DLL.
;
; Entry Point:
;       Linkage:  EXTRN BASEINIT:FAR
; Inputs:
;       Standard 16-Bit DLL Initialization Registers
;
; Exit Normal:
;       AX      ReturnCode Value = -1, Initialization successful
;
; Exit Errors:
;       AX      ReturnCode Value = 0, Initialization failed
;
; Effects:      All other registers preserved.
;
; Internal References:
;          Routines:
;
; External References:
;          Routines:
;
;************************************************************************
        .286p                           ;Generate 286 Protect Mode instructions

        EXTRN   ROUTPROCESSINIT:FAR     ;Mouse router initialization    ;@GDW
        EXTRN   BMSINIT:FAR             ;Mouse subsystem initialization
        EXTRN   VIOINITPROCESS:FAR      ;VIO router initialization
        EXTRN   ANSIINIT:FAR            ;ANSI per process init routine

;       The following per process data words are declared in VIOROUT.ASM

        EXTRN   procTYPE:WORD           ;Process type                   ;@T14

        .xlist
        INCLUDE struc.inc               ;Structured Macros
        INCLUDE error2.inc
        INCLUDE infoseg.inc                                             ;@T14
        .list

;        PUBLIC  __acrtused                                             ;MDLL
;__acrtused      EQU     0                                              ;MDLL

;CDATA_GROUP     GROUP CDATA_BSS, CDATA_CONST, CDATA                    ;MDLL
;                                                                       ;MDLL
;CDATA_BSS       SEGMENT WORD PUBLIC 'FAR_DATA'                         ;MDLL
;CDATA_BSS       ENDS                                                   ;MDLL
;                                                                       ;MDLL
;CDATA_CONST     SEGMENT WORD PUBLIC 'FAR_DATA'                         ;MDLL
;CDATA_CONST     ENDS                                                   ;MDLL
;                                                                       ;MDLL
;CDATA           SEGMENT WORD PUBLIC 'FAR_DATA'                         ;MDLL
;CDATA           ENDS                                                   ;MDLL

_DATA           EQU     <OS2CHAR_I>                                     ;MDLL
_DATA           SEGMENT WORD PUBLIC 'FAR_DATA'                          ;MDLL

SMGINSTANCE     label   far                                             ;@TL6
                PUBLIC  SMGINSTANCE                                     ;@TL6

;
;       Start of Session Manager instance data
;
                DD  32 DUP(0)       ; Slots                             ;@TL6
                DW  0               ; Next_Slot                         ;@TL6
;@T18           DD  0               ; Instance_SGCB                     ;@TL6
;@T18           DD  0               ; PopUp_SGCB                        ;@TL6

; * * * * * NOTE: xxxx_handle and xxxx_module MUST be consecutive * * * ;@TL6
                DW  0               ; AppWin_Handle                     ;@TL6
                DB  'PMWIN',0       ; AppWin_Module                     ;@TL6
                DW  0               ; PgmType_Handle                    ;@TL6
                DB  'PMSHAPI',0     ; PgmType_Modules                   ;@TL6
                DW  0               ; Store handle retd from Load ;D1506 ;60843
                DB  'PMVDMP',0      ; Make sure length is 9 bytes.;D1506 ;60843
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;@TL6

                DW  274             ; WinMsgSemWait ordinal        ;@TL6,@T15
                DW  16              ; WinQueryProgramType ordinal  ;@TL6,@T15
                DW  13              ; DosTransPropBinToStrl ordinal ;60843
                DD  0               ; WinMsgSemWait address             ;@TL6
                DD  0               ; WinQueryProgramType address       ;@TL6
                DD  0               ; VDMProp2Bin PMVdmP.dll            ;60843        ;D1506
ArraySeg        DW  0               ; Array selector for GetSeg optm.   ;@T18
                DW  0               ; Flag for 32 bit call              ;@D1200
                PUBLIC  ArraySeg                                        ;@T18

;
;       Start Screen Switcher instance data
;
                DW  0               ; in_sgid                           ;@TL6
                DW  0               ; in_procid                         ;@TL6
                DW  0               ; in_si_reg                         ;@TL6
                DW  0               ; in_di_reg                         ;@TL6
                DW  0               ; in_ds_reg                         ;@TL6
                DD  0               ; in_locktimer                      ;@TL6
                DW  0               ; in_firstunlok                     ;@TL6
                DW  0               ; in_savemodepid                    ;@TL6
                DW  0               ; in_saverestpid                    ;@TL6

_DATA           ENDS

CODE_TUNE2   SEGMENT WORD PUBLIC 'CODE'                                 ;MDLL
        ASSUME  CS:CODE_TUNE2, DS:NOTHING, ES:NOTHING, SS:NOTHING       ;MDLL

        public  OS2BASEINIT
OS2BASEINIT  proc    far

;       int     3

        call    VIOINITPROCESS

        .if     <zero ax>                                               ;@T14
            push    ds                                                  ;@T14
            push    _DATA       ;Setup instance data selector           ;@T14
            pop     ds          ;                                       ;@T14

            .if     <ds:procTYPE b LIS_PT_PRESMGR>  ;FS or Windowable?  ;@T14
                call    ANSIINIT                                        ;@T14
                .if     <zero ax>                                       ;@T14
                    call    ROUTPROCESSINIT  ;Mouse/Keyboard init       ;@GDW
                    .if     <zero ax>                                   ;@T14
                        call    BMSINIT      ;Base Mouse Subsystem init
                        sub     ax,ax        ;Temporary hack            ;@T16
                    .endif
                .endif                                                  ;@T14
            .endif                                                      ;@T14
            pop     ds                                                  ;@T14
        .endif

        .if     <zero ax>       ;Successful initialization done?        ;@T14
            dec     ax                                                  ;@T14
        .else                                                           ;@T14
            sub     ax,ax                                               ;@T14
        .endif                                                          ;@T14

        ret
OS2BASEINIT  endp

CODE_TUNE2   ENDS                                                       ;MDLL
        END ;OS2BASEINIT                                                ;MDLL
