?? power.asm
字號(hào):
Pwr_i25_next dw Pwr_i25_lab
dw Bios_Data
Pwr_i25_lab:
pop ds
jmp dword ptr cs:I25_Vec
Pwr_i26_next dw Pwr_i26_lab
dw Bios_Data
Pwr_i26_lab:
pop ds
jmp dword ptr cs:I26_Vec
Pwr_i6c_next dw Pwr_i6c_lab ;M080
dw Bios_Data ;M080
Pwr_i6c_lab: ;M080
pop ds ;M080
jmp dword ptr cs:I6c_Vec ;M080
End_Data label near
tocode ;Bios_Code segment starts
IFDEF POWERALONE ; device header needed here only for
; standalone version - in MSBIO1 for resident
assume ds:nothing
org 0
DEV_HDR dd CDEV_HDR ; address of next driver in chain
dw 8000H ; character device ; M003
dw DEV_STRATEGY ; DOS entry points to driver
dw DEV_INTERRUPT ;
db 'POWER$ ' ; driver name
CDEV_HDR dd -1 ; address of next dev hdr in chain
dw 8008h ; CLOCK device (& character)
dw DEV_STRATEGY
dw CDEV_INTERRUPT
db 'CLOCK$ ' ; driver name
;*************** DOS DEVICE REQUEST DEFINITIONS **************
; void DEV_STRATEGY( ES:BX.DOS_REQUEST_HEADER)
; purpose: Store DOS REQUEST HEADER (ES:BX) for
; DEV_INTERRUPT routine
DEV_STRATEGY proc far
push ds
mov ds,cs:Bios_Data_Word
assume ds:Bios_Data
mov word ptr [RHPTR]+0,bx
mov word ptr [RHPTR]+2,es
pop ds
assume ds:nothing
ret
DEV_STRATEGY endp
; void DEV_INTERRUPT( [REQHDR].DOS_REQUEST_HEADER)
; purpose: Executes DOS request; only one fuction is ; M003
; supportted by this driver: INIT ; M003
DEV_INTERRUPT proc far
push ax
push dx
push bx
push es
push ds
mov ds,cs:Bios_Data_Word
assume ds:Bios_Data
les bx,[RHPTR]
cmp es:[bx].RH_B_CMD,DEVINIT ; DEVICE INIT?
jne dstot0
call far ptr Power_Init
jmp short dstex0
; M003 : remove ioctl support
dstot0:
; cmp es:[bx].RH_B_CMD,DEVRDIOCTL ; DEVICE IOCTL READ?
; jne dstxxx
; call Power_IOCTL_Read
; jmp short dstex0
;
; M003: END
dstxxx: mov ax,STERR+03H ; RETURN DEVICE ERROR,
; ILLEGAL COMMAND
dstex0: les bx,[RHPTR]
mov es:[bx].RH_W_STATUS,ax
pop ds
assume ds:nothing
pop es
pop bx
pop dx
pop ax
ret
DEV_INTERRUPT endp
Bios_Data_Word dw Bios_Data ; Our data segment
extrn tim_read:near
extrn tim_writ:near
extrn P_UpdFromCMOS:far ; M081
public tim_table
tim_table label byte
db (((offset tim_table_end) - (offset tim_table) -1)/2)
dw Normal_exit ; 00 init
dw Normal_exit ; 01
dw Normal_exit ; 02
dw Cldev_cmderr ; 03
dw tim_read ; 04
dw Cldev_BusyErr ; 05
dw Normal_exit ; 06
dw Normal_exit ; 07
dw tim_writ ; 08
dw tim_writ ; 09
tim_table_end:
CDEV_INTERRUPT proc far
assume cs:Bios_Code,ds:nothing
push si
push ax
push bx
push cx
push dx
push di
push ds
push es
lea si,tim_table
mov ds,cs:Bios_Data_Word
assume ds:Bios_Data
les bx,[RHPTR]
mov al,es:[bx].RH_B_CMD ; al = cmd
cmp al,cs:[si]
jae Cldev_cmd_error
or al,al ; is it init call
jz Cldev_Init
cbw ; note that al <= 15 means ok
shl ax,1
add si,ax
les di, es:[bx].trans ; M082
cld ; ***** always clear direction
call cs:word ptr [si+1] ;go do command
assume ds:nothing
jc Cldev_set_stat ; if function returned status, don't
Cldev_Success:
mov ah,1 ; load with normal completion
Cldev_set_stat:
mov ds,Bios_Data_Word ; cas///// note: shouldn't be needed!
assume ds:Bios_Data
les bx,[RHPTR]
mov word ptr es:[bx].status,ax ;mark operation complete
pop es
pop ds
pop di
pop dx
pop cx
pop bx
pop ax
pop si
ret
Cldev_cmd_error:
mov ax,STERR+03H ; RETURN DEVICE ERROR,
; ILLEGAL COMMAND
jmp short Cldev_set_stat
Cldev_Init:
call far ptr Clock_Init
IFDEF POWERALONE ; M085
; Return DEVICE DRIVER end address
les bx,[RHPTR]
mov word ptr es:[bx].RH_D_BREAKPTR+0,offset Bios_Data:End_Data
mov word ptr es:[bx].RH_D_BREAKPTR+2,ds
ENDIF ; M085
jmp short Cldev_Success
CDEV_INTERRUPT endp
Cldev_cmderr proc near
mov al,3 ; unknown command error
mov ah,81h ; error return
Cldev_Ret:
stc ; indicate abnormal end
ret
Cldev_BusyErr label near
mov ah,3 ; indicate busy status
jmp short Cldev_Ret
Cldev_cmderr endp
ELSE ; resident driver version
extrn Bios_Data_Word:word ; supplied externally
public power_table
power_table:
db (((offset power_table_end) - (offset power_table) - 1) / 2)
dw Normal_exit
dw Normal_exit
dw Normal_exit
; M003 : BEGIN ; remove ioctl support
; dw Power_ioctl_read
dw Normal_exit
; M003 : END
power_table_end:
ENDIF ; resident driver version
Normal_exit proc near
clc
ret
Normal_exit endp
;
; M003: BEGIN ; remove ioctl support
;
IF 0
Power_ioctl_read proc near
assume ds:Bios_Data
push es
push di
cmp es:[bx].RH_W_XFERCNT,32 ; get transfer size
je dirot0
mov es:[bx].RH_W_XFERCNT,0 ; invalid size non-transfered
jmp short dirxxx
dirot0: les di,es:[bx].RH_D_XFERPTR ; address of read block
mov word ptr es:[di].PIB_ENTRY_OFFSET,offset EntryPoint
mov word ptr es:[di].PIB_ENTRY_SEG,ds
mov byte ptr es:[di].PIB_VERSION,POW_VERSION
dirxxx: pop di
pop es
clc
ret
power_ioctl_read endp
PUBLIC Pow_control
Pow_control proc far
assume ds:nothing, es:nothing
; M001 - NSM all these functions except IDLE_INFO have been replaced
; by equivalent INT 2f functions
cmp ah,POW_GET_CONTROL_INFO ; return CONTROL_INFO pointer
jnz pclot0
mov dx,cs:Bios_Data_Word
mov ax,offset CONTROL
mov cx,size CONTROL_INFO
jmp short pclex0
pclot0: cmp ah,POW_GET_STATS ; return IDLE_INFO pointer
jne pclot1
mov dx,cs:Bios_Data_Word
mov ax,offset INFO
mov cx,size IDLE_INFO
jmp short pclex0
pclot1: cmp ah,POW_DO_IDLE ; return call DO_IDLE direct
jne pclot2
push ds
mov ds,cs:Bios_Data_Word
assume ds:Bios_Data
call CheckV86 ; AVOID IN V86
pop ds
assume ds:nothing
jnz pclex0
push ds
mov ds,cs:Bios_Data_Word
assume ds:Bios_Data
call DO_IDLE ; return CY set if idle
pop ds
assume ds:nothing
jmp short pclxxx
; M001 -nsm - commented out
pclot2: cmp ah,0feh ; Return POWER_DATA
jne pclerr ; address ES:BX
mov es,cs:Bios_Data_Word ; special function for cstat
mov bx,offset POWER_DATA
pclex0: clc ; return no error
ret
pclot2: ; falls through to error
pclerr: mov ax,-1 ; INVALID OPERATION
stc
pclxxx: ret
Pow_control endp
ENDIF ; the code above is commented out - M003 END
;******************** INT 2F routine for POWER services *************
; Entry: AL = function code
; 0 Install check
;
; EXIT:
; BX = 504dH (PM) signature if installed /* M087 */
;
; 1 GET/(Enable/Disable) Power management
; BH = 0 -> get POWER enabled status
; = 1 -> ENABLE DISABLE POWER
; BL:bit 0 =T enable Idle detection
; =F disable Idle detection
; BL:bit 1 =T enable FW/APM
; =F disable FW/APM
; EXIT:
; BH = Prev. Power status (bit 0 & 1 as defined above)
; BL = Current power status
; CY set if function failed
;
; 2 Get/Set Idle Detection Alg
; BH = 0 -> Get Current idle detection alg.
; = 1 -> set Current alg.
; BL:bit 0 -> T - AUTO SELECT
; bit 1 -> T - App Idle (int 2f 1680)
; bit 2 -> T - Dos Yield (int 28)
; bit 3 -> T - Keyboard idle (int 16)
; BL = 0 -> disable Idle detecion
; EXIT:
; BL = current alg if Get_ALG
;
; 80 Get/Set Idle Detection Tuning parameters
; BX = 0 -> get
; else Set
; CX = size of buffer
; DS:SI -> ptr to buffer
; 81 Get Statistics
; CX = size of buffer
; DS:SI -> ptr to buffer
;
; 82 Get/Set APM polling count
; BX = 0 -> get APM polling count
; else new polling count to be set
; EXIT:
; BL = new polling count
;
; M001: Created - NSM
;
Pwr_Services proc near
push ds
cmp al,I2F_PW_INSTALL_CHK ; install check
je PS_Install_Chk
;
cmp al,I2F_PW_GET_SET_PWSTATE ; enable/disable PW MGMT
jne PS_Chk_SelAlg
jmp PS_GetSet_PWState
;
PS_Chk_SelAlg:
cmp al,I2F_PW_SELECT_ALG ; select Idle Detection Alg
je PS_Select_Alg
;
cmp al,I2f_PW_TUNE_PARM ; Idle detect. parm. Get/Set
je PS_Parm_Tune
;
cmp al,I2F_PW_APM_POLLCOUNT ; Get/Set APM poll count
je PS_APM_PollCount
;
cmp al,I2F_PW_GETSET_BASELINE
jne PS_ChkGetStat
jmp PS_GetSet_BaseLine
;
PS_ChkGetStat:
cmp al,I2F_PW_GET_STATS ; Get Idle Detect stats
je PS_Get_Stats
;
mov ax,ERROR_PM_FUNCTION_NOT_SUPPORTED
PS_FRet:
stc
jmp PS_Ret
PS_Install_Chk:
mov bx,504dH ; "PM" ;M087
mov ah,POW_MAJ_VERSION ; M084 major version no
mov al,POW_MIN_VERSION ; M084
clc ; M084
jmp PS_Ret ; M084
;
PS_Select_Alg:
mov ds,cs:Bios_Data_Word
assume ds:Bios_Data
IFDEF DEBUG
cmp bl,80h ; SOUND toggle
je PS_Toggle_Sound
ENDIF
or bh,bh ; get current algorithm
je PS_Get_Alg
test bl,ALG_RESERVED_BITS
jnz PS_Inv_Parm_Err
;
PS_Alg_OK:
xor bh,bh
shl bx,1 ; rotate the given alg.bits to the IDLE_FLG format
shl bx,1
and [CONTROL].IDLE_FLG,NOT ( AUTO_ACTIVE+APP_ACTIVE+DOS_ACTIVE+KYC_ACTIVE)
or [CONTROL].IDLE_FLG,bx
; M094 - Fall through to return the current algorithm in BL
PS_Get_Alg:
mov bx,[CONTROL].IDLE_FLG
and bx,( AUTO_ACTIVE+APP_ACTIVE+DOS_ACTIVE+KYC_ACTIVE) ; M075
shr bx,1 ; put this info into the desired
shr bx,1 ; API output format
jmp short PS_SRet
IFDEF DEBUG ;Toggle sound only for DEBUG VERSION
PS_Toggle_Sound:
xor [CONTROL].IDLE_FLG,SOUND_ACTIVE ; toggle the sound flag
jmp short PS_SRet
ENDIF
PS_APM_PollCount: ; 7 change APM poll count
call Do_APM_GetSet_PollCount
jmp short PS_SRet
assume ds:nothing
;
PS_Parm_Tune: ; 4 Tune various POWER.SYS parameters
cmp cx, size CONTROL_INFO - SWITCH_DLY
jb PS_Buff_Ovf_Err
push si ; M086
push di
push es
mov es,Bios_Data_Word
assume es:Bios_Data
lea di,[CONTROL].SWITCH_DLY
assume es:nothing
or bx,bx ; get parm or set parm ?
jnz PS_DoCopy ; if set parm
mov bx,-1
PS_Exch_ESDS_SIDI:
push es
push ds
pop es
pop ds
xchg si,di
or bx,bx
jz PS_EndCopy
PS_DoCopy:
rep movsb ; transfer data
inc bx
jz PS_Exch_ESDS_SIDI
PS_EndCopy:
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -