📄 gapm12.inc
字号:
mov ah,00000000b ; set power management disengaged by APM
jmp short apm_con_discon ;
apm_disconnect_local endp
;---------------------------------------------------------------;
; APM_CON_DISCON ;
;---------------------------------------------------------------;
; input : (al) to be ANDed to dev state ;
; (ah) to be ORed to dev state ;
; Output: NONE ;
; Register destroyed : (AL),(CX),(DI) ;
;---------------------------------------------------------------;
apm_con_discon proc near
mov cx,no_of_total_dev_v11 * no_of_units_for_each_dev; (cx) = total no. of device info bytes
mov di,apm_state ; (di) = APM device state pointer
apm_con_discon_02:
test byte ptr [di],apm_dev ; APM device ?
jz short apm_con_discon_01 ; no...
and [di],al ;
or [di],ah ;
apm_con_discon_01:
inc di ; points to next device/unit
loop apm_con_discon_02 ;
mov al,ds:apm_state ;
call set_rom_apm_state ; update ROM_APM_STATE
ret
apm_con_discon endp
;---------------------------------------------------------------;
; EXEC_APM_COMMON ;
;---------------------------------------------------------------;
; Input : (DL) to be ANDed to dev state...not required for;
; APM function# 0Ch ;
; (DH) to be ORed to dev state...not required for ;
; APM function# 0Ch ;
; (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. ;
; For no error & APM FN# 0Ch (Get power ;
; state), (AX) will contain power state ;
; 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...not required for;
; APM function# 0Ch ;
; (DH) to be ORed to dev state...not required for ;
; APM function# 0Ch ;
; (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. ;
; For no error & APM FN# 0Ch (Get power ;
; state), (AX) will contain power state ;
; 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:
cmp ch,apm_func_0c ; get power state function ?
jnz short handle_apm_dev_04 ; no...
handle_apm_dev_11:
and ax,apm_dev_state ; consider the device state part only for function # 0Ch
clc ; (cy) = 00 for no error
ret
handle_apm_dev_04:
call update_apm_global ; update global
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 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. ;
; For no error & APM FN# 0Ch (Get power ;
; state), (AX) will contain power state ;
; Register destroyed : (AX) ;
;---------------------------------------------------------------;
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:
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 ;
cmp ch,apm_func_0c ; get power state function ?
jz short verify_apm_unit_30 ; yes...
;-----------------------------------------------;
; SET POWER STATE (FN# 07h) ;
; ENABLE/DISABLE POWER MANAGEMENT (FN# 08h) ;
;ENABLE/DISABLE DEVICE POWER MANAGEMENT (FN# 0Dh)
; ENGAGE/DISENGAGE POWER MANAGEMENT (FN# 0Fh) ;
;-----------------------------------------------;
cmp ch,apm_func_08 ; enable/disable power management function ?
jz short verify_apm_unit_09 ; yes...
cmp ch,apm_func_0d ; enable/disable device power management function ?
jz short verify_apm_unit_09 ; yes...
;-----------------------------------------------;
; FOR CHICAGO 'pm_enabled_by_apm' CHECK ;
; HAS BEEN REMOVED FOR FN# 0Fh ;
;-----------------------------------------------;
; ;
; cmp ch,apm_func_0f ; engage/disengage power management ?
; jz short verify_apm_unit_07 ; yes...
; test al,pm_enabled_by_apm ; power management enabled by APM for this dev ?
; jz short verify_apm_unit_01 ; no...
; ;
;-----------------------------------------------;
; 'pm_enabled_by_apm' CHECK IS BROUGHT ;
; BACK ON 122895 TO SUPPORT HCT TEST ;
; FOR APM v1.2 & APPARENTLY IT SEEMS ;
; WINDOWS 95 HAS CORRECTED THE BUG ;
;-----------------------------------------------;
test al,pm_enabled_by_apm ; power management enabled by APM for this dev ?
jz short verify_apm_unit_01 ; no...
cmp ch,apm_func_0f ; engage/disengage power management ?
jz short verify_apm_unit_07 ; yes...
;
;-----------------------------------------------;
verify_apm_unit_09:
test byte ptr ds:apm_connection_info,apm_bios_active_ver_above_v10; APM v1.0 ?
jz short verify_apm_unit_07 ; yes...
test al,pm_engaged_by_apm ; power management engaged ?
jz short verify_apm_unit_06 ; no...
verify_apm_unit_07:
or sp,sp ; set (NZF) so that call goes to CSS module
clc ; set (CY) = 00 for no error
ret
;-----------------------------------------------;
verify_apm_unit_01:
check_apm_dev_01::
jmp apm_err_code_01 ; power management disabled
verify_apm_unit_06:
jmp apm_err_code_0b ; interface not engaged
verify_apm_unit_08:
check_apm_dev_03::
jmp apm_err_code_09 ; unrecognized device ID
;-----------------------------------------------;
; GET POWER STATE (FN# 0Ch) ;
;-----------------------------------------------;
verify_apm_unit_30:
test al,pm_enabled_by_apm ; power management enabled by APM for this dev ?
jz short verify_apm_unit_01 ; no...
test al,apm_fn0c_enabled ; function 0Ch enabled for this class ?
jz short verify_apm_unit_08 ; no...
test al,pm_engaged_by_apm ; power management engaged ?
jz short verify_apm_unit_07 ; no...power state available at chipset module
and al,apm_dev_state ;
xor ah,ah ; (CY) = 00 and (ZF) set
ret
verify_apm_unit endp
;---------------------------------------------------------------;
; CHECK_APM_DEV ;
;---------------------------------------------------------------;
; Input : (BH) device # ;
; (BL) unit # ;
; (DS) PM BIOS data segment ;
; (AL) APM_CONNECTION_INFO ;
; Output: (CY) 00 for no error ;
; (CY) 01 for error & error code in (AH) updated ;
; in stack. ;
; Register destroyed : (AH) for error ;
;---------------------------------------------------------------;
check_apm_dev proc near
test al,[ebp+off_bp_apm] ; is proper APM connection done ?
jz short check_apm_dev_00 ; no...
;---------------------------------------------------------------;
; CHECK_APM_DEV_FN0C ;
;---------------------------------------------------------------;
; Input : (BH) device # ;
; (BL) unit # ;
; (DS) PM BIOS data segment ;
; (AL) APM_CONNECTION_INFO ;
; Output: (CY) 00 for no error ;
; (CY) 01 for error & (ah) has error code ;
; Register destroyed : (AH) for error ;
;---------------------------------------------------------------;
check_apm_dev_fn0c proc near
test al,apm_bios_power_management_disabled; APM BIOS power management disabled ?
jnz short check_apm_dev_01 ; yes...
test al,apm_bios_active_ver_above_v10; active APM v1.0 ?
jnz short check_apm_dev_10 ; no...v1.1
cmp bh,serial_port_device_id ; valid device ID ?
check_apm_dev_11:
ja short check_apm_dev_03 ; no...
check_apm_dev_02:
clc ; set (CY) = 00 for no error
ret
check_apm_dev_10:
cmp bh,pcmcia_socket_device_id ; valid device ID ?
jmp short check_apm_dev_11 ;
;-----------------------------------------------;
check_apm_dev_00::
jmp apm_err_code_03 ; interface not connected
check_apm_dev_fn0c endp
check_apm_dev 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_v11 ; 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_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -