VMWARE平台使用ACPI标准进行关机/休眠/睡眠操作
使用ACPI标准来关机/休眠/睡眠,通用于DOS,WIN32/WIN64,演示代码为实模式的;版权所有:旓旓,2003-2011,保留所有权利.
;注释采用英文编写,因DOS模式不支持中文显示和输入.
.586p
.model large,stdcall
assume cs:code,ds:data,ss:stack
data segment use16
szCopyRight db "X64Asm Forum Computer Acpi Shutdown For Vmware Version 1.0.0 Build 1123",0dh,0ah
db "Copyright X64Asm Forum 2003-2011 All Rights Reserved!",0dh,0ah,0dh,0ah,"$"
szQuestion db "Do you want to Shutdown you computer now?",0dh,0ah
db "press 'y' key to shutdown your computer.",0DH,0AH,0DH,0AH,"$"
data ends
stack segment use16 para stack
bytestack db 100h dup (?)
stack ends
code segment use16
start:
mov ax,stack
mov ss,ax
mov sp,100h
mov ax,data
mov ds,ax
mov ah,9
mov dx,offset szCopyRight
int 21h
mov ah,9
mov dx,offset szQuestion
int 21h
;wait for user input
mov ah,1
int 21h
cmp al,"y"
jnz exit
;Beep Notify
MOV AH,06H
MOV DL,07H
INT 21H
;The Vmware's Default PmBase=01000H
;Read From Bus0,Device3,Function:7 Offset 040H-043H
;Base Address Is Bit 15:6
;Bit 0 Is Resource Type;
;Get PmBase Address
MOV EAX,80003B40H
MOV DX,0CF8H
OUT DX,EAX
MOV DX,0CFCH
IN EAX,DX
;Clear Resourct Type Bit
BTR EAX,0
;GetPm.PmCntrl
ADD AX,SIZEOF DWORD
;Read Pm.PmCntrl(PmBase+04H) I/O Port
MOV DX,AX
XOR EAX,EAX
IN AX,DX
;Set Bit 12:10,SuSpendType=000(S5)
AND AX,0E3FFH
;Set Bit 13 ,SuSpend Enable=1(Enable)
OR AX,2000H
;Write Pm.PmCntrl(PmBase+04H) I/O Port
OUT DX,AX
exit:
MOV AX,4C00H
INT 21H
code ends
end start
至于睡眠,休眠,将SUS_TYP置位对应的位即可,不再赘述.
请参考INTEL 82371芯片手册,如下图.
[ 本帖最后由 x64asm 于 2013-1-20 18:35 编辑 ]