;       SCCSID = @(#)kbdsysi.asm	6.1 90/11/17
  Page	58,132
  Title	  INITKBD - Prepare for OS/2 Keyboard Device Driver

SCCSID	equ	"@(#)kbdsysi.asm	13.4 90/09/17"

;@@ B ********** START OF SPECIFICATIONS ******************************
;*								      *
;* SUBROUTINE NAME: InitKbd					      *
;*								      *
;* DESCRIPTIVE NAME: Save the number of optionally prepared code      *
;*		pages for the keyboard device driver.		      *
;*								      *
;* FUNCTION:	This routine is passed the number of optional code    *
;*		pages allowed, increments this count, and stores      *
;*		this in an initdata segment so that SysInit may pass  *
;*		the number of code pages to prepare to the device     *
;*		driver during initialization.			      *
;*								      *
;* NOTES:	This routine, while called by SYSINIT, is owned by    *
;*		the Keyboard Device Driver.  If any specs. change     *
;*		in the DD concerning these data areas then this	      *
;*		routine must be updated as well.		      *
;*								      *
;*		SYSINIT expects to be returned the address of a	      *
;*		parm list which will later be passed to the device    *
;*     ##	driver.  Currently, the "parm list" address is	      *
;*     ##	actually the segment and zero offset of the	      *
;*     ##	InitData Seg. containing the codepage count.	      *
;*								      *
;*     ##	The count of code pages available in the system	      *
;*     ##	(including the "hardware default") is stored	      *
;*     ##	temporarily in the first word of this data area.      *
;*								      *
;* ENTRY POINT: InitKbd						      *
;*								      *
;*    LINKAGE:	NEAR						      *
;*								      *
;* INPUT:	AL = Number of code pages supported.		      *
;*								      *
;* EXIT-NORMAL: Carry Flag = 0 .				      *
;*		AX    = 0 or Non-Fatal Message ID.		      *
;*		BX:CX = Address of parm list to be passed to the KBD  *
;*			DD at initialization time.  Currently, this   *
;*			register pair contains the Segment to the     *
;*			data area containing the number of prepared   *
;*			code pages.				      *
;*								      *
;* EXIT-ERROR:	None.						      *
;*								      *
;* EFFECTS:	The number of optionally prepared code pages + 1 is   *
;*		stored in a temprorary data segment.		      *
;*								      *
;* INTERNAL REFERENCES:						      *
;*    ROUTINES: None.						      *
;*								      *
;* EXTERNAL REFERENCES:						      *
;*    ROUTINES: None.						      *
;*								      *
;*************** END OF SPECIFICATIONS ********************************

.286p
.sall
  ;The following files are included, but xlist'd out:
  ;	  dosseg.inc  -	 Sysinit segment names.
  ;	  basemaca.inc - base macros
  ;	  osmaca.inc - os/2 kernel macros
.xlist
  include dosseg.inc	;Sysinit segment names.
  include basemaca.inc	;base macros
  include fnodev.inc
  include osmaca.inc	;os/2 kernel macros
.list

	ModName  , FNO_KBDSYSI_ASM


INITBSS Segment			;## Include in r/o, discardable code
				;##  segment.
	public PrepCPs		;## Make it public.
PrepCPs	dw	?		;## This is the number of optionally
				;## prepared code pages + 1 to adjust
				;## for the hardware default.
INITBSS Ends

    FARCODE INIT

INITCODE segment		;## This code goes with SYSINIT.

Procedure InitKbd
  SaveReg <DX,SI,DI,DS,ES>	;## Save caller's registers.

  ;AL contains the number of optional code pages, while AH indicates
  ; whether a real mode session is supported.

  Inc AL			;## Account for the hardware default CP.
  Push AX			;## Save the input parms.

  DosInitContext  DS		;## Establish addressability to data group
				;## containing storage for the number of
				;## prepared codepages.
  Xor AH, AH			;## Zero high byte.
  Mov Word Ptr PrepCPs, AX	;## Save the optional code page count in the
				;## new segment.
  Pop AX			;## Restore the input parms. (already
				;##  adjusted for "hw default" code page).
  Mov BX, DS			;## Put the main data area selector into
				;##  the proper returning register.
  Mov CX, Offset PrepCPs	;## Set return offset value to zero.
  Xor AX, AX			;## Indicate no errors to report.
				;## (This also clears the carry flag,
				;##  indicating no errors).
  RestoreReg <ES,DS,DI,SI,DX>	;## Restore caller's registers.

  RET				;## Return to caller.
EndProc InitKbd

INITCODE ends
		END
;@@ E *****
