;	[]===========================================================[]
;
;	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
;----------------------------------------------------------------------------
;R55	04/19/99 GAR	Fixed error about FDD 3 mode of NS serial parts
;R54	04/07/99 GAR	Add PC87363
;R53	03/23/99 GAR	Add W83977CTF
;R52	03/10/99 GAR	Add LPC47U33X
;R52	03/10/99 GAR	Add PC87364/366
;R51	03/09/99 GAR	Add LPC47B27X
;R50	02/12/99 GAR	Add ITE8702/12
;R49A	02/10/99 GAR	Change Ali5113D to Ali5113B
;R49	02/02/99 GAR	Add Ali5113D
;R47A	02/01/99 GAR	cancle R47
;R48	01/26/99 GAR	Support W83627F/HF
;R47	01/19/99 GAR	Ali513x and Ali513xB use Ali513xF code
;R46	01/13/99 RIC	add SUPPORT VIA686
;R45	01/12/99 GAR	add SUPPORT SMC37M81x
;R44	01/06/99 KGN	Add code for SMC37N869 fdd 3 mode
;R43	10/22/98 GAR	Add code about ITE8673 and ITE8693
;R42	07/14/98 GAR	add SUPPORT SMC37M70x
;R41	07/07/98 GAR	add SUPPORT W83977EF
;R40	06/24/98 LAW	add SUPPORT SiS6801
;R39	05/27/98 LAW	add SUPPORT NS351
;R38	03/17/98 LAW	add Ali513xB
;R37	12/27/97 LAW	Let NS307/NS308/NS319 always Use IO port 2Eh
;R36	11/20/97 LAW	added "NO_WIN95_NODE" for some MB
;R35	11/06/97 LAW	added SMC37N769 support
;R34	10/30/97 LAW	added "ALi513xF"
;R33	10/28/97 LAW	added "W83877ATF"
;R32	10/15/97 LAW	added "ITE8681" and "ITE8671"
;R31	10/13/97 LAW	added "NS317" for NS pc97317VLJ
;R30    09/17/97 PAL	added SMC37C669_ITE8661
;R29	09/04/97 LAW	added ALi513x_5113 
;R28	08/04/97 LAW	added "W83977ATF" and make a W977TF.SIO for 9773 W83977TF
;R27	07/03/97 LAW	Added "NS309" for NS PC87309VLJ
;R26	07/01/97 LAW	fixed W83977/W83967 set 3mode error
;R25	06/15/97 LAW	Added support SMC37M60x, SMC37M61x
;R24	05/29/97 LAW	Added W83977TF SUPPORT
;R23	04/17/97 DRS	Added SMC68X.SIO for SMC37C68X
;R22	03/20/97 LAW	Added SMC37C93XAPM, SMC37C93XFR
;R21	03/06/97 LAW	Added W83877AF + W83877TF
;R20	03/06/97 LAW	Added SMC67x.SIO for SMC37C67x
;R19	02/12/97 LAW	Added ITE8661.SIO (ITE8661F/ITE8661RF)
;R18	12/17/96 LAW	Added NS83307VUL/NS87308VUL
;R17	12/16/96 LAW	Added "SMC37C669FR" "SMC37C67X" "SMC37C68X" "ITE8679"
;			SMC37C669FR --> SMC37C669 + SUPPORT_FAST_IR
;			SMC37C67X  ---> SMC93X
;			SMC37C68X  ---> SMC93X
;			ITE8679    ---> ITE8680
;R16	12/09/96 LAW	Modify superio define
;			ALi513x + ALi5123 -- > ALi513X
;			ALi514x + ALi5123 -- > ALi514X
;			W86967AF + W83977AF -- > W83977AF
;			NS307 + NS308 -- > NS308
;R15	10/23/96 LAW	Added W83967AF I/O
;R14	10/22/96 DNL	Add NS_338 Support
;R12A	10/18/96 RCH	Fixed compliation error for W787 ifdef Fdd_3_Mode
;R13	10/14/96 LAW	Fixed Ali5113 format Fdd diskette error
;R12    XX/XX/96 LAW    lessen duplicate code in superio
;R11	08/27/96 LAW	Added ITE8680 I/O
;R10	06/17/96 KGN	Add Smc93X Support
;R09	06/17/96 KGN	Add Smc669 Support
;R08	06/07/96 KGN	Add Protech DUAL I/O Support
;R07	02/07/96 KGN	Add Ali5123 Support
;R06	12/29/95 KGN	Add SMC_ALI support Ali5113
;R05	12/29/95 RAY	Fix error coding of SMC_ALI
;R04	12/05/95 TNY	Add UMC_8669 FDD 3 mode support.
;R03	11/06/95 HTR	ALi 5119 FDD 3 mode support added
;R02	11/02/95 KVN	Fixed W83787 FDD 3 mode read 1.2MB error
;R01	10/24/95 HTR	Fix FDD 3 mode auto switch bug.  SMC 665 installed
;			and FDD 3 mode enabled, it can not access 1.44 floppy

		extrn	DRIVE_MODE_ITEM:near
		extrn	GetItem_Value:near

;--------------------------------
;SMC 651/665 external definitions
;--------------------------------
ifdef	SMC37C651
SMC_CHIP	EQU	1
endif	;SMC37C651
ifdef	SMC37C665
SMC_CHIP	EQU	1
endif	;SMC37C665

;--------------------------------
;NS 332/306/336 external definitions
;--------------------------------
ifdef	PC87332
NS_CHIP 	EQU	1
endif	;PC87332
ifdef	PC87306
NS_CHIP 	EQU	1
endif	;PC87306
ifdef	PC87336
NS_CHIP 	EQU	1
endif	;PC87336
ifdef	NS_338				;R14
NS_CHIP 	EQU	1		;R14
endif	;NS_338				;R14

;R16 - start
;------------------
; ALi5123/513x/514x
;------------------
;R47ifdef	ALi513X
;R47ALi5123			EQU	1
;R47endif;	ALi513X
;R47ifdef	ALi513XB
;R47ALi5123			EQU	1
;R47endif;	ALi513XB
;R47A - start
ifdef	ALi513X
ALi5123			EQU	1
endif;	ALi513X
ifdef	ALi513XB
ALi5123			EQU	1
endif;	ALi513XB
;R47A - end
ifdef	ALi514X
ALi5123			EQU	1
endif;	ALi514X

ifdef	ALi513X_5113				;R29
ALi5123			EQU	1		;R29
NO_Have_Superio_PNP_Node	EQU	1	;R29
endif;	ALi513X_5113				;R29

;------------------
; W83967/977
;------------------
ifdef	W83967AF
W83977AF		EQU	1
endif;	W83967AF

ifdef	W83977ATF				;R28
W83977AF		EQU	1		;R28
endif;	W83977ATF				;R28
	   
ifdef	W83977CTF				;R53
W83977TF		EQU	1		;R53
endif;	W83977CTF				;R53
			       	
ifdef	W83977EF				;R41
W83977TF		EQU	1		;R41
endif;	W83977EF				;R41

;R28ifdef	W83977TF			;R24
;R28W83967AF		EQU	1		;R24
;R28endif;	W83977TF			;R24

;------------------
; NS307/308
;------------------
ifdef	NS308
NS307			EQU	1
endif;	NS308
ifdef	NS317					;R31
NS307			EQU	1		;R31
endif;	NS317					;R31

;R16 - end

;R17 - start
;------------------
; SMC37C669/669FR
;------------------
ifdef	SMC37C669FR
SMC37C669			EQU	1
endif;	SMC37C669FR
ifdef	SMC37N769				;R35
SMC37C669			EQU	1	;R35
endif;	SMC37N769				;R35

ifdef 	SMC37C669_ITE8661			;R30
SMC37C669			EQU	1	;R30
NO_Have_Superio_PNP_Node	EQU	1	;R30
endif; 	SMC37C669_ITE8661			;R30

;R20ifndef	SMC37C93X
;R20ifdef	SMC37C67X
;R20SMC37C93X			EQU	1
;R20endif;	SMC37C67X
;R20endif;	SMC37C93X

;R23 ifndef	SMC37C93X
;R23 ifdef	SMC37C68X
;R23 SMC37C93X			EQU	1
;R23 endif;	SMC37C68X
;R23 endif;	SMC37C93X

ifdef	ITE8679
ITE8680				EQU	1
endif;	ITE8679
ifdef	ITE8681					;R32
ITE8680				EQU	1	;R32
endif;	ITE8681					;R32
ifdef	ITE8671					;R32
ITE8680				EQU	1	;R32
endif;	ITE8671					;R32
;R17 - end

;R40 - start
ifdef	SIS6801
ITE8661				EQU	1
endif;	SIS6801
;R40 - end

;R43 - start
ifdef   ITE8693
ITE8680				EQU	1
endif;  ITE8693
ifdef   ITE8673
ITE8680				EQU	1
endif;  ITE8673
;R43 - end

;R19 - start
ifdef	ITE8661RF
ITE8661				EQU	1
endif;	ITE8661RF
;R19 - end

;R21 - start
ifdef	W83877AF
W83877F				EQU	1
endif;	W83877AF
ifdef	W83877TF
W83877F				EQU	1
endif;	W83877TF
;R21 - end
ifdef	W83877ATF				;R33
W83877F				EQU	1	;R33
endif;	W83877ATF				;R33

;R22 - start
ifdef	SMC37C93XAPM
SMC37C93X			EQU	1
endif;	SMC37C93XAPM
ifdef	SMC37C93XFR
SMC37C93X			EQU	1
endif;	SMC37C93XFR
;R22 - end

ifdef	SMC37M60x				;R25
SMC37C67X			EQU	1	;R25
endif;	SMC37M60x				;R25
ifdef	SMC37M61x				;R25
SMC37C67X			EQU	1	;R25
endif;	SMC37M61x				;R25
ifdef	SMC37M81x 				;R45
SMC37C67X			EQU	1	;R45
endif;	SMC37M81x				;R45
ifdef	SMC37M70x 				;R42
SMC37C67X			EQU	1	;R42
endif;	SMC37M70x				;R42
ifdef	SMC37B77x
SMC37C67X			EQU	1
endif;	SMC37B77x

;R03 - Start
;---------   Program chipset function   ---------
ifdef	ALi5119
		public	Set_FDD_3_mode
Set_FDD_3_mode:
		pusha

		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00001100b	;enable FDD 3 mode
@@:
		mov	cl,55h
		call	Get_ALi5119
		and	al,NOT 00001100b
		or	al,bl
		call	Set_ALi5119

		popa
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output : AL - Value read
;[]==============================================================[]
ALi_PORT	EQU	03f1h
Get_ALi5119	Proc	Near
		pushf
		push	dx
		cli

		call	En_ALi5119_Cfg
		in	al,dx

		pop	dx
		popf
		ret

Get_ALi5119	Endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_ALi5119	Proc	Near
		pushf
		push	dx
		cli

		call	En_ALi5119_Cfg
		out	dx,al

		pop	dx
		popf
		ret

Set_ALi5119	Endp

En_ALi5119_Cfg:
		push	ax
		mov	dx,ALi_PORT
		mov	al,051h
		out	dx,al
		IODELAY

		mov	al,29h
		out	dx,al
		IODELAY
		in	al,dx
		IODELAY
		cmp	al,92h			;ALi_5119A exit ?
		je	short ALi5119A_Exit

		mov	dx,ALi_PORT
		mov	al,051h
		out	dx,al
		IODELAY

		mov	al,19h
		out	dx,al
		IODELAY
		in	al,dx
		IODELAY
ALi5119A_Exit:
		mov	al,cl
		out	dx,al
		IODELAY
		pop	ax
		ret

endif	;ALi5119
;R03 - End

ifdef	NS_CHIP
		public	Set_FDD_3_mode
Set_FDD_3_mode:
		mov	bx,0c8h
		or	al,al
		jz	short @F
ifdef	High_Active_3mode
		mov	bx,48h
else	;High_Active_3mode
		mov	bx,8
endif	;High_Active_3mode
@@:
		push	bx

;program ASC reg. bit 6
		mov	bl,40h
		jz	short @F
		xor	bl,bl
@@:
ifdef	High_Active_3mode
		xor	bl,40h
endif	;High_Active_3mode
		mov	cl,9
		call	Get_PC87306
		and	al,not 40h
		or	al,bl
		call	Set_PC87306
;-------
		xor	bx,bx
		push	bx
		mov	si,sp			; pointer to args.
		mov	ah,1			; 1 = NS chip MODE command
		MOV	BL,5			; 5 byte command.
		CALL	SEND_COMMAND
		add	sp,4
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_PC87306	Proc	Near
		pushf
		cli
ifdef	PC87306
		mov	dx,PC87306_PORT 	;index port
endif	;PC87306
ifdef	PC87336
		mov	dx,PC87336_PORT 	;index port
endif	;PC87336
ifdef	NS_338					;R14
		mov	dx,398h			;R14
endif	;NS_338					;R14
		mov	al,cl
		out	dx,al
		IODELAY
		inc	dx			;data port
		in	al,dx
		sti
		popf
		ret
Get_PC87306	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_PC87306	Proc	Near
		pushf
		cli
ifdef	PC87306
		mov	dx,PC87306_PORT 	;index port
endif	;PC87306
ifdef	PC87336
		mov	dx,PC87336_PORT 	;index port
endif	;PC87336
ifdef	NS_338					;R14
		mov	dx,398h			;R14
endif	;NS_338					;R14
		xchg	al,cl
		out	dx,al
		IODELAY
		inc	dx			;data port
		xchg	al,cl
		out	dx,al
		out	dx,al
		sti
		popf
		ret
Set_PC87306	endp
endif	;NS_CHIP

ifdef	SMC_CHIP
		public	Set_FDD_3_mode
;R12 - start
ifdef	PNP_BIOS
		extrn	Get_Smc665:Near
		extrn	Set_Smc665:Near
endif	;PNP_BIOS
;R12 - end
Set_FDD_3_mode:
		pusha

		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00011000b	;enable FDD 3 mode
@@:
ifdef	High_Active_3mode
		xor	bl,00001000b
endif	;High_Active_3mode
		mov	cl,5
		call	Get_Smc665
		and	al,NOT 00011000b	;R01
		or	al,bl
		call	Set_Smc665

		popa
		ret
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
ifndef	PNP_BIOS				;R12
SMC_PORT	EQU	03f0h
Get_Smc665	Proc	Near
Get_Smc651:
		pushf
		cli
		call	En_Smc665_Cfg
		in	al,dx
		call	Dis_Smc665_Cfg
		sti
		popf
		ret
Get_Smc665	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Smc665	Proc	Near
Set_Smc651:
		pushf
		cli
		call	En_Smc665_Cfg
		out	dx,al
		call	Dis_Smc665_Cfg
		sti
		popf
		ret
Set_Smc665	endp

En_Smc665_Cfg:
		push	ax
		mov	dx,SMC_PORT
		mov	al,055h
		out	dx,al
		out	dx,al
		mov	al,cl
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret
Dis_Smc665_Cfg:
		push	ax
		mov	dx,SMC_PORT
		mov	al,0aah
		out	dx,al
		IODELAY
		pop	ax
		ret
endif	;PNPBIOS				;R12
endif	;SMC_CHIP

ifdef	UMC_8663
;[]===========================================================[]
;
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
;
; Saves: SP,BP , no stack available
;
; Input : AL = 0 - Disable
;	       1 - Enable
;
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
;R12 - start
ifdef	PNP_BIOS
	extrn	Get_8663:Near	
	extrn	Set_8663:Near	
endif	;PNP_BIOS
;R12 - end
Set_FDD_3_mode	Proc	Near
		pusha

		shl	al,2
		mov	bl,al
		mov	cl,0C2h
		Call	Get_8663
		and	al,not 4
		or	al,bl
;--- Programming CR2 Register Set
		Call	Set_8663

		popa
		ret
Set_FDD_3_mode	EndP
ifndef	PNP_BIOS				;R12
UMC8663_INDEX	EQU	108h
Get_8663	PROC	NEAR
                mov     dx,UMC8663_INDEX
                mov     al,0aah
                out     dx,al
		iodelay
		iodelay
                mov     al,cl
                out     dx,al
		iodelay
		iodelay
                inc     dx                      ;I/O port 109h
                in	al,dx
		iodelay
		iodelay
                dec     dx
		push	ax
                mov     al,55h
                out     dx,al
		pop	ax

		ret
Get_8663	ENDP
Set_8663	PROC	NEAR
		push	ax
                mov     dx,UMC8663_INDEX
                mov     al,0aah
                out     dx,al
		iodelay
		iodelay
                mov     al,cl
                out     dx,al
		iodelay
		iodelay
                inc     dx                      ;I/O port 109h
		pop	ax
                out     dx,al
		iodelay
		iodelay
                dec     dx
		push	ax
                mov     al,55h
                out     dx,al
		pop	ax

		ret
Set_8663	ENDP
endif	;PNP_BIOS				;R12
endif	;UMC_8663

ifdef	W83787F
;[]===========================================================[]
;
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
;
; Saves: SP,BP , no stack available
;
; Input : AL = 0 - Disable
;	       1 - Enable
;
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
;R12 - start
ifdef	PNP_BIOS
;R12A	extrn	Get_W787F:Near	
;R12A	extrn	Set_W787F:Near	
	extrn	Get_W787:Near	;R12A
	extrn	Set_W787:Near	;R12A
endif	;PNP_BIOS
;R12 - end
Set_FDD_3_mode	Proc	Near
		pusha

		xor	bh,bh
		or	al,al
		jz	short @F
;R02		mov	bh,0aah
		mov	bh,55h				;R02
@@:
		shl	al,5
		mov	bl,al
		mov	cl,9
		call	Get_W787
		and	al,not 20h
		or	al,bl
;--- Programming CR9 Register Set
		call	Set_W787

		mov	cl,7
		mov	al,bh
;--- Programming CR7 Register Set
		call	Set_W787


		popa
		ret
Set_FDD_3_mode	EndP

ifndef	PNP_BIOS				;R12
En_W787_Cfg:
		push	ax
		mov	dx,250H
ifdef	W787_USE_88H
		mov	al,88H
else;	W787_USE_88H
		mov	al,89H		;enable configuration
endif;	W787_USE_88H
		out	dx,al
		mov	al,cl		;get port to write
		inc	dx		;index port 251H
		out	dx,al
		inc	dx		;data port 252H
		pop	ax
		ret

Dis_W787_Cfg:
		push	ax
		dec	dx
		dec	dx
		xor	al,al		;disable configuration
		out	dx,al
		pop	ax
		ret

Get_W787	Proc	Near
		pushf
		cli
		call	En_W787_Cfg
		in	al,dx
		call	Dis_W787_Cfg
		sti
		popf
		ret
Get_W787	endp

;-----------------------------------------------------------
;-----------------------------------------------------------
Set_W787	Proc	Near
		pushf
		cli
		call	En_W787_Cfg
		out	dx,al
		call	Dis_W787_Cfg
		sti
		popf
		ret
Set_W787	endp
endif	;PNP_BIOS				;R12
endif	;W83787F

ifdef	SMC_ALI
;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
Set_FDD_3_mode	Proc	Near
		pusha

		push	ax		;save input status
		xor	bh,bh		;set normal mode
		or	al,al		;if choose normal
		jz	short @F	;yes
		mov	bh,00011000b	;set FDD 3 mode
@@:
		mov	cl,5		;665 CR5
		call	Get_Smc665
		and	al,11100111b	;mask bit 4-3
;R05		or	al,bl		;set FDD mode
		or	al,bh		;set FDD mode		;R05
		call	Set_Smc665

		xor	bh,bh		;set normal mode
		pop	ax		;check input status
		or	al,al		;if choose normal
		jz	short @f	;yes
		mov	bh,00001100b	;set FDD 3 mode
@@:
		mov	cl,55h		;5119 CR5
		call	Get_Ali5119
		and	al,11110011b	;mask bit 3-2
;R05		or	al,bl
		or	al,bh					;R05
		call	Set_Ali5119

		popa
		ret
Set_FDD_3_mode	EndP
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
SMC_PORT	EQU	03f0h
Get_Smc665	Proc	Near
		pushf
		cli
		call	En_Smc665_Cfg
		in	al,dx
		call	Dis_Smc665_Cfg
		sti
		popf
		ret
Get_Smc665	endp
;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Smc665	Proc	Near
		pushf
		cli
		call	En_Smc665_Cfg
		out	dx,al
		call	Dis_Smc665_Cfg
		sti
		popf
		ret
Set_Smc665	endp

En_Smc665_Cfg:
		push	ax
		mov	dx,SMC_PORT
		mov	al,055h
		out	dx,al
		out	dx,al
		mov	al,cl
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret
Dis_Smc665_Cfg:
		push	ax
		mov	dx,SMC_PORT
		mov	al,0aah
		out	dx,al
		IODELAY
		pop	ax
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
ALI_PORT	EQU	03F1h
Get_Ali5119	Proc	Near
		pushf
		cli
		call	En_Ali5119_Cfg
		in	al,dx
		popf
		ret
Get_Ali5119	endp
;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Ali5119	Proc	Near
		pushf
		cli
		call	En_Ali5119_Cfg
		out	dx,al
		popf
		ret
Set_Ali5119	endp

En_Ali5119_Cfg:
		push	ax
		mov	dx,ALI_PORT
		mov	al,051h
		out	dx,al
		IODELAY
		mov	al,29h
		out	dx,al
		IODELAY
		in	al,dx
		IODELAY
		cmp	al,92h			;Ali_5119A exit ?
		je	short Ali5119A_Exit
		cmp	al,93h			;R06 Ali5113 exit ?
		je	short Ali5119A_Exit	;R06
		mov	dx,ALI_PORT		
		mov	al,051h			
		out	dx,al			
		IODELAY				
		mov	al,19h
		out	dx,al
		IODELAY
		in	al,dx
		IODELAY
Ali5119A_Exit:
		mov	al,cl
		out	dx,al
		IODELAY
		pop	ax
		ret
endif	;SMC_ALI

ifdef	W83877F
;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
;R12 - start
ifdef	PNP_BIOS
	extrn	Get_W83877F:Near	
	extrn	Set_W83877F:Near	
endif	;PNP_BIOS
;R12 - end
Set_FDD_3_mode	Proc	Near
		pusha

		xor	bh,bh
		or	al,al
		jz	short @F
		mov	bh,55h
@@:
		shl	al,5
		mov	bl,al
		mov	cl,9
		call	Get_W83877F
		and	al,not 20h
		or	al,bl
;--- Programming CR9 Register Set
		call	Set_W83877F

		mov	cl,7
		mov	al,bh
;--- Programming CR7 Register Set
		call	Set_W83877F

		popa
		ret
Set_FDD_3_mode	EndP
ifndef	PNP_BIOS				;R12
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_W83877F	Proc	Near
		pushf
		cli
		call	En_W83877F_Cfg
		in	al,dx
		call	Dis_W83877F_Cfg
		popf
		ret
Get_W83877F	endp
;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_W83877F	Proc	Near
		pushf
		cli
		call	En_W83877F_Cfg
		out	dx,al
		call	Dis_W83877F_Cfg
		popf
		ret
Set_W83877F	endp

ifdef	W83877F_USE_3f0H

 ENABLE_W83877F_port	EQU	3f0h
 ifdef	W83877F_USE_86H
	ENABLE_W83877F_VAL	EQU	86h
  else	;W83877F_USE_86H
	ENABLE_W83877F_VAL	EQU	87h
 endif	;W83877F_USE_86H

else	;W83877F_USE_3f0H

 ENABLE_W83877F_port	EQU	250h
 ifdef	W83877F_USE_88H
	ENABLE_W83877F_VAL	EQU	88h
  else	;W83877F_USE_88H
	ENABLE_W83877F_VAL	EQU	89h
 endif	;W83877F_USE_88H

endif	;W83877F_USE_88H

En_W83877F_Cfg:
		push	ax
		mov	dx,ENABLE_W83877F_port

		mov	al,ENABLE_W83877F_VAL

		out	dx,al

ifdef	W83877F_USE_3f0H
		out	dx,al
endif	;W83877F_USE_3f0H

		mov	al,cl		;get port to write
ifndef	W83877F_USE_3f0H
		inc	dx		;index port XX1H
endif	;W83877F_USE_3f0H
		out	dx,al
		inc	dx		;data port XX2H
		pop	ax
		ret

Dis_W83877F_Cfg:
		push	ax
ifndef	W83877F_USE_3f0H
		dec	dx
endif	;W83877F_USE_3f0H
		dec	dx
		xor	al,al		;disable configuration
		out	dx,al
		pop	ax
		ret
endif	;PNP_BIOS
endif	;W83877F

IFDEF	Ali5113
;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
;R12 - start
ifndef	NO_WIN95_NODE				;R36
ifdef	PNP_BIOS
	extrn	Get_ALi5113:Near	
	extrn	Set_ALi5113:Near	
endif	;PNP_BIOS
else;	NO_WIN95_NODE				;R36
NO_Have_Superio_PNP_Node	EQU	1	;R36
endif;	NO_WIN95_NODE				;R36
;R12 - end
Set_FDD_3_mode	Proc	Near
		pusha

;R13		xor	bl,bl
		mov	bl,00001100b	;R13;enable FDD 3 mode
		or	al,al
		jnz	short @F	;R13
;R13		jz	short @F
;R13		mov	bl,00001100b	;enable FDD 3 mode
		xor	bl,bl		;R13
		mov	cl,55h		;R13
		call	Get_ALi5113	;R13
		test	al,00001100b	;R13
		jz	short No_Set	;R13
		jmp	short GOTO_SET	;R13
@@:
		mov	cl,55h		;R13
		call	Get_ALi5113	;R13
		test	al,00001100b	;R13
		jnz	short No_Set	;R13
GOTO_SET:				;R13
		mov	cl,55h
		call	Get_ALi5113
		and	al,NOT 00001100b
		or	al,bl
		call	Set_ALi5113
No_Set:

		popa
		ret
Set_FDD_3_mode	EndP
;R36ifndef	PNP_BIOS			;R12
ifdef	NO_Have_Superio_PNP_Node		;R36
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
ALI_PORT	EQU	03F1h
Get_Ali5113	Proc	Near
		pushf
		push	dx
		cli
		call	En_Ali5113_Cfg
		in	al,dx
		pop	dx
		popf
		ret
Get_Ali5113	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Ali5113	Proc	Near
		pushf
		push	dx
		cli
		call	En_Ali5113_Cfg
		out	dx,al
		pop	dx
		popf
		ret
Set_Ali5113	endp

En_Ali5113_Cfg:
		push	ax
		mov	dx,ALI_PORT
		mov	al,051h
		out	dx,al
		IODELAY
		mov	al,29h
		out	dx,al
		IODELAY
		in	al,dx
		IODELAY
		mov	al,cl
		out	dx,al
		IODELAY
		pop	ax
		ret
endif;	NO_Have_Superio_PNP_Node		;R36
;R36endif	;PNP_BIOS			;R12
endif	;Ali5113

;R04 - start

ifdef	UMC_8669
;[]===========================================================[]
;
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
;
; Saves: SP,BP , no stack available
;
; Input : AL = 0 - Disable
;	       1 - Enable
;
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
;R12 - start
ifdef	PNP_BIOS
	extrn	PNPIO_Get_8669:Near	
	extrn	PNPIO_Set_8669:Near	
endif	;PNP_BIOS
;R12 - end
Set_FDD_3_mode	Proc	Near
		pusha

		shl	al,1
		mov	bl,al
		mov	cl,0C2h
ifndef	PNP_BIOS				;R12
		Call	Get_8669
else	;PNP_BIOS				;R12
		Call	PNPIO_Get_8669		;R12
endif	;PNP_BIOS				;R12
		and	al,not 2
		or	al,bl
;--- Programming CR2 Register Set
ifndef	PNP_BIOS				;R12
		Call	Set_8669
else	;PNP_BIOS				;R12
		Call	PNPIO_Set_8669		;R12
endif	;PNP_BIOS				;R12

		popa
		ret
Set_FDD_3_mode	EndP
ifndef	PNP_BIOS				;R12
UMC8669_INDEX	EQU	108h
Get_8669	PROC	NEAR
                mov     dx,UMC8669_INDEX
                mov     al,0aah
                out     dx,al
		iodelay
		iodelay
                mov     al,cl
                out     dx,al
		iodelay
		iodelay
                inc     dx                      ;I/O port 109h
                in	al,dx
		iodelay
		iodelay
                dec     dx
		push	ax
		pop	ax

		ret
Get_8669	ENDP
Set_8669	PROC	NEAR
		push	ax
                mov     dx,UMC8669_INDEX
                mov     al,0aah
                out     dx,al
		iodelay
		iodelay
                mov     al,cl
                out     dx,al
		iodelay
		iodelay
                inc     dx                      ;I/O port 109h
		pop	ax
                out     dx,al
		iodelay
		iodelay
                dec     dx
		push	ax
		pop	ax

		ret
Set_8669	ENDP
endif	;PNP_BIOS				;R12
endif	;UMC_8669
;R04 - end

;R49 - start
;R49Aifdef	Ali5113D
ifdef	Ali5113B				;R49A
		extrn	Set_FDD_3_mode:near
endif	;Ali5113B				;R49A
;R49Aendif	;Ali5113D
;R49 - end

;R07 - Start
ifdef	Ali5123

ifdef	Use_370h
	Ali5123_PORT	EQU	370h
else	;Use_370h
	Ali5123_PORT	EQU	3f0h
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
;R12 - start
ifndef	PNP_BIOS					;R29
NO_Have_Superio_PNP_Node		EQU	1	;R29
endif;	PNP_BIOS					;R29
;R29ifdef	PNP_BIOS
ifndef	NO_Have_Superio_PNP_Node			;R29
	extrn	Set_Logic_Device:Near
	extrn	Enable_5123:Near
	extrn	Disable_5123:Near
	extrn	Get_ALi5123:Near	
	extrn	Set_ALi5123:Near	
endif	;PNP_BIOS
;R12 - end
Set_FDD_3_mode	Proc	Near
		pusha
		push	ax		;R12
		call	Enable_5123
		xor	cl, cl		;device 0 for FDD
		call	Set_Logic_Device
		pop	ax		;R12
		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00001100b	;enable FDD 3 mode
@@:
		mov	cl, 0f1h
		call	Get_ALi5123
		and	al,NOT 00001100b
		or	al,bl
		call	Set_ALi5123

		call	Disable_5123
		popa
		ret
Set_FDD_3_mode	EndP

;R29ifndef	PNP_BIOS				;R12
ifdef	NO_Have_Superio_PNP_Node			;R29
;[]==============================================================[]
;Input	: CL - logic device to set
;Output	: None
;[]==============================================================[]
Set_Logic_Device	proc	near
			push	ax
		    	mov	al,cl		;logic device
			mov	cl,07H		;index for logic device register
		 	call	Set_Ali5123
			pop	ax
			ret
Set_Logic_Device	endp

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_Ali5123	Proc	Near
		pushf
		cli
		call	En_Ali5123_Cfg
		in	al,dx
		popf
		ret
Get_Ali5123	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Ali5123	Proc	Near
		pushf
		cli
		call	En_Ali5123_Cfg
		out	dx,al
		popf
		ret
Set_Ali5123	endp

En_Ali5123_Cfg:
		push	ax
		mov	dx,Ali5123_PORT
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Enable_5123	Proc	Near
		push	ax
		mov	dx,Ali5123_PORT
		mov	al,051H			;unlock pattern
		out	dx,al			;need 2 continuous write
		mov	al,023H			;unlock pattern
		out	dx,al
		pop	ax
		ret
Enable_5123	Endp

Disable_5123	Proc	Near
		push	ax
		mov	dx,Ali5123_PORT
		mov	al,0BBH			;lock pattern
		out	dx,al
		pop	ax
		ret
Disable_5123	Endp
endif;	Have_Superio_PNP_Node			;R29
;R29endif	;PNP_BIOS				;R12
endif	;Ali5123
;R07 - End

;R47- start
;R47Aifdef	ALi513x
;R47AALi513xF		EQU	1
;R47Aendif	;ALi513x
;R47Aifdef	ALi513xB
;R47AALi513xF		EQU	1
;R47Aendif	;ALi513xB
;R47 - end
;R34 - start
ifdef	Ali513xF
ifdef	Use_370h
	Ali513xF_PORT	EQU	370h
else;	Use_370h
	Ali513xF_PORT	EQU	3f0h
endif;	Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Set_Logic_Device:Near
	extrn	Enable_513xF:Near
	extrn	Disable_513xF:Near
	extrn	Get_ALi513xF:Near	
	extrn	Set_ALi513xF:Near	
endif	;PNP_BIOS

Set_FDD_3_mode	Proc	Near
		pusha
		push	ax
		call	Enable_513xF
		xor	cl, cl		;device 0 for FDD
		call	Set_Logic_Device
		pop	ax
		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00001100b	;enable FDD 3 mode
@@:
		mov	cl, 0f1h
		call	Get_ALi513xF
		and	al,NOT 00001100b
		or	al,bl
		call	Set_ALi513xF

		call	Disable_513xF
		popa
		ret
Set_FDD_3_mode	EndP

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: CL - logic device to set
;Output	: None
;[]==============================================================[]
Set_Logic_Device	proc	near
			push	ax
		    	mov	al,cl		;logic device
			mov	cl,07H		;index for logic device register
		 	call	Set_Ali513xF
			pop	ax
			ret
Set_Logic_Device	endp

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_Ali513xF	Proc	Near
		pushf
		cli
		call	En_Ali513xF_Cfg
		in	al,dx
		popf
		ret
Get_Ali513xF	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Ali513xF	Proc	Near
		pushf
		cli
		call	En_Ali513xF_Cfg
		out	dx,al
		popf
		ret
Set_Ali513xF	endp

En_Ali513xF_Cfg:
		push	ax
		mov	dx,Ali513xF_PORT
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Enable_513xF	Proc	Near
		push	ax
		mov	dx,Ali513xF_PORT
		mov	al,051H			;unlock pattern
		out	dx,al			;need 2 continuous write
		mov	al,023H			;unlock pattern
		out	dx,al
		pop	ax
		ret
Enable_513xF	Endp

Disable_513xF	Proc	Near
		push	ax
		mov	dx,Ali513xF_PORT
		mov	al,0BBH			;lock pattern
		out	dx,al
		pop	ax
		ret
Disable_513xF	Endp
endif;	PNP_BIOS
endif;	Ali513xF
;R34 - End

;R08 - Start
IFDEF	Protech_special
;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
Set_FDD_3_mode	Proc	Near
		pusha

		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00001100b	;enable FDD 3 mode
@@:
		mov	cl,55h
		call	Get_ALi5113
		and	al,NOT 00001100b
		or	al,bl
		call	Set_ALi5113

		popa
		ret
Set_FDD_3_mode	EndP

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
ALI_PORT	EQU	03F1h
Get_Ali5113	Proc	Near
		pushf
		push	dx
		cli
		call	En_Ali5113_Cfg
		in	al,dx
		pop	dx
		popf
		ret
Get_Ali5113	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Ali5113	Proc	Near
		pushf
		push	dx
		cli
		call	En_Ali5113_Cfg
		out	dx,al
		pop	dx
		popf
		ret
Set_Ali5113	endp

En_Ali5113_Cfg:
		push	ax
		mov	dx,ALI_PORT
		mov	al,051h
		out	dx,al
		IODELAY
		mov	al,29h
		out	dx,al
		IODELAY
		in	al,dx
		IODELAY
		mov	al,cl
		out	dx,al
		IODELAY
		pop	ax
		ret
endif	;Protech_special
;R08 - End
;R09 - Start

ifdef	SMC37C669

ifdef	Use_370h
	SMC669_PORT	EQU	370H
else	;Use_370h
	SMC669_PORT	EQU	3f0H
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifndef	PNP_BIOS					;R30
NO_Have_Superio_PNP_Node		EQU	1	;R30
endif;	PNP_BIOS					;R30
;R30ifdef	PNP_BIOS
ifndef NO_Have_Superio_PNP_Node				;R30
	extrn	Get_Smc669:Near		;R12
	extrn	Set_Smc669:Near		;R12
endif	;PNP_BIOS			;R12
Set_FDD_3_mode:
		pusha

		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00011000b	;enable FDD 3 mode
@@:
ifdef	High_Active_3mode
		xor	bl,00001000b
endif	;High_Active_3mode
		mov	cl,5
		call	Get_Smc669
		and	al,NOT 00011000b
		or	al,bl
		call	Set_Smc669

		popa
		ret
;R30ifndef	PNP_BIOS				;R30
ifdef	NO_Have_Superio_PNP_Node			;R30
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
;R12Get_Smc669	Proc	Near
Get_Smc669:				;R12
		pushf
		cli
		call	En_Smc669_Cfg
		in	al,dx
		call	Dis_Smc669_Cfg
		popf
		ret
;R12Get_Smc669	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
;R12Set_Smc669	Proc	Near
Set_Smc669:					;R12
		pushf
		cli
		call	En_Smc669_Cfg
		out	dx,al
		call	Dis_Smc669_Cfg
		popf
		ret
;R12Set_Smc669	endp

En_Smc669_Cfg:
		push	ax
		mov	dx,SMC669_PORT
		mov	al,055H			;unlock pattern
		out	dx,al			;need 2 continuous write
		out	dx,al
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Dis_Smc669_Cfg:
		push	ax
		mov	dx,SMC669_PORT
		mov	al,0AAH			;lock pattern
		out	dx,al
		pop	ax
		ret
endif;	Have_Superio_PNP_Node			;R30
;R30 endif	;PNP_BIOS				;R12
endif	;SMC37C669
;R09 - End
;R44 - start
ifdef	SMC37N869

ifdef	Use_370h
	SMC869_PORT	EQU	370H
else	;Use_370h
	SMC869_PORT	EQU	3f0H
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifndef	PNP_BIOS
NO_Have_Superio_PNP_Node		EQU	1
endif;	PNP_BIOS
ifndef NO_Have_Superio_PNP_Node
	extrn	Get_Smc869:Near
	extrn	Set_Smc869:Near
endif	;PNP_BIOS
Set_FDD_3_mode:
		pusha

		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00011000b	;enable FDD 3 mode
@@:
ifdef	High_Active_3mode
		xor	bl,00001000b
endif	;High_Active_3mode
		mov	cl,5
		call	Get_Smc869
		and	al,NOT 00011000b
		or	al,bl
		call	Set_Smc869

		popa
		ret

ifdef	NO_Have_Superio_PNP_Node
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_Smc869:
		pushf
		cli
		call	En_Smc869_Cfg
		in	al,dx
		call	Dis_Smc869_Cfg
		popf
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_Smc869:
		pushf
		cli
		call	En_Smc869_Cfg
		out	dx,al
		call	Dis_Smc869_Cfg
		popf
		ret

En_Smc869_Cfg:
		push	ax
		mov	dx,SMC869_PORT
		mov	al,055H			;unlock pattern
		out	dx,al			;need 2 continuous write
		out	dx,al
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Dis_Smc869_Cfg:
		push	ax
		mov	dx,SMC869_PORT
		mov	al,0AAH			;lock pattern
		out	dx,al
		pop	ax
		ret
endif;	Have_Superio_PNP_Node
endif	;SMC37N869
;R44 - end
;R10 - Start
IFDEF	SMC37C93X

ifdef	Use_370h
	_Smc93X_PORT	EQU	370h
else	;Use_370h
	_Smc93X_PORT	EQU	3f0h
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS			;R12
	extrn	Get_Smc93x:Near		;R12
	extrn	Set_Smc93x:Near		;R12
endif	;PNP_BIOS			;R12
Set_FDD_3_mode:
		pusha
		xor	bl, bl		;set normal mode
		or	al, al
		jz	short @f
		mov	bl, 00001100b	;set 3 mode
	@@:
		mov	cl, 7
		xor	al, al		;set Logical device '0' for FDD
		call	Set_Smc93x

		mov	cl, 0f1h
		call	Get_Smc93x
		and	al, 11110011b
		or	al, bl
		call	Set_Smc93x
		popa
		ret

ifndef	PNP_BIOS			;R12
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
;R12Get_SMC93X	Proc	Near
Get_SMC93X:				;R12
		pushf
		cli
		call	En_SMC93X_Cfg
		in	al,dx
		call	Dis_SMC93X_Cfg
		popf
		ret
;R12Get_SMC93X	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
;R12Set_SMC93X	Proc	Near
Set_SMC93X:				;R12
		pushf
		cli
		call	En_SMC93X_Cfg
		out	dx,al
		IODELAY
		call	Dis_SMC93X_Cfg
		popf
		ret
;R12Set_SMC93X	endp

En_SMC93X_Cfg:
		push	ax
		mov	dx,_SMC93X_PORT
		mov	al,055H			;unlock pattern
		out	dx,al			;need 2 continuous write
		IODELAY
		out	dx,al
		IODELAY
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Dis_SMC93X_Cfg:
		push	ax
		mov	dx,_SMC93X_PORT
		mov	al,0AAH			;lock pattern
		out	dx,al
		IODELAY
		pop	ax
		ret
endif;	PNP_BIOS				;R12
ENDIF	;SMC37C93X
;R10 - End

;R11 - start
ifdef	ITE8680

;R12ITE8680_Init_Tbl:
;R12;--- Initial key string about I/O port ---
;R12ifdef	IO_PORT_USE_370H
;R12		;--- I/O port = 370h ---
;R12		ID8680_PORT	=	370H
;R12		db	086H,080H,0AAH,055H
;R12elseifdef	IO_PORT_USE_3BDH
;R12		;--- I/O port = 3BDh ---
;R12		ID8680_PORT	=	3BDH
;R12		db	086H,080H,055H,0AAH
;R12else
;R12		;--- I/O port = 3f0h ---
;R12		ID8680_PORT	=	3F0H
;R12		db	086H,080H,055H,055H
;R12endif	;IO_PORT_USE_370H
;R12Seq_Data:
;R12;--- Initial key string ---
;R12		db	06aH,0b5H,0daH,0edH,0f6H,0fbH,07dH,0beH
;R12		db	0dfH,06fH,037H,01bH,00dH,086H,0c3H,061H
;R12		db	0b0H,058H,02cH,016H,08bH,045H,0a2H,0d1H
;R12		db	0e8H,074H,03aH,09dH,0ceH,0e7H,073H,039H
;R12Enable_8680_Fdd_3_Mode:
;R12		db	07H,00H			;enable Fdd
;R12		db	0f0H,01H			;
;R12	;lock ITE8680
;R12		db	02h,02h
;R12
;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
;Program register of ITE8680 to enable or disable Fdd 3 mode
		extrn	Unlock_8680:Near	;R12
		extrn	Lock_8680:Near		;R12
		extrn	Get_8680:Near		;R12
		extrn	Set_8680:Near		;R12
		public	Set_FDD_3_mode
Set_FDD_3_mode:
		pusha
		call	Unlock_8680
;R12		mov	ax,0007h
		mov	cl,07h			;R12
		xor	al,al			;R12
		call	Set_8680
		popa
		pusha
		xor	bl,bl			;set normal mode
		or	al,al
		jz	short @F
		mov	bl,00000010b		;set 3 mode
@@:
;R12		mov	al,0f0h
		mov	cl,0f0h			;R12
		call	Get_8680
		and	al,not 00000010b
		or	al,bl
;R12		xchg	ah,al
;R12		mov	al,0f0h
		call	Set_8680
;R12		mov	ax,0202h
		mov	al,02h			;R12
		mov	cl,02h			;R12
		call	Set_8680
		popa
		ret

;R12Set_8680	proc	near
;R12		mov	dx,ID8680_PORT
;R12		out	dx,al
;R12		NEWIODELAY
;R12		xchg	ah,al
;R12		inc	dx
;R12ifdef	IO_PORT_USE_3BDH
;R12		inc	dx
;R12endif	;IO_PORT_USE_3BDH
;R12		out	dx,al
;R12		NEWIODELAY
;R12		ret
;R12Set_8680	endp
;R12
;R12Get_8680	proc	Near
;R12		mov	dx,ID8680_PORT
;R12		out	dx,al
;R12		NEWIODELAY
;R12		inc	dx
;R12ifdef	IO_PORT_USE_3BDH
;R12		inc	dx
;R12endif	;IO_PORT_USE_3BDH
;R12		in	al,dx
;R12		NEWIODELAY
;R12		ret
;R12Get_8680	endp
;R12
;R12Unlock_8680	proc	Near
;R12		pusha
;R12		mov	si,offset DGROUP:ITE8680_Init_Tbl
;R12		mov	dx,279h
;R12		mov	cx,4
;R12@@:
;R12		mov	al,byte ptr cs:[si]
;R12		out	dx,al
;R12		inc	si
;R12		loop	short @B
;R12
;R12		mov	si,offset DGROUP:Seq_Data
;R12		mov	dx,ID8680_PORT
;R12		mov	cx,20h
;R12@@:
;R12		mov	al,byte ptr cs:[si]
;R12		out	dx,al
;R12		inc	si
;R12		loop	short @B
;R12		popa
;R12		ret
;R12Unlock_8680	endp
endif	;IT8680
;R11 - end
;R15 - Start
IFDEF	W83977AF

ifdef	Use_370h
	W83977AF_PORT	EQU	370h
else	;Use_370h
	W83977AF_PORT	EQU	3f0h
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Set_Logic_Device:Near
	extrn	Unlock_967:Near
	extrn	Lock_967:Near
	extrn	Get_967:Near	
	extrn	Set_967:Near	
endif	;PNP_BIOS

Set_FDD_3_mode:
		pusha
		push	ax		;R12
		call	Unlock_967
		xor	cl, cl		;R26set Logical device '0' for FDD
		call	Set_Logic_Device;R26
		pop	ax		;R12
		xor	bl, bl		;set normal mode
		or	al, al
		jz	short @f
;R26		mov	bl, 00001000b	;set 3 mode
		mov	bl, 00000001b	;R26set 3 mode
	@@:
;R26		xor	al, al		;set Logical device '0' for FDD
;R26		call	Set_Logic_Device

;R26		mov	cl, 0f1h
		mov	cl, 0f0h	;R26
		call	Get_967
;R26		and	al, 11100111b	;R26
		and	al, 11111110b
		or	al, bl
		call	Set_967

		call	Lock_967

		popa
		ret

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: AL - logic device to set
;Output	: None
;[]==============================================================[]
Set_Logic_Device:
		push	ax

		xchg	al,cl
		mov	cl,07H		;index for logic device register
	 	call	Set_967

		pop	ax
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_967:
		mov	dx,W83977AF_Port
		mov	al,cl
		out	dx,al
		NEWIODELAY
		inc	dx
		in	al,dx
		NEWIODELAY
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_967:
		push	ax
		mov	dx,W83977AF_Port
		mov	al,cl
		out	dx,al
		NEWIODELAY
		pop	ax
		inc	dx
		out	dx,al
		NEWIODELAY
		ret

Unlock_967:
		mov	dx,W83977AF_port
		mov	al,087H			;unlock pattern
		out	dx,al			;need 2 continuous write
		out	dx,al
		ret

Lock_967:
		mov	dx,_W83977AF_port
		mov	al,0AAH			;lock pattern
		out	dx,al
		ret

endif	;PNP_BIOS
ENDIF	;W83977AF
;R15 - End

;R28 - Start
IFDEF	W83977TF

ifdef	Use_370h
	W83977TF_PORT	EQU	370h
else	;Use_370h
	W83977TF_PORT	EQU	3f0h
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Set_Logic_Device:Near
	extrn	Unlock_977:Near
	extrn	Lock_977:Near
	extrn	Get_977:Near	
	extrn	Set_977:Near	
endif	;PNP_BIOS

Set_FDD_3_mode:
		pusha
		push	ax
		call	Unlock_977
		xor	cl, cl		;set Logical device '0' for FDD
		call	Set_Logic_Device
		pop	ax
		xor	bl, bl		;set normal mode
		or	al, al
		jz	short @f
		mov	bl, 00000001b	;R26set 3 mode
	@@:
		mov	cl, 0f0h
		call	Get_977
		and	al, 11111110b
		or	al, bl
		call	Set_977

		call	Lock_977

		popa
		ret

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: AL - logic device to set
;Output	: None
;[]==============================================================[]
Set_Logic_Device:
		push	ax

		xchg	al,cl
		mov	cl,07H		;index for logic device register
	 	call	Set_977

		pop	ax
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_977:
		mov	dx,W83977TF_Port
		mov	al,cl
		out	dx,al
		NEWIODELAY
		inc	dx
		in	al,dx
		NEWIODELAY
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_977:
		push	ax
		mov	dx,W83977TF_Port
		mov	al,cl
		out	dx,al
		NEWIODELAY
		pop	ax
		inc	dx
		out	dx,al
		NEWIODELAY
		ret

Unlock_977:
		mov	dx,W83977TF_port
		mov	al,087H			;unlock pattern
		out	dx,al			;need 2 continuous write
		out	dx,al
		ret

Lock_977:
		mov	dx,_W83977TF_port
		mov	al,0AAH			;lock pattern
		out	dx,al
		ret

endif	;PNP_BIOS
ENDIF	;W83977TF
;R28 - End

;R54 - start
ifdef	PC87363
	PC87364		EQU	1
endif	;PC87363
;R54 - end
;R52 - start
ifdef	PC87366
	PC87364		EQU	1
endif	;PC87366
ifdef	PC87364
		extrn	Set_FDD_3_mode:near
endif	;PC87364
;R52 - end

;R48 - start
ifdef	W83627HF
	W83627F		EQU	1
endif	;W83627HF
ifdef	W83627F
		extrn	Set_FDD_3_mode:near
endif	;W83627F
;R48 - end

;R18 - start
IFDEF	NS307

;R37ifdef	IO_PORT_USE_02EH
		;--- I/O port = 2Eh ---
		NS307_PORT	=	2EH
;R37else
;R37		;--- I/O port = 15Ch ---
;R37		NS307_PORT	=	15CH
;R37endif	;IO_PORT_USE_2EH	

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Set_Logic_Device:Near
	extrn	Get_NS307:Near	
	extrn	Set_NS307:Near	
endif	;PNP_BIOS

Set_FDD_3_mode:
		pusha

		xor	bl, bl		;set normal mode
		or	al, al
		jnz	short @f
		mov	bl, 00100000b	;set 3 mode
	@@:
;R55		mov	al, 3		;set Logical device '0' for FDD
		mov	cl, 3		;R55 set Logical device '0' for FDD
		call	Set_Logic_Device

		mov	cl, 0f0h
		call	Get_NS307
		and	al, 11011111b
		or	al, bl
		call	Set_NS307

		popa
		ret

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: AL - logic device to set
;Output	: None
;[]==============================================================[]
Set_Logic_Device:
		push	ax

		xchg	al,cl
		mov	cl,07H		;index for logic device register
	 	call	Set_NS307

		pop	ax
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_NS307:
		mov	al,cl
		mov	dx,NS307_Port
		out	dx,al
		NEWIODELAY
		inc	dx
		in	al,dx
		NEWIODELAY
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_NS307:
		push	ax
		mov	al,cl
		mov	dx,NS307_Port
		out	dx,al
		NEWIODELAY
		pop	ax
		inc	dx
		out	dx,al
		NEWIODELAY
		ret

endif	;PNP_BIOS
ENDIF	;NS307
;R18 - End

;R19 - start

ifdef	ITE8661

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
;Program register of ITE8680 to enable or disable Fdd 3 mode
		extrn	Unlock_8661:Near
		extrn	Get_8661:Near
		extrn	Set_8661:Near
		public	Set_FDD_3_mode
Set_FDD_3_mode:
		pusha
		call	Unlock_8661
		mov	cl,07h
		xor	al,al
		call	Set_8661
		popa
		pusha
		xor	bl,bl			;set normal mode
		or	al,al
		jz	short @F
		mov	bl,00000010b		;set 3 mode
@@:
		mov	cl,0f0h
		call	Get_8661
		and	al,not 00000010b
		or	al,bl
		call	Set_8661
		mov	al,02h
		mov	cl,02h
		call	Set_8661
		popa
		ret

endif	;ITE8661
;R19 - end

;R50 - start
ifdef	ITE8712
ITE8702			EQU	1
endif	;ITE8712
ifdef	ITE8702
		extrn	Set_FDD_3_mode:near
endif	;ITE8702
;R50 - end

;R20 - Start
IFDEF	SMC37C67X

ifdef	Use_370h
	_Smc67X_PORT	EQU	370h
else	;Use_370h
	_Smc67X_PORT	EQU	3f0h
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Get_Smc67X:Near
	extrn	Set_Smc67X:Near
endif	;PNP_BIOS
Set_FDD_3_mode:
		pusha
		xor	bl, bl		;set normal mode
		or	al, al
		jz	short @f
		mov	bl, 00001100b	;set 3 mode
	@@:
		mov	cl, 7
		xor	al, al		;set Logical device '0' for FDD
		call	Set_Smc67X

		mov	cl, 0f1h
		call	Get_Smc67X
		and	al, 11110011b
		or	al, bl
		call	Set_Smc67X
		popa
		ret

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_SMC67X:
		pushf
		cli
		call	En_SMC67X_Cfg
		in	al,dx
		call	Dis_SMC67X_Cfg
		popf
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_SMC67X:
		pushf
		cli
		call	En_SMC67X_Cfg
		out	dx,al
		IODELAY
		call	Dis_SMC67X_Cfg
		popf
		ret

En_SMC67X_Cfg:
		push	ax
		mov	dx,_SMC67X_PORT
		mov	al,055H			;unlock pattern
		out	dx,al			;need 2 continuous write
		IODELAY
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Dis_SMC67X_Cfg:
		push	ax
		mov	dx,_SMC67X_PORT
		mov	al,0AAH			;lock pattern
		out	dx,al
		IODELAY
		pop	ax
		ret
endif;	PNP_BIOS
ENDIF	;SMC37C67X
;R20 - End

;R23 - Start
IFDEF	SMC37C68X

ifdef	Use_370h
	_Smc68X_PORT	EQU	370h
else	;Use_370h
	_Smc68X_PORT	EQU	3f0h
endif	;Use_370h

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Get_Smc68X:Near
	extrn	Set_Smc68X:Near
endif	;PNP_BIOS
Set_FDD_3_mode:
		pusha
		xor	bl, bl		;set normal mode
		or	al, al
		jz	short @f
		mov	bl, 00001100b	;set 3 mode
	@@:
		mov	cl, 7
		xor	al, al		;set Logical device '0' for FDD
		call	Set_SMC68X

		mov	cl, 0f1h
		call	Get_SMC68X
		and	al, 11110011b
		or	al, bl
		call	Set_SMC68X
		popa
		ret

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_SMC68X:
		pushf
		cli
		call	En_SMC68X_Cfg
		in	al,dx
		call	Dis_SMC68X_Cfg
		popf
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_SMC68X:
		pushf
		cli
		call	En_SMC68X_Cfg
		out	dx,al
		IODELAY
		call	Dis_SMC68X_Cfg
		popf
		ret

En_SMC68X_Cfg:
		push	ax
		mov	dx,_SMC68X_PORT
		mov	al,055H			;unlock pattern
		out	dx,al			;need 2 continuous write
		IODELAY
		mov	al,cl			;index number
		out	dx,al
		IODELAY
		inc	dx
		pop	ax
		ret

Dis_SMC68X_Cfg:
		push	ax
		mov	dx,_SMC68X_PORT
		mov	al,0AAH			;lock pattern
		out	dx,al
		IODELAY
		pop	ax
		ret
endif;	PNP_BIOS
ENDIF	;SMC37C68X

;R27 - start
ifdef	NS351					;R39
NS309			EQU	1		;R39
endif;	NS351					;R39
IFDEF	NS309

ifndef	IO_PORT_USE_15Ch
	NS309_PORT	EQU	02eh
else;	IO_PORT_USE_15Ch
	NS309_PORT	EQU	15Ch
endif;	IO_PORT_USE_15Ch

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifdef	PNP_BIOS
	extrn	Set_Logic_Device:Near
	extrn	Get_NS309:Near	
	extrn	Set_NS309:Near	
endif	;PNP_BIOS

Set_FDD_3_mode:
		pusha

		xor	bl, bl		;set normal mode
		or	al, al
		jnz	short @f
		mov	bl, 00100000b	;set 3 mode
	@@:
;R55		mov	al, 0		;set Logical device '0' for FDD
		xor	cl, cl		;R55 set Logical device '0' for FDD
		call	Set_Logic_Device

		mov	cl, 0f0h
		call	Get_NS309
		and	al, 11011111b
		or	al, bl
		call	Set_NS309

		popa
		ret

ifndef	PNP_BIOS
;[]==============================================================[]
;Input	: AL - logic device to set
;Output	: None
;[]==============================================================[]
Set_Logic_Device:
		push	ax

		xchg	al,cl
		mov	cl,07H		;index for logic device register
	 	call	Set_NS309

		pop	ax
		ret

;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_NS309:
		mov	al,cl
		mov	dx,NS309_Port
		out	dx,al
		NEWIODELAY
		inc	dx
		in	al,dx
		NEWIODELAY
		ret

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_NS309:
		push	ax
		mov	al,cl
		mov	dx,NS309_Port
		out	dx,al
		NEWIODELAY
		pop	ax
		inc	dx
		out	dx,al
		NEWIODELAY
		ret

endif	;PNP_BIOS
ENDIF	;NS309
;R27 - End

;R46 - start
ifdef	VIA686

;[]===========================================================[]
; Procedure Name: Set_FDD_3_mode
;	This routine is for control floppy 3 mode function
; Saves: SP,BP , no stack available
; Input : AL = 0 - Disable
;	       1 - Enable
; Output: None
;[]===========================================================[]
		public	Set_FDD_3_mode
ifndef	PNP_BIOS
NO_Have_Superio_PNP_Node		EQU	1
endif;	PNP_BIOS
ifndef NO_Have_Superio_PNP_Node
	extrn	Get_686:Near
	extrn	Set_686:Near
endif;	NO_Have_Superio_PNP_Node
Set_FDD_3_mode:
		pusha

		xor	bl,bl
		or	al,al
		jz	short @F
		mov	bl,00010000b	;enable FDD 3 mode (RegD6h[4])
@@:
		mov	cl,0D6h		; RegF6h
		call	Get_686
		and	al,NOT 00010000b
		or	al,bl
		call	Set_686

		popa
		ret

ifdef	NO_Have_Superio_PNP_Node
;[]==============================================================[]
;Input	: CL - register index
;Output	: AL - Value read
;[]==============================================================[]
Get_686	Proc	Near

		pushf
		cli
		call	En_686_Cfg
		in	al,dx
		call	Dis_686_Cfg
		popf

		ret

Get_686	endp

;[]==============================================================[]
;Input : CL - register index
;	 AL - Value to write
;Output: none
;[]==============================================================[]
Set_686	Proc	Near

		pushf
		cli
		call	En_686_Cfg
		out	dx,al
		call	Dis_686_Cfg
		popf

		ret

Set_686	endp

En_686_Cfg:
		push	ax
		push	bx
		push	cx
		mov 	cx, VT686 + 85h
		mov	bl, 02h		;686_RX85[1], configuration enable 
		call	Get_Set_Ct_OR
		
		mov	dx,_686_PORT
		pop	cx
		add	cl, 20h		;3057B mov C0-DF to E0-FF
		mov	al,cl		;get port to write
		out	dx,al
		inc	dx		;data port 3F1H
		pop	bx
		pop	ax
		ret

Dis_686_Cfg:
		push	ax
		push	bx
		push	cx
		mov 	cx, VT686 + 85h
		mov	bl, NOT 02h		;686_RX85[1], configuration enable 
		call	Get_Set_Ct_AND
		pop	cx
		pop	bx
		pop	ax
		ret
endif;	Have_Superio_PNP_Node
endif;	VIA686
;R46 - end

;R52 - start
ifdef	LPC47B27X
	LPC47U33X	EQU	1
endif	;LPC47B27X
;R52 - end

;R51 - start
ifdef	LPC47B27X
		extrn	Set_FDD_3_mode:near
endif;	LPC47B27X
;R51 - end



