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

📄 gpmlib.inc

📁 AMI 主板的BIOS源码
💻 INC
📖 第 1 页 / 共 5 页
字号:
days_in_suspend_43:
	movzx	si,byte ptr cgroup:[di+bx]	; (si) = # of days for this month
	add	ax,si				;
	inc	bx				;
	dec	dh				;
	jnz	short days_in_suspend_43	;
days_in_suspend_42:
	pop	dx				;

	mov	di,(offset cgroup:month_table - offset cgroup:smi_code_begin + orgbase)
	test	cl,00000011b			; current year leap year ?
	jnz	short days_in_suspend_44	; no...
	mov	di,(offset cgroup:month_table_leap_year - offset cgroup:smi_code_begin + orgbase)
days_in_suspend_44:
	dec	dh				; (dh) = # of full months in current year in suspend
	jz	short days_in_suspend_45	; no full month in current year in suspend
	xor	bx,bx				; start with month 1
days_in_suspend_46:
	movzx	si,byte ptr cgroup:[di+bx]	; (si) = # of days for this month
	add	ax,si				;
	inc	bx				;
	dec	dh				;
	jnz	short days_in_suspend_46	;
days_in_suspend_45:
	add	ax,dx				; (ax) = total days in suspend
	jmp	short days_in_suspend_16	;

days_in_suspend	endp

;---------------------------------------------------------------;
;			MONTH_TABLE				;
;---------------------------------------------------------------;

month_table	label	byte

	db	31				; JANUARY
	db	28				; FEBRUARY
	db	31				; MARCH
	db	30				; APRIL
	db	31				; MAY
	db	30				; JUNE
	db	31				; JULY
	db	31				; AUGUST
	db	30				; SEPTEMBER
	db	31				; OCTOBER
	db	30				; NOVEMBER
	db	31				; DECEMBER

;---------------------------------------------------------------;
;		      MONTH_TABLE_LEAP_YEAR			;
;---------------------------------------------------------------;

month_table_leap_year	label	byte

	db	31				; JANUARY
	db	29				; FEBRUARY
	db	31				; MARCH
	db	30				; APRIL
	db	31				; MAY
	db	30				; JUNE
	db	31				; JULY
	db	31				; AUGUST
	db	30				; SEPTEMBER
	db	31				; OCTOBER
	db	30				; NOVEMBER
	db	31				; DECEMBER

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

dos_date_time_restore_ends	label	byte

ENDIF

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

IF	KB_CNTLR_HANDLING_SUPPORT

;---------------------------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;---------------------------------------------------------------;
;			SAVE_LOCK_KB_CNTLR			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (CY) 01 error input buf full/output buf empty	;
;		(CY) 00 no error				;
;	Register destroyed : (AX),(CX),(SI)			;
; NOTE : Call this routine before issuing any command to the	;
;	 keyboard controller which has at least one  response 	;
;	 byte from keyboard controller. If you call this routine,
;	 you must call 'RES_KB_CNTLR' routine after you are done;
;	 with keyboard controller usage.			;
;---------------------------------------------------------------;

save_lock_kb_cntlr	proc	near

	mov	si,kb_cntlr_data		; (si) = keyboard controller data save area

;---------------------------------------------------------------;
;		    SAVE_LOCK_KB_CNTLR_EXT			;
;---------------------------------------------------------------;
;	Input : (SI) keyboard controller data save area		;
;	Output: (CY) 01 error input buf full/output buf empty	;
;		(CY) 00 no error				;
;	Register destroyed : (AX),(CX)				;
;---------------------------------------------------------------;

save_lock_kb_cntlr_ext	proc	near

	mov	al,wrt_kb_cntlr_cmd_byte_cmd	; write command byte (60H)
	call	write_kb_cntlr_cmd		; should lock the keyboard controller
	jnz	short lock_kb_cntlr_01		; no...input buffer full
	in	al,kb_stat_port			; (al) = read keyboard controller status
	mov	ah,al				;
	test	al,kb_output_buf_full		; keyboard controller output buffer full ?
	jz	short lock_kb_cntlr_02		; no...
	in	al,kb_data_port			; (al) = read the data
lock_kb_cntlr_02:
	mov	[si+kb_cntlr_output_buf_data],ax; save keyboard controller output buffer data and status byte

	mov	al,read_kb_cntlr_cmd_byte_cmd	; read command byte (20H)
	call	read_kb_cntlr_data		; (al) = keyboard controller command byte
	jc	short lock_kb_cntlr_01		; error...input buffer full/output buffer empty
	mov	[si+kb_cntlr_cmd_byte],al	; save keyboard controller command byte

	mov	ah,al				; (ah) = (al) = command byte
	or	ah,disable_keyboard_bit or disable_aux_dev_bit; disable keyboard & auxiliary device data xfer

res_kb_cntlr_05::
	mov	al,wrt_kb_cntlr_cmd_byte_cmd	; write command byte (60H)
	call	write_kb_cntlr_data		; program the command byte
	jz	short lock_kb_cntlr_03		; no error...(cy) = 00

res_kb_cntlr_01::
lock_kb_cntlr_01:
	stc					; (cy) = 01 for error
lock_kb_cntlr_03:
	ret

save_lock_kb_cntlr_ext	endp
save_lock_kb_cntlr	endp

;---------------------------------------------------------------;
;			   RES_KB_CNTLR				;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (CY) 01 error input buf full/output buf empty	;
;		(CY) 00 no error				;
;	Register destroyed : (AX),(CX),(SI)			;
; NOTE : Call this routine after you are done with keyboard	;
;	 controller usage. You should not call this routine	;
;	 unless you have called 'SAVE_LOCK_KB_CNTLR' routine	;
;	 before.						; 
;---------------------------------------------------------------;

res_kb_cntlr	proc	near

	mov	si,kb_cntlr_data		; (si) = keyboard controller data save area

;---------------------------------------------------------------;
;			RES_KB_CNTLR_EXT			;
;---------------------------------------------------------------;
;	Input : (SI) keyboard controller data save area		;
;	Output: (CY) 01 error input buf full/output buf empty	;
;		(CY) 00 no error				;
;	Register destroyed : (AX),(CX)				;
;---------------------------------------------------------------;

res_kb_cntlr_ext	proc	near

	mov	ax,[si+kb_cntlr_output_buf_data]; (al) = output buffer data, (ah) = keyboard controller status byte
	xchg	al,ah				; (al) = keyboard controller status byte, (ah) = output buffer data
	test	al,kb_output_buf_full		; output buffer full ?
	jz	short res_kb_cntlr_04		; no...
	test	al,kb_aux_output_buf_full	; auxiliary output buffer full ?
	mov	al,wrt_kb_output_buf_cmd	; write to output buffer as if initiated by keyboard
	jz	short res_kb_cntlr_02		; no...
	mov	al,wrt_kb_aux_output_buf_cmd	; write to output buffer as if initiated by auxiliary device
res_kb_cntlr_02:
	call	write_kb_cntlr_data		;
	jnz	short res_kb_cntlr_01		; error...input buffer full
res_kb_cntlr_04:
	mov	ah,[si+kb_cntlr_cmd_byte]	; (ah) = keyboard controller command byte
	jmp	short res_kb_cntlr_05		;
	
res_kb_cntlr_ext	endp
res_kb_cntlr	endp

;---------------------------------------------------------------;
;			READ_KB_CNTLR_DATA			;
;---------------------------------------------------------------;
;	Input : (AL) kb cntlr command				;
;	Output: (CY) 01 error input buf full/output buf empty	;
;		(CY) 00 no error &				;
;			(AL) data received from kb cntlr	;
;	Register destroyed : (AL),(CX)				;
; NOTE : This routines sends the command in (AL) to keyboard	;
;	 controller, then it receives the response byte for the ;
;	 command from the keyboard cntlr. The response byte is	;
;	 returned in (AL).					;
;---------------------------------------------------------------;

read_kb_cntlr_data	proc	near

	call	write_kb_cntlr_cmd		;
	jnz	short read_kb_cntlr_data_01	; error...input buffer full
	call	read_8042_data			; (al) = data received from keyboard controller
	jnz	short read_kb_cntlr_data_02	; no error...(cy) = 00
read_kb_cntlr_data_01:
	stc					; (cy) = 01 for error
read_kb_cntlr_data_02:
	ret

read_kb_cntlr_data	endp

;---------------------------------------------------------------;
;			WRITE_KB_CNTLR_CMD			;
;---------------------------------------------------------------;
;	Input : (AL) comand to keyboard cntlr			;
;	Output: (NZF) error...input buffer full			;
;		(ZF) no error...input buffer empty		;
;		(CY) 00 always for error/no error		;
;	Register destroyed : (CX)				;
; NOTE : This routine sends the command byte in (AL) to the	;
;	 keyboard controller.					;
;---------------------------------------------------------------;

write_kb_cntlr_cmd	proc	near

	call	empty_kb_cntlr_ibuf		; input buffer empty ?
	jnz	short write_kb_cntlr_cmd_01	; no...full
	out	kb_cmd_port,al			; output the command
	call	empty_kb_cntlr_ibuf		; wait for input buffer empty
write_kb_cntlr_cmd_01:
	ret

write_kb_cntlr_cmd	endp

;---------------------------------------------------------------;
;		  GET_AMI_MEGAKEY2_HK_SCAN_CODE			;
;---------------------------------------------------------------;
;	Input : NONE						;
;	Output: (CY) 01 error input buf full/output buf empty/	;
;			      no hotkey code found.		;
;		(CY) 00 no error &				;
;			(AL) has hot key scan code.		;
;	Register destroyed : (AX),(CX)				;
; NOTE : Use this routine if you are using AMI MEGAKEY II &	;
;	 external SMI is generated due to keyboard hotkey & you	;
;	 want to know which hotkey has been used.		;
;	 This routine assumes that 'SAVE_LOCK_KB_CNTLR' routine	;
;	 has been called before and 'RES_KB_CNTLR' routine will	;
;	 be called afterwards.					;
;---------------------------------------------------------------;

get_ami_megakey2_hk_scan_code	proc	near

	mov	ah,18h				; read ram location 18h
	call	read_ami_megakey2_ram_loc	; (al) = content of the ram location
	jc	short megakey2_hk_code_01	; error...input buffer full/output buffer empty

	test	al,00000010b			; is the hot key present ?
	mov	ah,50h				; corressponding ram location for hot key scan code
	jnz	short megakey2_hk_code_02	; yes...

	mov	ah,19h				; read ram location 19h
	call	read_ami_megakey2_ram_loc	; (al) = content of the ram location
	jc	short megakey2_hk_code_01	; error...input buffer full/output buffer empty

	mov	cx,5				; check for 5 hot keys
	mov	ah,54h				; start ram location for corressponding hot key scan code
megakey2_hk_code_03:
	shr	al,1				; is the hot key present ?
	jc	short megakey2_hk_code_02	; yes...
	add	ah,2				; next ram location for corressponding hot key scan code
	loop	megakey2_hk_code_03		;
megakey2_hk_code_01:
	stc					; (cy) = 00 for error
	ret

megakey2_hk_code_02:
	call	read_ami_megakey2_ram_loc	; (al) = hot key scan code
	ret

get_ami_megakey2_hk_scan_code	endp

;---------------------------------------------------------------;
;		    READ_AMI_MEGAKEY2_RAM_LOC			;
;---------------------------------------------------------------;
;	Input : (AH) RAM location to read			;
;	Output: (CY) 01 error...input buf full/output buf empty	;
;		(CY) 00 no error &				;
;			(AL) content of the RAM location	;
;	Register destroyed : (AL),(CX)				;
;---------------------------------------------------------------;

read_ami_megakey2_ram_loc	proc	near

	mov	al,ami_megakey2_rd_ram_cmd 	; (al) = AMI MEGAKEY II read ram command
	call	write_kb_cntlr_data		;
	jnz	short megakey2_ram_loc_01	; error...input buffer full
	call	read_8042_data			; (al) has corresponding ram content
	jnz	short megakey2_ram_loc_02	; no error...(cy) = 00
megakey2_ram_loc_01:
	stc					; (cy) = 01 for error
megakey2_ram_loc_02:
	ret

read_ami_megakey2_ram_loc	endp
	
;---------------------------------------------------------------;
;		    WRITE_AMI_MEGAKEY2_RAM_LOC			;
;---------------------------------------------------------------;
;	Input : (AH) RAM location to write			;
;		(AL) data to write to the RAM location		;
;	Output: (CY) 01 error...input buf full			;
;		(CY) 00 no error				;
;	Register destroyed : (CX)				;
;---------------------------------------------------------------;

write_ami_megakey2_ram_loc	proc	near

⌨️ 快捷键说明

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