📄 gapm10.inc
字号:
mov ax,ds:pending_apm_event ;
and ax,valid_v10_event_mask ; consider APM v1.0 events only
bsr bx,ax ; any event pending ?
jz short int_15_ah53_al0b_02 ; no...
btr ax,bx ; clear pending APM event
mov ds:pending_apm_event,ax ; update PENDING_APM_EVENT
call set_rom_pending_apm_event ; update ROM_PENDING_APM_EVENT
inc bx ; translated APM event
mov [ebp+off_bx_apm],bx ; return (bx)
mov al,notify_pm_event_posted ; notify chipset specific module about PM event posted to OS
call css_entry_std ;
clc ; (CY) = 00 for no error
int_15_ah53_al0b_00:
ret
;-----------------------------------------------;
int_15_ah53_al0b_02:
mov ah,no_pm_event_pending ; no power management event pending
jmp short apm_error_exit ;
int_15_ah53_al0b endp
;---------------------------------------------------------------;
; SUBROUTINES USED BY APM BIOS ;
;---------------------------------------------------------------;
; APM_ERROR ;
; Input : NONE ;
; Output: Error code in (AH) updated in stack ;
; Register destroyed : (AH) ;
;---------------------------------------------------------------;
apm_error proc near
;-----------------------------------------------;
; DUMMY PROCEDURE TO SUBSTITUTE '::' ;
;-----------------------------------------------;
apm_err_code_01 proc near
mov ah,power_management_disabled ; power management functionality disabled
jmp short apm_error_exit ;
;-----------------------------------------------;
; DUMMY PROCEDURE TO SUBSTITUTE '::' ;
;-----------------------------------------------;
apm_err_code_09 proc near
mov ah,invalid_device_id ; unrecognized device ID
;-----------------------------------------------;
; DUMMY PROCEDURE TO SUBSTITUTE '::' ;
;-----------------------------------------------;
apm_error_exit proc near
mov [ebp+off_ah_apm],ah ; return (ah)
stc ; (CY) = 01 for error
ret
apm_error_exit endp
apm_err_code_09 endp
apm_err_code_01 endp
apm_error endp
;---------------------------------------------------------------;
; EXEC_APM_COMMON ;
;---------------------------------------------------------------;
; Input : (DL) to be ANDed to dev state ;
; (DH) to be ORed to dev state ;
; (AL) offeset for function exec ;
; (BH) device # ;
; (BL) unit # ;
; Output: (CY) = 00 for no error ;
; (CY) = 01 for error & error code in (AH) updated;
; in stack. ;
; Register destroyed : (EAX),(BX),(CX),(SI),(DI) ;
;---------------------------------------------------------------;
exec_apm_common proc near
movzx si,al ; (si) = offset for function execution
cmp bh,system_device_id ; system ?
jnz short apm_common_01 ; no...other device
cmp bx,all_power_managed_device_id ; all devices power managed by APM BIOS ?
jnz short apm_common_02 ; no...error
mov bl,0ffh ; set it for all units
call handle_apm_dev ; handle the requested device
pushf ;
push ax ;
mov al,ds:apm_state ;
call set_rom_apm_state ; update ROM_APM_STATE
pop ax ;
popf ;
ret
apm_common_01:
call handle_apm_dev ; handle the requested device
ret
;-----------------------------------------------;
apm_common_02:
jmp short apm_err_code_09 ; unrecognized device ID
exec_apm_common endp
;---------------------------------------------------------------;
; HANDLE_APM_DEV ;
;---------------------------------------------------------------;
; Input : (DL) to be ANDed to dev state ;
; (DH) to be ORed to dev state ;
; (SI) offeset for function exec ;
; (BH) device # ;
; (BL) unit #, 0ffh means all units ;
; Output: (CY) = 00 for no error ;
; (CY) = 01 for error & error code in (AH) updated;
; in stack. ;
; Register destroyed : (EAX),(BX),(CX),(DI) ;
;---------------------------------------------------------------;
handle_apm_dev proc near
mov al,bh ; (al) = device #
mov cl,no_of_units_for_each_dev ; (cl) = # of units for each device
mul cl ; (ax) = device # * # of units for each device
mov di,ax ;
add di,apm_state ; (di) = points to requested device state
mov ch,[ebp+off_al_apm] ; (ch) = APM fn#
call verify_apm_unit ;
jc short handle_apm_dev_01 ; error...
jz short handle_apm_dev_11 ; do not need to update APM data area or do not need to call chipset specific module
push dx ;
mov ax,si ; (al) = function#
mov dx,bx ; (dl) = unit#, (dh) = device#
call css_entry_std ; execute the function in APM chipset specific module
pop dx ;
jc short handle_apm_dev_00 ; error...
handle_apm_dev_03:
call update_apm_global ; update global
handle_apm_dev_11:
clc ; (cy) = 00 for no error
handle_apm_dev_01:
ret
handle_apm_dev_00:
cmp ch,apm_func_07 ; set power state function ?
jnz short handle_apm_dev_03 ; no...ignore the error
mov ah,unable_to_enter_req_state ; unable to enter requested state
jmp short apm_error_exit ;
handle_apm_dev endp
;---------------------------------------------------------------;
; VERIFY_APM_UNIT ;
;---------------------------------------------------------------;
; Input : (DI) pointer to info for the dev ;
; (BH) device # ;
; (BL) unit #, 0ffh means all units ;
; (CL) # of units for each device ;
; (CH) APM fn# ;
; Output: (CY) = 00 for no error ;
; (ZF) set..do not need chipset module call;
; (ZF) not set..needs chipset module call ;
; (CY) = 01 for error & error code in (AH) updated;
; in stack. ;
; Register destroyed : NONE ;
;---------------------------------------------------------------;
verify_apm_unit proc near
cmp bl,0ffh ; all units ?
jz short verify_apm_unit_00 ; yes...
cmp bl,no_of_units_for_each_dev ; valid unit # ?
jb short verify_apm_unit_00 ; yes...
xor bl,bl ; set the unit # to 00
verify_apm_unit_00:
cmp ch,apm_func_08 ; enable/disable power management function ?
jz short verify_apm_unit_02 ; yes...
push bx ;
mov al,[di] ; for all units, consider unit # 00
cmp bl,0ffh ; all units ?
jz short verify_apm_unit_03 ; yes...
xor bh,bh ; (bx) = unit #
mov al,[di+bx] ;
verify_apm_unit_03:
pop bx ;
test al,pm_enabled_by_apm ; power management enabled by APM for this device/unit ?
jz short verify_apm_unit_01 ; no...
verify_apm_unit_02:
or sp,sp ; set (NZF) so that call goes to CSS module
clc ; (cy) = 00 for no error
ret
verify_apm_unit_01:
jmp apm_err_code_01 ; power management disabled
verify_apm_unit endp
;---------------------------------------------------------------;
; UPDATE_APM_GLOBAL ;
;---------------------------------------------------------------;
; Input : (DI) pointer to info for the dev ;
; (DL) to be ANDed to dev state ;
; (DH) to be ORed to dev state ;
; (BH) device # ;
; (BL) unit #, 0ffh means all units ;
; (CL) # of units for each device ;
; (CH) APM fn# ;
; Output: NONE ;
; Register destroyed : NONE except (AL),(BX),(DI) ;
;---------------------------------------------------------------;
update_apm_global proc near
cmp bh,system_device_id ; system ?
jnz short update_apm_global_00 ; no...
mov al,no_of_total_dev_v10 ; total # of device supported
update_apm_global_01:
call cntrl_dev_class ; handle current device
add di,no_of_units_for_each_dev ; points to next device
dec al ;
jnz short update_apm_global_01 ;
ret
update_apm_global_00:
cmp bl,0ffh ; all units of the class ?
jz short update_apm_global_02 ; yes...
xor bh,bh ; (bx) = unit #
and [di+bx],dl ; clear the required bits
or [di+bx],dh ; update required bits
ret
update_apm_global_02:
call cntrl_dev_class ; handle all units for the device
ret
update_apm_global endp
;---------------------------------------------------------------;
; CNTRL_DEV_CLASS ;
;---------------------------------------------------------------;
; Input : (DI) pointer to info for the dev ;
; (DL) to be ANDed to dev state ;
; (DH) to be ORed to dev state ;
; (CL) # of units for each device ;
; (CH) APM fn# ;
; Output: NONE ;
; Register destroyed : NONE except (BX) ;
;---------------------------------------------------------------;
cntrl_dev_class proc near
push cx ;
xor bx,bx ; start with unit# 00
cntrl_dev_class_06:
cmp ch,apm_func_08 ; enable/disable power mgt func ?
jz short cntrl_dev_class_11 ; yes...
test byte ptr [di+bx],pm_enabled_by_apm; power mgt enabled by APM for this dev/unit ?
jz short cntrl_dev_class_04 ; no...
cntrl_dev_class_11:
and [di+bx],dl ; clear the required bits
or [di+bx],dh ; update required bits
cntrl_dev_class_04:
inc bx ; next unit#
dec cl ; decrement # of units
jnz short cntrl_dev_class_06 ;
pop cx ;
ret
cntrl_dev_class endp
;---------------------------------------------------------------;
; CSS_ENTRY_STD ;
;---------------------------------------------------------------;
; Input : (AL) func# to execute ;
; (DS) PM bios data segment ;
; (DI) pointer to dev state for some functions ;
; (DH) device# for some functions ;
; (DL) unit# for some functions,0ffh for all units;
; (CL) # of units for each device for some funcs ;
; (BX) PM event code posted for some function ;
; Output: (CY) 00 for no error ;
; (CY) 01 for error ;
; Register destroyed : NONE except (EAX) ;
;---------------------------------------------------------------;
css_entry_std proc near
pushad ;
mov ch,[ebp+off_bp_apm] ; (ch) = info about func called in real/16/32 mode
call apm_css_entry ; CHIPSET HOOK HOOK HOOK...execute in APM chipset specific module
call get_ebp_for_stack_usage ; (ebp) = current stack pointer
mov [ebp+28],eax ; put returned (eax) on stack
popad ;
ret
css_entry_std endp
;---------------------------------------------------------------;
; GET_APM_BIOS_PM_STATUS ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; STACK PRESENT ;
; Output: (CY) 00 for APM BIOS power management enabled ;
; (CY) 01 for APM BIOS power management disabled ;
; Register destroyed : NONE ;
;---------------------------------------------------------------;
get_apm_bios_pm_status proc near
;-----------------------------------------------;
; FOLLOWING PIECE OF CODE HAS BEEN REMOVED ;
; AND REPLACED BY 'CLC' & 'RET' AS WE ARE ;
; EXECUTING APM ONLY IF SMI/IRQ BASED POWER ;
; MANAGEMENT IS ACTIVE, WHICH MEANS IT WILL ;
; ALWAYS RETURN POWER MANAGEMENT ENABLED. ;
;-----------------------------------------------;
clc ; (CY) = 00 for APM BIOS power management enabled
ret
get_apm_bios_pm_status endp
;---------------------------------------------------------------;
; APM_POST ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; Output: NONE ;
; Register destroyed : (AL),(DI) ;
;---------------------------------------------------------------;
apm_post proc near
mov word ptr ds:apm_bios_ver_no,0100h; set to v1.0
mov byte ptr ds:apm_connection_info,00000000b; no APM connection
; APM BIOS active version v1.0
mov word ptr ds:pending_apm_event,0000h
;---------------------------------------------------------------;
; SET_DEV_STATE ;
;---------------------------------------------------------------;
; Input : NONE ;
; Output: NONE ;
; Register destroyed : (AL),(DI) ;
;---------------------------------------------------------------;
set_dev_state proc near
push cx ;
mov cx,no_of_total_dev_v10 * no_of_units_for_each_dev; (cx) = total # of device info bytes
mov di,apm_state ; (di) = APM device state pointer
mov al,apm_dev or pm_engaged_by_apm or pm_enabled_by_apm
set_dev_state_00:
mov [di],al ; set the device/unit state
inc di ; points to next device/unit
loop set_dev_state_00 ;
pop cx ;
ret
set_dev_state endp
apm_post 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 + -