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

📄 gapm10.inc

📁 AMI 主板的BIOS源码
💻 INC
📖 第 1 页 / 共 3 页
字号:
Subttl.	Include file for GREEN PC support APM v1.0 code...GAPM10.INC

;-----------------------------------------------;
;  FOLLOWING ROUTINES USED FROM OTHER MODULES	;
;-----------------------------------------------;

	public	apm_version			;

;;	public	apm_call_near			; use the functional support thru near call
;;	public	apm_post			;

;-----------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;**								**;
;**	(C)Copyright 1985-1996, American Megatrends Inc.	**;
;**								**;
;**			All Rights Reserved.			**;
;**								**;
;**		6145-F, Northbelt Parkway, Norcross,		**;
;**								**;
;**		Georgia - 30071, USA. Phone-(770)-246-8600.	**;
;**								**;
;*****************************************************************;
;*****************************************************************;
;*****************************************************************;
;-----------------------------------------------;
;    THIS MODULE HAS THE CODE FOR SUPPORTING	;
;     APM FUNCTIONS AS DEFINED BY MICROSOFT	;
;	    AND INTEL IN V1.0 SPECS		;
;-----------------------------------------------;
;	  ALL CODES ARE REAL MODE CODE		;
;-----------------------------------------------;
;		INCLUDE  FILES			;
;-----------------------------------------------;

	include	gapm.equ			; equate file
	include	gapm.dat			; data file

;-----------------------------------------------;
;	      APM NEAR STACK  EQUATES		;
;-----------------------------------------------;

	off_al_apm		equ	28	;
	off_ah_apm		equ	29	;
	off_ax_apm		equ	28	;
	off_eax_apm		equ	28	;
	off_bl_apm		equ	16	;
	off_bh_apm		equ	17	;
	off_bx_apm		equ	16	;
	off_ebx_apm		equ	16	;
	off_cl_apm		equ	24	;
	off_ch_apm		equ	25	;
	off_cx_apm		equ	24	;
	off_ecx_apm		equ	24	;
	off_dl_apm		equ	20	;
	off_dh_apm		equ	21	;
	off_dx_apm		equ	20	;
	off_edx_apm		equ	20	;
	off_di_apm		equ	00	;
	off_si_apm		equ	04	;
	off_bp_apm		equ	08	;
	off_flag_apm		equ	32	;

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

apm_version	label	byte

	db	'APM1.0-1.11 ',00h

;---------------------------------------------------------------;
;	     RUN TIME CORE BIOS SMI APM HANDLER CODE		;
;	     RUN TIME CORE BIOS SMI APM HANDLER CODE		;
;	     RUN TIME CORE BIOS SMI APM HANDLER CODE		;
;	     RUN TIME CORE BIOS SMI APM HANDLER CODE		;
;---------------------------------------------------------------;
;			APM_CALL_NEAR				;
;---------------------------------------------------------------;
;	Input : (DS) PM BIOS data segment			;
;		(AX),(EBX),(ECX),(DX),(SI) & (EDI) has on	;
;		entry values when APM call was made.		;
;		(BP) bit 0 1 called in real mode		;
;		     bit 1 1 called in 16 bit protected mode	;
;		     bit 2 1 called in 32 bit protected mode	;
;	Output: (CY) 00 for no error				;
;		(CY) 01 for error & (AH) has error code		;
;		Registers as specified in function. Possible	;
;		registers are (AX),(EBX),(ECX),(DX),(SI) & (EDI);
;	Register destroyed : NONE except returned parameters in	;
;			     (AX),(EBX),(ECX),(DX),(SI) & (EDI)	;
;---------------------------------------------------------------;

apm_call_near	proc	near

	pushf					; save current CPU flags
	test	al,10000000b			; OEM APM functions ?
	jnz	short apm_near_00		; yes..

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

	pushad					; save all registers
	call	get_ebp_for_stack_usage		; (ebp) = current stack pointer

;-----------------------------------------------;
;	STACK LAYOUT AT THIS POSITION		;
;-----------------------------------------------;
;		EDI			[EBP+00];
;-----------------------------------------------;
;		ESI			[EBP+04];
;-----------------------------------------------;
;		EBP			[EBP+08];
;-----------------------------------------------;
;		ESP			[EBP+12];
;-----------------------------------------------;
;		EBX			[EBP+16];
;-----------------------------------------------;
;		EDX			[EBP+20];
;-----------------------------------------------;
;		ECX			[EBP+24];
;-----------------------------------------------;
;		EAX			[EBP+28];
;-----------------------------------------------;
;		FLAG			[EBP+32];
;-----------------------------------------------;
;		IP			[EBP+34];
;-----------------------------------------------;

	cmp	al,maxm_apm_v10_func_supported	; valid function (maximum func. no. supported) ?
	ja	short apm_near_01		; no...invalid function

apm_near_06:
	cbw					; (ax) = function no.
	shl	ax,1				; (ax) = func # * 2
	xchg	ax,di				; RESTORE (DI) IN EACH FUNCTION CALL IF REQUIRED
						; on entry (AX),(DI) destroyed

	and	byte ptr [ebp+off_flag_apm],0feh; clear (CF)
	mov	al,ds:apm_connection_info	; (al) = current apm_connection_info
	call	word ptr cgroup:[di+cgroup:apm_jmp_table - cgroup:smi_code_begin + orgbase ]; execute the function
						; returns (CY) = 0/1 for no error/error

apm_near_03:
	jnc	short apm_near_02		; no error
apm_near_04:
	or	byte ptr [ebp+off_flag_apm],01h	; set (CF)
apm_near_02:
	popad					; restore all registers
	popf					; restore CPU flag
	ret

apm_near_01:
	mov	byte ptr [ebp+off_ah_apm],unsupported_func
	jmp	short apm_near_04		;

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

apm_near_00:
	popf					; restore on entry CPU flags
	jmp	exec_oem_apm_func		; CHIPSET/OEM HOOK HOOK HOOK...execute OEM APM functions

apm_call_near	endp

;---------------------------------------------------------------;
;			    APM_JMP_TABLE			;
;---------------------------------------------------------------;

apm_jmp_table	label	word

	dw	cgroup:int_15_ah53_al00 - cgroup:smi_code_begin + orgbase; FN# = 00 ... APM installation check
	dw	cgroup:int_15_ah53_al01 - cgroup:smi_code_begin + orgbase; FN# = 01 ... APM real mode interface connect
	dw	cgroup:int_15_ah53_al02 - cgroup:smi_code_begin + orgbase; FN# = 02 ... APM protected mode connect 16 bit
	dw	cgroup:int_15_ah53_al03 - cgroup:smi_code_begin + orgbase; FN# = 03 ... APM protected mode connect 32 bit
	dw	cgroup:int_15_ah53_al04	- cgroup:smi_code_begin + orgbase; FN# = 04 ... APM interface disconnect
	dw	cgroup:int_15_ah53_al05	- cgroup:smi_code_begin + orgbase; FN# = 05 ... APM CPU idle
	dw	cgroup:int_15_ah53_al06	- cgroup:smi_code_begin + orgbase; FN# = 06 ... APM CPU busy
	dw	cgroup:int_15_ah53_al07	- cgroup:smi_code_begin + orgbase; FN# = 07 ... set power state
	dw	cgroup:int_15_ah53_al08	- cgroup:smi_code_begin + orgbase; FN# = 08 ... enable/disable power management
	dw	cgroup:int_15_ah53_al09	- cgroup:smi_code_begin + orgbase; FN# = 09 ... restore power on defaults
	dw	cgroup:int_15_ah53_al0a	- cgroup:smi_code_begin + orgbase; FN# = 0A ... get power status
	dw	cgroup:int_15_ah53_al0b	- cgroup:smi_code_begin + orgbase; FN# = 0B ... get PM event

;---------------------------------------------------------------;
;		FN# 00H ... APM INSTALLATION CHECK		;
;---------------------------------------------------------------;
;	Input : As specified in function			;
;		(DS) PM bios data segment			;
;		(AL) APM_CONNECTION_INFO			;
;	Output: (CY) 00 for no error				;
;		(CY) 01 for error				;
;		Required returned registers are updated in stack;
;	Register destroyed : ALL GENERAL PURPOSE except (EBP)	;
;---------------------------------------------------------------;

int_15_ah53_al00	proc	near

	call	check_real_mode_call		; called in real mode & valid device ID ?
	jc	short int_15_ah53_al00_00	; no...error

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

	and	al,not (apm_cpu_idle_slow_speed or apm_bios_power_management_disabled)
						; set for CPU STOP clock
						; set for APM BIOS power management enabled

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

	mov	cx,0000000000000011b		; bit 0 = 1 means 16 bit protected mode interface supported
						; bit 1 = 1 means 32 bit protected mode interface supported

	call	get_apm_cpu_idle_speed		; CHIPSET HOOK HOOK HOOK...APM CPU idle call slows processor clock speed ?
	jnc	short int_15_ah53_al00_05	; no...STOPs CPU clock
	or	cl,00000100b			; inform CPU idle call slows processor clock speed
	or	al,apm_cpu_idle_slow_speed	; keep info APM CPU idle call slows processor clock speed
int_15_ah53_al00_05:
	call	get_apm_bios_pm_status		; APM BIOS power management disabled ?
	jnc	short int_15_ah53_al00_10	; no...
	or	al,apm_bios_power_management_disabled; keep info APM BIOS power management disabled
	or	cl,00001000b			; inform APM BIOS power management disabled
int_15_ah53_al00_10:
	mov	ds:apm_connection_info,al	; update APM_CONNECTION_INFO
	call	set_rom_apm_connection_info	; update ROM_APM_CONNECTION_INFO

	mov	word ptr [ebp+off_ax_apm],0100h	; return (ax) as version no. of APM being supported
	mov	word ptr [ebp+off_bx_apm],'PM'	; return (bx)
	mov	[ebp+off_cx_apm],cx		; return (cx)
	clc					; set (CY) = 00 for no error
int_15_ah53_al00_00:
	ret

int_15_ah53_al00	endp

;---------------------------------------------------------------;
;	   FN# 01H ... APM REAL MODE INTERFACE CONNECT		;
;---------------------------------------------------------------;
;	Input : As specified in function			;
;		(DS) PM bios data segment			;
;		(AL) APM_CONNECTION_INFO			;
;	Output: (CY) 00 for no error				;
;		(CY) 01 for error				;
;		Required returned registers are updated in stack;
;	Register destroyed : ALL GENERAL PURPOSE except (EBP)	;
;---------------------------------------------------------------;

int_15_ah53_al01	proc	near

	mov	dl,apm_real_mode_connect_est	; APM real mode connection request
	jmp	short apm_connect_common	;

int_15_ah53_al01	endp

;---------------------------------------------------------------;
;	  FN# 02H ... APM PROTECTED MODE 16 BIT CONNECT		;
;---------------------------------------------------------------;
;	Input : As specified in function			;
;		(DS) PM bios data segment			;
;		(AL) APM_CONNECTION_INFO			;
;	Output: (CY) 00 for no error				;
;		(CY) 01 for error				;
;		Required returned registers are updated in stack;
;	Register destroyed : ALL GENERAL PURPOSE except (EBP)	;
;---------------------------------------------------------------;

int_15_ah53_al02	proc	near

	mov	dl,apm_16bit_mode_connect_est	; APM 16 bit protected mode connect request
	jmp	short apm_connect_common	;

int_15_ah53_al02	endp

;---------------------------------------------------------------;
;	  FN# 03H ... APM PROTECTED MODE 32 BIT CONNECT		;
;---------------------------------------------------------------;
;	Input : As specified in function			;
;		(DS) PM bios data segment			;
;		(AL) APM_CONNECTION_INFO			;
;	Output: (CY) 00 for no error				;
;		(CY) 01 for error				;
;		Required returned registers are updated in stack;
;	Register destroyed : ALL GENERAL PURPOSE except (EBP)	;
;---------------------------------------------------------------;

int_15_ah53_al03	proc	near

	mov	dl,apm_32bit_mode_connect_est	; APM 32 bit protected mode connection request
	jmp	short apm_connect_common	;

int_15_ah53_al03	endp

;---------------------------------------------------------------;
;			APM_CONNECT_COMMON			;
;---------------------------------------------------------------;
;	Input : (DL) bit 0 1 APM real mode connect request	;
;		     bit 1 1 APM 16 bit prot mode connect request
;		     bit 2 1 APM 32 bit prot mode connect request
;		(BX) requested device id			;
;		(DS) PM bios data segment			;
;		(AL) APM_CONNECTION_INFO			;
;	Output: (CY) 00 for no error				;
;		(CY) 01 for error				;
;		Required returned registers are updated in stack;
;	Register destroyed : ALL GENERAL PURPOSE except (EBP)	;
;---------------------------------------------------------------;

apm_connect_common	proc	near

	call	check_real_mode_call		; called in real mode & valid device ID ?
	jc	short apm_connect_common_00	; no...error

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

	test	al,apm_real_mode_connect_est	; APM real mode connection already established ?
	jnz	short apm_connect_common_02	; yes...error
	test	al,apm_16bit_mode_connect_est	; APM 16 bit protected mode connection already established ?
	jnz	short apm_connect_common_04	; yes...
	test	al,apm_32bit_mode_connect_est	; APM 32 bit protected mode connection already established ?
	jnz	short apm_connect_common_05	; yes...

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

	or	al,dl				;
	mov	ds:apm_connection_info,al	; set APM_CONNECTION_INFO
	call	set_rom_apm_connection_info	; set ROM_APM_CONNECTION_INFO

	mov	al,process_apm_connect		;
	call	css_entry_std			; call chipset specific module

;-----------------------------------------------;
;   FOLLOWING CODE HAS BEEN ADDED TO HANDLE A	;
;   BUG IN DOS POWER.EXE. THE BUG RELATED TO	;
;   SWITCHING BETWEEN POWER ON/OFF SETTINGS.	;
;-----------------------------------------------;

	push	ebp				;
	mov	ax,53h*256+apm_func_08		; enable/disable power management call
	mov	bx,all_pm_device_id_v10		; all devices power managed by APM BIOS
	mov	cx,enable_power_management	; enable power management
	mov	bp,00000001b			; set for called in real mode
	call	apm_call_near			;
	pop	ebp				;

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

	mov	al,dl				; (al) = bit 0/1/2 set APM real/16 bit/32 bit mode connection request

	test	al,00000001b			; APM real mode connect request ?
	jnz	short apm_connect_common_10	; yes...
	
;-----------------------------------------------;

	call	get_apm_16_32_bit_code_seg	; (bx) = APM BIOS 16 bit/32 bit protected mode code segment
	mov	[ebp+off_ax_apm],bx		; return (ax)

	call	get_apm_16_32_bit_data_seg	; (dx) = APM BIOS 16 bit/32 bit protected mode data segment

	test	al,00000010b			; APM 16 bit protected mode connect request ?
	jnz	short apm_connect_common_11	; yes...

	mov	[ebp+off_cx_apm],bx		; return (cx)
	mov	[ebp+off_dx_apm],dx		; return (dx)

	call	get_apm_32_bit_entry_point	; NON-SMI CORE BIOS ENTRY POINT...(ebx) = APM bios 32 bit protected mode entry point
	mov	[ebp+off_ebx_apm],ebx		; return (ebx)

	clc					; set (CY) = 00 for no error
apm_connect_common_00:
	ret

apm_connect_common_11:
	mov	[ebp+off_cx_apm],dx		; return (cx)

	call	get_apm_16_bit_entry_point	; NON-SMI CORE BIOS ENTRY POINT...(bx) = APM bios 16 bit protected mode entry point
	mov	[ebp+off_bx_apm],bx		; return (bx)

apm_connect_common_10:
	clc					; set (CY) = 00 for no error
	ret

⌨️ 快捷键说明

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