;	[]===========================================================[]
;
;	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
;----------------------------------------------------------------------------
;R16	03/14/98 RAY	Add macro switch for item needs no help
;R15	02/14/98 RAY	Add dummy MACROs:
;
;			Support new ?feature.asm format in which the help
;			offset of each item is pointed to XGROUP.
;
;			This is done to let ?feature.asm works both in BIOS
;			4.51 & 4.60(supports Multi-Languages)
;
;R14	05/29/97 KVN	Added a new segment for store more BIOS code
;R13	03/26/97 KEN	Add "USB_SMI_AT_E000" definition.
;R10A	11/30/96 RAY	No need to add R10
;R12	11/04/96 DNL	Added "E000_SMI_SUPPORT" definition support
;R11	08/21/96 KEN	Add macro SMI_F0CALL for SMI handler to call F000 codes.
;R10	08/14/96 RAY	Add switch MASM611 for compiling DMIPOST.ASM using
;			MASM 6.X
;R09	01/10/96 RCH	ESS1788/1888 use port 0E0H & 0E1H as register control
;			port, so NEWIODELAY default use 0EBH instead of 0E1H
;R08A	10/12/95 RCH	It's not necessary to output word for delay
;R08	10/11/95 RCH	Some chipsets or M/B use port 0E1H , so the port for 
;			NEWIODELAY should be changeable. ( for example, ECS/
;			SiS551X with CIRRUS 5436 VGA card )
;R07A	09/06/95 RCH	BIOS never do far call under protected mode 
;R07	08/22/95 DNL	Added protection mode F000_Call support
;R06	06/13/95 KVN	Reduce Post_func_call and F000_call code size
;R04	04/18/94 RAY	add FAR_CALL macro
;R03	02/24/93 RCH	Always use 0E1H to instead of 0EBH
;R02	05/05/92 RCH	Some chipset use port 0EBh , So we can't use this port
;			 to make I/O delay. ( such as TOPCAT,SCAMP )
;R01	OCT-15-90 SMS	adding copyright stmt.
;R00	06/01/90 TIM    Initial release for 4.0

;[]-----------------------------------[]
;
;   Award Software 386/486 BIOS
;          Common Macros
;   Initial Revision 17-Apr-1990
;
;[]-----------------------------------[]


		INCLUDE	BIOS.CFG
;R10A ifndef	MASM611			;R10
INVD	MACRO			       
	db	0fh,08h
	ENDM

WBINVD	MACRO
	db	0fh,09h
	ENDM

RDMSR	MACRO
	db	0Fh,32h
	ENDM

WRMSR	MACRO
	db	0Fh,30h
	ENDM
;R10A endif	;MASM611		;R10


;
;	Timing macros
;

SIODELAY	MACRO				; SHORT IODELAY
		jmp	short $+2
		ENDM

IODELAY		MACRO				; NORMAL IODELAY
		siodelay
		siodelay
		ENDM

WAFORIO		MACRO				; NORMAL IODELAY
		siodelay
		siodelay
		siodelay
		siodelay
		siodelay
		siodelay
		ENDM

NEWIODELAY     MACRO
;R03           OUT 0EBh, AX                                               
;R09 ifdef	PORT_E1H_BE_USED	      	;R08
		out	0ebh,al                 ;R08A
;R08A		out	0ebh,ax                 ;R08                              
;R09 else;	PORT_E1H_BE_USED	      	;R08
;R09 		out	0e1h,al			;R08A
;R08A		out	0e1h,ax			;R08
;R09 endif;	PORT_E1H_BE_USED	      	;R08
	       ENDM  

;
;	Other macros
;

FAR_JMP		MACRO	OFF_SET, SEG
		DB	0EAH
		DW	OFF_SET
		DW	SEG
		ENDM

;R04 - starts
FAR_CALL	MACRO	OFF_SET, SEG
		DB	09Ah
		DW	OFF_SET
		DW	SEG
		ENDM
;R04 - ends

;[]==============================================================[]
; 
; ROM_CALL:
;
; 	Performs a call to a routine while there is not stack.
;	The routine called can use no stack but can do a normal RET
;
;DESTROYS: SP
;
;EXAMPLES:
;
;		ROM_CALL Any_Rtn
;		ROM_CALL <dword ptr ss:[bp+di]>
;
;Author: Tim Lewis
;Date:	 18 April, 1990
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM  | 18-Apr-90 | Initial revision
;
;[]==============================================================[]

ROM_CALL	MACRO	RTN_NAME
		LOCAL	RTN_ADD
		mov	sp,offset DGROUP:RTN_ADD
		jmp	RTN_NAME
RTN_ADD:	dw	DGROUP:$+2
		ENDM

FCALL		MACRO	OFF_SET
		DB	09AH
		DW	offset dgroup:OFF_SET
		DW	0F000h
		ENDM

F000_call	MACRO	func_addr
		LOCAL	Ret_addr,_P11		;R07
;R07		LOCAL	Ret_addr
;R07 - start
;R07A		push	eax
;R07A		mov	eax,cr0
;R07A		test	eax,1
;R07A		pop	eax
;R07A		jz	short _P11
;R07A
;R07A		push	offset cs:Ret_addr
;R07A		push	offset Ret_E_Seg
;R07Aif ((.TYPE func_addr) and 10h)			;func_addr is register?
;R07A		push	func_addr		;Yes,direct push
;R07Aelse
;R07A		push	offset func_addr
;R07Aendif
;R07A		FAR_JMP <OFFSET F000_VECT>,010h
_P11:
;R07 - end
;R06		push	0e000h
;R06		push	offset cs:Ret_addr
;R06		push	offset F000_func_end
		push	cs			;R14
		push	offset cs:Ret_addr	;R14
if ((.TYPE func_addr) and 10h)			;func_addr is register?
		push	func_addr		;Yes,direct push
else
		push	offset func_addr
endif
;R06		FAR_JMP	<OFFSET F000_VECT>,0F000H
;R14		push	offset cs:Ret_addr	;R06
;R14		jmp	EGROUP:F000_call_proc	;R06
		far_jmp	<offset F000_call_proc>,0e000h	;R14
Ret_addr:
		ENDM

F000_far_call	MACRO	func_addr
		LOCAL	Ret_addr
		push	0e000h
		push	offset cs:Ret_addr
		push	0f000h
		push	offset F000_func_end
if ((.TYPE func_addr) and 10h)			;func_addr is register?
		push	func_addr		;Yes,direct push
else
		push	offset func_addr
endif
		FAR_JMP	<OFFSET F000_VECT>,0F000H
Ret_addr:
		ENDM

POST_func_call	MACRO	func_addr
		LOCAL	P_Ret_addr
;R06		push	0f000h
;R06		push	offset cs:P_Ret_addr
;R06		push	offset POST_func_end
		push	cs			;R14
		push	offset cs:P_Ret_addr	;R14
if ((.TYPE func_addr) and 10h)			;func_addr is register?
		push	func_addr		;Yes,direct push
else
		push	offset func_addr
endif
;R06		FAR_JMP	<OFFSET POST_VECT>,0e000h
;R14		push	offset cs:P_Ret_addr	;R06
;R14		jmp	DGROUP:Post_call_proc	;R06
		far_jmp	<offset Post_call_proc>,0f000h	;R14
P_Ret_addr:
		ENDM

POST_far_call	MACRO	func_addr
		LOCAL	P_Ret_addr
		push	0f000h
		push	offset cs:P_Ret_addr
		push	0e000h
		push	offset POST_func_end
if ((.TYPE func_addr) and 10h)			;func_addr is register?
		push	func_addr		;Yes,direct push
else
		push	offset func_addr
endif
		FAR_JMP	<OFFSET POST_VECT>,0e000h
P_Ret_addr:
		ENDM

;R11 - start

SMI_F0CALL	MACRO	Func_Addr
		LOCAL	Ret_Addr
ifdef	E000_SMI_SUPPORT				;R12
		F000_Call	Func_Addr		;R12
else	;E000_SMI_SUPPORT				;R12
ifdef	USB_SMI_AT_E000					;R13
		F000_Call	Func_Addr		;R13
else	;USB_SMI_AT_E000				;R13
if ((.TYPE Func_Addr) and 10h)			;Func_Addr is register?
		push	Func_Addr		;Yes,direct push
else
		push	offset Func_Addr
endif
		push	(offset Ret_Addr - offset SMI_Handler_Start)
		jmp	SMI_F0call_Proc
Ret_Addr:
endif	;USB_SMI_AT_E000				;R13
endif	;E000_SMI_SUPPORT				;R12
		ENDM

ifdef	E000_SMI_SUPPORT				;R12
SMI_OFFSET	EQU	<>				;R12
else	;E000_SMI_SUPPORT				;R12
ifdef	USB_SMI_AT_E000					;R13
SMI_OFFSET	EQU	<>				;R13
else	;USB_SMI_AT_E000				;R13
SMI_OFFSET	EQU	<- offset SMI_Handler_Start>
endif	;USB_SMI_AT_E000				;R13
endif	;E000_SMI_SUPPORT				;R12

;R11 - end

;R14 start
Xcall		MACRO	func_addr
		LOCAL	X_Ret_addr
		push	cs
		push	offset cs:X_Ret_addr
if ((.TYPE func_addr) and 10h)			;func_addr is register?
		push	func_addr		;Yes,direct push
else
		push	offset func_addr
endif
		far_jmp	<offset Xcall_proc>,Xgroup_Segment
X_Ret_addr:
		ENDM
;R14 end

;R15 - starts
INCLUDE_LANGUAGES	MACRO
			ENDM

DECLARE_MULTI_LANGUAGE	MACRO
			ENDM

DEFINE_MSG	MACRO	MESSAGE_LABEL
		Public	MESSAGE_LABEL
MESSAGE_LABEL:
		ENDM

		NEED_STD_HELP	EQU	1			;R16
		NO_NEED_HELP	EQU	0			;R16
DEFINE_ITEM_MSG	MACRO	Lang_Tbl, Item_Name, Item_Val, MultiLang_Help, Std_Help_Flg
		Public	Lang_Tbl&_Lang_Tbl
Lang_Tbl&_Lang_Tbl:
	IFNB	<Std_Help_Flg>
;R16		db	1
		db	Std_Help_Flg				;R16
	ENDIF
		ENDM
;R15 - ends
