;	[]===========================================================[]
;
;	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.
;
; 	[]===========================================================[]
;

;		PAGE	60,132
;		TITLE	POST  -- 386 ROM/BIOS POST
;----------------------------------------------------------------------------
;Rev	Date	 Name	Description
;----------------------------------------------------------------------------
;R06	04/30/98 JKY	Added HPM_SUPPORT
;R05	06/05/98 PAL	Fixed Simple Boot abnormal after restart
;R04	04/14/98 DNL	Fixed resume from S4 failure 
;R03	03/19/98 DNL	Fixed resume from S4 failure 
;R02	03/19/98 DNL	Fxied coding mistake
;R01	03/11/98 DNL	No memory size display while system warm boot
;R00	03/11/98 DNL	Fully support SIMPLE BOOT spec. & speed up S4/BIOS resume


.386P
;[]-----------------------------------[]
;
;   Award Software Elite BIOS
;	  Simple Boot Self-Test
;   Initial Revision 03-Mar-1998
;
;
;	Copyright (C) 1991
;	Award Software, Inc.
;	All Rights Reserved
;[]-----------------------------------[]

.XLIST

		INCLUDE BIOS.CFG

ifndef	No_Support_4_IDE
Support_4_IDE		EQU	1
endif	;No_Support_4_IDE
ifdef	RPB_ENABLED
	    include rpb.cfg
endif	;RPB_ENABLED

		INCLUDE COMMON.EQU
		INCLUDE POST.EQU
		INCLUDE ATORGS.EQU
		INCLUDE PORT61.EQU
		INCLUDE 8042.EQU
		INCLUDE 8259.EQU

		INCLUDE COMMON.MAC
		INCLUDE POST.MAC
		INCLUDE USERINT.MAC
		INCLUDE BTROMSEG.EQU

ifdef	ACPI_SUPPORT
		EXTRN	TEST_INDEX:ABS
		EXTRN	GDT_LOC:ABS

ifndef	HPM_SUPPORT					;R06
		extrn	Ct_PMRAM_Use_SYSRAM:near	;R03
endif	;HPM_SUPPORT					;R06
		extrn	XCALL_PROC:near			;R02
		extrn	Issue_System_Reset:near
		extrn	Superio_Early_Init:near
		extrn	F000_Set_CMOS:NEAR
		extrn	F000_Buffer_8042_Full:NEAR
		extrn	F000_Out_8042_Full:NEAR
		extrn	IntCache_Status:near
		extrn	F000_Cpu_Cache:near
		extrn	PM_Init:near
ifndef	HPM_SUPPORT					;R06
		extrn	Ct_PM_Final_Init:near		;R04
endif	;HPM_SUPPORT					;R06
		extrn	Try_Actual_Cache:near
ifdef	S4_SUPPORT
		extrn	Notebook_Resume:near
endif	;S4_SUPPORT
ifdef	USB_SUPPORT				
		extrn	Usb_Final_Init:near
endif	;USB_SUPPORT				
		Extrn	Check_PS2_Mouse_Support:NEAR
		EXTRN	TEST_MEM_MSG:NEAR
		EXTRN	OK_Msg:NEAR
		EXTRN	A20_OFF:NEAR
		EXTRN	KBD_A20_OFF:NEAR
		EXTRN	Ct_Remap:NEAR
		EXTRN	Get_Switch:NEAR
		EXTRN	SYSTEM5_BYTE:BYTE
		EXTRN	Enable_Prot_Mode:NEAR
		EXTRN	E000_Back_Real_Mode:NEAR
		EXTRN	Shutdown_From_Mem_Test:NEAR 
if	BIOS_SUPPORT_IBM_CPU
		EXTRN	IBMCPU_Cacheable_Size:NEAR
endif	;BIOS_SUPPORT_IBM_CPU
		EXTRN	Prg_K5_Write_Allocate:NEAR
		EXTRN	Ct_Ext_Mem_Limit:NEAR
		EXTRN	F000_GetItem_Value:NEAR
		EXTRN	Set_Cpu_MtRR:NEAR
		EXTRN	Read_Memory:NEAR
		EXTRN	DISP_DWORD_INT6:NEAR
		EXTRN	Disp_Str_In_POST:NEAR
		EXTRN	F000_Vcrlf:NEAR
		EXTRN	E000_A20_On:NEAR
		EXTRN	E000_Enter_Prot_mode:NEAR
		EXTRN	ExtCache_Item:NEAR
		EXTRN	Later_cache_Sizing:NEAR

ifdef	KLAMATH_CPU_ONLY				
		EXTRN	ConfigurePProL2Cache:NEAR
endif	;KLAMATH_CPU_ONLY				
ifdef	P6_BIOS_ONLY
		EXTRN	Init_Apic:NEAR
endif;	P6_BIOS_ONLY
ifdef	USB_SUPPORT
		EXTRN	Usb_Init:NEAR
endif	;USB_SUPPORT
ifdef	SPECIAL_SHARE_MEMORY_SHOW					
		EXTRN	Ct_Share_Memory_Size:NEAR
endif	;SPECIAL_SHARE_MEMORY_SHOW					
ifndef	KBC_KBDMOUSE_SWAP
		EXTRN	Special_KBC_Init:NEAR
endif;	KBC_KBDMOUSE_SWAP

		extrn	CPU_Cache:near
		EXTRN	SET_CMOS:NEAR
		EXTRN	HALTSYSTEM:NEAR
		EXTRN	Ram_Post_Tests:NEAR

		EXTRN	POST_3S:NEAR
		EXTRN	POST_4S:NEAR
		EXTRN	POST_5S:NEAR
		EXTRN	POST_6S:NEAR
		EXTRN	POST_7S:NEAR
		EXTRN	POST_8S:NEAR
		EXTRN	POST_9S:NEAR
		EXTRN	POST_10S:NEAR
		EXTRN	POST_11S:NEAR
		EXTRN	POST_12S:NEAR
		EXTRN	POST_13S:NEAR
		EXTRN	POST_14S:NEAR
		EXTRN	POST_15S:NEAR
		EXTRN	POST_16S:NEAR
		EXTRN	POST_17S:NEAR
		EXTRN	POST_18S:NEAR
		EXTRN	POST_19S:NEAR
		EXTRN	POST_20S:NEAR
		EXTRN	POST_21S:NEAR
		EXTRN	POST_22S:NEAR
		EXTRN	POST_23S:NEAR
		EXTRN	POST_24S:NEAR
		EXTRN	POST_25S:NEAR
		EXTRN	POST_26S:NEAR
		EXTRN	POST_27S:NEAR
		EXTRN	POST_28S:NEAR
		EXTRN	POST_29S:NEAR
		EXTRN	POST_30S:NEAR
		EXTRN	POST_48S:NEAR
		EXTRN	POST_49S:NEAR
		EXTRN	POST_50S:NEAR
		EXTRN	POST_51S:NEAR
		EXTRN	POST_52S:NEAR
		EXTRN	POST_53S:NEAR
		EXTRN	POST_54S:NEAR
		EXTRN	POST_55S:NEAR
		EXTRN	POST_56S:NEAR
		EXTRN	POST_57S:NEAR
		EXTRN	POST_58S:NEAR
		EXTRN	POST_59S:NEAR
		EXTRN	POST_60S:NEAR
		EXTRN	POST_61S:NEAR
		EXTRN	POST_62S:NEAR
		EXTRN	POST_63S:NEAR
		EXTRN	POST_64S:NEAR
		EXTRN	POST_65S:NEAR
		EXTRN	POST_66S:NEAR
		EXTRN	POST_67S:NEAR
		EXTRN	POST_68S:NEAR
		EXTRN	POST_69S:NEAR
		EXTRN	POST_70S:NEAR
		EXTRN	POST_71S:NEAR
		EXTRN	POST_72S:NEAR
		EXTRN	POST_73S:NEAR
		EXTRN	POST_74S:NEAR
		EXTRN	POST_75S:NEAR
		EXTRN	POST_76S:NEAR
		EXTRN	POST_77S:NEAR
		EXTRN	POST_78S:NEAR
		EXTRN	POST_79S:NEAR
		EXTRN	POST_80S:NEAR
		EXTRN	POST_81S:NEAR
		EXTRN	POST_82S:NEAR
		EXTRN	POST_83S:NEAR
		EXTRN	POST_84S:NEAR
		EXTRN	POST_85S:NEAR
		EXTRN	POST_86S:NEAR
		EXTRN	POST_87S:NEAR
		EXTRN	POST_88S:NEAR
		EXTRN	POST_89S:NEAR
		EXTRN	POST_90S:NEAR
		EXTRN	POST_91S:NEAR
		EXTRN	POST_92S:NEAR
		EXTRN	POST_93S:NEAR
		EXTRN	POST_94S:NEAR
		EXTRN	POST_95S:NEAR
		EXTRN	POST_96S:NEAR
		EXTRN	POST_97S:NEAR
		EXTRN	POST_98S:NEAR
		EXTRN	POST_99S:NEAR

		extrn	F000_func_end:Near
		extrn	F000_VECT:Near
endif	;ACPI_SUPPORT

;Macro for far calling from E-segment and the called routine is in F-segment
F000_call	MACRO	func_addr
		LOCAL	Ret_addr
		push	0e000h
		push	offset cs:Ret_addr
		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

;[]---------------------------[]
;
;   Stack init
;
;[]---------------------------[]

BIOS_STK	SEGMENT USE16 AT 0H
		ORG	400H
BIOSSTK_TOP	LABEL	WORD
		ORG	5B00H
POSTSTK_TOP	LABEL	WORD

BIOS_STK	ENDS

;[]---------------------------[]
;
;   Low memory init (1st 64k)
;
;[]---------------------------[]

G_RAM		SEGMENT USE16 AT 0

		ORG	04H*4
		INCLUDE SEG_0.INC

		ORG	400H
		INCLUDE G_RAM.INC

G_RAM		ENDS
EGROUP		GROUP	ECODE
DGROUP		GROUP	FCODE
ECODE		SEGMENT USE16 PARA PUBLIC 'ECODE'
		ASSUME	CS:EGROUP,DS:G_RAM,ES:EGROUP

ifdef	ACPI_SUPPORT
if	Quick_POST_Flag		EQ	1
;[]==============================================================[]
;
; Quick_Mem_Init:
;
;	Find and display the size of yotal memory  
;	which also happens to clear memory.
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		Public	Quick_Mem_Init
Quick_Mem_Init	Proc	Near

	;Before memory sizing , we must program chipset's remap feature if needed

		F000_call	Ct_Remap

		cli

		mov	ax,G_RAM		; setup ds point to low ram
		mov	ds,ax

		mov	ax,word ptr BASE_MEMORY[bp] ; move orig. amount to 40: area
		mov	Size_Sysram,ax

		cmp	ax,200h 			; >512K memory?
		jbe	short p48_5

		or	byte ptr INFO_FLAG[bp],EXT_128KB
p48_5:
		and	byte ptr CMOS_STATUS[bp], NOT MEM_STATUS

;[]==============================================================[]
;	Here we will size extended memory, starting at just over
;	the 1M boundary. We will continue until we fail to read
;	what we write or we come to the 64M boundary.
;[]==============================================================[]

		xor	ax,ax
		mov	ds,ax			;segment at 0

	;save data to avoid destoried by memory sizing due to wrap-around
		push	dword ptr ds:[0FFF8H]
		push	dword ptr ds:[0FFFCH]

	;write a pre-defined pattern to check wrap-around
		mov	dword ptr ds:[0FFF8H],12345678H

		mov	ax,G_RAM
		mov	ds,ax

;	Go into protected mode...

		call	Enable_Prot_Mode	; enable protected mode
		jc	Exit_Mem_Sizing

;	Size extended memory from 1Mb

		xor	eax,eax
		mov	ax,10h
p48_62:
		mov	esi,TEST_INDEX
		add	esi,GDT_LOC
		mov	byte ptr ds:[esi+HIBASE+20000h],al
		mov	byte ptr ds:[esi+MSBASE+20000h],ah

		mov	si,TEST_INDEX
		mov	es,si			; es = test segment

		mov	dword ptr es:[0fff8h],0 	; write data to memory
		mov	dword ptr es:[0fffch],eax	; flush bus

		cmp	dword ptr ds:[0fff8h], 12345678h
		jne	short P48_64

		cmp	dword ptr es:[0fff8h],0 	; memory exist?
		mov	dword ptr es:[0fff8h],0 	; clear offboard latches
		jne	short p48_64			; end of memory

		mov	dword ptr es:[0fff8h],0ffffffffh ; write data into memory
		mov	dword ptr es:[0fffch],eax	 ; flush bus
		cmp	dword ptr es:[0fff8h],0ffffffffh ; memory exist??
		mov	dword ptr es:[0fff8h],0ffffffffh ; clear off board parity latches
		jne	short p48_64			 ; jump if no more mem found

		mov	dword ptr es:[0fff8h],0 	 ; write data into memory
		mov	dword ptr es:[0fffch],eax	 ; flush bus
		cmp	dword ptr es:[0fff8h],0 	 ; memory exist??
		mov	dword ptr es:[0fff8h],0 	 ; clear offboard parity latches
		jne	short p48_64			 ; jump if no more mem found

p48_623:

		inc	ax			; increment 64k mem count

ifdef	MAX_DRAM_SIZE
		cmp	ax,MAX_DRAM_SIZE	; DRAM size limit
else;	MAX_DRAM_SIZE
 		cmp	ax,MAX_MEM_SIZE*4*4	; (400H*16)  1Gb yet?
endif;	MAX_DRAM_SIZE

		jae	short P48_64		; test only up to 256Mb
		jmp	p48_62

;	Enable parity

p48_64:

;	Save amount found

		sub	ax,10h			; ax = no. of 64k chunk above 1M
		shl	eax,6			; change to 1K
		mov	EXT_MEM_SIZE[bp],eax	; save memory found
		cmp	eax,0ffffh		; over 64Mb
		jbe	short @F		; No.
		mov	ax,0ffffh		; set 65535Kb max.
@@:
		and	ax,0FFC0h
		mov	cx,ax			; save orginial size

;	Write information to the screen...

p48_65:
		call	Shutdown_From_Mem_Test			; back to real mode...

		F000_call	Ct_Ext_Mem_Limit	; limit extended size

		mov	EXT_MEM_FOUND[bp],ax	; save amount of memory found in CMOS
		cmp	cx,ax
		je	short @F		; extended size changed
		xor	ecx,ecx
		mov	cx,ax
		mov	EXT_MEM_SIZE[bp],ecx	; save memory found
@@:

;	Display amount of memory

		mov	dx,EXT_MEM_FOUND[bp]	; get the found amount of ext. memory
		mov	EXT_MEMORY[bp],dx	; set value

if	BIOS_SUPPORT_IBM_CPU
		call	IBMCPU_Cacheable_Size
endif	;BIOS_SUPPORT_IBM_CPU
		call	Prg_K5_Write_Allocate

Exit_Mem_Sizing:

		xor	ax,ax
		mov	ds,ax			;segment at 0

	;restore data to avoid destoried by memory sizing due to wrap-around

		pop	dword ptr ds:[0FFFCH]
		pop	dword ptr ds:[0FFF8H]

		mov	byte ptr MEM_ERR_STATUS[bp],0

		mov	ax,G_RAM
		mov	ds,ax
		ASSUME	DS:G_RAM

ifdef	KLAMATH_CPU_ONLY
		mov	si,offset ExtCache_Item	;get CMOS status of L2 cache
		call	F000_GetItem_Value
		mov	bl,al			;for Set_Cpu_Mtrr use
endif;	KLAMATH_CPU_ONLY

		mov	esi,EXT_MEM_SIZE[bp]	;extended memory size
		mov	al,1			;program address above 1Mb
		call	Set_Cpu_MtRR

ifdef	P6_BIOS_ONLY
		push	ds
		mov	ax,4100H
		mov	ds,ax
		mov	esi,EXT_MEM_SIZE[bp]	;extended memory size
		mov	dword ptr ds:[0],esi	;save extended size
		call	Init_Apic
		pop	ds
endif;	P6_BIOS_ONLY

		cmp	word ptr ds:[User_Reboot],CTRL_ALT_DEL	;R01
		je	Fill_Mem_0			;R01

		mov	si,offset Test_Mem_Msg
		call	Disp_Str_In_POST

ifdef	Show_Total_After_Memory_Test

	;show total memory size (multiple of 512K)

		mov	cl,0
		F000_call Read_Memory

else	;Show_Total_After_Memory_Test

		mov	eax,EXT_MEM_SIZE[bp]	;extended memory size
		add	eax,1024

endif	;Show_Total_After_Memory_Test

ifdef	SPECIAL_SHARE_MEMORY_SHOW					
		push	eax						
		F000_call Ct_Share_Memory_Size	;get shared mem. size	
		xor	ecx,ecx						
		mov	cx, ax						
		pop	eax						
		add	eax, ecx					
endif	;SPECIAL_SHARE_MEMORY_SHOW					

		F000_call	Disp_Dword_Int6
		mov	si,offset OK_Msg
		call	Disp_Str_In_POST

		call	F000_Vcrlf

Fill_Mem_0:						;R01

ifndef	KBC_KBDMOUSE_SWAP
		mov	ax,0f000h
		mov	ds,ax
		lea	si,SYSTEM5_BYTE
		call	Get_Switch
		call	Special_KBC_Init
endif;	KBC_KBDMOUSE_SWAP

ifdef	USB_SUPPORT
ifndef	SMIHANDLE_IN_XGROUP
		call	Usb_Init
else	;SMIHANDLE_IN_XGROUP
		Xcall	Usb_Init
endif	;SMIHANDLE_IN_XGROUP
endif	;USB_SUPPORT
		cli				;R05
		call	E000_A20_On		; turn on a20 gate
		call	E000_Enter_Prot_mode	;enter CPU protected mode

		mov	ax,ds
		mov	es,ax			;setup descriptor table

		call	E000_Back_Real_Mode	;enter CPU big real mode

;----- clear 4000:0 - 5000:FFFF memory
		mov	edi,4*64*1024
		mov	ecx,128*1024/4
		xor	eax,eax
		db	67h
		rep	stosd			;clear memory

	;----- clear 7000:0 - 9000:FFFF memory
		mov	edi,7*64*1024		;start from 7000:0

ifdef	Flash_2M_support
	;----- clear 7000:0 - 7000:FFFF memory
		mov	ecx,64*1024/4		;size = 64K
else	;Flash_2M_support
		mov	ecx,192*1024/4		;size = 192K
endif	;Flash_2M_support
		db	67h
		rep	stosd			;clear memory

ifdef	Flash_2M_support
		mov	esi,160000h
		mov	edi,80000h
		mov	ecx,8000h
 		db	67h
 		rep	movsd			;move extend 128k data to 160000h
endif	;Flash_2M_support

	;clear 1Mb to top of memory
		mov	edi,1024*1024		;start from 1Mb

		mov	ecx,EXT_MEM_SIZE[bp]	;no of Kb of extended memory
		shl	ecx,(10-2)		;convert to dword
		db	67h
		rep	stosd			;clear all extended memory

	;read base memory to flush L2 cache
		xor	esi,esi
		mov	ecx,(640*1024)/4	;number of dword to clear
		db	67h
		rep	lodsd			;read memory to invalidate tag

ifdef	Flash_2M_support
		mov	esi,80000h
		mov	edi,160000h
		mov	ecx,8000h
 		db	67h
 		rep	movsd			;move extend 128k data to 160000h
;----- clear 8000:0 - 9000:FFFF memory
		xor	eax,eax
		mov	edi,8*64*1024		;start from 8000:0
		mov	ecx,128*1024/4		;size = 128K
		db	67h
		rep	stosd			;clear all extended memory
endif	;Flash_2M_support

		F000_CALL A20_Off		;turn gate A20 off
		call	KBD_A20_OFF		;set KBC gate A20 off

		sti
		clc
		ret
QUICK_Mem_Init	ENDP
		
endif	;Quick_POST_Flag	EQ	1

ifdef	S4_SUPPORT
S4_POST_TABLE:
		DW	OFFSET	S4_POST_1
		DW	OFFSET	S4_POST_2
		DW	OFFSET	S4_POST_3
		DW	OFFSET	S4_POST_4
		DW	OFFSET	S4_POST_5
		DW	OFFSET	S4_POST_6
		DW	OFFSET	S4_POST_7
		DW	OFFSET	S4_POST_8
		DW	OFFSET	S4_POST_9
		DW	OFFSET	S4_POST_10
		DW	OFFSET	S4_POST_11
		DW	OFFSET	S4_POST_12
		DW	OFFSET	S4_POST_13
		DW	OFFSET	S4_POST_14
		DW	OFFSET	S4_POST_15
		DW	OFFSET	S4_POST_16
		DW	0

;[]==============================================================[]
;
; S4_POST_TESTS:
;
;	Execute S4 resume POST tests
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;Author: Award
;Date:	 03/03/98
;
;[]==============================================================[]
S4_POST_CODE		EQU	90h

		public	S4_POST_TESTS
S4_POST_TESTS	PROC	NEAR
	
		mov	cx,S4_POST_CODE
		mov	di,offset S4_POST_TABLE
		call	Ram_Post_Tests

		jmp	HaltSystem

S4_POST_TESTS	ENDP

;[]==============================================================[]
;
;S4_POST_1:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_1
S4_POST_1	PROC	NEAR

		Call	POST_5S
		ret
S4_POST_1	ENDP

;[]==============================================================[]
;
;S4_POST_2:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_2
S4_POST_2	PROC	NEAR
		Call	POST_7S
		ret
S4_POST_2	ENDP

;[]==============================================================[]
;
;S4_POST_3:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_3
S4_POST_3	PROC	NEAR
		Call	POST_8S
		ret
S4_POST_3	ENDP

;[]==============================================================[]
;
;S4_POST_4:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_4
S4_POST_4	PROC	NEAR
		Call	POST_9S
		ret
S4_POST_4	ENDP

;[]==============================================================[]
;
;S4_POST_5:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_5
S4_POST_5	PROC	NEAR
		Call	POST_10S
		ret
S4_POST_5	ENDP

;[]==============================================================[]
;
;S4_POST_6:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_6
S4_POST_6	PROC	NEAR
		Call	POST_11S
		ret
S4_POST_6	ENDP

;[]==============================================================[]
;
;S4_POST_7:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_7
S4_POST_7	PROC	NEAR
		Call	POST_12S
		ret
S4_POST_7	ENDP

;[]==============================================================[]
;
;S4_POST_8:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_8
S4_POST_8	PROC	NEAR
		Call	POST_13S
		ret
S4_POST_8	ENDP

;[]==============================================================[]
;
;S4_POST_9:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_9
S4_POST_9	PROC	NEAR
		Call	POST_14S
		ret
S4_POST_9	ENDP

;[]==============================================================[]
;
;S4_POST_10:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_10
S4_POST_10	PROC	NEAR
		Call	POST_15S
		ret
S4_POST_10	ENDP

;[]==============================================================[]
;
;S4_POST_11:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_11
S4_POST_11	PROC	NEAR
		cli

		mov	al,0b8h 		; init controller #1
		out	a8259+1,al
		NEWIODELAY
						; mask channel 4 off
		mov	al,0bfh 		;mask IRQ 9
		out	b8259+1,al

		Call	Quick_Mem_Init
		ret
S4_POST_11	ENDP

;[]==============================================================[]
;
;S4_POST_12:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_12
S4_POST_12	PROC	NEAR
		Call	POST_61S
		Call	POST_62S
		ret
S4_POST_12	ENDP

;[]==============================================================[]
;
;S4_POST_13:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_13
S4_POST_13	PROC	NEAR

		Call	POST_65S
		Call	POST_66S
		ret
S4_POST_13	ENDP

;[]==============================================================[]
;
;S4_POST_14:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_14
S4_POST_14	PROC	NEAR

		push	bp

;R03 - start
ifndef	HPM_SUPPORT					;R06
		F000_call	Ct_PMRAM_Use_SYSRAM
		or	al,al
		jz	short @F

		mov	bx,G_RAM
		mov	ds,bx
		assume	DS:G_RAM

		mov	bx,SIZE_SYSRAM
		xor	ah,ah
		sub	bx,ax
		mov	SIZE_SYSRAM,bx

		shl	bx,6				; translate to segment
		mov	PMRAM_LOC,bx

	@@:
endif	;HPM_SUPPORT					;R06
;R03 - end

ifdef	USB_SUPPORT				
 ifndef M1523B_USB				
  ifndef Dont_turn_cache_in_USB_Final_Init	
	;Disable internal cache			
		mov	al,FALSE		
		call	F000_Cpu_Cache		
  endif ;Dont_turn_cache_in_USB_Final_Init	
 endif	;M1523B_USB				

ifndef	SMIHANDLE_IN_XGROUP	
		call	Usb_Final_Init
else	;SMIHANDLE_IN_XGROUP	
		Xcall	Usb_Final_Init
endif	;SMIHANDLE_IN_XGROUP	

 ifndef M1523B_USB				
  ifndef Dont_turn_cache_in_USB_Final_Init	
	;Restore internal cache			
		call	IntCache_Status 	
		jz	short CpuCache_Disable	
		mov	al,TRUE			
		call	F000_Cpu_Cache		
  CpuCache_Disable:				
  endif ;Dont_turn_cache_in_USB_Final_Init	
 endif	;M1523B_USB				
endif	;USB_SUPPORT				

		pop	bp
		clc
		ret
S4_POST_14	ENDP

;[]==============================================================[]
;
;S4_POST_15:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_15
S4_POST_15	PROC	NEAR
		Call	PM_Init
		clc
		ret
S4_POST_15	ENDP

;[]==============================================================[]
;
;S4_POST_16:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	S4_POST_16
S4_POST_16	PROC	NEAR
		Call	Try_Actual_Cache
		F000_Call	Ct_PM_Final_Init	;R04
ifndef	HPM_SUPPORT					;R06
		call	Notebook_Resume
endif	;HPM_SUPPORT					;R06
		clc
		ret
S4_POST_16	ENDP

endif	;S4_SUPPORT
endif	;ACPI_SUPPORT

ifdef	SIMPLE_BOOT_SUPPORT
Q_POST_TESTS:
		DW	OFFSET	QUICK_POST_1
		DW	OFFSET	QUICK_POST_2
		DW	OFFSET	QUICK_POST_3
		DW	OFFSET	QUICK_POST_4
		DW	OFFSET	QUICK_POST_5
		DW	OFFSET	QUICK_POST_6
		DW	OFFSET	QUICK_POST_7
		DW	OFFSET	QUICK_POST_8
		DW	OFFSET	QUICK_POST_9
		DW	OFFSET	QUICK_POST_10
		DW	OFFSET	QUICK_POST_11
		DW	OFFSET	QUICK_POST_12
		DW	OFFSET	QUICK_POST_13
		DW	OFFSET	QUICK_POST_14
		DW	OFFSET	QUICK_POST_15
		DW	OFFSET	QUICK_POST_16
		DW	OFFSET	QUICK_POST_17
		DW	OFFSET	QUICK_POST_18
		DW	OFFSET	QUICK_POST_19
		DW	OFFSET	QUICK_POST_20
		DW	OFFSET	QUICK_POST_21
		DW	OFFSET	QUICK_POST_22
		DW	OFFSET	QUICK_POST_23
		DW	OFFSET	QUICK_POST_24
		DW	OFFSET	QUICK_POST_25
		DW	OFFSET	QUICK_POST_26
		DW	OFFSET	QUICK_POST_27
		DW	OFFSET	QUICK_POST_28
		DW	0

;[]==============================================================[]
;
;QUICK_POST_TESTS:
;
;	Execute Quick POST tests
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;Author: Award
;Date:	 03/03/98
;
;[]==============================================================[]
QUICK_POST_CODE		EQU	101

			public	QUICK_POST_TESTS
QUICK_POST_TESTS	PROC	NEAR

		mov	cx,QUICK_POST_CODE
		mov	di,offset Q_POST_TESTS
		call	Ram_Post_Tests

		jmp	HaltSystem

QUICK_POST_TESTS	ENDP

;[]==============================================================[]
;
;QUICK_POST_1:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_1
QUICK_POST_1	PROC	NEAR

		Call	POST_5S
		Call	POST_6S
		Call	POST_8S

		mov	al,SIMPLE_BOOT_CMOS NMI_OFF
		mov	ah,00000010b			;Every thing is OK
		F000_Call	Set_CMOS

		ret
QUICK_POST_1	ENDP

;[]==============================================================[]
;
;QUICK_POST_2:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_2
QUICK_POST_2	PROC	NEAR

		Call	POST_9S
		Call	POST_10S
		ret
QUICK_POST_2	ENDP

;[]==============================================================[]
;
;QUICK_POST_3:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_3
QUICK_POST_3	PROC	NEAR
		Call	POST_11S
		Call	POST_12S
		ret
QUICK_POST_3	ENDP

;[]==============================================================[]
;
;QUICK_POST_4:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_4
QUICK_POST_4	PROC	NEAR

		Call	POST_13S
		Call	POST_14S

		ret
QUICK_POST_4	ENDP

;[]==============================================================[]
;
;QUICK_POST_5:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_5
QUICK_POST_5	PROC	NEAR
		cli

		mov	al,0b8h 		; init controller #1
		out	a8259+1,al
		NEWIODELAY
						; mask channel 4 off
		mov	al,0bfh 		;mask IRQ 9
		out	b8259+1,al

		clc
		ret
QUICK_POST_5	ENDP

;[]==============================================================[]
;
;QUICK_POST_6:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_6
QUICK_POST_6	PROC	NEAR

		Call	Quick_Mem_Init
		ret
QUICK_POST_6	ENDP

;[]==============================================================[]
;
;QUICK_POST_7:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_7
QUICK_POST_7	PROC	NEAR
		Call	POST_50S
		Call	POST_51S
		ret
QUICK_POST_7	ENDP

;[]==============================================================[]
;
;QUICK_POST_8:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_8
QUICK_POST_8	PROC	NEAR
		Call	POST_52S
		Call	POST_53S
		ret
QUICK_POST_8	ENDP

;[]==============================================================[]
;
;QUICK_POST_9:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_9
QUICK_POST_9	PROC	NEAR
		Call	POST_54S
		Call	POST_55S
		ret
QUICK_POST_9	ENDP

;[]==============================================================[]
;
;QUICK_POST_10:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_10
QUICK_POST_10	PROC	NEAR
		Call	POST_56S
		Call	POST_57S
		ret
QUICK_POST_10	ENDP

;[]==============================================================[]
;
;QUICK_POST_11:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_11
QUICK_POST_11	PROC	NEAR
		Call	POST_58S
		Call	POST_59S
		ret
QUICK_POST_11	ENDP

;[]==============================================================[]
;
;QUICK_POST_12:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_12
QUICK_POST_12	PROC	NEAR
		Call	POST_60S
		Call	POST_61S
		ret
QUICK_POST_12	ENDP

;[]==============================================================[]
;
;QUICK_POST_13:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_13
QUICK_POST_13	PROC	NEAR
		Call	POST_62S
		Call	POST_63S
		ret
QUICK_POST_13	ENDP

;[]==============================================================[]
;
;QUICK_POST_14:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_14
QUICK_POST_14	PROC	NEAR
		Call	POST_64S
		Call	POST_65S
		ret
QUICK_POST_14	ENDP

;[]==============================================================[]
;
;QUICK_POST_15:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_15
QUICK_POST_15	PROC	NEAR
		Call	POST_66S
		Call	POST_67S
		ret
QUICK_POST_15	ENDP

;[]==============================================================[]
;
;QUICK_POST_16:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_16
QUICK_POST_16	PROC	NEAR
		Call	POST_68S
		Call	POST_69S
		Call	POST_70S
		ret
QUICK_POST_16	ENDP

;[]==============================================================[]
;
;QUICK_POST_17:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_17
QUICK_POST_17	PROC	NEAR
		Call	POST_71S
		Call	POST_72S
		Call	POST_73S
		ret
QUICK_POST_17	ENDP

;[]==============================================================[]
;
;QUICK_POST_18:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_18
QUICK_POST_18	PROC	NEAR
		Call	POST_74S
		Call	POST_75S
		Call	POST_76S
		ret
QUICK_POST_18	ENDP

;[]==============================================================[]
;
;QUICK_POST_19:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_19
QUICK_POST_19	PROC	NEAR
		Call	POST_77S
		Call	POST_78S
		Call	POST_79S
		ret
QUICK_POST_19	ENDP

;[]==============================================================[]
;
;QUICK_POST_20:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_20
QUICK_POST_20	PROC	NEAR
		Call	POST_80S
		Call	POST_81S
		Call	POST_82S
		ret
QUICK_POST_20	ENDP

;[]==============================================================[]
;
;QUICK_POST_21:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_21
QUICK_POST_21	PROC	NEAR
		Call	POST_83S
		Call	POST_84S
		Call	POST_85S
		ret
QUICK_POST_21	ENDP

;[]==============================================================[]
;
;QUICK_POST_22:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_22
QUICK_POST_22	PROC	NEAR
		Call	POST_86S
		Call	POST_87S
		Call	POST_88S
		ret
QUICK_POST_22	ENDP

;[]==============================================================[]
;
;QUICK_POST_23:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_23
QUICK_POST_23	PROC	NEAR
		Call	POST_89S
		Call	POST_90S
		Call	POST_91S
		ret
QUICK_POST_23	ENDP

;[]==============================================================[]
;
;QUICK_POST_24:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_24
QUICK_POST_24	PROC	NEAR
		Call	POST_92S
		Call	POST_93S
		Call	POST_94S
		ret
QUICK_POST_24	ENDP

;[]==============================================================[]
;
;QUICK_POST_25:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_25
QUICK_POST_25	PROC	NEAR
		Call	POST_95S
		Call	POST_96S
		ret
QUICK_POST_25	ENDP

;[]==============================================================[]
;
;QUICK_POST_26:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_26
QUICK_POST_26	PROC	NEAR
		Call	POST_97S
		ret
QUICK_POST_26	ENDP

;[]==============================================================[]
;
;QUICK_POST_27:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_27
QUICK_POST_27	PROC	NEAR
		Call	POST_98S
		ret
QUICK_POST_27	ENDP

;[]==============================================================[]
;
;QUICK_POST_28:
;
;Saves: NONE
;
;Entry: NONE
;Exit:	NONE
;
;[]==============================================================[]
		PUBLIC	QUICK_POST_28
QUICK_POST_28	PROC	NEAR
		Call	POST_99S
		ret
QUICK_POST_28	ENDP

endif	;SIMPLE_BOOT_SUPPORT

ECODE		ENDS

FCODE		SEGMENT PARA PUBLIC 'CODE'
		ASSUME	CS:DGROUP
FCODE		ENDS

		END
