;	[]===========================================================[]
;
;	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/12/99 BAR 	Suport Windows NT update BIOS.
;R01	02/03/99 BAR 	Support Flash_Part_Erase .
;R00	01/28/99 BAR	Support update ESCD DMI in SMM mode.
;			define switch "Flash_IN_SMBASE"

ifdef	Flash_IN_SMBASE

;****************************************************************
;*								*
;*	COMPILING STAGE 1					*
;*								*
;*	MISCELLANEOUS DEFINITION				*
;*								*
;****************************************************************
IF	COMPILE_FOR_APMBIOS EQ 1
ifdef	APM_IN_SMBASE
		extrn	APM_SMI_Start:near
		extrn	APM_SMI_End:near
		extrn	APM_SMI_Handler:far
		extrn	Err_Checking_Routines:near
		extrn	APM_FUNC_TBL:near
		extrn	APM_Handler_Len:Abs
endif;	APM_IN_SMBASE

		extrn	SMI_FLASH_START:near
		extrn	SMI_FLASH_End:near
		extrn	SMI_FLASH_Handler:far
		extrn	NO_OF_Flash_CALL:Abs
		extrn   Flash_FUNC_TBL:near

ENDIF	;COMPILE_FOR_APMBIOS EQ 1

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

IF	COMPILE_FOR_APMBIOS EQ 2
;[]========================================================================[]
;Procedure:	Move_FlashCode
;Function:	Move Flash code to SMBASE
;Input:		ES:SMBASE_SEGMENT
;Output:	none
;[]========================================================================[]
Move_FlashCode	PROC	Near
		push	ds
		push	es
		mov	ax,seg XGROUP
		mov	ds, ax

		mov	si, offset Flash_FUNC_TBL
		mov	cl, NO_OF_Flash_CALL
		call	Adjust_Flash_Func_Table

		mov	si, offset XGroup:SMI_FLASH_START
		mov	cx, offset XGroup:SMI_FLASH_End
		sub	cx, si					;flash rotuine size
ifdef	APM_IN_SMBASE
		mov	di, SMI_Handler_Len + APM_Handler_Len	;Flash handler start
else;	APM_IN_SMBASE
		mov	di, SMI_Handler_Len 
endif;	APM_IN_SMBASE
		rep	movsb			;move into SMBASE area

		pop	es
		pop	ds
		ret
Move_FlashCode	ENDP
;R02 start
Adjust_Flash_Func_Table:
ifdef	APM_IN_SMBASE
		add	word ptr DS:[si], SMI_Handler_Len + APM_Handler_Len
else;	APM_IN_SMBASE
		add	word ptr DS:[si], SMI_Handler_Len
endif;	APM_IN_SMBASE
		add	si,2
		loop	short Adjust_Flash_Func_Table
		ret
;R02 end
ENDIF	;COMPILE_FOR_APMBIOS EQ 2

ifndef	APM_IN_SMBASE
;****************************************************************
;*								*
;*	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

		cmp	[Software_SMI_Type], SMI_FlashRead
		jb	Not_FlashSMI
;R01 		cmp	[Software_SMI_Type], SMI_FlashProgram
;R02		cmp	[Software_SMI_Type], SMI_FlashPartErase	;R01
		cmp	[Software_SMI_Type], SMI_Auto_Flash	;R02
		ja	Not_FlashSMI
From_IO_Port1:							;R02
		mov	si, SMI_Handler_Len
		call	si
		clc
		ret
Not_FlashSMI:
;R02 - start
ifdef NT_Flash
		push	ax
		in	al,0b2h
		cmp	al, SMI_FlashRead
		jb	Not_IOport_SMI
		cmp	al, SMI_Auto_Flash
		ja	Not_IOport_SMI
		pop	ax
		jmp	From_IO_Port1
Not_IOport_SMI:
		pop	ax
endif; NT_Flash
;R02 - end
		stc			;Assume not kernel call	
		ret
Chk_Kernel_SMI	ENDP

ENDIF	;COMPILE_FOR_APMBIOS EQ 3
endif	;APM_IN_SMBASE

endif	;Flash_IN_SMBASE


