9
A
回答
7
從this有關OSDev的文章,您可以使用ACPI或APM接口。 ACPI似乎過於複雜,您可以在this article中看到,而APM更簡單。
1)安裝檢查,看看是否支持APM:因爲它們出現here我會報告的基本步驟
mov ah,53h ;this is an APM command
mov al,00h ;installation check command
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
;the function was successful
;AX = APM version number
;AH = Major revision number (in BCD format)
;AL = Minor revision number (also BCD format)
;BX = ASCII characters "P" (in BH) and "M" (in BL)
;CX = APM flags (see the official documentation for more details)
2)斷開任何現有的接口:
;disconnect from any APM interface
mov ah,53h ;this is an APM command
mov al,04h ;interface disconnect command
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
jc .disconnect_error ;if the carry flag is set see what the fuss is about.
jmp .no_error
.disconnect_error: ;the error code is in ah.
cmp ah,03h ;if the error code is anything but 03h there was an error.
jne APM_error ;the error code 03h means that no interface was connected in the first place.
.no_error:
;the function was successful
;Nothing is returned.
3)連接到實模式接口(01h):
;connect to an APM interface
mov ah,53h ;this is an APM command
mov al,[interface_number];see above description
xor bx,bx ;device id (0 = APM BIOS)
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
;the function was successful
;The return values are different for each interface.
;The Real Mode Interface returns nothing.
;See the official documentation for the
;return values for the protected mode interfaces.
4)啓用電源管理所有設備:
;Enable power management for all devices
mov ah,53h ;this is an APM command
mov al,08h ;Change the state of power management...
mov bx,0001h ;...on all devices to...
mov cx,0001h ;...power management on.
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
5)最後,電源狀態設置爲關閉(03H):
;Set the power state for all devices
mov ah,53h ;this is an APM command
mov al,07h ;Set the power state...
mov bx,0001h ;...on all devices to...
mov cx,[power_state] ;see above
int 15h ;call the BIOS function through interrupt 15h
jc APM_error ;if the carry flag is set there was an error
+0
在QEMU 2.0.0上測試Ubuntu 14.04:https://github.com/cirosantilli/x86-bare-metal-examples/blob/ 7cff2a3fc93a636f8e253892af212a30c5a58697/apm_shutdown2.S –
+0
那麼當最後的int15h返回成功時你怎麼做? – Joshua
相關問題
- 1. 處理 - 關閉計算機
- 2. 關閉計算機編程
- 3. 在x86實模式下選擇堆棧指針地址(對齊)
- 4. 計算機在運行eclipse時關閉
- 5. ThreeJS:Raycasts在某些計算機上關閉
- 6. 在系統/計算機關閉時從Outlook下載附件
- 7. 在x86和x64計算機使用Hintpath
- 8. DOS命令調出「關閉計算機」窗口?
- 9. 如何在嚴格模式下實現以下JavaScript關閉?
- 10. 從AIR/Flex關閉計算機
- 11. 使用nasm關閉計算機
- 12. 關閉計算機通過網頁
- 13. 如何從ASP.NET關閉計算機
- 14. x86和指令
- 15. 使用gdb計算機器指令
- 16. Adobe AIR的:檢查/警報/提示用戶時按下關閉計算機關閉或命令
- 17. 計算X86彙編語言代碼中的指令數
- 18. 計算模式如下
- 19. 指令不計算
- 20. 如何在32位保護模式下關閉機器
- 21. Android手機,什麼單位被關閉在睡眠模式下
- 22. 在調試模式下關閉異常
- 23. 在肖像模式下關閉縮放
- 24. 跨平臺的方式來關閉計算機
- 25. x86指令含義
- 26. 關閉指令中的模式對話框
- 27. 使用轉義鍵關閉模式的角度指令
- 28. 在netbeans中關閉計算機(關閉電源)後文件損壞
- 29. 如何在實模式下計算20位地址
- 30. 在計算機關閉時在VPS上運行SikuliX腳本?
我認爲這個問題可以幫助你:http://stackoverflow.com/questions/3145569/how-to-power-down-the-computer-from-a-freestanding-environment –