;	[]===========================================================[]
;
;	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
;----------------------------------------------------------------------------
;R01A	05/21/98 KVN	If system not found AWARD external code (XGROUP) in 2MB
;			BIOS then will execute boot block POST to avoid system
;			always hang at 0C8h.This is flash ROM first 128k be
;			crashed but last 128k is OK.
;R03	05/18/98 KVN	Fixed compressed code table(0:6000) will be destroyed
;			when one of combined option ROM size over 64k.That will
;			cause POST hang at decompress or execute BootBlock code.
;R02	12/23/97 KVN	Supported a linear combine ROM space.The old 2MB BIOS
;			ROM space are to be sperate 2 piece of 64KB so if
;			compressed ROM size large than 64KB that will can't be
;			added to BIOS.This feature should be use new CBROM.EXE
;			(v1.16 or later)
;R01	12/01/97 KVN	Added a new POST error code 0C8h to notify system not
;			found AWARD external code (XGROUP).For example BIOS is
;			2MB size and mother board flash BIOS is 1MB that will
;			issue this error during POST
;R00	10/16/96 AVN	Initial Revision. To Support Different BootBlock For
;			INTEL 2M EEPROM	: 16K BootBlock
;			SST 2M EEPROM	: 16K BootBlock
;			ATMEL 2M EEPROM	: 16K BootBlock
;			AMD 2M EEPROM	: 16K BootBlock
;			MXIC 2M EEPROM	:  8K BootBlock

ifdef	Flash_2M_support
if	COMPILE_FOR_BOOTROM_ASM	EQ	1
Extern_execute1:
ifdef	A17_From_KB_Pin						;R124
		call	Enable_KB_Controller
endif;	A17_From_KB_Pin						;R124

Temp_Extra_BIOS_Addres	EQU	8000h
		push	2000h
		call	Enable_Extra_1MBIOS_Hook
		mov	esi,0
		jnz	short @F	;real mode address
		mov	esi,0fff00000h	;protect mode high address
@@:
		movzx	ecx,cx
		shl	ecx,4
		or	esi,ecx
		cld
;---------------- Enter Protect Mode ----------------
                mov     ax,cs
                mov     ds,ax
                assume  ds:dgroup

                lgdt    fword ptr DGROUP:B_GDTR1

                mov     eax,cr0
                or      al,1
                mov     cr0,eax

		jmp	short $+2		;clear prefetch

                mov     ax,B_DATA1_INDEX
                mov     ds,ax                   ; ds = 00000000h
		mov	es,ax

		mov	edi,(Temp_Extra_BIOS_Addres shl 4)
		mov	ecx,8000h
		db	67h
		rep	movsd

;---------------- Leave Protect Mode ----------------
                mov     eax,cr0
                and     al, NOT 1
                mov     cr0,eax
		jmp	short $+2
		push	2000h
		call	Disable_Extra_1MBIOS_Hook
endif;	COMPILE_FOR_BOOTROM_ASM

if	COMPILE_FOR_BOOTROM_ASM	EQ	2
Extern_execute2:
;----- decompress first extra BIOS area (0C000h) -----
		mov	bx,Temp_Extra_BIOS_Addres
		mov	es,bx
		xor	bx,bx
;R03		xor	cx,cx
		xor	ecx,ecx		;R03
		push	cx		;R01 assume no award external code
Expand_ROM_loop:
		add	bx,cx
;R02 start
;R03		jnc	short @F
		jc	short Next_segment	;R03
		test	ecx,0ffff0000h		;R03
		jz	short @F		;R03
Next_segment:					;R03
		mov	cx,es
		add	cx,1000h
		mov	es,cx
		jmp	short Expand_ROM_Next
@@:
;R02 end
;R01 start
	cmp	byte ptr es:[bx+12h],41h	;Is award external code?
	jne	short @F			;No,skip
	pop	ax				;restore flag
	or	al,1				;set fount flag
	push	ax				;store it to stack
@@:
;R01 end
		call	BootBlock_Expand
		jnc	short Expand_ROM_loop

;----- decompress secondary extra BIOS area (0D000h) -----
		mov	bx,es
		add	bx,1000h
		mov	es,bx
		xor	bx,bx
Expand_ROM_Next:				;R02
		xor	cx,cx
Expand_ROM_loop1:
		add	bx,cx
;R01 start
	cmp	byte ptr es:[bx+12h],41h	;Is award external code?
	jne	short @F			;No,skip
	pop	ax				;restore flag
	or	al,1				;set fount flag
	push	ax				;store it to stack
@@:
;R01 end
		call	BootBlock_Expand
		jnc	short Expand_ROM_loop1
;R01 start
	pop	ax			;restore flag
	or	al,al			;check award external code has fount?
;R01A	jnz	short @F		;Yes,fount then jump
;R01A	POST_CODE	0c8h		;POST error code
;R01A	jmp	$			;system halt
;R01A@@:
;R01 end
endif;	COMPILE_FOR_BOOTROM_ASM
endif	;Flash_2M_support
