📄 gapm12.inc
字号:
Subttl. Include file for GREEN PC support APM v1.2 code...GAPM12.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/V1.1 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.2-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 word ptr ds:apm_bios_ver_no,0100h; APM v1.0 ?
jz short apm_near_05 ; yes...
cmp al,apm_func_0e ; function no. 0Eh ?
jz short apm_near_06 ; yes...
cmp word ptr ds:apm_bios_ver_no,0102h; APM v1.2 or above ?
jb short apm_near_08 ; no...
cmp al,apm_func_10 ; function no. 10h ?
jz short apm_near_06 ;
apm_near_08:
test byte ptr ds:apm_connection_info,apm_bios_active_ver_above_v10; active APM v1.0 ?
jz short apm_near_05 ; yes...
test byte ptr ds:apm_connection_info,apm_bios_active_ver_v12; active APM v1.2 ?
jnz short apm_near_10 ; yes...
cmp al,maxm_apm_v11_func_supported ; valid function no. ?
jmp short apm_near_07 ;
apm_near_10:
cmp al,maxm_apm_v12_func_supported ; valid function no. ?
jmp short apm_near_07 ;
apm_near_05:
cmp al,maxm_apm_v10_func_supported ; valid function (maximum func. no. supported) ?
apm_near_07:
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
dw cgroup:int_15_ah53_al0c - cgroup:smi_code_begin + orgbase; FN# = 0C ... get power state (v1.1 only)
dw cgroup:int_15_ah53_al0d - cgroup:smi_code_begin + orgbase; FN# = 0D ... enable/disable device power management(v1.1 only)
dw cgroup:int_15_ah53_al0e - cgroup:smi_code_begin + orgbase; FN# = 0E ... APM driver version (v1.1 only)
dw cgroup:int_15_ah53_al0f - cgroup:smi_code_begin + orgbase; FN# = 0F ... engage/disengage power management(v1.1 only)
dw cgroup:int_15_ah53_al10 - cgroup:smi_code_begin + orgbase; FN# = 10 ... get capabilities (v1.2 only)
dw cgroup:int_15_ah53_al11 - cgroup:smi_code_begin + orgbase; FN# = 11 ... get/set/disable resume timer (v1.2 only)
dw cgroup:int_15_ah53_al12 - cgroup:smi_code_begin + orgbase; FN# = 12 ... enable/disable resume on ring indicator (v1.2 only)
dw cgroup:int_15_ah53_al13 - cgroup:smi_code_begin + orgbase; FN# = 13 ... enable/disable timer based requests (v1.2 only)
;---------------------------------------------------------------;
; 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:
test al,apm_bios_active_ver_above_v10; APM v1.0 ?
jz short int_15_ah53_al00_06 ; yes...
test byte ptr ds:apm_state,pm_engaged_by_apm ; APM BIOS power management engaged ?
jnz short int_15_ah53_al00_06 ; yes...
or cl,00010000b ; inform APM BIOS power management disengaged
int_15_ah53_al00_06:
;; Added by Robert at 11/27/97 for power off working when PM disabled!
push ax
mov al,q_power_management
call check_cmos_data_far
jnz pm_op_enable
mov cl,08h
pm_op_enable:
pop ax
mov ds:apm_connection_info,al ; update APM_CONNECTION_INFO
call set_rom_apm_connection_info ; update ROM_APM_CONNECTION_INFO
mov ax,ds:apm_bios_ver_no ; (ax) = version no. of APM being supported
mov [ebp+off_ax_apm],ax ; return (ax)
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 ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -