⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpmmisc.inc

📁 AMI 主板的BIOS源码
💻 INC
📖 第 1 页 / 共 3 页
字号:
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
;                           PM_FIXED_DELAY                      ;
;---------------------------------------------------------------;
;	Input : (CX) count of 15 microseconds to wait		;
;		STACK PRESENT					;
;	Output: NONE						;
;	Register destroyed : (CX)				;
;								;
; This routine is called to wait for 15 microseconds * count in ;
; (CX), then return.  Gives a programmed software delay.        ;
;---------------------------------------------------------------;

pm_fixed_delay	proc	near

	push    ax				;

	in      al,refresh_port			;
	smi_io_delay				; i/o delay
	and     al,refresh_bit			;
	mov     ah,al				;
pm_fixed_delay_1:
	in      al,refresh_port			;
	smi_io_delay				; i/o delay
	and     al,refresh_bit			;
	cmp     al,ah				;
	jz     short pm_fixed_delay_1		;
	mov     ah,al				;
	loop    short pm_fixed_delay_1		;

	pop     ax				;
	ret

pm_fixed_delay	endp

;---------------------------------------------------------------;
;			SINGLE_SHT_BEEP				;
;---------------------------------------------------------------;
;	Input : (BX) no. of short beeps				;
;	Output: NONE						;
;	Register destroyed : (AX),(BX),(CX)			;
; NOTE : This routine assumes port 61h & 8254 timer controller	;
;        counter 2 count and command byte have been saved before;
;	 calling this routine					;
;---------------------------------------------------------------;

single_sht_beep	proc	near

	mov	al,10110110b			; initialise timer #2
	out	timer_cntlr_1_cmd_reg,al	;
	smi_io_delay				; i/o delay
	mov	al,05h				; (al) = frequency low byte
	out	timer_cntlr_1_count2_reg,al	;
	smi_io_delay				; i/o delay
	out	timer_cntlr_1_count2_reg,al	; frequency high byte
	smi_io_delay				; i/o delay

next_beep:
	in	al,speaker_port			; (al) = read current status
	smi_io_delay				; i/o delay
	push	ax				;
	or	al,00000011b			; speaker gate, speaker bit
	out	speaker_port,al			; start the beep
	smi_io_delay				; i/o delay
	mov	cx,1000h			; beep duration
	call	pm_fixed_delay			;
	pop	ax				;
	and	al,11111101b			; reset speaker bit
	out	speaker_port,al			; no beep
	smi_io_delay				; i/o delay
	mov	cx,2000h			; no beep duration
	call	pm_fixed_delay			;
	dec	bx				; any more beep ?
	jnz	short next_beep			;
	ret

single_sht_beep	endp

;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
;		       BCD_TO_BINARY				;
;---------------------------------------------------------------;
;	Input : (AL) BCD					;
;	Output: (AX) BINARY, (AH) = 00				;
;	Register destroyed : (AX)				;
;---------------------------------------------------------------;

bcd_to_binary	proc	near

	mov	ah,al				; (ah) = (al) = BCD
	shr	ah,4				; (ah) = upper nibble of BCD
	and	al,00001111b			; (al) = lower nibble of BCD
	aad					; (al) = (ah)*10+(al)
						; (ah) = 00
	ret

bcd_to_binary	endp

;---------------------------------------------------------------;
;		     HR_MIN_SEC_TO_SEC				;
;---------------------------------------------------------------;
;	Input : (CH) hours in BCD				;
;		(CL) minutes in BCD				;
;		(DH) seconds in BCD				;
;	Output: (EAX) seconds in BINARY				;
;	Register destroyed : (EAX),(EDX),(BX),(CX)		;
;---------------------------------------------------------------;

hr_min_sec_to_sec	proc	near

	xchg	dh,ch				; (dh) = hours, (ch) = seconds
	mov	al,dh				; (al) = hours in BCD
	call	bcd_to_binary			; (ax) = hours in BINARY
	mov	bx,60				; 60 mins/hour, 60 secs/min
	mul	bl				; (ax) = hours converted to minutes in BINARY
	mov	dx,ax				;
	mov	al,cl				; (al) = minutes in BCD
	call	bcd_to_binary			; (ax) = minutes in BINARY
	add	ax,dx				; (ax) = total minutes in BINARY
	mul	bx				; (dx):(ax) = minutes converted to secs in BINARY
	shl	edx,16				;
	mov	dx,ax				; (edx) = secs in BINARY
	mov	al,ch				; (al) = seconds in BCD
	call	bcd_to_binary			; (ax) = seconds in BINARY
	movzx	eax,ax				;
	add	eax,edx				; (eax) = converted seconds in BINARY
	ret

hr_min_sec_to_sec	endp

;---------------------------------------------------------------;
;			 SEC_TO_HR_MIN_SEC			;
;---------------------------------------------------------------;
;	Input : (EAX) seconds in BINARY				;
;	Output: (CH) hours in BCD				;
;		(CL) minutes in BCD				;
;		(DH) seconds in BCD				;
;	Register destroyed : (EAX),(BX),(CX),(DX)		;
;---------------------------------------------------------------;

sec_to_hr_min_sec	proc	near

	mov	dx,ax				;
	shr	eax,16				;
	xchg	ax,dx				;
	mov	bx,60				; 60 mins/hour, 60 secs/min
	div	bx				; (ax) = minutes in BINARY
						; (dx) = seconds in BINARY
	div	bl				; (al) = hours in BINARY
						; (ah) = minutes in BINARY
	call	binary_to_bcd			; (al) = hours in BCD
	mov	ch,al				; (ch) = hours in BCD
	mov	al,ah				; (al) = minutes in BINARY
	call	binary_to_bcd			; (al) = minutes in BCD
	mov	cl,al				; (cl) = minutes in BCD
	mov	al,dl				; (al) = seconds in BINARY
	call	binary_to_bcd			; (al) = seconds in BCD
	mov	dh,al				; (dh) = seconds in BCD
	ret

sec_to_hr_min_sec	endp

;---------------------------------------------------------------;
;		       DATE_TO_BINARY				;
;---------------------------------------------------------------;
;	Input : (CH) century in BCD				;
;		(CL) year in BCD				;
;		(DH) month in BCD				;
;		(DL) day in BCD					;
;	Output: (AH)++ century in BINARY			;
;		(AH)+  year in BINARY				;
;		(AH)   month in BINARY				;
;		(AL)   day in BINARY				;
;	Register destroyed : (EAX),(CX),(DX)			;
;---------------------------------------------------------------;

date_to_binary	proc	near

	mov	al,ch				; (al) = century in BCD
	call	bcd_to_binary			; (al) = century in BINARY
	xchg	al,cl				; (cl) = century in BINARY
						; (al) = year in BCD
	call	bcd_to_binary			; (al) = year in BINARY
	mov	ah,cl				; (ah) = century in BINARY
	shl	eax,16				; (ah)++ = century in BINARY
						; (ah)+ = year in BINARY
	mov	al,dh				; (al) = month in BCD
	call	bcd_to_binary			; (al) = month in BINARY
	xchg	al,dl				; (dl) = month in BINARY
						; (al) = day in BCD
	call	bcd_to_binary			; (al) = day in BINARY
	mov	ah,dl				; (ah) = month in BINARY
	ret

date_to_binary	endp

;---------------------------------------------------------------;
;		        BINARY_TO_BCD				;
;---------------------------------------------------------------;
;	Input : (AL) BINARY					;
;	Output: (AL) BCD					;
;	Register destroyed : (AL)				;
;---------------------------------------------------------------;

binary_to_bcd	proc	near

	push	cx				;
	mov	ch,ah				; save (ah) in (ch)	
	xor	ah,ah				; (ax) = BINARY
	mov	cl,10				;
	div	cl				; (al) = quotient, (ah) = remainder
	shl	al,4				;
	and	ah,00001111b			;
	or	al,ah				; (al) = BCD
	mov	ah,ch				; restore (ah)
	pop	cx				;
	ret

binary_to_bcd	endp

;---------------------------------------------------------------;
;		        GET_RTC_DATE				;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (DL) date					;
;		(DH) month					;
;		(CL) year					;
;		(CH) century					;
;	Register destroyed : (AX),(CX),(DX)			;
;---------------------------------------------------------------;

get_rtc_date	proc	near

	call	wait_for_update_complete	; wait for RTC update over

	mov	cl,cmos_century or 10000000b	; CMOS address for century with NMI off
	mov	dx,(cmos_year or 10000000b)*256+(cmos_month or 10000000b); CMOS address for year,mon with NMI off
	mov	al,cmos_date or 10000000b	; CMOS address for date with NMI off
	call	smi_cmos_data_in_x		;
	xchg	al,dl				; (DL) = date
	jmp	short get_rtc_date_10		;

get_rtc_date	endp

;---------------------------------------------------------------;
;		          GET_RTC_TIME				;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (DH) seconds					;
;		(CL) minutes					;
;		(CH) hour					;
;	Register destroyed : (AX),(CX),(DX)			;
;---------------------------------------------------------------;

get_rtc_time	proc	near

	call	wait_for_update_complete	; wait for RTC update over

	mov	cl,cmos_hours or 10000000b	; CMOS address for hours with NMI off
	mov	dh,cmos_minutes	or 10000000b	; CMOS address for min with NMI off
	mov	al,cmos_seconds	or 10000000b	; CMOS address for sec with NMI off

;-----------------------------------------------;

get_rtc_date_10::
	call	smi_cmos_data_in_x		;
	xchg	al,dh				; (DH) = seconds/month
	call	smi_cmos_data_in_x		;
	xchg	al,cl				; (CL) = minutes/year
	call	smi_cmos_data_in		;
	xchg	al,ch				; (CH) = hours/century
	ret

get_rtc_time	endp

;---------------------------------------------------------------;
;			   READ_RTC_ALARM			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (CF) (CY) error...CMOS inoperational		;
;		(CF) (NC) no error &				;
;		     (ZF) (ZR) alarm disabled			;
;		     (ZF) (NZ) alarm enabled &			;
;				(CH) alarm hour in BCD		;
;				(CL) alarm minutes in BCD	;
;				(DH) alarm seconds in BCD	;
;	Register destroyed : (AX),(CX),(DX)			;
;---------------------------------------------------------------;

read_rtc_alarm	proc	near

	call	wait_for_update_complete	; update complete ?
	jnz	short read_rtc_alarm_01		; no...

	mov	al,cmos_alarm_hour or 10000000b	; NMI off
	mov	cx,(cmos_alarm_minute or 10000000b)*256+(cmos_alarm_second or 10000000b); NMI off

	call	smi_cmos_data_in_x		; (al) = read the data
	xchg	al,ch				; (ch) = first data
						; (al) = next CMOS index to read
	call	smi_cmos_data_in_x		; (al) = read the data
	xchg	al,cl				; (cl) = second data
						; (al) = next CMOS index to read
	call	smi_cmos_data_in_x		; (al) = read the data
	xchg	al,dh				; (dh) = third data

	call	cmos_stat_reg_b_read		; (al) = read status reg 0Bh data
	test	al,alarm_intr_bit		; alarm interrupt enabled ?
						; (cy) = 00 for no error
	ret

;-----------------------------------------------;

read_rtc_alarm_01:
	stc					; set (cy) = 01 for error
	ret

read_rtc_alarm	endp

;---------------------------------------------------------------;
;		   WAIT_FOR_UPDATE_COMPLETE			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (ZF) set means update complete			;
;		(ZF) NZ means update in progress		;
;	Register destroyed : NONE				;
;---------------------------------------------------------------;

wait_for_update_complete	proc	near

	push	cx				;
	push	ax				;
	mov	cx,upd_check_loop_time		; update in progress check loop count
update_complete_01:
	mov	al,cmos_stat_reg_a or 10000000b	; NMI off
	call	smi_cmos_data_in_x		; (al) = read the data
	test	al,update_in_progress_bit	; update in progress ?
	loopnz	update_complete_01		; yes...
	pop	ax				;
	pop	cx				;
	ret

wait_for_update_complete	endp

;---------------------------------------------------------------;
;			CMOS_STAT_REG_B_READ			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (AL) data read					;
;	Register destroyed : (AL)				;
;---------------------------------------------------------------;

cmos_stat_reg_b_read	proc	near

	mov	al,cmos_stat_reg_b or 10000000b	; NMI off
	jmp	short cmos_stat_reg_read	; (al) = read the data

cmos_stat_reg_b_read	endp

;---------------------------------------------------------------;
;			CMOS_STAT_REG_C_READ			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (AL) data read					;
;	Register destroyed : (AL)				;
;---------------------------------------------------------------;

cmos_stat_reg_c_read	proc	near

	mov	al,cmos_stat_reg_c or 10000000b	; NMI off

;---------------------------------------------------------------;
;			CMOS_STAT_REG_READ			;
;---------------------------------------------------------------;
;	Input : (AL) CMOS status register to read		;
;	Output: (AL) data read					;
;	Register destroyed : (AL)				;
;---------------------------------------------------------------;

cmos_stat_reg_read	proc	near

	call	smi_cmos_data_in		; (al) = read the data
	ret

cmos_stat_reg_read	endp
cmos_stat_reg_c_read	endp

;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -