标题:VMWARE平台使用ACPI标准进行关机/休眠/睡眠操作
只看楼主
x64asm
Rank: 2
来 自:X64ASM
等 级:论坛游民
威 望:1
帖 子:45
专家分:36
注 册:2010-5-20
 问题点数:0 回复次数:2 
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 编辑 ]
搜索更多相关主题的帖子: 平台 睡眠 
2013-01-20 18:31
wp231957
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:神界
等 级:版主
威 望:422
帖 子:13681
专家分:53296
注 册:2012-10-18
得分:0 
只能佩服

DO IT YOURSELF !
2013-01-21 22:03
hu9jj
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:红土地
等 级:贵宾
威 望:396
帖 子:11713
专家分:43267
注 册:2006-5-13
得分:0 
好资料,留记号备查。

活到老,学到老! http://www. E-mail:hu-jj@
2013-01-22 08:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-397164-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.219035 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved