📄 gpmlib.inc
字号:
subttl. Include file for GREEN PC support LIBRARY code....GPMLIB.INC
;-----------------------------------------------;
; FOLLOWING ROUTINES USED FROM OTHER MODULES ;
;-----------------------------------------------;
;; public vesa_low_power_request ;
;; public ide_low_power_request ;
;; public save_suspend_date_time ;
;; public res_suspend_date_time ;
;; public save_lock_kb_cntlr ;
;; public res_kb_cntlr ;
;; public read_kb_cntlr_data ;
;; public write_kb_cntlr_cmd ;
;; public get_ami_megakey2_hk_scan_code ;
;; public set_rtc_alarm_during_suspend ;
;; public restore_rtc_on_resume ;
;; public set_apm_resume_timer ;
;; public check_apm_resume_date ;
;; public is_it_alarm_resume ;
;-----------------------------------------------;
;*****************************************************************;
;*****************************************************************;
;** **;
;** (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 DISPLAY POWER MANAGEMENT ;
; CODE TO HANDLE DISPLAY POWER MANAGEMENT ;
; CODE TO HANDLE DISPLAY POWER MANAGEMENT ;
; CODE TO HANDLE DISPLAY POWER MANAGEMENT ;
;---------------------------------------------------------------;
; All the code from here labelled as 'DISP_POWER_DOWN' to ;
; the label 'DISP_POWER_DOWN_ENDS' should be made active if ;
; you need to use VESA display power down commands. ;
; Following routine needs to be called... ;
; VESA_LOW_POWER_REQUEST ;
;---------------------------------------------------------------;
IF VESA_POWER_DOWN_SUPPORT
disp_power_down label byte
;---------------------------------------------------------------;
; VESA_LOW_POWER_REQUEST ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; (CX) controller unit# (currently 0000h for ;
; primary controller) ;
; (BL) 000h ... get power state ;
; 0ffh ... set power state & ;
; (BH) 00h ... ON ;
; 01h ... STANDBY ;
; 02h ... SUSPEND ;
; 04h ... OFF ;
; Output: (CY) 00h function successful & for get_power_state
; request (BH) 00h ... ON ;
; 01h ... STANDBY ;
; 02h ... SUSPEND ;
; 04h ... OFF ;
; (CY) 01h for error & ;
; (AH) 01h ... req vbe/pm func not supported
; 02h ... req power state not supported
; Register destroyed : all general purpose registers ;
;---------------------------------------------------------------;
vesa_low_power_request proc near
IF IRQ_HANDLING_SUPPORT
call check_irq_apm ; IRQ based APM 16/32 bit function currently being executed ?
jnz short vesa_low_power_req_20 ; yes...
ENDIF
mov si,disp_0_control_struc ; currently assume primary controller support only
and bh,vbe_pm_standby_bit or vbe_pm_suspend_bit or vbe_pm_off_bit or vbe_pm_reduced_on_bit
test byte ptr [si+disp_misc_control_info],vbe_pm_interface_supported
jnz short vesa_low_power_req_10 ; VESA VBE/PM interface supported
vesa_low_power_req_20:
or bl,bl ; get power state request ?
jz short vesa_low_power_req_01 ; yes...return with error
or bh,bh ; request for 'ON' ?
jz short vesa_low_power_req_02 ; yes...
call disable_video_display_3c0 ; disable video for any low power mode
call disable_video_display_3c4 ; disable video for any low power mode
call disable_horz_vert_retrace ; disable horizontal/vertical retrace
vesa_low_power_req_01:
mov ah,vbe_pm_req_func_not_supported; requested VBE/PM function not supported
stc ; (cy) = 01 for error
ret
vesa_low_power_req_02:
call enable_horz_vert_retrace ; enable horizontal/vertical retrace
call enable_video_display_3c0 ; enable video for ON
call enable_video_display_3c4 ; enable video for ON
jmp short vesa_low_power_req_01 ;
;-----------------------------------------------;
vesa_low_power_req_10:
or bl,bl ; get power state request ?
jnz short vesa_low_power_req_11 ; no...
mov bl,get_disp_power_state ; get display power state
call exec_vesa_vbe_pm_func ;
ret
;-----------------------------------------------;
vesa_low_power_req_11:
or bh,bh ; set power state to 'ON' ?
jnz short vesa_low_power_req_12 ; no...
mov bl,set_disp_power_state ; set display power state
call exec_vesa_vbe_pm_func ;
pushf ;
;; call enable_video_display_3c0 ; enable video for ON
call enable_video_display_3c4 ; enable video for ON
;; green monitor can not off when suspend mode
call enable_horz_vert_retrace ; enable horizontal/vertical retrace
call enable_video_display_3c0 ; enable video for ON
popf ;
ret
;-----------------------------------------------;
vesa_low_power_req_12:
test [si+disp_vbe_supported_power_mode],bh; requested power state mode supported ?
jz short vesa_low_power_req_13 ; no...
;-----------------------------------------------;
; TAKE OUT COMMENT FROM FOLLOWING ;
; CODE IF YOU WANT TO CHECK CURRENT ;
; POWER SAVING MODE GREATER THAN ;
; REQUESTED MODE OR NOT. ;
;-----------------------------------------------;
; ;
; push bx ; save (bh) = requested power state
; mov bl,get_disp_power_state ; get display power state
; call exec_vesa_vbe_pm_func ; (bh) = current display power state
; and bh,vbe_pm_standby_bit or vbe_pm_suspend_bit or vbe_pm_off_bit or vbe_pm_reduced_on_bit
; mov dh,bh ; (dh) = current display power state
; pop bx ; (bh) = requested display power state
; jc short vesa_low_power_req_14 ; function not supported
; cmp dh,bh ; is current power state more power managed ?
; jae short vesa_low_power_req_15 ; currently doing better power saving
;vesa_low_power_req_14: ;
; ;
;-----------------------------------------------;
mov bl,set_disp_power_state ; set display power state
call exec_vesa_vbe_pm_func ;
vesa_low_power_req_15:
pushf ;
;; call disable_video_display_3c0 ; disable video
call disable_video_display_3c4 ; disable video
;; green monitor can not off when suspend mode
call disable_video_display_3c0 ; disable video for any low power mode
call disable_horz_vert_retrace ; disable horizontal/vertical retrace
popf ;
ret
vesa_low_power_req_13:
mov ah,vbe_pm_req_state_not_supported; requested VBE/PM state not supported
stc ; (cy) = 01 for error
jmp short vesa_low_power_req_15 ;
vesa_low_power_request endp
;---------------------------------------------------------------;
; EXEC_VESA_VBE_PM_FUNC ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; (SI) display control info pointer ;
; (BL) 01h/02h ... set/get power state ;
; (BH) requested state if (BL) = 01h ;
; Output: (CY) 00 for no error & ;
; (BH) has current state for (BL) = 02h ;
; (CY) 01h for error & ;
; (AH) 01h ... req vbe/pm func not supported
; 02h ... req power state not supported
; Register destroyed : all general purpose except (SI) ;
;---------------------------------------------------------------;
exec_vesa_vbe_pm_func proc near
push si ;
mov ax,vesa_ext_func*256+vesa_vbe_pm_services_func; extended VESA VBE/PM function call
mov cl,[si+disp_misc_control_info] ;
and cx,vbe_pm_cntlr_mask ; (cx) = controller #
call smi_int_10h ; issue INT 10H
pop si ;
cmp al,vesa_ext_func ; VESA VBE/PM function supported ?
jnz short exec_vesa_pm_func_00 ; no...
or ah,ah ; function call failed ?
mov ah,vbe_pm_req_state_not_supported; requested state not supported
jnz short exec_vesa_pm_func_01 ; yes...
ret
exec_vesa_pm_func_00:
mov ah,vbe_pm_req_func_not_supported; requested VESA VBE/PM function not supported
exec_vesa_pm_func_01:
stc ; (CY) = 01 for error
ret
exec_vesa_vbe_pm_func endp
;---------------------------------------------------------------;
disp_power_down_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 IDE DRIVE POWER MANAGEMENT ;
; CODE TO HANDLE IDE DRIVE POWER MANAGEMENT ;
; CODE TO HANDLE IDE DRIVE POWER MANAGEMENT ;
; CODE TO HANDLE IDE DRIVE POWER MANAGEMENT ;
;---------------------------------------------------------------;
; All the code from here labelled as 'IDE_POWER_DOWN' to ;
; the label 'IDE_POWER_DOWN_ENDS' should be made active if ;
; you need to use IDE drive power down commands. ;
; Following routine needs to be called... ;
; IDE_LOW_POWER_REQUEST ;
;---------------------------------------------------------------;
IF IDE_POWER_DOWN_SUPPORT
ide_power_down label byte
;---------------------------------------------------------------;
; IDE_LOW_POWER_REQUEST ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; (DL) bit 0 = 1 ... drive 0 of primary controller;
; bit 1 = 1 ... drive 1 of primary controller;
; bit 2 = 1 ... drive 0 of secondary controller
; bit 3 = 1 ... drive 1 of secondary controller
; ;
; bit 4 = 1 ... request for standby/standby ;
; immediate command ;
; bit 5 = 1 ... request for idle/idle ;
; immediate command ;
; ;
; (DH) 0ffh do not program timer into sec count reg
; <> 0ffh program (dh) in sector count reg ;
; actual time = (dh) * 5 seconds ;
; STACK PRESENT ;
; Output: (DL) bit 0 = 1 ... drive 0 of primary controller;
; * requested and failed ;
; 0 ... drive 0 of primary controller;
; * not requested or ;
; * requested but absent or
; * requested and passed ;
; bit 1 = 1 ... drive 1 of primary controller;
; * requested and failed ;
; 0 ... drive 1 of primary controller;
; * not requested or ;
; * requested but absent or
; * requested and passed ;
; bit 2 = 1 ... drive 0 of secondary controller
; * requested and failed ;
; 0 ... drive 0 of secondary controller
; * not requested or ;
; * requested but absent or
; * requested and passed ;
; bit 3 = 1 ... drive 1 of secondary controller
; * requested and failed ;
; 0 ... drive 1 of secondary controller
; * not requested or ;
; * requested but absent or
; * requested and passed ;
; bit 7-4 ... same as input ;
; Register destroyed : (AX),(DL) ;
; ;
; This subroutine is called to write low power command to the ;
; ide drive. This routine checks for the drive presence. ;
; ;
; assumption: Hardware interrupt for the ide is masked on ;
; entry to this subroutine. ;
;---------------------------------------------------------------;
ide_low_power_request proc near
push bx ;
push cx ;
mov ch,no_of_ide_drv_supported ; check for 4 drives
mov cl,00000001b ; start with drive 0 of primary controller
mov bx,hdd_0_control_struc ; control info pointer for drive 0 of primary controller
low_power_request_00:
test dl,cl ; request for current drive ?
jz short low_power_request_01 ; no...
call ide_low_power_cmd_ext ; execute the low power command
jc short low_power_request_01 ; failed in low power request
xor dl,cl ; requested but absent/requested and passed
low_power_request_01:
shl cl,1 ; position it for next drive
add bx,struc_hdd_x_info_size ; control info pointer for next drive
dec ch ; decrement # of drives
jnz short low_power_request_00 ;
pop cx ;
pop bx ;
ret
ide_low_power_request endp
;---------------------------------------------------------------;
; IDE_LOW_POWER_CMD_EXT ;
;---------------------------------------------------------------;
; Input : (DS) PM BIOS data segment ;
; (BX) control information pointer for the drive ;
; (CL) drive# to be checked in bits 0 thru 3 ;
; (DL) bit 0 = 1 ... drive 0 of primary controller;
; bit 1 = 1 ... drive 1 of primary controller;
; bit 2 = 1 ... drive 0 of secondary controller
; bit 3 = 1 ... drive 1 of secondary controller
; ;
; bit 4 = 1 ... request for standby/standby ;
; immediate command ;
; bit 5 = 1 ... request for idle/idle ;
; immediate command ;
; ;
; (DH) 0ffh do not program timer into sec count reg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -