;	SCCSID = @(#)msginit.asm	6.1 90/11/17
;	SCCSID = @(#)msginit.asm	1.8 90/02/01
PAGE	60,132
;********************************************************************
;   Modification history
;
;12-06-87 Created
;
; 4-20-88 Added Do_Write routine which must reside at level 3, so that
;	  the DosWrite call is called from ring 3.
; noto	11/18/93  Define which segment for Page Tuning DLL
;
.XALL
.LIST
IFNDEF	FamilyAPI
.286c
ENDIF	;FamilyAPI
TITLE  Message Retriever - initialization - IBM CONFIDENTIAL
SUBTTL Externals
;/********************** START OF SPECIFICATIONS **********************/
;/*								      */
;/* SOURCE FILE NAME:  MSGINIT					      */
;/*								      */
;/* DESCRIPTIVE NAME:  get infoseg pointers			      */
;/*								      */
;/* COPYRIGHT: IBM						      */
;/*								      */
;/* STATUS: RELEASE 1 LEVEL 1					      */
;/*								      */
;/* FUNCTION:  gets infoseg (global and local) segments and passes    */
;/*	       them to DosGetMessage and DosPutMessage shared segment.*/
;/*								      */
;/* NOTES:							      */
;/*								      */
;/*    DEPENDENCIES:  NONE					      */
;/*								      */
;/*    RESTRICTIONS:  NONE					      */
;/*								      */
;/*    PATCH LABEL:						      */
;/*								      */
;/* ENTRY POINTS:  MSGINIT					      */
;/*								      */
;/* INTERNAL REFERENCES:					      */
;/*								      */
;/* EXTERNAL REFERENCES:					      */
;/*			  DOSGETINFOSEG 			      */
;/*								      */
;/*********************** END OF SPECIFICATIONS ***********************/
PAGE
;
;***********************************************************************
; PUBLICS
;***********************************************************************
public	GlobalSeg
public	LocalSeg

;***********************************************************************
; EXTERNALS
;***********************************************************************
;
extrn dosgetinfoseg:far
extrn doswrite:far
;
SUBTTL Includes
	PAGE
;---------------------------------------------------------
; INCLUDES HERE
;---------------------------------------------------------
.XLIST
	INCLUDE error.inc		;ERROR CODES
	INCLUDE error2.inc		;new ERROR CODES
	INCLUDE basemaca.inc		;DOS MACROS
	include dc1segs.inc					; DCR 704
.LIST
;
SUBTTL Data and Code Segment Definitions and Local Variables
	PAGE
;**************************************************************************
; THE FOLLOWING DATA SEGMENT DECLARATION IS USED TO HOLD PTRS TO THE GLOBAL
; DATA SEGMENT AND LOCAL DATA SEGMENT (shared)
;*****************************************************************************
IFNDEF FamilyAPI
initseg SEGMENT
ELSE
initseg SEGMENT word public 'data'
ENDIF	;FamilyAPI
       GlobalSeg	DW	0	       ; store global segment
       LocalSeg 	DW	0	       ; store local segment
initseg ENDS
;****************************************************************************

IFNDEF	FamilyAPI
dseg	SEGMENT 			; ##1			  DCR 704
ELSE
dseg	SEGMENT word public 'data'      ; ##1
ENDIF	;FamilyAPI
	extrn	RESULT:word			;RESULT OF DOSWRITE (#BYTES WRITTEN)
dseg	ENDS



initcode    SEGMENT
	ASSUME	CS:initcode, ds:initseg, es:nothing
;***************************************************************************
;	DECLARE MSGINIT       PUBLIC
;	DECLARE MSGINIT       PROC FAR
;***************************************************************************
	PROCEDURE	msginit,FAR
;
SUBTTL Msginit Main Routine
	PAGE

   pushf			;save flags
   push cx			;save registers
   push dx			;
   push ds			;
   push es			;
   push si			;
   push di			;

   mov	ax,initseg		;Get addressability to INITSEG
   mov	ds,ax

   assume ds:initseg

   push ds			;sel:off to common GDTINFO selector
   push offset globalseg	;
   push ds			;sel:off to common LDTINFO selector
   push offset localseg 	;
   call DOSGETINFOSEG

   mov	 ax,-1		;good ret. = non-zero

   pop	di		;restore registers
   pop	si		;
   pop	es		;
   pop	ds		;
   pop	dx		;
   pop	cx		;
   popf 		;restore flags
   ret			;return
msginit endp

initcode    ENDS



CODE16_TUNE1 SEGMENT DWORD USE16 PUBLIC 'CODE'
CODE16_TUNE1 ENDS


;/********************** START OF SPECIFICATIONS **********************/
;/*								      */
;/* SOURCE FILE NAME:  Do_Write 				      */
;/*								      */
;/* DESCRIPTIVE NAME:  Call DosWrite from ring 3.		      */
;/*								      */
;/* COPYRIGHT: IBM						      */
;/*								      */
;/* STATUS: RELEASE 1 LEVEL 1					      */
;/*								      */
;/* FUNCTION:  Calls DosWrite from ring 3, so that it can write to    */
;/*	       the screen.					      */
;/*								      */
;/* NOTES:  This routine can be removed when DosWrite can write to    */
;/*	    standard output from ring 2.			      */
;/*								      */
;/*    DEPENDENCIES:  NONE					      */
;/*								      */
;/*    RESTRICTIONS:  NONE					      */
;/*								      */
;/*    INPUT:							      */
;/*	  AX	 Handle to write to				      */
;/*	  BX	 OFFSET of variable RESULT in dseg		      */
;/*	  CX	 buffer length					      */
;/*	  ES	 SEGMENT of buffer to write (dseg)		      */
;/*	  DI	 OFFSET of buffer to write			      */
;/*								      */
;/*    RETURNS: 						      */
;/*	  AX	 return code from DosWrite			      */
;/*								      */
;/* ENTRY POINTS:  Do_Write					      */
;/*								      */
;/* INTERNAL REFERENCES:					      */
;/*								      */
;/* EXTERNAL REFERENCES:					      */
;/*			  DosWrite				      */
;/*								      */
;/*********************** END OF SPECIFICATIONS ***********************/

CODE16_TUNE1 SEGMENT
	ASSUME	cs:CODE16_TUNE1, ds:initseg, es:nothing
	PROCEDURE	Do_Write, FAR

	PUSH	AX		       ;SAVE HANDLE
	PUSH	ES		       ;SAVE BUFFER SEGMENT (dseg)
	PUSH	DI		       ;SAVE BUFFER OFFSET
	PUSH	CX		       ;SAVE BUFFER LENGTH
	PUSH	ES		       ;SAVE RESULT SEGMENT (dseg)
	PUSH	BX		       ;SAVE RESULT OFFSET

	CALL	DOSWRITE	       ;DO DOS WRITE

	ret

Do_Write endp

CODE16_TUNE1  ENDS
	END							; DCR 704
;	END	msginit 					  DCR 704

