;	[]===========================================================[]
;
;	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
;----------------------------------------------------------------------------
;R140	04/07/99 RCH	Reserved space for showing PCI IRQ routing information
;			in MODBIN.
;R139	03/31/99 RCH	Some customers (IPC vendor) don't want the hardware 
;			spurious interrupt to be masked even the interrupt
;			is generated by noise. Add a specific swtich to
;			support that (DONT_MASK_IRQ_FOR_SPURIOS).
;
;R138	03/20/99 KVN	Fixed HDD LED of M/B turn on a long time after reset
;			IDE controller.Now we send a NOP command for each
;			ATAPI device after reset IDE that can solve this problem.
;R137	03/12/99 BAR 	Suport Windows NT update BIOS.
;			Add BIOS Information in F000:E006 ,check data is 0aah.
;			BIOS_Information0
;   			 Bit0   = Support Win_NT update Flash ROM .
;			 Bit1~7 = Reservation
;			BIOS_Information1~3
;			 Bit0~15 = Reservation
;R136	03/12/99 RCH	Report memory space FFB00000-FFFFFFFF as reserved
;			memory of INT 15H function E820H for platform using
;			ICH (i810,i820 ..etc).
;R135	03/01/99 RAY	Fix code overflow when MP_SUPPORT is defined
;R133 	02/25/99 BAR	Reserve a byte space for save Flash ROM type.
;R132	12/31/98 KVN	Change the year of copyright from 1998 to 1999
;R131	12/29/98 RCH	Reserve a byte space for storing host clock frequency
;			of P6 CPU. Some chipsets need this information for
;			timing programming.
;R130	12/18/98 MCH	Fixed switch NO_PS2_MOUSE_SUPPORT compile error.
;R129	12/02/98 KVN	Support IDE DMA transfer function
;R128	10/12/98 KVN	Added Int 18h handler return to Int19h feature to fixed
;			HDLOCK tool work correctly.That is don't check active
;			flag for HDD.If HDD boot fail in master sector then it
;			will call Int 18h so we return to int 19h at this time.
;R127	10/08/98 RAY	Support K6-2 model 8's write allocation in which 
;			the write allocation limit bits are different from
;			model 7 & before
;
;R126B	10/07/98 KVN	Fixed coding mistake by R126A
;R126A	10/06/98 KVN	Fixed compiler error in some BIOS (e.g. 2A43xxxx)
;R126	10/03/98 KVN	Fixed execute ZDIAG.EXE test program of CPU test item
;			then cause system hang.That reason is BIOS not reset
;			SS:SP if test program issue shutdown then BIOS will
;			destroy memory content of SS:SP pointed
;R125A	09/29/98 ADS	Fixed complier error.
;R125	09/21/98 KEN	Increased the period of waiting mouse data for USB
;			mouse supporting.
;R124	09/03/98 DNL	Fixed some motherboard device no initial while BIOS	
;			support simple boot and system restart from WIN 98
;			ACPI mode
;R123	09/03/98 DNL	Fixed Intel TESTVIEW utility report memory size error
;M01  	09/02/98 RAY	Adapt Preboot-Agent from code modified by US
;	(01/29/98 TJM)  Added MPC 2.0 (Formerly RPB) modifications
;
;R122	08/11/98 KVN	Added "request sense command" to exactly report ATAPI
;			access status.That will dont delay or loop for some
;			boot fail CDROM
;R121A	07/08/98 DNL	R121 is chipset dependent problem so cancel R121
;R121	07/06/98 DNL	Fixed system halt when sytem from APM mode transfer
;			to ACPI mode (only for Intel chipsets)
;R120	06/15/98 TNY	Support onboard NCR810 ROM's memory node of ACPI.
;R119	06/11/98 DNL	Added USB memory usage report for ACPI BIOS to prevent
;			"Unreported memory" for HCT 7.5
;R118	05/21/98 DNL	Added memory usage report for ACPI BIOS	to prevent
;			"Unreported memory" for HCT 7.5
;R117 	05/08/98 DNL	Added sensor chip auto detection function for ACPI
;R116A	05/05/98 TNY	Fix code exploding.
;R116	04/28/98 KVN	Seprate 2 spurious handle to avoid mask wrong IRQ if
;			soft INT issue and set Int 0-77 vector default to
;			"SPURIOUS_soft_HDLR" subroutine.
;R115	04/16/98 KVN	IOMEGA release new ZIP drive support both original
;			ZIP mode and floppy emluation mode. BIOS need to 
;			program the new drive to Floppy mode, otherwise
;			it can be booted as drive A when new firmware is
;			used.
;R111A	03/13/98 RCH	Restore string location to fit old WIN2X4 utlility
;			spec.
;R114	03/10/98 DNL	Fully support SIMPLE BOOT spec. & speed up S4/BIOS resume
;R113	02/25/98 DNL	Remove unused code
;R112	02/24/98 DNL	Added ACPI S3 state support
;R111	02/19/98 RCH	Re-arrange string location. Also take out CACHE_PORT
;			support
;R110	02/13/98 KVN	Added ZIDA string area for ZIDA customer
;R108A	12/31/97 KVN	Fixed check 0C1h function of Int15 by wrong method
;R109	12/31/97 RCH	Change the year of copyright from 1997 to 1998
;R108	12/30/97 STV	Fixed Mylex DAC960 RAID controller card cannot work
;			successfully while the PS/2 mouse is not plugging,
;			the card will set to disable automatically while 
;			without PS/2 mouse.PS/2 mouse plugging flag isn't
;			config_table+5 ,so change to SYSTEM1_BYTE(bit 2).
;			Bit 2 of Config_Table+5 is for EBDA flag. 
;			See atorgs.asm
;R107	12/22/97 KGN	Add switch for cardbus card plug in system restart
;			Win95 will hang at Reset_PciMaster
;R106	12/15/97 BAR	Added two byte to store CDROM boot times 
;R94A	12/11/97 KVN	Moved size of xgroup code to 64K(original only 60K)
;R105	12/01/97 RCH	It's not necessary to have delay at power on stage
;			for compressed BIOS.
;R104	12/01/97 DNL	Added ACPI Thermal Zone support
;R103	11/27/97 DNL	Added ACPI on/off option support
;R102	10/27/97 LAW	Modify wait for completion interrupt From 1.5 to 2.5 second
;			to fixed OS/2 boot from A: error 
;R101	10/22/95 DNL	There is not enough space for Notebook BIOS , so mask
;			unuse codes to get more space
;R100	09/12/97 RCH	Fixed testing error of cyrix's software "cxm.exe"
;			for CPU M1/M2 with "CPU reset test"
;R98A	07/11/97 ADS	Fixed that R98 code mistake.
;R89B	08/07/97 DNL	Add ACPI Table size runtime assign function
;R99	07/18/97 TNY	Set F000:F810 to be UMC86xx PnP read port for ACPI.
;R98	07/11/97 KVN	POST runtime decompress code compact to subroutine
;R96A	07/10/97 RAX	Fix code will flow
;R97	07/02/97 RAX	Add define for Notebook.
;R96	06/30/97 RAX	Patch NeoMagic VGA will hang when use TV-out display
;			warm boot.
;R95	06/06/97 PTY	Add code for RPB
;R94	05/29/97 KVN	Added a new segment for store more BIOS code
;R93	05/21/97 KVN	Fix up beep sound frequence not fix if CPU clock is
;			different when memory, VGA or floppy error during POST
;R89B	05/06/97 KVN	Added ACPI function support
;R92	04/01/97 KVN	Added some code for Cyrix Gx86 & Cx5510 and VSA VGA
;R91    03/18/97 TNY    Add "NO_SUPPORT_AVIDEO" definition.
;R90    03/18/97 TNY    Add "NO_SUPPORT_AVIDEO" definition.
;R89A	03/11/97 KVN	Fixed system hang from SETUP exit or run warmboot
;R89	03/03/97 KVN	Added ACPI function support
;R88	01/22/97 RAY	Add Write Allocation support for K6 CPU
;R72C	01/15/97 RCH	VIA590+WINBOND877 issue a dummy IRQ on first 8259
;			channel 2 but can not read ISR status on second
;			8259 that cause second 8259 to be masked and take
;			about 30 seconds to boot IDE/HDD.
;R87	01/14/97 KVN	Support default password for some customer request if
;			you need please define "Support_AWARD_Default_Password"
;			in BIOS.CFG
;R83A	01/09/97 KVN	Cancel "No_Support_HiScan" parameter define for auto
;			support EMM386.EXE 'HIGHSCAN'
;R86	01/07/96 RCH	Change the year of copyright from 1996 to 1997
;R72B	12/31/96 RCH	ViperM+AHA3940+Create/SP16 failed with AVI play in
;			SCT v5.10
;R85	12/18/96 KVN	Cancle "AWARD_SW" default password in BIOS and set it
;			by MODBIN.EXE v4.50.60 or later
;R84	12/10/96 RCH	Fixed system can not reboot under SUNOS/UNIX v2.5 for
;			MP platform.
;R83	11/25/96 KVN	Ignore EMM386.EXE 'HIGHSCAN' parameter even added in
;			config.sys
;R82	11/09/96 RCH	BESTKEY+PS2 MOUSE+PENTUM 133Mhz cause installing
;			WIN v3.11 sometimes hang up.
;R81	10/04/96 KVN	Added boot HDD selectable function
;R80	09/23/96 KVN	Fixed NT 4.0 no emulation CD install to SCSI HDD fail
;R79	09/20/96 RAY	Add Public label: CPU_HALT to where CPU will enter
;			"HLT' state. This is added for the multi-processor
;			system as a destination code for the 2nd CPU.
;R78A	09/18/96 RCH	R78 cause MO compiliation error , move "INT18_HDLR" to
;			ORG E826H.
;R78	09/17/96 RCH	Change memory size report method to get memory hole
;			size table for function E820H
;R72A	09/17/96 RCH	Some customers request mask IRQ for spurious interrupt
;			, add switch "MASK_IRQ_FOR_SPURIOS"
;R77	09/07/96 RCH	Move part of codes from ATBASE.ASM to save F-segment
;			space
;R76	09/07/96 RCH	Procedure REPORT_ERR_WSPKR is only used by POST, so
;			put it in E-segment.
;R75	07/25/96 RCH	The PCI devices display become modbinable
;R62A	06/28/96 RCH	Added more delay for new chipset (like Triton HX)
;			to fix problem for Japanese DOS
;R74	05/09/96 RCH	Support PCI reset function for warm boot by using
;			I/O 0CF9H to reset system.
;R73	04/23/96 DNL	Added codes for notebook power management
;R72	03/07/96 RCH	Don't mask spurious interrupt , otherwise can not
;			play movie under WIN 3.1 "Media Player" with Acer's
;			CD-ROM driver and the sound is Crstal PnP card and
;			the IRQ for Window Sound System is assigned with
;			IRQ 5.
;R71	01/12/96 KVN	Added full screen logo display function
;R70	12/27/95 RCH	BIOS have to disable master bit of PCI devices to
;			fix system hung after warm booting for network card
;R65A	12/15/95 KVN	Added "AVIDEO_AT_F000" option for Release full E000 segment
;R69	12/09/11 RCH	P6 don't have 16bytes buffer , so change method for
;			supporting PnP/ESCD.
;R68	12/09/95 RCH	Mask IRQ if spurious interrupt occured for PCI BIOS
;R67	12/04/95 KVN	Fixed system hang after shutdown
;R66	11/22/95 RAY	Not only Cirrus Logic PCI VGA should set to Mode 3
;			immediately after warm boot, some other PCI VGA also
;			need to do the same thing. Thus we have to add
;			another name to the flag: CIRRUS_PCI_VGA.
;R65	11/01/95 KVN	Release full E000 segment size for none PNP bios
;R64	10/12/95 RCH	Kill unused codes of WAIT_FOR_PORT and WAIT_FOR_MEM
;R63	10/02/95 RCH	KBD_A20_OFF is POST only , so move it into POST.ASM
;R61A	10/02/95 RCH	Don't clear shutdown byte information for CPU re-reset
;R62	10/02/95 RCH	Screen become abormal if ruuing MS-DOS v6.2 for
;			Japanese with AMI K-series keyboard controller
;R61	09/30/95 DNL	The shutdown function is available in real mode only
;R60	09/21/95 RCH	There is not enough space for MP BIOS , so mask
;			unuse codes to get more space
;R59	09/05/95 RCH	Added special reset codes for ORION/P6 to patch
;			system hang during warm booting
;R20F	08/24/95 RCH	Don't call INT 10 to set mode during warm boot but
;			Cirrus PCI/VGA
;R58	08/22/95 DNL	Added "Ret_E_Seg" function to support protection mode
;			F000_Call
;R57	07/25/95 KVN	Fixed Irq 15 error when hook SiSdr.sys
;R56	06/13/95 KVN	Reduce Post_func_call and F000_call code size
;R55	06/01/95 KVN	Fixed BIOS_INFORM_STR too long then cover follow code
;			and CHIPSET_NAME add 'C' indicate is compress bios.
;R54	05/30/95 AVN	Fixed Warm Boot Fail If Install NE2000 And Drive.
;R53	05/24/95 RCH	Move codes from bootrom.asm due to some M/Bs hang up
;			while warmboot from OS2 for WB CPU
;R52	05/24/95 RCH	Fixed error coding according to R20
;R51	05/17/95 AVN	Fixed Routine Address Had Change If Modify Chiprun.asm
;			And FLASH_ROUTINE_HEAD Was Index Old Address Because
;			Can't Rewrite By Use INTEL BOOTBLOCK ROM.
;			FLASH_ROUTINE_HEAD Move To Chiprun.asm
;R50	05/17/95 RCH	Fixed system hang while press keyboard and PS2 mouse
;			simultaneously
;R49	05/16/95  KVN	Fix Wearnes CD-ROM driver bug. because this driver
;			only use INT-76 (IRQ14 and IRQ15)
;R48	04/12/95 RCH	BIOS will clear system configuation byte for PS2 mouse
;			,now we can check this byte to determine function
;			0c1h & 0c2h to be served or not
;R47	03/20/95  KVN	Fix coding mistake
;Rmv1	03/15/95  KVN	Move PS2 mouse ISR from AMOUSE.ASM to here
;Rmv	03/02/95  KVN	Move power on post code from multiser.asm to here
;R46	02/28/95  KVN	Add serial communication service (int 14h) function
;			4 and 5
;R41	02/23/95  AVN	Added New Flash Utility in chiprun.asm
;R40	02/23/95  RCH	Fixed error coding for INT75
;R39	12/13/94  KVN	Fixed up SONY ide CD-ROM error MODEL NO. is "CDU55E"
;R38	10/03/94  RCH	Kill silent POST table to get more useable space
;R37	09/16/94  RAY	Add Show_VESA_For_ISA support
;R36	09/10/94  RCH	Fixed sytem hang when press TAB key under KOREAN
;			DOSSHELL
;R35	09/09/94  RAY	Public Shadow_Adaptor
;R34	08/26/94  RAY	Add special 6845 mono settings
;R33	08/17/94  KVN	Added POST auto IDE detect function
;R32	08/17/94  RCH	Always shadow F0000-FFFFF ROM , because LBA and large
;			mode of IDE drive have to modify HDD parameters
;R31	07/12/94  RCH	Some chipsets should program registers to special
;			values , otherwise system can not work after CPU
;			reset.
;R30	07/09/94  RCH	Upgrade EISA BIOS into v4.50G
;R29	07/01/94  RCH	Skip virtual move block checking , it is already in
;			multiser.asm
;R28	06/08/94  KVN	Fixed up VLIDE.SYS drive bug
;R27	06/02/94  KVN	Support 4 IDE hard drives
;R26	06/01/94  RCH	Fixed some incompatibility testing from NSTL/LANBit
;			Labs
;R25	05/30/94  KVN	Added VESA bus option when [bios.cfg] define VESA_BUS.
;R24	05/02/94  RCH	PCI interrupt is level trigger and shareable , so
;			don't disable IRQ while spurious interrupt is occured
;R23	04/19/94  KVN	Some VGA card can't programable.For example : Trident
;			PCI-bus VGA, ET-4000AX VL-bus VGA.
;R22	02/25/94  RCH	Change PCI_SLOT_CFG slot config. argithm
;R21	03/23/94  KEN	Add option ROM scanning, avoid to shadow at blank
;			region
;R18	01/27/94  RCH	Don't support additional information screen any more
;R17	12/27/93  RCH	Don't turn on IRQ 15 in supurious routine
;R16	12/13/93  KVN	Fixed up some boards CMOS failure bug while read or
;			write.
;R15	11/04/93  RCH	Fixed NCR keyboard test utility INT 16h	function call
;			Errors
;R14	10/29/93  RAY	Check_In_Post decomes public
;R13	10/05/93  RCH	Let WR_CPU routine become public sevice
;R12	09/27/93  RCH	Added Green PC output control pin
;R11	09/27/93  RCH	Added Pin 31 as turbo switch input
;R10	08/17/93  RCH	Added PCI BIOS32 service directory support for v2.0G
;R09	08/16/93  RCH	Change default keyboard controller from AMI to ASII
;			 KB-100/200
;R08	08/11/93  RAY	Add PCI Slot Configuration
;R07	08/04/93  RCH	Replace default AWARD keyboard controller with AMI's
;R06	05/13/93  RAY	Add Power Management
;R05	05/12/93  RCH	Added baud rate table at E729H for compatible with IBM
;R04	04/08/93  RCH	Added MOTHERBOARD_ID & PRODUCT_ID modbinable
;R03	03/23/93  RCH	Modify motor spin up table ( because some chipset fail
;			 if system shadow is disabled )
;R02	03/08/93  RCH	Added jumpper setting table display support
;R01	03/03/93  RCH	Added power on delay support & POST color setting

		PAGE	63,132
		TITLE	ATORGS  -- AT ROM/BIOS COMPATIBLE SECTION

.386P
;[]-----------------------------------[]
;
;   Award Software 386/486 BIOS
;          ATORGS.ASM
;   Initial Revision 17-Apr-1990
;
;[]-----------------------------------[]



.XLIST
		INCLUDE BIOS.CFG
		INCLUDE COMMON.EQU

		INCLUDE POST.EQU

		INCLUDE PORT61.EQU

		INCLUDE 8042.EQU
		INCLUDE 8259.EQU
		INCLUDE 8254.EQU
		INCLUDE 8237.EQU

		INCLUDE ATORGS.EQU
                INCLUDE SETUP.EQU

		INCLUDE MATHCOP.EQU
		INCLUDE	HDISK.EQU

		INCLUDE	ATIME.EXT
		INCLUDE	AKBRD.EXT
		INCLUDE ATBASE.EXT
		INCLUDE SETUP.EXT
		INCLUDE MULTISER.EXT
		INCLUDE AHDSK.EXT
		INCLUDE ADISK.EXT
		INCLUDE AVIDEO.EXT
		INCLUDE USERINT.EXT

;M01 - starts
ifdef	RPB_ENABLED
		include	rpb.cfg
endif	;RPB_ENABLED
;M01 - ends

		include	btromseg.equ	;R98

;R97 start
ifdef	Notebook_Power_Management
ifndef	No_Battery_system
MASK_IRQ_FOR_SPURIOS	EQU	1
endif;	No_Battery_system
endif;	Notebook_Power_Management
;R97 end

;R65A start
ifndef	PNP_BIOS
AVIDEO_AT_F000		EQU	1
endif	;PNP_BIOS
;R65A end
ifdef	SPECIAL_ON_CPU_RESET						;R31
		extrn	PCI_CPU_RESET:near				;R31
endif;	SPECIAL_ON_CPU_RESET						;R31

ifdef Flash_2M_support					;R98A
		extrn	Enter_Protect_Mode:near		;R98
		extrn	Leave_Protect_Mode:near		;R98
endif; Flash_2M_support					;R98A
;Rmv		extrn	Redo:near
		extrn	EXCEPTION_HDLR:Near
;R77		extrn	PUP_WAIT1:Near
		extrn	E000_64K_shadow_RW:near		;R77
		extrn	E000_64K_shadow_R:near		;R77
		extrn	Move_Codes:near			;R77
		extrn	Normal_Post_Tests:near		;R77
		extrn	Ct_A20:Near

;R59 - start
ifdef	PATCH_ORION_PCI_RESET
		extrn	Orion_Reset_Patch:near
endif;	PATCH_ORION_PCI_RESET
;R59 - end

IF BUS_TYPE EQ EISA_BUS
                INCLUDE EISA.EQU
                INCLUDE EISAMAIN.EXT
                INCLUDE EISA_32.EXT
ENDIF ;BUS_TYPE

;R56		extrn	POST_func_end:Near
;R56		extrn	POST_VECT:Near
		extrn	Post_call_proc:near	;R56
		extrn	SETSPEED:near
		extrn	HDISK_PARMS:Near
		EXTRN	E000_VECT:NEAR			;R58
;R95 start
;M01ifdef RPB_ENABLED                   ; RXX
;M01  extrn rpb_is_running:near         
;M01endif ; RPB_ENABLED
;R95 end
;M01 - start
ifdef RPB_ENABLED
ifdef RPB_REBOOT_DISABLE
  extrn rpbf_prepare_for_reset:near
endif ; RPB_REBOOT_DISABLE
endif ; RPB_ENABLED
;M01 - end

		INCLUDE COMMON.MAC
		INCLUDE ATORGS.MAC
		INCLUDE	POST.MAC

.LIST

; MISCELLANEOUS
FILLER		EQU	'Award Software Inc. '

		PUBLIC	PRINT_HEX

		PAGE

;Rmv - start
		extrn	Init_Cyrix_Reg:near	;R21
		extrn	Cpu_Apic_Init:near
		extrn	IntCache_Item:near
		extrn	PUP_WAIT:near
		extrn	RESTORE_CYRIX_REG:near
		extrn	CT_RESTORE_CYRIX_REG:near
		extrn	GETITEM_CMOS:near
		extrn	EXC9HDLR:near
		extrn	PUP_WAIT:near
ifdef	PM_SUPPORT
		extrn	CT_SLEEP_DETECT:near
		extrn	CT_CHECK_SMI_START:near
		extrn	CT_RESUME_HANDLE:near
endif	;PM_SUPPORT

ifdef	ACPI_SUPPORT				;R89B			
		extrn	GDTR1:near		;R89B
		extrn	DATA1_INDEX:near	;R89B
;R114 - start
ifdef	SIMPLE_BOOT_SUPPORT
		extrn	Quick_Post_Tests:near
endif	;SIMPLE_BOOT_SUPPORT
ifdef	S4_SUPPORT
		extrn	S4_Post_Tests:near
 		extrn	Check_S4_Resume:near
endif	;S4_SUPPORT
;R114 - end
endif	;ACPI_SUPPORT				;R89B			
;[]---------------------------[]
;
;   Stack init
;
;[]---------------------------[]

BIOS_STK	SEGMENT	USE16 AT 0H
		ORG	400H
BIOSSTK_TOP	LABEL	WORD
		ORG	1000H
POSTSTK_TOP	LABEL	WORD

BIOS_STK	ENDS
;Rmv - end

G_RAM		SEGMENT	USE16 AT 040H

		INCLUDE	G_RAM.INC

		ORG	100H

STAT_BYTE	DB	?

G_RAM		ENDS

		PAGE

DGROUP		GROUP	@DATAC
@DATAC		SEGMENT	USE16 DWORD COMMON 'DATAC'
		ASSUME	CS:DGROUP,DS:DGROUP

		PUBLIC	DOUBLE_DOT		; AVIDEO.OBJ(AVIDEO)
		PUBLIC	TBL_MODE_CLEN		; AVIDEO.OBJ(AVIDEO)
		PUBLIC	TBL_MODE_COLM		; AVIDEO.OBJ(AVIDEO)
		PUBLIC	TBL_MODE_SETS		; AVIDEO.OBJ(AVIDEO)

		PUBLIC	HDERRORS		; AHDSK.OBJ(AHDSK)

		PUBLIC	KEYS			; AKBRD.OBJ(AKBRD)

		PUBLIC	BIOS_IDT		; MULTISER.OBJ(MULTISER)
		PUBLIC	CONFIG_TABLE		; MULTISER.OBJ(MULTISER)

		PUBLIC	SPURIOUS_INT_HDLR	; ATBASE.OBJ

		PUBLIC	AUX_ADDRS
		PUBLIC	AUX_PRN_ADDRS		; 303A
		PUBLIC	END_AUX_ADDRS		; 303A

		PUBLIC	FDC_PARS
		PUBLIC	INT_TBL
		PUBLIC	INT_TBL_HALF
		PUBLIC	SEC_HRDWR_INTS
		PUBLIC	IRET_VECT
		PUBLIC	INT_HDISK

		PUBLIC	ERR_HLT
		PUBLIC	SETTINGS


;REFERENCE ONLY

		PUBLIC	COMM_VECT
		PUBLIC	DSK_VECT
		PUBLIC	EQ_VECT
		PUBLIC	INT18_HDLR
		PUBLIC	INT19_VECT
		PUBLIC	INT71_REDIRECT
		PUBLIC	INT75_REDIRECT
		PUBLIC	IRET_VECT
		PUBLIC	MEM_SZ_VECT
		PUBLIC	PRNTSCR_VECT
		PUBLIC	TIMDAY_VECT
		PUBLIC	TIMER_VECT
		PUBLIC	VIDEO_PARMS
		PUBLIC	VIDEO_VECT
		PUBLIC	VECTOR_TABLE
		PUBLIC	RST_VECT

		PAGE

FILLER_VAR	DB	FILLER
		FILL_SIZE	= $ - FILLER_VAR
		DB	(2000H/FILL_SIZE) - 2*(FILL_SIZE)  DUP (FILLER)

		ORG	0

ORG_START:
;R137 - start
BIOS_Information0	= 	0		;default value
   ifdef	NT_FLASH		;Support Win_NT update Flash ROM
	BIOS_Information0	=	BIOS_Information0 + 01H ;bit 0
   endif;	NT_FLASH
BIOS_Information1	= 	0		;default value
BIOS_Information2	= 	0		;default value
BIOS_Information3	= 	0		;default value 
		CK_ORG	0E006H
		DB	0AAh  			;sign for new function support
		DB	BIOS_Information0	;e007h
		DW	BIOS_Information1	;e008h
		DW	BIOS_Information2	;e00ah
		DW	BIOS_Information3	;e00ch
;R137 - end

		public	ORG_OFFSET
		CK_ORG	0E00EH
		DB	'IBM COMPATIBLE'
		DB	' 486 BIOS COPYRIGHT Award Software Inc.';R111A
;R111A		DB	' IBM IS A TRADEMARK OF INTERNATIONAL BUSINESS MACHINES CORP.';R111
;R111		DB	' 486 BIOS COPYRIGHT Award Software Inc.'
;R111
;R111;MODBIN TABLE: CACHE INFORMATION
;R111;
;R111;	This table contains the information necessary for a standard
;R111;	I/O port cache. Do not move this table.
;R111;
;R111
;R111		CK_ORG	0E052H
;R111		PUBLIC	CACHE_PORT
;R111
;R111CACHE_PORT      DW      0C03H		;for INTEL EISA cache
;R111
;R111		PUBLIC	CACHE_ENABLE
;R111CACHE_ENABLE    DB      4H		;for INTEL EISA cache
;R111
;R111		PUBLIC  CACHE_DISABLE
;R111CACHE_DISABLE   DB      1H
;R111
;R111		PUBLIC	CACHE_SWITCH
;R111CACHE_SWITCH    DB      1

;R126A start
Get_ShutDown_Byte:
 		mov	al,0FH NMI_OFF		;get shutdown info.
 		out	CMOS,al
 		newiodelay
 	   	in	al,CMOS+1
 		newiodelay

		or	al,al			;warm reset or exit from setup
;R126B		ret
		jmp	Get_ShutDown_Byte_Ret		;R126B
;R126A end
;R133 - start
		CK_ORG	0E05AH	
		db	0ffh	;Reserve a byte space for save Flash ROM type.
;R133 - end
;[]==============================================================[]
;
;RESET VECTOR:
;
;	This is the location jumped to by the hardware reset vector
;	which can by called from anyware within the BIOS.
;
;
;Saves:	NONE
;
;Entry: NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM  | 18-Apr-90   | Updatate for 4.0
;
;[]==============================================================[]

		CK_ORG	0E05BH

	    	PUBLIC	RST_VECT
RST_VECT	PROC	NEAR
RST_VECT_NEAR	LABEL	NEAR

		JMP	REDO

RST_VECT	ENDP

;	MODBIN TABLE: CHECKSUM INFO
;
;	Used by MODBIN to identify BIOS's which have not been
;	checksum'd yet. Should have a 'C' here.

		CK_ORG	0E05FH
		DB	43H


;	START OF LINE 1: NOT MORE THAN 46 CHARACTERS
;
;	SIGN-ON MESSAGE:
;
;	This is the sign-on message printed at the top
;	of the screen during POST. It is composed of three sections:
;	the sign-on message and copyright message, which are only
;	changeable by source code and the evaluation message which
;	MODBIN can change.
;
;	The string must be null (00h) terminated. The length byte is
;	used by MODBIN to checksum the message and by POST to center
;	the strings.


		CK_ORG	0E060H
		PUBLIC	SIGN_ON_MSG
SIGN_ON_MSG	DB	SIGN_ON_MSG_L

		DB	'Award Modular BIOS'

IF1
	%OUT	Including VERS.INC
ENDIF

		INCLUDE	VERS.INC

		DB	0
SIGN_ON_MSG_L	EQU	$-SIGN_ON_MSG-1

;
;	SIGN-ON MESSAGE CHECKSUM:
;
;	Used by MODBIN to identify BIOS's which have
;	not been checksum'd yet. Should have an 'h' here. MODBIN then
;	checksums the sign-on message and puts the result here.
;
;	This byte must follow immediately after the message!
;

		PUBLIC	SIGN_ON_CHKSUM
SIGN_ON_CHKSUM	DB	68H

; Begin copyright message change

;	START OF LINE 2: NOT MORE THAN 46 CHARACTERS
;
;	COPYRIGHT_MSG:
;
;	This message is not changeable by MODBIN.
;
;	The string must be null (00h) terminated. The length byte is
;	used by MODBIN to checksum the message and by POST to center
;	the strings.
;

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT

		INCLUDE	MOUSE.EQU
		INCLUDE EXTDATA.EQU

; input register values in stack

bp_subf 	equ	byte ptr [bp+10h]	;al
bp_cmd		equ	byte ptr [bp+0fh]	;bh
bp_seg		equ	word ptr [bp+02h]	;es
bp_offset	equ	word ptr [bp+0eh]	;bx

; output register values in stack

bp_flag 	equ	word ptr [bp+16h]
bp_errcode	equ	byte ptr [bp+11h]	;ah
bp_bh		equ	byte ptr [bp+0fh]	;bh
bp_bl		equ	byte ptr [bp+0eh]	;bl
bp_cl		equ	byte ptr [bp+0ch]	;cl
bp_dl		equ	byte ptr [bp+0ah]	;dl

						;bp+16(flag)
						;bp+14(segment)
						;bp+12(offset)

address_tbl	label	word
		dw	offset DGROUP:size1
		dw	offset DGROUP:size2
		dw	offset DGROUP:size3
		dw	offset DGROUP:size4
		dw	offset DGROUP:size5
		dw	offset DGROUP:size6
		dw	offset DGROUP:size7
		dw	offset DGROUP:size8
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

		CK_ORG	0E090H
		PUBLIC	COPYRIGHT_MSG
COPYRIGHT_MSG:	DB	COPYRIGHT_MSG_L
;R132		DB	'Copyright (C) 1984-98, Award Software, Inc.';R86;R109
		DB	'Copyright (C) 1984-99, Award Software, Inc.';R132
		DB	00h
COPYRIGHT_MSG_L	EQU	$-COPYRIGHT_MSG-1
; End copyright message change


; START OF LINE 3
;
;	EVALUATION MESSAGE:

;	This is the part of the message which
;	can be changed via MODBIN for users to customize.
;
;	The string must be null (00h) terminated. The length byte is
;	used by MODBIN to checksum the message and by POST to center
;	the strings.
;
		CK_ORG	0E0C0H
		PUBLIC	EVAL_MSG
EVAL_MSG	DB	EVAL_MSG_L
		DB	'EVALUATION ROM - NOT FOR SALE !'
		DB	79-($-EVAL_MSG) DUP (0)
EVAL_MSG_L	EQU	$-EVAL_MSG-1

;
;	EVALUATION MESSAGE CHECKSUM:
;
;	Used by MODBIN to identify BIOS's
;	which have not been checksum'd yet. Should be a 'r' here
;	initially. MODBIN then checksums the evaluation message and
;	puts the result here.
;
;	This byte must follow immediately after the message!
;

		PUBLIC	EVAL_MSG_CHKSUM
EVAL_MSG_CHKSUM	DB	72H

;IBM DISCLAIMER:
;
;	Here for PR/legal reasons.
;

;R111		DB	' IBM IS A TRADEMARK OF INTERNATIONAL BUSINESS MACHINES CORP.'
		DB	' IBM IS A TRADEMARK OF INTERNATIONAL BUSINESS MACHINES CORP.';R111A


;***********************************************************************
;
;	The following code emulate LOADALL instruction on 386 processor
;
;***********************************************************************

;[]==============================================================[]
;
;LOADALL:
;
; Emulation of 286 opcode 0F 05 - LOADALL instruction.
;
; The LOADALL instruction is an undocumented function of the 286, designed
; to aid Intel in debugging the 286.  This opcode is NOT implemented on the
; 386, and executing a LOADALL instruction on the 386 results in an
; invalid-opcode fault, exception #6.
;
; (We are prompted to emulate LOADALL because some hackers at MicroSoft
; used it in OS2, causing it to crash on 386s.)
;
; The LOADALL instruction loads all 286 registers from a user prepared
; table at 800:0.  This includes the descriptor caches, lending to a
; variety of weird things that can be done.  We concentrate on 2 of the
; more useful things, since it is impossible to emulate the instruction
; exactly.  (Impossible, unless Intel has hidden an equivalent 386
; instruction somewhere).
;
; 1) The CPU can be made to address regions of RAM above 1M while still
;    in REAL MODE, simply by forcing DS/ES segment register descriptor
;    caches to point above 1M.  Note the visible selector portion (the
;    16 bit segment register value) need not contain anything valid or
;    consistent with its associated cache.  Until the segment register
;    is reloaded, the CPU will adhere to the Limit/Base/Access-Rights
;    values in the cache.
;
;    Our treatment of this case:
;	- Load all general registers per table
;	- Assume SS remains in REAL space, loading the SELECTOR
;	  (ignoring descriptor cache) from the table
;	- Deduce whether DS/ES is to use the SELECTOR (ie, REAL compatible)
;	  or the LIMIT/BASE/ACCESS descriptor cache (ie, PROTECTED).
;	  We determine this by evaluating if the BASE points to the same
;	  physical location as the SELECTOR.
;	    --If so, the SELECTOR is REAL-compatible; we use it "as is".
;	    --Else, we use the LIMIT/BASE/ACCESS cache value, by creating
;	      a temporary GDT, entering PROTECTED mode, loading DS/ES
;	      via the temporary GDT, then returning to REAL mode.  Note
;	      this will in general leave the visible segment register with
;	      a value different than the user's table value.  But it works
;	      ok, since the L/B/A value is what the user wants.  Note als0,
;	      the instant the user reloads that segment register, the L/B/A
;	      is reloaded by the CPU with REAL-compatible values.
;	- Assume CS remains in REAL space, loading the SELECTOR
;	  (ignoring descriptor cache) from the table (upon exit, via IRET)
;	- All special PROTECTED mode support registers (TSSR,TR,LDTR,GDTR)
;	  are preserved, not updated, except GDT.  Since we trash GDTR
;	  by building a temporary GDT, we do load it per table entry.
;
; 2) The CPU can be put into PROTECTED MODE, with all registers pre-loaded.
;    There is no real benefit to entering PROTECTED MODE via this
;    unconventional method, unless something very weird is being done.
;    If so, we probably don't emulate it correctly anyway.
;
;    Our treatment of this case is much simpler than the 1st.  We load
;    up all registers from the table, trusting that the GDT reference
;    is valid (and that, if the GDT is in an odd-MegaByte bank, the
;    gate A20 has been enabled by the user).
;
;
; The LOADALL table has this format:
;
; Physical address (Hex)	CPU Register
; --------------		----------------
; 800-805			none
; 806-807			MSW
; 808-815			none
; 816-817			TR   (selector)
; 818-819			FLAGS
; 81A-81B			IP
; 81C-81D			LDTR  (selector)
; 81E-81F			DS
; 820-821			SS
; 822-823			CS
; 824-825			ES
; 826-827			DI
; 828-829			SI
; 82A-82B			BP
; 82C-82D			SP
; 82E-82F			BX
; 830-831			DX
; 832-833			CX
; 834-835			AX
; 836-838,839,83A-83B 		ES descriptor cache: base, access, limit
; 83C-83E,83F,840-841		CS descriptor cache: base, access, limit
; 842-844,845,846-847		SS descriptor cache: base, access, limit
; 848-84A,84B,84C-84D		DS descriptor cache: base, access, limit
; 84E-850,851,852-853		GDTR          cache: base, xxxxxx, limit
; 854-856,857,858-59		LDT           cache: base, xxxxxx, limit
; 85A-85C,85D,85E-85F		IDTR          cache: base, xxxxxx, limit
; 860-862,863,864-865		TSS           cache: base, xxxxxx, limit
;
;[]==============================================================[]

        	PUBLIC	LOADALL
LOADALL		PROC	FAR
INT06_ISR	LABEL	FAR


;
; Did a LOADALL instruction cause this INT6 ?
;

		PUSH	BP
		MOV	BP, SP
		PUSH	SI
		PUSH	DS
		LDS	SI, DWORD PTR SS:[BP+2]
		CMP	WORD PTR DS:[SI], 050FH
		JE	SHORT DO_LOADALL

; Maybe 0F 04 - Kill CPU?

		CMP	WORD PTR DS:[SI], 040FH		; 286 KILL-CPU opcode
		JE	SHORT KILL_CPU

; Maybe fault from LOCK instruction?

		CMP	BYTE PTR DS:[SI], 0F0H		; LOCK opcode
		JE	SHORT INT6_INC

; Maybe invalid REP/REPNE ?

		CMP	BYTE PTR DS:[SI], 0F2H
		JE	SHORT INT6_INC

; Maybe invalid REPE ?

		CMP	BYTE PTR DS:[SI], 0F3H
		JNE	SHORT INT6_EXIT

INT6_INC:
		INC	SI
		MOV	WORD PTR SS:[BP+2], SI

INT6_EXIT:
; Well, maybe somebody did INT6 just for fun.

		POP	DS
		POP	SI
		POP	BP
		IRET

KILL_CPU:
		JMP	KILL_MACHINE


Loadall_GDTaddr	DW	4*8		;limit GDT
		DD	800h		;base address for GDT index 00h

Loadall_GDT	DW	0FFFFh,0,9B0Fh,0;index 08h BIOS (CS)-descriptor
		DW	0,0,0,0		;index 10h USER (ES)-descriptor
		DW	0,0,0,0		;index 18h USER (DS)-descriptor

DO_LOADALL:
		xor	ax,ax
		mov	ds,ax			;DS set to loadall image
		mov	es,ax			;ES set to loadall image
		mov	ss,word ptr ds:[820h]	;set SS:SP to user stack
		mov	sp,word ptr ds:[82Ch]
		push	word ptr ds:[818h]	;put flag -> [SP]
		push	word ptr ds:[822h]	;    CS	  -> [SP-2]
		push	word ptr ds:[81Ah]	;    IP   -> [SP-4] for IRET
;
		mov	di,808h			;preserve user's MSW
		mov 	si,offset DGROUP:loadall_GDT
		mov	cx,3*8
		cld
		rep	movs byte ptr [di],cs:[si] ;temporary GDT into ldallbuf
;
		mov	dx,word ptr ds:[806h]	;save machine status word
;
		mov	si,word ptr ds:[836h][4];ES_limit0_15 to loadall_table
		mov	word ptr ds:[810h],si
		mov	si,word ptr ds:[836h][0];ES_base0_15 to loadall_table
		mov	word ptr ds:[812h],si
		mov	bl,byte ptr ds:[836h][2];ES_base16_23
		mov	bh,93h			;ES_access
		mov	word ptr ds:[814h],bx	;put into loadall_table
		xchg	bl,bh			;ES_access into BL
;						;ES_base16_23 into BH

		mov	di,word ptr ds:[848h][4];DS_limit0_15 to loadall_table
		mov	word ptr ds:[818h],di
		mov	di,word ptr ds:[848h][0];DS_base0_15 to loadall_table
		mov	word ptr ds:[81Ah],di
		mov	cl,byte ptr ds:[848h][2];DS_base16_23
		mov	ch,93h			;DS_access
		mov	word ptr ds:[81Ch],cx	;put into loadall_table
		xchg	cl,ch			;DS_access into BL
;						;DS_base16_23 into BH
		test	bh,0F0h			;ES_base20_23 > 1M byte?
		jnz 	short load_a1		;if above, check (DS)-base next
		test	si,0Fh			;ES_base0_3, aligned 16?
		jnz	short load_a1		;not paragraph aligned
;						;(ES) is within real
		shr	si,4			;aaaaaaaa:aaaa0000 >> 4
		xor	bl,bl
		shl	bx,4			;0000aaaa:00000000 << 4
		or	si,bx			;(SI) has ES_real
		mov	es,si			;load ES segment register real
;
load_a1:
		test	ch,0F0h			;DS_base20_23 > 1M byte?
		jnz 	short load_a2		;if above, check (DS)-base next
		test	di,0Fh			;DS_base0_3, aligned 16?
		jnz	short load_a2		;not paragraph aligned
;						;(ES) is within real
		shr	di,4			;aaaaaaaa:aaaa0000 >> 4
		xor	cl,cl
		shl	cx,4			;0000aaaa:00000000 << 4
		or	di,cx			;(DI) has DS_real
		mov	ds,di			;load DS segment register real
;
load_a2:
		mov	al,bl			;if DS and ES already set up real,
						; we are done
		or	al,cl
		jz	short load_a_iret

		lgdt	fword ptr cs:[Loadall_GDTaddr] ;prepare for protected mode
		smsw	ax
		or	ax,01h			;set PE_BIT in MSW for prot mode
		lmsw	ax

		db	0EAh			;FAR_JMP $+4,8
		dw	0E000h+$+4              ;flush queue and load CS selector
		dw	8                       ; and cache

		or	bl,bl			;ES already loaded for real mode?
		jz	short load_a3		;yes - no need to load ES-cache

		mov	ax,10h			;index for ES-descriptor
		mov 	es,ax			;load ES selector and cache

load_a3:
		or	cl,cl			;DS already loaded for real mode?
		jz	short load_a_exit	;yes - no need to load DS-cache

		mov	ax,18h			;index for DS-descriptor
		mov 	ds,ax			;load DS selector and cache
	;
load_a_exit:
		mov	eax,cr0
		and	al,0F0h			;turn off protected mode
		and 	dl,0Eh			;and set status from user MSW's
		or	al,dl
		mov	cr0,eax

		db	0EAh			;FAR_JMP $+4,0F000h
		dw	0E000h+$+4              ;flush queue and load CS selector
		dw	0F000h
	;
load_a_iret:
		xor	ax,ax
		mov	fs,ax			;using (FS), DS,ES cant be touched
						; here
		pop	word ptr fs:[81Ah]	;restore user's IP from stack
		add	sp,2			;no need to restore cs
		pop	word ptr fs:[818h]	;restore user's flags fro stack
		mov	ss,ax
		mov	sp,826h
		popa				;lodall general registers
		mov	sp,word ptr ss:[82Ch]	;set user stack pointer seperately
		sub	sp,6			;set SP to flags,CS,IP for IRET
		mov	ss, word ptr ss:[820h]	;set user stack segment
		iret
LOADALL		ENDP


		PUBLIC	DELAY
DELAY		PROC	NEAR			; delay for io device to settle
		NEWIODELAY
		NEWIODELAY
		ret
DELAY		ENDP
		ASSUME	DS:DGROUP


;*****************************************
;Name:   	ENABLE_PARITY
;Entry:  	called
;Input:
;Output:	AL - VALUE WRITTEN TO SYS1
;Description:
;
;ENABLE_PARITY will:
;1. 	CLEAR PARITY, THEN TURN RAM AND IO ENABLE BITS ON ON SYS1
;*****************************************
		ALIGN	4			; N3.03
		PUBLIC	ENABLE_PARITY
ENABLE_PARITY	PROC	NEAR
		CALL	CLEAR_PARITY		; CLEAR POSSIBLE PARITY
		AND	AL,PARITY_CHECK_ON	; ENABLE PARITY
		OUT	SYS1,AL
		RET
ENABLE_PARITY	ENDP

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT
subftbl 	label	word
		dw	offset DGROUP:subf_00
		dw	offset DGROUP:subf_01
		dw	offset DGROUP:subf_02
		dw	offset DGROUP:subf_03
		dw	offset DGROUP:subf_04
		dw	offset DGROUP:subf_05
		dw	offset DGROUP:subf_06
		dw	offset DGROUP:subf_07

;*****************************************************************************
; Procedure Name:	cmd_02
;	set scaling factor 2:1
; Saves:
; Inputs:	none
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 03 : interface error
;				= 04 : resend
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

CMD_02		PROC	NEAR
		mov	al,ms_setscl		; set scaling 2:1 command
do_scale:
		extrn	out_aux:near
		call	out_aux
		jz	short wait_cmd02_ack		; ok, if no IBF
		jmp	error_03		; interface error
wait_cmd02_ack:
		call	wait_ack		; wait response and set status
		jmp	func_c2_ret
CMD_02		ENDP

endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

		CK_ORG	0E2C3H
;[]==============================================================[]
;
;NMI_VECT:
;
;	Compatibility ORG for NMI handler.
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]
		PUBLIC	NMI_HDLR
NMI_HDLR	PROC	NEAR
		PUBLIC	NMI_VECT
NMI_VECT	LABEL	FAR

;R14		jmp	Check_In_Post
		jmp	Check_In_Post1	;R14
Normal_Nmi:

;R06 start
ifdef	PM_SUPPORT
		extrn	Check_PM_Using_NMI:Near
		jmp	Check_PM_Using_NMI
NMI_Original:	Public	NMI_Original
endif	;PM_SUPPORT
;R06 end

		PUSH	AX

		extrn	Clear_Ibm_Parity:near
		call	Clear_Ibm_Parity

ifndef	NO_PARITY_DURING_MEM_SIZING
		push	dx
		POST_CODE 0B1H
		pop	dx
endif;	NO_PARITY_DURING_MEM_SIZING

IF BUS_TYPE EQ EISA_BUS
                call    Eisa_NMI_Chk
ENDIF ;BUS_TYPE

		MOV	AL,0FH NMI_OFF		; release nmi - no parity
		CALL	GET_CMOS

		; CLEAR PARITY, CHECK PARITY AH HAS OLD PORT READ

		IN	AL,SYS1			; get value from port
		MOV	AH,AL			; save value

		CALL	CLEAR_PARITY		; 303A

		TEST	AH,PARITY_CHECK		; and see if parity
		JNE	SHORT NMI_1

		MOV	AL,AH			; set status again
		NEWIODELAY
		OUT	SYS1,AL			; CLEARING OF PARITY BITS

		MOV	AL,0FH NMI_ON
		CALL	GET_CMOS

		POP	AX
		IRET

		ALIGN	4			; N3.03
NMI_1:
	;AX IS ON STACK FROM ABOVE
		PUSH	BX
		PUSH	CX
		PUSH	DX
		PUSH	DI
		PUSH	SI
		PUSH	DS			; FOR POSSIBLE RETURN LATER
	; first set stack to first 64k
		PUSH	AX			; save value from 8042
						; previous value is in ah!!
		MOV	AL,DISABLE_KBRD		; disable keyboard
		OUT	STAT8042,AL
		CALL	BUFFER_8042_FULL	; and wait

		IN	AL,DATA8042		; get current setting
		NEWIODELAY
		MOV	AL,0C0H
		OUT	STAT8042,AL
		CALL	BUFFER_8042_FULL	; and wait
		CALL	OUT_8042_FULL

		MOV	AX,G_RAM
		MOV	DS,AX			; set segment
		ASSUME	DS:G_RAM

		MOV	AL,[CON_MODE]	; and get crt mode
		INT	10H			; clear screen

		POP	AX			; recover value
		PUSH	AX			; SAVE IN CASE F1 KEY PRESSED

		TEST	AL,IOCHANNEL_CHECK	; parity error?
		JZ	SHORT T1		; NO, PARITY ERROR

		MOV	SI,OFFSET DGROUP:IO_PAR_ERR

		TEST	AL,MEMORY_CHECK
		JZ	SHORT T2

		CALL	WR_STR_TTY		; PRINT THIS MESSAGE
		; FALL THROUGH AND PRINT OTHER MESSAGE

T1:		MOV	SI,OFFSET DGROUP:PL_PAR_ERR
T2:		CALL	WR_STR_TTY

		MOV	AL,0EFH NMI_OFF		; disable nmi
		OUT	CMOS,AL

		CALL	ENABLE_PARITY

		MOV	DX,[SIZE_SYSRAM]	; get amount of memory and
		SHR	DX,1			; in 64k banks
		MOV	DI,DX			; and save
		XOR	BX,BX			; see where error is

		ALIGN	4			; N3.03
LL1:		MOV	DS,BX
		ASSUME	DS:NOTHING

		XOR	SI,SI
		MOV	CX,8000H
		CALL	ENABLE_PARITY		; set parity toggle

		CLD
		REP	LODSW

		IN	AL,SYS1			; see if error in bank
		AND	AL,PARITY_CHECK		; PARITY
		JNZ	SHORT LL2		; this bank has error

		ADD	BX,1000H		; bank address
		DEC	DX
		JNZ	SHORT LL1		; next bank

LL2:		MOV	SI,OFFSET DGROUP:STRSEGMENT
		CALL	WR_STR_TTY

		CMP	DI,BX			; see if error found
		JE	SHORT LL3

		PUSH	BX
		CALL	PRINT_HEX
		POP	BX

		CALL	ENABLE_PARITY
		JMP	SHORT NMI_USER_OPTION

LL3:		MOV	SI,OFFSET DGROUP:PAR_UNKNOWN	; N3.03
		CALL	WR_STR_TTY

NMI_USER_OPTION:
		MOV	SI,OFFSET DGROUP:NMI_OPTION_MSG
		CALL	WR_STR_TTY

NMI_USER_WAIT:
		;POP	AX	ON STACK FROM NMI_1, WHO CARES NOW...
		XOR	AH,AH
		INT	16H
		CMP	AH,3BH			; WAIT FOR 'F1' KEY
		JE	SHORT NMI_PROCESS_F1
		CMP	AH,3CH			; WAIT FOR 'F2' KEY
		JE	SHORT NMI_PROCESS_F2
		MOV	SI,OFFSET DGROUP:NMI_HALT_MSG
		CALL	WR_STR_TTY

;		POST_CODE 0E1h
		POST_CODE 0B2h 			;E1H confuse with setup code
SYSTEM_HALT:	STI
		HLT
		JMP	SHORT SYSTEM_HALT

NMI_PROCESS_F1:					; NOTE: DUPLICATE PREVIOUS IRET
		;SET FLAG
; AL IS RECOVERED FROM ABOVE TO MAKE SURE THAT WE DON'T DISABLE IO CHECK
; FOR AUTOSWITCH CARDS WHEN WE DIDN'T MEAN TO.
; WE MUST FIRST ESTABLISH THE OLD ENABLE BITS,
; SEE IF THERE IS A NEW ENABLE BIT, THEN SET THE DISABLE/ENABLE BITS
; DON'T FORGET THE REV0/REV1 LOGIC FOR NEAT...REV0 KIND OF WORKS REV1 WORKS
; REVERSE LOGIC PLACEMENT OF ENABLE/DISABLE BITS TO XOR
;
		CALL	CLEAR_PARITY		; DON'T RE-ENABLE
		MOV	CH,AL			; SAVE FROM IMMENENT DESTRUCTION
		AND	CH,NOT 0CH		; GET RID OF ENABLE BITS
		POP	AX			; RESTORE FROM NMI_1
		MOV	AL,AH			; FIRST VALUE IS SAVED IN AH!!!
		AND	AH,00CH			; GET OLD ENABLE BITS
		AND	AL,0C0H			; GET NEW CHECK BIT(S)
; CHECK BITS AND ENABLE BITS APPEAR TO BE REVERSED WITH REV 0
		SHR	AL,4			; ROTATE TO ENABLE POSITION
		MOV	BL,AL			; SWAP BITS 3 2
		SHR	BL,1			; MOVE BIT 3 TO BIT 2
		AND	BL,04H			; MASK BIT 2
		SHL	AL,1			; MOVE BIT 2 TO BIT 3
		AND	AL,08H			; MASK BIT 3
		OR	AL,BL			; PLACE BITS
		OR	AL,AH			; PUT OLD DISABLED BIT(S) INTO AL
						; DISABLED BITS ARE 1
		OR	AL,CH			; PUT OTHER BITS FROM SYS1 IN PLACE
		OUT	SYS1,AL			; PLACE ON PORT

		MOV	AL,0EH NMI_ON
		CALL	GET_CMOS		; RE-ENABLE NMI

		POP	DS			; RESTORE ENVIRONMENT FROM NMI_1
		POP	SI
		POP	DI
		POP	DX
		POP	CX
		POP	BX
		POP	AX			; RESTORE FROM NMI_HDLR ENTRY
		STI				; JUST IN CASE
		IRET

NMI_PROCESS_F2:
		;POP	AX	ON STACK FROM NMI_1, WHO CARES NOW...
		JMP	REDO
NMI_HDLR	ENDP

;R78A		ALIGN	4
;R78AINT18_HDLR	PROC	NEAR
;R78A		MOV	AX,G_RAM			; set up segment register.
;R78A		MOV	DS,AX
;R78A		ASSUME	DS:G_RAM
;R78A
;R78A		XOR	AH,AH				; set mode command.
;R78A		MOV	AL,[CON_MODE]
;R78A		INT	10H				; clear the screen.
;R78A		MOV	SI,OFFSET DGROUP:INT18_MSG	; write the message.
;R78A		CALL	WR_STR_TTY
;R78A		XOR	AH,AH				; wait for a key.
;R78A		INT	16H
;R78A		MOV	USER_REBOOT,CTRL_ALT_DEL	; reset the computer.
;R78A		JMP	REDO
;R78AINT18_HDLR	ENDP

;[]==========================================================[]
;
; A20_ON:
;
;	Turn on gate A20.
;
; ENTRY:	NONE
;  EXIT:	Z	JZ (Z=1) if success, JNZ (Z=0) if failed
;
; DESTROYS: AX
;
;[]==========================================================[]

		ALIGN	4
		PUBLIC	A20_ON
A20_ON		PROC	NEAR

		mov	al,0DFh
;First Check If fast gate A20
		push	ax
		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM
		test	byte ptr FDD_VERIFY_CMD_FLAG,10h
		pop	ax
		jz	short Key_A20

		push	ax
		call	Ct_A20
		pop	ax
		jnc	Good_Fast_A20		; fast A20 support

;If carry set means no fast Gate A20 support, use keyboard GATE A20
Key_A20:

; 		mov	al,0DFh			;A20 on
 		test	cs:[SETTINGS],SPD_SW_DISABLE	;is speed switching
 		jnz	short v_m_b_0			;  disabled?
 		push	ds
 		mov	ax,G_RAM
		push	ax
 		pop	ds
		assume	ds:G_RAM
 		mov	al,cs:[SP_STATE]	;get speed switch pattern
 		and	al,0ch			;strip unused bits and assume HI speed
 		mov	ah,al			;
 		xor	ah,0ch			;reverse 0s to 1s and 1s to 0s to
						;  create an OR mask for unused
						;  bits.

 		test	[INIT_ERR_FLG],80h	;current HIGH speed ?
 		pop	ds
 		jnz	short set_hi		;jump if so
 		xor	al,0ch			;low speed
set_hi:
		test	cs:[SPD_DEF],SPD_POL	;check speed switch polarity
 		jz	short set_sp		;jump if high active high
 		xor	al,0Ch			; CHANGE POLARITY
set_sp:
		or	al,0D3h			;output byte with speed	control
 		or	al,ah			;set unused bits to High.

v_m_b_0:
		jmp	short Address_20

A20_ON		ENDP

;[]==========================================================[]
;
; A20_OFF:
;
;	Turn off gate A20.
;
;ENTRY:	NONE
;EXIT:	Z	JZ (Z=1) if success, JNZ (Z=0) if failed
;
;DESTROYS: AX
;
;[]==========================================================[]

		ALIGN	4
		PUBLIC	A20_OFF
A20_OFF		PROC	NEAR

		mov	al,0DDh
;First Check If fast gate A20
		push	ax
		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM
		test	byte ptr FDD_VERIFY_CMD_FLAG,10h
		pop	ax
		jz	short Key_A20_1

		push	ax
		call	Ct_A20
		pop	ax
		jnc	short Good_Fast_A20		; fast A20 support

;If carry set means no fast Gate A20 support, use keyboard GATE A20
Key_A20_1:
 		test	cs:[SETTINGS],SPD_SW_DISABLE	; is speed switching
 		jnz	short J0		; disabled?

 		push	ds
 		mov	ax,G_RAM
 		mov	ds,ax
		assume	ds:G_RAM
 		mov	al,cs:[SP_STATE]	; speed swicth pattern
 		and	al,0ch			; strip unused bits and assume hi speed
 		mov	ah,al			; copy to ah 303a
 		xor	ah,0ch			; create OR mask for unused bits
 		test	[INIT_ERR_FLG],80h	; current high speed ?
 		pop	ds
 		jnz	short set_hi1		; jump if so

 		xor	al,0ch			; low speed

set_hi1:
		test	cs:[SPD_DEF],SPD_POL	; check speed switch polarity
 		jz	short set_sp1		; jump if high active high

 		xor	al,0ch			; change polarity

set_sp1:
		or	al,0d1h			; output byte with speed flag
 		or	al,ah			; unused bits = 1.
J0:
		jmp	short Address_20

A20_OFF		ENDP


;[]==========================================================[]
;
;  ADDRESS_20:
;
;	This is the main routine which turns on or off gate
;	A20.
;
; ENTRY:	AL = 	0DDh to turn off A20 gate
; 			0DFh to turn on A20 gate
;
;  EXIT:	Z	JZ (Z=1) if success, JNZ (Z=0) if failed
;
; DESTROYS: AX
;
;[]==========================================================[]

		ALIGN	4
		PUBLIC	ADDRESS_20
ADDRESS_20	PROC	NEAR

		push	cx			; save cx
		mov	ah,al			; save data

		call	Buffer_8042_Full	; check for empty
		jnz	short add_fail

		mov	al,0D1h			; send command
		out	STAT8042,al

		call	Buffer_8042_Full	; wait for command ready
		jnz	short add_fail

		mov	al,ah			; send data
		out	DATA8042,al

		call	Buffer_8042_Full	; and make sure got there
		jnz	short add_fail

		mov	cx,4			;R62A
Wait_A20:					;R62A
		NEWIODELAY			;R62
		loop	short Wait_A20		;R62A
;R62A		NEWIODELAY			;R62

		xor	al,al
		pop	cx
		ret

add_fail:
		pop	cx
		stc
		ret

Good_Fast_A20:
		clc
		xor	al,al
		ret

ADDRESS_20	ENDP

;R63 ;[]==========================================================[]
;R63 ;KBD_A20_OFF
;R63 ;
;R63 ;	Procedure to disable GATE A20 on the keyboard
;R63 ;	controller. This is necessary for FAST A20
;R63 ;	operation because if KBD A20 is enabled, gate A20
;R63 ;	cannot be disabled with FAST A20 (the A20 line
;R63 ;	will always be enabled which will screw up any
;R63 ;	software that needs the 1 meg wrap around.
;R63 ;
;R63 ;    INPUT: NONE
;R63 ;   OUTPUT: KBD gate A20 is disabled
;R63 ;
;R63 ;    SAVES: AX BX CX DX
;R63 ;
;R63 ;[]==========================================================[]
;R63 		ALIGN	4
;R63 		PUBLIC KBD_A20_OFF
;R63 KBD_A20_OFF 	PROC	NEAR
;R63
;R63 		push	ax
;R63 		mov	al,0ddh			;gate a20 off command
;R63 ;R02 - start
;R63 		test	CS:[SPD_DEF],01H	; is low speed active low?
;R63 		jz	short No_Active_Low
;R63 		and	al,11110011b		;set 23 and 24 pins low
;R63 No_Active_Low:
;R63 ;R02 - end
;R63
;R63 a20_op:
;R63 		push	bx
;R63 		push	cx
;R63 		push	dx
;R63
;R63 		push	ax
;R63 		call	Buffer_8042_Full	; wait for kb inbuff empty
;R63 		jnz	short a20_op_bad	; return if empty
;R63
;R63 		mov	al,0D1h			; write output port command
;R63 		out	STAT8042,al
;R63
;R63 		call	Buffer_8042_Full	; and wait
;R63 		jnz	short a20_op_bad	; timeout, jump out of here
;R63
;R63 		pop	ax			; command byte
;R63 		out	DATA8042,al
;R63
;R63 		call	Buffer_8042_Full	; and make sure got there
;R63 		jz	short a20_op_ret
;R63
;R63 		push	ax			; push junk onto stack
;R63 a20_op_bad:
;R63 		pop	ax			; get junk off stack
;R63 		stc				; set carry for error
;R63 a20_op_ret:
;R63 		pop	dx
;R63 		pop	cx
;R63 		pop	bx
;R63 		pop	ax
;R63 		ret
;R63 KBD_A20_OFF     ENDP

		include	cpurun.asm

;Rmv start
QUERY_SYSTEM_ADDRESS_MAP	equ	1
ifdef	QUERY_SYSTEM_ADDRESS_MAP
MEM_AVAILABLE	EQU	1
MEM_RESERVED	EQU	2
;R89 start
ifdef	ACPI_Support
ACPI_TABLE	EQU	3
ACPI_NVS	EQU	4	
endif;	ACPI_Support
;R89 end
		public	Addr_Range_Tbl
Addr_Range_Tbl:
Base639Kb:	dd	0		;32-bit low address
		dd	0		;32-bit high address
		dd	639*1024	;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_AVAILABLE
		public	ADDR_RNG_SIZE
ADDR_RNG_SIZE	EQU	$ - Base639Kb

		public	ExtData1Kb
ExtData1Kb:	dd	09fc00H		;32-bit low address
		dd	0		;32-bit high address
		dd	1*1024		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_AVAILABLE	;if mouse install , set it to reserve

SystemBios64Kb:	dd	0f0000H		;32-bit low address
		dd	0		;32-bit high address
		dd	64*1024		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_RESERVED	;system BIOS

;R78		public	ExtMem128Mb
;R78ExtMem128Mb:dd	100000H		;32-bit low address
;R78		dd	0		;32-bit high address
;R78		dd	127*1024*1024	;32-bit length low dword
;R78		dd	0		;32-bit length high dword
;R78		dd	MEM_AVAILABLE	;extended memory, this field should
					;filled by POST

ifdef	MP_SUPPORT
IoApic4Kb:	dd	0fec00000H	;32-bit low address
		dd	0		;32-bit high address
		dd	4*1024		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_RESERVED	;I/O APIC

LocalApic4Kb:	dd	0fee00000H	;32-bit low address
		dd	0		;32-bit high address
		dd	4*1024		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_RESERVED	;local APIC
endif;	MP_SUPPORT

OverlayBios64Kb:
;R136 - start
ifdef	ICH
		dd	0ffb00000H	;32-bit low address
		dd	0		;32-bit high address
		dd	5*1024*1024 	;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_RESERVED	;remapped system bios at end of addr.
else;	ICH
;R136 - end
		dd	0ffff0000H	;32-bit low address
		dd	0		;32-bit high address
		dd	64*1024		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_RESERVED	;remapped system bios at end of addr.
endif;	ICH				;R136

;R103 ;R89 start
;R103 ifdef ACPI_Support
;R103 		public	ACPITableAddress
;R103 ACPITableAddress: 	
;R103 		dd	000000H		;32-bit low address (filled in by SETUP_PS2)
;R103 		dd	0		;32-bit high address
;R103 ;R89B		dd	ACPITableSize*1024;32-bit length low dword
;R103 		dd	0		;R89B 32-bit length low dword
;R103 		dd	0		;32-bit length high dword
;R103 		dd	ACPI_TABLE	;
;R103 
;R103 		public	ACPINVSAddress
;R103 ACPINVSAddress: 	
;R103 		dd	000000H		;32-bit low address (filled in by SETUP_PS2)
;R103 		dd	0		;32-bit high address
;R103 		dd	ACPINVSSize*1024;32-bit length low dword
;R103 		dd	0		;32-bit length high dword
;R103 		dd	ACPI_NVS	;
;R103 endif;ACPI_Support
;R103 ;R89 end

;R78 - start
		public	ExtMem128Mb
ExtMem128Mb: 	dd	100000H		;32-bit low address
		dd	0		;32-bit high address
		dd	14*1024*1024	;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_AVAILABLE	;extended memory, this field should
					;filled by POST

		public	MemHole_15Mb
MemHole_15Mb: 	dd	0F00000H 	;32-bit low address
		dd	0		;32-bit high address
		dd	1*1024*1024	;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_RESERVED	;extended memory, this field should
					;filled by POST

		public	MemAbove_15Mb
MemAbove_15Mb: 	dd	01000000H 	;32-bit low address
		dd	0		;32-bit high address
		dd	0		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	MEM_AVAILABLE	;extended memory, this field should
					;filled by POST
;R103 - start
ifdef ACPI_Support
		public	ACPITableAddress
ACPITableAddress: 	
		dd	-1		;32-bit low address (filled in by SETUP_PS2)
		dd	0		;32-bit high address
		dd	0		;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	ACPI_TABLE	;

		public	ACPINVSAddress
ACPINVSAddress: 	
		dd	000000H		;32-bit low address (filled in by SETUP_PS2)
		dd	0		;32-bit high address
		dd	ACPINVSSize*1024;32-bit length low dword
		dd	0		;32-bit length high dword
		dd	ACPI_NVS	;
endif;ACPI_Support
;R103 - end
		db	-1		;end of table
;R78 - end

;R78		public	End_Of_Rng_Tbl
;R78End_Of_Rng_Tbl:

endif;	QUERY_SYSTEM_ADDRESS_MAP
;Rmv end

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT
;*****************************************************************************
; Procedure Name:	subf_07
;	Device driver far call initialization
;	Set INT74 far call address with ES:BX and set far call flag (27:b.7)
;	Assume always no error occur
; Saves:
; Inputs:	bp_seg (ES)	= device driver routine segment
;		bp_offset (BX)	= device driver routine offset
; Output:	none
; Destroy:	ax
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	|		| NEW	| Initial revision
;
;*****************************************************************************

SUBF_07 	PROC	NEAR
		mov	ax,bp_seg
		mov	word ptr ds:fcsegment,ax
		mov	ax,bp_offset
		mov	word ptr ds:fcoffset,ax
		or	byte ptr ds:pdflg_2,ddfcflg
		jmp	succ_00 			; successful
SUBF_07 	ENDP

;*****************************************************************************
; Procedure Name:	wait_ack
;	long loop to get the mouse response for system's command
; Saves:
; Inputs:	none
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 03 : interface error
;				= 04 : resend
;		zf = 1 : acknowledge received
;		zf = 0 : error occur
; Destroy:	ax
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

WAIT_ACK	PROC	NEAR
		push	cx
wait_ack1:
		xor	cx,cx
wait_oaf_loop:
		push	cx
		extrn	out_aux_full:near
		call	out_aux_full
		pop	cx
		jnz	short get_ack
		loop	short wait_oaf_loop
		jmp	short wa_error_03	; time out
get_ack:
		in	al,data8042
		cmp	al,ackcode		; check acknowledge code
		je	short wa_suc
chk_rsnd_code:
		cmp	al,rscode		; check resend code
		jne	short chk_error_code
		mov	bp_errcode,04
		jmp	short wa_error
chk_error_code:
;R82		cmp	al,errcode		; check error code
;R82		jne	short wait_ack1
wa_error_03:
		mov	bp_errcode,03
wa_error:
		and	byte ptr ds:pdflg_1,0f0h
		or	bp_flag,01		; set carry flag
		jmp	short wa_ret
wa_suc:
		mov	bp_errcode,00
		and	bp_flag,0fffeh		; clear carry flag
wa_ret:
		pop	cx
		or	bp_errcode,0		; affect ZF
		ret
WAIT_ACK	ENDP

;*****************************************************************************
; Procedure Name:	get_data
;	receive data from mouse if Auxiliary device Output Buffer Full
; Saves:
; Inputs:	none
; Output:	zf = 1 : no data received
;		zf = 0 : successful
;			al = data byte received
; Destroy:	ah
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

GET_DATA	PROC	NEAR
		push	cx
		xor	cx,cx
gd_loop:
		push	cx
		call	out_aux_full		; check AOBF
		pop	cx
		jnz	short receive_data
		loop	short gd_loop
		jmp	short gd_ret
receive_data:
		in	al,data8042
gd_ret:
		pop	cx
		ret
GET_DATA	ENDP
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

;R110 start
ifdef ZIDA_String
		align	16
		db	'_ZIDA_'
		db	16 dup (0)
endif ;ZIDA_String
;R110 end

;R116A;R116 start
;R116A		public	SPURIOUS_soft_HDLR
;R116ASPURIOUS_soft_HDLR:
;R116A
;R116A		PUSH	DS
;R116A		PUSH	AX
;R116A		PUSH	CX
;R116A
;R116A		ASSUME	DS:G_RAM		; N3.03
;R116A		MOV	AX,G_RAM
;R116A		MOV	DS,AX
;R116A		jmp	SOFT_INT
;R116A;R116 end

		CK_ORG	0E6F0H
		dw	offset DGROUP:HDISK_PARMS

		PAGE

		CK_ORG	0E6F2H
INT19_VECT:	JMP	INT_19S

CONFIG_TABLE:	DW	8			; Size of table
		DB	0FCH			; AT BIOS Model
		DB	1			; 8 Mhz,
		DB	0			; Revision 0 compatible
                DB      01110000B               ; info byte,see **1
		DB	0			; reserved
		DB	0
		DB	0
		DB	0
		DB	'Award Software Inc. - 04/23/90',0	; 0 for end of
						; string, Award
						; bios release
						; date.

;;**1 - Information byte definition
; bit 7 = 1 Fixed disk BIOS use DMA channel 3
; bit 6 = 1 Second interrupt chip (8259) present
; bit 5 = 1 Real time clock present
; bit 4 = 1 Keyboard intercept(int 15H, function 4fH) called by INT 9
; bit 3 = 1 Wait for external event supported
;R108 bit 2 = 1 Extended BIOS data area is allocated (1Kb for PS2 mouse)
; bit 2 = 1 Extended BIOS data area is allocated (1Kb EBDA) ;R108
; bit 1 = 1 Micro Channel supported
;	  0 PC-type I/O channel implmented
; bit 0 =   reserved

;R05 - start
		CK_ORG	0E729H
		DW	1047,768,384,192,96,48,24,12
;R05 - end

; 4 BYTES REMAINING

		CK_ORG	0E739H

COMM_VECT:	JMP	COMM_ENTRY

		PAGE
		PUBLIC	WAIT_FOR_PORT
		PUBLIC	WAIT_FOR_MEM

		PUBLIC	WAIT_FDU_8THS
		PUBLIC	WAIT_FDU_HEAD_SETTLE
		PUBLIC	WAIT_FDU_INT_LO
		PUBLIC	WAIT_FDU_INT_HI
		PUBLIC	WAIT_FDU_RESULTS_LO
		PUBLIC	WAIT_FDU_RESULTS_HI
		PUBLIC	WAIT_FDU_SEND_LO
		PUBLIC	WAIT_FDU_SEND_HI
		PUBLIC	WAIT_HDU_CTLR_BUSY_LO
		PUBLIC	WAIT_HDU_CTLR_BUSY_HI
		PUBLIC	WAIT_HDU_INT_LO
		PUBLIC	WAIT_HDU_INT_HI
		PUBLIC	WAIT_HDU_DRQ_LO
		PUBLIC	WAIT_HDU_DRQ_HI
		PUBLIC	WAIT_P61_B4_HI
		PUBLIC	WAIT_P61_B4_LO
		PUBLIC	WAIT_CHK_KBD_LO
		PUBLIC	WAIT_CHK_KBD_HI


WAIT_TBL	LABEL	BYTE
;Number of low to high transitions that should be made by 61, bit 4
;between 2 INT 8s:
;	54,925 Us between ticks/30 Us period = 1830 transitions.
;	Hi = 1830 + 25% = 2013 transitions
;	lo = 1830 - 25% = 1647 transitions.

WAIT_P61_B4_HI	DW	2287
WAIT_P61_B4_LO	DW	1372

;amount of time to wait for motor spin up, per unit in
;parameter table = 1/8th of second.
;R03 WAIT_FDU_8THS	DW	4167	; 125,000/30 = 1/8th second in 30 micro units.
WAIT_FDU_8THS	DW	3167	; 125,000/30 = 1/8th second in 30 micro units.;R03

;amount of time to wait for head settle, per unit in parameter
;table = 1 ms.
WAIT_FDU_HEAD_SETTLE	DB	33		; 1 ms in 30 micro units.


;Wait while printer initializes should be 65,536 microseconds.
;65,536/30 = 2185
			PUBLIC	WAIT_PRN_INIT_LO
WAIT_PRN_INIT_LO	DW	2185
			PUBLIC	WAIT_PRN_INIT_HI
WAIT_PRN_INIT_HI	DW	0

;Wait for check keyboard = 100,000Us/30Us = 3,333 refresh periods.
WAIT_CHK_KBD_LO	DW	3333
WAIT_CHK_KBD_HI	DB	0

;amount of time to wait for completion interrupt from NEC.
;1.5 seconds.
;R102WAIT_FDU_INT_LO	DW	050000			; 1.5 secs in 30 micro units.
;R102WAIT_FDU_INT_HI	DB	0
WAIT_FDU_INT_LO	DW	017798			;R102 2.5 secs in 30 micro units.
WAIT_FDU_INT_HI	DB	1			;R102

;Time to wait while waiting for each byte of NEC results = .5
;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
WAIT_FDU_RESULTS_LO	DW	16667		; .5 seconds in 30 micro units.
WAIT_FDU_RESULTS_HI	DB	0

;Time to wait in between sending each byte of command to NEC =
;.5 seconds. .5 seconds = 500,000 us.  500,000/30 = 16,667.
WAIT_FDU_SEND_LO	DW	16667		; .5 secons in 30 us units.
WAIT_FDU_SEND_HI	DB	0

;The wait for controller to be not busy is 8 seconds.
;8,000,000 / 30  = 266,667.  266,667 decimal = 0411ABh
;R39 WAIT_HDU_CTLR_BUSY_LO	DW	011ABH
;R39 WAIT_HDU_CTLR_BUSY_HI	DB	4H
;The wait for controller to be not busy is 10 seconds.	;R39
;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h	;R39
WAIT_HDU_CTLR_BUSY_LO	DW	01615H			;R39
WAIT_HDU_CTLR_BUSY_HI	DB	5H			;R39

;The wait for controller to issue completion interrupt is 10 seconds.
;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
WAIT_HDU_INT_LO	DW	1615H
WAIT_HDU_INT_HI	DB	5H

;The wait for Data request on read and write longs is
;2000 us.
WAIT_HDU_DRQ_LO	DW	1000
WAIT_HDU_DRQ_HI	DB	0H

;1,200,000 microsecond wait is used for all 4 waits in ACOMM
;Memory refresh occurs every 15 micros, which gives us 30 us period.
;1,200,000 / 30 = 40,000
		PUBLIC	WAIT_COMM_LO
WAIT_COMM_LO	DW	40000
		PUBLIC	WAIT_COMM_HI
WAIT_COMM_HI	DB	0


;Wait for printer not busy should be 1,080,000 microseconds.
;Memory refresh =15 us, therefore memory refresh period = 30 Us.
;1,080,000 / 30 = 36,000
			PUBLIC	WAIT_PRN_NBUSY_LO
WAIT_PRN_NBUSY_LO	DW	36000
			PUBLIC	WAIT_PRN_NBUSY_HI
WAIT_PRN_NBUSY_HI	DB	0


;WAIT_FOR_PORT:	Waits for a bit at a port pointed to by DX to
;		go on.
;INPUT:
;	AH=Mask for isolation bits.
;	AL=pattern to look for.
;	DX=Port to test for
;	BH:CX=Number of memory refresh periods to delay.
;		(normally 30 microseconds per period.)
;OUTPUT:
;	AH=  0 if got pattern.
;	    80h if timeout.
;	AL= Last read of port.
;	DX= preserved
;	BH:CX destroyed.
;	BL preserved.

		ALIGN	4			; 303A
WAIT_FOR_PORT	PROC	NEAR
;R64		TEST	BYTE PTR cs:[SETTINGS],0C0H
;R64		JZ	SHORT WFP_SHORT
;R64		JNS	SHORT WFP_LONG
;R64		JMP	WFP_CPU

;WFP_SHORT:  Wait for port if refresh cycle is short (15-80 Us range).

;R64 WFP_SHORT	PROC	NEAR
		PUSH	BX			; save outer counter.
						; and BL register.
		MOV	BH,AL			; matching pattern to bh.
		ALIGN	4			; N3.03
WFPS_OUTER_LP:
		OR	CX,CX			; if 1st entry,
		JNZ	SHORT WFPS_CHECK_PORT	; begin testing
		POP	CX			; get outer counter off stack
		DEC	CH			; decrement it.
		PUSH	CX			; back on stack, preserving
						; original bl.
		CMP	CH,0FFH			; if ch was just, zero
		JZ	SHORT WFPS_TIMEOUT	; then were done.
		XOR	CX,CX
		ALIGN	4			; N3.03
WFPS_CHECK_PORT:
		IN	AL,DX			; read port
		MOV	BL,AL			; save it.
		AND	AL,AH			; isolate bits.
		CMP	AL,BH			; check for match.
		JE	SHORT WFPS_GOT_PATTERN	; got the bit

		ALIGN	4			; 303A
WFPS_HI:	IN	AL,SYS1		; wait for hi to lo
		TEST	AL,010H			; transition on memory
		JNZ	SHORT WFPS_HI		; refresh.
		ALIGN	4			; 303A
WFPS_LO:	IN	AL,SYS1
		TEST	AL,010H
		JZ	SHORT WFPS_LO
		LOOP	SHORT WFPS_CHECK_PORT
		JMP	WFPS_OUTER_LP

WFPS_TIMEOUT:	MOV	AH,80H			; fail
		JMP	SHORT WFPS_EXIT

WFPS_GOT_PATTERN:
		XOR	AH,AH			; success

WFPS_EXIT:	MOV	AL,BL			; recover last read of port.
		POP	BX			; preserve bl.
		RET
;R64 WFP_SHORT	ENDP
WAIT_FOR_PORT	ENDP				;R64


;R64 ;WFP_LONG:  WAIT FOR PORT, if refresh cycle is long. (81Us to 5 ms range)
;R64
;R64 WFP_LONG	PROC	NEAR
;R64 		PUSH	BX			; save outer counter.
;R64 						; and BL register.
;R64		MOV	BH,AL			; matching pattern to bh.
;R64WFPL_OUTER_LP:
;R64		OR	CX,CX			; if 1st entry,
;R64		JNZ	SHORT WFPL_CHECK_HI	; begin testing
;R64		POP	CX			; get outer counter off stack
;R64		DEC	CH			; decrement it.
;R64		PUSH	CX			; back on stack, preserving
;R64						; original bl.
;R64		CMP	CH,0FFH			; if ch was just, zero
;R64		JZ	SHORT WFPL_TIMEOUT	; then were done.
;R64		XOR	CX,CX
;R64		ALIGN	4			; 303A
;R64WFPL_CHECK_HI:
;R64		IN	AL,DX			; read port
;R64		MOV	BL,AL			; save it.
;R64		AND	AL,AH			; isolate bits.
;R64		CMP	AL,BH			; check for match.
;R64		JE	SHORT WFPL_GOT_PATTERN	; got the bit
;R64		IN	AL,SYS1		; wait for hi to lo
;R64		TEST	AL,010H			; transition on memory
;R64		JNZ	SHORT WFPL_CHECK_HI	; refresh.
;R64
;R64		ALIGN	4			; 303A
;R64WFPL_CHECK_LO:
;R64		IN	AL,DX			; read port
;R64		MOV	BL,AL			; save it.
;R64		AND	AL,AH			; isolate bits.
;R64		CMP	AL,BH			; check for match.
;R64		JE	SHORT WFPL_GOT_PATTERN	; got the bit
;R64		IN	AL,SYS1		; wait for lo to hi
;R64		TEST	AL,010H			; transition on memory
;R64		JZ	SHORT WFPL_CHECK_LO	; refresh.
;R64
;R64		LOOP	SHORT WFPL_CHECK_HI
;R64		JMP	WFPL_OUTER_LP
;R64
;R64WFPL_TIMEOUT:	MOV	AH,80H			; fail
;R64		JMP	SHORT WFPL_EXIT
;R64
;R64WFPL_GOT_PATTERN:
;R64		XOR	AH,AH			; success
;R64
;R64WFPL_EXIT:	MOV	AL,BL			; recover last read of port.
;R64 		POP	BX			; preserve bl.
;R64 		RET
;R64 WFP_LONG	ENDP
;R64
;R64 ;WFP_CPU:  Wait for Port if refresh clock is unreliable or non-existant.
;R64
;R64
;R64 WFP_CPU		PROC	NEAR
;R64 		PUSH	BX			; save outer counter.
;R64 						; and BL register.
;R64 		MOV	BH,AL			; matching pattern to bh.
;R64 WFPC_OUTER_LP:
;R64 		OR	CX,CX			; if 1st entry,
;R64 		JNZ	SHORT WFPC_CHECK_PORT	; begin testing
;R64 		POP	CX			; get outer counter off stack
;R64 		DEC	CH			; decrement it.
;R64 		PUSH	CX			; back on stack, preserving
;R64 						; original bl.
;R64 		CMP	CH,0FFH			; if ch was just, zero
;R64 		JZ	SHORT WFPC_TIMEOUT	; then were done.
;R64 		XOR	CX,CX
;R64 		ALIGN	4			; 303A
;R64 WFPC_CHECK_PORT:
;R64 		PUSH	CX
;R64 		MOV	CX,6			; approximately 30 Us
;R64 						; at 8Mhz.
;R64 		ALIGN	4			; 303A
;R64 WFPC_INNER_LP:
;R64 		IN	AL,DX			; read port
;R64 		MOV	BL,AL			; save it.
;R64 		AND	AL,AH			; isolate bits.
;R64 		CMP	AL,BH			; check for match.
;R64 		JE	SHORT WFPC_GOT_PATTERN	; got the bit
;R64 		LOOP	SHORT WFPC_INNER_LP
;R64 		POP	CX			; recover outer counter
;R64 		LOOP	SHORT WFPC_CHECK_PORT
;R64 		JMP	WFPC_OUTER_LP
;R64 WFPC_TIMEOUT:
;R64 		MOV	AH,80H			; fail
;R64 		JMP	SHORT WFPC_EXIT
;R64
;R64 WFPC_GOT_PATTERN:
;R64 		POP	CX			; clear outer counter
;R64 		XOR	AH,AH			; success
;R64
;R64 WFPC_EXIT:	MOV	AL,BL			; recover last read of port.
;R64 		POP	BX			; preserve bl.
;R64 		RET
;R64 WFP_CPU		ENDP
;R64
;R64
;R64 WAIT_FOR_PORT	ENDP

; 7 BYTES REMAINING
		PUBLIC	EXTERN_SETUP
EXTERN_SETUP	PROC	FAR
		call	Setup
		ret					;R02A
EXTERN_SETUP	ENDP

;R78 - start
		ALIGN	4
INT18_HDLR	PROC	NEAR
		MOV	AX,G_RAM			; set up segment register.
		MOV	DS,AX
		ASSUME	DS:G_RAM

;R128 start
		cmp	word ptr G_RAM:[ROM_MODULE_SEG],0f000h	;return segment is 0f000h(INT19h of segment)
		jne	short @F				;No,jump normal INT18h
		jmp	dword ptr G_RAM:[ROM_MODULE_OFFSET]	;return to INT19h
@@:
;R128 end
		XOR	AH,AH				; set mode command.
		MOV	AL,[CON_MODE]
		INT	10H				; clear the screen.
		MOV	SI,OFFSET DGROUP:INT18_MSG	; write the message.
		CALL	WR_STR_TTY
		XOR	AH,AH				; wait for a key.
		INT	16H
		MOV	USER_REBOOT,CTRL_ALT_DEL	; reset the computer.
		JMP	REDO
INT18_HDLR	ENDP
;R78 - end

;R89A start
ifdef	ACPI_Support
		include	acpi.inc
		include	acpi_ct.inc
ifdef	S2_SUPPORT				;R112
CheckACPIWakeEvent:
		mov	dx, PM1a_CNT_BLK	;Get PM1 Control register
		in	al, dx
		cmp	al, 0ffh		;R89B If not valid IO value, jump out.
		je	NotACPIWakeEvent	;R89B 
		test	al, SCI_En		;Is SCI bit enabled?
		jz	NotACPIWakeEvent	;If not, this is normal reset. 
		inc	dx			;Next byte
		in	al, dx			;Read this register			
		cmp	al, 0ffh		;If not valid IO, jump out.
		je	NotACPIWakeEvent
		and	al, SLP_TYPE_MASK	;Isolate sleep type bits
;R89B - start
;Note:
;For S2, power on suspend,  the FACS table and SLP_TYP register are intact.
;So just get the waking vector from FACS table and jump to it. 
;For S3, save to RAM, the chip set registers are reset.
;Need to restore the DRAM boundary registers and DRAM timing before access
;FACS table.
;For S4, do the same thing as our BIOS do for suspend to disk.  Before O/S
;goes into S4, it will issue a SW SMI by write S4_BIOS value to SMI_CMD.  Our
;SMI handler then take care of saving stuffs into disk. 
;
;Just support S2 for now!!! 
;
		cmp	al, S2			;Is it S2 state		
		je	short @f		;Yes, jump to waking vector
		jmp	NotACPIWakeEvent	;No, jump back to normal reset	
@@:
		extrn	S2_Resume:near		;R112
		jmp	S2_Resume		;R112
endif	;S2_SUPPORT				;R112
if	ACPI_RESUME		EQ	1	;R112
		Public	Sx_Resume_Point		;R112
Sx_Resume_Point:				;R112
		mov	ax,cs			   
		mov	ss,ax				;Set up stack for ROM_CALL
;R89B - end
;R112		extrn	RestoreContext:near
;R89B		extrn	GetWakingVector:near
;R89B		call	RestoreContext 		;Restore context for this state
;R89B		call	GetWakingVector		;Get the waking vector
;R89B - start
;R112		Rom_Call	RestoreContext 		;Restore context for this state
		Rom_Call	EnterBigRealMode
JmpWakingVector:
		extrn	FACS_Pointer:near
		mov	eax, dword ptr cs:FACS_Pointer	;Get start address of FACS table
		add	eax, WakingVector		;Set to waking vector offset
		mov	ecx, dword ptr ds:[eax]		;Get the waking vector value	
		mov	ebx, ecx 			;Save a copy.
		and	ebx, 0fh			;Addjust the offset.			
		mov	word ptr ds:[eax], bx		;Save waking offset back to table
		shr	ecx, 4 				;Convert to segment.
		mov	word ptr ds:[eax+2], cx		;Save waking segment back to table
		jmp	dword ptr ds:[eax] 		;Jump back to O/S waking vector.
;R89B - end
;R89B		jmp	NotACPIWakeEvent
endif	;ACPI_RESUME		EQ	1	;R112
endif	;ACPI_Support
;R89A end

;R122;R106 - start
;R122public	CDROM_Boot_Delay
;R122public	CDROM_Boot_loop
;R122CDROM_Boot_Delay	DB	0h			;delay time before boot
;R122CDROM_Boot_loop		DB	08h			;retry boot times
;R122;R106 - end

;R115 start
		public	IoMegaZip_Flag
IoMegaZip_Flag		DB	0	;bit0 = 1 indicate primary master ZIP is floppy mode
					;bit1 = 1 indicate primary slave ZIP is floppy mode
					;bit2 = 1 indicate secondary master ZIP is floppy mode
					;bit3 = 1 indicate secondary slave ZIP is floppy mode
;R115 end

;R116A start
		public	SPURIOUS_soft_HDLR
SPURIOUS_soft_HDLR:

		PUSH	DS
		PUSH	AX
		PUSH	CX

		ASSUME	DS:G_RAM		; N3.03
		MOV	AX,G_RAM
		MOV	DS,AX
		jmp	SOFT_INT
;R116A end

		CK_ORG	0E826H
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;FAR_SETSPEED:  Entry point for application programs that want
;		to change speed of machine.
; enter with al,bit 0 = 1 to switch high, 0 to switch lo
;	     al,bit 7 = 1 to beep speaker, 0 to stay silent.
; modifies ax, cx.

FAR_SETSPEED	PROC	FAR
IFNDEF		NSS
		CALL	SETSPEED
ENDIF						; NSS
		RET
FAR_SETSPEED	ENDP

; 0 BYTES REMAINING

		CK_ORG	0E82AH
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;FAR_SETUP:  Entry point for application programs that want to
;	     make a far call to execute the SETUP procedure.
;	     Calling program is responsible for deciding whether
;	     rebooting system is necessary.
;INPUT: none.
;OUTPUT:  Carry flag Clear if user updated CMOS.
;	  Carry flag SET if user aborted CMOS changes.  (Time and Date
;		may still have been changed).

FAR_SETUP	PROC	FAR
;R64		JMP	EXTERN_SETUP
		JMP	near ptr EXTERN_SETUP		;R64
FAR_SETUP	ENDP

; 2 BYTES REMAINING

		CK_ORG	0E82EH
;[]==============================================================[]
;
;KBD_VECT:
;
;	Compatibility ORG for Int 16h. Calls routine in
;	KEYBOARD.ASM
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

		PUBLIC	KBD_VECT
KBD_VECT	PROC	FAR

		jmp	Keyboard
KBD_VECT	ENDP

;[]==============================================================[]
;INT 16

;Interrupt number 16H

;Name:   	Keyboard_IO
;Entry:  	INT 16H
;Input:  	ah=function number
;Output: 	see individual keyboard functions
;		ah=ah-2 if ah has illegal opcode (~0-2) - V2.09
;
;Description:
;	Keystokes are serviced by ISR 9 and placed in a circular buffer
;of 15 words at 40:1EH-3CH. The head offset pointer of the buffer is
;at 40:1AH.  The tail offset pointer of the buffer is at 40:1CH. The
;current shift status bytes are at 40:17H and 40:18H. Keyboard buffer
;start offset pointer is at 40:80H and end offset pointer is at
;40:82H. Keyboard LED flag byte is at 40:97H. Byte 40:19H is used for
;alt key code input temp.
;
;Keyboard_IO will:
;1. 	save environment
;2. 	invoke the requested keyboard function.
;3. 	restore environment
;4. 	return to POI
;
;[]==============================================================[]

		PUBLIC	KEYBOARD
KEYBOARD	PROC	NEAR

		PUSH	DS
		PUSH	SI
		PUSH	CX			; needed for UPDATE_LED

		ASSUME	DS:G_RAM
		MOV	SI,G_RAM
		MOV	DS,SI			; set ds = 40H

		MOV	CL,AH			; save function call into cl

		MOV	SI,OFFSET PTR_KBD_BUF_HD	; base of operations for keyb
		TEST	AH,0EFH			; is this a 10H or a 0H
		JNZ	SHORT KBDIO_1		; NOT READ_KEY (0)

;GET A CHARACTER FROM THE KEYBOARD (FUNC 0)

;Interrupt number 16H, function 0 or function 10h
;
;Name:   	Read_Key
;Entry:  	called from Keyboard_IO
;Input:  	ah=0 or 10H
;Output: 	ah=scan code, al= ascii char
;Description:
;
;Read_Key will:
;1. 	save environment
;2. 	obtain the next available key stroke from the keyboard queue.
;        If no key available call INT 15H (ah=90H) until key stroke
;        available.
;3.	Convert extended 101 key function into standard format
;4. 	update key queue pointers
;5. 	restore environment
;6. 	return to Keyboard_IO

		PUSH	CX
		CALL	UPDATE_LED		; this will change the keyboard leds
		POP	CX			; if the user has changed the flag bits

KBDIO_F0_4:
		cli				; R36
		MOV	AX,[SI]			; get buffer head ptr
		CMP	AX,[SI+2]		; compare with buffer tail ptr
		JNE	SHORT KBDIO_F0_1	; CHAR WAITING

;WAIT FOR A KEY

;R36		STI				; enable interrupts
		MOV	AX,9002H		; and then call busy wait
		INT	15H			; once - v2.06

KBDIO_F0_2:	STI				; loop to get key - do not
		NEWIODELAY			; busy wait in loop V2.06
						; a little delay
		CLI
		MOV	AX,[SI]
		CMP	AX,[SI+2]
		JE	SHORT KBDIO_F0_2	; WAIT TILL KEY PRESSED

;GET KEY FROM BUFFER

KBDIO_F0_1:	CALL	MOVE_BUF_PTR		; point to next character
		CALL	XLAT_EX_CHAR		; convert extended character
		JC	SHORT KBDIO_F0_4	; invalid character, try again
		JMP	SHORT KBDIO_RET

;RETURN CHARACTER READY STATUS (FUNC 1)

KBDIO_1:	TEST	AH,0EEH			; is this a 11H or a 1
		JNZ	SHORT KBDIO_F2		; NOT CHAR CHECK (1)

;[]==============================================================[]
; Interrupt number 16H, function 1 or function 11H
;
;Name:   	Key_Stat
;Entry:  	called from Keyboard_IO
;Input:  	ah=01h or 11h
;Output: 	z flag =1= no keystroke queued
;   	    	z flag =0= keystroke is available in queue, key in ax
;Description:
;
;Key_Stat will:
;1. 	save environment
;2. 	if the key queue contains a keystroke
;   	  {
;   	    	copy char and scan code from queue to ax
;   	    	do not update key queue pointers
;		convert extended char code to standard char code
;   	    	set z flag = 0
;   	  }
;   	else (no key available)
;   	  {
;   	    	set z flag = 1
;   	  }
;3. 	restore environment
;4. 	return to Keyboard_IO
;
;[]==============================================================[]

		PUSH	CX
		CALL	UPDATE_LED
		POP	CX

		cli				; R36
KBDIO_F1_1:	MOV	AX,[SI]
		CMP	AX,[SI+2]		; CHECK FOR ANY CHAR, sets flag
		XCHG	SI,AX			; get pointer to char
		MOV	SI,[SI]			; GET CHARACTER
		XCHG	SI,AX			; get char in ax, si = buffer head ptr
		JE	SHORT KBDIO_RET2	; exit, if there is no new code
		PUSHF				; save flag
		CALL	XLAT_EX_CHAR		; else, translate to standard code
		JNC	SHORT KBDIO_F1_2	; if it is valid, exit
		POPF				; restore flags
		CALL	MOVE_BUF_PTR		; move to next character
		JMP	SHORT KBDIO_F1_1	; loop

KBDIO_F1_2:	POPF

KBDIO_RET2:
;R26		STI
		POP	CX
KBDIO_RET2_1:
		POP	SI
		POP	DS
		STI				;R26
		RETF	2			; INT RETURN


;RETURN SHIFT STATUS (FUNC 2)

KBDIO_F2:	TEST	AH,0EDH			; is this a 12H or a 2
		JNZ	SHORT KBDIO_F3		;

;[]==============================================================[]
; Interrupt number 16H, function 2 or function 12
;
;Name:   	Key_Shift
;Entry:  	called from Keyboard_IO
;Input:  	ah=02h or 12H
;Output: 	al=shift status
;   	    	bit 0 =1= right-shift depressed
;   	    	bit 1 =1= left-shift depressed
;   	    	bit 2 =1= ctrl-shift depressed
;   	    	bit 3 =1= alt-shift depressed
;   	    	bit 4 =1= scroll mode set
;   	    	bit 5 =1= num lock mode set
;   	    	bit 6 =1= caps mode set
;   	    	bit 7 =1= insert mode set
;	if ah=12H then ah = extended status as follows:
;   	    	bit 0 =1= left-ctrl-shift depressed
;   	    	bit 1 =1= left-alt-shift depressed
;   	    	bit 2 =1= right-ctrl-shift depressed
;   	    	bit 3 =1= right-alt-shift depressed
;   	    	bit 4 =1= scroll lock is depressed
;   	    	bit 5 =1= num lock is depressed
;   	    	bit 6 =1= caps lock is depressed
;   	    	bit 7 =1= sys key held
;   	    	all other regs restored
;Description:
;
;Key_Shift will:
;1. 	save environment
;2. 	return the current mode(s) and shift status in al
;3. 	restore environment
;4. 	return to POI
;
;[]==============================================================[]

		TEST	AH,10H			; is this a 12H
		mov	ah,0			;R15
		JE	SHORT KBDIO_F2_1	; no, then go to function 2

		MOV	AH,KBD_FLG1		; get flag
		AND	AH,07FH			; clear  last bit
		TEST	AH,4			; test sys lock
		JE	SHORT SYS_NOT_ON
		OR	AH,80H			; set sys lock bit on
SYS_NOT_ON:	AND	AH,0F3H			; clear 2 bits for right toggle keys
		MOV	AL,KB_FLAG_3		; get extended flags
		AND	AL,0CH			; just keep right toggles
		OR	AH,AL			; put it all together

KBDIO_F2_1:	MOV	AL,SHFT_STAT		; return keyboard flag byte

KBDIO_RET:	POP	CX
KBDIO_2RET:	POP	SI			; MULTITECH LABEL
		POP	DS
		STI
		IRET				; v2.09 - changed ret 2 to iret

KBDIO_F3:	CMP	AH,3			; V3.00 - is this function 3
		JNE	SHORT KBDIO_F5

;[]==============================================================[]
; Interrupt number 16H, function 3 - V3.00
;
;Name:   	Set Typematic Rate and Repeat Delay
;Entry:  	called from Keyboard_IO
;Input:  	ah=03h
;		al=05h
;		bl=typematic rate (0 - 1FH) - value checked
;		bh=repeat delay	(0 - 3H) - value checked
;
;       Typematic Rate (make codes/second)
;
;       bit     rate    bit     rate    bit     rate
;       00000   30      00001   26.7    00010   24
;       00011   21.8    00100   20      00101   18.5
;       00110   17.1    00111   16      01000   15
;       01001   13.3    01010   12      01011   10.9
;       01100   10      01101   9.2     01110   8.6
;       01111   8       10000   7.5     10001   6.7
;       10010   6       10011   5.5     10100   5
;       10101   4.5     10110   4.3     10111   4
;       11000   3.7     11001   3.3     11010   3
;       11011   2.7     11100   2.5     11101   2.3
;       11110   2.1     11111   2
;
;       Repeat Delay (milliseconds)
;
;       bit     delay   bit     delay   bit     delay   bit     delay
;       00      250     01      500     10      750     11      1000
;
;Output:        none
;Description:
;
;Set Typematic Rate will:
;1. 	save environment
;2. 	issue set typematic rate command to keyboard (F3H)
;3.	send new parameters to the keyboard
;4. 	restore environment
;5. 	return to POI
;
;[]==============================================================[]

		XOR	AH,AH			; ah=0 for return value.
		CMP	AL,5			; check for correct function code
		JNE	SHORT KBDIO_RET		; if not error

		TEST	BX,0FCE0H		; check for typematic rate with < 6 bits
						; and delay < 3 bits
		JNZ	SHORT KBDIO_RET		; otherwise error

		MOV	AL,0F3H			; typematic rate command
		CALL	KB_OUT			; send it out
		MOV	CL,5
		MOV	AL,BH			; get delay
		SHL	AL,CL			; move to bits 5-6
		OR	AL,BL			; get rate command
		PUSH	AX			; preserve rate for return
		CALL	KB_OUT			; send it out
		POP	AX			; recover rate for return.
		JMP	SHORT KBDIO_RET		; finished, go home

KBDIO_F5:	SUB	AH,12H
		CMP	AH,0F3H			; is this function 5


		JNE	SHORT KBDIO_RET		; if not ah -= 12h, bad command
						; else drop to function 5

;[]==============================================================[]
; Interrupt number 16H, function 5
;
;Name:   	Character Unget
;Entry:  	called from Keyboard_IO
;Input:  	ah=05h
;		cl=extended ascii code
;		ch=scan code
;Output: 	al=0 if successful
;		al=1 if operation failed
;			carry set if failed
;   	    	all other regs restored
;Description:
;
;Character Unget will:
;1. 	save environment
;2. 	places contents of cx into keyboard buffer if not full
;3. 	restore environment
;4. 	return to POI
;
;[]==============================================================[]

		POP	CX			; restore character
		CALL	INSERT_CHAR		; place in buffer
		JE	SHORT KBDIO_F5_1	; jump if unsuccessful

		XOR	AX,AX			; al = 0 , carry = 0
		JMP	KBDIO_RET2_1

KBDIO_F5_1:	MOV	AX,1
		STC				; al = 1 , carry = 1
		JMP	KBDIO_RET2_1		; return flags set

KEYBOARD	ENDP

		ALIGN	4			; 303A
;[]==============================================================[]
; This function increments the buffer pointer to the next location,
; and returns the last character in AX
;
; INPUT:
; SI=offset current buffer head ptr
;
; OUTPUT:
; AX = last character in buffer
; buffer head ptr = ptr to next character in buffer
;
; MODIFIES	AX
;[]==============================================================[]

MOVE_BUF_PTR	PROC	NEAR

		MOV	AX,[SI]			; get next position
		ADD	AX,2			; increment head ptr
		CMP	AX,[KBD_BUFEND_LOCN]	; less than end of buffer
		JB	SHORT KBDIO_F0_3	; yes, this is next char

		MOV	AX,[KBD_BUF_LOCN]	; no, then point to buffer start

KBDIO_F0_3:	XCHG	[SI],AX
		XCHG	SI,AX			; ax = offset ptr_kbd_buf_hd
		MOV	SI,[SI]			; si = character
		XCHG	SI,AX			; ax = char, si = buffer head ptr
		RET
MOVE_BUF_PTR	ENDP



;[]==============================================================[]
; translates extended char into standard character code - V2.09
;
; INPUT:
; AX = character from buffer
;
; OUTPUT:
; AX = translated character
; CL = original command code
; CARRY = 1 - if character invalid
;	= 0 - if valid character
;[]==============================================================[]

XLAT_EX_CHAR	PROC	NEAR

		TEST	CL,10H			; is this an extended call?
		JNE	SHORT EX_2		; if it is, then just check for F0

		CMP	AH,0E0H			; is this keypad return or /
		JNE	SHORT EX_1		; if not, continue

		MOV	AH,01CH			; set to RETURN
		cmp	al,0dh			;R15
		je	short EXLIT		;R15
		cmp	al,0ah			;R15
		je	short EXLIT		;R15
;R15		CMP	AL,02FH			; is this a /
;R15		JNE	SHORT EXLIT
		MOV	AH,035H			; set to /
		JMP	SHORT EXLIT

EX_1:		CMP	AH,84H			; is this a new code
		JA	SHORT EXLIT1		; must eliminate later

		CMP	AL,0E0H			; is this an E0 character (alternate)
		JNE	SHORT EX_2		; if not, continue

		OR	AH,AH			; keep alt 224 code
		JZ	SHORT EXLIT

		XOR	AL,AL			; make it look like normal character
		JMP	SHORT	EXLIT

EX_2:		CMP	AL,0F0H			; is this a filler
		JNE	SHORT EXLIT		; if not, good char

		OR	AH,AH			; is this alt 240 (F0 00)
		JE	SHORT EXLIT		; if so, then this is valid

		XOR	AL,AL			; get rid of filler characters

		TEST	CL,10H			; is this extended function?
		JNE	SHORT EXLIT		; if it is, return valid char

EXLIT1:		STC				; bad char, throw away
		RET

EXLIT:		CLC				; good char, keep
		RET

XLAT_EX_CHAR	ENDP


;[]==============================================================[]
;
;EXTERN_SETUP:
;
;	Sets up the stack for a post-boot call of setup
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

;		PUBLIC	EXTERN_SETUP
;EXTERN_SETUP	PROC	FAR
;		call	Setup
;		ret
;EXTERN_SETUP	ENDP

		ALIGN	4			; N3.03
		PUBLIC	CLEAR_PARITY
CLEAR_PARITY	PROC	NEAR
		IN	AL,SYS1			; SYSTEM CONTROL REGISTER
		NEWIODELAY
		OR	AL,PARITY_CHECK_OFF	; CLEAR POSSIBLE PARITY
		OUT	SYS1,AL			;
		RET
CLEAR_PARITY	ENDP


;HDD drive table for system BIOS shadowed to fix NOVELL boot problem
;R27		public	DRV0
;R27DRV0		label	word
;R27		db	16 dup(?)
;R27
;R27		public	DRV1
;R27DRV1		label	word
;R27		db	16 dup(?)

;Rmv1 start
;*****************************************************************************
; Procedure Name:	int15_ms
;	Pointing device handler INT 15 service routine
;	check the mouse function call C1, C2
;	far jmp to original INT15 if not mouse driver function call
; Saves:
; Inputs:	ah = function call
; Output:	none
; Destroy:	none
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

		PUBLIC	INT15_MS
INT15_MS	PROC	NEAR

ifdef	NO_PS2_MOUSE_SUPPORT				;R130
		jmp	int15_not_mouse			;R130
else;	NO_PS2_MOUSE_SUPPORT				;R130

;R04 - start
;R48		test	cs:SYSTEM4_BYTE,PS2_MOUSE	;ps2 mouse support
		test	byte ptr cs:[CONFIG_TABLE+5],04H	;R48
		jnz	short Yes_Mouse
		jmp	int15_not_mouse
Yes_Mouse:
;R04 - end

; start - added this code to solve WIN386/2.11 problem

		cmp	ah,0c1h				;R108A
		je	func_c1				;R108A
		push	es
		push	G_RAM
		pop	es
		assume	es:g_RAM
	       	test	byte ptr es:Hardware,00000100b	; check if mouse exist
		pop	es
		jnz 	short int15_ms_1
		jmp	int15_not_mouse
int15_ms_1:
;R108A		cmp	ah,0c1h
;R108A		je	func_c1
		jmp	func_c2

endif;	NO_PS2_MOUSE_SUPPORT				;R130
INT15_MS	ENDP
;Rmv1 end

		CK_ORG	0E987H
;[]==============================================================[]
;
;KBD_VECT:
;
;	Compatibility ORG for Int 9h interrupt vectors. Calls
;	routine in AKBRD.ASM.
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

		PUBLIC	KBDINT_VECT
KBDINT_VECT	PROC	FAR

		JMP	KBD_INT			; JUMP TO INT 9

KBDINT_VECT	ENDP

comment %		;R16
;R14 Start
Check_In_Post1:
		call	Check_In_Post		;in POST?
		jnz	short Yes_In_Post	;yes
		jmp	Normal_Nmi
Yes_In_Post:
		iret

		Public	Check_In_Post
Check_In_Post:
		push	ds
		push	ax
		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM
	      	test	INIT_ERR_FLG,IEF_IN_POST ; is POST occurring?
		pop	ax
		pop	ds
		ret
;R14 Endp
%			;R16

comment %	;R14
Check_In_Post:
		push	ds
		push	ax
		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM
	      	test	INIT_ERR_FLG,IEF_IN_POST ; is POST occurring?
		pop	ax
		pop	ds
		jnz	short Yes_In_Post
		jmp	Normal_Nmi
Yes_In_Post:
		iret
%		;R14

		ASSUME	DS:DGROUP
;
;	MESSAGE TABLE: This is where I put all of the messages which
;	are printed outside of POST, such as unclaimed NMI, disk boot
;	failure, etc.
;

IF1
	%OUT	Including ATORGS.001
ENDIF
		INCLUDE	ATORGS.001

;R38 ;
;R38 ;	MODBIN SILENT POST: DISPLAY STATUS FOR POST CODES
;R38 ;
;R38 ;	MODBIN'able message display status for each post code,
;R38 ;	(two bits in each table for each of possible 128 post codes).
;R38 ;	First table (MESS_TABLE_OFF) is for setup option DISPLAY_POST_OFF,
;R38 ;	second table (MESS_TABLE_ON) is for setup option DISPLAY_POST_ON.
;R38 ;
;R38
;R38 		CK_ORG	0EB00H
;R38 		PUBLIC	SP_MESS_TABLE_OFF, SP_MESS_TABLE_ON
;R38 		db	045h		;value=33h means silent post installed
;R38
;R38 SP_TABLE_BYTES	   EQU  (MAX_SILENT_POST_CODE+4)/4 ; each table entry is 2 bits.
;R38
;R38  SP_MESS_TABLE_OFF: DB	3 DUP(10101010B)		; POST 0 - POST 23
;R38 		    db	10101010b			; POST 13 - POST 15
;R38 		    db  10101010b			; POST 16 - POST 19
;R38 		    db  10101010b			; POST 20 - POST 23
;R38 		    db  10101010b			; POST 24 - POST 27
;R38 		    db  5 dup(10101010b)		; POST 28 - POST 47
;R38 		    db	10101010B			; POST 48 - POST 51
;R38 		    db	2 dup(10101010b)		; POST 52 - POST 59
;R38 		    db  10101010b			; POST 60 - POST 63
;R38  		    DB	17 DUP(10101010B)	 	; POST 64 - POST 127
;R38
;R38
;R38 SP_MESS_TABLE_ON:  DB	SP_TABLE_BYTES DUP(10101010B)	; init all post codes for always display on cold.

;R46 start
BP_BX		EQU	ss:[bp+type UART][4]
;[]=====================================================================[]
;	Function 4: Extended initialize
;
;	ENTRY:
;	AH = 4		AL = Break		   BH = Parity
;			     00 No break		00 None
;	BL = Stop Bit	     01 Break			01 Odd
;	     00 One					02 Even
;	     01 Two if 6-, 7-, or 8- bit word length	03 Stick parity odd
;	        One-and-One-half if 5-bit word length	04 Stick parity even
;
;	CH = Word length	CL = Baud rate
;	     00 = 5 Bits	     00 = 110 Baud
;	     01 = 6 Bits	     01 = 150 Baud
;	     02 = 7 Bits	     02 = 300 Baud
;	     03 = 8 Bits	     03 = 600 Baud
;				     04 = 1200 Baud
;				     05 = 2400 Baud
;				     06 = 4800 Baud
;				     07 = 9600 Baud
;				     08 = 19200 Baud
;
;	EXIT:
;		AH = line control status
;		AL = modem status
;
;[]=====================================================================[]

COMM_F4:
		mov	bl,cl			;get mode byte
		xor	bh,bh
		shl	bx,1			;bx = word index to table
		mov	dx,word ptr cs:BAUD_DIVISORS[bx]	;AX = divisor
		mov	bx,BP_BX
		and	bl,1
		shl	bl,2
		or	bl,ch
		shl	al,6
		or	bl,al
		or	bh,bh
		jz	short @F
		shl	bh,4
		sub	bh,8
@@:
		or	bl,bh
		mov	cx,dx
		jmp	Set_Baud_Rate

;[]=====================================================================[]
;	Function 5: Extended serial port control
;
;	ENTRY
;		AH = 05h
;		AL = 00h Read modem control register
;
;		AL = 01h Write modem control register
;		BL = modem control register
;		     Bits 7-5 = 0 Reserved
;		     Bit 4    = 1 Loopback mode
;		     Bit 3    = 1 Enable OUT2 interrupt
;		     Bit 2    = 1 Force OUT1 active
;		     Bit 1    = 1 Force request-to-send active
;		     Bit 0    = 1 Force data-terminal-ready active
;	EXIT
;		AH = line status
;		AL = modem status
;		BL = modem control register
;
;[]=====================================================================[]

COMM_F5:
		or	al,al
		jz	short Get_Control_Reg
		mov	al,BP_BX
		mov	dx,[bp].ModemControl	;modem control reg (base+4)
		out	dx,al
		newiodelay
Get_Control_Reg:
		mov	dx,[bp].ModemControl	;modem control reg (base+4)
		in	al,dx
		newiodelay
		mov	BP_BX,al
		jmp	COMM_status
;R46 end

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT
;*****************************************************************************
; Procedure Name:	func_c1
;	Mouse handler INT 15 service routine function C1h
;	Return extended BIOS data area
; Saves:
; Inputs:	ah = C1
; Output:	es = extended data area segment address
; Destroy:	none
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

func_c1 	proc	near
		push	ax
		mov	ax,g_ram
		mov	es,ax
		mov	ax,word ptr es:Ext_Segment
		mov	es,ax
		pop	ax
		iret
func_c1 	endp

;*****************************************************************************
; Procedure Name:	func_c2
;	Mouse handler INT 15 service routine function C2h
;	Pointing device interface
;
;	Contain subfunctions list:
;
;	AL value | BL value | decription
;	---------+----------+-----------------------------------------
;	00	 |	    | Enable/disable pointing device
;	01	 |	    | Reset pointing device
;	02	 |	    | Set sample rate
;	03	 |	    | Set resolution
;	04	 |	    | Read device type
;	05	 |	    | Pointing device interface initialization
;	06	 | 00	    | Return status
;	06	 | 01	    | Set scalling 1:1
;	06	 | 02	    | Set scalling 2:1
;	07	 |	    | Device driver far call initialization
;
; Saves:
; Inputs:	ah = C2
;		al, bl = describe previously
; Output:	cf = 0 : successfully
;			ah = 00
;		cf = 1 : error
;			ah = 01 : invalid function call
;			ah = 02 : invalid input
;			ah = 03 : interface error
;			ah = 04 : resend
;			ah = 05 : no far call installed
; Destroy:	none
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

FUNC_C2 	PROC	NEAR

		test	al,0f8h
		jz	short correct_subf

		mov	ah,01			; invalid subfunction
		stc				; set cf=1
		retf	2

correct_subf:
		push	ax			;bp+10
		push	bx			;bp+0e
		push	cx			;bp+0c
		push	dx			;bp+0a
		push	si			;bp+08
		push	di			;bp+06
		push	ds			;bp+04
		push	es			;bp+02
		push	bp			;bp
		mov	bp,sp

		mov	ax,g_ram
		mov	es,ax
		assume	es:g_ram

		mov	ax,g_ram:Ext_Segment
		mov	ds,ax
		assume	ds:nothing

		extrn	dis_kc_ms:near
		call	dis_kc_ms		; disable AOBF interrupt

		test	byte ptr g_ram:Hardware,00000100b	; mouse flag
		jz	short error_03

		xor	ah,ah
		mov	al,bp_subf
		shl	ax,1			; *2(word)
		lea	si,DGROUP:subftbl		; point to subf address table
		add	si,ax
		jmp	word ptr cs:[si]

succ_00:
		mov	bp_errcode,0		; no error
		and	bp_flag,0fffeh		; clear carry falg in stack
		jmp	short func_c2_ret
error_01:
		mov	bp_errcode,01		; invalid function call
		jmp	short func_c2_error
error_02:
		mov	bp_errcode,02		; invalid input
		jmp	short func_c2_error
error_03:
		mov	bp_errcode,03		; interface error
		jmp	short func_c2_error
error_05:
		mov	bp_errcode,05		; no far call installed
func_c2_error:
		or	bp_flag,01		; set carry flag in stack

func_c2_ret:
		extrn	en_kc_ms:near
		call	en_kc_ms		; enable AOBF interrupt

		pop	bp
		pop	es
		pop	ds
		pop	di
		pop	si
		pop	dx
		pop	cx
		pop	bx
		pop	ax
		iret
FUNC_C2 	ENDP

;*****************************************************************************
; Procedure Name:	subf_00
;	Enable/disable pointing device
; Saves:
; Inputs:	bp_bh (BH) = 00 disable
;			   = 01 enable
;		device driver far call flag
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 01 : invalid function
;				= 03 : interface error
;				= 04 : resend
;				= 05 : no far call installed
; Destroy:	ax, bh, cx
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_00 	PROC	NEAR
		mov	al,bp_bh
		test	al,0feh
		jnz	short error_01		; invalid function
chk_fcflg:
		test	byte ptr ds:PDFLG_2,DDFCFLG
		jz	short error_05		; no far call installed
send_encmd:
						; en=01,dis=00
		xor	al,01			; xlat to en=00,dis=01
		add	al,MS_ENDATA		; en=00+f4,dis=01+f4=f5
		call	out_aux
		jnz	short error_03		; interface error
wait_subf00_ack:
		call	wait_ack		; wait response and set status
		jmp	short func_c2_ret
SUBF_00 	ENDP

;*****************************************************************************
; Procedure Name:	subf_01
;	Reset pointing device
;	mouse status after successfully reset:
;		- data transmission	= disable
;		- sampling rate 	= 100 reports/second
;		- resolution		= 4 counts/millimeter
;		- scalling		= 1:1
;		- mode			= stream mode
; Saves:
; Inputs:	none
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 03 : interface error
;				= 04 : resend
;		bp_bl (BL) = first byte of device response
;		bp_bh (BH) = device id (mouse:00)
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_01 	PROC	NEAR
;R05 - start
;Clear mouse buffer Before send command to mouse
		and	byte ptr ds:pdflg_1,0f8h	; clear count index
;R05 - end
;R82 - start
		mov	cl,10			; number of retry
ReSend:
		push	cx
		mov	al,MS_RESET		; reset mouse command
		call	out_aux
		pop	cx

		jnz	short error_03		; interface error
		call	wait_ack		; wait response and set status
		jz	short Get_Id		; ACK received ?
		dec	cl			; no ,resend command
		jnz	short ReSend
						; retry time-out
		or	bp_errcode,0		; affect ZF
		jmp	short func_c2_ret
;R82 - end
;R82		mov	al,MS_RESET		; reset mouse command
;R82		call	out_aux
;R82		jnz	short error_03		; interface error
;R82wait_subf01_ack:
;R82		call	wait_ack		; wait response and set status
;R82		jnz	short func_c2_ret
get_id:
		call	get_data		; wait AOBF and get data
		jz	short error_03		; error if no AOBF
		mov	bp_bl,al		; first byte device response

		call	get_data		; wait AOBF and get data
		jz	short error_03		; error if no AOBF
		mov	bp_bh,al		; device id

		jmp	short succ_00		; successful
SUBF_01 	ENDP

;*****************************************************************************
; Procedure Name:	subf_02
;	Set sampling rate
; Saves:
; Inputs:	bp_bh (BH) = sample rate value (00 - 06)
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 02 : invalid input
;				= 03 : interface error
;				= 04 : resend
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_02 	PROC	NEAR
		cmp	bp_bh,06
		ja	short error_02		; invalid input
correct_rate:
		mov	al,ms_setrate		; set sampling rate command
		call	out_aux
		jnz	short error_03		; interface error
wait_subf02_ack:
		call	wait_ack		; wait response and set status
		jnz	short func_c2_ret
send_rate:
		lea	si,DGROUP:smplrate		; point to translate table
		xor	ah,ah
		mov	al,bp_bh
		add	si,ax
		lods	byte ptr cs:[si]	; get actual value send to
						; mouse
		call	out_aux 		; out sampling rate to mouse
		jz	short wait_subf02_ack1	; ok, if no IBF
		jmp	error_03		; interface error
wait_subf02_ack1:
		call	wait_ack		; wait response and set status
		jmp	func_c2_ret
SUBF_02 	ENDP

; sampling rate translate table

smplrate	label	byte	; bh input	; reports per second
		db	0ah	; 00		; 10 reports/second
		db	14h	; 01		; 20 reports/second
		db	28h	; 02		; 40 reports/second
		db	3ch	; 03		; 60 reports/second
		db	50h	; 04		; 80 reports/second
		db	64h	; 05		; 100 reports/second
		db	0c8h	; 06		; 200 reports/second

;*****************************************************************************
; Procedure Name:	subf_03
;	Set resolution
; Saves:
; Inputs:	bp_bh (BH) = resolution value (00 - 03 counts per millimeter)
;			   = 00 : 1 count/millimeter
;			   = 01 : 2 counts/millimeter
;			   = 02 : 4 counts/millimeter
;			   = 03 : 8 counts/millimeter
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 02 : invalid input
;				= 03 : interface error
;				= 04 : resend
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_03 	PROC	NEAR
		cmp	bp_bh,03
		jbe	short correct_res
		jmp	error_02		; invalid input
correct_res:
		mov	al,ms_setres		; set resolution command
		call	out_aux
		jz	short wait_subf03_ack 	; ok, if no IBF
		jmp	error_03		; interface error
wait_subf03_ack:
		call	wait_ack		; wait response and set status
		jz	short send_res		; ok, if get acknowledge
		jmp	func_c2_ret
send_res:
		mov	al,bp_bh		; resolution value
		call	out_aux
		jz	short wait_subf03_ack1	; ok, if no IBF
		jmp	error_03		; interface error
wait_subf03_ack1:
		call	wait_ack		; wait response and set status
		jmp	func_c2_ret
SUBF_03 	ENDP
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

;R58 - start
		Public	Ret_E_Seg
Ret_E_Seg:
		FAR_JMP <OFFSET E000_VECT>,08h
;R58 - end

;R89B - start
ifdef	ACPI_Support
;[]========================================================================[]
;EnterBigRealMode
;[]========================================================================[]
EnterBigRealMode:
                mov     ax,cs
                mov     ds,ax
                assume  ds:dgroup
                mov     si, offset GDTR1
                lgdt    fword ptr ds:[si]	;load descriptor table
                mov     eax,cr0                 ;Enter protected mode
                or      al,1
                mov     cr0,eax
                jmp     short Enter_Protect_Mode1
Enter_Protect_Mode1:
                mov     ax,offset DATA1_INDEX
                mov     ds,ax                   ; ds = 00000000h
		mov	es,ax			;
		mov	ds,ax
;Switch back to real mode, DS and ES limits are set
;
    		mov  eax,cr0
    		and  al,NOT 1
    		mov  cr0,eax
    		jmp  @f				; clear prefetch queue.
@@:
		xor	ax, ax
		mov	ds, ax			;DS and ES limit are set
		mov	es, ax
		ret
endif	;ACPI_Support
;R89B - end
		CK_ORG	0EC30H
		public	F000_VECT
		public	F000_func_end
F000_VECT:
		retn
F000_func_end:
		retf

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT
package_tbl	label	byte
; define the position in stack
; data position -	0,1,2,3,4,5,6,7 ; in extended data area
					; data package size
size1		db	6		; 1
size2		db	6,7		; 2
size3		db	6,4,2		; 3
size4		db	6,7,4,2 	; 4
size5		db	6,4,2,5,3	; 5
size6		db	6,7,4,2,5,3	; 6
size7		db	6,4,2,0,5,3,1	; 7
size8		db	6,7,4,2,0,5,3,1 ; 8
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

		CK_ORG	0EC59H

DSK_VECT:	JMP	DISKIO

		CK_ORG	0EC5CH

;
;	SETUP: MODBIN'able setup information, including date format.
;

		CK_ORG	0EC5CH

;
;	MODBIN SECURITY: MASTER PASSWORD, MAXIMUM BAD ENTRIES
;
;	MODBIN'able master password (for security check)
;	stored in hashed form and maximum bad password
;	entry tries.
;

		CK_ORG	0EC60H
		PUBLIC	MASTER_PASS_HASH, MAX_BAD_PASSWORDS
;R85 MASTER_PASS_HASH	DW	01EAAh		; hashed version of master password, ("AWARD_SW")
;R87 start
ifdef Support_AWARD_Default_Password
MASTER_PASS_HASH	DB	22h,0f2h,22h,52h,82h,0fah,72h,0f2h
else ;Support_AWARD_Default_Password
;R87 end
MASTER_PASS_HASH	DB	8 dup (0)	;R85
endif ;Support_AWARD_Default_Password		;R87
MAX_BAD_PASSWORDS	DB	20		; max bad password entries before quitting
;
;	BIOS ID: Set at compile time. I've left 16 bytes here so that
;	the part number can expand if necessary. Must be 00h terminated.
;
		CK_ORG	0EC70H
		PUBLIC	BIOS_INFORM_STR
BIOS_INFORM_STR:
		DB	BIOS_STR_LEN
		DB	'05/15/92-'
		DB	15 DUP (0)		;dummy , filled by MODBIN
		DB	'-'
;R55		DB	'21400000'		;Dummy , filled by MODBIN
		DB	'21400000C-00',0	;R55
BIOS_STR_LEN	EQU	$-BIOS_INFORM_STR-1

;R16 Start
Check_In_Post1:
		call	Check_In_Post		;in POST?
		jnz	short Yes_In_Post	;yes
		jmp	Normal_Nmi
Yes_In_Post:
		iret

		Public	Check_In_Post
Check_In_Post:
		push	ds
		push	ax
		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM
	      	test	INIT_ERR_FLG,IEF_IN_POST ; is POST occurring?
		pop	ax
		pop	ds
		ret
;R16 Endp

;Rmv1 end
ifndef	NO_PS2_MOUSE_SUPPORT
;*****************************************************************************
; Procedure Name:	subf_04
;	Read auxiliary device type
; Saves:
; Inputs:	none
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 03 : interface error
;				= 04 : resend
;		bp_bh (BH) = device id (mouse:00)
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_04 	PROC	NEAR
		mov	al,ms_rdtype		; read device type command
		call	out_aux
		jz	short wait_subf04_ack 	; ok, if no IBF
		jmp	error_03		; interface error
wait_subf04_ack:
		call	wait_ack		; wait response and set status
		jz	short get_type		; ok, if get acknowledge
		jmp	func_c2_ret
get_type:
		call	get_data		; wait AOBF and get data
		jz	short no_echo_type		; error if no AOBF
		mov	bp_bh,al		; set device id

		jmp	succ_00 		; successful
no_echo_type:
		jmp	error_03		; interface error
SUBF_04 	ENDP
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end
		CK_ORG	0ECD0H
Cyrix_Reg_Tbl:
		extrn	Cyrix_Cache_Reg:near
		extrn	NO_OF_CYRIX_REG:ABS
		DW	OFFSET DGROUP:Cyrix_Cache_Reg
		db	NO_OF_CYRIX_REG
		db	0aah			;means cyrix modbinable

		CK_ORG	0ECD4H
		extrn	IbmCpu_Reg:near
		extrn	IbmCpu_End:near
		dw	offset DGROUP:IbmCpu_Reg
		dw	offset DGROUP:IbmCpu_End
		db	0aah			;means IBM CPU modbinable

		CK_ORG	0ECE0h

		PUBLIC	BIOS_ID_NUMBER
BIOS_ID_NUMBER:
		DB	'21400000',0		;Dummy , filled by MODBIN

;R04 - start
		CK_ORG	0ECE9h
  		PUBLIC	EISA_MOTHERBOARD_ID
EISA_MOTHERBOARD_ID:
		DB	3 dup (' ')		; manufacturer ID
		DW	0			; product ID
;R04 - end

		CK_ORG	0ECF0H
		JMP	HRDSKIO			; jmp to fixed disk software interrupt


INT71_REDIRECT	PROC	FAR

		PUSH	AX
;R121A ifdef	ACPI_SUPPORT				;R121
;R121A ifdef	PIIX_ID					;R121
;R121A 		Call	Mask_IRQ9		;R121
;R121A endif	;PIIX_ID				;R121
;R121A endif	;ACPI_SUPPORT				;R121
		MOV	AL,20H
		OUT	B8259,AL
		POP	AX
		INT	0AH
		IRET

INT71_REDIRECT	ENDP

; 4 BYTES REMAINING

		CK_ORG	0ED00H
INT_HDISK	PROC	FAR			; fixed disk interrupt vector must
						; be at fixed location for SPEEDSTOR
		PUSH	AX
		PUSH	DS
		ASSUME	DS:G_RAM		; N3.03
		MOV	AX,G_RAM		; set segment to BIOS data areaN3.03
		MOV	DS,AX
;R27		MOV	HDC_INT,255		; interrupt occurred
;R28		OR	HDC_INT,1		;R27
;R49		OR	HDC_INT,not 40h		;R28 reserve bit 1 for IRQ15
		OR	HDC_INT,0ffh		;R49
		PUSH	DX
		MOV	DX,DISK_STAT_PORT
Clear_IRQ1415:					;R27
		IN	AL,DX			; CLEAR CONTROLLER (CONNER)
		POP	DX
		NEWIODELAY
		MOV	AL,END_OF_INT		; IRQ14 CLEAR
		OUT	B8259,AL
		NEWIODELAY
		OUT	A8259,AL
		MOV	AX,9100H
		POP	DS
		INT	15H
		POP	AX
		IRET

INT_HDISK	ENDP

;R121A ;R121 - start
;R121A ifdef	ACPI_SUPPORT				
;R121A ifdef	PIIX_ID					
;R121A MAsk_IRQ9	Proc	Near			
;R121A 		IN	AL,B8259+1		
;R121A 		OR	AL,02h			;Mask IRQ9
;R121A 		OUT	B8259+1,AL		
;R121A 		ret				
;R121A MAsk_IRQ9	Endp				
;R121A endif	;PIIX_ID				
;R121A endif	;ACPI_SUPPORT				
;R121A ;R121 - end
;R27 - starts
		public	INT_HDISK1
INT_HDISK1	PROC	FAR			; fixed disk interrupt vector must
						; be at fixed location for SPEEDSTOR
		PUSH	AX
		PUSH	DS
		ASSUME	DS:G_RAM		; N3.03
		MOV	AX,G_RAM		; set segment to BIOS data areaN3.03
		MOV	DS,AX
;R57		OR	HDC_INT,40h		; interrupt occurred
		OR	HDC_INT,0c0h		;R57
		PUSH	DX
		MOV	DX,DISK_STAT_PORT-80h
		jmp	short Clear_IRQ1415

INT_HDISK1	ENDP
;R27 - ends

		PAGE
;WAIT_FOR_MEM:	Waits for a bit at a specified memory location pointed
;		to by ES:[DI] to become set.
;INPUT:
;	AH=Mask to test with.
;	ES:[DI] = memory location to watch.
;	BH:CX=Number of memory refresh periods to delay.
;		(normally 30 microseconds per period.)
;OUTPUT:
;	AH=  0 if got pattern.
;	    80h if timeout.
;	DX= preserved
;	AL,BH:CX destroyed.
;	BL preserved.
		ALIGN	4			; 303A
WAIT_FOR_MEM	PROC	NEAR
;R64 		TEST	BYTE PTR cs:[SETTINGS],0C0H
;R64 		JZ	SHORT WFM_SHORT
;R64 		JNS	SHORT WFM_LONG
;R64 		JMP	WFM_CPU

;WFM_SHORT:  Wait for memory when refresh pulse is short (15-80 Us)

		ALIGN	4
WFM_SHORT	PROC	NEAR

WFMS_OUTER_LP:	OR	CX,CX			; if 1st entry,
		JNZ	SHORT WFMS_CHECK_MEM	; begin testing
		OR	BH,BH			; check outer counter
		JZ	SHORT WFMS_TIMEOUT	; then were done.
		DEC	BH

		ALIGN	4
WFMS_CHECK_MEM:	TEST	ES:[DI],AH
		JNZ	SHORT WFMS_GOT_BIT	; got the bit

		ALIGN	4
WFMS_HI:	IN	AL,SYS1		; wait for lo to hi
		TEST	AL,010H			; transition on memory
		JNZ	SHORT WFMS_HI		; refresh.

		ALIGN	4
WFMS_LO:	IN	AL,SYS1
		TEST	AL,010H
		JZ	SHORT WFMS_LO
		LOOP	SHORT WFMS_CHECK_MEM
		JMP	SHORT WFMS_OUTER_LP

WFMS_TIMEOUT:	MOV	AH,80H			; fail
		JMP	SHORT WFMS_EXIT

WFMS_GOT_BIT:	XOR	AH,AH			; success
WFMS_EXIT:	RET
WFM_SHORT	ENDP

;WFM_LONG:  Wait for memory when refresh pulse is long (80Us to 5 Ms)

;R64 		ALIGN	4
;R64 WFM_LONG	PROC	NEAR
;R64
;R64 WFML_OUTER_LP:	OR	CX,CX			; if 1st entry,
;R64 		JNZ	SHORT WFML_CHECK_MEM_HI	; begin testing
;R64 		OR	BH,BH			; check outer counter
;R64 		JZ	SHORT WFML_TIMEOUT	; then were done.
;R64 		DEC	BH
;R64
;R64 		ALIGN	4
;R64 WFML_CHECK_MEM_HI:
;R64 		TEST	ES:[DI],AH
;R64 		JNE	SHORT WFML_GOT_BIT	; got the bit
;R64 		IN	AL,SYS1		; wait for lo to hi
;R64 		TEST	AL,010H			; transition on memory
;R64 		JNZ	SHORT WFML_CHECK_MEM_HI	; refresh.
;R64
;R64 		ALIGN	4
;R64 WFML_CHECK_MEM_LO:
;R64 		TEST	ES:[DI],AH
;R64 		JNE	SHORT WFML_GOT_BIT	; got the bit
;R64 		IN	AL,SYS1		; wait for lo to hi
;R64 		TEST	AL,010H			; transition on memory
;R64 		JZ	SHORT WFML_CHECK_MEM_LO	; refresh.
;R64
;R64 		LOOP	SHORT WFML_CHECK_MEM_HI
;R64 		JMP	WFML_OUTER_LP
;R64
;R64 WFML_TIMEOUT:	MOV	AH,80H			; fail
;R64 		JMP	SHORT WFML_EXIT
;R64
;R64 WFML_GOT_BIT:	XOR	AH,AH			; success
;R64 WFML_EXIT:	RET
;R64 WFM_LONG	ENDP
;R64
;R64 ;WFM_CPU:  Wait for memory when refresh pulse is unreliable
;R64
;R64 		ALIGN	4			; 303A
;R64 WFM_CPU		PROC	NEAR
;R64
;R64 WFMC_OUTER_LP:	OR	CX,CX			; if 1st entry,
;R64 		JNZ	SHORT WFMC_CHECK_MEM	; begin testing
;R64 		OR	BH,BH			; check outer counter
;R64 		JZ	SHORT WFMC_TIMEOUT	; then were done.
;R64 		DEC	BH
;R64
;R64 		ALIGN	4
;R64 WFMC_CHECK_MEM:	PUSH	CX
;R64 		MOV	CX,8
;R64
;R64 		ALIGN	4
;R64 WFMC_INNER_LP:	TEST	ES:[DI],AH
;R64 		JNZ	SHORT WFMC_GOT_BIT	; got the bit
;R64 		LOOP	SHORT WFMC_INNER_LP
;R64 		POP	CX
;R64
;R64 		LOOP	SHORT WFMC_CHECK_MEM
;R64 		JMP	SHORT WFMC_OUTER_LP
;R64
;R64 WFMC_TIMEOUT:	MOV	AH,80H			; fail
;R64 		JMP	SHORT WFMC_EXIT
;R64
;R64 WFMC_GOT_BIT:	POP	CX
;R64 		XOR	AH,AH			; success
;R64
;R64 WFMC_EXIT:	RET
;R64 WFM_CPU		ENDP


WAIT_FOR_MEM	ENDP

		PAGE
;WAIT_REFRESH:  Uses port 61, bit 4 to have CPU speed independent waiting.
;   	INPUT: BX:CX = number of refresh periods to wait
;     	       (refresh periods = 1 per 30 microseconds on most machines)
;	OUTPUT: BX:CX destroyed.
;
;	SAVES:	AX (except when NO STACK)
;
;	NOTES:	This routine can be (and is) used with no stack. When
;		used this way, AX is assumed to be destroyed.
;

		ALIGN	4
		PUBLIC	WAIT_REFRESH
WAIT_REFRESH	PROC	NEAR
		TEST	BYTE PTR cs:[SETTINGS],0C0H
		JZ	SHORT WR_SHORT
		JNS	SHORT WR_SHORT
		JMP	WR_CPU

WR_SHORT	PROC	NEAR

		PUSH	AX			; save ax.

		ALIGN	4
WR_OUTER_LP:
WR_INNER_LP:
WR_STATE_0:	IN	AL,SYS1
		TEST	AL,010H
		JZ	SHORT WR_STATE_0

		ALIGN	4
WR_STATE_1:	IN	AL,SYS1
		TEST	AL,010H
		JNZ	SHORT WR_STATE_1
		LOOP	SHORT WR_INNER_LP

		OR	BX,BX
		JZ	SHORT WR_EXIT
		DEC	BX
		JMP	SHORT WR_OUTER_LP

WR_EXIT:	POP	AX			; restore ax
		RET
WR_SHORT	ENDP

		public	WR_CPU			;R13
WR_CPU		PROC	NEAR
		PUSH	AX			; save ax.

		ALIGN	4			; N3.03
WRC_OUTER_LP:
WRC_INNER_LP:
		PUSH	CX
		MOV	CX,15
		LOOP	SHORT $
		POP	CX

		LOOP	SHORT WRC_INNER_LP

		OR	BX,BX
		JZ	SHORT WRC_EXIT
		DEC	BX
		JMP	SHORT WRC_OUTER_LP

WRC_EXIT:	POP	AX			; restore ax
		RET
WR_CPU		ENDP

WAIT_REFRESH	ENDP


;[]==============================================================[]
;
; WR_STR_TTY:
;
;	Writes a null terminated string to the screen. Used for
;	strings which the BIOS prints after POST, such as unclaimed
;	NMI, disk boot failure, etc. This routine works with 0Dh (CR)
;	0Ch (LF) and 07h (BELL).
;
;Saves:	BX,CX,SI
;
;Entry:	CS:SI	Null terminated string to print.
;
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

		ALIGN	4
		PUBLIC	WR_STR_TTY
WR_STR_TTY	PROC	NEAR

		push	cx
		push	bx
		push	ds

		push	cs
		pop	ds

		ALIGN	4
wr_str_tty_1:
		lodsb
		or	al,al	    		; end of string?
		jz	wr_str_tty_2		; yes...

		call	Tty_Char

		jmp	short wr_str_tty_1

wr_str_tty_2:
		pop	ds
		pop	bx
		pop	cx
		ret
WR_STR_TTY	ENDP



PRINT_HEX	PROC	NEAR
		PUSH	BP
		MOV	BP,SP
		MOV	DX,WORD PTR 4[BP]
		POP	BP
;		CALL	PRNT_HEX_NUMBER
;		RET
;;;; WARNING FALL THROUGH TO PRNT_HEX_NUMBER
PRINT_HEX	ENDP

PRNT_HEX_NUMBER	PROC	NEAR
; FALLEN INTO BY PRINT_HEX

		MOV	AL,DH
		CALL	XLAT_ASCII
		MOV	AL,DL
;		JMP	XLAT_ASCII		; AND RETURN
;;;; WARNING FALL THROUGH TO XLAT_ASCII
PRNT_HEX_NUMBER	ENDP
XLAT_ASCII	PROC	NEAR
; FALLEN INTO BY PRNT_HEX_NUMBER
;
		MOV	CL,4
		MOV	BX,2F0H			; DO 2 NIBBLES,HI ONE FIRST

		ALIGN	4
CONV_NIBBLE:	PUSH	AX
		AND	AL,BL
		SHR	AL,CL
		CMP	AL,9
		JBE	SHORT ADD_ASC_ADJ

		ADD	AL,7

ADD_ASC_ADJ:	ADD	AL,30H
		call	TTY_Char
		POP	AX
		SHR	BL,CL			; GET LOW NIBBLE
		SUB	CL,4
		DEC	BH
		JNZ	SHORT CONV_NIBBLE
		RET

XLAT_ASCII	ENDP

;[]==============================================================[]
;
; TTY_CHAR:
;
;	Print a character to screen using BIOS.
;
;ENTRY:	AL	Character to print
; EXIT: NONE
;
;SAVES: BX
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM  | 15-Nov-90  | Update to 4.0
;
;[]==============================================================[]

		PUBLIC	TTY_CHAR
TTY_CHAR	PROC	NEAR

		push	ax
		push	bx
		mov	ah,0eh			; wrtty function
		mov	bx,3			; page 0, attr in case graph mode
		int	10h			; write to tty
		pop	bx
		pop	ax

		ret
TTY_CHAR	ENDP

;R77 - start

;[]==============================================================[]
;
;SETUP_STACK:
;
;	Reserve stack space for user-interface routines, CMOS, etc.
;
;
;Saves:	AX,CX
;
;Entry: NONE
;Exit:	NONE
;
;Notes:	1.	TOTALSTACK is defined in STACK.EQU.
;
;Author: Tim Lewis
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Initial revision
;
;[]==============================================================[]
		align	4
		PUBLIC	SETUP_STACK
SETUP_STACK	PROC	NEAR


; Begin save BP
		pop	bx			; pop return address

		sub	sp,DATAAREASIZE		; reserve stack size for setup

		mov	bp,sp

; Begin save BP
		push	ds			; save BP in G_RAM:Temp_BP
		push	ax
		mov	ax, G_RAM
		mov	ds,ax
		ASSUME DS:G_RAM
		mov	word ptr [Temp_BP], bp
		ASSUME DS:DGROUP
		pop	ax
		pop	ds

		push	bx			; put return address back
; End save BP

		ret
SETUP_STACK	ENDP

		public	PUP_WAIT1
PUP_WAIT1:
;R105		mov	cx,cs:[Power_On_Delay]
;R105		jcxz	short @F
;R105Wait_Chipset:
;R105		NEWIODELAY
;R105		loop	short Wait_Chipset
;R105@@:

		mov	ax,BIOS_STK
		mov	ss,ax
		mov	sp,offset POSTSTK_TOP

		call	Setup_Stack

		PUBLIC	POST_1S
POST_1S		PROC	NEAR
POST_1S		ENDP
		PUBLIC	POST_2S
POST_2S		PROC	NEAR
		call	E000_64K_shadow_RW
		mov	si,5000h
		mov	di,0e000h
		mov	cx,8000h
		call	Move_Codes
		call	E000_64K_shadow_R
;R94 start
		mov	si,4100h
		mov	di,Xgroup_Segment
;R94A		mov	cx,7800h
		mov	cx,8000h		;R94A
		call	Move_Codes
;R94 end
;R98 start
ifdef Flash_2M_support
		call	Enter_Protect_Mode
		mov	ax,ds
		mov	es,ax
		mov	esi,80000h
		mov	edi,160000h
		mov	ecx,8000h
		cld
 		db	67h
 		rep	movsd			;move extend 128k data to 160000h
		call	Leave_Protect_Mode
endif ;Flash_2M_support
;R98 end
;R114 - start
   		mov	byte ptr POST_SPEED[bp],Normal_Boot
		mov	si,offset Normal_Post_Tests
ifdef	ACPI_SUPPORT
	ifdef	S4_SUPPORT
		Call	Check_S4_Resume
		jz	short @F
;R124		mov	si,offset S4_Post_Tests
		mov	si,offset Normal_Post_Tests		;R124
	   	mov	byte ptr POST_SPEED[bp],S4_resume_Boot
		jmp	short Normal_Poweron
	@@:
	endif	;S4_SUPPORT

	ifdef	SIMPLE_BOOT_SUPPORT
		Call	Check_Simple_Flag
	endif	;SIMPLE_BOOT_SUPPORT
Normal_Poweron:
endif	;ACPI_SUPPORT
		push	0E000H
		push	si
		retf
;R114 - end
;R114		FAR_JMP	<OFFSET Normal_Post_Tests>,0E000H
POST_2S		ENDP

;R77 - end

;R76;[]==============================================================[]
;R76;
;R76; REPORT_ERROR_WSPKR:
;R76;
;R76;	Reports errors before the video is available. The unique
;R76;	number of long and short beeps can identify the type
;R76;	of the error.
;R76;
;R76;
;R76;Saves:	NONE
;R76;
;R76;Entry:	DH	Number of long beeps to make
;R76;	DL	Number of short beeps to make
;R76;
;R76;Exit:	NONE
;R76;
;R76;Author: Award
;R76;Date:   04/18/90
;R76;
;R76; Name | Date	    | Description
;R76; ---------------------------------------------------------------
;R76; TIM | 18-Apr-90   | Update to 4.0
;R76;
;R76;[]==============================================================[]
;R76
;R76		ALIGN	4
;R76		PUBLIC	REPORT_ERR_WSPKR
;R76REPORT_ERR_WSPKR PROC	NEAR
;R76
;R76		CLI
;R76		PUSHF
;R76		PUSH	DS
;R76		MOV	BX,G_RAM		; CAUSED A BUG WHEN MOVED
;R76		MOV	DS,BX			; set ds=0
;R76		ASSUME	DS:G_RAM
;R76
;R76		OR	DH,DH			; any long beeps?
;R76		JZ	SHORT SHORT_B		; no...
;R76
;R76;
;R76; 	Long beeps
;R76;
;R76
;R76		ALIGN	4			; 303A
;R76LONG_B:		MOV	BL,6
;R76		CALL	SND_SPKR
;R76
;R76		LOOP	SHORT $
;R76		DEC	DH
;R76		JNZ	SHORT LONG_B
;R76
;R76;
;R76;	Short beeps
;R76;
;R76
;R76		ALIGN	4			; 303A
;R76SHORT_B:	MOV	BL,1
;R76		CALL	SND_SPKR
;R76
;R76		LOOP	SHORT $
;R76		DEC	DL
;R76		JNZ	SHORT SHORT_B
;R76
;R76		LOOP	SHORT $
;R76		LOOP	SHORT $
;R76
;R76		POP	DS
;R76		POPF
;R76
;R76		STI
;R76		RET
;R76
;R76REPORT_ERR_WSPKR ENDP


		PUBLIC	SND_SPKR
		ALIGN	4
SND_SPKR	PROC	NEAR
; RETURNS CX 0

		MOV	CX,533H

		PUBLIC	SND_SPKR_TONE
SND_SPKR_TONE:
		MOV	AL,0B6H
		OUT	CTRL8254,AL
		MOV	AX,CX
		NEWIODELAY
		OUT	DATA8254+2,AL
		MOV	AL,AH
		NEWIODELAY
		OUT	DATA8254+2,AL
		IN	AL,SYS1
		MOV	AH,AL
		OR	AL,3
		NEWIODELAY
		OUT	SYS1,AL
;R93		XOR	CX,CX

@@:					;R93
		mov	cx,5000h	;R93
		ALIGN	4
B_WAIT:
		newiodelay		;R93
		newiodelay		;R93
		newiodelay		;R93
		newiodelay		;R93
		LOOP	SHORT B_WAIT
		DEC	BL
;R93		JNZ	SHORT B_WAIT
		jnz	short @B	;R93

		MOV	AL,AH
		OUT	SYS1,AL
		RET
SND_SPKR	ENDP

		PUBLIC	EQUIP_INT11_SERVICE
EQUIP_INT11_SERVICE PROC NEAR

		push	ds			; save ds
		mov	ax,G_RAM		; get selector segemnt
		mov	ds,ax
		assume	ds:G_RAM		; n3.03

		xor	eax,eax			; assume no weitek

IFDEF WEITEK_SUPPORT
		mov	al,weitek_cmos
		call	get_cmos
		test	al,weitek_bit
		jz	equip_no_weitek
		mov	eax, (1 shl 24) 	;Indicate weitek present
equip_no_weitek:

ENDIF ;WEITEK_SUPPORT

		MOV	AX,[HARDWARE]		; and get current settings
		POP	DS
		IRET
EQUIP_INT11_SERVICE ENDP

;Rmv1 start
;*****************************************************************************
; Procedure Name:	irq12
;	Pointing device hardware interrupt IRQ12 routine
;	Just process mouse data, don't care hand-shaking flag
;	Relative flag : device driver far call flag
;	Relative value : data package size and count index
; Saves:
; Inputs:	none
; Output:	affect data package size and count index
; Destroy:	none
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************
		public	Irq12
irq12		proc	far

ifndef	NO_PS2_MOUSE_SUPPORT
		extrn	PM_Before_PS2_Mouse:near	;routine in PMU.ASM
		call	PM_Before_PS2_Mouse

		push	ax
		push	bx
		push	cx
		push	si
		push	di
		push	bp

		push	ds
                push    es                      ;R50
		cld
		in	al,DATA8042		; get mouse data

		sti
		mov	bx,G_RAM
		mov	ds,bx
		assume	ds:g_ram
		mov	bx,word ptr G_RAM:EXT_SEGMENT
		mov	ds,bx				; ds point to extended
		assume	ds:NOTHING			; data area

		mov	bl,byte ptr ds:PDFLG_1		; get current count idx
		and	byte ptr ds:pdflg_1,0f8h	; clear count index
		xor	bh,bh
		and	bl,07
		mov	byte ptr ds:auxdata[bx],al	; set mouse data
		mov	bh,byte ptr ds:PDFLG_2		; get data package size
		and	bh,07
		inc	bl
		cmp	bl,bh
		ja	do_far_call
		or	byte ptr ds:PDFLG_1,bl		; set new count index

		call	Check_DataPack			;R50

		jmp	short irq12_ret
do_far_call:
		test	byte ptr ds:PDFLG_2,DDFCFLG	; check device service
		jz	short irq12_ret			; routine installed

		xchg	bl,bh
		xor	bh,bh			; bx contain data package size
		mov	cx,bx
		inc	cx			; data size loop
		mov	si,bx
		shl	si,1
		lea	bx,DGROUP:address_tbl
		mov	bx,word ptr cs:[bx+si]	; get xlat table address

		xor	ax,ax			; set stack and clear
		push	ax
		push	ax
		push	ax
		push	ax
		mov	bp,sp
		mov	si,auxdata
set_stack_loop:
		mov	al,byte ptr cs:[bx]	; get stack relative position
		mov	di,ax
		lodsb				; get mouse data
		mov	byte ptr [bp+di],al	; put it in stack
		inc	bx
		loop	set_stack_loop

		call	dword ptr ds:fcoffset	; call device service routine
		add	sp,08
irq12_ret:
		cli

		extrn	PM_After_PS2_Mouse:near	;routine in PMU.ASM
		call	PM_After_PS2_Mouse

		mov	al,END_OF_INT
		out	B8259,al 		; EOI to slave 8259
		NEWIODELAY
		out	A8259,al			; EOI to master 8259

                pop     es                            ;R50

		pop	ds

		pop	bp
		pop	di
		pop	si
		pop	cx
		pop	bx
		pop	ax

endif	;NO_PS2_MOUSE_SUPPORT

		iret
irq12		endp
;Rmv1 end

		CK_ORG	0EF57H

DSKINT_VECT	PROC	NEAR
		PUSH	AX
		PUSH	DS
		MOV	AX,G_RAM
		MOV	DS,AX
		ASSUME	DS:G_RAM		; N3.03
		OR	NEED_RECAL,80H

		MOV	AL,END_OF_INT
		OUT	A8259,AL
		MOV	AX,9101H
		POP	DS
		INT	15H
		POP	AX
		IRET
DSKINT_VECT	ENDP

		PAGE

SPURIOUS_INT_HDLR PROC	FAR

		PUSH	DS
		PUSH	AX
		PUSH	CX

		ASSUME	DS:G_RAM		; N3.03
		MOV	AX,G_RAM
		MOV	DS,AX
		MOV	AL,0BH			;Interrupt Service Register
		OUT	A8259,AL		;(ISR)
		NEWIODELAY
		IN	AL,A8259
		Newiodelay
		MOV	AH,AL
		OR	AL,AL			;IRQ0-IRQ7 in service ?
		JZ	SHORT SOFT_INT		;no, it should be soft INT.

		test	al,100b			;IRQ 2(chain to 2nd 8259) ?;R72B
		jz	short Primary_Int	;no , it's by IRQ 0-7	   ;R72B

	;Check if INT came by 2nd 8259
		MOV	AL,0BH			;read ISR of second 8259
		OUT	B8259,AL
		NEWIODELAY
		IN	AL,B8259
		Newiodelay
		MOV	CL,AL
		OR	AL,AL			;IRQ8-IRQ15 in service ?
		JZ	SHORT PRIMARY_INT			;R72C
;R72C		jz	short Soft_Int				;R72B
;R72B		JZ	SHORT PRIMARY_INT
;R68 ifndef	PCI_BUS						;R24
;R72		IN	AL,B8259+1
;R72		NEWIODELAY
;R72		OR	AL,CL
;R06 start
;R17		and	al,07Fh			; Do not turn off watchdog
;R06 end
;R72		OUT	B8259+1,AL
;R72		NEWIODELAY
;R68 endif;	PCI_BUS						;R24

;R72A - start
;R116ifdef	MASK_IRQ_FOR_SPURIOS
ifndef		DONT_MASK_IRQ_FOR_SPURIOS	;R139
		IN	AL,B8259+1
		NEWIODELAY
		OR	AL,CL			;mask noise interrupt
		OUT	B8259+1,AL
		NEWIODELAY
endif;		DONT_MASK_IRQ_FOR_SPURIOS	;R139
;R116endif;	MASK_IRQ_FOR_SPURIOS
;R72A - end

		MOV	AL,END_OF_INT
		OUT	B8259,AL
		JMP	SHORT SEND_PRIMARY_EOI

PRIMARY_INT:
;R68 ifndef	PCI_BUS						;R24
		IN	AL,A8259+1
;R72		OR	AL,AH
;R72A - start
;R116ifdef	MASK_IRQ_FOR_SPURIOS
ifndef		DONT_MASK_IRQ_FOR_SPURIOS	;R139
		OR	AL,AH			;mask noise interrupt
endif;		DONT_MASK_IRQ_FOR_SPURIOS	;R139
;R116endif;	MASK_IRQ_FOR_SPURIOS
;R72A - end
		NEWIODELAY
		and	al,0FBh			;enable IRQ2 for slave 8259
		OUT	A8259+1,AL
;R68 endif;	PCI_BUS						;R24
SEND_PRIMARY_EOI:
		MOV	AL,20H
		NEWIODELAY
		OUT	A8259,AL
		JMP	SHORT SPUR_DONE

SOFT_INT:
		MOV	AH,0FFH

SPUR_DONE:
		MOV	INT_OCCUR_FLG,AH
		POP	CX
		POP	AX
		POP	DS

		IRET
SPURIOUS_INT_HDLR ENDP


		CK_ORG	0EFC7H
FDC_PARS:	DB	0DFH,2H,25H,2,18,1BH,0FFH,54H,0F6H,15,8	; 15->18 1.44
; CHANGE FOR 720K FLOPPY
; SIMILAR TO 1.44 MEG BIOS PARMS, WITH FASTER MOTOR SPIN UP TIME 08->04
;	DB	0AFH,02H,25H,02H,12H,1BH,0FFH,6CH,0F6H,0FH,04H ; NEW PARMS



		ASSUME	DS:DGROUP
		CK_ORG	0EFD2H
;[]==============================================================[]
;
;PRN_VECT:
;
;	Compatibility ORG for Int 17h. Calls routine in
;	PARALLEL.ASM
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

		PUBLIC	PRN_VECT
PRN_VECT	PROC	NEAR

		jmp	Printer

;R27 - starts
;HDD drive table for system BIOS shadowed to fix NOVELL boot problem
		public	DRV0
DRV0		label	word
		db	16 dup(?)

		public	DRV1
DRV1		label	word
		db	16 dup(?)

		public	DRV2
DRV2		label	word
		db	16 dup(?)

		public	DRV3
DRV3		label	word
		db	16 dup(?)
;R27 - ends

;R138 start
	public	IDE_drive_Type
IDE_drive_Type		dw	?	;bit 0 -3  : for IDE 0
					;bit 4 -7  : for IDE 1
					;bit 8 -11 : for IDE 2
					;bit 12-15 : for IDE 3
					;value define : 0000 = none
					;		0001 = HDD
					;		0002 = CDROM
					;		0003 = LS120
					;		0004 = ZIP 100
;R138 end

	public	IDE_drive_Max_num		;R80
	public	Int13_original_address		;R80
	public	SCSI_drive_Max_num		;R81
SCSI_drive_Max_num	db	?		;R81
IDE_drive_Max_num	db	?		;R80
Int13_original_address	dd	?		;R80
;R129 start
		public	IDE_DMA_Flag
IDE_DMA_Flag		db	?	;bit 0 = 1 means drive 0 DMA active
					;bit 1 = 1 means drive 1 DMA active
					;bit 2 = 1 means drive 2 DMA active
					;bit 3 = 1 means drive 3 DMA active
		public	IDE_DMA_BMIBA
IDE_DMA_BMIBA		dw	?	;Bus Master Interface Base Address for DMA transfer
;R129 end

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT
;*****************************************************************************
; Procedure Name:	subf_05
;	Pointing device interface initialization
;	- set data package size
;	- execute reset command, if fail, then try 3 times
; Saves:
; Inputs:	bp_bh (BH) = data package size (01 - 08 bytes)
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 02 : invalid input
;				= 03 : interface error
;				= 04 : resend
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_05 	PROC	NEAR
		or	bp_bh,00		; check data package size
		jz	short incorrect_size
		cmp	bp_bh,08
		jbe	short correct_size
incorrect_size:
		jmp	error_02		; invalid input
correct_size:
		and	byte ptr ds:pdflg_2,0f8h
		mov	al,bp_bh
		dec	al
		or	byte ptr ds:pdflg_2,al
		mov	bh,03			; try 3 times if fail
rstloop:
		mov	al,ms_reset		; reset command
		call	out_aux
		jz	short wait_subf05_ack 	; ok, if no IBF
		jmp	short subf05_error
wait_subf05_ack:
		call	wait_ack		; wait response and set status
		jnz	short subf05_error		; jmp if error occur
		call	get_data		; wait AOBF and get data
		jz	short subf05_error		; error if no AOBF
		call	get_data		; wait AOBF and get data
		jnz	short setdef_suc
subf05_error:
		dec	bh
		jnz	short rstloop
		jmp	error_03		; interface error
setdef_suc:
		jmp	succ_00 		; successful
SUBF_05 	ENDP
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

		CK_ORG	0F065H
;[]==============================================================[]
;
;VIDEO_VECT:
;
;	Compatibility ORG for Int 17h. Calls routine in
;	AVIDEO.ASM. Required for EGA/VGA operation
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

		PUBLIC	VIDEO_VECT
VIDEO_VECT	PROC	NEAR

;R65A ifdef	PNP_BIOS					;R65
;R65A 		jmp	Video_Entry1
;R65A else	;PNP_BIOS					;R65
;R65A 		jmp	Video_Entry			;R65
;R65A endif	;PNP_BIOS					;R65
;R65A start
;R90 - start
ifdef NO_SUPPORT_AVIDEO
		iret
else ;NO_SUPPORT_AVIDEO
;R90 - end
ifdef	AVIDEO_AT_F000
		jmp	Video_Entry
else	;AVIDEO_AT_F000
		jmp	Video_Entry1
endif	;AVIDEO_AT_F000
endif ;NO_SUPPORT_AVIDEO			;R90
;R65A end

VIDEO_VECT	ENDP



IF BUS_TYPE EQ EISA_BUS
;[]==============================================================[]
;
;EISA_NMI_CHK:
;
;	Do special handling for NMIs on the EISA bus since there
;	can be multiple NMI sources.
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: SDI
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | New for 4.0
;
;[]==============================================================[]

		PUBLIC	EISA_NMI_CHK
EISA_NMI_CHK	PROC	NEAR
		push	dx

		mov	dx,EISA_NMI_STATUS
chk_eisa_nmi:
		in	al,dx			;read EISA NMI status
		test	al,EISA_TIMER_NMI+EISA_TIMEOUT_NMI+EISA_SW_NMI
		jz	short eisa_nmi_done	;no more EISA NMIs to check
		mov	ah,NOT(CLR_SW_NMI)	;prepare s/w NMI mask
		test	al,EISA_SW_NMI
		jnz	short eisa_nmi_clear	;go clear s/w NMI
		mov	ah,NOT (CLR_TIMEOUT_NMI) ;prepare for bus timeout NMI
		test	al,EISA_TIMEOUT_NMI
		jnz	short eisa_nmi_clear	;go clear bus timeout NMI
		mov	ah,NOT (CLR_TIMER_NMI)	;must be fail-safe timer NMI
eisa_nmi_clear:
		and	al,0FH			;only bits 0-3 to be set
		and	al,ah			;and in zeroed NMI bit
		out	dx,al			;and send to port
		IODELAY
		not	ah			;"toggle" bit to clear NMI
		or	al,ah
		out	dx,al
		IODELAY
		not	ah			;now disable this NMI channel
		and	al,ah
		out	dx,al
		IODELAY
		jmp	short chk_eisa_nmi
eisa_nmi_done:
		pop	dx			;restore DX, and continue
		ret
EISA_NMI_CHK	ENDP
ENDIF ;BUS_TYPE EQ EISA_BUS

;R114 - start
ifdef	SIMPLE_BOOT_SUPPORT
Check_Simple_Flag	Proc	Near

		mov	al,SIMPLE_BOOT_CMOS NMI_OFF
		Call	Get_CMOS
		xor	bl,bl
		mov	cx,8
Test_Bit:
		ror	al,1
		jnc	short Bit_Low
		inc	bl
Bit_Low:
		loop	short Test_Bit

		test	bl,1			;Is ODD parity OK ?
		jz	short Normal_Post	;No

		test	al,00000001b		;Is PNP OS installed ?
		jz	short Normal_Post	;No

		test	al,00000110b		;Is every thing OK ?
		jnz	short Normal_Post	;No

	   	mov	byte ptr POST_SPEED[bp],Quick_Boot
;R124		mov	si,offset Quick_Post_Tests
		mov	si,offset Normal_Post_Tests		;R124
Normal_Post:
		mov	al,SIMPLE_BOOT_CMOS NMI_OFF
		mov	ah,10000110b		;Assume every thing is fail
		Call	Set_CMOS
		ret
Check_Simple_Flag	Endp
endif	;SIMPLE_BOOT_SUPPORT
;R114 - end

		CK_ORG	0F0A4H
VIDEO_PARMS:	DB	38H,28H,2DH,0AH,1FH,6,19H,1CH,2,7,6,7,0,0,0,0
		DB	71H,50H,5AH,0AH,1FH,6,19H,1CH,2,7,6,7,0,0,0,0
		DB	38H,28H,2DH,0AH,7FH,6,64H,70H,2,1,6,7,0,0,0,0
ifdef	Special_6845_Mode_7_Parms			;R34
		db	Special_6845_Mode_7_Parms	;R34
else	;Special_6845_Mode_7_Parms			;R34
		DB	61H,50H,52H,0FH,19H,6,19H,19H,2,0DH,0BH,0CH,0,0,0,0
endif	;Special_6845_Mode_7_Parms			;R34

TBL_MODE_CLEN:	DW	2048			; # OF CHAR PER SCREEN MODES(0,2,4,6)
		DW	4096
		DW	16384
		DW	16384

TBL_MODE_COLM:	DB	40,40,80,80,40,40,80,80	; # OF COLUMNS FOR MODES 0-7

TBL_MODE_SETS:	DB	2CH,28H,2DH,29H,2AH,2EH,1EH,29H	; MODES SETS FOR MODES 0-7

;[]==============================================================[]
;
;INT75_REDIRECT:
;
;	Handles the incoming IRQ 13. If EISA, we allow chaining.
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

INT75_REDIRECT	PROC	FAR

		push	ax
		push	dx

IF BUS_TYPE EQ EISA_BUS

		mov	dx,EISA_DMA_CHAIN
		in	al,dx			;check if chained DMA IRQ 13

		test	al,0EFH			;bit 4 is reserved, so mask out
		jz	short not_eisa_dma	;no ints. go do coprocessor int

		test	al,0E0H			;check if word or byte
		jz	short eisa_byte_ok	;byte - use byte mode register

		mov	dx,EISA_DMA_CH_2	;word - use word mode register
		shr	al,4			;get channel data in low nibble
		and	al,0EH			;mask out reserved bit

eisa_byte_ok:
		mov	ah,0fh			;set up for mode register mask

find_eisa_channel:				;(10H for channel 0 etc.)
		inc	ah			;set appropriate mask
		shr	al,1			;get channel in CFL
		jnc	find_eisa_channel	;loop til channel found

		mov	al,ah			;AL now has required channel no.
		out	dx,al			;clear DMA IRQ13, disable chain
		pop	dx

		mov	al,END_OF_INT
		out	B8259,al
		NEWIODELAY
		out	A8259,al		;send EOI to int. controllers
		pop	ax			;restore regs.
		iret				;and return to caller

not_eisa_dma:					;not DMA IRQ13, do coprocessor
ENDIF ;BUS_TYPE EQ EISA_BUS

		xor	al,al
		out	MATH_PORT,al

		mov	al,END_OF_INT
		NEWIODELAY
		out	B8259,al

		NEWIODELAY
		out	A8259,al

;R40		pop	ax
		pop	dx
		pop	ax			;R40
		int	2
		iret

INT75_REDIRECT	ENDP

		PAGE


; SERIAL BASE PORTS, MUST BE NEAR LABELS FOR LINK...


AUX_ADDRS:					; always supports 4 COMMs.
		DW	03FAH			; STANDARD COM1
		DW	02FAH			; STANDARD COM2
		DW	03EAH			; NON-STANDARD COM3
		DW	02EAH			; NON-STANDARD COM4

; PRINTER BASE PORTS

AUX_PRN_ADDRS:	DW	03BCH			; MONO/PRINTER CARD
		DW	0378H			; LPT1
		DW	0278H			; LPT2

END_AUX_ADDRS:



;NON ORGED DATA

BIOS_IDT:	DW	100H,OFFSET DGROUP:BIOS_IDT_DESC,0Fh,0

; WHY IS 8700H THE SAME BETWEEN 286/386
BIOS_IDT_DESC:	DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0
		DW	OFFSET DGROUP:EXCEPTION_HDLR
		DW	20H,8700H,0

HDERRORS:	DW	0E000H,200H,4000H,100H,0BB00H,400H,0BB00H,1000H,0A00H

		PUBLIC	BAUD_DIVISORS
;R46 BAUD_DIVISORS:	DW	1047,768,384,192,96,48,24,12,3,5,6,7,8,10,12,14
BAUD_DIVISORS:	DW	1047,768,384,192,96,48,24,12,6		;R46

SHIFT		EQU	0
ALPHA		EQU	1
ASCII		EQU	2
FUNCTION	EQU	3
KEYPAD		EQU	4
TOGGLE		EQU	5
NUMERIC		EQU	6
F11_F12		EQU	7
BREAK		EQU	8
E0_E1		EQU	9

INS_LK		EQU	80H
CAPS_LK		EQU	40H
NUM_LK		EQU	20H
SCRL_LK		EQU	10H
SYS_REQ		EQU	4
ALT		EQU	8
CTRL		EQU	4
LT_SHFT		EQU	2
RT_SHFT		EQU	1

KEYS:
ifndef	Non_English_KB
		DB	0,      0,      0,      0	; 00 (0)  scan codes start with 1
		DB	ASCII   ,    1BH,    1BH,    1BH	; 01 (1)  esc key
		DB	NUMERIC ,    '1',    '!',   0FFH	; 02 (2)  1 key
		DB	NUMERIC ,    '2',    '@',      0	; 03 (3)  2 KEY
		DB	NUMERIC ,    '3',    '#',   0FFH	; 04 (4)  3 KEY
		DB	NUMERIC ,    '4',    '$',   0FFH	; 05 (5)  4 key
		DB	NUMERIC ,    '5',    '%',   0FFH	; 06 (6)  5
		DB	NUMERIC ,    '6',    '^',     30	; 07 (7)  6
		DB	NUMERIC ,    '7',    '&',   0FFH	; 08 (8)  7
		DB	NUMERIC ,    '8',    '*',   0FFH	; 09 (9)  8
		DB	NUMERIC ,    '9',    '(',   0FFH	; 0A (10) 9
		DB	NUMERIC ,    '0',    ')',   0FFH	; 0B (11) 0
		DB	NUMERIC ,    '-',    '_',     31	; 0C (12) -
		DB	NUMERIC ,    '=',    '+',   0FFH	; 0D (13) =
		DB	ASCII   ,      8,      8,    127	; 0E (14) bksp
		DB	ASCII   ,      9,      0,   0FFH	; 0F (15) tab key
		DB	ALPHA   ,    'q',    'Q',     17	; 10 (16) q
		DB	ALPHA   ,    'w',    'W',     23	; 11 (17) w
		DB	ALPHA   ,    'e',    'E',      5	; 12 (18) e
		DB	ALPHA   ,    'r',    'R',     18	; 13 (19) r
		DB	ALPHA   ,    't',    'T',     20	; 14 (20) t
		DB	ALPHA   ,    'y',    'Y',     25	; 15 (21) y
		DB	ALPHA   ,    'u',    'U',     21	; 16 (22) u
		DB	ALPHA   ,    'i',    'I',      9	; 17 (23) i
		DB	ALPHA   ,    'o',    'O',     15	; 18 (24) o
		DB	ALPHA   ,    'p',    'P',     16	; 19 (25) p
		DB	ASCII   ,    '[',    '{',     27	; 1A (26) [
		DB	ASCII   ,    ']',    '}',     29	; 1B (27) ]
		DB	ASCII   ,     CR,     CR,     10	; 1C (28) CR
		DB	SHIFT   ,   CTRL,   0FFH,   0FFH	; 1D (29) ctrl key
		DB	ALPHA   ,    'a',    'A',      1	; 1E (30) a
		DB	ALPHA   ,    's',    'S',     19	; 1F (31) s
		DB	ALPHA   ,    'd',    'D',      4	; 20 (32) d
		DB	ALPHA   ,    'f',    'F',      6	; 21 (33) f
		DB	ALPHA   ,    'g',    'G',      7	; 22 (34) g
		DB	ALPHA   ,    'h',    'H',      8	; 23 (35) h
		DB	ALPHA   ,    'j',    'J',     LF	; 24 (36) j
		DB	ALPHA   ,    'k',    'K',     11	; 25 (37) k
		DB	ALPHA   ,    'l',    'L',     12	; 26 (38) l
		DB	ASCII   ,    ';',    ':',   0FFH	; 27 (39) COMMA
		DB	ASCII   ,    27H,    22H,   0FFH	; 28 (40) '
		DB	ASCII   ,    60H,    '~',   0FFH	; 29 (41) `
		DB	SHIFT   ,LT_SHFT,   0FFH,   0FFH	; 2A (42) left SHIFT
		DB	ASCII   ,    '\',    '|',     28	; 2B (43) \
		DB	ALPHA   ,    'z',    'Z',     26	; 2C (44) z
		DB	ALPHA   ,    'x',    'X',     24	; 2D (45) x
		DB	ALPHA   ,    'c',    'C',      3	; 2E (46) c
		DB	ALPHA   ,    'v',    'V',     22	; 2F (47) v
		DB	ALPHA   ,    'b',    'B',      2	; 30 (48) b
		DB	ALPHA   ,    'n',    'N',     14	; 31 (49) n
		DB	ALPHA   ,    'm',    'M',     CR	; 32 (50) m
		DB	ASCII   ,    ',',    '<',   0FFH	; 33 (51)
		DB	ASCII   ,    '.',    '>',   0FFH	; 34 (52) .
		DB	ASCII   ,    '/',    '?',   0FFH	; 35 (53) / 101
		DB	SHIFT   ,RT_SHFT,   0FFH,   0FFH	; 36 (54) right SHIFT
		DB	TOGGLE  ,      0,   0FFH,   0FFH	; 37 (55) prnt scrn
		DB	SHIFT   ,    ALT,   0FFH,   0FFH	; 38 (56) alt key
		DB	ALPHA   ,    ' ',    ' ',    ' '	; 39 (57) sp
		DB	TOGGLE  ,CAPS_LK,   0FFH,   0FFH	; 3A (58) caps lk
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 3B (59) f1
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 3C (60) f2
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 3D (61) f3
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 3E (62) f4
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 3F (63) f5
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 40 (64) f6
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 41 (65) f7
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 42 (66) f8
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 43 (67) f9
		DB	FUNCTION,   0FFH,   0FFH,   0FFH	; 44 (68) f10
		DB	TOGGLE  , NUM_LK,   0FFH,   0FFH	; 45 (69) num lk
		DB	TOGGLE  ,SCRL_LK,   0FFH,   0FFH	; 46 (70) scrl lk
		DB	KEYPAD  ,      1,    '7',    119	; 47 (71) home
		DB	KEYPAD  ,      1,    '8',    141	; 48 (72) up arrow 101
		DB	KEYPAD  ,      1,    '9',    132	; 49 (73) pg up
		DB	ASCII   ,    '-',    '-',   0FFH	; 4A (74) - 101
		DB	KEYPAD  ,      1,    '4',    115	; 4B (75) lft arrow
		DB	KEYPAD  ,      1,    '5',    143	; 4C (76) 5 101
		DB	KEYPAD  ,      1,    '6',    116	; 4D (77) rt arrow
		DB	ASCII   ,    '+',    '+',   0FFH	; 4E (78) + 101
		DB	KEYPAD  ,      1,    '1',    117	; 4F (79) end
		DB	KEYPAD  ,      1,    '2',    145	; 50 (80) dn arrow 101
		DB	KEYPAD  ,      1,    '3',    118	; 51 (81) pg dn
		DB	KEYPAD  , INS_LK,    '0',    146	; 52 (82) ins 101
		DB	TOGGLE  ,      0,   0FFH,    147	; 53 (83) del 101
		DB	TOGGLE  ,SYS_REQ,   0FFH,   0FFH	; 54 (84) SYS KEY
		DB	E0_E1	,   0FFH,   0FFH,   0FFH	; 55 (85) E0 - V2.09
		DB	ASCII   ,    '\',    '|',     28	; 56 (86) \
		DB	F11_F12	,   0FFH,   0FFH,   0FFH	; 57 (87) f11 - V2.09
		DB	F11_F12	,   0FFH,   0FFH,   0FFH	; 58 (88) f12 - V2.09
else	;Non_English_KB
		include	atorgs.inc
endif	;Non_English_KB


;[]=========================================================================[]
;
;	INT 17 -- Printer I/O
;
;	ENTRY
;		AL = character
;		AH = function number (0-2)
;		DX = printer # (0-3)
;	EXIT
;		AH = status
;	SAVES
;		all but AH
;
;[]=========================================================================[]
;[]========================================================================[]
;	Function table
;[]========================================================================[]

prn_func_table	dw	offset DGROUP:print_F0
		dw	offset DGROUP:print_F1
		dw	offset DGROUP:print_F2
prn_func_no	equ	($-prn_func_table) / 2

		public	Printer
Printer		proc	near

		push	dx
		push	cx
		push	bx
		push	di
		push	si
		push	bp
		sti

		cmp	dx,4
		jnc	exit1
		cmp	ah,prn_func_no
		jb	short prn_0
		sub	ah,prn_func_no - 1
		jmp	exit1
prn_0:
		mov	di,dx

	;get printer port and timeout value
		push	es
		assume	es:G_RAM
		mov	bx,G_RAM
		mov	es,bx
		mov	cl,byte ptr es:[di+PARL_PORT_TO_CNT]
				;get timeout value
		shl	di,1
		mov	dx,es:[di+PRNTR_PORT_ADDRS]
				;get port address
		pop	es
		assume	es:nothing
		cmp	dx,0
		je	exit1
		mov	si,dx	;si = status port
		inc	si
		mov	bp,dx	;bp = control port
		add	bp,2

		push	ax	;save character
		xor	bh,bh
		mov	bl,ah
		shl	bx,1
		jmp	word ptr cs:prn_func_table[bx]


;[]========================================================================[]
;	Function 0: print one character
;
;	Entry:
;		al = character
;		cl = timeout value
;		dx = printer port address
;	Return:
;		ah = printer status
;[]========================================================================[]
print_F0:

		out	dx,al		;send character
		newiodelay
		mov	dx,si		;status port
		in	al,dx		;get status
		newiodelay
		and	al,80h		;is printer busy?
		jnz	short print_F0_0
		mov	ah,90h		;call INT 15h
		mov	al,0feh
		int	15h

print_F0_wait:
		push	cx		;save timeout value
		mov	cx,cs:[WAIT_PRN_NBUSY_LO]
		mov	bh,cs:[WAIT_PRN_NBUSY_HI]
		mov	al,80h		;wait for bit 7 to be set
		mov	ah,80h		;only bit 7 is used
		call	wait_for_port	;al = last read of port
		pop	cx
		or	ah,ah		;did we get it?
		jz	short print_F0_0	;yes, go to print
		dec	cl
		jnz	short print_F0_wait
		or	al,1		;timeout error
		jmp	short exit

print_F0_0:
		mov	dx,bp		;strobe port
		mov	al,00001101b
		out	dx,al		;strobe HIGH
		newiodelay
		mov	al,00001100b
		out	dx,al		;strobe LOW
		newiodelay

	;get printer status
printer_status:
		mov	dx,si		;status port
		in	al,dx		;get status
		newiodelay
		and	al,0feh		;remove D0

exit:
		and	al,0f9h		;clear bits
		xor	al,48h		;invert bits
		mov	ah,al
		pop	bx		;retrieve AL
		mov	al,bl

exit1:

		pop	bp
		pop	si
		pop	di
		pop	bx
		pop	cx
		pop	dx
		iret

;[]========================================================================[]
;	Function 1: initialize printer
;
;	Entry:
;		dx = printer port address
;	Return:
;		ah = printer status
;[]========================================================================[]
print_F1:
		mov	al,00001000b	;select printer
		mov	dx,bp		;control port
		out	dx,al
		newiodelay
		mov	cx,cs:[WAIT_PRN_INIT_LO]
		mov	bx,cs:[WAIT_PRN_INIT_HI]
		call	wait_refresh
		mov	al,00001100b	;select+initialize printer
		out	dx,al
		newiodelay
		jmp	printer_status

;[]========================================================================[]
;	Function 2: get printer status
;
;	Entry:
;		dx = printer port address
;	Return:
;		ah = printer status
;[]========================================================================[]
print_F2:
		jmp	printer_status

PRINTER		ENDP
PRN_VECT	ENDP

;Rmv start
;[]==============================================================[]
;
; REDO:
;
;	This routine is called by the reset vector at F000:E05B
;	after a power-up. It determines whether this is a virtual
;	shutdown or a normal boot. If it is a normal boot, we
;	juggle a few cache's and then go on to POST.
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]
  		align	4			;R16
		PUBLIC	REDO
REDO		PROC	NEAR

;M01 - start
ifdef RPB_ENABLED
ifdef RPB_REBOOT_DISABLE
  call rpbf_prepare_for_reset
endif ; RPB_REBOOT_DISABLE
endif ; RPB_ENABLED
;M01 - end

		mov	gs,dx
;
;	Test if this was a virtual shutdown.
;

		cli
		cld
;R89 start
ifdef	ACPI_Support	
ifdef	S2_SUPPORT				;R112
;R89A		extrn	CheckACPIWakeEvent:near
;R89A		public	NotACPIWakeEvent
		jmp	CheckACPIWakeEvent	;If wake up from ACPI sleep state
						;code won't return here.
NotACPIWakeEvent:
endif	;S2_SUPPORT				;R112
endif;	ACPI_Support
;R89 end
		in	al,STAT8042		; was this a user or prog reset ?
		test	al,4
		jnz	short redo1		; virtual shutdown...

		mov	ax,cs						;R12
		mov	ss,ax			; ss = cs		;R12

;R02 start
ifdef	PM_SUPPORT
		rom_call  	CT_Sleep_Detect
		jnz	short redo1		; virtual shutdown...
endif	;PM_SUPPORT
;R02 end

		jmp	Pup_Wait		; first time power up
REDO		ENDP


;[]==============================================================[]
;
; REDO1:
;
;
;	Handle the virtual shutdown. The shutdown code is in byte 0Fh
;of CMOS. The following codes can be found can be used:
;
;
;00h = Power on or soft reset
;01h = Memory sizing pass
;02h = Memory test pass
;03h = Memory test fail
;04h = POST end; boot system
;05h = Flush keyboard buffer, do an EOI, jmp to dword 40:67
;06h = Protected mode test pass
;07h = Protected mode test fail
;08h = Memory sizing fail
;09h = INT 15h block move return
;0Ah = jmp to dword 40:67
;
;Saves:	NONE
;
;Entry:	NONE
;Exit:	NONE
;
;Author: Award
;Date:   04/18/90
;
; Name | Date	    | Description
; ---------------------------------------------------------------
; TIM | 18-Apr-90   | Update to 4.0
;
;[]==============================================================[]

  		align	4			;R16
REDO1		PROC	NEAR

;R61 - start
		smsw	ax
		test	al,01h			;in protection mode?
		jz	short _Not_VM		;No

;R61A		mov	ax,cs
;R61A		mov	ss,ax
;R61A		mov	al,0fh NMI_OFF
;R61A		mov	ah,0
;R61A		Rom_Call Set_Cmos

		cli
		mov	al,0feh
		out	64h,al			;Reset CPU
		Public	CPU_HALT		;R79
CPU_HALT:					;R79
_292:
		hlt
		jmp	short _292
_Not_VM:
;R61 - end

;R95 start
;M01ifdef RPB_ENABLED                     ; R89
;M01    ; We cannot call RPB to check if is enabled here because
;M01    ; RPB is in E000h which has been overwritten.  We must 
;M01    ; check the RPB data in the BDA directly
;M01    extrn rpb_f000_is_running:near
;M01    call  rpb_f000_is_running
;M01    jnz   skip_chipset_reset          ; NZ if RPB is running
;M01endif ; RPB_ENABLED
;R95 end

;R88 - starts
IF	BIOS_SUPPORT_586
;----------------------------------------------------------------------
;The following code is added to support the AMD k6's Write allocation
; - This feature must be disabled in early stage of warm boot.
; - the "jmp short Not_K6" instruction will be replaced with 2 NOPs
;   if K6 CPU is detected in POST 
;----------------------------------------------------------------------
		Public	Skip_K6_Write_Allocate
	Skip_K6_Write_Allocate	Label	Near

		jmp	short Not_K6
		mov	ecx, 0c0000082h
;R127		RDMSR
;R127		and	ax, not 1FFh
		xor	eax, eax				;R127
		WRMSR

	Not_K6:
ENDIF	;BIOS_SUPPORT_586
;R88 - ends

;R74 - start
;Issue system reset if warm booting
Send_SystemReset:				;R84
;R126 start
;R126A 		mov	al,0FH NMI_OFF		;get shutdown info.
;R126A 		out	CMOS,al
;R126A 		newiodelay
;R126A 	   	in	al,CMOS+1
;R126A 		newiodelay
;R126A
;R126A		or	al,al			;warm reset or exit from setup
;R126B		call	Get_ShutDown_Byte	;R126A
		jmp	Get_ShutDown_Byte	;R126B
Get_ShutDown_Byte_Ret:				;R126B
		jnz	short ShutDown_Func
;R126 end
		extrn	Issue_System_Reset:near
		call	Issue_System_Reset
ShutDown_Func:					;R126
;R74 - end

;R95 start
ifdef RPB_ENABLED                     ; R89
    skip_chipset_reset:
endif ; RPB_ENABLED
;R95 end
;R59 - start
ifdef	PATCH_ORION_PCI_RESET
		call	Orion_Reset_Patch
endif;	PATCH_ORION_PCI_RESET
;R59 - start

;R07 start
;R20 ifdef	PM_SUPPORT
		mov	ax,G_RAM			;R15
		mov	es,ax				;R15
		assume	es:G_RAM
		cmp	es:USER_REBOOT,CTRL_ALT_DEL	;R52
		je	short Its_WarmBoot		;R52

ifdef	PM_SUPPORT					;R20
;R52		cmp	es:USER_REBOOT,CTRL_ALT_DEL	;R20B
;R20		cmp	G_RAM:USER_REBOOT,CTRL_ALT_DEL	;R15
;R52		je	short Not_SMI_Start		;R15
	jmp	Ct_Check_SMI_Start	;See if it is a SMI request
					;issue(AMD & U5 CPU)
	Public	Not_SMI_Start
Not_SMI_Start:
endif	;PM_SUPPORT
;R07 end

;R20 - start
		jmp	short Skip_Video_Set 	;it's cold boot
Its_WarmBoot:
;R96 start
ifdef	NeoMagic_2093AB
ifndef	By_pass_TV_Support
		mov	ax,4f14h
		mov	bx,0104h		;Set active display
		mov	cl,3			;SimulSCAN
		int	10h			;set display type
endif	;By_pass_TV_Support
		jmp	short Skip_Video_Set	;no, skip it
endif	;NeoMagic_2093AB
;R96 end

;R20F - start
;R66		test	es:[System_Flag],Cirrus_PCi_VGA	;Is Cirrus VGA ?
ifndef	NeoMagic_2093AB		;R96A
	test	es:[System_Flag],VGA_NEED_SET_MODE3	;need set mode 3?;R66
	jz	short Skip_Video_Set			;no, skip it
;R20F - end

;R20C - start
		mov	esi,dword ptr es:[TEMP_BP+2]

;R20D - start
		mov	eax,esi
		shr	eax,16
		mov	ds,ax
		mov	ax,ds:[0]
		cmp	ax,0AA55h
		jne	short Skip_Video_Set
;R20D - end

		xor	ax,ax
		mov	ds,ax
		mov	ds:[40h],esi
;R20C - end
		mov	ax,0003H		;set text mode 80*25
		int	10H
endif	;NeoMagic_2093AB		;R96A
Skip_Video_Set:
;R20 - end

;R126		mov	ax,BIOS_STK		; setup stack
;R126		mov	ss,ax
;R126		mov	sp,offset BIOSSTK_TOP
;R126 start
		mov	ax,30h			;set SS:SP=30h:100h
		mov	ss,ax
		mov	sp,100h
;R126 end

;R05 - start
;R16A		mov	al,8fh			; cmos shutdown byte
;R16A		out	CMOS,al
;R16A		newiodelay
;R16A	   	in	al,CMOS+1
		mov	al,0fh NMI_OFF		;R16A
		call	Get_Cmos		;R16A

;R113;R73 - start
;R113ifdef	Notebook_Power_Management
;R113		extrn	ZV_Resume_Byte:ABS
;R113		xor	ah,ah
;R113		cmp	al,ZV_Resume_Byte
;R113		jne	short @F
;R113		xchg	al,ah
;R113@@:
;R113endif	;Notebook_Power_Management
;R113;R73 - end

;R70 - start
ifdef	PCI_BUS
		or	al,al
		jnz	short Sys_ShutDown
ifndef	Atorgs_Dont_Reset_PciMaster		;R107
		extrn	Reset_PciMaster:near
		call	Reset_PciMaster
endif	;Atorgs_Dont_Reset_PciMaster		;R107
Sys_ShutDown:
endif;	PCI_BUS
;R70 - end

;R16A		push	ax
		or	al,al
;R54		jz	short Not_ShutDown
		jz	chk_2			;R54
;R05 - end

		push	ax			;R16A

		cmp	al,0AH	;0AH shutdown ?	;R100
		je	short SkipCyrixProg	;R100

		call	Init_Cyrix_Reg		;R21

		mov	al,1			;R06
		call	Restore_Cyrix_Reg	;R06

		call	Ct_Restore_Cyrix_Reg	;R14A
SkipCyrixProg:					;R100

;R14 - starts
;R14B		mov	ax,0C3C3h	;lock Cyrix registers
;R14B		out	22h,al
;R14B		in	al,23h
;R14B		or	al,1
;R14B		xchg	ah,al
;R14B		out	22h,al
;R14B		xchg	ah,al
;R14B		out	23h,al
;R14 - ends

		call	Cpu_Init

ifdef	MP_SUPPORT
		call	Cpu_Apic_Init
endif;	MP_SUPPORT

;R67		mov	si,offset DGROUP:IntCache_Item
;R67		call	GetItem_Cmos
;R67		or	al,al
		test	byte ptr es:[SYSTEM_FLAG],Int_Cache_Status	;R67
		jz	short Not_Enable_486_Cache

;		mov	al,CMOS_AWARD_CACHE  NMI_OFF
;		call	Get_Cmos
;		test	al,SECONDARY_CACHE
;		jz	short Not_Enable_486_Cache

		mov	al,1			; al = cache on		;R12
		call	CPU_Cache					;R12
Not_Enable_486_Cache:							;R22

;R05		mov	al,8fh			; cmos shutdown byte
;R05		out	CMOS,al
;R05		newiodelay
;R05	   	in	al,CMOS+1
;R16A Not_ShutDown: 				;R05
		pop	ax			;R05
Not_ShutDown:					;R16A
; begin -workaround 386SL
; This delay loop is here to fix QAPLUS extended memory test for 386SL
; This loop should be taken away once bug is solved in hardware
;
;Deleted IFDEF DELAY_FOR_SHUTDOWN_BYTE_READ
;Deleted 		mov	cx,100
;Deleted 		loop	$
;Deleted ENDIF

		mov	ah,al
		cmp	al,9			; if 9 or 0ah don't re-init 8259s
		jae	short shut_branch

;
;		reset 8259s after virtual shut down
;

int8259init:
		xor	al,al
		out	MATH_PORT+1,al		; reset the co-processor
		mov	bx,ax			; save the shutdown code

		mov	ax,cs
		mov	ds,ax

;R67		mov	si,offset int_inits
		mov	si,offset DGROUP:int_inits	;R67
		mov	cx,size_int_inits

int8259_lp1:
		lodsw				; get the port
		mov	dx,ax			; put in correct reg
		lodsb				; get byte to ouput
		out	dx,al
		loop	short int8259_lp1

		mov	ax,bx			; restore shutdown

;
;		reset shutdown byte
;

shut_branch:
		mov	al,8fh			; NMI off
		out	CMOS,al
		newiodelay
		xor	al,al
		out	CMOS+1,al

	;check other shut down modes

		cmp	ah,9
		jne	short Chk_2
;R13		extrn	Exc9hdlr:near
		jmp	Exc9hdlr

chk_2:
		cmp	ah,5
		je	short jmp_5init		; user return from virtual mode

		cmp	ah,0ah			; user return from virtual mode without 8259 init
		je	short jmp_ioinit

;R02 start
ifdef	PM_SUPPORT
		cmp	ah,RESUME_SHUTDOWN_BYTE	; user return sleep mode
;R09		je	short jmp_RESUME_HANDLE
		je	jmp_RESUME_HANDLE	;R09
endif	;PM_SUPPORT
;R02 end

		cmp	ah,4			; user return from virtual w/ boot request
		jne	short chk_2a

;
;		enable parity, nmi (mode 4)
;

		call	Enable_Parity		; additional code clear parity

;
; 		enabling nmi is a bug fix which must stay in place here...
;

		mov	al,0fh NMI_ON		; enable nmi
		call	Get_Cmos

		int	19h			; boot

;
;	clear keyboard buffer and do an end-of-interrupt (mode 5)
;

jmp_5init:
		in	al,DATA8042		; clear keyboard
		mov	al,END_OF_INT		; clear interrupts
		NEWIODELAY
		out	A8259,al

;
;	jmp dword 40:[67] (mode 5 & 10)
;

jmp_ioinit:					; jmp to dword at 40:67

		mov	eax,cr0
		or	al,10h			; enable ET bit
		mov	cr0,eax

		mov	ax,G_RAM
		mov	ds,ax
		assume	ds:G_RAM

;R19 - start
ifdef	MP_SUPPORT
;Windows NT 3.5 set an invalid return address 0c0000003H if only one CPU
;plugged , so system can not reboot and hang in video ROM
;R19A - It also hang in option ROM. For example, Using NCR/810 and it's ROM
;	locate at E800H , the return address will be E8000003H.
;R19A - start

;R84 - start
		cmp	G_RAM:USER_REBOOT,CTRL_ALT_DEL		;warm booting
		jne	short Not_WarmReboot
		cmp	ds:dword ptr ROM_MODULE_OFFSET,01000000H;invaild address
		je	Send_SystemReset
Not_WarmReboot:
;R84 - end

		cmp	ds:word ptr ROM_MODULE_OFFSET,0003H
		jne	short @F
		mov	ax,ds:word ptr (ROM_MODULE_OFFSET+2)
		cmp	ax,0c000H	;In option ROM area ?
		jb	short @F
		cmp	ax,0f000H
		jbe	Chk_2a
@@:

;R19A		cmp	ds:dword ptr ROM_MODULE_OFFSET,0c0000003H	;invaild address
;R19A		je	chk_2a		;warm reset

endif;	MP_SUPPORT
;R19 - end

		jmp	G_RAM:dword ptr ROM_MODULE_OFFSET
;;;		jmp	ds:dword ptr ROM_MODULE_OFFSET

;R02 start
ifdef	PM_SUPPORT
jmp_RESUME_HANDLE:
;;;;;		mov	ax,cs
;;;;;		mov	ss,ax
		push	cs	;;;;; reduce code size
		pop	ss	;;;;;
		call  	CT_RESUME_HANDLE
endif	;PM_SUPPORT
;R02 end

chk_2a:
;;system warm boot or after doing setup go to here
		xor	bp,bp			; memory test fail
		call	A20_On			; turn on A20 to match
						; cold boot status

;R53 - start
		mov	al,FALSE
		call	Cpu_Cache		;disable CPU cache
;R53 - end

;R01 - start
;
; Restore CPU type from G_RAM:CPU_TYPE_FLAG for warm boot
;
		mov	al,0eh				;R03
		call	get_cmos			;R03
		test	al,CKSM_STATUS+RTC_STATUS	;R03
		jz	short @F			;R03

;R135		mov	ax,G_RAM
;R135		mov	ds,ax
		push	SEG G_RAM			;R135
		pop	ds				;R135
		assume  ds:G_RAM
		mov	al,CMOS_AWARD_2 NMI_OFF
		mov	ah,G_RAM:CPU_TYPE_FLAG
;;;;		mov	ah,ds:CPU_TYPE_FLAG
		call	Set_Cmos

		mov	al,CMOS_OVERRIDE NMI_OFF	;R04
		call	get_cmos			;R04
		and	al,00111111b			;R04
		mov	ah,G_RAM:CPU_CLOCK			;R04
;;;;		mov	ah,ds:CPU_CLOCK			;R04
;;;;		and	ah,00000011b			;R04
		shl	ah,6				;R04
		or	ah,al				;R04
		mov	al,CMOS_OVERRIDE NMI_OFF	;R04
		call	Set_Cmos			;R04

@@:							;R03
;R09 - start
ifndef	MP_SUPPORT					;R60
IF	BIOS_SUPPORT_486				;R101
		mov	al,CMOS_AWARD_2 NMI_OFF
		call	Get_Cmos
		and	al,CPU_TYPE_MASK
		cmp	al,TYPE_TI486SXL2
		jne	short @F

		mov	dx,CPU_TI486SXL
		mov	ah,dl
		mov	al,CMOS_AWARD_2 NMI_OFF
		Call	Set_Cmos

		mov	al,OVERRIDE NMI_OFF
		Call	Get_Cmos
		and	al,Not Clock_Mode
		mov	ah,dh
		or	ah,al
		mov	al,OVERRIDE NMI_OFF
		Call	Set_Cmos
@@:
endif	;BIOS_SUPPORT_486				;R101
endif;	MP_SUPPORT					;R60
;R09 - end
;R01 - end
		jmp	Pup_Wait


REDO1		ENDP
;Rmv end

;R65A ifdef	PNP_BIOS				;R65
ifndef NO_SUPPORT_AVIDEO				;R90
ifndef	AVIDEO_AT_F000					;R65A
Video_Entry1:
		push	0e000h
		push	offset Video_Entry
		retf
;R65A endif	;PNP_BIOS				;R65
endif	;AVIDEO_AT_F000					;R65A
endif ;NO_SUPPORT_AVIDEO				;R90

		CK_ORG	0F600H
;***********************************************************************;
;									;
;	The following code reserve for Ct_Very_Early_Init		;
;									;
;			<<< Don't Use Please... >>>			;
;									;
;***********************************************************************;

		CK_ORG	0F80DH
		jmp	PUP_WAIT1

                CK_ORG  0F810H

;R104		public	UMC86xx_Read_Data_Port			;R99
;R104UMC86xx_Read_Data_Port:						;R99
;R104		DW	?					;R99
;R104 - start
		Public	TEMP1_HIGH
		Public	TEMP1_LOW
		Public	TEMP2_HIGH
		Public	TEMP2_LOW
		Public	CRITICAL_HIGH
;R117 TEMP1_HIGH:	DW	?					; Trip point 1 high  
;R117 TEMP1_LOW:	DW	?					; Trip point 1 low 
;R117 TEMP2_HIGH:	DW	?					; Trip point 2 high
;R117 TEMP2_LOW:	DW	?					; Trip point 2 low 
;R117 CRITICAL_HIGH:	DW	?					; Critical trip point
;R117 - start
TEMP1_HIGH:		DW	2732 + ( 50 * 10)	; Trip point 1 high  
TEMP1_LOW:		DW	2732 + ( 20 * 10)	; Trip point 1 low 
TEMP2_HIGH:		DW	2732 + ( 50 * 10)	; Trip point 2 high
TEMP2_LOW:		DW	2732 + ( 20 * 10)	; Trip point 2 low 
CRITICAL_HIGH:		DW	2732 + ( 60 * 10)	; Critical trip point
		Public	SENSOR_FLAG
SENSOR_FLAG		dw	01h			; Bit0 = 1  exist	
;R117 - end
;R104 - end

;R69 - start
ifdef	P6_BIOS_ONLY
                CK_ORG  0F820H
		include	CtEscdRd.inc
endif;	P6_BIOS_ONLY
;R69 - end

;R69 IF BUS_TYPE EQ EISA_BUS                         ;EISA_BUS ?
;R69 ;
;R69 ;	SPD_TBL: SetSpeed slowdown time constant for EISA (this should
;R69 ;	make it MODBINable in the future)
;R69 ;
;R69 		PUBLIC	SPD_TBL
;R69 		CK_ORG	0F830H
;R69 SPD_TBL:
;R69 		DB	64h
;R69 		DB	40h
;R69 		DB	20h
;R69 		DB	10H
;R69 ENDIF	;BUS_TYPE

;R118 - start
ifdef	ACPI_SUPPORT
		PUBLIC	ACPI_RESERVED_MEM	;R123
ACPI_RESERVED_MEM:				;R123
		DW	0			;R123
;R120 - start
		PUBLIC	Combined_Rom1
		CK_ORG	0F830H
Combined_Rom1:
		DW	00h		;offset
		DW	00h		;size

		PUBLIC	Combined_Rom2
		CK_ORG	0F834H
Combined_Rom2:
		DW	00h		;offset
		DW	00h		;size

		PUBLIC	Combined_Rom3
		CK_ORG	0F838H
Combined_Rom3:
		DW	00h		;offset
		DW	00h		;size

		PUBLIC	Combined_Rom_End
Combined_Rom_End:
;R120 - end
;R120;R119 - start
;R120ifdef	USB_SUPPORT
;R120		PUBLIC	USB_MEMORY
;R120		CK_ORG	0F83AH
;R120USB_MEMORY:
;R120		DW	00h
;R120endif	;USB_SUPPORT
;R120;R119 - end
		PUBLIC	ACPI_MEMORY
		CK_ORG	0F83CH
ACPI_MEMORY:
		DD	00h
endif	;ACPI_SUPPORT
;R118 - end

		CK_ORG	0F841H
;*****************************************
;Name:   	Memory_Size
;Entry:  	INT 12H
;Input:  	none
;Output: 	ax=number of 1K blocks
;Description:
;
;Memory_Size will:
;1. 	save environment
;2. 	return the memory size from memory word location 0:413h
;3. 	restore environment
;4. 	return to POI
;************************************************

MEM_SZ_VECT:
MEMORY_SIZE	PROC	NEAR
		PUSH	DS			; save DS
		ASSUME	DS:G_RAM		; N3.03
		MOV	AX,G_RAM		; segment selector
		MOV	DS,AX
		MOV	AX,[SIZE_SYSRAM]	; and get current settings
		POP	DS
		IRET
MEMORY_SIZE	ENDP


		ASSUME	DS:DGROUP
		CK_ORG	0F84DH
;********************************************************
;Name:   	equip
;Entry:  	INT 11H
;Input:
;Output: 	(ax) = equipment configuration as follows
;   	    	bit 0=1= diskette drive(s) configured
;   	    	bit 1 not used
;   	    	bit 2,3 (=00=64k,=01=128k,=10=192k,=11=256k) ram installed
;   	    	bit 4,5 =IPL video mode
;   	    	        =00=unused
;   	    	    	   =01=40x25 BW using color controller
;   	    	    	   =02=80x25 BW using color controller
;   	    	    	   =03=80x25 BW using BW controller
;   	    	bit 6,7 =number of diskette drives
;
;   	    	    	   =00=1 drive
;   	    	    	   =01=2 drives
;   	    	    	   =10=3 drives
;   	    	    	   =11=4 drives
;   	    	bit 8 unused
;   	    	bit 9,10,11 = number of RS232 cards configured
;   	    	bit 12 = game controller configured
;   	    	bit 13 not used
;   	    	bit 14,15 number of printers configured
;
;	EAX bit 24 set (=1) means Weitek Abacus coprocessor present
;
;Description:
;
;equip will:
;1. 	save environment
;2. 	return the equipment flag from memory word location 0:410h.
;3. 	restore environment
;4. 	return to POI
;*******************************************************

EQ_VECT:
EQUIP		PROC	NEAR
		JMP	EQUIP_INT11_SERVICE
EQUIP		ENDP


		CK_ORG	0F859H

		PUBLIC	CASS_VECT
CASS_VECT:
IF BUS_TYPE EQ EISA_BUS
;
;	NOTE: we MUST do a short jump here, since 16-bit offsets
;	are not recognized in 32-bit mode.
;
		JMP	SHORT MULT_D8_CHK	; NOTE:8-BIT
ELSEIF BUS_TYPE EQ ISA_BUS
		JMP	MULTI_SERVICE_NEAR
ENDIF ;BUS_TYPE



		CK_ORG	0F85CH
		extrn	PageOffset:near
		extrn	Rom_Table:near
		extrn	EndRom_Table:near
		extrn	Auto_Table:near
		extrn	EndAuto_Table:near
		extrn	Auto_String:near
		db	0bbh			;new setup structure
		dw	offset DGROUP:PageOffset
		dw	offset DGROUP:Rom_Table
		dw	offset DGROUP:EndRom_Table
		dw	offset DGROUP:Auto_Table
		dw	offset DGROUP:EndAuto_Table
		dw	offset DGROUP:Auto_String

; Begin MULT_D8_CHK move
IF BUS_TYPE EQ EISA_BUS
;
;	MULT_D8_CHK: ORG'd here so that the near jmp at CASS_VECT can
;	reach here.
;
;
                PUBLIC  MULT_D8_CHK
MULT_D8_CHK     PROC    NEAR

;R29	        cmp     ah,087h			; virtual move block?
;R29            jne     short md8c_1		; no...
;R29
;R29            jmp     Virtual_Move_Block
;R29
;R29md8c_1:
                cmp     ah,0d8h                 ; new EISA functions?
                jne     short do_norm_int15     ; no, do normal

                test    al,80h                  ; 16-bit mode?
                je      short do_16bit_int15    ; yes...

;
;       The following jmp instruction is executed in 32-bit mode. When
;       this happens, it will use the dw 0FFFFh which follows and will
;       jump to Eisa_Mode_32 + 2.
;

                jmp     cs:Eisa_Mode_32
                dw      0ffffh

do_norm_int15:
                jmp     Multi_Service_Near      ;normal INT 15H path
do_16bit_int15:
                jmp     Eisa_Functions_D8       ;16-bit EISA path
MULT_D8_CHK     ENDP
ENDIF ;BUS_TYPE
; End MULT_D8_CHK move

IF BUS_TYPE EQ EISA_BUS
IFDEF	DEFAULT_IRQ7
CLEAN_UP_IRQ	PROC	FAR
		IRET
CLEAN_UP_IRQ	ENDP
ENDIF	;DEFAULT_IRQ7
ENDIF	;BUS_TYPE

		PAGE

UART	STRUC
	ReceiveBuffer	DW	0	;base
	XmitHolding	DW	0	;base
	InterruptEnable	DW	0	;base+1
	LineControl	DW	0	;base+3
	ModemControl	DW	0	;base+4
	LineStatus	DW	0	;base+5
	ModemStatus	DW	0	;base+6
	DivisorLSB	DW	0	;base
	DivisorMSB	DW	0	;base+1
UART	ENDS
;[]=========================================================================[]
;	Serial function entry table
;[]=========================================================================[]

COMM_func_table	dw	offset DGROUP:COMM_F0
		dw	offset DGROUP:COMM_F1
		dw	offset DGROUP:COMM_F2
		dw	offset DGROUP:COMM_F3
		dw	offset DGROUP:COMM_F4		;R46
		dw	offset DGROUP:COMM_F5		;R46
COMM_func_no	equ	($-COMM_func_table) / 2


;[]======================================================================[]
;
;	INT 14 -- Serial I/O
;
;	ENTRY
;		AL = character or mode byte
;		AH = function number (0-3)
;		DX = port # (0-3)
;	EXIT
;		see functions
;	SAVES
;		all but AX
;
;[]======================================================================[]

		PUBLIC	COMM_entry
		ALIGN	4
COMM_entry	proc	near

		push	dx
		push	cx
		push	bx
		push	di
		push	bp
		sub	sp,type UART
		mov	bp,sp
		sti


	;check for valid port #

		cmp	dx,4
		jb	COMM_0
		jmp	COMM_exit
COMM_0:
		cmp	ah,COMM_func_no
		jb	COMM_1
		sub	ah,3
		jmp	COMM_exit

	;get serial port and timeout values

COMM_1:
		push	ds
		assume	ds:G_RAM
		mov	bx,G_RAM
		mov	ds,bx			; ds=data area.
		mov	bx,dx			; bx=com number
		cmp	ah,2				;R46
		je	short Get_Timeout_Val		;R46
;R47		cmp	ah,3				;R46
		cmp	ah,1				;R47
		jne	short @F			;R46
Get_Timeout_Val:					;R46
		mov	cl,byte ptr [bx+COMM_PORT_TO_CNT]	; get timeout value
@@:							;R46
		shl	bx,1			; word addressing
		mov	dx,[bx+COMM_PORT_ADDRS]
						; get port base address
		pop	ds

		or	dx,dx
		jz	COMM_exit
		mov	[bp].ReceiveBuffer,dx	;save reg. addr. in local
		mov	[bp].XmitHolding,dx
		mov	[bp].DivisorLSB,dx
		inc	dx
		mov	[bp].InterruptEnable,dx
		mov	[bp].DivisorMSB,dx
		add	dx,2
		mov	[bp].LineControl,dx
		inc	dx
		mov	[bp].ModemControl,dx
		inc	dx
		mov	[bp].LineStatus,dx
		inc	dx
		mov	[bp].ModemStatus,dx

		mov	bl,ah
		xor	bh,bh
		shl	bx,1
		jmp	word ptr cs:COMM_func_table[bx]


;[]=====================================================================[]
;	Function 0: initialize serial port parameters
;
;	ENTRY:
;		AH = 0
;		AL = parameter byte
;	EXIT:
;		AH = line control status
;		AL = modem status
;
;	DEFINITION OF PARAMETER BYTE:
;
;	765             43              2             10
;	Baud Rate       Parity          Stop Bit      Word Length
;	000 = 110 	00 = none       0 = 1 bit     10 = 7 bits
;	001 = 150 	01 = odd        1 = 2 bits    11 = 8 bits
;	010 = 300 	02 = even
;	011 = 600
;	100 = 1200
;	101 = 2400
;	110 = 4800
;	111 = 9600
;
;[]=====================================================================[]

COMM_F0:
;R46 start
		mov	bl,al			;get mode byte
		shr	bl,5			;get baud rate bits
		xor	bh,bh
		shl	bx,1			;si = word index to table
		mov	cx,word ptr cs:BAUD_DIVISORS[bx]	;AX = divisor
		mov	bl,al
		and	bl,1fh			;BL = retrieve mode byte
;R46 end

;set baud rate
;R46 start
;	CX = Baud rate divisor
;	BL = retrieve mode byte
Set_Baud_Rate:
;R46 end

;R46		push	ax			;save mode byte
		mov	al,10000000b		;set DLAB=1
		mov	dx,[bp].LineControl	;line control register
		out	dx,al
		newiodelay
;R46		pop	ax
;R46		push	ax
;R46		mov	bl,al			;get mode byte
;R46		shr	bl,5			;get baud rate bits
;R46		shl	bx,1			;bx=word index to table
;R46		mov	al,byte ptr cs:BAUD_DIVISORS[bx]	;divisor LSB
		mov	al,cl			;R46 divisor LSB
		mov	dx,[bp].DivisorLSB	;divisor latch LS (base)
		out	dx,al
		newiodelay
;R46		mov	al,byte ptr cs:BAUD_DIVISORS[BX+1]	;divisor MSB
		mov	al,ch			;R46 divisor MSB
		mov	dx,[bp].DivisorMSB	;divisor latch MS (base+1)
		out	dx,al
		newiodelay

	;set line control register (parity, stop bit and word length

;R46		pop	ax			;retrieve mode byte
;R46		and	al,01Fh			;mask off baud rate bits
		mov	al,bl			;R46 get retrieve mode byte
		mov	dx,[bp].LineControl	;line control reg (base+3)
		out	dx,al			;DLAB=0
		newiodelay

	;set interrupt control register (disable all UART interrupts)

		xor	al,al			;interrupt OFF
		mov	dx,[bp].InterruptEnable	;interrupt enable reg (base+1)
		out	dx,al
		newiodelay

COMM_status:
		mov	dx,[bp].ModemStatus	;modem status register
		in	al,dx
		newiodelay
		mov	ah,al
		mov	dx,[bp].LineStatus	;line status register
		in	al,dx
		newiodelay
		xchg	ah,al

COMM_exit:
		add	sp,type UART	;disgard local variables
		pop	bp
		pop	di
		pop	bx
		pop	cx
		pop	dx
		iret


		page

;[]=====================================================================[]
;	Function 1: write character to COMM port
;
;	ENTRY
;		AL = character
;		CL = timeout value
;
;	EXIT
;	   if function successful
;		AH = D7 : 0
;		     D6 - D0 : line status
;		AL = character (unchanged)
;
;	   if function unsuccessful
;		AH = D7 : 1 (timeout)
;		     D6 - D0 : either modem or line status
;		AL = character (unchanged)
;
;[]=====================================================================[]

COMM_F1:

	;set modem control DTR and RTS


		mov	ch,al			;save character
		mov	di,cx			; and timeout value
		mov	al,00000011b		;set DTR, RTS
		mov	dx,[bp].ModemControl	;modem control reg (base+4)
		out	dx,al
		newiodelay

	;wait for CTS and DSR or TIME-OUT

		mov	dx,[bp].ModemStatus	;modem status reg (base+6)
COMM_F1_lp1:
		push	cx			;save timeout value
		mov	cx,cs:[WAIT_COMM_LO]
		mov	bh,cs:[WAIT_COMM_HI]
		mov	al,30h			;wait for bits 4, 5 to be set
		mov	ah,30h			;only bits 4,5
		call	wait_for_port		;al=last read,
		pop	cx
		or	ah,ah			;ah=0 if we got
		mov	ah,al			;ah=last read.
		jz	short COMM_F1_1		;got CTS & RTS

		dec	cl
		jnz	short COMM_F1_lp1
		jmp	short Timeout_err_1

	;check Tramsmitter Holding Register empty (THRE) or TIME-OUT

COMM_F1_1:
		mov	cx,di
		mov	dx,[bp].LineStatus	;line status reg (base+5)
COMM_F1_lp2:
		push	cx			;save timeout value
		mov	cx,cs:[WAIT_COMM_LO]
		mov	bh,cs:[WAIT_COMM_HI]
		mov	al,20h			;wait for THRE (bit 5) set
		mov	ah,20h			;only bit 5
		call	wait_for_port		;al=last read,
		pop	cx
		or	ah,ah			;ah=0 if we got
		mov	ah,al			;ah=last read of status.
		jz	short COMM_F1_2		;XMT buffer empty.

		dec	cl
		jnz	short COMM_F1_lp2
		jmp	short Timeout_err_1	;timeout

	;send character

COMM_F1_2:
		mov	cx,di			;restore character
		mov	al,ch
		mov	dx,[bp].XmitHolding	;xmt holding reg (base)
		out	dx,al
		newiodelay
		jmp	short COMM_exit

	;timeout error

Timeout_err_1:
		mov	cx,di			;restore character
		or	ah,80h			;mark timeout
		mov	al,ch
		jmp	COMM_exit

		PAGE
;[]=====================================================================[]
;	Function 2: read character from COMM port
;
;	ENTRY
;		CL = timeout value
;
;	EXIT
;	  if function successful
;		AH = D7 : 0
;		     D6-D0 : line status
;		AL = character
;
;	  if function unsuccessful
;		AH = D7 : 1 for timeout
;		     D6-D0 : either modem or line status
;[]=====================================================================[]

COMM_F2:

	;set modem control DTR

		mov	di,cx			;save timeout value
		mov	al,00000001b		;set DTR
		mov	dx,[bp].ModemControl	;modem control reg (base+4)
		out	dx,al
		newiodelay

	;wait for DSR or TIME-OUT

		mov	dx,[bp].ModemStatus	;modem status reg (base+6)
COMM_F2_lp1:
		push	cx			;save timeout value
		mov	cx,cs:[WAIT_COMM_LO]
		mov	bh,cs:[WAIT_COMM_HI]		; wait for DSR
		mov	al,20h			;wait for bit 5 set
		mov	ah,20H			; only bit 5
		call	wait_for_port		;al=last read,
		pop	cx
		or	ah,ah			;ah=0 if we got
		mov	ah,al			;ah=last read.
		jz	short COMM_F2_1		;got DSR

		dec	cl
		jnz	short COMM_F2_lp1
		jmp	short Timeout_err_2	;timeout

	;wait for DR or TIME-OUT

COMM_F2_1:
		mov	cx,di			;restore timeout value
		mov	dx,[bp].LineStatus	;line status reg (base+5)
COMM_F2_lp2:
		push	cx
		mov	cx,cs:[WAIT_COMM_LO]
		mov	bh,cs:[WAIT_COMM_HI]		; wait for DATA READY
		mov	al,1			;wait for bit 0 set
		mov	ah,1			;only bit 0
		call	wait_for_port		;al=last read,
		pop	cx			;
		or	ah,ah			;ah=0 if we got
		mov	ah,al			;ah=last read.
		jz	short COMM_F2_2		;got DR

		dec	cl
		jnz	short COMM_F2_lp2
		jmp	short Timeout_err_2	;timeout

	;read data

COMM_F2_2:
		mov	dx,[bp].ReceiveBuffer	;data buffer (base)
		in	al,dx			;get character
		newiodelay
		and	ah,00011110b		;get error bits
		jmp	COMM_exit

	;timeout error

Timeout_err_2:
		or	ah,80h			;mark timeout
		jmp	COMM_exit


		PAGE
;[]=====================================================================[]
;	Function 3: get COMM port status
;
;	ENTRY
;		none
;	EXIT
;		AH = line status
;		AL = modem status
;
;[]=====================================================================[]

COMM_F3:

		jmp	COMM_status



COMM_ENTRY	ENDP				; MASM5

;Rmv1 start
ifndef	NO_PS2_MOUSE_SUPPORT
;*****************************************************************************
; Procedure Name:	subf_06
;	Extended commands
; Saves:
; Inputs:	bp_bl (BL) = extended command
;			   = 00 - Return status
;			   = 01 - Set scalling factor to 1:1
;			   = 02 - Set scalling factor to 2:1
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 01 : invalid function
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

SUBF_06 	PROC	NEAR
		mov	al,bp_bh
		or	al,al
		jz	short cmd_00
		dec	al
		jz	short cmd_01
		dec	al
		jz	cmd_02
		jmp	error_01		; invalid subfunction
SUBF_06 	ENDP

;*****************************************************************************
; Procedure Name:	cmd_00
;	return status
;	- execute auxiliary device status request command
;	- auxiliary device should sent 3 bytes status to system
; Saves:
; Inputs:	none
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 03 : interface error
;				= 04 : resend
;		bp_bl (BL) = status byte 1
;			bit 7	= reserved
;			bit 6	= 0 stream mode
;				= 1 remote mode
;			bit 5	= 0 disable data transmission
;				= 1 enable data transmission
;			bit 4	= 0 scaling 1:1
;				= 1 scaling 2:1
;			bit 3	= reserved
;			bit 2	= 1 left mouse button pressed
;			bit 1	= reserved
;			bit 0	= 1 right mouse button pressed
;		bp_cl (CL) = status byte 2
;			00 : 1 count/millimeter
;			01 : 2 counts/millimeter
;			02 : 4 counts/millimeter
;			03 : 8 counts/millimeter
;		bp_bl (DL) = status byte 3
;			0ah  : 10 reports/second
;			14h  : 20 reports/second
;			28h  : 40 reports/second
;			3ch  : 60 reports/second
;			50h  : 80 reports/second
;			64h  : 100 reports/second
;			0c8h : 200 reports/second
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

CMD_00		PROC	NEAR
		mov	al,ms_stsreq		; status request command
		call	out_aux
		jz	short wait_cmd00_ack		; ok, if no IBF
		jmp	error_03		; interface error
wait_cmd00_ack:
		call	wait_ack		; wait response and set status
		jz	short get_status		; ok, if get acknowledge
		jmp	func_c2_ret
get_status:
		call	get_data		; wait AOBF and get data
		jz	short no_echo_status		; error if no AOBF
		mov	bp_bl,al		; set 1st status byte

		call	get_data		; wait AOBF and get data
		jz	short no_echo_status		; error if no AOBF
		mov	bp_cl,al		; set 2nd status byte

		call	get_data		; wait AOBF and get data
		jz	short no_echo_status		; error if no AOBF
		mov	bp_dl,al		; set 3rd status byte

		jmp	succ_00 		; successful
no_echo_status:
		jmp	error_03		; interface error
CMD_00		ENDP

;*****************************************************************************
; Procedure Name:	cmd_01
;	set scaling factor 1:1
; Saves:
; Inputs:	none
; Output:	bp_flag : cf = 0 : no error
;			  cf = 1 : error
;		bp_errcode (AH) = 00 : no error
;				= 03 : interface error
;				= 04 : resend
; Destroy:
; Author:	Ken Chen
; Date: 	06/21/90
;
; Rev	| Name	| Date		| TPR#	| Description
; ------+-------+---------------+-------+-------------------------------------
; 1.00	| Ken	| 06/21/90	| NEW	| Initial revision
;
;*****************************************************************************

CMD_01		PROC	NEAR
		mov	al,ms_rstscl		; reset scaling command
		jmp	do_scale
CMD_01		ENDP
endif	;NO_PS2_MOUSE_SUPPORT
;Rmv1 end

		CK_ORG	0FA6EH

DOUBLE_DOT:	DB	000H,000H,000H,000H,000H,000H,000H,000H
		DB	07EH,081H,0A5H,081H,0BDH,099H,081H,07EH
		DB	07EH,0FFH,0DBH,0FFH,0C3H,0E7H,0FFH,07EH
		DB	06CH,0FEH,0FEH,0FEH,07CH,038H,010H,000H
		DB	010H,038H,07CH,0FEH,07CH,038H,010H,000H
		DB	038H,07CH,038H,0FEH,0FEH,07CH,038H,07CH
		DB	010H,010H,038H,07CH,0FEH,07CH,038H,07CH
		DB	000H,000H,018H,03CH,03CH,018H,000H,000H
		DB	0FFH,0FFH,0E7H,0C3H,0C3H,0E7H,0FFH,0FFH
		DB	000H,03CH,066H,042H,042H,066H,03CH,000H
		DB	0FFH,0C3H,099H,0BDH,0BDH,099H,0C3H,0FFH
		DB	00FH,007H,00FH,07DH,0CCH,0CCH,0CCH,078H
		DB	03CH,066H,066H,066H,03CH,018H,07EH,018H
		DB	03FH,033H,03FH,030H,030H,070H,0F0H,0E0H
		DB	07FH,063H,07FH,063H,063H,067H,0E6H,0C0H
		DB	099H,05AH,03CH,0E7H,0E7H,03CH,05AH,099H
		DB	080H,0E0H,0F8H,0FEH,0F8H,0E0H,080H,000H
		DB	002H,00EH,03EH,0FEH,03EH,00EH,002H,000H
		DB	018H,03CH,07EH,018H,018H,07EH,03CH,018H
		DB	066H,066H,066H,066H,066H,000H,066H,000H
		DB	07FH,0DBH,0DBH,07BH,01BH,01BH,01BH,000H
		DB	03EH,063H,038H,06CH,06CH,038H,0CCH,078H
		DB	000H,000H,000H,000H,07EH,07EH,07EH,000H
		DB	018H,03CH,07EH,018H,07EH,03CH,018H,0FFH
		DB	018H,03CH,07EH,018H,018H,018H,018H,000H
		DB	018H,018H,018H,018H,07EH,03CH,018H,000H
		DB	000H,018H,00CH,0FEH,00CH,018H,000H,000H
		DB	000H,030H,060H,0FEH,060H,030H,000H,000H
		DB	000H,000H,0C0H,0C0H,0C0H,0FEH,000H,000H
		DB	000H,024H,066H,0FFH,066H,024H,000H,000H
		DB	000H,018H,03CH,07EH,0FFH,0FFH,000H,000H
		DB	000H,0FFH,0FFH,07EH,03CH,018H,000H,000H
		DB	000H,000H,000H,000H,000H,000H,000H,000H
		DB	030H,078H,078H,078H,030H,000H,030H,000H	; !
		DB	06CH,06CH,06CH,000H,000H,000H,000H,000H
		DB	06CH,06CH,0FEH,06CH,0FEH,06CH,06CH,000H	; #
		DB	030H,07CH,0C0H,078H,00CH,0F8H,030H,000H	; $
		DB	000H,0C6H,0CCH,018H,030H,066H,0C6H,000H
		DB	038H,06CH,038H,076H,0DCH,0CCH,076H,000H
		DB	060H,060H,0C0H,000H,000H,000H,000H,000H
		DB	018H,030H,060H,060H,060H,030H,018H,000H
		DB	060H,030H,018H,018H,018H,030H,060H,000H
		DB	000H,066H,03CH,0FFH,03CH,066H,000H,000H
		DB	000H,030H,030H,0FCH,030H,030H,000H,000H
		DB	000H,000H,000H,000H,000H,030H,030H,060H
		DB	000H,000H,000H,0FCH,000H,000H,000H,000H	; -
		DB	000H,000H,000H,000H,000H,030H,030H,000H	; .
		DB	006H,00CH,018H,030H,060H,0C0H,080H,000H	; /
		DB	07CH,0C6H,0CEH,0DEH,0F6H,0E6H,07CH,000H	; 0
		DB	030H,070H,030H,030H,030H,030H,0FCH,000H
		DB	078H,0CCH,00CH,038H,060H,0CCH,0FCH,000H
		DB	078H,0CCH,00CH,038H,00CH,0CCH,078H,000H
		DB	01CH,03CH,06CH,0CCH,0FEH,00CH,01EH,000H
		DB	0FCH,0C0H,0F8H,00CH,00CH,0CCH,078H,000H
		DB	038H,060H,0C0H,0F8H,0CCH,0CCH,078H,000H
		DB	0FCH,0CCH,00CH,018H,030H,030H,030H,000H
		DB	078H,0CCH,0CCH,078H,0CCH,0CCH,078H,000H
		DB	078H,0CCH,0CCH,07CH,00CH,018H,070H,000H	; 9
		DB	000H,030H,030H,000H,000H,030H,030H,000H	; :
		DB	000H,030H,030H,000H,000H,030H,030H,060H	; SEMI
		DB	018H,030H,060H,0C0H,060H,030H,018H,000H	; <
		DB	000H,000H,0FCH,000H,000H,0FCH,000H,000H	; =
		DB	060H,030H,018H,00CH,018H,030H,060H,000H	; >
		DB	078H,0CCH,00CH,018H,030H,000H,030H,000H	; ?
		DB	07CH,0C6H,0DEH,0DEH,0DEH,0C0H,078H,000H	; @
		DB	030H,078H,0CCH,0CCH,0FCH,0CCH,0CCH,000H	; A
		DB	0FCH,066H,066H,07CH,066H,066H,0FCH,000H	; B
		DB	03CH,066H,0C0H,0C0H,0C0H,066H,03CH,000H	; C
		DB	0F8H,06CH,066H,066H,066H,06CH,0F8H,000H	; D
		DB	07EH,060H,060H,078H,060H,060H,07EH,000H	; E
		DB	07EH,060H,060H,078H,060H,060H,060H,000H	; F
		DB	03CH,066H,0C0H,0C0H,0CEH,066H,03EH,000H	; G
		DB	0CCH,0CCH,0CCH,0FCH,0CCH,0CCH,0CCH,000H	; H
		DB	078H,030H,030H,030H,030H,030H,078H,000H	; I
		DB	01EH,00CH,00CH,00CH,0CCH,0CCH,078H,000H	; J
		DB	0E6H,066H,06CH,078H,06CH,066H,0E6H,000H	; K
		DB	060H,060H,060H,060H,060H,060H,07EH,000H	; L
		DB	0C6H,0EEH,0FEH,0FEH,0D6H,0C6H,0C6H,000H	; M
		DB	0C6H,0E6H,0F6H,0DEH,0CEH,0C6H,0C6H,000H	; N
		DB	038H,06CH,0C6H,0C6H,0C6H,06CH,038H,000H	; O
		DB	0FCH,066H,066H,07CH,060H,060H,0F0H,000H	; P
		DB	078H,0CCH,0CCH,0CCH,0DCH,078H,01CH,000H	; Q
		DB	0FCH,066H,066H,07CH,06CH,066H,0E6H,000H	; R
		DB	078H,0CCH,0E0H,070H,01CH,0CCH,078H,000H	; S
		DB	0FCH,030H,030H,030H,030H,030H,030H,000H	; T
		DB	0CCH,0CCH,0CCH,0CCH,0CCH,0CCH,0FCH,000H	; U
		DB	0CCH,0CCH,0CCH,0CCH,0CCH,078H,030H,000H	; V
		DB	0C6H,0C6H,0C6H,0D6H,0FEH,0EEH,0C6H,000H	; W
		DB	0C6H,0C6H,06CH,038H,038H,06CH,0C6H,000H	; X
		DB	0CCH,0CCH,0CCH,078H,030H,030H,078H,000H	; Y
		DB	0FEH,006H,00CH,018H,030H,060H,0FEH,000H	; Z
		DB	078H,060H,060H,060H,060H,060H,078H,000H
		DB	0C0H,060H,030H,018H,00CH,006H,002H,000H
		DB	078H,018H,018H,018H,018H,018H,078H,000H
		DB	010H,038H,06CH,0C6H,000H,000H,000H,000H
		DB	000H,000H,000H,000H,000H,000H,000H,0FFH
		DB	030H,030H,018H,000H,000H,000H,000H,000H
		DB	000H,000H,078H,00CH,07CH,0CCH,076H,000H
		DB	0E0H,060H,060H,07CH,066H,066H,0DCH,000H
		DB	000H,000H,078H,0CCH,0C0H,0CCH,078H,000H
		DB	01CH,00CH,00CH,07CH,0CCH,0CCH,076H,000H
		DB	000H,000H,078H,0CCH,0FCH,0C0H,078H,000H
		DB	038H,06CH,060H,0F0H,060H,060H,0F0H,000H
		DB	000H,000H,076H,0CCH,0CCH,07CH,00CH,0F8H
		DB	0E0H,060H,06CH,076H,066H,066H,0E6H,000H
		DB	030H,000H,070H,030H,030H,030H,078H,000H
		DB	00CH,000H,00CH,00CH,00CH,0CCH,0CCH,078H
		DB	0E0H,060H,066H,06CH,078H,06CH,0E6H,000H
		DB	070H,030H,030H,030H,030H,030H,078H,000H
		DB	000H,000H,0CCH,0FEH,0FEH,0D6H,0C6H,000H
		DB	000H,000H,0F8H,0CCH,0CCH,0CCH,0CCH,000H
		DB	000H,000H,078H,0CCH,0CCH,0CCH,078H,000H
		DB	000H,000H,0DCH,066H,066H,07CH,060H,0F0H
		DB	000H,000H,076H,0CCH,0CCH,07CH,00CH,01EH
		DB	000H,000H,0DCH,076H,066H,060H,0F0H,000H
		DB	000H,000H,07CH,0C0H,078H,00CH,0F8H,000H
		DB	010H,030H,07CH,030H,030H,034H,018H,000H
		DB	000H,000H,0CCH,0CCH,0CCH,0CCH,076H,000H
		DB	000H,000H,0CCH,0CCH,0CCH,078H,030H,000H
		DB	000H,000H,0C6H,0D6H,0FEH,0FEH,06CH,000H
		DB	000H,000H,0C6H,06CH,038H,06CH,0C6H,000H
		DB	000H,000H,0CCH,0CCH,0CCH,07CH,00CH,0F8H
		DB	000H,000H,0FCH,098H,030H,064H,0FCH,000H
		DB	01CH,030H,030H,0E0H,030H,030H,01CH,000H
		DB	018H,018H,018H,000H,018H,018H,018H,000H
		DB	0E0H,030H,030H,01CH,030H,030H,0E0H,000H
		DB	076H,0DCH,000H,000H,000H,000H,000H,000H
		DB	000H,010H,038H,06CH,0C6H,0C6H,0FEH,000H


		CK_ORG	0FE6EH
TIMDAY_VECT:	JMP	TIME_DAY_START

;R06 start
		CK_ORG	0FE73H
		Public	PM_CONFIG_BYTE
		extrn	PM_Auto_Table:near
		extrn	PM_EndAuto_Table:near
		extrn	PM_Auto_String:near
		db	0AAh				;0AAh mean this BIOS
							;has PM function
		dw	offset DGROUP:PM_Auto_Table
		dw	offset DGROUP:PM_EndAuto_Table
		dw	offset DGROUP:PM_Auto_String

PM_CONFIG_BYTE	LABEL	BYTE
		db	00000000b			;bit 0   : 1 = PM enable
							;    1   : 1 = Allow Setup from DOS
							;    2   : 1 = APM support
							;    43  : 00 = Reserved
							;	   01 = PMI using IRQ15
							;	   10 = PMI using NMI
							;	   11 = PMI using SMI
							;    5-7 : Reserved
;R06 end

;R08 - Starts
ifdef	PCI_BUS
		CK_ORG	0FE90H
;R22		db	0AAh
;R22		Public	PCI_SLOT_CFG
;R22PCI_SLOT_CFG	LABEL	WORD
;R22		dw	6543h		;bit 15-12: PCI Slot 4 Address
;R22					;     11-8: PCI Slot 3 Address
;R22					;      7-4: PCI Slot 2 Address
;R22					;      3-0: PCI Slot 1 Address
;R22		dw	0000h		;bit 15-12: PCI Slot 8 Address
;R22					;     11-8: PCI Slot 7 Address
;R22					;      7-4: PCI Slot 6 Address
;R22					;      3-0: PCI Slot 5 Address
		db	0bbh				;R22
		extrn	Pci_Slot_Cfg:near		;R22
		dw	offset DGROUP:Pci_Slot_Cfg	;R22
;R09 - start
		CK_ORG	0FE95H
		db	0AAh   		; PCI 2.0G existed
		extrn	Pci_Bios32_Signature:near
		dw	offset DGROUP:Pci_Bios32_Signature
;R09 - end
;R140 - start
		CK_ORG	0FE98H
		db	0AAh   				;flag
		extrn	IrqRout_Table:near
		dw	offset DGROUP:IrqRout_Table	;Routing information
;R140 - end

endif	;PCI_BUS
;R08 - Ends

		CK_ORG	0FEA5H
TIMER_VECT:	JMP	NEAR PTR T_S

		CK_ORG	0FEA8H
;R01 - start
		public	POWER_ON_DELAY
		public	COLOR_SETTING
		public	POST_COLOR
POWER_ON_DELAY	dw	1000h		;loop to delay while power on
COLOR_SETTING	db	0		;bit 3-0 - Setup default color
					;    7-4 - Post default color
POST_COLOR	db	0		;bit 0 = 0 : use Post default color
					;    0 = 1 : use color by setup setting
;R01 - end

;R41 - start
;R51		ALIGN	8
;R51FLASH_ROUTINE_HEAD	db	'AWDFLASH'
;R51		extrn	KBC_12V_Control:near
;R51		extrn	Ct_ROM_Write_Enable:near
;R51		extrn	Ct_ROM_Write_Disable:near
;R51		extrn	Ct_Enable_ROM_Decode:near
;R51		extrn	Ct_Init:near
;R51		extrn	CT_Disable_ROM_Shadow:near
;R51		extrn	CT_Enable_ROM_Shadow:near
;R51		extrn	Ct_Special_REG_Save:near
;R51		extrn	Ct_After_Program:near
;R51		DW	Offset	DGROUP:KBC_12V_Control
;R51		DW	Offset	DGROUP:Ct_ROM_Write_Enable
;R51		DW	Offset	DGROUP:Ct_ROM_Write_Disable
;R51		DW	Offset	DGROUP:Ct_Enable_ROM_Decode
;R51		DW	Offset	DGROUP:Ct_Init
;R51		DW	Offset	DGROUP:CT_Disable_ROM_Shadow
;R51		DW	Offset	DGROUP:CT_Enable_ROM_Shadow
;R51		DW	Offset	DGROUP:Ct_Special_REG_Save
;R51		DW	Offset	DGROUP:Ct_After_Program
;R51;R41 - end

;R50 - start
ifndef	NO_PS2_MOUSE_SUPPORT				;R130
Check_DataPack	proc	near
;Give up whole package if all 3 bytes can not received
ifdef	USB_MOUSE_SUPPORT			;R125
                mov     cx,20*33		;R125
else	;USB_MOUSE_SUPPORT			;R125
                mov     cx,5*33
endif	;USB_MOUSE_SUPPORT			;R125A
;R125A else	;USB_MOUSE_SUPPORT		;R125
delay_lp:
                in      al,STAT8042
                iodelay
                sti
                and     al,21h
                cmp     al,21h
                je      short irq12exit

                push    cx
                push    bx
                mov     cx,1
		xor	bx,bx
                call    wait_refresh
                pop     bx
                pop     cx
                loop    short delay_lp

                ;Time out
                and     ds:PDFLG_1, 11111000b         ;rest count index
                mov     ax,ds
                mov     es,ax
                cld
                lea     di,ds:auxdata
                xor     ax,ax
                stosw
                stosw
                stosw
                stosw

irq12exit:
		ret
Check_DataPack	endp
endif;	NO_PS2_MOUSE_SUPPORT				;R130
;R50 - end

		CK_ORG	0FEE1H			;R92
		db	0Fh, 0AAh		;R92
		CK_ORG	0FEE3H
INT_TBL:
;R116		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; DIVIDE BY ZERO
;R116		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT01
		DW	OFFSET DGROUP:SPURIOUS_soft_HDLR	;R116
		DW	OFFSET DGROUP:SPURIOUS_soft_HDLR	;R116
		DW	OFFSET DGROUP:NMI_VECT		; INT02
;R116		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; SINGLE STEP
;R116		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT04
	DW	OFFSET DGROUP:SPURIOUS_soft_HDLR	;R116
	DW	OFFSET DGROUP:SPURIOUS_soft_HDLR	;R116
		DW	OFFSET DGROUP:PRNTSCR_VECT	; PRINT SCREEN
;R83Aifdef	No_Support_HiScan				;R83
		extrn	INT06_VECT:near			;R83
		DW	OFFSET DGROUP:INT06_VECT	;R83
;R83Aelse	;No_Support_HiScan				;R83
;R83A		DW	OFFSET DGROUP:LOADALL		; INVALID OP-CODE
;R83Aendif	;No_Support_HiScan				;R83
;R116		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT07
		DW	OFFSET DGROUP:SPURIOUS_soft_HDLR	;R116

; 0 BYTES REMAINING

		CK_ORG	0FEF3H
VECTOR_TABLE:	DW	OFFSET DGROUP:TIMER_VECT	; INT08
		DW	OFFSET DGROUP:KBDINT_VECT	; INT09
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT0A
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT0B
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT0C
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT0D
		DW	OFFSET DGROUP:DSKINT_VECT	; INT0E


IF BUS_TYPE EQ EISA_BUS
  IFDEF	DEFAULT_IRQ7
		DW	OFFSET DGROUP:CLEAN_UP_IRQ
  ELSE
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR
  ENDIF	;DEFAULT_IRQ7

ELSE
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT0F
ENDIF



INT_TBL_HALF:	DW	OFFSET DGROUP:VIDEO_VECT	; INT10
		DW	OFFSET DGROUP:EQ_VECT		; INT11
		DW	OFFSET DGROUP:MEM_SZ_VECT	; INT12
		DW	OFFSET DGROUP:DSK_VECT		; INT13
		DW	OFFSET DGROUP:COMM_VECT		; INT14
		DW	OFFSET DGROUP:CASS_VECT		; INT15
		DW	OFFSET DGROUP:KBD_VECT		; INT16
		DW	OFFSET DGROUP:PRN_VECT		; INT17
		DW	OFFSET DGROUP:INT18_HDLR	; INT18
		DW	OFFSET DGROUP:INT19_VECT	; INT19
		DW	OFFSET DGROUP:TIMDAY_VECT	; INT1A
		DW	OFFSET DGROUP:IRET_VECT		; INT1B
		DW	OFFSET DGROUP:IRET_VECT		; INT1C
		DW	OFFSET DGROUP:VIDEO_PARMS	; INT1D
		DW	OFFSET DGROUP:FDC_PARS		; INT1E
		DW	0				; INT1F

SEC_HRDWR_INTS:	DW	OFFSET DGROUP:PIE_AIE_HDLR	; INT70
		DW	OFFSET DGROUP:INT71_REDIRECT	; INT71
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT72
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT73
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT74
		DW	OFFSET DGROUP:INT75_REDIRECT	; INT75
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT76
		DW	OFFSET DGROUP:SPURIOUS_INT_HDLR	; INT77	;R06

		public	P6HostClock					;R131
P6HostClock	db	0			;P6 host frequency	;R131

;MODBIN SERIAL NUMBER INFORMATION:
;
;	Contains manufacturer number and serial number generated
;	by MODBIN.
;
;R71		CK_ORG	0FF3EH			;V4.5G
;R71		PUBLIC	LOGO_OFFSET
;R71LOGO_OFFSET	DW	0FFFFH			;V4.5G
;R71		PUBLIC	LOGO_SEGMENT
;R71LOGO_SEGMENT	DW	0FFFFH			;V4.5G

						;
		CK_ORG	0FF43H			;
		PUBLIC	SER_NUM_MANU		; 304 (atbase)
SER_NUM_MANU	DW	0FFFFH			; 2 byte manufacturer number    ;
						; 			       ;
SER_NUM_ROM_LO	DW	0			; 4 byte rom serial number.     ;
SER_NUM_ROM_HI	DW	0			;
SER_NUM_MODBIN	DB	10 DUP(30H)		; MODBIN -A OPTION
						;
		CK_ORG	0FF53H
IRET_VECT	PROC	NEAR
		IRET
IRET_VECT	ENDP

;
;	INT 5   -   PRINT SCREEN SERVICE
;
		CK_ORG	0FF54H
PRNTSCR_VECT:
;		JMP	PRNT_SCRN
;[]======================================================================[]
;
;	INT 5 -- Print Screen
;
;	ENTRY
;		none
;	EXIT
;		AH = status
;	SAVES
;		all but AH
;
;[]======================================================================[]

		PUBLIC	Prnt_Scrn
Prnt_Scrn	proc	far
Prnt_Scrn_Near	proc	near
						;don't STI until we check flag.
		pusha				;save all general registers
		push	ds

		mov	ax,G_RAM
		push	ax
		pop	ds			;DS points to data area
		assume	ds:G_RAM		;

		mov	al,1			;block further int 5's
		xchg	al,STAT_BYTE		;and read to see if printing already
		cmp	al,1			;if in use, exit.
		je	short PS_Exit

		sti				;now we can allow interrupts.

		mov	bl,0ffh			;assume bad status.
		mov	ah,2			;get printer status.
		xor	dx,dx			;from printer 0.
		int	17h			;

		and	ah,0A0h			;test bits 7 and 5
		jns	short PS_UPDATE_STATUS	;if bit 7 =0, it is busy.
		jpe	short PS_UPDATE_STATUS	;if bit 5 =1, it is out of paper.

		mov	ah,0fh			;get video mode
		int	10h			;ah=# of col on screen
		mov	bl,ah			;bl=columns until done
						;bh=page until done

		mov	ah,03h			;read cursor
		int	10h			;dx=cursor location
		mov	di,dx			;save original position

		xor	cx,cx			;cx=printer zero
		xor	dh,dh			;init row #
PS_Next_Line:
		mov	al,CR			;start screen with cr/lf and
		call	PS_Print		;and end each line with cr/lf.
		mov	al,LF
		call	PS_Print

		cmp	dh,[CON_ROWS]		;last line printed?
		jbe	short PS_Print_Line
		xor	bl,bl			;flag successful print.
		jmp	short PS_Restore_Cursor

PS_Print_Line:
		xor	dl,dl			;start at column 0.
PS_Next_Char:
		cmp	dl,bl			;end of line?
		jb	short PS_get_char
		inc	dh
		jmp	short PS_Next_Line
PS_get_char:
		mov	ah,2			;set cursor position
		int	10h
		mov	ah,8			;read char and attribute
		int	10h
		or	al,al			;a zero ?
		jnz	short PS_PRN_Char	;
		mov	al,' '			;yes, change it to space
PS_PRN_Char:
		call	PS_Print
		inc	dl			;point to next column
		jmp	short PS_Next_Char


;!!! SPECIAL SUBROUTINE:  Does not return to caller if error.
PS_Print:
		xor	ah,ah			;print function.
		xchg	cx,dx			;dx=0, cx saves current cursor.
		int	17h
		xchg	cx,dx			;dx=cursor, cx=0
		test	ah,29h			;test out of paper,I/O error
		jnz	short PS_Printing_Err	;  and time-out
		ret

PS_Printing_Err:
		pop	dx			;disgard RETURN address
		mov	bl,0ffh			;error code.

PS_Restore_Cursor:
		mov	dx,di		;restore original cursor position
		mov	ah,2
		int	10h

PS_Update_Status:
		cli			;don't allow next int 5 until we iret
		mov	STAT_BYTE,bl	;result code.

PS_Exit:
		pop	ds
		popa
		iret

PRNT_SCRN_NEAR	ENDP

PRNT_SCRN	ENDP

		ASSUME	DS:DGROUP
		PUBLIC	BUS_ID_STR
		CK_ORG	0FFD9H
BUS_ID_STR:
IF BUS_TYPE EQ EISA_BUS
		DB	'EISA'
ELSEIF BUS_TYPE EQ ISA_BUS
ifdef	PCI_BUS
		db	'PCI/ISA'
;R25 start
elseifdef VESA_BUS
		DB	'VESA'
;R25 end
else;	PCI_BUS
	ifdef	Show_VESA_For_ISA		;R37
		db	'VESA'			;R37
	else	;Show_VESA_For_ISA		;R37
		db	'ISA '
	endif	;Show_VESA_For_ISA		;R37
endif;	PCI_BUS
ENDIF ;BUS_TYPE


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;BYTES 0FFE0h - 0FFEFh may be changed by MODBIN.EXE.  Do not change
;		or move these bytes.
;
;Explanation of the bytes FFE0 - FFEF:
;
;  There are two base 'TYPES' of data defined by the code below:
;     TYPE 1 -> is a  'DATA' TYPE.
;	 Many of the DATA TYPE values can be modified via MODBIN to alter their
;	 meaning; Also, the values in a DATA TYPE are by the used bios (see
;	 examples below).
;
;     TYPE 2 -> is an 'INFO' TYPE.
;	 The values of an INFO TYPE are set at MAKE time and are NOT changed
;	 by anybody; But, MODBIN looks at the values in an INFO TYPE for the
;	 'INSTALLED OPTIONS' menu.  The bits in an INFO TYPE are set up
;	 according to what kind of options are installed by the compile
;	 options for code that is included or totally excluded from the bios
;	 (see examples below).
;
;     NOTE: Sometimes there will be data defined for a particular option in
;	 both a DATA TYPE and an INFO TYPE.  The main reason is the bios has
;	 three posibilities for many options (see examples below):
;	    1) The code is INSTALLED and ENABLED; or,
;	    2) The code is INSTALLED and DISABLED; or,
;	    3) The code is NOT INSTALLED.
;
; example 1:
;     Let's assume that the option 'GOLDBIOS' has been enabled at compile
;     time.  This is only an INFO TYPE flag which results in bit 0 of the
;     SYSTEM_BYTE2 byte to be set to a 1 indicating that we have created an
;     Award GOLDBIOS.  Modbin will see this in its Installed Options Menu
;     and say that GOLDBIOS is Installed; However, there is no place in modbin
;     that a user can change this setting.
;
; example 2:
;     The word value WAIT_TABLE_PTR is a DATA TYPE.  The bios uses this in
;     various places in order to find out where the Wait Table is stored.
;     This particular DATA TYPE is not changeable with modbin (nor is it
;     viewable).
;
; example 3:
;     The values in the SETTINGS byte are all DATA TYPEs.  Bit 0 is used to
;     indicate whether to have the num-lock on a 101 style keyboard on or
;     off.  This is defaulted at compile time to off (a 1).  A user of modbin
;     can, however, change this so that that particular bios will have the
;     num-lock be on.
;
; example 4: (this one's kind of tricky!)
;     First some information obout the purpose of NSS and NFS. The switch NSS
;     stands for No Speed Switching; It causes all of the code that deals with
;     speed switching to be excluded from the bios.  The switch NFS stands for
;     No Floppy Speed-switching; It causes all of the code that deals with
;     floppy speed-switching to be excluded from the bios.
;
;     Bit 3 of SETTINGS is a DATA TYPE.  When NSS is not set (ie: speed
;     switching code is included in the bios) then a zero is put in this
;     bit. MODBIN can alter the setting of this bit if the code is included.
;     The speed switching module will do a test and if the bit is set then
;     speed switching will be skipped.	Bit 2 of SYSTEM1_BYTE is an INFO TYPE.
;     When NSS is not set then it will have a 0 and MODBIN will display
;     Speed Switching Installed in the Installed Options Menu.
;
;     These two bits are used together to define what the availability of
;     speed switching is:
;
;     The INFO TYPE is the main switch; If it is a 1 (ie: NSS is set) then the
;     speed switching code is not installed in the BIOS; therefore speed
;     switching is not possible and the DATA TYPE is ignored.
;     If the INFO TYPE is a 0 then speed switching is installed in the BIOS;
;     The DATA TYPE is then checked by the speed switching code to see if
;     speed switching has been disabled/enabled (via MODBIN).
;
;     MODBIN first checks the INFO TYPE.  If not set (ie: NSS not set) then
;     the user is allowed to turn speed switching on or off (in the Change
;     BIOS Options Menu).
;
;[]==============================================================[]

		CK_ORG	0FFE0H

; all bits in CUSTOMIZATION_BYTE are DATA TYPEs
CUSTOMIZATION_BYTE:
;0ffe0						; bit
ERR_HLT		DB	00H			; 0 = 1= no halt on any error.
						; 	if bit 0 = 0 then
						; 1 = 1= no halt on keyboard error.
						; 2 = 1= no halt on disk error.
						; 3-7 = reserved

;[]==============================================================[]
;
;	SPD_DEF: Default BIOS speed switching options
;
; 	All bits in SPD_DEF are DATA TYPEs
;	0ffe1h:
; 	0     = polarity of speed switch
;		0 = low speed is active low
;		1 = low speed is active high
; 	1-3   = Reserved
;	5-4   = Default definitions of slow
;		00 = Very slow
;		01 = Slow
;		10 = Fast
;		11 = Very Fast
;	6     = Default speed at boot
;		0 = low speed
;		1 = high speed
;  	7     = beep speaker on speed change
;		1 = don't beep speaker
;		0 = beep speaker
;[]==============================================================[]


		PUBLIC	SPD_DEF
SPD_DEF		DB	01100000B		; default to high speed, low = fast, etc.

;[]==============================================================[]
;
;	SETTINGS: General BIOS configuration options.
;	(For equates, see ATORGS.EQU)
;
; 	All bits in SETTINGS are DATA TYPEs, with defintions of:
;	0ffe2h:
; 	  0 = num lock on 101 keyboard
;		1 = 101 key Num lock off on power up.
;		0 = 101 key Num lock on on power up.
; 	  1 = Disallow fast HDU seek operations
;		1 = disallow fast seeks.
;		0 = allow fast seeks
; 	  2 = Disallow speed switching in cmos
;		1 = disallow speed switch setting
;		0 = allow speed switch setting
;	3-5 = Reserved
; 	6-7 = Waiting method
;		00 = short refresh clock method
;		01 = long refresh clock method
;		10 = dummy loop method
;
;[]==============================================================[]

SETTINGS	DB	01H + 02H

; WAIT_TABLE_PTR IS A DATA TYPE
WAIT_TABLE_PTR	DW	OFFSET DGROUP:WAIT_TBL

; Begin version number update
;[]==============================================================[]
;
; 	ROM_VERSION: Contains major and minor version numbers
;
;
;	All bits in ROM_VERSION are INFO_TYPEs
;	0ffe5h:
;	bits 7-4 = Major version number
;	bits 3-0 = Minor version number
;
;[]==============================================================[]

ROM_VERSION	DB	45H
; End version number update

;0ffe6h:
		PUBLIC	SP_STATE	; SP_STATE IS A DATA TYPE
SP_STATE	DB	084H		; Default output are Pin 23 & 30

OPTION_BYTEVAL	EQU      01H		; DEFAULT IS INSTALLED/DISABLED
;0ffe7h:
		PUBLIC	OPTION_BYTE
OPTION_BYTE	DB	OPTION_BYTEVAL	; Green PC Clock output control	;R12
					; bit 2 - pin 23		;R12
					; bit 3 - pin 24		;R12
					; bit 4 - pin 27		;R12
					; bit 5 - pin 28		;R12
					; bit 6 - pin 29		;R12
					; bit 7 - pin 30		;R12

		public	SYSTEM_BYTE
		public	SYSTEM1_BYTE
		public	SYSTEM2_BYTE
		public	SYSTEM3_BYTE
		public	SYSTEM4_BYTE
		public	SYSTEM5_BYTE

; Begin INFO TYPE fixup
;[]==============================================================[]
; THE NEXT FIVE BYTES DESCRIBE ASSEMBLER OPTIONS
;
;	SYSTEM_BYTE: All bits in SYSTEM_BYTE are INFO TYPEs
;
;		bit 0 = CHIPSET_NEED_PRG 	Chipset support installed
;		bit 1 = NFS 			No floppy speed switching
;		bit 2 = NSS			No speed switching
;		bit 3 = K8242			Phoenix 8242 support
;		bit 4 = 0			;Turbo switch using pin 29 or 30
;		      = 1			;Turbo switch using pin 31	;R11
;		bit 5 = 0			;Turbo swtich low means turbo
;		      = 1			;Turbo swtich high means turbo
;		bit 6 = 0			;Turbo switch using pin 29
;		      = 1			;Turbo switch using pin 30
;		bit 7 = 1			;Turbo switch input enabled
;
;[]==============================================================[]

SYSTEM_BYTEVAL	=	00000000B		; No installed options
;0ffe8h:
SYSTEM_BYTE	DB	SYSTEM_BYTEVAL		; contains first 8 IFDEFs

;[]==============================================================[]
;
;	SYSTEM1_BYTE: All bits in SYSTEM1_BYTE are INFO TYPEs
;	;0ffe9h:
;	bit   0 = 1 : NOVELL workaround installed
;	bit   1 = 1 : No PCI devices info. display		;R75
;R108	bit   2 =	----			Reserved
;	bit   2 = 1 : PS2 mouse present		;R108
;	bit   3 = 	CACHE			Cache support enabled
;	bit 4-6 =	----			Reserved
;	bit   7 =	FSCAN			F000: option ROM support
;
;[]==============================================================[]


SYSTEM1_BYTEVAL	= 0				; NO OPTIONS
  SYSTEM1_BYTEVAL = SYSTEM1_BYTEVAL + 00000001B	; NOVELL workaround
SYSTEM1_BYTE	DB	SYSTEM1_BYTEVAL

;[]==============================================================[]
;
;	SYSTEM2_BYTE: All bits in SYSTEM2_BYTE are INFO TYPEs
;	;0ffeah:
;	bit   0 =	GOLDBIOS		GOLD Bios
;	bit   1 =	CALL_TABLE		CALL table at 0F000:0 enabled
;	bit 2-6 = 	----			Reserved
;	bit   7 =  NO_WAIT_86H	- Don't use PIE wait for FDD motor on
;				  and head settle time
;[]==============================================================[]

SYSTEM2_BYTEVAL = 0
  SYSTEM2_BYTEVAL = SYSTEM2_BYTEVAL + 10000000B	; skip 86h of INT 15H call
SYSTEM2_BYTE	DB	SYSTEM2_BYTEVAL

;[]==============================================================[]
;
;	SYSTEM3_BYTE: All bits in SYSTEM3_BYTE are INFO TYPEs
;	;0ffebh:
;	bit   0 =	CACHE_NEED_PRG		OEM cache control enabled (CT_CACHE)
;	bit   1 =	MEMORY_PRESENT_TEST	OEM memory-presence test (CT_MEMORY_PRESENCE)
;	bit   2 =	EARLY_MEMORY_INIT	OEM early chipset/memory/cache init. (CT_EARLY_INIT)
;	bit   3 =	EXT_MEMORY_INIT		OEM extended memory init. (CT_EXT_MEM_INIT)
;	bit   4 =	SPECIAL_DISP_SWITCH	OEM display switch handling (CT_DISP_SWITCH)
;	bit   5 = 	SPECIAL_A20		OEM fast gate A20 handling (CT_A20)
;	bit   6 = 	PRG_CACHEABILITY	OEM cache programming (CT_CACHE_BLOCK)
;	bit   7 =	VERY_EARLY_INIT		OEM early initialization (CT_VERY_EARLY_INIT)
;
;[]==============================================================[]

SYSTEM3_BYTEVAL = 00000000B			; no options installed
SYSTEM3_BYTE	DB	SYSTEM3_BYTEVAL

;[]==============================================================[]
;
;	SYSTEM4_BYTE: All bits in SYSTEM4_BYTE are INFO TYPEs
;	;0ffech:
;	bit   0 =	SPEED_NEED_PRG		; OEM speed switching (CT_SPEED)
;	bit   1 =	SPEED_CHANGE_CACHE	; OEM shadowing (CT_SHADOW)
;	bit   2 =	1 - disable parity check
;	bit   3 =	1 - skip keylock checking
;	bit   4 =	scan onboard E000H video ROM
;	bit   5 =	scan onboard C000H video ROM
;	bit   6 = 	1 - NOMANUFACTURE
;	bit   7 =	PS2 mouse support
;
;[]==============================================================[]

SYSTEM4_BYTEVAL = 00000000B			; no options installed
SYSTEM4_BYTE	DB	SYSTEM4_BYTEVAL

; End INFO TYPE fixup
;
;	RESERVED BYTES: All reserved bytes are INFO TYPEs
;
;R12 - start
;[]==============================================================[]
;
;	SYSTEM5_BYTE: All bits in SYSTEM5_BYTE are INFO TYPEs
;	This byte define keyboard controller type, the values are
;	;0ffedh:
;	00 - AWARD  v1.8 and above
;	01 - AMI K8 & KF
;	02 - PHOENIX K8242
;	03 - C&T v2.??
;	04 - IBM standard
;	05 - MrBIOS , AWARD KB-100,KB-200 ;R09		;R19
;[]==============================================================[]

;R07 SYSTEM5_BYTEVAL		equ	0
;R07 SYSTEM5_BYTE  DB	SYSTEM5_BYTEVAL
;R09 SYSTEM5_BYTE  DB	AMIKBC				;R07
SYSTEM5_BYTE	DB	MRKBC				;R09

; 0 BYTES REMAINING
		CK_ORG	0FFEEH
		PUBLIC	WORD_CHECKSUM
WORD_CHECKSUM:	DW	7369H			; NEAR LABEL for Linker

; 0 BYTES REMAINING
		CK_ORG	0FFF0H
		PUBLIC	COLDBOOT
COLDBOOT:
ifdef	SPECIAL_ON_CPU_RESET						;R31
		FAR_JMP	<OFFSET DGROUP:PCI_CPU_RESET>,0F000H		;R31
else;	SPECIAL_ON_CPU_RESET						;R31
		FAR_JMP	<OFFSET DGROUP:RST_VECT>,0F000H
endif;	SPECIAL_ON_CPU_RESET						;R31

		DB	'05/04/93'		; ARBITRARY DATE AFTER 7/15/85
		DB	0			; FILL
		DB	0FCH			; TYPE, NEXT BYTE IS CHECKSUM
						; linker strips these bytes
		public	CODE_END				;R19
CODE_END	db	?					;R19
@DATAC		ENDS

		END	RST_VECT
