;	[]===========================================================[]
;
;	NOTICE: THIS PROGRAM BELONGS TO AWARD SOFTWARE INTERNATIONAL(R)
;	        INC. IT IS CONSIDERED A TRADE SECRET AND IS NOT TO BE 	
;	        DIVULGED OR USED BY PARTIES WHO HAVE NOT RECEIVED	
;	        WRITTEN AUTHORIZATION FROM THE OWNER.
;
; 	[]===========================================================[]
;

;----------------------------------------------------------------------------
;Rev	Date	 Name	Description
;----------------------------------------------------------------------------
;R02	03/25/98 RAX	Added code for use MASM6.X compiler APM.ASM.
;R01	12/24/97 RAX	Fixed mistake.
;R00	12/19/97 RAX	Initial Revison for move APM to SMBASE.

ifdef	PM_SUPPORT
ifdef	ADVANCE_POWER_MANAGEMENT
ifdef	APM_IN_SMBASE

;****************************************************************
;*								*
;*	COMPILING STAGE 1					*
;*								*
;*	MISCELLANEOUS DEFINITION				*
;*								*
;****************************************************************
IF	COMPILE_FOR_APMBIOS EQ 1
		extrn	APM_SMI_Start:near
		extrn	APM_SMI_End:near
		extrn	APM_SMI_Handler:far
;R02 start
		extrn	Err_Checking_Routines:near
		extrn	APM_FUNC_TBL:near
;R02 end
ENDIF	;COMPILE_FOR_APMBIOS EQ 1

;************************************************************************
;*									*
;*	COMPILING STAGE 2					*
;*	POST INTERFACE MODULE						*
;*									*
;************************************************************************

IF	COMPILE_FOR_APMBIOS EQ 2
;[]========================================================================[]
;Procedure:	Move_APMCode
;Function:	Move APM code to SMBASE
;Input:		ES:SMBASE_SEGMENT
;Output:	none
;[]========================================================================[]
Move_APMCode	PROC	Near

		push	ds
		push	es
		mov	ax, Xgroup
		mov	ds, ax

;R02 start
		mov	si, offset Err_Checking_Routines
		mov	cl, 8h
		call	Adjust_Func_Table
		mov	si, offset APM_FUNC_TBL
		mov	cl, 14h
		call	Adjust_Func_Table
;R02 end
		mov	si, offset XGroup:APM_SMI_Start
		mov	cx, offset XGroup:APM_SMI_End
		sub	cx, si
		mov	di, SMI_Handler_Len

		rep	movsb

		pop	es
		pop	ds
		ret
Move_APMCode	ENDP
;R02 start
Adjust_Func_Table:
		add	word ptr DS:[si], SMI_Handler_Len
		add	si,2
		loop	Adjust_Func_Table
		ret
;R02 end
ENDIF	;COMPILE_FOR_APMBIOS EQ 2

;****************************************************************
;*								*
;*	COMPILING STAGE 3					*
;*	RUN-TIME EXECUTION CODES RESIDENT AT SMI RAM		*
;*								*
;****************************************************************
IF	COMPILE_FOR_APMBIOS EQ 3
		Public	Chk_Kernel_SMI
Chk_Kernel_SMI	PROC	NEAR

;R01		stc			;Assume not kernel call
		cmp	[Software_SMI_Type], APM_SMI
		stc			;Assume not kernel call	;R01
		jne	short Not_APMSMI
		mov	si, SMI_Handler_Len
		call	si
		clc
Not_APMSMI:
		ret
Chk_Kernel_SMI	ENDP

ENDIF	;COMPILE_FOR_APMBIOS EQ 3

endif	;APM_IN_SMBASE
endif	;ADVANCE_POWER_MANAGEMENT
endif	;PM_SUPPORT
